diff --git a/.changeset/afraid-glasses-carry.md b/.changeset/afraid-glasses-carry.md deleted file mode 100644 index 924fb056..00000000 --- a/.changeset/afraid-glasses-carry.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"planck": patch ---- - -Improve world.queueUpdate diff --git a/.changeset/sour-news-float.md b/.changeset/sour-news-float.md deleted file mode 100644 index 0e8bc986..00000000 --- a/.changeset/sour-news-float.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"planck": minor ---- - -Add world.queueUpdate() to queue and defer updates after current simulation step diff --git a/CHANGELOG.md b/CHANGELOG.md index 61d0ea93..092a01c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # planck +## 1.2.0 + +### Minor Changes + +- f0127f4: Add world.queueUpdate() to queue and defer updates after current simulation step + +### Patch Changes + +- 97bb79e: Improve world.queueUpdate + ## 1.1.6 ### Patch Changes diff --git a/dist/planck-with-testbed.d.ts b/dist/planck-with-testbed.d.ts index 29a5041a..9eb305a9 100644 --- a/dist/planck-with-testbed.d.ts +++ b/dist/planck-with-testbed.d.ts @@ -1596,6 +1596,8 @@ declare class Body$1 { /** * Set the type of the body to "static", "kinematic" or "dynamic". * @param type The type of the body. + * + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. */ setType(type: BodyType): void; isBullet(): boolean; @@ -1625,6 +1627,8 @@ declare class Body$1 { * in collisions, ray-casts, or queries. Joints connected to an inactive body * are implicitly inactive. An inactive body is still owned by a World object * and remains + * + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. */ setActive(flag: boolean): void; isFixedRotation(): boolean; @@ -1641,6 +1645,8 @@ declare class Body$1 { * transform may cause non-physical behavior. Note: contacts are updated on the * next call to World.step. * + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. + * * @param position The world position of the body's local origin. * @param angle The world rotation in radians. */ @@ -1649,6 +1655,8 @@ declare class Body$1 { * Set the position of the body's origin and rotation. Manipulating a body's * transform may cause non-physical behavior. Note: contacts are updated on the * next call to World.step. + * + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. */ setTransform(xf: Transform): void; synchronizeTransform(): void; @@ -1751,6 +1759,8 @@ declare class Body$1 { * destroying fixtures can also alter the mass. This function has no effect if * the body isn't dynamic. * + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. + * * @param massData The mass properties. */ setMassData(massData: MassData): void; @@ -1812,7 +1822,7 @@ declare class Body$1 { * * Contacts are not created until the next time step. * - * Warning: This function is locked during callbacks. + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. */ createFixture(def: FixtureDef): Fixture; createFixture(shape: Shape, opt?: FixtureOpt): Fixture; @@ -1824,7 +1834,7 @@ declare class Body$1 { * All fixtures attached to a body are implicitly destroyed when the body is * destroyed. * - * Warning: This function is locked during callbacks. + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. * * @param fixture The fixture to be removed. */ @@ -2074,13 +2084,15 @@ export declare class World { * position -= newOrigin * * @param newOrigin The new origin with respect to the old origin + * + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. */ shiftOrigin(newOrigin: Vec2Value): void; /** * Create a rigid body given a definition. No reference to the definition is * retained. * - * Warning: This function is locked during callbacks. + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. */ createBody(def?: BodyDef): Body$1; createBody(position: Vec2Value, angle?: number): Body$1; @@ -2089,24 +2101,26 @@ export declare class World { createKinematicBody(def?: BodyDef): Body$1; createKinematicBody(position: Vec2Value, angle?: number): Body$1; /** - * Destroy a rigid body given a definition. No reference to the definition is - * retained. + * Destroy a body from the world. * * Warning: This automatically deletes all associated shapes and joints. * - * Warning: This function is locked during callbacks. + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. */ destroyBody(b: Body$1): boolean; /** * Create a joint to constrain bodies together. No reference to the definition * is retained. This may cause the connected bodies to cease colliding. * - * Warning: This function is locked during callbacks. + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. */ createJoint(joint: T): T | null; /** - * Destroy a joint. This may cause the connected bodies to begin colliding. - * Warning: This function is locked during callbacks. + * Destroy a joint. + * + * Warning: This may cause the connected bodies to begin colliding. + * + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. */ destroyJoint(joint: Joint): void; /** @@ -2118,6 +2132,10 @@ export declare class World { * @param timeStep Time step, this should not vary. */ step(timeStep: number, velocityIterations?: number, positionIterations?: number): void; + /** + * Queue a function to be called after ongoing simulation step. If no simulation is in progress call it immediately. + */ + queueUpdate(callback: (world: World) => unknown): void; /** * Called when two fixtures begin to touch. * diff --git a/dist/planck-with-testbed.js b/dist/planck-with-testbed.js index 2b8bf284..fa973594 100644 --- a/dist/planck-with-testbed.js +++ b/dist/planck-with-testbed.js @@ -2,7 +2,7 @@ typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.planck = {})); })(this, function(exports2) { "use strict";/** - * Planck.js v1.1.6 + * Planck.js v1.2.0 * @license The MIT license * @copyright Copyright (c) 2024 Erin Catto, Ali Shakiba * @@ -5953,6 +5953,7 @@ this.m_velocityIterations = def.velocityIterations; this.m_positionIterations = def.positionIterations; this.m_t = 0; + this.m_step_callback = []; } World2.prototype._serialize = function() { var bodies = []; @@ -6099,7 +6100,7 @@ return this.m_broadPhase.getTreeQuality(); }; World2.prototype.shiftOrigin = function(newOrigin) { - if (this.m_locked) { + if (this.isLocked()) { return; } for (var b2 = this.m_bodyList; b2; b2 = b2.m_next) { @@ -6331,8 +6332,19 @@ this.clearForces(); } this.m_locked = false; + var callback; + while (callback = this.m_step_callback.shift()) { + callback(this); + } this.publish("post-step", timeStep); }; + World2.prototype.queueUpdate = function(callback) { + if (!this.isLocked()) { + callback(this); + } else { + this.m_step_callback.push(callback); + } + }; World2.prototype.findNewContacts = function() { var _this = this; this.m_broadPhase.updatePairs(function(proxyA, proxyB) { diff --git a/dist/planck-with-testbed.js.map b/dist/planck-with-testbed.js.map index 392c3086..c6618653 100644 --- a/dist/planck-with-testbed.js.map +++ b/dist/planck-with-testbed.js.map @@ -1 +1 @@ -{"version":3,"file":"planck-with-testbed.js","sources":["../node_modules/tslib/tslib.es6.js","../src/util/options.ts","../src/common/Math.ts","../src/common/Vec2.ts","../src/collision/AABB.ts","../src/Settings.ts","../src/util/Pool.ts","../src/collision/DynamicTree.ts","../src/collision/BroadPhase.ts","../src/common/Matrix.ts","../src/common/Rot.ts","../src/common/Sweep.ts","../src/common/Transform.ts","../src/dynamics/Velocity.ts","../src/dynamics/Position.ts","../src/collision/Shape.ts","../src/dynamics/Fixture.ts","../src/dynamics/Body.ts","../src/dynamics/Joint.ts","../src/util/stats.ts","../src/util/Timer.ts","../src/collision/Distance.ts","../src/collision/TimeOfImpact.ts","../src/dynamics/Solver.ts","../src/common/Mat22.ts","../src/collision/Manifold.ts","../src/dynamics/Contact.ts","../src/dynamics/World.ts","../src/common/Vec3.ts","../src/collision/shape/EdgeShape.ts","../src/collision/shape/ChainShape.ts","../src/collision/shape/PolygonShape.ts","../src/collision/shape/CircleShape.ts","../src/dynamics/joint/DistanceJoint.ts","../src/dynamics/joint/FrictionJoint.ts","../src/common/Mat33.ts","../src/dynamics/joint/RevoluteJoint.ts","../src/dynamics/joint/PrismaticJoint.ts","../src/dynamics/joint/GearJoint.ts","../src/dynamics/joint/MotorJoint.ts","../src/dynamics/joint/MouseJoint.ts","../src/dynamics/joint/PulleyJoint.ts","../src/dynamics/joint/RopeJoint.ts","../src/dynamics/joint/WeldJoint.ts","../src/dynamics/joint/WheelJoint.ts","../src/serializer/index.ts","../src/util/Testbed.ts","../src/collision/shape/BoxShape.ts","../src/collision/shape/CollideCircle.ts","../src/collision/shape/CollideEdgeCircle.ts","../src/collision/shape/CollidePolygon.ts","../src/collision/shape/CollideCirclePolygon.ts","../src/collision/shape/CollideEdgePolygon.ts","../src/internal.ts","../node_modules/stage-js/dist/stage.js","../testbed/StageTestbed.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from) {\r\n for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)\r\n to[j] = from[i];\r\n return to;\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","/** @internal */\nexport const options = function(input: T, defaults: object): T {\n if (input === null || typeof input === \"undefined\") {\n // tslint:disable-next-line:no-object-literal-type-assertion\n input = {} as T;\n }\n\n const output = {...input};\n\n // tslint:disable-next-line:no-for-in\n for (const key in defaults) {\n if (defaults.hasOwnProperty(key) && typeof input[key] === \"undefined\") {\n output[key] = defaults[key];\n }\n }\n\n if (typeof Object.getOwnPropertySymbols === \"function\") {\n const symbols = Object.getOwnPropertySymbols(defaults);\n for (let i = 0; i < symbols.length; i++) {\n const symbol = symbols[i];\n if (defaults.propertyIsEnumerable(symbol) && typeof input[symbol] === \"undefined\") {\n output[symbol] = defaults[symbol];\n }\n }\n }\n\n return output;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_random = Math.random;\n\n\nexport const EPSILON = 1e-9;\n\n/** @internal @deprecated */\nexport const isFinite = Number.isFinite;\n\n/**\n * @deprecated\n * Next Largest Power of 2 Given a binary integer value x, the next largest\n * power of 2 can be computed by a SWAR algorithm that recursively \"folds\" the\n * upper bits into the lower bits. This process yields a bit vector with the\n * same most significant 1 as x, but all 1's below it. Adding 1 to that value\n * yields the next largest power of 2. For a 32-bit value:\n */\nexport function nextPowerOfTwo(x: number): number {\n x |= (x >> 1);\n x |= (x >> 2);\n x |= (x >> 4);\n x |= (x >> 8);\n x |= (x >> 16);\n return x + 1;\n}\n\n/** @deprecated */\nexport function isPowerOfTwo(x: number): boolean {\n return x > 0 && (x & (x - 1)) === 0;\n}\n\n/** @deprecated */\nexport function mod(num: number, min?: number, max?: number): number {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n if (max > min) {\n num = (num - min) % (max - min);\n return num + (num < 0 ? max : min);\n } else {\n num = (num - max) % (min - max);\n return num + (num <= 0 ? min : max);\n }\n}\n\n/**\n * @deprecated\n * Returns a min if num is less than min, and max if more than max, otherwise returns num.\n */\nexport function clamp(num: number, min: number, max: number): number {\n if (num < min) {\n return min;\n } else if (num > max) {\n return max;\n } else {\n return num;\n }\n}\n\n/**\n * @deprecated\n * Returns a random number between min and max when two arguments are provided.\n * If one arg is provided between 0 to max.\n * If one arg is passed between 0 to 1.\n */\nexport function random(min?: number, max?: number): number {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n return min === max ? min : math_random() * (max - min) + min;\n}\n\n/** @ignore */\nexport const math = Object.create(Math);\nmath.EPSILON = EPSILON;\nmath.isFinite = isFinite;\nmath.nextPowerOfTwo = nextPowerOfTwo;\nmath.isPowerOfTwo = isPowerOfTwo;\nmath.mod = mod;\nmath.clamp = clamp;\nmath.random = random;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { clamp, EPSILON } from \"./Math\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/** 2D vector */\nexport interface Vec2Value {\n x: number;\n y: number;\n}\n\ndeclare module \"./Vec2\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(x: number, y: number): Vec2;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(obj: Vec2Value): Vec2;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(): Vec2;\n}\n\n/** 2D vector */\n// @ts-expect-error\nexport class Vec2 {\n x: number;\n y: number;\n\n constructor(x: number, y: number);\n constructor(obj: Vec2Value);\n constructor();\n // tslint:disable-next-line:typedef\n constructor(x?, y?) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Vec2)) {\n return new Vec2(x, y);\n }\n if (typeof x === \"undefined\") {\n this.x = 0;\n this.y = 0;\n } else if (typeof x === \"object\") {\n this.x = x.x;\n this.y = x.y;\n } else {\n this.x = x;\n this.y = y;\n }\n if (_ASSERT) Vec2.assert(this);\n }\n\n /** @internal */\n _serialize(): object {\n return {\n x: this.x,\n y: this.y\n };\n }\n\n /** @internal */\n static _deserialize(data: any): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = data.x;\n obj.y = data.y;\n return obj;\n }\n\n static zero(): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = 0;\n obj.y = 0;\n return obj;\n }\n\n /** @hidden */\n static neo(x: number, y: number): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = x;\n obj.y = y;\n return obj;\n }\n\n static clone(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(v.x, v.y);\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n /**\n * Does this vector contain finite coordinates?\n */\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.x) && Number.isFinite(obj.y);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Vec2.isValid(o), \"Invalid Vec2!\", o);\n }\n\n clone(): Vec2 {\n return Vec2.clone(this);\n }\n\n /**\n * Set this vector to all zeros.\n *\n * @returns this\n */\n setZero(): Vec2 {\n this.x = 0.0;\n this.y = 0.0;\n return this;\n }\n\n set(x: number, y: number): Vec2;\n set(value: Vec2Value): Vec2;\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n // tslint:disable-next-line:typedef\n set(x, y?) {\n if (typeof x === \"object\") {\n if (_ASSERT) Vec2.assert(x);\n this.x = x.x;\n this.y = x.y;\n } else {\n if (_ASSERT) console.assert(Number.isFinite(x));\n if (_ASSERT) console.assert(Number.isFinite(y));\n this.x = x;\n this.y = y;\n }\n return this;\n }\n\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n setNum(x: number, y: number) {\n if (_ASSERT) console.assert(Number.isFinite(x));\n if (_ASSERT) console.assert(Number.isFinite(y));\n this.x = x;\n this.y = y;\n\n return this;\n }\n\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n setVec2(value: Vec2Value) {\n if (_ASSERT) Vec2.assert(value);\n this.x = value.x;\n this.y = value.y;\n\n return this;\n }\n\n /** @internal @deprecated Use setCombine or setMul */\n wSet(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.setCombine(a, v, b, w);\n } else {\n return this.setMul(a, v);\n }\n }\n\n /**\n * Set linear combination of v and w: `a * v + b * w`\n */\n setCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x = x;\n this.y = y;\n return this;\n }\n\n setMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x = x;\n this.y = y;\n return this;\n }\n\n /**\n * Add a vector to this vector.\n *\n * @returns this\n */\n add(w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(w);\n this.x += w.x;\n this.y += w.y;\n return this;\n }\n\n /** @internal @deprecated Use addCombine or addMul */\n wAdd(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.addCombine(a, v, b, w);\n } else {\n return this.addMul(a, v);\n }\n }\n\n /**\n * Add linear combination of v and w: `a * v + b * w`\n */\n addCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x += x;\n this.y += y;\n return this;\n }\n\n addMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x += x;\n this.y += y;\n return this;\n }\n\n /**\n * @deprecated Use subCombine or subMul\n */\n wSub(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.subCombine(a, v, b, w);\n } else {\n return this.subMul(a, v);\n }}\n\n /**\n * Subtract linear combination of v and w: `a * v + b * w`\n */\n subCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x -= x;\n this.y -= y;\n return this;\n }\n\n subMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x -= x;\n this.y -= y;\n return this;\n }\n\n /**\n * Subtract a vector from this vector\n *\n * @returns this\n */\n sub(w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(w);\n this.x -= w.x;\n this.y -= w.y;\n return this;\n }\n\n /**\n * Multiply this vector by a scalar.\n *\n * @returns this\n */\n mul(m: number): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(m));\n this.x *= m;\n this.y *= m;\n return this;\n }\n\n /**\n * Get the length of this vector (the norm).\n *\n * For performance, use this instead of lengthSquared (if possible).\n */\n length(): number {\n return Vec2.lengthOf(this);\n }\n\n /**\n * Get the length squared.\n */\n lengthSquared(): number {\n return Vec2.lengthSquared(this);\n }\n\n /**\n * Convert this vector into a unit vector.\n *\n * @returns old length\n */\n normalize(): number {\n const length = this.length();\n if (length < EPSILON) {\n return 0.0;\n }\n const invLength = 1.0 / length;\n this.x *= invLength;\n this.y *= invLength;\n return length;\n }\n\n /**\n * Returns a new unit vector from the provided vector.\n *\n * @returns new unit vector\n */\n static normalize(v: Vec2Value): Vec2 {\n const length = Vec2.lengthOf(v);\n if (length < EPSILON) {\n return Vec2.zero();\n }\n const invLength = 1.0 / length;\n return Vec2.neo(v.x * invLength, v.y * invLength);\n }\n\n /**\n * Get the length of this vector (the norm).\n *\n * For performance, use this instead of lengthSquared (if possible).\n */\n static lengthOf(v: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n return math_sqrt(v.x * v.x + v.y * v.y);\n }\n\n /**\n * Get the length squared.\n */\n static lengthSquared(v: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n return v.x * v.x + v.y * v.y;\n }\n\n static distance(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n const dx = v.x - w.x;\n const dy = v.y - w.y;\n return math_sqrt(dx * dx + dy * dy);\n }\n\n static distanceSquared(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n const dx = v.x - w.x;\n const dy = v.y - w.y;\n return dx * dx + dy * dy;\n }\n\n static areEqual(v: Vec2Value, w: Vec2Value): boolean {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v === w || typeof w === \"object\" && w !== null && v.x === w.x && v.y === w.y;\n }\n\n /**\n * Get the skew vector such that dot(skew_vec, other) == cross(vec, other)\n */\n static skew(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(-v.y, v.x);\n }\n\n /** Dot product on two vectors */\n static dot(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.x + v.y * w.y;\n }\n\n /** Cross product between two vectors */\n static cross(v: Vec2Value, w: Vec2Value): number;\n /** Cross product between a vector and a scalar */\n static cross(v: Vec2Value, w: number): Vec2;\n /** Cross product between a scalar and a vector */\n static cross(v: number, w: Vec2Value): Vec2;\n static cross(v: any, w: any): any {\n if (typeof w === \"number\") {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y, -w * v.x);\n\n } else if (typeof v === \"number\") {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y, v * w.x);\n\n } else {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.y - v.y * w.x;\n }\n }\n\n /** Cross product on two vectors */\n static crossVec2Vec2(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.y - v.y * w.x;\n }\n\n /** Cross product on a vector and a scalar */\n static crossVec2Num(v: Vec2Value, w: number): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y, -w * v.x);\n }\n\n /** Cross product on a vector and a scalar */\n static crossNumVec2(v: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y, v * w.x);\n }\n\n /** Returns `a + (v x w)` */\n static addCross(a: Vec2Value, v: Vec2Value, w: number): Vec2;\n /** Returns `a + (v x w)` */\n static addCross(a: Vec2Value, v: number, w: Vec2Value): Vec2;\n static addCross(a: Vec2Value, v: any, w: any): Vec2 {\n if (typeof w === \"number\") {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y + a.x, -w * v.x + a.y);\n\n } else if (typeof v === \"number\") {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y + a.x, v * w.x + a.y);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n /**\n * Returns `a + (v x w)`\n */\n static addCrossVec2Num(a: Vec2Value, v: Vec2Value, w: number): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y + a.x, -w * v.x + a.y);\n }\n\n /**\n * Returns `a + (v x w)`\n */\n static addCrossNumVec2(a: Vec2Value, v: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y + a.x, v * w.x + a.y);\n }\n\n static add(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(v.x + w.x, v.y + w.y);\n }\n\n /** @hidden @deprecated */\n static wAdd(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return Vec2.combine(a, v, b, w);\n } else {\n return Vec2.mulNumVec2(a, v);\n }\n }\n\n static combine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n return Vec2.zero().setCombine(a, v, b, w);\n }\n\n static sub(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(v.x - w.x, v.y - w.y);\n }\n\n static mul(a: Vec2Value, b: number): Vec2;\n static mul(a: number, b: Vec2Value): Vec2;\n static mul(a: any, b: any): Vec2 {\n if (typeof a === \"object\") {\n if (_ASSERT) Vec2.assert(a);\n if (_ASSERT) console.assert(Number.isFinite(b));\n return Vec2.neo(a.x * b, a.y * b);\n\n } else if (typeof b === \"object\") {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(b);\n return Vec2.neo(a * b.x, a * b.y);\n }\n }\n\n static mulVec2Num(a: Vec2Value, b: number): Vec2 {\n if (_ASSERT) Vec2.assert(a);\n if (_ASSERT) console.assert(Number.isFinite(b));\n return Vec2.neo(a.x * b, a.y * b);\n }\n\n static mulNumVec2(a: number, b: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(b);\n return Vec2.neo(a * b.x, a * b.y);\n }\n\n neg(): Vec2 {\n this.x = -this.x;\n this.y = -this.y;\n return this;\n }\n\n static neg(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(-v.x, -v.y);\n }\n\n static abs(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(math_abs(v.x), math_abs(v.y));\n }\n\n static mid(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo((v.x + w.x) * 0.5, (v.y + w.y) * 0.5);\n }\n\n static upper(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(math_max(v.x, w.x), math_max(v.y, w.y));\n }\n\n static lower(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(math_min(v.x, w.x), math_min(v.y, w.y));\n }\n\n clamp(max: number): Vec2 {\n const lengthSqr = this.x * this.x + this.y * this.y;\n if (lengthSqr > max * max) {\n const scale = max / math_sqrt(lengthSqr);\n this.x *= scale;\n this.y *= scale;\n }\n return this;\n }\n\n static clamp(v: Vec2Value, max: number): Vec2 {\n const r = Vec2.neo(v.x, v.y);\n r.clamp(max);\n return r;\n }\n\n /** @hidden */\n static clampVec2(v: Vec2Value, min?: Vec2Value, max?: Vec2Value): Vec2Value {\n return {\n x: clamp(v.x, min?.x, max?.x),\n y: clamp(v.y, min?.y, max?.y)\n };\n }\n\n /** @hidden @deprecated */\n static scaleFn(x: number, y: number) {\n // todo: this was used in examples, remove in the future\n return function(v: Vec2Value): Vec2 {\n return Vec2.neo(v.x * x, v.y * y);\n };\n }\n\n /** @hidden @deprecated */\n static translateFn(x: number, y: number) {\n // todo: this was used in examples, remove in the future\n return function(v: Vec2Value): Vec2 {\n return Vec2.neo(v.x + x, v.y + y);\n };\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { EPSILON } from \"../common/Math\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n/**\n * Ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n */\nexport interface RayCastInput {\n p1: Vec2Value;\n p2: Vec2Value;\n maxFraction: number;\n}\n\nexport type RayCastCallback = (subInput: RayCastInput, id: number) => number;\n\n/**\n * Ray-cast output data. The ray hits at `p1 + fraction * (p2 - p1)`,\n * where `p1` and `p2` come from RayCastInput.\n */\nexport interface RayCastOutput {\n normal: Vec2;\n fraction: number;\n}\n\n/** Axis-aligned bounding box */\nexport interface AABBValue {\n lowerBound: Vec2Value;\n upperBound: Vec2Value;\n}\n\ndeclare module \"./AABB\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function AABB(lower?: Vec2Value, upper?: Vec2Value): AABB;\n}\n\n/** Axis-aligned bounding box */\n// @ts-expect-error\nexport class AABB {\n lowerBound: Vec2;\n upperBound: Vec2;\n\n constructor(lower?: Vec2Value, upper?: Vec2Value) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof AABB)) {\n return new AABB(lower, upper);\n }\n\n this.lowerBound = Vec2.zero();\n this.upperBound = Vec2.zero();\n\n if (typeof lower === \"object\") {\n this.lowerBound.setVec2(lower);\n }\n if (typeof upper === \"object\") {\n this.upperBound.setVec2(upper);\n } else if (typeof lower === \"object\") {\n this.upperBound.setVec2(lower);\n }\n }\n\n /**\n * Verify that the bounds are sorted.\n */\n isValid(): boolean {\n return AABB.isValid(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.lowerBound) && Vec2.isValid(obj.upperBound) && Vec2.sub(obj.upperBound, obj.lowerBound).lengthSquared() >= 0;\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!AABB.isValid(o), \"Invalid AABB!\", o);\n }\n\n /**\n * Get the center of the AABB.\n */\n getCenter(): Vec2 {\n return Vec2.neo((this.lowerBound.x + this.upperBound.x) * 0.5, (this.lowerBound.y + this.upperBound.y) * 0.5);\n }\n\n /**\n * Get the extents of the AABB (half-widths).\n */\n getExtents(): Vec2 {\n return Vec2.neo((this.upperBound.x - this.lowerBound.x) * 0.5, (this.upperBound.y - this.lowerBound.y) * 0.5);\n }\n\n /**\n * Get the perimeter length.\n */\n getPerimeter(): number {\n return 2.0 * (this.upperBound.x - this.lowerBound.x + this.upperBound.y - this.lowerBound.y);\n }\n\n /**\n * Combine one or two AABB into this one.\n */\n combine(a: AABBValue, b?: AABBValue): void {\n b = b || this;\n\n const lowerA = a.lowerBound;\n const upperA = a.upperBound;\n const lowerB = b.lowerBound;\n const upperB = b.upperBound;\n\n const lowerX = math_min(lowerA.x, lowerB.x);\n const lowerY = math_min(lowerA.y, lowerB.y);\n const upperX = math_max(upperB.x, upperA.x);\n const upperY = math_max(upperB.y, upperA.y);\n\n this.lowerBound.setNum(lowerX, lowerY);\n this.upperBound.setNum(upperX, upperY);\n }\n\n combinePoints(a: Vec2Value, b: Vec2Value): void {\n this.lowerBound.setNum(math_min(a.x, b.x), math_min(a.y, b.y));\n this.upperBound.setNum(math_max(a.x, b.x), math_max(a.y, b.y));\n }\n\n set(aabb: AABBValue): void {\n this.lowerBound.setNum(aabb.lowerBound.x, aabb.lowerBound.y);\n this.upperBound.setNum(aabb.upperBound.x, aabb.upperBound.y);\n }\n\n contains(aabb: AABBValue): boolean {\n let result = true;\n result = result && this.lowerBound.x <= aabb.lowerBound.x;\n result = result && this.lowerBound.y <= aabb.lowerBound.y;\n result = result && aabb.upperBound.x <= this.upperBound.x;\n result = result && aabb.upperBound.y <= this.upperBound.y;\n return result;\n }\n\n extend(value: number): AABB {\n AABB.extend(this, value);\n return this;\n }\n\n static extend(out: AABBValue, value: number): AABBValue {\n out.lowerBound.x -= value;\n out.lowerBound.y -= value;\n out.upperBound.x += value;\n out.upperBound.y += value;\n return out;\n }\n\n static testOverlap(a: AABBValue, b: AABBValue): boolean {\n const d1x = b.lowerBound.x - a.upperBound.x;\n const d2x = a.lowerBound.x - b.upperBound.x;\n\n const d1y = b.lowerBound.y - a.upperBound.y;\n const d2y = a.lowerBound.y - b.upperBound.y;\n\n if (d1x > 0 || d1y > 0 || d2x > 0 || d2y > 0) {\n return false;\n }\n return true;\n }\n\n static areEqual(a: AABBValue, b: AABBValue): boolean {\n return Vec2.areEqual(a.lowerBound, b.lowerBound) && Vec2.areEqual(a.upperBound, b.upperBound);\n }\n\n static diff(a: AABBValue, b: AABBValue): number {\n const wD = math_max(0, math_min(a.upperBound.x, b.upperBound.x) - math_max(b.lowerBound.x, a.lowerBound.x));\n const hD = math_max(0, math_min(a.upperBound.y, b.upperBound.y) - math_max(b.lowerBound.y, a.lowerBound.y));\n\n const wA = a.upperBound.x - a.lowerBound.x;\n const hA = a.upperBound.y - a.lowerBound.y;\n\n const wB = b.upperBound.x - b.lowerBound.x;\n const hB = b.upperBound.y - b.lowerBound.y;\n\n return wA * hA + wB * hB - wD * hD;\n }\n\n rayCast(output: RayCastOutput, input: RayCastInput): boolean {\n // From Real-time Collision Detection, p179.\n\n let tmin = -Infinity;\n let tmax = Infinity;\n\n const p = input.p1;\n const d = Vec2.sub(input.p2, input.p1);\n const absD = Vec2.abs(d);\n\n const normal = Vec2.zero();\n\n for (let f: \"x\" | \"y\" = \"x\"; f !== null; f = (f === \"x\" ? \"y\" : null)) {\n if (absD.x < EPSILON) {\n // Parallel.\n if (p[f] < this.lowerBound[f] || this.upperBound[f] < p[f]) {\n return false;\n }\n } else {\n const inv_d = 1.0 / d[f];\n let t1 = (this.lowerBound[f] - p[f]) * inv_d;\n let t2 = (this.upperBound[f] - p[f]) * inv_d;\n\n // Sign of the normal vector.\n let s = -1.0;\n\n if (t1 > t2) {\n const temp = t1;\n t1 = t2;\n t2 = temp;\n s = 1.0;\n }\n\n // Push the min up\n if (t1 > tmin) {\n normal.setZero();\n normal[f] = s;\n tmin = t1;\n }\n\n // Pull the max down\n tmax = math_min(tmax, t2);\n\n if (tmin > tmax) {\n return false;\n }\n }\n }\n\n // Does the ray start inside the box?\n // Does the ray intersect beyond the max fraction?\n if (tmin < 0.0 || input.maxFraction < tmin) {\n return false;\n }\n\n // Intersection.\n output.fraction = tmin;\n output.normal = normal;\n return true;\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static combinePoints(out: AABBValue, a: Vec2Value, b: Vec2Value): AABBValue {\n out.lowerBound.x = math_min(a.x, b.x);\n out.lowerBound.y = math_min(a.y, b.y);\n out.upperBound.x = math_max(a.x, b.x);\n out.upperBound.y = math_max(a.y, b.y);\n return out;\n }\n\n static combinedPerimeter(a: AABBValue, b: AABBValue) {\n const lx = math_min(a.lowerBound.x, b.lowerBound.x);\n const ly = math_min(a.lowerBound.y, b.lowerBound.y);\n const ux = math_max(a.upperBound.x, b.upperBound.x);\n const uy = math_max(a.upperBound.y, b.upperBound.y);\n return 2.0 * (ux - lx + uy - ly); \n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Tuning constants based on meters-kilograms-seconds (MKS) units.\n * \n * Some tolerances are absolute and some are relative. Absolute tolerances use MKS units.\n */\nexport class Settings {\n /**\n * You can use this to change the length scale used by your game.\n * \n * For example for inches you could use 39.4.\n */\n static lengthUnitsPerMeter = 1.0;\n \n // Collision\n /**\n * The maximum number of contact points between two convex shapes. Do not change\n * this value.\n */\n static maxManifoldPoints: number = 2;\n\n /**\n * The maximum number of vertices on a convex polygon. You cannot increase this\n * too much because BlockAllocator has a maximum object size.\n */\n static maxPolygonVertices: number = 12;\n\n /**\n * This is used to fatten AABBs in the dynamic tree. This allows proxies to move\n * by a small amount without triggering a tree adjustment. This is in meters.\n */\n static aabbExtension: number = 0.1;\n\n /**\n * This is used to fatten AABBs in the dynamic tree. This is used to predict the\n * future position based on the current displacement. This is a dimensionless\n * multiplier.\n */\n static aabbMultiplier: number = 2.0;\n\n /**\n * A small length used as a collision and constraint tolerance. Usually it is\n * chosen to be numerically significant, but visually insignificant.\n */\n static linearSlop: number = 0.005;\n\n /**\n * A small angle used as a collision and constraint tolerance. Usually it is\n * chosen to be numerically significant, but visually insignificant.\n */\n static angularSlop: number = (2.0 / 180.0 * math_PI);\n\n /**\n * The radius of the polygon/edge shape skin. This should not be modified.\n * Making this smaller means polygons will have an insufficient buffer for\n * continuous collision. Making it larger may create artifacts for vertex\n * collision.\n */\n static get polygonRadius(): number { return 2.0 * Settings.linearSlop; }\n\n /**\n * Maximum number of sub-steps per contact in continuous physics simulation.\n */\n static maxSubSteps: number = 8;\n\n // Dynamics\n\n /**\n * Maximum number of contacts to be handled to solve a TOI impact.\n */\n static maxTOIContacts: number = 32;\n\n /**\n * Maximum iterations to solve a TOI.\n */\n static maxTOIIterations: number = 20;\n\n /**\n * Maximum iterations to find Distance.\n */\n static maxDistanceIterations: number = 20;\n\n /**\n * A velocity threshold for elastic collisions. Any collision with a relative\n * linear velocity below this threshold will be treated as inelastic.\n */\n static velocityThreshold: number = 1.0;\n\n /**\n * The maximum linear position correction used when solving constraints. This\n * helps to prevent overshoot.\n */\n static maxLinearCorrection: number = 0.2;\n\n /**\n * The maximum angular position correction used when solving constraints. This\n * helps to prevent overshoot.\n */\n static maxAngularCorrection: number = (8.0 / 180.0 * math_PI);\n\n /**\n * The maximum linear velocity of a body. This limit is very large and is used\n * to prevent numerical problems. You shouldn't need to adjust Settings.\n */\n static maxTranslation: number = 2.0;\n\n /**\n * The maximum angular velocity of a body. This limit is very large and is used\n * to prevent numerical problems. You shouldn't need to adjust Settings.\n */\n static maxRotation: number = (0.5 * math_PI);\n\n /**\n * This scale factor controls how fast overlap is resolved. Ideally this would\n * be 1 so that overlap is removed in one time step. However using values close\n * to 1 often lead to overshoot.\n */\n static baumgarte: number = 0.2;\n static toiBaugarte: number = 0.75;\n\n // Sleep\n\n /**\n * The time that a body must be still before it will go to sleep.\n */\n static timeToSleep: number = 0.5;\n\n /**\n * A body cannot sleep if its linear velocity is above this tolerance.\n */\n static linearSleepTolerance: number = 0.01;\n\n /**\n * A body cannot sleep if its angular velocity is above this tolerance.\n */\n static angularSleepTolerance: number = (2.0 / 180.0 * math_PI);\n}\n\n/** @internal */\nexport class SettingsInternal {\n static get maxManifoldPoints() {\n return Settings.maxManifoldPoints;\n }\n static get maxPolygonVertices() {\n return Settings.maxPolygonVertices;\n }\n static get aabbExtension() {\n return Settings.aabbExtension * Settings.lengthUnitsPerMeter;\n }\n static get aabbMultiplier() {\n return Settings.aabbMultiplier;\n }\n static get linearSlop() {\n return Settings.linearSlop * Settings.lengthUnitsPerMeter;\n }\n static get linearSlopSquared() {\n return Settings.linearSlop * Settings.lengthUnitsPerMeter * Settings.linearSlop * Settings.lengthUnitsPerMeter;\n }\n static get angularSlop() {\n return Settings.angularSlop;\n }\n static get polygonRadius() {\n return 2.0 * Settings.linearSlop;\n }\n static get maxSubSteps() {\n return Settings.maxSubSteps;\n }\n static get maxTOIContacts() {\n return Settings.maxTOIContacts;\n }\n static get maxTOIIterations() {\n return Settings.maxTOIIterations;\n }\n static get maxDistanceIterations() {\n return Settings.maxDistanceIterations;\n }\n static get velocityThreshold() {\n return Settings.velocityThreshold * Settings.lengthUnitsPerMeter;\n }\n static get maxLinearCorrection() {\n return Settings.maxLinearCorrection * Settings.lengthUnitsPerMeter;\n }\n static get maxAngularCorrection() {\n return Settings.maxAngularCorrection;\n }\n static get maxTranslation() {\n return Settings.maxTranslation * Settings.lengthUnitsPerMeter;\n }\n static get maxTranslationSquared() {\n return Settings.maxTranslation * Settings.lengthUnitsPerMeter * Settings.maxTranslation * Settings.lengthUnitsPerMeter;\n }\n static get maxRotation() {\n return Settings.maxRotation;\n }\n static get maxRotationSquared() {\n return Settings.maxRotation * Settings.maxRotation;\n }\n static get baumgarte() {\n return Settings.baumgarte;\n }\n static get toiBaugarte() {\n return Settings.toiBaugarte;\n }\n static get timeToSleep() {\n return Settings.timeToSleep;\n }\n static get linearSleepTolerance() {\n return Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter;\n }\n static get linearSleepToleranceSqr() {\n return Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter * Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter;\n }\n static get angularSleepTolerance() {\n return Settings.angularSleepTolerance;\n }\n static get angularSleepToleranceSqr() {\n return Settings.angularSleepTolerance * Settings.angularSleepTolerance;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */\nexport interface PoolOptions {\n max?: number,\n create?: () => T,\n /** Called when an object is being re-allocated. */\n allocate?: (item: T) => void,\n /** Called when an object is returned to pool. */\n release?: (item: T) => void,\n /** Called when an object is returned to the pool but will be disposed from pool. */\n dispose?: (item: T) => T,\n}\n\n/** @internal */\nexport class Pool {\n _list: T[] = [];\n _max: number = Infinity;\n\n _createFn: () => T;\n _hasCreateFn: boolean = false;\n _createCount: number = 0;\n\n _allocateFn: (item: T) => void;\n _hasAllocateFn: boolean = false;\n _allocateCount: number = 0;\n\n _releaseFn: (item: T) => void;\n _hasReleaseFn: boolean = false;\n _releaseCount: number = 0;\n\n _disposeFn: (item: T) => T;\n _hasDisposeFn: boolean = false;\n _disposeCount: number = 0;\n\n constructor(opts: PoolOptions) {\n this._list = [];\n this._max = opts.max || this._max;\n\n this._createFn = opts.create;\n this._hasCreateFn = typeof this._createFn === \"function\";\n this._allocateFn = opts.allocate;\n this._hasAllocateFn = typeof this._allocateFn === \"function\";\n this._releaseFn = opts.release;\n this._hasReleaseFn = typeof this._releaseFn === \"function\";\n this._disposeFn = opts.dispose;\n this._hasDisposeFn = typeof this._disposeFn === \"function\";\n }\n\n max(n?: number): number | Pool {\n if (typeof n === \"number\") {\n this._max = n;\n return this;\n }\n return this._max;\n }\n\n size(): number {\n return this._list.length;\n }\n\n allocate(): T {\n let item: T;\n if (this._list.length > 0) {\n item = this._list.shift();\n } else {\n this._createCount++;\n if (this._hasCreateFn) {\n item = this._createFn();\n } else {\n // tslint:disable-next-line:no-object-literal-type-assertion\n item = {} as T;\n }\n }\n this._allocateCount++;\n if (this._hasAllocateFn) {\n this._allocateFn(item);\n }\n return item;\n }\n\n release(item: T): void {\n if (this._list.length < this._max) {\n this._releaseCount++;\n if (this._hasReleaseFn) {\n this._releaseFn(item);\n }\n this._list.push(item);\n } else {\n this._disposeCount++;\n if (this._hasDisposeFn) {\n item = this._disposeFn(item);\n }\n }\n }\n\n toString(): string {\n return \" +\" + this._createCount + \" >\" + this._allocateCount + \" <\" + this._releaseCount + \" -\"\n + this._disposeCount + \" =\" + this._list.length + \"/\" + this._max;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { Pool } from \"../util/Pool\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { AABB, AABBValue, RayCastCallback, RayCastInput } from \"./AABB\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n\n\nexport type DynamicTreeQueryCallback = (nodeId: number) => boolean;\n\n/**\n * A node in the dynamic tree. The client does not interact with this directly.\n */\nexport class TreeNode {\n id: number;\n /** Enlarged AABB */\n aabb: AABB = new AABB();\n userData: T = null;\n parent: TreeNode = null;\n child1: TreeNode = null;\n child2: TreeNode = null;\n /** 0: leaf, -1: free node */\n height: number = -1;\n\n constructor(id?: number) {\n this.id = id;\n }\n\n /** @internal */\n toString(): string {\n return this.id + \": \" + this.userData;\n }\n\n isLeaf(): boolean {\n return this.child1 == null;\n }\n}\n\n/** @internal */ const poolTreeNode = new Pool>({\n create(): TreeNode {\n return new TreeNode();\n },\n release(node: TreeNode) {\n node.userData = null;\n node.parent = null;\n node.child1 = null;\n node.child2 = null;\n node.height = -1;\n node.id = undefined;\n }\n});\n\n/**\n * A dynamic AABB tree broad-phase, inspired by Nathanael Presson's btDbvt. A\n * dynamic tree arranges data in a binary tree to accelerate queries such as\n * volume queries and ray casts. Leafs are proxies with an AABB. In the tree we\n * expand the proxy AABB by `aabbExtension` so that the proxy AABB is bigger\n * than the client object. This allows the client object to move by small\n * amounts without triggering a tree update.\n *\n * Nodes are pooled and relocatable, so we use node indices rather than\n * pointers.\n */\nexport class DynamicTree {\n m_root: TreeNode;\n m_lastProxyId: number;\n m_nodes: {\n [id: number]: TreeNode\n };\n\n constructor() {\n this.m_root = null;\n this.m_nodes = {};\n this.m_lastProxyId = 0;\n }\n\n /**\n * Get proxy user data.\n *\n * @return the proxy user data or 0 if the id is invalid.\n */\n getUserData(id: number): T {\n const node = this.m_nodes[id];\n if (_ASSERT) console.assert(!!node);\n return node.userData;\n }\n\n /**\n * Get the fat AABB for a node id.\n *\n * @return the proxy user data or 0 if the id is invalid.\n */\n getFatAABB(id: number): AABB {\n const node = this.m_nodes[id];\n if (_ASSERT) console.assert(!!node);\n return node.aabb;\n }\n\n allocateNode(): TreeNode {\n const node = poolTreeNode.allocate();\n node.id = ++this.m_lastProxyId;\n this.m_nodes[node.id] = node;\n return node;\n }\n\n freeNode(node: TreeNode): void {\n // tslint:disable-next-line:no-dynamic-delete\n delete this.m_nodes[node.id];\n poolTreeNode.release(node);\n }\n\n /**\n * Create a proxy in the tree as a leaf node. We return the index of the node\n * instead of a pointer so that we can grow the node pool.\n *\n * Create a proxy. Provide a tight fitting AABB and a userData pointer.\n */\n createProxy(aabb: AABBValue, userData: T): number {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n\n const node = this.allocateNode();\n\n node.aabb.set(aabb);\n\n // Fatten the aabb.\n AABB.extend(node.aabb, Settings.aabbExtension);\n\n node.userData = userData;\n node.height = 0;\n\n this.insertLeaf(node);\n\n return node.id;\n }\n\n /**\n * Destroy a proxy. This asserts if the id is invalid.\n */\n destroyProxy(id: number): void {\n const node = this.m_nodes[id];\n\n if (_ASSERT) console.assert(!!node);\n if (_ASSERT) console.assert(node.isLeaf());\n\n this.removeLeaf(node);\n this.freeNode(node);\n }\n\n /**\n * Move a proxy with a swepted AABB. If the proxy has moved outside of its\n * fattened AABB, then the proxy is removed from the tree and re-inserted.\n * Otherwise the function returns immediately.\n *\n * @param d Displacement\n *\n * @return true if the proxy was re-inserted.\n */\n moveProxy(id: number, aabb: AABBValue, d: Vec2Value): boolean {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n if (_ASSERT) console.assert(!d || Vec2.isValid(d));\n\n const node = this.m_nodes[id];\n\n if (_ASSERT) console.assert(!!node);\n if (_ASSERT) console.assert(node.isLeaf());\n\n if (node.aabb.contains(aabb)) {\n return false;\n }\n\n this.removeLeaf(node);\n\n node.aabb.set(aabb);\n\n // Extend AABB.\n aabb = node.aabb;\n AABB.extend(aabb, Settings.aabbExtension);\n\n // Predict AABB displacement.\n // const d = Vec2.mul(Settings.aabbMultiplier, displacement);\n\n if (d.x < 0.0) {\n aabb.lowerBound.x += d.x * Settings.aabbMultiplier;\n } else {\n aabb.upperBound.x += d.x * Settings.aabbMultiplier;\n }\n\n if (d.y < 0.0) {\n aabb.lowerBound.y += d.y * Settings.aabbMultiplier;\n } else {\n aabb.upperBound.y += d.y * Settings.aabbMultiplier;\n }\n\n this.insertLeaf(node);\n\n return true;\n }\n\n insertLeaf(leaf: TreeNode): void {\n if (_ASSERT) console.assert(AABB.isValid(leaf.aabb));\n\n if (this.m_root == null) {\n this.m_root = leaf;\n this.m_root.parent = null;\n return;\n }\n\n // Find the best sibling for this node\n const leafAABB = leaf.aabb;\n let index = this.m_root;\n while (!index.isLeaf()) {\n const child1 = index.child1;\n const child2 = index.child2;\n\n const area = index.aabb.getPerimeter();\n\n const combinedArea = AABB.combinedPerimeter(index.aabb, leafAABB);\n\n // Cost of creating a new parent for this node and the new leaf\n const cost = 2.0 * combinedArea;\n\n // Minimum cost of pushing the leaf further down the tree\n const inheritanceCost = 2.0 * (combinedArea - area);\n\n // Cost of descending into child1\n const newArea1 = AABB.combinedPerimeter(leafAABB, child1.aabb);\n let cost1 = newArea1 + inheritanceCost;\n if (!child1.isLeaf()) {\n const oldArea = child1.aabb.getPerimeter();\n cost1 -= oldArea;\n }\n\n // Cost of descending into child2\n const newArea2 = AABB.combinedPerimeter(leafAABB, child2.aabb);\n let cost2 = newArea2 + inheritanceCost;\n if (!child2.isLeaf()) {\n const oldArea = child2.aabb.getPerimeter();\n cost2 -= oldArea;\n }\n\n // Descend according to the minimum cost.\n if (cost < cost1 && cost < cost2) {\n break;\n }\n\n // Descend\n if (cost1 < cost2) {\n index = child1;\n } else {\n index = child2;\n }\n }\n\n const sibling = index;\n\n // Create a new parent.\n const oldParent = sibling.parent;\n const newParent = this.allocateNode();\n newParent.parent = oldParent;\n newParent.userData = null;\n newParent.aabb.combine(leafAABB, sibling.aabb);\n newParent.height = sibling.height + 1;\n\n if (oldParent != null) {\n // The sibling was not the root.\n if (oldParent.child1 === sibling) {\n oldParent.child1 = newParent;\n } else {\n oldParent.child2 = newParent;\n }\n\n newParent.child1 = sibling;\n newParent.child2 = leaf;\n sibling.parent = newParent;\n leaf.parent = newParent;\n } else {\n // The sibling was the root.\n newParent.child1 = sibling;\n newParent.child2 = leaf;\n sibling.parent = newParent;\n leaf.parent = newParent;\n this.m_root = newParent;\n }\n\n // Walk back up the tree fixing heights and AABBs\n index = leaf.parent;\n while (index != null) {\n index = this.balance(index);\n\n const child1 = index.child1;\n const child2 = index.child2;\n\n if (_ASSERT) console.assert(child1 != null);\n if (_ASSERT) console.assert(child2 != null);\n\n index.height = 1 + math_max(child1.height, child2.height);\n index.aabb.combine(child1.aabb, child2.aabb);\n\n index = index.parent;\n }\n\n // validate();\n }\n\n removeLeaf(leaf: TreeNode): void {\n if (leaf === this.m_root) {\n this.m_root = null;\n return;\n }\n\n const parent = leaf.parent;\n const grandParent = parent.parent;\n let sibling;\n if (parent.child1 === leaf) {\n sibling = parent.child2;\n } else {\n sibling = parent.child1;\n }\n\n if (grandParent != null) {\n // Destroy parent and connect sibling to grandParent.\n if (grandParent.child1 === parent) {\n grandParent.child1 = sibling;\n } else {\n grandParent.child2 = sibling;\n }\n sibling.parent = grandParent;\n this.freeNode(parent);\n\n // Adjust ancestor bounds.\n let index = grandParent;\n while (index != null) {\n index = this.balance(index);\n\n const child1 = index.child1;\n const child2 = index.child2;\n\n index.aabb.combine(child1.aabb, child2.aabb);\n index.height = 1 + math_max(child1.height, child2.height);\n\n index = index.parent;\n }\n } else {\n this.m_root = sibling;\n sibling.parent = null;\n this.freeNode(parent);\n }\n\n // validate();\n }\n\n /**\n * Perform a left or right rotation if node A is imbalanced. Returns the new\n * root index.\n */\n balance(iA: TreeNode): TreeNode {\n if (_ASSERT) console.assert(iA != null);\n\n const A = iA;\n if (A.isLeaf() || A.height < 2) {\n return iA;\n }\n\n const B = A.child1;\n const C = A.child2;\n\n const balance = C.height - B.height;\n\n // Rotate C up\n if (balance > 1) {\n const F = C.child1;\n const G = C.child2;\n\n // Swap A and C\n C.child1 = A;\n C.parent = A.parent;\n A.parent = C;\n\n // A's old parent should point to C\n if (C.parent != null) {\n if (C.parent.child1 === iA) {\n C.parent.child1 = C;\n } else {\n C.parent.child2 = C;\n }\n } else {\n this.m_root = C;\n }\n\n // Rotate\n if (F.height > G.height) {\n C.child2 = F;\n A.child2 = G;\n G.parent = A;\n A.aabb.combine(B.aabb, G.aabb);\n C.aabb.combine(A.aabb, F.aabb);\n\n A.height = 1 + math_max(B.height, G.height);\n C.height = 1 + math_max(A.height, F.height);\n } else {\n C.child2 = G;\n A.child2 = F;\n F.parent = A;\n A.aabb.combine(B.aabb, F.aabb);\n C.aabb.combine(A.aabb, G.aabb);\n\n A.height = 1 + math_max(B.height, F.height);\n C.height = 1 + math_max(A.height, G.height);\n }\n\n return C;\n }\n\n // Rotate B up\n if (balance < -1) {\n const D = B.child1;\n const E = B.child2;\n\n // Swap A and B\n B.child1 = A;\n B.parent = A.parent;\n A.parent = B;\n\n // A's old parent should point to B\n if (B.parent != null) {\n if (B.parent.child1 === A) {\n B.parent.child1 = B;\n } else {\n B.parent.child2 = B;\n }\n } else {\n this.m_root = B;\n }\n\n // Rotate\n if (D.height > E.height) {\n B.child2 = D;\n A.child1 = E;\n E.parent = A;\n A.aabb.combine(C.aabb, E.aabb);\n B.aabb.combine(A.aabb, D.aabb);\n\n A.height = 1 + math_max(C.height, E.height);\n B.height = 1 + math_max(A.height, D.height);\n } else {\n B.child2 = E;\n A.child1 = D;\n D.parent = A;\n A.aabb.combine(C.aabb, D.aabb);\n B.aabb.combine(A.aabb, E.aabb);\n\n A.height = 1 + math_max(C.height, D.height);\n B.height = 1 + math_max(A.height, E.height);\n }\n\n return B;\n }\n\n return A;\n }\n\n /**\n * Compute the height of the binary tree in O(N) time. Should not be called\n * often.\n */\n getHeight(): number {\n if (this.m_root == null) {\n return 0;\n }\n\n return this.m_root.height;\n }\n\n /**\n * Get the ratio of the sum of the node areas to the root area.\n */\n getAreaRatio(): number {\n if (this.m_root == null) {\n return 0.0;\n }\n\n const root = this.m_root;\n const rootArea = root.aabb.getPerimeter();\n\n let totalArea = 0.0;\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height < 0) {\n // Free node in pool\n continue;\n }\n\n totalArea += node.aabb.getPerimeter();\n }\n\n this.iteratorPool.release(it);\n\n return totalArea / rootArea;\n }\n\n /**\n * Compute the height of a sub-tree.\n */\n computeHeight(id?: number): number {\n let node;\n if (typeof id !== \"undefined\") {\n node = this.m_nodes[id];\n } else {\n node = this.m_root;\n }\n\n // if (_ASSERT) console.assert(0 <= id && id < this.m_nodeCapacity);\n\n if (node.isLeaf()) {\n return 0;\n }\n\n const height1 = this.computeHeight(node.child1.id);\n const height2 = this.computeHeight(node.child2.id);\n return 1 + math_max(height1, height2);\n }\n\n validateStructure(node: TreeNode): void {\n if (node == null) {\n return;\n }\n\n if (node === this.m_root) {\n if (_ASSERT) console.assert(node.parent == null);\n }\n\n const child1 = node.child1;\n const child2 = node.child2;\n\n if (node.isLeaf()) {\n if (_ASSERT) console.assert(child1 == null);\n if (_ASSERT) console.assert(child2 == null);\n if (_ASSERT) console.assert(node.height === 0);\n return;\n }\n\n // if (_ASSERT) console.assert(0 <= child1 && child1 < this.m_nodeCapacity);\n // if (_ASSERT) console.assert(0 <= child2 && child2 < this.m_nodeCapacity);\n\n if (_ASSERT) console.assert(child1.parent === node);\n if (_ASSERT) console.assert(child2.parent === node);\n\n this.validateStructure(child1);\n this.validateStructure(child2);\n }\n\n validateMetrics(node: TreeNode): void {\n if (node == null) {\n return;\n }\n\n const child1 = node.child1;\n const child2 = node.child2;\n\n if (node.isLeaf()) {\n if (_ASSERT) console.assert(child1 == null);\n if (_ASSERT) console.assert(child2 == null);\n if (_ASSERT) console.assert(node.height === 0);\n return;\n }\n\n // if (_ASSERT) console.assert(0 <= child1 && child1 < this.m_nodeCapacity);\n // if (_ASSERT) console.assert(0 <= child2 && child2 < this.m_nodeCapacity);\n\n const height1 = child1.height;\n const height2 = child2.height;\n const height = 1 + math_max(height1, height2);\n if (_ASSERT) console.assert(node.height === height);\n\n const aabb = new AABB();\n aabb.combine(child1.aabb, child2.aabb);\n\n if (_ASSERT) console.assert(AABB.areEqual(aabb, node.aabb));\n\n this.validateMetrics(child1);\n this.validateMetrics(child2);\n }\n\n /**\n * Validate this tree. For testing.\n */\n validate(): void {\n if (!_ASSERT) return;\n this.validateStructure(this.m_root);\n this.validateMetrics(this.m_root);\n\n console.assert(this.getHeight() === this.computeHeight());\n }\n\n /**\n * Get the maximum balance of an node in the tree. The balance is the difference\n * in height of the two children of a node.\n */\n getMaxBalance(): number {\n let maxBalance = 0;\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height <= 1) {\n continue;\n }\n\n if (_ASSERT) console.assert(!node.isLeaf());\n\n const balance = math_abs(node.child2.height - node.child1.height);\n maxBalance = math_max(maxBalance, balance);\n }\n this.iteratorPool.release(it);\n\n return maxBalance;\n }\n\n /**\n * Build an optimal tree. Very expensive. For testing.\n */\n rebuildBottomUp(): void {\n const nodes = [];\n let count = 0;\n\n // Build array of leaves. Free the rest.\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height < 0) {\n // free node in pool\n continue;\n }\n\n if (node.isLeaf()) {\n node.parent = null;\n nodes[count] = node;\n ++count;\n } else {\n this.freeNode(node);\n }\n }\n this.iteratorPool.release(it);\n\n while (count > 1) {\n let minCost = Infinity;\n let iMin = -1;\n let jMin = -1;\n for (let i = 0; i < count; ++i) {\n const aabbi = nodes[i].aabb;\n for (let j = i + 1; j < count; ++j) {\n const aabbj = nodes[j].aabb;\n const cost = AABB.combinedPerimeter(aabbi, aabbj);\n if (cost < minCost) {\n iMin = i;\n jMin = j;\n minCost = cost;\n }\n }\n }\n\n const child1 = nodes[iMin];\n const child2 = nodes[jMin];\n\n const parent = this.allocateNode();\n parent.child1 = child1;\n parent.child2 = child2;\n parent.height = 1 + math_max(child1.height, child2.height);\n parent.aabb.combine(child1.aabb, child2.aabb);\n parent.parent = null;\n\n child1.parent = parent;\n child2.parent = parent;\n\n nodes[jMin] = nodes[count - 1];\n nodes[iMin] = parent;\n --count;\n }\n\n this.m_root = nodes[0];\n\n if (_ASSERT) this.validate();\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n // Build array of leaves. Free the rest.\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n const aabb = node.aabb;\n aabb.lowerBound.x -= newOrigin.x;\n aabb.lowerBound.y -= newOrigin.y;\n aabb.upperBound.x -= newOrigin.x;\n aabb.upperBound.y -= newOrigin.y;\n }\n this.iteratorPool.release(it);\n }\n\n /**\n * Query an AABB for overlapping proxies. The callback class is called for each\n * proxy that overlaps the supplied AABB.\n */\n query(aabb: AABBValue, queryCallback: DynamicTreeQueryCallback): void {\n if (_ASSERT) console.assert(typeof queryCallback === \"function\");\n const stack = this.stackPool.allocate();\n\n stack.push(this.m_root);\n while (stack.length > 0) {\n const node = stack.pop();\n if (node == null) {\n continue;\n }\n\n if (AABB.testOverlap(node.aabb, aabb)) {\n if (node.isLeaf()) {\n const proceed = queryCallback(node.id);\n if (proceed === false) {\n return;\n }\n } else {\n stack.push(node.child1);\n stack.push(node.child2);\n }\n }\n }\n\n this.stackPool.release(stack);\n }\n\n /**\n * Ray-cast against the proxies in the tree. This relies on the callback to\n * perform a exact ray-cast in the case were the proxy contains a shape. The\n * callback also performs the any collision filtering. This has performance\n * roughly equal to k * log(n), where k is the number of collisions and n is the\n * number of proxies in the tree.\n *\n * @param input The ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n * @param rayCastCallback A function that is called for each proxy that is hit by the ray. If the return value is a positive number it will update the maxFraction of the ray cast input, and if it is zero it will terminate they ray cast.\n */\n rayCast(input: RayCastInput, rayCastCallback: RayCastCallback): void {\n // TODO: GC\n if (_ASSERT) console.assert(typeof rayCastCallback === \"function\");\n const p1 = input.p1;\n const p2 = input.p2;\n const r = Vec2.sub(p2, p1);\n if (_ASSERT) console.assert(r.lengthSquared() > 0.0);\n r.normalize();\n\n // v is perpendicular to the segment.\n const v = Vec2.crossNumVec2(1.0, r);\n const abs_v = Vec2.abs(v);\n\n // Separating axis for segment (Gino, p80).\n // |dot(v, p1 - c)| > dot(|v|, h)\n\n let maxFraction = input.maxFraction;\n\n // Build a bounding box for the segment.\n const segmentAABB = new AABB();\n let t = Vec2.combine((1 - maxFraction), p1, maxFraction, p2);\n segmentAABB.combinePoints(p1, t);\n\n const stack = this.stackPool.allocate();\n const subInput = this.inputPool.allocate();\n\n stack.push(this.m_root);\n while (stack.length > 0) {\n const node = stack.pop();\n if (node == null) {\n continue;\n }\n\n if (AABB.testOverlap(node.aabb, segmentAABB) === false) {\n continue;\n }\n\n // Separating axis for segment (Gino, p80).\n // |dot(v, p1 - c)| > dot(|v|, h)\n const c = node.aabb.getCenter();\n const h = node.aabb.getExtents();\n const separation = math_abs(Vec2.dot(v, Vec2.sub(p1, c))) - Vec2.dot(abs_v, h);\n if (separation > 0.0) {\n continue;\n }\n\n if (node.isLeaf()) {\n subInput.p1 = Vec2.clone(input.p1);\n subInput.p2 = Vec2.clone(input.p2);\n subInput.maxFraction = maxFraction;\n\n const value = rayCastCallback(subInput, node.id);\n\n if (value === 0.0) {\n // The client has terminated the ray cast.\n break;\n } else if (value > 0.0) {\n // update segment bounding box.\n maxFraction = value;\n t = Vec2.combine((1 - maxFraction), p1, maxFraction, p2);\n segmentAABB.combinePoints(p1, t);\n }\n } else {\n stack.push(node.child1);\n stack.push(node.child2);\n }\n }\n this.stackPool.release(stack);\n this.inputPool.release(subInput);\n }\n\n private inputPool: Pool = new Pool({\n create(): RayCastInput {\n // tslint:disable-next-line:no-object-literal-type-assertion\n return {} as RayCastInput;\n },\n release(stack: RayCastInput): void {\n }\n });\n\n private stackPool: Pool>> = new Pool>>({\n create(): Array> {\n return [];\n },\n release(stack: Array>): void {\n stack.length = 0;\n }\n });\n\n private iteratorPool: Pool> = new Pool>({\n create(): Iterator {\n return new Iterator();\n },\n release(iterator: Iterator): void {\n iterator.close();\n }\n });\n\n}\n\n/** @internal */\nclass Iterator {\n parents: Array> = [];\n states: number[] = [];\n preorder(root: TreeNode): Iterator {\n this.parents.length = 0;\n this.parents.push(root);\n this.states.length = 0;\n this.states.push(0);\n return this;\n }\n next(): TreeNode {\n while (this.parents.length > 0) {\n const i = this.parents.length - 1;\n const node = this.parents[i];\n if (this.states[i] === 0) {\n this.states[i] = 1;\n return node;\n }\n if (this.states[i] === 1) {\n this.states[i] = 2;\n if (node.child1) {\n this.parents.push(node.child1);\n this.states.push(1);\n return node.child1;\n }\n }\n if (this.states[i] === 2) {\n this.states[i] = 3;\n if (node.child2) {\n this.parents.push(node.child2);\n this.states.push(1);\n return node.child2;\n }\n }\n this.parents.pop();\n this.states.pop();\n }\n }\n close(): void {\n this.parents.length = 0;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2Value } from \"../common/Vec2\";\nimport { AABB, AABBValue, RayCastCallback, RayCastInput } from \"./AABB\";\nimport { DynamicTree, DynamicTreeQueryCallback } from \"./DynamicTree\";\nimport { FixtureProxy } from \"../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/**\n * The broad-phase wraps and extends a dynamic-tree to keep track of moved\n * objects and query them on update.\n */\nexport class BroadPhase {\n m_tree: DynamicTree = new DynamicTree();\n m_moveBuffer: number[] = [];\n\n m_callback: (userDataA: any, userDataB: any) => void;\n m_queryProxyId: number;\n\n /**\n * Get user data from a proxy. Returns null if the id is invalid.\n */\n getUserData(proxyId: number): FixtureProxy {\n return this.m_tree.getUserData(proxyId);\n }\n\n /**\n * Test overlap of fat AABBs.\n */\n testOverlap(proxyIdA: number, proxyIdB: number): boolean {\n const aabbA = this.m_tree.getFatAABB(proxyIdA);\n const aabbB = this.m_tree.getFatAABB(proxyIdB);\n return AABB.testOverlap(aabbA, aabbB);\n }\n\n /**\n * Get the fat AABB for a proxy.\n */\n getFatAABB(proxyId: number): AABB {\n return this.m_tree.getFatAABB(proxyId);\n }\n\n /**\n * Get the number of proxies.\n */\n getProxyCount(): number {\n return this.m_moveBuffer.length;\n }\n\n /**\n * Get the height of the embedded tree.\n */\n getTreeHeight(): number {\n return this.m_tree.getHeight();\n }\n\n /**\n * Get the balance (integer) of the embedded tree.\n */\n getTreeBalance(): number {\n return this.m_tree.getMaxBalance();\n }\n\n /**\n * Get the quality metric of the embedded tree.\n */\n getTreeQuality(): number {\n return this.m_tree.getAreaRatio();\n }\n\n /**\n * Query an AABB for overlapping proxies. The callback class is called for each\n * proxy that overlaps the supplied AABB.\n */\n query = (aabb: AABBValue, queryCallback: DynamicTreeQueryCallback): void => {\n this.m_tree.query(aabb, queryCallback);\n };\n\n /**\n * Ray-cast against the proxies in the tree. This relies on the callback to\n * perform a exact ray-cast in the case were the proxy contains a shape. The\n * callback also performs the any collision filtering. This has performance\n * roughly equal to k * log(n), where k is the number of collisions and n is the\n * number of proxies in the tree.\n *\n * @param input The ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n * @param rayCastCallback A function that is called for each proxy that is hit by the ray. If the return value is a positive number it will update the maxFraction of the ray cast input, and if it is zero it will terminate they ray cast.\n */\n rayCast(input: RayCastInput, rayCastCallback: RayCastCallback): void {\n this.m_tree.rayCast(input, rayCastCallback);\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_tree.shiftOrigin(newOrigin);\n }\n\n /**\n * Create a proxy with an initial AABB. Pairs are not reported until UpdatePairs\n * is called.\n */\n createProxy(aabb: AABBValue, userData: FixtureProxy): number {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n const proxyId = this.m_tree.createProxy(aabb, userData);\n this.bufferMove(proxyId);\n return proxyId;\n }\n\n /**\n * Destroy a proxy. It is up to the client to remove any pairs.\n */\n destroyProxy(proxyId: number): void {\n this.unbufferMove(proxyId);\n this.m_tree.destroyProxy(proxyId);\n }\n\n /**\n * Call moveProxy as many times as you like, then when you are done call\n * UpdatePairs to finalized the proxy pairs (for your time step).\n */\n moveProxy(proxyId: number, aabb: AABB, displacement: Vec2Value): void {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n const changed = this.m_tree.moveProxy(proxyId, aabb, displacement);\n if (changed) {\n this.bufferMove(proxyId);\n }\n }\n\n /**\n * Call to trigger a re-processing of it's pairs on the next call to\n * UpdatePairs.\n */\n touchProxy(proxyId: number): void {\n this.bufferMove(proxyId);\n }\n\n bufferMove(proxyId: number): void {\n this.m_moveBuffer.push(proxyId);\n }\n\n unbufferMove(proxyId: number): void {\n for (let i = 0; i < this.m_moveBuffer.length; ++i) {\n if (this.m_moveBuffer[i] === proxyId) {\n this.m_moveBuffer[i] = null;\n }\n }\n }\n\n /**\n * Update the pairs. This results in pair callbacks. This can only add pairs.\n */\n updatePairs(addPairCallback: (userDataA: FixtureProxy, userDataB: FixtureProxy) => void): void {\n if (_ASSERT) console.assert(typeof addPairCallback === \"function\");\n this.m_callback = addPairCallback;\n\n // Perform tree queries for all moving proxies.\n while (this.m_moveBuffer.length > 0) {\n this.m_queryProxyId = this.m_moveBuffer.pop();\n if (this.m_queryProxyId === null) {\n continue;\n }\n\n // We have to query the tree with the fat AABB so that\n // we don't fail to create a pair that may touch later.\n const fatAABB = this.m_tree.getFatAABB(this.m_queryProxyId);\n\n // Query tree, create pairs and add them pair buffer.\n this.m_tree.query(fatAABB, this.queryCallback);\n }\n\n // Try to keep the tree balanced.\n // this.m_tree.rebalance(4);\n }\n\n queryCallback = (proxyId: number): boolean => {\n // A proxy cannot form a pair with itself.\n if (proxyId === this.m_queryProxyId) {\n return true;\n }\n\n const proxyIdA = math_min(proxyId, this.m_queryProxyId);\n const proxyIdB = math_max(proxyId, this.m_queryProxyId);\n\n // TODO: Skip any duplicate pairs.\n\n const userDataA = this.m_tree.getUserData(proxyIdA);\n const userDataB = this.m_tree.getUserData(proxyIdB);\n\n // Send the pairs back to the client.\n this.m_callback(userDataA, userDataB);\n\n return true;\n };\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n/** @internal */ const math_sqrt = Math.sqrt;\n\n\nimport { RotValue } from \"./Rot\";\nimport { TransformValue } from \"./Transform\";\nimport { Vec2Value } from \"./Vec2\";\nimport { Vec3Value } from \"./Vec3\";\n\nexport function vec2(x: number, y: number): Vec2Value {\n return { x, y };\n}\n\nexport function vec3(x: number, y: number, z: number): Vec3Value {\n return { x, y, z };\n}\n\nexport function rotation(angle: number): RotValue {\n return { s: math_sin(angle), c: math_cos(angle) };\n}\n\nexport function setVec2(out: Vec2Value, x: number, y: number): Vec2Value {\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function copyVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = w.x;\n out.y = w.y;\n return out;\n}\n\nexport function zeroVec2(out: Vec2Value): Vec2Value {\n out.x = 0;\n out.y = 0;\n return out;\n}\n\nexport function negVec2(out: Vec2Value): Vec2Value {\n out.x = -out.x;\n out.y = -out.y;\n return out;\n}\n\nexport function plusVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x += w.x;\n out.y += w.y;\n return out;\n}\n\nexport function addVec2(out: Vec2Value, v: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = v.x + w.x;\n out.y = v.x + w.y;\n return out;\n}\n\nexport function minusVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x -= w.x;\n out.y -= w.y;\n return out;\n}\n\nexport function subVec2(out: Vec2Value, v: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = v.x - w.x;\n out.y = v.y - w.y;\n return out;\n}\n\nexport function mulVec2(out: Vec2Value, m: number): Vec2Value {\n out.x *= m;\n out.y *= m;\n return out;\n}\n\nexport function scaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x = m * w.x;\n out.y = m * w.y;\n return out;\n}\n\nexport function plusScaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x += m * w.x;\n out.y += m * w.y;\n return out;\n}\n\nexport function minusScaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x -= m * w.x;\n out.y -= m * w.y;\n return out;\n}\n\nexport function combine2Vec2(out: Vec2Value, am: number, a: Vec2Value, bm: number, b: Vec2Value): Vec2Value {\n out.x = am * a.x + bm * b.x;\n out.y = am * a.y + bm * b.y;\n return out;\n}\n\nexport function combine3Vec2(out: Vec2Value, am: number, a: Vec2Value, bm: number, b: Vec2Value, cm: number, c: Vec2Value): Vec2Value {\n out.x = am * a.x + bm * b.x + cm * c.x;\n out.y = am * a.y + bm * b.y + cm * c.y;\n return out;\n}\n\nexport function normalizeVec2Length(out: Vec2Value): number {\n const length = math_sqrt(out.x * out.x + out.y * out.y);\n if (length !== 0) {\n const invLength = 1 / length;\n out.x *= invLength;\n out.y *= invLength;\n }\n return length;\n}\n\nexport function normalizeVec2(out: Vec2Value): Vec2Value {\n const length = math_sqrt(out.x * out.x + out.y * out.y);\n if (length > 0) {\n const invLength = 1 / length;\n out.x *= invLength;\n out.y *= invLength;\n }\n return out;\n}\n\nexport function crossVec2Num(out: Vec2Value, v: Vec2Value, w: number): Vec2Value {\n const x = w * v.y;\n const y = -w * v.x;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function crossNumVec2(out: Vec2Value, w: number, v: Vec2Value): Vec2Value {\n const x = -w * v.y;\n const y = w * v.x;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function crossVec2Vec2(a: Vec2Value, b: Vec2Value): number {\n return a.x * b.y - a.y * b.x;\n}\n\nexport function dotVec2(a: Vec2Value, b: Vec2Value): number {\n return a.x * b.x + a.y * b.y;\n}\n\nexport function lengthVec2(a: Vec2Value): number {\n return math_sqrt(a.x * a.x + a.y * a.y);\n}\n\nexport function lengthSqrVec2(a: Vec2Value): number {\n return a.x * a.x + a.y * a.y;\n}\n\nexport function distVec2(a: Vec2Value, b: Vec2Value): number {\n const dx = a.x - b.x;\n const dy = a.y - b.y;\n return math_sqrt(dx * dx + dy * dy);\n}\n\nexport function distSqrVec2(a: Vec2Value, b: Vec2Value): number {\n const dx = a.x - b.x;\n const dy = a.y - b.y;\n return dx * dx + dy * dy;\n}\n\nexport function dotVec3(v: Vec3Value, w: Vec3Value): number {\n return v.x * w.x + v.y * w.y + v.z * w.z;\n}\n\nexport function setRotAngle(out: RotValue, a: number): RotValue {\n out.c = math_cos(a);\n out.s = math_sin(a);\n return out;\n}\n\nexport function rotVec2(out: Vec2Value, q: RotValue, v: Vec2Value): Vec2Value {\n out.x = q.c * v.x - q.s * v.y;\n out.y = q.s * v.x + q.c * v.y;\n return out;\n}\n\nexport function derotVec2(out: Vec2Value, q: RotValue, v: Vec2Value): Vec2Value {\n const x = q.c * v.x + q.s * v.y;\n const y = -q.s * v.x + q.c * v.y;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function rerotVec2(out: Vec2Value, before: RotValue, after: RotValue, v: Vec2Value): Vec2Value {\n const x0 = before.c * v.x + before.s * v.y;\n const y0 = -before.s * v.x + before.c * v.y;\n const x = after.c * x0 - after.s * y0;\n const y = after.s * x0 + after.c * y0;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function transform(x: number, y: number, a: number): TransformValue {\n return { p: vec2(x, y), q: rotation(a) };\n}\n\nexport function copyTransform(out: TransformValue, transform: TransformValue): TransformValue {\n out.p.x = transform.p.x;\n out.p.y = transform.p.y;\n out.q.s = transform.q.s;\n out.q.c = transform.q.c;\n return out;\n}\n\nexport function transformVec2(out: Vec2Value, xf: TransformValue, v: Vec2Value): Vec2Value {\n const x = xf.q.c * v.x - xf.q.s * v.y + xf.p.x;\n const y = xf.q.s * v.x + xf.q.c * v.y + xf.p.y;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function detransformVec2(out: Vec2Value, xf: TransformValue, v: Vec2Value): Vec2Value {\n const px = v.x - xf.p.x;\n const py = v.y - xf.p.y;\n const x = (xf.q.c * px + xf.q.s * py);\n const y = (-xf.q.s * px + xf.q.c * py);\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function retransformVec2(out: Vec2Value, from: TransformValue, to: TransformValue, v: Vec2Value): Vec2Value {\n const x0 = from.q.c * v.x - from.q.s * v.y + from.p.x;\n const y0 = from.q.s * v.x + from.q.c * v.y + from.p.y;\n const px = x0 - to.p.x;\n const py = y0 - to.p.y;\n const x = to.q.c * px + to.q.s * py;\n const y = -to.q.s * px + to.q.c * py;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function detransformTransform(out: TransformValue, a: TransformValue, b: TransformValue): TransformValue {\n const c = a.q.c * b.q.c + a.q.s * b.q.s;\n const s = a.q.c * b.q.s - a.q.s * b.q.c;\n const x = a.q.c * (b.p.x - a.p.x) + a.q.s * (b.p.y - a.p.y);\n const y = -a.q.s * (b.p.x - a.p.x) + a.q.c * (b.p.y - a.p.y);\n out.q.c = c;\n out.q.s = s;\n out.p.x = x;\n out.p.y = y;\n return out;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n/** @internal */ const math_atan2 = Math.atan2;\n\nexport interface RotValue {\n /** sin(angle) */\n s: number;\n /** cos(angle) */\n c: number;\n}\n\ndeclare module \"./Rot\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(angle: number): Rot;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(obj: RotValue): Rot;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(): Rot;\n}\n\n/** Rotation */\n// @ts-expect-error\nexport class Rot {\n /** sin(angle) */\n s: number;\n /** cos(angle) */\n c: number;\n\n /** Initialize from an angle in radians. */\n constructor(angle?: number | RotValue) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Rot)) {\n return new Rot(angle);\n }\n if (typeof angle === \"number\") {\n this.setAngle(angle);\n } else if (typeof angle === \"object\") {\n this.setRot(angle);\n } else {\n this.setIdentity();\n }\n }\n\n /** @hidden */\n static neo(angle: number): Rot {\n const obj = Object.create(Rot.prototype);\n obj.setAngle(angle);\n return obj;\n }\n\n static clone(rot: RotValue): Rot {\n if (_ASSERT) Rot.assert(rot);\n const obj = Object.create(Rot.prototype);\n obj.s = rot.s;\n obj.c = rot.c;\n return obj;\n }\n\n static identity(): Rot {\n const obj = Object.create(Rot.prototype);\n obj.s = 0.0;\n obj.c = 1.0;\n return obj;\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.s) && Number.isFinite(obj.c);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Rot.isValid(o), \"Invalid Rot!\", o);\n }\n\n /** Set to the identity rotation. */\n setIdentity(): void {\n this.s = 0.0;\n this.c = 1.0;\n }\n\n set(angle: number | RotValue): void {\n if (typeof angle === \"object\") {\n if (_ASSERT) Rot.assert(angle);\n this.s = angle.s;\n this.c = angle.c;\n\n } else {\n if (_ASSERT) console.assert(Number.isFinite(angle));\n // TODO_ERIN optimize\n this.s = math_sin(angle);\n this.c = math_cos(angle);\n }\n }\n\n setRot(angle: RotValue): void {\n if (_ASSERT) Rot.assert(angle);\n this.s = angle.s;\n this.c = angle.c;\n }\n\n /** Set using an angle in radians. */\n setAngle(angle: number): void {\n if (_ASSERT) console.assert(Number.isFinite(angle));\n // TODO_ERIN optimize\n this.s = math_sin(angle);\n this.c = math_cos(angle);\n }\n\n /** Get the angle in radians. */\n getAngle(): number {\n return math_atan2(this.s, this.c);\n }\n\n /** Get the x-axis. */\n getXAxis(): Vec2 {\n return Vec2.neo(this.c, this.s);\n }\n\n /** Get the y-axis. */\n getYAxis(): Vec2 {\n return Vec2.neo(-this.s, this.c);\n }\n\n /** Multiply two rotations: q * r */\n static mul(rot: RotValue, m: RotValue): Rot;\n /** Rotate a vector */\n static mul(rot: RotValue, m: Vec2Value): Vec2;\n static mul(rot, m) {\n if (_ASSERT) Rot.assert(rot);\n if (\"c\" in m && \"s\" in m) {\n if (_ASSERT) Rot.assert(m);\n // [qc -qs] * [rc -rs] = [qc*rc-qs*rs -qc*rs-qs*rc]\n // [qs qc] [rs rc] [qs*rc+qc*rs -qs*rs+qc*rc]\n // s = qs * rc + qc * rs\n // c = qc * rc - qs * rs\n const qr = Rot.identity();\n qr.s = rot.s * m.c + rot.c * m.s;\n qr.c = rot.c * m.c - rot.s * m.s;\n return qr;\n\n } else if (\"x\" in m && \"y\" in m) {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x - rot.s * m.y, rot.s * m.x + rot.c * m.y);\n }\n }\n\n /** Multiply two rotations: q * r */\n static mulRot(rot: RotValue, m: RotValue): Rot {\n if (_ASSERT) Rot.assert(rot);\n if (_ASSERT) Rot.assert(m);\n // [qc -qs] * [rc -rs] = [qc*rc-qs*rs -qc*rs-qs*rc]\n // [qs qc] [rs rc] [qs*rc+qc*rs -qs*rs+qc*rc]\n // s = qs * rc + qc * rs\n // c = qc * rc - qs * rs\n const qr = Rot.identity();\n qr.s = rot.s * m.c + rot.c * m.s;\n qr.c = rot.c * m.c - rot.s * m.s;\n return qr;\n }\n\n /** Rotate a vector */\n static mulVec2(rot: RotValue, m: Vec2Value): Vec2 {\n if (_ASSERT) Rot.assert(rot);\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x - rot.s * m.y, rot.s * m.x + rot.c * m.y);\n }\n\n static mulSub(rot: RotValue, v: Vec2Value, w: Vec2Value): Vec2 {\n const x = rot.c * (v.x - w.x) - rot.s * (v.y - w.y);\n const y = rot.s * (v.x - w.x) + rot.c * (v.y - w.y);\n return Vec2.neo(x, y);\n }\n\n /** Transpose multiply two rotations: qT * r */\n static mulT(rot: RotValue, m: RotValue): Rot;\n /** Inverse rotate a vector */\n static mulT(rot: RotValue, m: Vec2Value): Vec2;\n static mulT(rot, m) {\n if (\"c\" in m && \"s\" in m) {\n if (_ASSERT) Rot.assert(m);\n // [ qc qs] * [rc -rs] = [qc*rc+qs*rs -qc*rs+qs*rc]\n // [-qs qc] [rs rc] [-qs*rc+qc*rs qs*rs+qc*rc]\n // s = qc * rs - qs * rc\n // c = qc * rc + qs * rs\n const qr = Rot.identity();\n qr.s = rot.c * m.s - rot.s * m.c;\n qr.c = rot.c * m.c + rot.s * m.s;\n return qr;\n\n } else if (\"x\" in m && \"y\" in m) {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x + rot.s * m.y, -rot.s * m.x + rot.c * m.y);\n }\n }\n\n /** Transpose multiply two rotations: qT * r */\n static mulTRot(rot: RotValue, m: RotValue): Rot {\n if (_ASSERT) Rot.assert(m);\n // [ qc qs] * [rc -rs] = [qc*rc+qs*rs -qc*rs+qs*rc]\n // [-qs qc] [rs rc] [-qs*rc+qc*rs qs*rs+qc*rc]\n // s = qc * rs - qs * rc\n // c = qc * rc + qs * rs\n const qr = Rot.identity();\n qr.s = rot.c * m.s - rot.s * m.c;\n qr.c = rot.c * m.c + rot.s * m.s;\n return qr;\n }\n\n /** Inverse rotate a vector */\n static mulTVec2(rot: RotValue, m: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x + rot.s * m.y, -rot.s * m.x + rot.c * m.y);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"./Matrix\";\nimport { mod } from \"./Math\";\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { TransformValue } from \"./Transform\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_atan2 = Math.atan2;\n/** @internal */ const math_PI = Math.PI;\n\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n\n/**\n * This describes the motion of a body/shape for TOI computation. Shapes are\n * defined with respect to the body origin, which may not coincide with the\n * center of mass. However, to support dynamics we must interpolate the center\n * of mass position.\n */\nexport class Sweep {\n /** Local center of mass position */\n localCenter = Vec2.zero();\n\n /** World center position */\n c = Vec2.zero();\n\n /** World angle */\n a = 0;\n\n /** Fraction of the current time step in the range [0,1], c0 and a0 are c and a at alpha0. */\n alpha0 = 0;\n\n c0 = Vec2.zero();\n a0 = 0;\n\n /** @internal */\n recycle() {\n matrix.zeroVec2(this.localCenter);\n matrix.zeroVec2(this.c);\n this.a = 0;\n this.alpha0 = 0;\n matrix.zeroVec2(this.c0);\n this.a0 = 0;\n }\n\n setTransform(xf: TransformValue): void {\n matrix.transformVec2(temp, xf, this.localCenter);\n matrix.copyVec2(this.c, temp);\n matrix.copyVec2(this.c0, temp);\n\n this.a = this.a0 = math_atan2(xf.q.s, xf.q.c);\n }\n\n setLocalCenter(localCenter: Vec2Value, xf: TransformValue): void {\n matrix.copyVec2(this.localCenter, localCenter);\n\n matrix.transformVec2(temp, xf, this.localCenter);\n matrix.copyVec2(this.c, temp);\n matrix.copyVec2(this.c0, temp);\n }\n\n /**\n * Get the interpolated transform at a specific time.\n *\n * @param xf\n * @param beta A factor in [0,1], where 0 indicates alpha0\n */\n getTransform(xf: TransformValue, beta: number = 0): void {\n matrix.setRotAngle(xf.q, (1.0 - beta) * this.a0 + beta * this.a);\n matrix.combine2Vec2(xf.p, (1.0 - beta), this.c0, beta, this.c);\n\n // shift to origin\n matrix.minusVec2(xf.p, matrix.rotVec2(temp, xf.q, this.localCenter));\n }\n\n /**\n * Advance the sweep forward, yielding a new initial state.\n *\n * @param alpha The new initial time\n */\n advance(alpha: number): void {\n if (_ASSERT) console.assert(this.alpha0 < 1.0);\n const beta = (alpha - this.alpha0) / (1.0 - this.alpha0);\n matrix.combine2Vec2(this.c0, beta, this.c, 1 - beta, this.c0);\n this.a0 = beta * this.a + (1 - beta) * this.a0;\n this.alpha0 = alpha;\n }\n\n forward(): void {\n this.a0 = this.a;\n matrix.copyVec2(this.c0, this.c);\n }\n\n /**\n * normalize the angles in radians to be between -pi and pi.\n */\n normalize(): void {\n const a0 = mod(this.a0, -math_PI, +math_PI);\n this.a -= this.a0 - a0;\n this.a0 = a0;\n }\n\n set(that: Sweep): void {\n matrix.copyVec2(this.localCenter, that.localCenter);\n matrix.copyVec2(this.c, that.c);\n this.a = that.a;\n this.alpha0 = that.alpha0;\n matrix.copyVec2(this.c0, that.c0);\n this.a0 = that.a0;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { Rot, RotValue } from \"./Rot\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\nexport type TransformValue = {\n p: Vec2Value;\n q: RotValue;\n};\n\ndeclare module \"./Transform\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Transform(position?: Vec2Value, rotation?: number): Transform;\n}\n\n/**\n * A transform contains translation and rotation. It is used to represent the\n * position and orientation of rigid frames. Initialize using a position vector\n * and a rotation.\n */\n// @ts-expect-error\nexport class Transform {\n /** position */\n p: Vec2;\n\n /** rotation */\n q: Rot;\n\n constructor(position?: Vec2Value, rotation?: number) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Transform)) {\n return new Transform(position, rotation);\n }\n this.p = Vec2.zero();\n this.q = Rot.identity();\n if (typeof position !== \"undefined\") {\n this.p.setVec2(position);\n }\n if (typeof rotation !== \"undefined\") {\n this.q.setAngle(rotation);\n }\n }\n\n static clone(xf: Transform): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.clone(xf.p);\n obj.q = Rot.clone(xf.q);\n return obj;\n }\n\n /** @hidden */\n static neo(position: Vec2Value, rotation: Rot): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.clone(position);\n obj.q = Rot.clone(rotation);\n return obj;\n }\n\n static identity(): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.zero();\n obj.q = Rot.identity();\n return obj;\n }\n\n /** Set this to the identity transform */\n setIdentity(): void {\n this.p.setZero();\n this.q.setIdentity();\n }\n\n /** Set position and angle */\n set(position: Vec2Value, rotation: number): void;\n /** Copy from another transform */\n set(xf: TransformValue): void;\n set(a: any, b?: any) {\n if (typeof b === \"undefined\") {\n this.p.set(a.p);\n this.q.set(a.q);\n } else {\n this.p.set(a);\n this.q.set(b);\n }\n }\n\n /** Set position and angle */\n setNum(position: Vec2Value, rotation: number) {\n this.p.setVec2(position);\n this.q.setAngle(rotation);\n }\n\n setTransform(xf: TransformValue): void {\n this.p.setVec2(xf.p);\n this.q.setRot(xf.q);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.p) && Rot.isValid(obj.q);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Transform.isValid(o), \"Invalid Transform!\", o);\n }\n\n static mul(a: TransformValue, b: Vec2Value): Vec2;\n static mul(a: TransformValue, b: TransformValue): Transform;\n // static mul(a: Transform, b: Vec2Value[]): Vec2[];\n // static mul(a: Transform, b: Transform[]): Transform[];\n static mul(a, b) {\n if (Array.isArray(b)) {\n // todo: this was used in examples, remove in the future\n if (_ASSERT) Transform.assert(a);\n const arr = [];\n for (let i = 0; i < b.length; i++) {\n arr[i] = Transform.mul(a, b[i]);\n }\n return arr;\n\n } else if (\"x\" in b && \"y\" in b) {\n return Transform.mulVec2(a, b);\n\n } else if (\"p\" in b && \"q\" in b) {\n return Transform.mulXf(a, b);\n }\n }\n\n static mulAll(a: Transform, b: Vec2Value[]): Vec2[];\n static mulAll(a: Transform, b: Transform[]): Transform[];\n static mulAll(a: TransformValue, b) {\n if (_ASSERT) Transform.assert(a);\n const arr = [];\n for (let i = 0; i < b.length; i++) {\n arr[i] = Transform.mul(a, b[i]);\n }\n return arr;\n }\n\n /** @hidden @deprecated */\n static mulFn(a: TransformValue) {\n // todo: this was used in examples, remove in the future\n if (_ASSERT) Transform.assert(a);\n return function(b: Vec2Value): Vec2 {\n return Transform.mul(a, b);\n };\n }\n\n static mulVec2(a: TransformValue, b: Vec2Value): Vec2 {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const x = (a.q.c * b.x - a.q.s * b.y) + a.p.x;\n const y = (a.q.s * b.x + a.q.c * b.y) + a.p.y;\n return Vec2.neo(x, y);\n }\n\n static mulXf(a: TransformValue, b: TransformValue): Transform {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Transform.assert(b);\n // v2 = A.q.Rot(B.q.Rot(v1) + B.p) + A.p\n // = (A.q * B.q).Rot(v1) + A.q.Rot(B.p) + A.p\n const xf = Transform.identity();\n xf.q = Rot.mulRot(a.q, b.q);\n xf.p = Vec2.add(Rot.mulVec2(a.q, b.p), a.p);\n return xf;\n }\n\n static mulT(a: TransformValue, b: Vec2Value): Vec2;\n static mulT(a: TransformValue, b: TransformValue): Transform;\n static mulT(a, b) {\n if (\"x\" in b && \"y\" in b) {\n return Transform.mulTVec2(a, b);\n\n } else if (\"p\" in b && \"q\" in b) {\n return Transform.mulTXf(a, b);\n }\n }\n\n static mulTVec2(a: TransformValue, b: Vec2Value): Vec2 {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const px = b.x - a.p.x;\n const py = b.y - a.p.y;\n const x = (a.q.c * px + a.q.s * py);\n const y = (-a.q.s * px + a.q.c * py);\n return Vec2.neo(x, y);\n }\n\n static mulTXf(a: TransformValue, b: TransformValue): Transform {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Transform.assert(b);\n // v2 = A.q' * (B.q * v1 + B.p - A.p)\n // = A.q' * B.q * v1 + A.q' * (B.p - A.p)\n const xf = Transform.identity();\n xf.q.setRot(Rot.mulTRot(a.q, b.q));\n xf.p.setVec2(Rot.mulTVec2(a.q, Vec2.sub(b.p, a.p)));\n return xf;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2 } from \"../common/Vec2\";\n\nexport class Velocity {\n /** linear */\n v = Vec2.zero();\n\n /** angular */\n w = 0;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { TransformValue } from \"../common/Transform\";\n\n\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n\n\nexport class Position {\n /** location */\n c = Vec2.zero();\n\n /** angle */\n a = 0;\n\n // todo: cache sin/cos\n getTransform(xf: TransformValue, p: Vec2Value): TransformValue {\n // xf.q = rotation(this.a);\n // xf.p = this.c - xf.q * p\n xf.q.c = math_cos(this.a);\n xf.q.s = math_sin(this.a);\n xf.p.x = this.c.x - (xf.q.c * p.x - xf.q.s * p.y);\n xf.p.y = this.c.y - (xf.q.s * p.x + xf.q.c * p.y);\n return xf;\n }\n}\n\nexport function getTransform(xf: TransformValue, p: Vec2Value, c: Vec2Value, a: number): TransformValue {\n // xf.q = rotation(a);\n // xf.p = this.c - xf.q * p\n xf.q.c = math_cos(a);\n xf.q.s = math_sin(a);\n xf.p.x = c.x - (xf.q.c * p.x - xf.q.s * p.y);\n xf.p.y = c.y - (xf.q.s * p.x + xf.q.c * p.y);\n return xf;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { MassData } from \"../dynamics/Body\";\nimport { RayCastOutput, RayCastInput, AABBValue } from \"./AABB\";\nimport { DistanceProxy } from \"./Distance\";\nimport type { Transform, TransformValue } from \"../common/Transform\";\nimport type { Vec2Value } from \"../common/Vec2\";\nimport { Style } from \"../util/Testbed\";\n\n// todo make shape an interface\n\n/**\n * A shape is used for collision detection. You can create a shape however you\n * like. Shapes used for simulation in World are created automatically when a\n * Fixture is created. Shapes may encapsulate one or more child shapes.\n */\nexport abstract class Shape {\n /** @hidden */ m_type: ShapeType;\n\n /**\n * @hidden\n * Radius of a shape. For polygonal shapes this must be b2_polygonRadius.\n * There is no support for making rounded polygons.\n */\n m_radius: number;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n /** @hidden */\n abstract _reset(): void;\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return typeof obj.m_type === \"string\" && typeof obj.m_radius === \"number\";\n }\n\n abstract getRadius(): number;\n\n /**\n * Get the type of this shape. You can use this to down cast to the concrete\n * shape.\n *\n * @return the shape type.\n */\n abstract getType(): ShapeType;\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n abstract _clone(): Shape;\n\n /**\n * Get the number of child primitives.\n */\n abstract getChildCount(): number;\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n abstract testPoint(xf: TransformValue, p: Vec2Value): boolean;\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n abstract rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean;\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n abstract computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void;\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n abstract computeMass(massData: MassData, density?: number): void;\n\n abstract computeDistanceProxy(proxy: DistanceProxy, childIndex: number): void;\n\n}\n\nexport type ShapeType = \"circle\" | \"edge\" | \"polygon\" | \"chain\";\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { options } from \"../util/options\";\nimport { Vec2Value } from \"../common/Vec2\";\nimport { AABB, RayCastInput, RayCastOutput } from \"../collision/AABB\";\nimport { Shape, ShapeType } from \"../collision/Shape\";\nimport { Body, MassData } from \"./Body\";\nimport { BroadPhase } from \"../collision/BroadPhase\";\nimport { TransformValue } from \"../common/Transform\";\nimport { Style } from \"../util/Testbed\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/** @internal */ const synchronize_aabb1 = new AABB();\n/** @internal */ const synchronize_aabb2 = new AABB();\n/** @internal */ const displacement = matrix.vec2(0, 0);\n\n/**\n * A fixture definition is used to create a fixture. This class defines an\n * abstract fixture definition. You can reuse fixture definitions safely.\n */\nexport interface FixtureOpt {\n userData?: unknown;\n /**\n * The friction coefficient, usually in the range [0,1]\n */\n friction?: number;\n /**\n * The restitution (elasticity) usually in the range [0,1]\n */\n restitution?: number;\n /**\n * The density, usually in kg/m^2\n */\n density?: number;\n /**\n * A sensor shape collects contact information but never generates a collision response.\n */\n isSensor?: boolean;\n /**\n * Zero, positive or negative collision group.\n * Fixtures with same positive groupIndex always collide and fixtures with same negative groupIndex never collide.\n */\n filterGroupIndex?: number;\n /**\n * Collision category bit or bits that this fixture belongs to.\n * If groupIndex is zero or not matching, then at least one bit in this fixture categoryBits should match other fixture maskBits and vice versa.\n */\n filterCategoryBits?: number;\n /**\n * Collision category bit or bits that this fixture accept for collision.\n */\n filterMaskBits?: number;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\nexport interface FixtureDef extends FixtureOpt {\n shape: Shape;\n}\n\n/** @internal */ const FixtureDefDefault: FixtureOpt = {\n userData : null,\n friction : 0.2,\n restitution : 0.0,\n density : 0.0,\n isSensor : false,\n\n filterGroupIndex : 0,\n filterCategoryBits : 0x0001,\n filterMaskBits : 0xFFFF\n};\n\n/**\n * This proxy is used internally to connect shape children to the broad-phase.\n */\nexport class FixtureProxy {\n aabb: AABB;\n fixture: Fixture;\n childIndex: number;\n proxyId: number;\n constructor(fixture: Fixture, childIndex: number) {\n this.aabb = new AABB();\n this.fixture = fixture;\n this.childIndex = childIndex;\n // this.proxyId;\n }\n}\n\n/**\n * A fixture is used to attach a shape to a body for collision detection. A\n * fixture inherits its transform from its parent. Fixtures hold additional\n * non-geometric data such as friction, collision filters, etc.\n *\n * To create a new Fixture use {@link Body.createFixture}.\n */\nexport class Fixture {\n /** @internal */ m_body: Body;\n /** @internal */ m_friction: number;\n /** @internal */ m_restitution: number;\n /** @internal */ m_density: number;\n /** @internal */ m_isSensor: boolean;\n /** @internal */ m_filterGroupIndex: number;\n /** @internal */ m_filterCategoryBits: number;\n /** @internal */ m_filterMaskBits: number;\n /** @internal */ m_shape: Shape;\n /** @internal */ m_next: Fixture | null;\n /** @internal */ m_proxies: FixtureProxy[];\n // 0 indicates inactive state, this is not the same as m_proxies.length\n /** @internal */ m_proxyCount: number;\n /** @internal */ m_userData: unknown;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n constructor(body: Body, def: FixtureDef);\n constructor(body: Body, shape: Shape, def?: FixtureOpt);\n constructor(body: Body, shape: Shape, density?: number);\n /** @internal */\n constructor(body: Body, shape?, def?) {\n if (shape.shape) {\n def = shape;\n shape = shape.shape;\n\n } else if (typeof def === \"number\") {\n def = {density : def};\n }\n\n def = options(def, FixtureDefDefault);\n\n this.m_body = body;\n\n this.m_friction = def.friction;\n this.m_restitution = def.restitution;\n this.m_density = def.density;\n this.m_isSensor = def.isSensor;\n\n this.m_filterGroupIndex = def.filterGroupIndex;\n this.m_filterCategoryBits = def.filterCategoryBits;\n this.m_filterMaskBits = def.filterMaskBits;\n\n // TODO validate shape\n this.m_shape = shape; // .clone();\n\n this.m_next = null;\n\n this.m_proxies = [];\n this.m_proxyCount = 0;\n\n // fixture proxies are created here,\n // but they are activate in when a fixture is added to body\n const childCount = this.m_shape.getChildCount();\n for (let i = 0; i < childCount; ++i) {\n this.m_proxies[i] = new FixtureProxy(this, i);\n }\n\n this.m_userData = def.userData;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /** @hidden Re-setup fixture. */\n _reset(): void {\n const body = this.getBody();\n const broadPhase = body.m_world.m_broadPhase;\n this.destroyProxies(broadPhase);\n if (this.m_shape._reset) {\n this.m_shape._reset();\n }\n const childCount = this.m_shape.getChildCount();\n for (let i = 0; i < childCount; ++i) {\n this.m_proxies[i] = new FixtureProxy(this, i);\n }\n this.createProxies(broadPhase, body.m_xf);\n body.resetMassData();\n }\n\n /** @internal */\n _serialize(): object {\n return {\n friction: this.m_friction,\n restitution: this.m_restitution,\n density: this.m_density,\n isSensor: this.m_isSensor,\n\n filterGroupIndex: this.m_filterGroupIndex,\n filterCategoryBits: this.m_filterCategoryBits,\n filterMaskBits: this.m_filterMaskBits,\n\n shape: this.m_shape,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, body: any, restore: any): Fixture {\n const shape = restore(Shape, data.shape);\n const fixture = shape && new Fixture(body, shape, data);\n return fixture;\n }\n\n /**\n * Get the type of the child shape. You can use this to down cast to the\n * concrete shape.\n */\n getType(): ShapeType {\n return this.m_shape.m_type;\n }\n\n /**\n * Get the child shape. You can modify the child shape, however you should not\n * change the number of vertices because this will crash some collision caching\n * mechanisms. Manipulating the shape may lead to non-physical behavior.\n */\n getShape(): Shape {\n return this.m_shape;\n }\n\n /**\n * A sensor shape collects contact information but never generates a collision\n * response.\n */\n isSensor(): boolean {\n return this.m_isSensor;\n }\n\n /**\n * Set if this fixture is a sensor.\n */\n setSensor(sensor: boolean): void {\n if (sensor != this.m_isSensor) {\n this.m_body.setAwake(true);\n this.m_isSensor = sensor;\n }\n }\n\n // /**\n // * Get the contact filtering data.\n // */\n // getFilterData() {\n // return this.m_filter;\n // }\n\n /**\n * Get the user data that was assigned in the fixture definition. Use this to\n * store your application specific data.\n */\n getUserData(): unknown {\n return this.m_userData;\n }\n\n /**\n * Set the user data. Use this to store your application specific data.\n */\n setUserData(data: unknown): void {\n this.m_userData = data;\n }\n\n /**\n * Get the parent body of this fixture. This is null if the fixture is not\n * attached.\n */\n getBody(): Body {\n return this.m_body;\n }\n\n /**\n * Get the next fixture in the parent body's fixture list.\n */\n getNext(): Fixture | null {\n return this.m_next;\n }\n\n /**\n * Get the density of this fixture.\n */\n getDensity(): number {\n return this.m_density;\n }\n\n /**\n * Set the density of this fixture. This will _not_ automatically adjust the\n * mass of the body. You must call Body.resetMassData to update the body's mass.\n */\n setDensity(density: number): void {\n if (_ASSERT) console.assert(Number.isFinite(density) && density >= 0.0);\n this.m_density = density;\n }\n\n /**\n * Get the coefficient of friction, usually in the range [0,1].\n */\n getFriction(): number {\n return this.m_friction;\n }\n\n /**\n * Set the coefficient of friction. This will not change the friction of\n * existing contacts.\n */\n setFriction(friction: number): void {\n this.m_friction = friction;\n }\n\n /**\n * Get the coefficient of restitution.\n */\n getRestitution(): number {\n return this.m_restitution;\n }\n\n /**\n * Set the coefficient of restitution. This will not change the restitution of\n * existing contacts.\n */\n setRestitution(restitution: number): void {\n this.m_restitution = restitution;\n }\n\n /**\n * Test a point in world coordinates for containment in this fixture.\n */\n testPoint(p: Vec2Value): boolean {\n return this.m_shape.testPoint(this.m_body.getTransform(), p);\n }\n\n /**\n * Cast a ray against this shape.\n */\n rayCast(output: RayCastOutput, input: RayCastInput, childIndex: number): boolean {\n return this.m_shape.rayCast(output, input, this.m_body.getTransform(), childIndex);\n }\n\n /**\n * Get the mass data for this fixture. The mass data is based on the density and\n * the shape. The rotational inertia is about the shape's origin. This operation\n * may be expensive.\n */\n getMassData(massData: MassData): void {\n this.m_shape.computeMass(massData, this.m_density);\n }\n\n /**\n * Get the fixture's AABB. This AABB may be enlarge and/or stale. If you need a\n * more accurate AABB, compute it using the shape and the body transform.\n */\n getAABB(childIndex: number): AABB {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_proxies.length);\n return this.m_proxies[childIndex].aabb;\n }\n\n /**\n * These support body activation/deactivation.\n */\n createProxies(broadPhase: BroadPhase, xf: TransformValue): void {\n if (_ASSERT) console.assert(this.m_proxyCount == 0);\n\n // Create proxies in the broad-phase.\n this.m_proxyCount = this.m_shape.getChildCount();\n\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n this.m_shape.computeAABB(proxy.aabb, xf, i);\n proxy.proxyId = broadPhase.createProxy(proxy.aabb, proxy);\n }\n }\n\n destroyProxies(broadPhase: BroadPhase): void {\n // Destroy proxies in the broad-phase.\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n broadPhase.destroyProxy(proxy.proxyId);\n proxy.proxyId = null;\n }\n\n this.m_proxyCount = 0;\n }\n\n /**\n * Updates this fixture proxy in broad-phase (with combined AABB of current and\n * next transformation).\n */\n synchronize(broadPhase: BroadPhase, xf1: TransformValue, xf2: TransformValue): void {\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n // Compute an AABB that covers the swept shape (may miss some rotation\n // effect).\n this.m_shape.computeAABB(synchronize_aabb1, xf1, proxy.childIndex);\n this.m_shape.computeAABB(synchronize_aabb2, xf2, proxy.childIndex);\n\n proxy.aabb.combine(synchronize_aabb1, synchronize_aabb2);\n\n matrix.subVec2(displacement, xf2.p, xf1.p);\n\n broadPhase.moveProxy(proxy.proxyId, proxy.aabb, displacement);\n }\n }\n\n /**\n * Set the contact filtering data. This will not update contacts until the next\n * time step when either parent body is active and awake. This automatically\n * calls refilter.\n */\n setFilterData(filter: { groupIndex: number, categoryBits: number, maskBits: number }): void {\n this.m_filterGroupIndex = filter.groupIndex;\n this.m_filterCategoryBits = filter.categoryBits;\n this.m_filterMaskBits = filter.maskBits;\n this.refilter();\n }\n\n getFilterGroupIndex(): number {\n return this.m_filterGroupIndex;\n }\n\n setFilterGroupIndex(groupIndex: number): void {\n this.m_filterGroupIndex = groupIndex;\n this.refilter();\n }\n\n getFilterCategoryBits(): number {\n return this.m_filterCategoryBits;\n }\n\n setFilterCategoryBits(categoryBits: number): void {\n this.m_filterCategoryBits = categoryBits;\n this.refilter();\n }\n\n getFilterMaskBits(): number {\n return this.m_filterMaskBits;\n }\n\n setFilterMaskBits(maskBits: number): void {\n this.m_filterMaskBits = maskBits;\n this.refilter();\n }\n\n /**\n * Call this if you want to establish collision that was previously disabled by\n * ContactFilter.\n */\n refilter(): void {\n if (this.m_body == null) {\n return;\n }\n\n // Flag associated contacts for filtering.\n let edge = this.m_body.getContactList();\n while (edge) {\n const contact = edge.contact;\n const fixtureA = contact.getFixtureA();\n const fixtureB = contact.getFixtureB();\n if (fixtureA == this || fixtureB == this) {\n contact.flagForFiltering();\n }\n\n edge = edge.next;\n }\n\n const world = this.m_body.getWorld();\n\n if (world == null) {\n return;\n }\n\n // Touch each proxy so that new pairs may be created\n const broadPhase = world.m_broadPhase;\n for (let i = 0; i < this.m_proxyCount; ++i) {\n broadPhase.touchProxy(this.m_proxies[i].proxyId);\n }\n }\n\n /**\n * Implement this method to provide collision filtering, if you want finer\n * control over contact creation.\n *\n * Return true if contact calculations should be performed between these two\n * fixtures.\n *\n * Warning: for performance reasons this is only called when the AABBs begin to\n * overlap.\n */\n shouldCollide(that: Fixture): boolean {\n\n if (that.m_filterGroupIndex === this.m_filterGroupIndex && that.m_filterGroupIndex !== 0) {\n return that.m_filterGroupIndex > 0;\n }\n\n const collideA = (that.m_filterMaskBits & this.m_filterCategoryBits) !== 0;\n const collideB = (that.m_filterCategoryBits & this.m_filterMaskBits) !== 0;\n const collide = collideA && collideB;\n return collide;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { options } from \"../util/options\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { Rot } from \"../common/Rot\";\nimport { Sweep } from \"../common/Sweep\";\nimport { Transform, TransformValue } from \"../common/Transform\";\nimport { Velocity } from \"./Velocity\";\nimport { Position } from \"./Position\";\nimport { Fixture, FixtureDef, FixtureOpt } from \"./Fixture\";\nimport { Shape } from \"../collision/Shape\";\nimport { JointEdge } from \"./Joint\";\nimport { World } from \"./World\";\nimport { ContactEdge } from \"./Contact\";\nimport { Style } from \"../util/Testbed\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A static body does not move under simulation and behaves as if it has infinite mass.\n * Internally, zero is stored for the mass and the inverse mass.\n * Static bodies can be moved manually by the user.\n * A static body has zero velocity.\n * Static bodies do not collide with other static or kinematic bodies.\n * \n * A kinematic body moves under simulation according to its velocity.\n * Kinematic bodies do not respond to forces.\n * They can be moved manually by the user, but normally a kinematic body is moved by setting its velocity.\n * A kinematic body behaves as if it has infinite mass, however, zero is stored for the mass and the inverse mass.\n * Kinematic bodies do not collide with other kinematic or static bodies.\n * \n * A dynamic body is fully simulated.\n * They can be moved manually by the user, but normally they move according to forces.\n * A dynamic body can collide with all body types.\n * A dynamic body always has finite, non-zero mass.\n * If you try to set the mass of a dynamic body to zero, it will automatically acquire a mass of one kilogram and it won't rotate.\n */\nexport type BodyType = \"static\" | \"kinematic\" | \"dynamic\";\n\n/** @internal */ const STATIC = \"static\";\n/** @internal */ const KINEMATIC = \"kinematic\";\n/** @internal */ const DYNAMIC = \"dynamic\";\n\n/** @internal */ const oldCenter = matrix.vec2(0, 0);\n/** @internal */ const localCenter = matrix.vec2(0, 0);\n/** @internal */ const shift = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n\nexport interface BodyDef {\n /**\n * Body types are static, kinematic, or dynamic. Note: if a dynamic\n * body would have zero mass, the mass is set to one.\n */\n type?: BodyType;\n /**\n * The world position of the body. Avoid creating bodies at the\n * origin since this can lead to many overlapping shapes.\n */\n position?: Vec2Value;\n /**\n * The world angle of the body in radians.\n */\n angle?: number;\n /**\n * The linear velocity of the body's origin in world co-ordinates.\n */\n linearVelocity?: Vec2Value;\n angularVelocity?: number;\n /**\n * Linear damping is use to reduce the linear velocity. The\n * damping parameter can be larger than 1.0 but the damping effect becomes\n * sensitive to the time step when the damping parameter is large.\n * Units are 1/time\n */\n linearDamping?: number;\n /**\n * Angular damping is use to reduce the angular velocity.\n * The damping parameter can be larger than 1.0 but the damping effect\n * becomes sensitive to the time step when the damping parameter is large.\n * Units are 1/time\n */\n angularDamping?: number;\n /**\n * Should this body be prevented from rotating? Useful for characters.\n */\n fixedRotation?: boolean;\n /**\n * Is this a fast moving body that should be prevented from\n * tunneling through other moving bodies? Note that all bodies are\n * prevented from tunneling through kinematic and static bodies. This\n * setting is only considered on dynamic bodies. Warning: You should use\n * this flag sparingly since it increases processing time.\n */\n bullet?: boolean;\n gravityScale?: number;\n /**\n * Set this flag to false if this body should never fall asleep. Note that this increases CPU usage.\n */\n allowSleep?: boolean;\n /**\n * Is this body initially awake or sleeping?\n */\n awake?: boolean;\n /**\n * Does this body start out active?\n */\n active?: boolean;\n userData?: any;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\n/** @internal */ const BodyDefDefault: BodyDef = {\n type : STATIC,\n position : Vec2.zero(),\n angle : 0.0,\n\n linearVelocity : Vec2.zero(),\n angularVelocity : 0.0,\n\n linearDamping : 0.0,\n angularDamping : 0.0,\n\n fixedRotation : false,\n bullet : false,\n gravityScale : 1.0,\n\n allowSleep : true,\n awake : true,\n active : true,\n\n userData : null\n};\n\n/**\n * MassData This holds the mass data computed for a shape.\n */\nexport interface MassData {\n /** The mass of the shape, usually in kilograms. */\n mass: number;\n /** The position of the shape's centroid relative to the shape's origin. */\n center: Vec2Value;\n /** The rotational inertia of the shape about the local origin. */\n I: number;\n}\n\n/**\n * A rigid body composed of one or more fixtures.\n *\n * To create a new Body use {@link World.createBody}.\n */\nexport class Body {\n /** @hidden */\n static readonly STATIC: BodyType = \"static\";\n /** @hidden */\n static readonly KINEMATIC: BodyType = \"kinematic\";\n /** @hidden */\n static readonly DYNAMIC: BodyType = \"dynamic\";\n\n /** @internal */ m_world: World;\n /** @internal */ m_awakeFlag: boolean;\n /** @internal */ m_autoSleepFlag: boolean;\n /** @internal */ m_bulletFlag: boolean;\n /** @internal */ m_fixedRotationFlag: boolean;\n /** @internal */ m_activeFlag: boolean;\n /** @internal */ m_islandFlag: boolean;\n /** @internal */ m_toiFlag: boolean;\n /** @internal */ m_userData: unknown;\n /** @internal */ m_type: BodyType;\n /** @internal */ m_mass: number;\n /** @internal */ m_invMass: number;\n /** @internal Rotational inertia about the center of mass. */\n m_I: number;\n /** @internal */ m_invI: number;\n /** @internal the body origin transform */\n m_xf: Transform;\n /** @internal the swept motion for CCD */\n m_sweep: Sweep;\n // position and velocity correction\n /** @internal */ c_velocity: Velocity;\n /** @internal */ c_position: Position;\n /** @internal */ m_force: Vec2;\n /** @internal */ m_torque: number;\n /** @internal */ m_linearVelocity: Vec2;\n /** @internal */ m_angularVelocity: number;\n /** @internal */ m_linearDamping: number;\n /** @internal */ m_angularDamping: number;\n /** @internal */ m_gravityScale: number;\n /** @internal */ m_sleepTime: number;\n /** @internal */ m_jointList: JointEdge | null;\n /** @internal */ m_contactList: ContactEdge | null;\n /** @internal */ m_fixtureList: Fixture | null;\n /** @internal */ m_prev: Body | null;\n /** @internal */ m_next: Body | null;\n /** @internal */ m_destroyed: boolean;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n /** @internal */\n constructor(world: World, def: BodyDef) {\n def = options(def, BodyDefDefault);\n\n if (_ASSERT) console.assert(Vec2.isValid(def.position));\n if (_ASSERT) console.assert(Vec2.isValid(def.linearVelocity));\n if (_ASSERT) console.assert(Number.isFinite(def.angle));\n if (_ASSERT) console.assert(Number.isFinite(def.angularVelocity));\n if (_ASSERT) console.assert(Number.isFinite(def.angularDamping) && def.angularDamping >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.linearDamping) && def.linearDamping >= 0.0);\n\n this.m_world = world;\n\n this.m_awakeFlag = def.awake;\n this.m_autoSleepFlag = def.allowSleep;\n this.m_bulletFlag = def.bullet;\n this.m_fixedRotationFlag = def.fixedRotation;\n this.m_activeFlag = def.active;\n\n this.m_islandFlag = false;\n this.m_toiFlag = false;\n\n this.m_userData = def.userData;\n this.m_type = def.type;\n\n if (this.m_type == DYNAMIC) {\n this.m_mass = 1.0;\n this.m_invMass = 1.0;\n } else {\n this.m_mass = 0.0;\n this.m_invMass = 0.0;\n }\n\n // Rotational inertia about the center of mass.\n this.m_I = 0.0;\n this.m_invI = 0.0;\n\n // the body origin transform\n this.m_xf = Transform.identity();\n this.m_xf.p.setVec2(def.position);\n this.m_xf.q.setAngle(def.angle);\n\n // the swept motion for CCD\n this.m_sweep = new Sweep();\n this.m_sweep.setTransform(this.m_xf);\n\n // position and velocity correction\n this.c_velocity = new Velocity();\n this.c_position = new Position();\n\n this.m_force = Vec2.zero();\n this.m_torque = 0.0;\n\n this.m_linearVelocity = Vec2.clone(def.linearVelocity);\n this.m_angularVelocity = def.angularVelocity;\n\n this.m_linearDamping = def.linearDamping;\n this.m_angularDamping = def.angularDamping;\n this.m_gravityScale = def.gravityScale;\n\n this.m_sleepTime = 0.0;\n\n this.m_jointList = null;\n this.m_contactList = null;\n this.m_fixtureList = null;\n\n this.m_prev = null;\n this.m_next = null;\n\n this.m_destroyed = false;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /** @internal */\n _serialize(): object {\n const fixtures = [];\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n fixtures.push(f);\n }\n return {\n type: this.m_type,\n bullet: this.m_bulletFlag,\n position: this.m_xf.p,\n angle: this.m_xf.q.getAngle(),\n linearVelocity: this.m_linearVelocity,\n angularVelocity: this.m_angularVelocity,\n fixtures,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): Body {\n const body = new Body(world, data);\n\n if (data.fixtures) {\n for (let i = data.fixtures.length - 1; i >= 0; i--) {\n const fixture = restore(Fixture, data.fixtures[i], body);\n body._addFixture(fixture);\n }\n }\n return body;\n }\n\n isWorldLocked(): boolean {\n return this.m_world && this.m_world.isLocked() ? true : false;\n }\n\n getWorld(): World {\n return this.m_world;\n }\n\n getNext(): Body | null {\n return this.m_next;\n }\n\n setUserData(data: any): void {\n this.m_userData = data;\n }\n\n getUserData(): unknown {\n return this.m_userData;\n }\n\n getFixtureList(): Fixture | null {\n return this.m_fixtureList;\n }\n\n getJointList(): JointEdge | null {\n return this.m_jointList;\n }\n\n /**\n * Warning: this list changes during the time step and you may miss some\n * collisions if you don't use ContactListener.\n */\n getContactList(): ContactEdge | null {\n return this.m_contactList;\n }\n\n isStatic(): boolean {\n return this.m_type == STATIC;\n }\n\n isDynamic(): boolean {\n return this.m_type == DYNAMIC;\n }\n\n isKinematic(): boolean {\n return this.m_type == KINEMATIC;\n }\n\n /**\n * This will alter the mass and velocity.\n */\n setStatic(): Body {\n this.setType(STATIC);\n return this;\n }\n\n setDynamic(): Body {\n this.setType(DYNAMIC);\n return this;\n }\n\n setKinematic(): Body {\n this.setType(KINEMATIC);\n return this;\n }\n\n /**\n * Get the type of the body.\n */\n getType(): BodyType {\n return this.m_type;\n }\n\n /**\n * Set the type of the body to \"static\", \"kinematic\" or \"dynamic\".\n * @param type The type of the body.\n */\n setType(type: BodyType): void {\n if (_ASSERT) console.assert(type === STATIC || type === KINEMATIC || type === DYNAMIC);\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (this.m_type == type) {\n return;\n }\n\n this.m_type = type;\n\n this.resetMassData();\n\n if (this.m_type == STATIC) {\n this.m_linearVelocity.setZero();\n this.m_angularVelocity = 0.0;\n this.m_sweep.forward();\n this.synchronizeFixtures();\n }\n\n this.setAwake(true);\n\n this.m_force.setZero();\n this.m_torque = 0.0;\n\n // Delete the attached contacts.\n let ce = this.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n this.m_world.destroyContact(ce0.contact);\n }\n this.m_contactList = null;\n\n // Touch the proxies so that new contacts will be created (when appropriate)\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n for (let i = 0; i < f.m_proxyCount; ++i) {\n broadPhase.touchProxy(f.m_proxies[i].proxyId);\n }\n }\n }\n\n isBullet(): boolean {\n return this.m_bulletFlag;\n }\n\n /**\n * Should this body be treated like a bullet for continuous collision detection?\n */\n setBullet(flag: boolean): void {\n this.m_bulletFlag = !!flag;\n }\n\n isSleepingAllowed(): boolean {\n return this.m_autoSleepFlag;\n }\n\n setSleepingAllowed(flag: boolean): void {\n this.m_autoSleepFlag = !!flag;\n if (this.m_autoSleepFlag == false) {\n this.setAwake(true);\n }\n }\n\n isAwake(): boolean {\n return this.m_awakeFlag;\n }\n\n /**\n * Set the sleep state of the body. A sleeping body has very low CPU cost.\n *\n * @param flag Set to true to wake the body, false to put it to sleep.\n */\n setAwake(flag: boolean): void {\n if (flag) {\n this.m_awakeFlag = true;\n this.m_sleepTime = 0.0;\n } else {\n this.m_awakeFlag = false;\n this.m_sleepTime = 0.0;\n this.m_linearVelocity.setZero();\n this.m_angularVelocity = 0.0;\n this.m_force.setZero();\n this.m_torque = 0.0;\n }\n }\n\n isActive(): boolean {\n return this.m_activeFlag;\n }\n\n /**\n * Set the active state of the body. An inactive body is not simulated and\n * cannot be collided with or woken up. If you pass a flag of true, all fixtures\n * will be added to the broad-phase. If you pass a flag of false, all fixtures\n * will be removed from the broad-phase and all contacts will be destroyed.\n * Fixtures and joints are otherwise unaffected.\n *\n * You may continue to create/destroy fixtures and joints on inactive bodies.\n * Fixtures on an inactive body are implicitly inactive and will not participate\n * in collisions, ray-casts, or queries. Joints connected to an inactive body\n * are implicitly inactive. An inactive body is still owned by a World object\n * and remains\n */\n setActive(flag: boolean): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (flag == this.m_activeFlag) {\n return;\n }\n\n this.m_activeFlag = !!flag;\n\n if (this.m_activeFlag) {\n // Create all proxies.\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.createProxies(broadPhase, this.m_xf);\n }\n\t\t // Contacts are created at the beginning of the next\n\t\t this.m_world.m_newFixture = true;\n } else {\n // Destroy all proxies.\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.destroyProxies(broadPhase);\n }\n\n // Destroy the attached contacts.\n let ce = this.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n this.m_world.destroyContact(ce0.contact);\n }\n this.m_contactList = null;\n }\n }\n\n isFixedRotation(): boolean {\n return this.m_fixedRotationFlag;\n }\n\n /**\n * Set this body to have fixed rotation. This causes the mass to be reset.\n */\n setFixedRotation(flag: boolean): void {\n if (this.m_fixedRotationFlag == flag) {\n return;\n }\n\n this.m_fixedRotationFlag = !!flag;\n\n this.m_angularVelocity = 0.0;\n\n this.resetMassData();\n }\n\n /**\n * Get the world transform for the body's origin.\n */\n getTransform(): Transform {\n return this.m_xf;\n }\n\n /**\n * Set the position of the body's origin and rotation. Manipulating a body's\n * transform may cause non-physical behavior. Note: contacts are updated on the\n * next call to World.step.\n *\n * @param position The world position of the body's local origin.\n * @param angle The world rotation in radians.\n */\n setTransform(position: Vec2Value, angle: number): void;\n /**\n * Set the position of the body's origin and rotation. Manipulating a body's\n * transform may cause non-physical behavior. Note: contacts are updated on the\n * next call to World.step.\n */\n setTransform(xf: Transform): void;\n setTransform(a: Vec2Value | Transform, b?: number): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return;\n }\n if (typeof b === \"number\") {\n this.m_xf.setNum(a as Vec2Value, b);\n } else {\n this.m_xf.setTransform(a as TransformValue);\n }\n\n this.m_sweep.setTransform(this.m_xf);\n\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.synchronize(broadPhase, this.m_xf, this.m_xf);\n }\n this.setAwake(true);\n }\n\n synchronizeTransform(): void {\n this.m_sweep.getTransform(this.m_xf, 1);\n }\n\n /**\n * Update fixtures in broad-phase.\n */\n synchronizeFixtures(): void {\n this.m_sweep.getTransform(xf, 0);\n\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.synchronize(broadPhase, xf, this.m_xf);\n }\n }\n\n /**\n * Used in TOI.\n */\n advance(alpha: number): void {\n // Advance to the new safe time. This doesn't sync the broad-phase.\n this.m_sweep.advance(alpha);\n matrix.copyVec2(this.m_sweep.c, this.m_sweep.c0);\n this.m_sweep.a = this.m_sweep.a0;\n this.m_sweep.getTransform(this.m_xf, 1);\n }\n\n /**\n * Get the world position for the body's origin.\n */\n getPosition(): Vec2 {\n return this.m_xf.p;\n }\n\n setPosition(p: Vec2Value): void {\n this.setTransform(p, this.m_sweep.a);\n }\n\n /**\n * Get the current world rotation angle in radians.\n */\n getAngle(): number {\n return this.m_sweep.a;\n }\n\n setAngle(angle: number): void {\n this.setTransform(this.m_xf.p, angle);\n }\n\n /**\n * Get the world position of the center of mass.\n */\n getWorldCenter(): Vec2 {\n return this.m_sweep.c;\n }\n\n /**\n * Get the local position of the center of mass.\n */\n getLocalCenter(): Vec2 {\n return this.m_sweep.localCenter;\n }\n\n /**\n * Get the linear velocity of the center of mass.\n *\n * @return the linear velocity of the center of mass.\n */\n getLinearVelocity(): Vec2 {\n return this.m_linearVelocity;\n }\n\n /**\n * Get the world linear velocity of a world point attached to this body.\n *\n * @param worldPoint A point in world coordinates.\n */\n getLinearVelocityFromWorldPoint(worldPoint: Vec2Value): Vec2 {\n const localCenter = Vec2.sub(worldPoint, this.m_sweep.c);\n return Vec2.add(this.m_linearVelocity, Vec2.crossNumVec2(this.m_angularVelocity,\n localCenter));\n }\n\n /**\n * Get the world velocity of a local point.\n *\n * @param localPoint A point in local coordinates.\n */\n getLinearVelocityFromLocalPoint(localPoint: Vec2Value): Vec2 {\n return this.getLinearVelocityFromWorldPoint(this.getWorldPoint(localPoint));\n }\n\n /**\n * Set the linear velocity of the center of mass.\n *\n * @param v The new linear velocity of the center of mass.\n */\n setLinearVelocity(v: Vec2Value): void {\n if (this.m_type == STATIC) {\n return;\n }\n if (Vec2.dot(v, v) > 0.0) {\n this.setAwake(true);\n }\n this.m_linearVelocity.setVec2(v);\n }\n\n /**\n * Get the angular velocity.\n *\n * @returns the angular velocity in radians/second.\n */\n getAngularVelocity(): number {\n return this.m_angularVelocity;\n }\n\n /**\n * Set the angular velocity.\n *\n * @param w The new angular velocity in radians/second.\n */\n setAngularVelocity(w: number): void {\n if (this.m_type == STATIC) {\n return;\n }\n if (w * w > 0.0) {\n this.setAwake(true);\n }\n this.m_angularVelocity = w;\n }\n\n getLinearDamping(): number {\n return this.m_linearDamping;\n }\n\n setLinearDamping(linearDamping: number): void {\n this.m_linearDamping = linearDamping;\n }\n\n getAngularDamping(): number {\n return this.m_angularDamping;\n }\n\n setAngularDamping(angularDamping: number): void {\n this.m_angularDamping = angularDamping;\n }\n\n getGravityScale(): number {\n return this.m_gravityScale;\n }\n\n /**\n * Scale the gravity applied to this body.\n */\n setGravityScale(scale: number): void {\n this.m_gravityScale = scale;\n }\n\n /**\n * Get the total mass of the body.\n *\n * @returns The mass, usually in kilograms (kg).\n */\n getMass(): number {\n return this.m_mass;\n }\n\n /**\n * Get the rotational inertia of the body about the local origin.\n *\n * @return the rotational inertia, usually in kg-m^2.\n */\n getInertia(): number {\n return this.m_I + this.m_mass\n * Vec2.dot(this.m_sweep.localCenter, this.m_sweep.localCenter);\n }\n\n /**\n * Copy the mass data of the body to data.\n */\n getMassData(data: MassData): void {\n data.mass = this.m_mass;\n data.I = this.getInertia();\n matrix.copyVec2(data.center, this.m_sweep.localCenter);\n }\n\n /**\n * This resets the mass properties to the sum of the mass properties of the\n * fixtures. This normally does not need to be called unless you called\n * SetMassData to override the mass and you later want to reset the mass.\n */\n resetMassData(): void {\n // Compute mass data from shapes. Each shape has its own density.\n this.m_mass = 0.0;\n this.m_invMass = 0.0;\n this.m_I = 0.0;\n this.m_invI = 0.0;\n matrix.zeroVec2(this.m_sweep.localCenter);\n\n // Static and kinematic bodies have zero mass.\n if (this.isStatic() || this.isKinematic()) {\n matrix.copyVec2(this.m_sweep.c0, this.m_xf.p);\n matrix.copyVec2(this.m_sweep.c, this.m_xf.p);\n this.m_sweep.a0 = this.m_sweep.a;\n return;\n }\n\n if (_ASSERT) console.assert(this.isDynamic());\n\n // Accumulate mass over all fixtures.\n matrix.zeroVec2(localCenter);\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n if (f.m_density == 0.0) {\n continue;\n }\n\n const massData: MassData = {\n mass: 0,\n center: matrix.vec2(0, 0),\n I: 0\n };\n f.getMassData(massData);\n this.m_mass += massData.mass;\n matrix.plusScaleVec2(localCenter, massData.mass, massData.center);\n this.m_I += massData.I;\n }\n\n // Compute center of mass.\n if (this.m_mass > 0.0) {\n this.m_invMass = 1.0 / this.m_mass;\n matrix.scaleVec2(localCenter, this.m_invMass, localCenter);\n\n } else {\n // Force all dynamic bodies to have a positive mass.\n this.m_mass = 1.0;\n this.m_invMass = 1.0;\n }\n\n if (this.m_I > 0.0 && this.m_fixedRotationFlag == false) {\n // Center the inertia about the center of mass.\n this.m_I -= this.m_mass * matrix.dotVec2(localCenter, localCenter);\n if (_ASSERT) console.assert(this.m_I > 0.0);\n this.m_invI = 1.0 / this.m_I;\n\n } else {\n this.m_I = 0.0;\n this.m_invI = 0.0;\n }\n\n // Move center of mass.\n matrix.copyVec2(oldCenter, this.m_sweep.c);\n this.m_sweep.setLocalCenter(localCenter, this.m_xf);\n\n // Update center of mass velocity.\n matrix.subVec2(shift, this.m_sweep.c, oldCenter);\n matrix.crossNumVec2(temp, this.m_angularVelocity, shift);\n matrix.plusVec2(this.m_linearVelocity, temp);\n }\n\n /**\n * Set the mass properties to override the mass properties of the fixtures. Note\n * that this changes the center of mass position. Note that creating or\n * destroying fixtures can also alter the mass. This function has no effect if\n * the body isn't dynamic.\n *\n * @param massData The mass properties.\n */\n setMassData(massData: MassData): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (this.m_type != DYNAMIC) {\n return;\n }\n\n this.m_invMass = 0.0;\n this.m_I = 0.0;\n this.m_invI = 0.0;\n\n this.m_mass = massData.mass;\n if (this.m_mass <= 0.0) {\n this.m_mass = 1.0;\n }\n\n this.m_invMass = 1.0 / this.m_mass;\n\n if (massData.I > 0.0 && this.m_fixedRotationFlag == false) {\n this.m_I = massData.I - this.m_mass * matrix.dotVec2(massData.center, massData.center);\n if (_ASSERT) console.assert(this.m_I > 0.0);\n this.m_invI = 1.0 / this.m_I;\n }\n\n // Move center of mass.\n matrix.copyVec2(oldCenter, this.m_sweep.c);\n this.m_sweep.setLocalCenter(massData.center, this.m_xf);\n\n // Update center of mass velocity.\n matrix.subVec2(shift, this.m_sweep.c, oldCenter);\n matrix.crossNumVec2(temp, this.m_angularVelocity, shift);\n matrix.plusVec2(this.m_linearVelocity, temp);\n }\n\n /**\n * Apply a force at a world point. If the force is not applied at the center of\n * mass, it will generate a torque and affect the angular velocity. This wakes\n * up the body.\n *\n * @param force The world force vector, usually in Newtons (N).\n * @param point The world position of the point of application.\n * @param wake Also wake up the body\n */\n applyForce(force: Vec2Value, point: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping.\n if (this.m_awakeFlag) {\n this.m_force.add(force);\n this.m_torque += Vec2.crossVec2Vec2(Vec2.sub(point, this.m_sweep.c), force);\n }\n }\n\n /**\n * Apply a force to the center of mass. This wakes up the body.\n *\n * @param force The world force vector, usually in Newtons (N).\n * @param wake Also wake up the body\n */\n applyForceToCenter(force: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_force.add(force);\n }\n }\n\n /**\n * Apply a torque. This affects the angular velocity without affecting the\n * linear velocity of the center of mass. This wakes up the body.\n *\n * @param torque About the z-axis (out of the screen), usually in N-m.\n * @param wake Also wake up the body\n */\n applyTorque(torque: number, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_torque += torque;\n }\n }\n\n /**\n * Apply an impulse at a point. This immediately modifies the velocity. It also\n * modifies the angular velocity if the point of application is not at the\n * center of mass. This wakes up the body.\n *\n * @param impulse The world impulse vector, usually in N-seconds or kg-m/s.\n * @param point The world position of the point of application.\n * @param wake Also wake up the body\n */\n applyLinearImpulse(impulse: Vec2Value, point: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n\n // Don't accumulate velocity if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_linearVelocity.addMul(this.m_invMass, impulse);\n this.m_angularVelocity += this.m_invI * Vec2.crossVec2Vec2(Vec2.sub(point, this.m_sweep.c), impulse);\n }\n }\n\n /**\n * Apply an angular impulse.\n *\n * @param impulse The angular impulse in units of kg*m*m/s\n * @param wake Also wake up the body\n */\n applyAngularImpulse(impulse: number, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate velocity if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_angularVelocity += this.m_invI * impulse;\n }\n }\n\n /**\n * This is used to test if two bodies should collide.\n * \n * Bodies do not collide when:\n * - Neither of them is dynamic\n * - They are connected by a joint with collideConnected == false\n */\n shouldCollide(that: Body): boolean {\n // At least one body should be dynamic.\n if (this.m_type != DYNAMIC && that.m_type != DYNAMIC) {\n return false;\n }\n // Does a joint prevent collision?\n for (let jn = this.m_jointList; jn; jn = jn.next) {\n if (jn.other == that) {\n if (jn.joint.m_collideConnected == false) {\n return false;\n }\n }\n }\n return true;\n }\n\n /** @internal Used for deserialize. */\n _addFixture(fixture: Fixture): Fixture {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return null;\n }\n\n if (this.m_activeFlag) {\n const broadPhase = this.m_world.m_broadPhase;\n fixture.createProxies(broadPhase, this.m_xf);\n }\n\n fixture.m_next = this.m_fixtureList;\n this.m_fixtureList = fixture;\n\n // Adjust mass properties if needed.\n if (fixture.m_density > 0.0) {\n this.resetMassData();\n }\n\n // Let the world know we have a new fixture. This will cause new contacts\n // to be created at the beginning of the next time step.\n this.m_world.m_newFixture = true;\n\n return fixture;\n }\n\n /**\n * Creates a fixture and attach it to this body.\n *\n * If the density is non-zero, this function automatically updates the mass of\n * the body.\n *\n * Contacts are not created until the next time step.\n *\n * Warning: This function is locked during callbacks.\n */\n createFixture(def: FixtureDef): Fixture;\n createFixture(shape: Shape, opt?: FixtureOpt): Fixture;\n createFixture(shape: Shape, density?: number): Fixture;\n // tslint:disable-next-line:typedef\n createFixture(shape, fixdef?) {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return null;\n }\n\n const fixture = new Fixture(this, shape, fixdef);\n this._addFixture(fixture);\n return fixture;\n }\n\n /**\n * Destroy a fixture. This removes the fixture from the broad-phase and destroys\n * all contacts associated with this fixture. This will automatically adjust the\n * mass of the body if the body is dynamic and the fixture has positive density.\n * All fixtures attached to a body are implicitly destroyed when the body is\n * destroyed.\n *\n * Warning: This function is locked during callbacks.\n *\n * @param fixture The fixture to be removed.\n */\n destroyFixture(fixture: Fixture): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (_ASSERT) console.assert(fixture.m_body == this);\n\n // Remove the fixture from this body's singly linked list.\n let found = false;\n if (this.m_fixtureList === fixture) {\n this.m_fixtureList = fixture.m_next;\n found = true;\n\n } else {\n let node = this.m_fixtureList;\n while (node != null) {\n if (node.m_next === fixture) {\n node.m_next = fixture.m_next;\n found = true;\n break;\n }\n node = node.m_next;\n }\n }\n\n // You tried to remove a shape that is not attached to this body.\n if (_ASSERT) console.assert(found);\n\n // Destroy any contacts associated with the fixture.\n let edge = this.m_contactList;\n while (edge) {\n const c = edge.contact;\n edge = edge.next;\n\n const fixtureA = c.getFixtureA();\n const fixtureB = c.getFixtureB();\n\n if (fixture == fixtureA || fixture == fixtureB) {\n // This destroys the contact and removes it from\n // this body's contact list.\n this.m_world.destroyContact(c);\n }\n }\n\n if (this.m_activeFlag) {\n const broadPhase = this.m_world.m_broadPhase;\n fixture.destroyProxies(broadPhase);\n }\n\n fixture.m_body = null;\n fixture.m_next = null;\n\n this.m_world.publish(\"remove-fixture\", fixture);\n\n // Reset the mass data.\n this.resetMassData();\n }\n\n /**\n * Get the corresponding world point of a local point.\n */\n getWorldPoint(localPoint: Vec2Value): Vec2 {\n return Transform.mulVec2(this.m_xf, localPoint);\n }\n\n /**\n * Get the corresponding world vector of a local vector.\n */\n getWorldVector(localVector: Vec2Value): Vec2 {\n return Rot.mulVec2(this.m_xf.q, localVector);\n }\n\n /**\n * Gets the corresponding local point of a world point.\n */\n getLocalPoint(worldPoint: Vec2Value): Vec2 {\n return Transform.mulTVec2(this.m_xf, worldPoint);\n }\n\n /**\n * Gets the corresponding local vector of a world vector.\n */\n getLocalVector(worldVector: Vec2Value): Vec2 {\n return Rot.mulTVec2(this.m_xf.q, worldVector);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { Vec2, Vec2Value } from \"../common/Vec2\";\nimport type { Body } from \"./Body\";\nimport { TimeStep } from \"./Solver\";\nimport { Style } from \"../util/Testbed\";\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/**\n * A joint edge is used to connect bodies and joints together in a joint graph\n * where each body is a node and each joint is an edge. A joint edge belongs to\n * a doubly linked list maintained in each attached body. Each joint has two\n * joint nodes, one for each attached body.\n */\nexport class JointEdge {\n /**\n * provides quick access to the other body attached.\n */\n other: Body | null = null;\n /**\n * the joint\n */\n joint: Joint | null = null;\n /**\n * prev the previous joint edge in the body's joint list\n */\n prev: JointEdge | null = null;\n /**\n * the next joint edge in the body's joint list\n */\n next: JointEdge | null = null;\n}\n\n/**\n * Joint definitions are used to construct joints.\n */\nexport interface JointOpt {\n /**\n * Use this to attach application specific data to your joints.\n */\n userData?: any;\n /**\n * Set this flag to true if the attached bodies\n * should collide.\n */\n collideConnected?: boolean;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\n/**\n * Joint definitions are used to construct joints.\n */\nexport interface JointDef extends JointOpt {\n /**\n * The first attached body.\n */\n bodyA: Body;\n /**\n * The second attached body.\n */\n bodyB: Body;\n}\n\n/** @internal */ const DEFAULTS = {\n userData : null,\n collideConnected : false\n};\n\n/**\n * The base joint class. Joints are used to constraint two bodies together in\n * various fashions. Some joints also feature limits and motors.\n */\nexport abstract class Joint {\n\n /** @internal */ m_type: string = \"unknown-joint\";\n\n /** @internal */ m_bodyA: Body;\n /** @internal */ m_bodyB: Body;\n\n /** @internal */ m_collideConnected: boolean;\n\n /** @internal */ m_prev: Joint | null = null;\n /** @internal */ m_next: Joint | null = null;\n\n /** @internal */ m_edgeA: JointEdge = new JointEdge();\n /** @internal */ m_edgeB: JointEdge = new JointEdge();\n\n /** @internal */ m_islandFlag: boolean = false;\n /** @internal */ m_userData: unknown;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n constructor(def: JointDef);\n constructor(def: JointOpt, bodyA: Body, bodyB: Body);\n constructor(def: JointDef | JointOpt, bodyA?: Body, bodyB?: Body) {\n bodyA = \"bodyA\" in def ? def.bodyA : bodyA;\n bodyB = \"bodyB\" in def ? def.bodyB : bodyB;\n\n if (_ASSERT) console.assert(!!bodyA);\n if (_ASSERT) console.assert(!!bodyB);\n if (_ASSERT) console.assert(bodyA != bodyB);\n\n this.m_bodyA = bodyA!;\n this.m_bodyB = bodyB!;\n\n this.m_collideConnected = !!def.collideConnected;\n this.m_userData = def.userData;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /**\n * Short-cut function to determine if either body is inactive.\n */\n isActive(): boolean {\n return this.m_bodyA.isActive() && this.m_bodyB.isActive();\n }\n\n /**\n * Get the type of the concrete joint.\n */\n getType(): string {\n return this.m_type;\n }\n\n /**\n * Get the first body attached to this joint.\n */\n getBodyA(): Body {\n return this.m_bodyA;\n }\n\n /**\n * Get the second body attached to this joint.\n */\n getBodyB(): Body {\n return this.m_bodyB;\n }\n\n /**\n * Get the next joint the world joint list.\n */\n getNext(): Joint {\n return this.m_next;\n }\n\n getUserData(): unknown {\n return this.m_userData;\n }\n\n setUserData(data: unknown): void {\n this.m_userData = data;\n }\n\n /**\n * Get collide connected. Note: modifying the collide connect flag won't work\n * correctly because the flag is only checked when fixture AABBs begin to\n * overlap.\n */\n getCollideConnected(): boolean {\n return this.m_collideConnected;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n abstract getAnchorA(): Vec2;\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n abstract getAnchorB(): Vec2;\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n abstract getReactionForce(inv_dt: number): Vec2;\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n abstract getReactionTorque(inv_dt: number): number;\n\n /**\n * Shift the origin for any points stored in world coordinates.\n */\n shiftOrigin(newOrigin: Vec2Value): void {}\n\n abstract initVelocityConstraints(step: TimeStep): void;\n\n abstract solveVelocityConstraints(step: TimeStep): void;\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n abstract solvePositionConstraints(step: TimeStep): boolean;\n\n /**\n * @hidden @experimental\n * Update joint with new props.\n */\n abstract _reset(def: Partial): void;\n\n /**\n * @internal @deprecated\n * Temporary for backward compatibility, will be removed.\n */\n _resetAnchors(def: any): void {\n return this._reset(def);\n }\n}\n","/** @hidden */\nexport const stats = {\n gjkCalls: 0,\n gjkIters: 0,\n gjkMaxIters: 0,\n\n toiTime: 0,\n toiMaxTime: 0,\n toiCalls: 0,\n toiIters: 0,\n toiMaxIters: 0,\n toiRootIters: 0,\n toiMaxRootIters: 0,\n\n toString(newline?: string): string {\n newline = typeof newline === \"string\" ? newline : \"\\n\";\n let string = \"\";\n // tslint:disable-next-line:no-for-in\n for (const name in this) {\n if (typeof this[name] !== \"function\" && typeof this[name] !== \"object\") {\n string += name + \": \" + this[name] + newline;\n }\n }\n return string;\n }\n};\n","/** @internal */\nexport const now = function(): number {\n return Date.now();\n};\n\n/** @internal */\nexport const diff = function(time: number): number {\n return Date.now() - time;\n};\n\n/** @internal */\nexport default {\n now,\n diff,\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { stats } from \"../util/stats\";\nimport { Shape } from \"./Shape\";\nimport { EPSILON } from \"../common/Math\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { Rot } from \"../common/Rot\";\nimport { Transform, TransformValue } from \"../common/Transform\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_max = Math.max;\n\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const e12 = matrix.vec2(0, 0);\n/** @internal */ const e13 = matrix.vec2(0, 0);\n/** @internal */ const e23 = matrix.vec2(0, 0);\n/** @internal */ const temp1 = matrix.vec2(0, 0);\n/** @internal */ const temp2 = matrix.vec2(0, 0);\n\n/**\n * GJK using Voronoi regions (Christer Ericson) and Barycentric coordinates.\n */\n\nstats.gjkCalls = 0;\nstats.gjkIters = 0;\nstats.gjkMaxIters = 0;\n\n/**\n * Input for Distance. You have to option to use the shape radii in the\n * computation. Even\n */\nexport class DistanceInput {\n readonly proxyA = new DistanceProxy();\n readonly proxyB = new DistanceProxy();\n readonly transformA = Transform.identity();\n readonly transformB = Transform.identity();\n useRadii = false;\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.transformA.setIdentity();\n this.transformB.setIdentity();\n this.useRadii = false;\n }\n}\n\n/**\n * Output for Distance.\n */\nexport class DistanceOutput {\n /** closest point on shapeA */\n pointA = matrix.vec2(0, 0);\n /** closest point on shapeB */\n pointB = matrix.vec2(0, 0);\n distance = 0;\n /** iterations number of GJK iterations used */\n iterations = 0;\n recycle() {\n matrix.zeroVec2(this.pointA);\n matrix.zeroVec2(this.pointB);\n this.distance = 0;\n this.iterations = 0;\n }\n}\n\n/**\n * Used to warm start Distance. Set count to zero on first call.\n */\nexport class SimplexCache {\n /** length or area */\n metric: number = 0;\n /** vertices on shape A */\n indexA: number[] = [];\n /** vertices on shape B */\n indexB: number[] = [];\n count: number = 0;\n recycle() {\n this.metric = 0;\n this.indexA.length = 0;\n this.indexB.length = 0;\n this.count = 0;\n }\n}\n\n/**\n * Compute the closest points between two shapes. Supports any combination of:\n * CircleShape, PolygonShape, EdgeShape. The simplex cache is input/output. On\n * the first call set SimplexCache.count to zero.\n */\nexport const Distance = function (output: DistanceOutput, cache: SimplexCache, input: DistanceInput): void {\n ++stats.gjkCalls;\n\n const proxyA = input.proxyA;\n const proxyB = input.proxyB;\n const xfA = input.transformA;\n const xfB = input.transformB;\n\n // Initialize the simplex.\n // const simplex = new Simplex();\n simplex.recycle();\n simplex.readCache(cache, proxyA, xfA, proxyB, xfB);\n\n // Get simplex vertices as an array.\n const vertices = simplex.m_v;\n const k_maxIters = Settings.maxDistanceIterations;\n\n // These store the vertices of the last simplex so that we\n // can check for duplicates and prevent cycling.\n const saveA = [];\n const saveB = []; // int[3]\n let saveCount = 0;\n\n // Main iteration loop.\n let iter = 0;\n while (iter < k_maxIters) {\n // Copy simplex so we can identify duplicates.\n saveCount = simplex.m_count;\n for (let i = 0; i < saveCount; ++i) {\n saveA[i] = vertices[i].indexA;\n saveB[i] = vertices[i].indexB;\n }\n\n simplex.solve();\n\n // If we have 3 points, then the origin is in the corresponding triangle.\n if (simplex.m_count === 3) {\n break;\n }\n\n // Get search direction.\n const d = simplex.getSearchDirection();\n\n // Ensure the search direction is numerically fit.\n if (matrix.lengthSqrVec2(d) < EPSILON * EPSILON) {\n // The origin is probably contained by a line segment\n // or triangle. Thus the shapes are overlapped.\n\n // We can't return zero here even though there may be overlap.\n // In case the simplex is a point, segment, or triangle it is difficult\n // to determine if the origin is contained in the CSO or very close to it.\n break;\n }\n\n // Compute a tentative new simplex vertex using support points.\n const vertex = vertices[simplex.m_count]; // SimplexVertex\n\n vertex.indexA = proxyA.getSupport(matrix.derotVec2(temp, xfA.q, matrix.scaleVec2(temp, -1, d)));\n matrix.transformVec2(vertex.wA, xfA, proxyA.getVertex(vertex.indexA));\n\n vertex.indexB = proxyB.getSupport(matrix.derotVec2(temp, xfB.q, d));\n matrix.transformVec2(vertex.wB, xfB, proxyB.getVertex(vertex.indexB));\n\n matrix.subVec2(vertex.w, vertex.wB, vertex.wA);\n\n // Iteration count is equated to the number of support point calls.\n ++iter;\n ++stats.gjkIters;\n\n // Check for duplicate support points. This is the main termination\n // criteria.\n let duplicate = false;\n for (let i = 0; i < saveCount; ++i) {\n if (vertex.indexA === saveA[i] && vertex.indexB === saveB[i]) {\n duplicate = true;\n break;\n }\n }\n\n // If we found a duplicate support point we must exit to avoid cycling.\n if (duplicate) {\n break;\n }\n\n // New vertex is ok and needed.\n ++simplex.m_count;\n }\n\n stats.gjkMaxIters = math_max(stats.gjkMaxIters, iter);\n\n // Prepare output.\n simplex.getWitnessPoints(output.pointA, output.pointB);\n output.distance = matrix.distVec2(output.pointA, output.pointB);\n output.iterations = iter;\n\n // Cache the simplex.\n simplex.writeCache(cache);\n\n // Apply radii if requested.\n if (input.useRadii) {\n const rA = proxyA.m_radius;\n const rB = proxyB.m_radius;\n\n if (output.distance > rA + rB && output.distance > EPSILON) {\n // Shapes are still no overlapped.\n // Move the witness points to the outer surface.\n output.distance -= rA + rB;\n matrix.subVec2(normal, output.pointB, output.pointA);\n matrix.normalizeVec2(normal);\n matrix.plusScaleVec2(output.pointA, rA, normal);\n matrix.minusScaleVec2(output.pointB, rB, normal);\n } else {\n // Shapes are overlapped when radii are considered.\n // Move the witness points to the middle.\n const p = matrix.subVec2(temp, output.pointA, output.pointB);\n matrix.copyVec2(output.pointA, p);\n matrix.copyVec2(output.pointB, p);\n output.distance = 0.0;\n }\n }\n};\n\n/**\n * A distance proxy is used by the GJK algorithm. It encapsulates any shape.\n */\nexport class DistanceProxy {\n /** @internal */ m_vertices: Vec2Value[] = [];\n // todo: remove this?\n /** @internal */ m_count = 0;\n /** @internal */ m_radius = 0;\n\n recycle() {\n this.m_vertices.length = 0;\n this.m_count = 0;\n this.m_radius = 0;\n }\n\n /**\n * Get the vertex count.\n */\n getVertexCount(): number {\n return this.m_count;\n }\n\n /**\n * Get a vertex by index. Used by Distance.\n */\n getVertex(index: number): Vec2Value {\n if (_ASSERT) console.assert(0 <= index && index < this.m_count);\n return this.m_vertices[index];\n }\n\n /**\n * Get the supporting vertex index in the given direction.\n */\n getSupport(d: Vec2Value): number {\n let bestIndex = -1;\n let bestValue = -Infinity;\n for (let i = 0; i < this.m_count; ++i) {\n const value = matrix.dotVec2(this.m_vertices[i], d);\n if (value > bestValue) {\n bestIndex = i;\n bestValue = value;\n }\n }\n return bestIndex;\n }\n\n /**\n * Get the supporting vertex in the given direction.\n */\n getSupportVertex(d: Vec2Value): Vec2Value {\n return this.m_vertices[this.getSupport(d)];\n }\n\n /**\n * Initialize the proxy using the given shape. The shape must remain in scope\n * while the proxy is in use.\n */\n set(shape: Shape, index: number): void {\n // TODO remove, use shape instead\n if (_ASSERT) console.assert(typeof shape.computeDistanceProxy === \"function\");\n shape.computeDistanceProxy(this, index);\n }\n\n /**\n * Initialize the proxy using a vertex cloud and radius. The vertices\n * must remain in scope while the proxy is in use.\n */\n setVertices(vertices: Vec2Value[], count: number, radius: number) {\n this.m_vertices = vertices;\n this.m_count = count;\n this.m_radius = radius;\n }\n}\n\nclass SimplexVertex {\n /** support point in proxyA */\n wA = matrix.vec2(0, 0);\n /** wA index */\n indexA = 0;\n\n /** support point in proxyB */\n wB = matrix.vec2(0, 0);\n /** wB index */\n indexB = 0;\n\n /** wB - wA; */\n w = matrix.vec2(0, 0);\n /** barycentric coordinate for closest point */\n a = 0;\n\n recycle() {\n this.indexA = 0;\n this.indexB = 0;\n matrix.zeroVec2(this.wA);\n matrix.zeroVec2(this.wB);\n matrix.zeroVec2(this.w);\n this.a = 0;\n }\n set(v: SimplexVertex): void {\n this.indexA = v.indexA;\n this.indexB = v.indexB;\n matrix.copyVec2(this.wA, v.wA);\n matrix.copyVec2(this.wB, v.wB);\n matrix.copyVec2(this.w, v.w);\n this.a = v.a;\n }\n}\n\n/** @internal */ const searchDirection_reuse = matrix.vec2(0, 0);\n/** @internal */ const closestPoint_reuse = matrix.vec2(0, 0); \n\nclass Simplex {\n m_v1 = new SimplexVertex();\n m_v2 = new SimplexVertex();\n m_v3 = new SimplexVertex();\n m_v = [this.m_v1, this.m_v2, this.m_v3];\n m_count: number;\n recycle() {\n this.m_v1.recycle();\n this.m_v2.recycle();\n this.m_v3.recycle();\n this.m_count = 0;\n }\n\n /** @internal */ toString(): string {\n if (this.m_count === 3) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y,\n this.m_v2.a, this.m_v2.wA.x, this.m_v2.wA.y, this.m_v2.wB.x, this.m_v2.wB.y,\n this.m_v3.a, this.m_v3.wA.x, this.m_v3.wA.y, this.m_v3.wB.x, this.m_v3.wB.y\n ].toString();\n\n } else if (this.m_count === 2) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y,\n this.m_v2.a, this.m_v2.wA.x, this.m_v2.wA.y, this.m_v2.wB.x, this.m_v2.wB.y\n ].toString();\n\n } else if (this.m_count === 1) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y\n ].toString();\n\n } else {\n return \"+\" + this.m_count;\n }\n }\n\n readCache(cache: SimplexCache, proxyA: DistanceProxy, transformA: TransformValue, proxyB: DistanceProxy, transformB: TransformValue): void {\n if (_ASSERT) console.assert(cache.count <= 3);\n\n // Copy data from cache.\n this.m_count = cache.count;\n for (let i = 0; i < this.m_count; ++i) {\n const v = this.m_v[i];\n v.indexA = cache.indexA[i];\n v.indexB = cache.indexB[i];\n const wALocal = proxyA.getVertex(v.indexA);\n const wBLocal = proxyB.getVertex(v.indexB);\n matrix.transformVec2(v.wA, transformA, wALocal);\n matrix.transformVec2(v.wB, transformB, wBLocal);\n matrix.subVec2(v.w,v.wB, v.wA);\n v.a = 0.0;\n }\n\n // Compute the new simplex metric, if it is substantially different than\n // old metric then flush the simplex.\n if (this.m_count > 1) {\n const metric1 = cache.metric;\n const metric2 = this.getMetric();\n if (metric2 < 0.5 * metric1 || 2.0 * metric1 < metric2 || metric2 < EPSILON) {\n // Reset the simplex.\n this.m_count = 0;\n }\n }\n\n // If the cache is empty or invalid...\n if (this.m_count === 0) {\n const v = this.m_v[0];\n v.indexA = 0;\n v.indexB = 0;\n const wALocal = proxyA.getVertex(0);\n const wBLocal = proxyB.getVertex(0);\n matrix.transformVec2(v.wA, transformA, wALocal);\n matrix.transformVec2(v.wB, transformB, wBLocal);\n matrix.subVec2(v.w,v.wB, v.wA);\n v.a = 1.0;\n this.m_count = 1;\n }\n }\n\n writeCache(cache: SimplexCache): void {\n cache.metric = this.getMetric();\n cache.count = this.m_count;\n for (let i = 0; i < this.m_count; ++i) {\n cache.indexA[i] = this.m_v[i].indexA;\n cache.indexB[i] = this.m_v[i].indexB;\n }\n }\n\n getSearchDirection(): Vec2Value {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 1:\n return matrix.setVec2(searchDirection_reuse, -v1.w.x, -v1.w.y);\n\n case 2: {\n matrix.subVec2(e12, v2.w, v1.w);\n const sgn = -matrix.crossVec2Vec2(e12, v1.w);\n if (sgn > 0.0) {\n // Origin is left of e12.\n return matrix.setVec2(searchDirection_reuse, -e12.y, e12.x);\n } else {\n // Origin is right of e12.\n return matrix.setVec2(searchDirection_reuse, e12.y, -e12.x);\n }\n }\n\n default:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(searchDirection_reuse);\n }\n }\n\n getClosestPoint(): Vec2Value {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(closestPoint_reuse);\n\n case 1:\n return matrix.copyVec2(closestPoint_reuse, v1.w);\n\n case 2:\n return matrix.combine2Vec2(closestPoint_reuse, v1.a, v1.w, v2.a, v2.w);\n\n case 3:\n return matrix.zeroVec2(closestPoint_reuse);\n\n default:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(closestPoint_reuse);\n }\n }\n\n getWitnessPoints(pA: Vec2Value, pB: Vec2Value): void {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n break;\n\n case 1:\n matrix.copyVec2(pA, v1.wA);\n matrix.copyVec2(pB, v1.wB);\n break;\n\n case 2:\n matrix.combine2Vec2(pA, v1.a, v1.wA, v2.a, v2.wA);\n matrix.combine2Vec2(pB, v1.a, v1.wB, v2.a, v2.wB);\n break;\n\n case 3:\n matrix.combine3Vec2(pA, v1.a, v1.wA, v2.a, v2.wA, v3.a, v3.wA);\n matrix.copyVec2(pB, pA);\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n break;\n }\n }\n\n getMetric(): number {\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n return 0.0;\n\n case 1:\n return 0.0;\n\n case 2:\n return matrix.distVec2(this.m_v1.w, this.m_v2.w);\n\n case 3:\n return matrix.crossVec2Vec2(\n matrix.subVec2(temp1, this.m_v2.w, this.m_v1.w),\n matrix.subVec2(temp2, this.m_v3.w, this.m_v1.w),\n );\n\n default:\n if (_ASSERT) console.assert(false);\n return 0.0;\n }\n }\n\n solve(): void {\n switch (this.m_count) {\n case 1:\n break;\n\n case 2:\n this.solve2();\n break;\n\n case 3:\n this.solve3();\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n }\n }\n\n// Solve a line segment using barycentric coordinates.\n//\n// p = a1 * w1 + a2 * w2\n// a1 + a2 = 1\n//\n// The vector from the origin to the closest point on the line is\n// perpendicular to the line.\n// e12 = w2 - w1\n// dot(p, e) = 0\n// a1 * dot(w1, e) + a2 * dot(w2, e) = 0\n//\n// 2-by-2 linear system\n// [1 1 ][a1] = [1]\n// [w1.e12 w2.e12][a2] = [0]\n//\n// Define\n// d12_1 = dot(w2, e12)\n// d12_2 = -dot(w1, e12)\n// d12 = d12_1 + d12_2\n//\n// Solution\n// a1 = d12_1 / d12\n// a2 = d12_2 / d12\n solve2(): void {\n const w1 = this.m_v1.w;\n const w2 = this.m_v2.w;\n matrix.subVec2(e12, w2, w1);\n\n // w1 region\n const d12_2 = -matrix.dotVec2(w1, e12);\n if (d12_2 <= 0.0) {\n // a2 <= 0, so we clamp it to 0\n this.m_v1.a = 1.0;\n this.m_count = 1;\n return;\n }\n\n // w2 region\n const d12_1 = matrix.dotVec2(w2, e12);\n if (d12_1 <= 0.0) {\n // a1 <= 0, so we clamp it to 0\n this.m_v2.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v2);\n return;\n }\n\n // Must be in e12 region.\n const inv_d12 = 1.0 / (d12_1 + d12_2);\n this.m_v1.a = d12_1 * inv_d12;\n this.m_v2.a = d12_2 * inv_d12;\n this.m_count = 2;\n }\n\n// Possible regions:\n// - points[2]\n// - edge points[0]-points[2]\n// - edge points[1]-points[2]\n// - inside the triangle\n solve3(): void {\n const w1 = this.m_v1.w;\n const w2 = this.m_v2.w;\n const w3 = this.m_v3.w;\n\n // Edge12\n // [1 1 ][a1] = [1]\n // [w1.e12 w2.e12][a2] = [0]\n // a3 = 0\n matrix.subVec2(e12, w2, w1);\n const w1e12 = matrix.dotVec2(w1, e12);\n const w2e12 = matrix.dotVec2(w2, e12);\n const d12_1 = w2e12;\n const d12_2 = -w1e12;\n\n // Edge13\n // [1 1 ][a1] = [1]\n // [w1.e13 w3.e13][a3] = [0]\n // a2 = 0\n matrix.subVec2(e13, w3, w1);\n const w1e13 = matrix.dotVec2(w1, e13);\n const w3e13 = matrix.dotVec2(w3, e13);\n const d13_1 = w3e13;\n const d13_2 = -w1e13;\n\n // Edge23\n // [1 1 ][a2] = [1]\n // [w2.e23 w3.e23][a3] = [0]\n // a1 = 0\n matrix.subVec2(e23, w3, w2);\n const w2e23 = matrix.dotVec2(w2, e23);\n const w3e23 = matrix.dotVec2(w3, e23);\n const d23_1 = w3e23;\n const d23_2 = -w2e23;\n\n // Triangle123\n const n123 = matrix.crossVec2Vec2(e12, e13);\n\n const d123_1 = n123 * matrix.crossVec2Vec2(w2, w3);\n const d123_2 = n123 * matrix.crossVec2Vec2(w3, w1);\n const d123_3 = n123 * matrix.crossVec2Vec2(w1, w2);\n\n // w1 region\n if (d12_2 <= 0.0 && d13_2 <= 0.0) {\n this.m_v1.a = 1.0;\n this.m_count = 1;\n return;\n }\n\n // e12\n if (d12_1 > 0.0 && d12_2 > 0.0 && d123_3 <= 0.0) {\n const inv_d12 = 1.0 / (d12_1 + d12_2);\n this.m_v1.a = d12_1 * inv_d12;\n this.m_v2.a = d12_2 * inv_d12;\n this.m_count = 2;\n return;\n }\n\n // e13\n if (d13_1 > 0.0 && d13_2 > 0.0 && d123_2 <= 0.0) {\n const inv_d13 = 1.0 / (d13_1 + d13_2);\n this.m_v1.a = d13_1 * inv_d13;\n this.m_v3.a = d13_2 * inv_d13;\n this.m_count = 2;\n this.m_v2.set(this.m_v3);\n return;\n }\n\n // w2 region\n if (d12_1 <= 0.0 && d23_2 <= 0.0) {\n this.m_v2.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v2);\n return;\n }\n\n // w3 region\n if (d13_1 <= 0.0 && d23_1 <= 0.0) {\n this.m_v3.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v3);\n return;\n }\n\n // e23\n if (d23_1 > 0.0 && d23_2 > 0.0 && d123_1 <= 0.0) {\n const inv_d23 = 1.0 / (d23_1 + d23_2);\n this.m_v2.a = d23_1 * inv_d23;\n this.m_v3.a = d23_2 * inv_d23;\n this.m_count = 2;\n this.m_v1.set(this.m_v3);\n return;\n }\n\n // Must be in triangle123\n const inv_d123 = 1.0 / (d123_1 + d123_2 + d123_3);\n this.m_v1.a = d123_1 * inv_d123;\n this.m_v2.a = d123_2 * inv_d123;\n this.m_v3.a = d123_3 * inv_d123;\n this.m_count = 3;\n }\n}\n\n/** @internal */ const simplex = new Simplex();\n\n/** @internal */ const input = new DistanceInput();\n/** @internal */ const cache = new SimplexCache();\n/** @internal */ const output = new DistanceOutput();\n\n/**\n * Determine if two generic shapes overlap.\n */\nexport const testOverlap = function (shapeA: Shape, indexA: number, shapeB: Shape, indexB: number, xfA: TransformValue, xfB: TransformValue): boolean {\n input.recycle();\n input.proxyA.set(shapeA, indexA);\n input.proxyB.set(shapeB, indexB);\n matrix.copyTransform(input.transformA, xfA);\n matrix.copyTransform(input.transformB, xfB);\n input.useRadii = true;\n\n output.recycle();\n cache.recycle();\n\n Distance(output, cache, input);\n\n return output.distance < 10.0 * EPSILON;\n};\n\n// legacy exports\nDistance.testOverlap = testOverlap;\nDistance.Input = DistanceInput;\nDistance.Output = DistanceOutput;\nDistance.Proxy = DistanceProxy;\nDistance.Cache = SimplexCache;\n\n/**\n * Input parameters for ShapeCast\n */\nexport class ShapeCastInput {\n readonly proxyA = new DistanceProxy();\n readonly proxyB = new DistanceProxy();\n readonly transformA = Transform.identity();\n readonly transformB = Transform.identity();\n readonly translationB = Vec2.zero();\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.transformA.setIdentity();\n this.transformB.setIdentity();\n matrix.zeroVec2(this.translationB);\n }\n}\n\n/**\n * Output results for b2ShapeCast\n */\nexport class ShapeCastOutput {\n point: Vec2 = Vec2.zero();\n normal: Vec2 = Vec2.zero();\n lambda = 1.0;\n iterations = 0;\n}\n\n/**\n * Perform a linear shape cast of shape B moving and shape A fixed. Determines\n * the hit point, normal, and translation fraction.\n * \n * @returns true if hit, false if there is no hit or an initial overlap\n */\n//\n// GJK-raycast\n// Algorithm by Gino van den Bergen.\n// \"Smooth Mesh Contacts with GJK\" in Game Physics Pearls. 2010\nexport const ShapeCast = function(output: ShapeCastOutput, input: ShapeCastInput): boolean {\n output.iterations = 0;\n output.lambda = 1.0;\n output.normal.setZero();\n output.point.setZero();\n\n const proxyA = input.proxyA;\n const proxyB = input.proxyB;\n\n const radiusA = math_max(proxyA.m_radius, Settings.polygonRadius);\n const radiusB = math_max(proxyB.m_radius, Settings.polygonRadius);\n const radius = radiusA + radiusB;\n\n const xfA = input.transformA;\n const xfB = input.transformB;\n\n const r = input.translationB;\n const n = Vec2.zero();\n let lambda = 0.0;\n\n // Initial simplex\n const simplex = new Simplex();\n simplex.m_count = 0;\n\n // Get simplex vertices as an array.\n const vertices = simplex.m_v;\n\n // Get support point in -r direction\n let indexA = proxyA.getSupport(Rot.mulTVec2(xfA.q, Vec2.neg(r)));\n let wA = Transform.mulVec2(xfA, proxyA.getVertex(indexA));\n let indexB = proxyB.getSupport(Rot.mulTVec2(xfB.q, r));\n let wB = Transform.mulVec2(xfB, proxyB.getVertex(indexB));\n const v = Vec2.sub(wA, wB);\n\n // Sigma is the target distance between polygons\n const sigma = math_max(Settings.polygonRadius, radius - Settings.polygonRadius);\n const tolerance = 0.5 * Settings.linearSlop;\n\n // Main iteration loop.\n const k_maxIters = 20;\n let iter = 0;\n while (iter < k_maxIters && v.length() - sigma > tolerance) {\n if (_ASSERT) console.assert(simplex.m_count < 3);\n\n output.iterations += 1;\n\n // Support in direction -v (A - B)\n indexA = proxyA.getSupport(Rot.mulTVec2(xfA.q, Vec2.neg(v)));\n wA = Transform.mulVec2(xfA, proxyA.getVertex(indexA));\n indexB = proxyB.getSupport(Rot.mulTVec2(xfB.q, v));\n wB = Transform.mulVec2(xfB, proxyB.getVertex(indexB));\n const p = Vec2.sub(wA, wB);\n\n // -v is a normal at p\n v.normalize();\n\n // Intersect ray with plane\n const vp = Vec2.dot(v, p);\n const vr = Vec2.dot(v, r);\n if (vp - sigma > lambda * vr) {\n if (vr <= 0.0) {\n return false;\n }\n\n lambda = (vp - sigma) / vr;\n if (lambda > 1.0) {\n return false;\n }\n\n n.setMul(-1, v);\n simplex.m_count = 0;\n }\n\n // Reverse simplex since it works with B - A.\n // Shift by lambda * r because we want the closest point to the current clip point.\n // Note that the support point p is not shifted because we want the plane equation\n // to be formed in unshifted space.\n const vertex = vertices[simplex.m_count];\n vertex.indexA = indexB;\n vertex.wA = Vec2.combine(1, wB, lambda, r);\n vertex.indexB = indexA;\n vertex.wB = wA;\n vertex.w = Vec2.sub(vertex.wB, vertex.wA);\n vertex.a = 1.0;\n simplex.m_count += 1;\n\n switch (simplex.m_count) {\n case 1:\n break;\n\n case 2:\n simplex.solve2();\n break;\n\n case 3:\n simplex.solve3();\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n }\n \n // If we have 3 points, then the origin is in the corresponding triangle.\n if (simplex.m_count == 3) {\n // Overlap\n return false;\n }\n\n // Get search direction.\n v.setVec2(simplex.getClosestPoint());\n\n // Iteration count is equated to the number of support point calls.\n ++iter;\n }\n\n if (iter == 0) {\n // Initial overlap\n return false;\n\t}\n\n // Prepare output.\n const pointA = Vec2.zero();\n const pointB = Vec2.zero();\n simplex.getWitnessPoints(pointB, pointA);\n\n if (v.lengthSquared() > 0.0) {\n n.setMul(-1, v);\n n.normalize();\n }\n\n output.point = Vec2.combine(1, pointA, radiusA, n);\n output.normal = n;\n output.lambda = lambda;\n output.iterations = iter;\n return true;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { stats } from \"../util/stats\";\nimport Timer from \"../util/Timer\";\nimport { Sweep } from \"../common/Sweep\";\nimport { Transform } from \"../common/Transform\";\nimport { Distance, DistanceInput, DistanceOutput, DistanceProxy, SimplexCache } from \"./Distance\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n\n\n/**\n * Input parameters for TimeOfImpact.\n */\nexport class TOIInput {\n proxyA = new DistanceProxy();\n proxyB = new DistanceProxy();\n sweepA = new Sweep();\n sweepB = new Sweep();\n /** defines sweep interval [0, tMax] */\n tMax: number;\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.sweepA.recycle();\n this.sweepB.recycle();\n this.tMax = -1;\n }\n}\n\nexport enum TOIOutputState {\n e_unset = -1,\n e_unknown = 0,\n e_failed = 1,\n e_overlapped = 2,\n e_touching = 3,\n e_separated = 4,\n}\n\n/**\n * Output parameters for TimeOfImpact.\n */\nexport class TOIOutput {\n state = TOIOutputState.e_unset;\n t = -1;\n recycle() {\n this.state = TOIOutputState.e_unset;\n this.t = -1;\n }\n}\n\nstats.toiTime = 0;\nstats.toiMaxTime = 0;\nstats.toiCalls = 0;\nstats.toiIters = 0;\nstats.toiMaxIters = 0;\nstats.toiRootIters = 0;\nstats.toiMaxRootIters = 0;\n\n/** @internal */ const distanceInput = new DistanceInput();\n/** @internal */ const distanceOutput = new DistanceOutput();\n// this is passed to Distance and SeparationFunction\n/** @internal */ const cache = new SimplexCache();\n\n/** @internal */ const xfA = matrix.transform(0, 0, 0);\n/** @internal */ const xfB = matrix.transform(0, 0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const axisA = matrix.vec2(0, 0);\n/** @internal */ const axisB = matrix.vec2(0, 0);\n/** @internal */ const localPointA = matrix.vec2(0, 0);\n/** @internal */ const localPointB = matrix.vec2(0, 0);\n\n\n/**\n * Compute the upper bound on time before two shapes penetrate. Time is\n * represented as a fraction between [0,tMax]. This uses a swept separating axis\n * and may miss some intermediate, non-tunneling collisions. If you change the\n * time interval, you should call this function again.\n *\n * Note: use Distance to compute the contact point and normal at the time of\n * impact.\n *\n * CCD via the local separating axis method. This seeks progression by computing\n * the largest time at which separation is maintained.\n */\nexport const TimeOfImpact = function (output: TOIOutput, input: TOIInput): void {\n const timer = Timer.now();\n\n ++stats.toiCalls;\n\n output.state = TOIOutputState.e_unknown;\n output.t = input.tMax;\n\n const proxyA = input.proxyA; // DistanceProxy\n const proxyB = input.proxyB; // DistanceProxy\n\n const sweepA = input.sweepA; // Sweep\n const sweepB = input.sweepB; // Sweep\n\n // Large rotations can make the root finder fail, so we normalize the\n // sweep angles.\n sweepA.normalize();\n sweepB.normalize();\n\n const tMax = input.tMax;\n\n const totalRadius = proxyA.m_radius + proxyB.m_radius;\n const target = math_max(Settings.linearSlop, totalRadius - 3.0 * Settings.linearSlop);\n const tolerance = 0.25 * Settings.linearSlop;\n if (_ASSERT) console.assert(target > tolerance);\n\n let t1 = 0.0;\n const k_maxIterations = Settings.maxTOIIterations;\n let iter = 0;\n\n // Prepare input for distance query.\n // const cache = new SimplexCache();\n cache.recycle();\n\n distanceInput.proxyA.setVertices(proxyA.m_vertices, proxyA.m_count, proxyA.m_radius);\n distanceInput.proxyB.setVertices(proxyB.m_vertices, proxyB.m_count, proxyB.m_radius);\n distanceInput.useRadii = false;\n\n // The outer loop progressively attempts to compute new separating axes.\n // This loop terminates when an axis is repeated (no progress is made).\n while (true) {\n sweepA.getTransform(xfA, t1);\n sweepB.getTransform(xfB, t1);\n\n // Get the distance between shapes. We can also use the results\n // to get a separating axis.\n matrix.copyTransform(distanceInput.transformA, xfA);\n matrix.copyTransform(distanceInput.transformB, xfB);\n Distance(distanceOutput, cache, distanceInput);\n\n // If the shapes are overlapped, we give up on continuous collision.\n if (distanceOutput.distance <= 0.0) {\n // Failure!\n output.state = TOIOutputState.e_overlapped;\n output.t = 0.0;\n break;\n }\n\n if (distanceOutput.distance < target + tolerance) {\n // Victory!\n output.state = TOIOutputState.e_touching;\n output.t = t1;\n break;\n }\n\n // Initialize the separating axis.\n separationFunction.initialize(cache, proxyA, sweepA, proxyB, sweepB, t1);\n\n // if (false) {\n // // Dump the curve seen by the root finder\n // const N = 100;\n // const dx = 1.0 / N;\n // const xs = []; // [ N + 1 ];\n // const fs = []; // [ N + 1 ];\n // const x = 0.0;\n // for (const i = 0; i <= N; ++i) {\n // sweepA.getTransform(xfA, x);\n // sweepB.getTransform(xfB, x);\n // const f = fcn.evaluate(xfA, xfB) - target;\n // printf(\"%g %g\\n\", x, f);\n // xs[i] = x;\n // fs[i] = f;\n // x += dx;\n // }\n // }\n\n // Compute the TOI on the separating axis. We do this by successively\n // resolving the deepest point. This loop is bounded by the number of\n // vertices.\n let done = false;\n let t2 = tMax;\n let pushBackIter = 0;\n while (true) {\n // Find the deepest point at t2. Store the witness point indices.\n let s2 = separationFunction.findMinSeparation(t2);\n\n // Is the final configuration separated?\n if (s2 > target + tolerance) {\n // Victory!\n output.state = TOIOutputState.e_separated;\n output.t = tMax;\n done = true;\n break;\n }\n\n // Has the separation reached tolerance?\n if (s2 > target - tolerance) {\n // Advance the sweeps\n t1 = t2;\n break;\n }\n\n // Compute the initial separation of the witness points.\n let s1 = separationFunction.evaluate(t1);\n\n // Check for initial overlap. This might happen if the root finder\n // runs out of iterations.\n if (s1 < target - tolerance) {\n output.state = TOIOutputState.e_failed;\n output.t = t1;\n done = true;\n break;\n }\n\n // Check for touching\n if (s1 <= target + tolerance) {\n // Victory! t1 should hold the TOI (could be 0.0).\n output.state = TOIOutputState.e_touching;\n output.t = t1;\n done = true;\n break;\n }\n\n // Compute 1D root of: f(x) - target = 0\n let rootIterCount = 0;\n let a1 = t1;\n let a2 = t2;\n while (true) {\n // Use a mix of the secant rule and bisection.\n let t;\n if (rootIterCount & 1) {\n // Secant rule to improve convergence.\n t = a1 + (target - s1) * (a2 - a1) / (s2 - s1);\n } else {\n // Bisection to guarantee progress.\n t = 0.5 * (a1 + a2);\n }\n\n ++rootIterCount;\n ++stats.toiRootIters;\n\n const s = separationFunction.evaluate(t);\n\n if (math_abs(s - target) < tolerance) {\n // t2 holds a tentative value for t1\n t2 = t;\n break;\n }\n\n // Ensure we continue to bracket the root.\n if (s > target) {\n a1 = t;\n s1 = s;\n } else {\n a2 = t;\n s2 = s;\n }\n\n if (rootIterCount === 50) {\n break;\n }\n }\n\n stats.toiMaxRootIters = math_max(stats.toiMaxRootIters, rootIterCount);\n\n ++pushBackIter;\n\n if (pushBackIter === Settings.maxPolygonVertices) {\n break;\n }\n }\n\n ++iter;\n ++stats.toiIters;\n\n if (done) {\n break;\n }\n\n if (iter === k_maxIterations) {\n // Root finder got stuck. Semi-victory.\n output.state = TOIOutputState.e_failed;\n output.t = t1;\n break;\n }\n }\n\n stats.toiMaxIters = math_max(stats.toiMaxIters, iter);\n\n const time = Timer.diff(timer);\n stats.toiMaxTime = math_max(stats.toiMaxTime, time);\n stats.toiTime += time;\n\n separationFunction.recycle();\n};\n\nenum SeparationFunctionType {\n e_unset = -1,\n e_points = 1,\n e_faceA = 2,\n e_faceB = 3,\n}\n\nclass SeparationFunction {\n // input cache\n // todo: maybe assign by copy instead of reference?\n m_proxyA: DistanceProxy = null;\n m_proxyB: DistanceProxy = null;\n m_sweepA: Sweep = null;\n m_sweepB: Sweep = null;\n\n // initialize cache\n m_type = SeparationFunctionType.e_unset;\n m_localPoint = matrix.vec2(0, 0);\n m_axis = matrix.vec2(0, 0);\n\n // compute output\n indexA = -1;\n indexB = -1;\n\n recycle() {\n this.m_proxyA = null;\n this.m_proxyB = null;\n this.m_sweepA = null;\n this.m_sweepB = null;\n\n this.m_type = SeparationFunctionType.e_unset;\n matrix.zeroVec2(this.m_localPoint);\n matrix.zeroVec2(this.m_axis);\n\n this.indexA = -1;\n this.indexB = -1;\n }\n\n // TODO_ERIN might not need to return the separation\n\n initialize(cache: SimplexCache, proxyA: DistanceProxy, sweepA: Sweep, proxyB: DistanceProxy, sweepB: Sweep, t1: number): number {\n const count = cache.count;\n if (_ASSERT) console.assert(0 < count && count < 3);\n\n this.m_proxyA = proxyA;\n this.m_proxyB = proxyB;\n this.m_sweepA = sweepA;\n this.m_sweepB = sweepB;\n\n this.m_sweepA.getTransform(xfA, t1);\n this.m_sweepB.getTransform(xfB, t1);\n\n if (count === 1) {\n this.m_type = SeparationFunctionType.e_points;\n const localPointA = this.m_proxyA.getVertex(cache.indexA[0]);\n const localPointB = this.m_proxyB.getVertex(cache.indexB[0]);\n matrix.transformVec2(pointA, xfA, localPointA);\n matrix.transformVec2(pointB, xfB, localPointB);\n matrix.subVec2(this.m_axis, pointB, pointA);\n const s = matrix.normalizeVec2Length(this.m_axis);\n return s;\n\n } else if (cache.indexA[0] === cache.indexA[1]) {\n // Two points on B and one on A.\n this.m_type = SeparationFunctionType.e_faceB;\n const localPointB1 = proxyB.getVertex(cache.indexB[0]);\n const localPointB2 = proxyB.getVertex(cache.indexB[1]);\n\n matrix.crossVec2Num(this.m_axis, matrix.subVec2(temp, localPointB2, localPointB1), 1.0);\n matrix.normalizeVec2(this.m_axis);\n matrix.rotVec2(normal, xfB.q, this.m_axis);\n\n matrix.combine2Vec2(this.m_localPoint, 0.5, localPointB1, 0.5, localPointB2);\n matrix.transformVec2(pointB, xfB, this.m_localPoint);\n\n const localPointA = proxyA.getVertex(cache.indexA[0]);\n const pointA = Transform.mulVec2(xfA, localPointA);\n\n let s = matrix.dotVec2(pointA, normal) - matrix.dotVec2(pointB, normal);\n if (s < 0.0) {\n matrix.negVec2(this.m_axis);\n s = -s;\n }\n return s;\n\n } else {\n // Two points on A and one or two points on B.\n this.m_type = SeparationFunctionType.e_faceA;\n const localPointA1 = this.m_proxyA.getVertex(cache.indexA[0]);\n const localPointA2 = this.m_proxyA.getVertex(cache.indexA[1]);\n\n matrix.crossVec2Num(this.m_axis, matrix.subVec2(temp, localPointA2, localPointA1), 1.0);\n matrix.normalizeVec2(this.m_axis);\n matrix.rotVec2(normal, xfA.q, this.m_axis);\n\n matrix.combine2Vec2(this.m_localPoint, 0.5, localPointA1, 0.5, localPointA2);\n matrix.transformVec2(pointA, xfA, this.m_localPoint);\n\n const localPointB = this.m_proxyB.getVertex(cache.indexB[0]);\n matrix.transformVec2(pointB, xfB, localPointB);\n\n let s = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal);\n if (s < 0.0) {\n matrix.negVec2(this.m_axis);\n s = -s;\n }\n return s;\n }\n }\n\n compute(find: boolean, t: number): number {\n // It was findMinSeparation and evaluate\n this.m_sweepA.getTransform(xfA, t);\n this.m_sweepB.getTransform(xfB, t);\n\n switch (this.m_type) {\n case SeparationFunctionType.e_points: {\n if (find) {\n matrix.derotVec2(axisA, xfA.q, this.m_axis);\n matrix.derotVec2(axisB, xfB.q, matrix.scaleVec2(temp, -1, this.m_axis));\n\n this.indexA = this.m_proxyA.getSupport(axisA);\n this.indexB = this.m_proxyB.getSupport(axisB);\n }\n\n matrix.copyVec2(localPointA, this.m_proxyA.getVertex(this.indexA));\n matrix.copyVec2(localPointB, this.m_proxyB.getVertex(this.indexB));\n\n matrix.transformVec2(pointA, xfA, localPointA);\n matrix.transformVec2(pointB, xfB, localPointB);\n\n const sep = matrix.dotVec2(pointB, this.m_axis) - matrix.dotVec2(pointA, this.m_axis);\n return sep;\n }\n\n case SeparationFunctionType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.m_axis);\n matrix.transformVec2(pointA, xfA, this.m_localPoint);\n\n if (find) {\n matrix.derotVec2(axisB, xfB.q, matrix.scaleVec2(temp, -1, normal));\n\n this.indexA = -1;\n this.indexB = this.m_proxyB.getSupport(axisB);\n }\n\n matrix.copyVec2(localPointB, this.m_proxyB.getVertex(this.indexB));\n matrix.transformVec2(pointB, xfB, localPointB);\n\n const sep = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal);\n return sep;\n }\n\n case SeparationFunctionType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.m_axis);\n matrix.transformVec2(pointB, xfB, this.m_localPoint);\n\n if (find) {\n matrix.derotVec2(axisA, xfA.q, matrix.scaleVec2(temp, -1, normal));\n\n this.indexB = -1;\n this.indexA = this.m_proxyA.getSupport(axisA);\n }\n\n matrix.copyVec2(localPointA, this.m_proxyA.getVertex(this.indexA));\n matrix.transformVec2(pointA, xfA, localPointA);\n\n const sep = matrix.dotVec2(pointA, normal) - matrix.dotVec2(pointB, normal);\n return sep;\n }\n\n default:\n if (_ASSERT) console.assert(false);\n if (find) {\n this.indexA = -1;\n this.indexB = -1;\n }\n return 0.0;\n }\n }\n\n findMinSeparation(t: number): number {\n return this.compute(true, t);\n }\n\n evaluate(t: number): number {\n return this.compute(false, t);\n }\n}\n\n/** @internal */ const separationFunction = new SeparationFunction();\n\n// legacy exports\nTimeOfImpact.Input = TOIInput;\nTimeOfImpact.Output = TOIOutput;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { EPSILON } from \"../common/Math\";\nimport { Body } from \"./Body\";\nimport type { Contact } from \"./Contact\";\nimport { Joint } from \"./Joint\";\nimport { TimeOfImpact, TOIInput, TOIOutput, TOIOutputState } from \"../collision/TimeOfImpact\";\nimport { Distance, DistanceInput, DistanceOutput, SimplexCache } from \"../collision/Distance\";\nimport { World } from \"./World\";\nimport { Sweep } from \"../common/Sweep\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_min = Math.min;\n\n\nexport class TimeStep {\n /** time step */\n dt: number = 0;\n /** inverse time step (0 if dt == 0) */\n inv_dt: number = 0;\n velocityIterations: number = 0;\n positionIterations: number = 0;\n warmStarting: boolean = false;\n blockSolve: boolean = true;\n\n /** timestep ratio for variable timestep */\n inv_dt0: number = 0.0;\n /** dt * inv_dt0 */\n dtRatio: number = 1;\n\n reset(dt: number): void {\n if (this.dt > 0.0) {\n this.inv_dt0 = this.inv_dt;\n }\n this.dt = dt;\n this.inv_dt = dt == 0 ? 0 : 1 / dt;\n this.dtRatio = dt * this.inv_dt0;\n }\n}\n\n// reuse\n/** @internal */ const s_subStep = new TimeStep();\n/** @internal */ const c = matrix.vec2(0, 0);\n/** @internal */ const v = matrix.vec2(0, 0);\n/** @internal */ const translation = matrix.vec2(0, 0);\n/** @internal */ const input = new TOIInput();\n/** @internal */ const output = new TOIOutput();\n/** @internal */ const backup = new Sweep();\n/** @internal */ const backup1 = new Sweep();\n/** @internal */ const backup2 = new Sweep();\n\n/**\n * Contact impulses for reporting. Impulses are used instead of forces because\n * sub-step forces may approach infinity for rigid body collisions. These match\n * up one-to-one with the contact points in Manifold.\n */\nexport class ContactImpulse {\n // TODO: merge with Contact class?\n\n private readonly contact: Contact;\n private readonly normals: number[];\n private readonly tangents: number[];\n\n constructor(contact: Contact) {\n this.contact = contact;\n this.normals = [];\n this.tangents = [];\n }\n\n recycle() {\n this.normals.length = 0;\n this.tangents.length = 0;\n }\n\n get normalImpulses(): number[] {\n const contact = this.contact;\n const normals = this.normals;\n normals.length = 0;\n for (let p = 0; p < contact.v_points.length; ++p) {\n normals.push(contact.v_points[p].normalImpulse);\n }\n return normals;\n }\n\n get tangentImpulses(): number[] {\n const contact = this.contact;\n const tangents = this.tangents;\n tangents.length = 0;\n for (let p = 0; p < contact.v_points.length; ++p) {\n tangents.push(contact.v_points[p].tangentImpulse);\n }\n return tangents;\n }\n}\n\n/**\n * Finds and solves islands. An island is a connected subset of the world.\n */\nexport class Solver {\n m_world: World;\n m_stack: Body[];\n m_bodies: Body[];\n m_contacts: Contact[];\n m_joints: Joint[];\n\n constructor(world: World) {\n this.m_world = world;\n this.m_stack = [];\n this.m_bodies = [];\n this.m_contacts = [];\n this.m_joints = [];\n }\n\n clear(): void {\n this.m_stack.length = 0;\n this.m_bodies.length = 0;\n this.m_contacts.length = 0;\n this.m_joints.length = 0;\n }\n\n addBody(body: Body): void {\n if (_ASSERT) console.assert(body instanceof Body, \"Not a Body!\", body);\n this.m_bodies.push(body);\n // why?\n // body.c_position.c.setZero();\n // body.c_position.a = 0;\n // body.c_velocity.v.setZero();\n // body.c_velocity.w = 0;\n }\n\n addContact(contact: Contact): void {\n // if (_ASSERT) console.assert(contact instanceof Contact, 'Not a Contact!', contact);\n this.m_contacts.push(contact);\n }\n\n addJoint(joint: Joint): void {\n if (_ASSERT) console.assert(joint instanceof Joint, \"Not a Joint!\", joint);\n this.m_joints.push(joint);\n }\n\n solveWorld(step: TimeStep): void {\n const world = this.m_world;\n\n // Clear all the island flags.\n for (let b = world.m_bodyList; b; b = b.m_next) {\n b.m_islandFlag = false;\n }\n for (let c = world.m_contactList; c; c = c.m_next) {\n c.m_islandFlag = false;\n }\n for (let j = world.m_jointList; j; j = j.m_next) {\n j.m_islandFlag = false;\n }\n\n // Build and simulate all awake islands.\n const stack = this.m_stack;\n let loop = -1;\n for (let seed = world.m_bodyList; seed; seed = seed.m_next) {\n loop++;\n if (seed.m_islandFlag) {\n continue;\n }\n\n if (seed.isAwake() == false || seed.isActive() == false) {\n continue;\n }\n\n // The seed can be dynamic or kinematic.\n if (seed.isStatic()) {\n continue;\n }\n\n // Reset island and stack.\n this.clear();\n\n stack.push(seed);\n\n seed.m_islandFlag = true;\n\n // Perform a depth first search (DFS) on the constraint graph.\n while (stack.length > 0) {\n // Grab the next body off the stack and add it to the island.\n const b = stack.pop();\n if (_ASSERT) console.assert(b.isActive() == true);\n this.addBody(b);\n\n // Make sure the body is awake (without resetting sleep timer).\n b.m_awakeFlag = true;\n\n // To keep islands as small as possible, we don't\n // propagate islands across static bodies.\n if (b.isStatic()) {\n continue;\n }\n\n // Search all contacts connected to this body.\n for (let ce = b.m_contactList; ce; ce = ce.next) {\n const contact = ce.contact;\n\n // Has this contact already been added to an island?\n if (contact.m_islandFlag) {\n continue;\n }\n\n // Is this contact solid and touching?\n if (contact.isEnabled() == false || contact.isTouching() == false) {\n continue;\n }\n\n // Skip sensors.\n const sensorA = contact.m_fixtureA.m_isSensor;\n const sensorB = contact.m_fixtureB.m_isSensor;\n if (sensorA || sensorB) {\n continue;\n }\n\n this.addContact(contact);\n contact.m_islandFlag = true;\n\n const other = ce.other;\n\n // Was the other body already added to this island?\n if (other.m_islandFlag) {\n continue;\n }\n\n // if (_ASSERT) console.assert(stack.length < world.m_bodyCount);\n stack.push(other);\n other.m_islandFlag = true;\n }\n\n // Search all joints connect to this body.\n for (let je = b.m_jointList; je; je = je.next) {\n if (je.joint.m_islandFlag == true) {\n continue;\n }\n\n const other = je.other;\n\n // Don't simulate joints connected to inactive bodies.\n if (other.isActive() == false) {\n continue;\n }\n\n this.addJoint(je.joint);\n je.joint.m_islandFlag = true;\n\n if (other.m_islandFlag) {\n continue;\n }\n\n // if (_ASSERT) console.assert(stack.length < world.m_bodyCount);\n stack.push(other);\n other.m_islandFlag = true;\n }\n }\n\n this.solveIsland(step);\n\n // Post solve cleanup.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n // Allow static bodies to participate in other islands.\n // TODO: are they added at all?\n const b = this.m_bodies[i];\n if (b.isStatic()) {\n b.m_islandFlag = false;\n }\n }\n }\n }\n\n solveIsland(step: TimeStep): void {\n // B2: Island Solve\n const world = this.m_world;\n const gravity = world.m_gravity;\n const allowSleep = world.m_allowSleep;\n\n const h = step.dt;\n\n // Integrate velocities and apply damping. Initialize the body state.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.m_sweep.c);\n const a = body.m_sweep.a;\n matrix.copyVec2(v, body.m_linearVelocity);\n let w = body.m_angularVelocity;\n\n // Store positions for continuous collision.\n matrix.copyVec2(body.m_sweep.c0, body.m_sweep.c);\n body.m_sweep.a0 = body.m_sweep.a;\n\n if (body.isDynamic()) {\n // Integrate velocities.\n matrix.plusScaleVec2(v, h * body.m_gravityScale, gravity);\n matrix.plusScaleVec2(v, h * body.m_invMass, body.m_force);\n w += h * body.m_invI * body.m_torque;\n /**\n *
\n         * Apply damping.\n         * ODE: dv/dt + c * v = 0\n         * Solution: v(t) = v0 * exp(-c * t)\n         * Time step: v(t + dt) = v0 * exp(-c * (t + dt)) = v0 * exp(-c * t) * exp(-c * dt) = v * exp(-c * dt)\n         * v2 = exp(-c * dt) * v1\n         * Pade approximation:\n         * v2 = v1 * 1 / (1 + c * dt)\n         * 
\n */\n matrix.scaleVec2(v, 1.0 / (1.0 + h * body.m_linearDamping), v);\n w *= 1.0 / (1.0 + h * body.m_angularDamping);\n }\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initConstraint(step);\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initVelocityConstraint(step);\n }\n\n if (step.warmStarting) {\n // Warm start.\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.warmStartConstraint(step);\n }\n }\n\n for (let i = 0; i < this.m_joints.length; ++i) {\n const joint = this.m_joints[i];\n joint.initVelocityConstraints(step);\n }\n\n // Solve velocity constraints\n for (let i = 0; i < step.velocityIterations; ++i) {\n for (let j = 0; j < this.m_joints.length; ++j) {\n const joint = this.m_joints[j];\n joint.solveVelocityConstraints(step);\n }\n\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n contact.solveVelocityConstraint(step);\n }\n }\n\n // Store impulses for warm starting\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.storeConstraintImpulses(step);\n }\n\n // Integrate positions\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.c_position.c);\n let a = body.c_position.a;\n matrix.copyVec2(v, body.c_velocity.v);\n let w = body.c_velocity.w;\n\n // Check for large velocities\n matrix.scaleVec2(translation, h, v);\n const translationLengthSqr = matrix.lengthSqrVec2(translation);\n if (translationLengthSqr > Settings.maxTranslationSquared) {\n const ratio = Settings.maxTranslation / math_sqrt(translationLengthSqr);\n matrix.mulVec2(v, ratio);\n }\n\n const rotation = h * w;\n if (rotation * rotation > Settings.maxRotationSquared) {\n const ratio = Settings.maxRotation / math_abs(rotation);\n w *= ratio;\n }\n\n // Integrate\n matrix.plusScaleVec2(c, h, v);\n a += h * w;\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n }\n\n // Solve position constraints\n let positionSolved = false;\n for (let i = 0; i < step.positionIterations; ++i) {\n let minSeparation = 0.0;\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n const separation = contact.solvePositionConstraint(step);\n minSeparation = math_min(minSeparation, separation);\n }\n // We can't expect minSpeparation >= -Settings.linearSlop because we don't\n // push the separation above -Settings.linearSlop.\n const contactsOkay = minSeparation >= -3.0 * Settings.linearSlop;\n\n let jointsOkay = true;\n for (let j = 0; j < this.m_joints.length; ++j) {\n const joint = this.m_joints[j];\n const jointOkay = joint.solvePositionConstraints(step);\n jointsOkay = jointsOkay && jointOkay;\n }\n\n if (contactsOkay && jointsOkay) {\n // Exit early if the position errors are small.\n positionSolved = true;\n break;\n }\n }\n\n // Copy state buffers back to the bodies\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(body.m_sweep.c, body.c_position.c);\n body.m_sweep.a = body.c_position.a;\n matrix.copyVec2(body.m_linearVelocity, body.c_velocity.v);\n body.m_angularVelocity = body.c_velocity.w;\n body.synchronizeTransform();\n }\n\n this.postSolveIsland();\n\n if (allowSleep) {\n let minSleepTime = Infinity;\n\n const linTolSqr = Settings.linearSleepToleranceSqr;\n const angTolSqr = Settings.angularSleepToleranceSqr;\n\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n if (body.isStatic()) {\n continue;\n }\n\n if ((body.m_autoSleepFlag == false)\n || (body.m_angularVelocity * body.m_angularVelocity > angTolSqr)\n || (matrix.lengthSqrVec2(body.m_linearVelocity) > linTolSqr)) {\n body.m_sleepTime = 0.0;\n minSleepTime = 0.0;\n } else {\n body.m_sleepTime += h;\n minSleepTime = math_min(minSleepTime, body.m_sleepTime);\n }\n }\n\n if (minSleepTime >= Settings.timeToSleep && positionSolved) {\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n body.setAwake(false);\n }\n }\n }\n }\n\n /**\n * Find TOI contacts and solve them.\n */\n solveWorldTOI(step: TimeStep): void {\n const world = this.m_world;\n\n if (world.m_stepComplete) {\n for (let b = world.m_bodyList; b; b = b.m_next) {\n b.m_islandFlag = false;\n b.m_sweep.alpha0 = 0.0;\n }\n\n for (let c = world.m_contactList; c; c = c.m_next) {\n // Invalidate TOI\n c.m_toiFlag = false;\n c.m_islandFlag = false;\n c.m_toiCount = 0;\n c.m_toi = 1.0;\n }\n }\n\n // Find TOI events and solve them.\n while (true) {\n // Find the first TOI.\n let minContact: Contact | null = null;\n let minAlpha = 1.0;\n\n for (let c = world.m_contactList; c; c = c.m_next) {\n // Is this contact disabled?\n if (c.isEnabled() == false) {\n continue;\n }\n\n // Prevent excessive sub-stepping.\n if (c.m_toiCount > Settings.maxSubSteps) {\n continue;\n }\n\n let alpha = 1.0;\n if (c.m_toiFlag) {\n // This contact has a valid cached TOI.\n alpha = c.m_toi;\n } else {\n const fA = c.getFixtureA();\n const fB = c.getFixtureB();\n\n // Is there a sensor?\n if (fA.isSensor() || fB.isSensor()) {\n continue;\n }\n\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n if (_ASSERT) console.assert(bA.isDynamic() || bB.isDynamic());\n\n const activeA = bA.isAwake() && !bA.isStatic();\n const activeB = bB.isAwake() && !bB.isStatic();\n\n // Is at least one body active (awake and dynamic or kinematic)?\n if (activeA == false && activeB == false) {\n continue;\n }\n\n const collideA = bA.isBullet() || !bA.isDynamic();\n const collideB = bB.isBullet() || !bB.isDynamic();\n\n // Are these two non-bullet dynamic bodies?\n if (collideA == false && collideB == false) {\n continue;\n }\n\n // Compute the TOI for this contact.\n // Put the sweeps onto the same time interval.\n let alpha0 = bA.m_sweep.alpha0;\n\n if (bA.m_sweep.alpha0 < bB.m_sweep.alpha0) {\n alpha0 = bB.m_sweep.alpha0;\n bA.m_sweep.advance(alpha0);\n } else if (bB.m_sweep.alpha0 < bA.m_sweep.alpha0) {\n alpha0 = bA.m_sweep.alpha0;\n bB.m_sweep.advance(alpha0);\n }\n\n if (_ASSERT) console.assert(alpha0 < 1.0);\n\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n\n const sweepA = bA.m_sweep;\n const sweepB = bB.m_sweep;\n\n // Compute the time of impact in interval [0, minTOI]\n input.proxyA.set(fA.getShape(), indexA);\n input.proxyB.set(fB.getShape(), indexB);\n input.sweepA.set(bA.m_sweep);\n input.sweepB.set(bB.m_sweep);\n input.tMax = 1.0;\n\n TimeOfImpact(output, input);\n\n // Beta is the fraction of the remaining portion of the [time?].\n const beta = output.t;\n if (output.state == TOIOutputState.e_touching) {\n alpha = math_min(alpha0 + (1.0 - alpha0) * beta, 1.0);\n } else {\n alpha = 1.0;\n }\n\n c.m_toi = alpha;\n c.m_toiFlag = true;\n }\n\n if (alpha < minAlpha) {\n // This is the minimum TOI found so far.\n minContact = c;\n minAlpha = alpha;\n }\n }\n\n if (minContact == null || 1.0 - 10.0 * EPSILON < minAlpha) {\n // No more TOI events. Done!\n world.m_stepComplete = true;\n break;\n }\n\n // Advance the bodies to the TOI.\n const fA = minContact.getFixtureA();\n const fB = minContact.getFixtureB();\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n backup1.set(bA.m_sweep);\n backup2.set(bB.m_sweep);\n\n bA.advance(minAlpha);\n bB.advance(minAlpha);\n\n // The TOI contact likely has some new contact points.\n minContact.update(world);\n minContact.m_toiFlag = false;\n ++minContact.m_toiCount;\n\n // Is the contact solid?\n if (minContact.isEnabled() == false || minContact.isTouching() == false) {\n // Restore the sweeps.\n minContact.setEnabled(false);\n bA.m_sweep.set(backup1);\n bB.m_sweep.set(backup2);\n bA.synchronizeTransform();\n bB.synchronizeTransform();\n continue;\n }\n\n bA.setAwake(true);\n bB.setAwake(true);\n\n // Build the island\n this.clear();\n this.addBody(bA);\n this.addBody(bB);\n this.addContact(minContact);\n\n bA.m_islandFlag = true;\n bB.m_islandFlag = true;\n minContact.m_islandFlag = true;\n\n // Get contacts on bodyA and bodyB.\n const bodies = [ bA, bB ];\n for (let i = 0; i < bodies.length; ++i) {\n const body = bodies[i];\n if (body.isDynamic()) {\n for (let ce = body.m_contactList; ce; ce = ce.next) {\n // if (this.m_bodyCount == this.m_bodyCapacity) { break; }\n // if (this.m_contactCount == this.m_contactCapacity) { break; }\n\n const contact = ce.contact;\n\n // Has this contact already been added to the island?\n if (contact.m_islandFlag) {\n continue;\n }\n\n // Only add if either is static, kinematic or bullet.\n const other = ce.other;\n if (other.isDynamic() && !body.isBullet() && !other.isBullet()) {\n continue;\n }\n\n // Skip sensors.\n const sensorA = contact.m_fixtureA.m_isSensor;\n const sensorB = contact.m_fixtureB.m_isSensor;\n if (sensorA || sensorB) {\n continue;\n }\n\n // Tentatively advance the body to the TOI.\n backup.set(other.m_sweep);\n if (other.m_islandFlag == false) {\n other.advance(minAlpha);\n }\n\n // Update the contact points\n contact.update(world);\n\n // Was the contact disabled by the user?\n // Are there contact points?\n if (contact.isEnabled() == false || contact.isTouching() == false) {\n other.m_sweep.set(backup);\n other.synchronizeTransform();\n continue;\n }\n\n // Add the contact to the island\n contact.m_islandFlag = true;\n this.addContact(contact);\n\n // Has the other body already been added to the island?\n if (other.m_islandFlag) {\n continue;\n }\n\n // Add the other body to the island.\n other.m_islandFlag = true;\n\n if (!other.isStatic()) {\n other.setAwake(true);\n }\n\n this.addBody(other);\n }\n }\n }\n\n s_subStep.reset((1.0 - minAlpha) * step.dt);\n s_subStep.dtRatio = 1.0;\n s_subStep.positionIterations = 20;\n s_subStep.velocityIterations = step.velocityIterations;\n s_subStep.warmStarting = false;\n\n this.solveIslandTOI(s_subStep, bA, bB);\n\n // Reset island flags and synchronize broad-phase proxies.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n body.m_islandFlag = false;\n\n if (!body.isDynamic()) {\n continue;\n }\n\n body.synchronizeFixtures();\n\n // Invalidate all contact TOIs on this displaced body.\n for (let ce = body.m_contactList; ce; ce = ce.next) {\n ce.contact.m_toiFlag = false;\n ce.contact.m_islandFlag = false;\n }\n }\n\n // Commit fixture proxy movements to the broad-phase so that new contacts\n // are created.\n // Also, some contacts can be destroyed.\n world.findNewContacts();\n\n if (world.m_subStepping) {\n world.m_stepComplete = false;\n break;\n }\n }\n }\n\n solveIslandTOI(subStep: TimeStep, toiA: Body, toiB: Body): void {\n\n // Initialize the body state.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n matrix.copyVec2(body.c_position.c, body.m_sweep.c);\n body.c_position.a = body.m_sweep.a;\n matrix.copyVec2(body.c_velocity.v, body.m_linearVelocity);\n body.c_velocity.w = body.m_angularVelocity;\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initConstraint(subStep);\n }\n\n // Solve position constraints.\n for (let i = 0; i < subStep.positionIterations; ++i) {\n let minSeparation = 0.0;\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n const separation = contact.solvePositionConstraintTOI(subStep, toiA, toiB);\n minSeparation = math_min(minSeparation, separation);\n }\n // We can't expect minSpeparation >= -Settings.linearSlop because we don't\n // push the separation above -Settings.linearSlop.\n const contactsOkay = minSeparation >= -1.5 * Settings.linearSlop;\n if (contactsOkay) {\n break;\n }\n }\n\n if (false) {\n // Is the new position really safe?\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const c = this.m_contacts[i];\n const fA = c.getFixtureA();\n const fB = c.getFixtureB();\n\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n\n const input = new DistanceInput();\n input.proxyA.set(fA.getShape(), indexA);\n input.proxyB.set(fB.getShape(), indexB);\n input.transformA.set(bA.getTransform());\n input.transformB.set(bB.getTransform());\n input.useRadii = false;\n\n const output = new DistanceOutput();\n const cache = new SimplexCache();\n Distance(output, cache, input);\n\n if (output.distance == 0 || cache.count == 3) {\n cache.count += 0;\n }\n }\n }\n\n // Leap of faith to new safe state.\n matrix.copyVec2(toiA.m_sweep.c0, toiA.c_position.c);\n toiA.m_sweep.a0 = toiA.c_position.a;\n matrix.copyVec2(toiB.m_sweep.c0, toiB.c_position.c);\n toiB.m_sweep.a0 = toiB.c_position.a;\n\n // No warm starting is needed for TOI events because warm\n // starting impulses were applied in the discrete solver.\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initVelocityConstraint(subStep);\n }\n\n // Solve velocity constraints.\n for (let i = 0; i < subStep.velocityIterations; ++i) {\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n contact.solveVelocityConstraint(subStep);\n }\n }\n\n // Don't store the TOI contact forces for warm starting\n // because they can be quite large.\n\n const h = subStep.dt;\n\n // Integrate positions\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.c_position.c);\n let a = body.c_position.a;\n matrix.copyVec2(v, body.c_velocity.v);\n let w = body.c_velocity.w;\n\n // Check for large velocities\n matrix.scaleVec2(translation, h, v);\n const translationLengthSqr = matrix.lengthSqrVec2(translation);\n if (translationLengthSqr > Settings.maxTranslationSquared) {\n const ratio = Settings.maxTranslation / math_sqrt(translationLengthSqr);\n matrix.mulVec2(v, ratio);\n }\n\n const rotation = h * w;\n if (rotation * rotation > Settings.maxRotationSquared) {\n const ratio = Settings.maxRotation / math_abs(rotation);\n w *= ratio;\n }\n\n // Integrate\n matrix.plusScaleVec2(c, h, v);\n a += h * w;\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n\n // Sync bodies\n matrix.copyVec2(body.m_sweep.c, c);\n body.m_sweep.a = a;\n matrix.copyVec2(body.m_linearVelocity, v);\n body.m_angularVelocity = w;\n body.synchronizeTransform();\n }\n\n this.postSolveIsland();\n }\n\n /** @internal */\n postSolveIsland(): void {\n for (let c = 0; c < this.m_contacts.length; ++c) {\n const contact = this.m_contacts[c];\n this.m_world.postSolve(contact, contact.m_impulse);\n }\n }\n}\n\n// @ts-ignore\nSolver.TimeStep = TimeStep;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A 2-by-2 matrix. Stored in column-major order.\n */\nexport class Mat22 {\n ex: Vec2;\n ey: Vec2;\n\n constructor(a: number, b: number, c: number, d: number);\n constructor(a: { x: number; y: number }, b: { x: number; y: number });\n constructor();\n constructor(a?, b?, c?, d?) {\n if (typeof a === \"object\" && a !== null) {\n this.ex = Vec2.clone(a);\n this.ey = Vec2.clone(b);\n } else if (typeof a === \"number\") {\n this.ex = Vec2.neo(a, c);\n this.ey = Vec2.neo(b, d);\n } else {\n this.ex = Vec2.zero();\n this.ey = Vec2.zero();\n }\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.ex) && Vec2.isValid(obj.ey);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Mat22.isValid(o), \"Invalid Mat22!\", o);\n }\n\n set(a: Mat22): void;\n set(a: Vec2Value, b: Vec2Value): void;\n set(a: number, b: number, c: number, d: number): void;\n set(a, b?, c?, d?): void {\n if (typeof a === \"number\" && typeof b === \"number\" && typeof c === \"number\"\n && typeof d === \"number\") {\n this.ex.setNum(a, c);\n this.ey.setNum(b, d);\n\n } else if (typeof a === \"object\" && typeof b === \"object\") {\n this.ex.setVec2(a);\n this.ey.setVec2(b);\n\n } else if (typeof a === \"object\") {\n if (_ASSERT) Mat22.assert(a);\n this.ex.setVec2(a.ex);\n this.ey.setVec2(a.ey);\n\n } else {\n if (_ASSERT) console.assert(false);\n }\n }\n\n setIdentity(): void {\n this.ex.x = 1.0;\n this.ey.x = 0.0;\n this.ex.y = 0.0;\n this.ey.y = 1.0;\n }\n\n setZero(): void {\n this.ex.x = 0.0;\n this.ey.x = 0.0;\n this.ex.y = 0.0;\n this.ey.y = 0.0;\n }\n\n getInverse(): Mat22 {\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const imx = new Mat22();\n imx.ex.x = det * d;\n imx.ey.x = -det * b;\n imx.ex.y = -det * c;\n imx.ey.y = det * a;\n return imx;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases.\n */\n solve(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const w = Vec2.zero();\n w.x = det * (d * v.x - b * v.y);\n w.y = det * (a * v.y - c * v.x);\n return w;\n }\n\n /**\n * Multiply a matrix times a vector. If a rotation matrix is provided, then this\n * transforms the vector from one frame to another.\n */\n static mul(mx: Mat22, my: Mat22): Mat22;\n static mul(mx: Mat22, v: Vec2Value): Vec2;\n static mul(mx, v) {\n if (v && \"x\" in v && \"y\" in v) {\n if (_ASSERT) Vec2.assert(v);\n const x = mx.ex.x * v.x + mx.ey.x * v.y;\n const y = mx.ex.y * v.x + mx.ey.y * v.y;\n return Vec2.neo(x, y);\n\n } else if (v && \"ex\" in v && \"ey\" in v) { // Mat22\n if (_ASSERT) Mat22.assert(v);\n // return new Mat22(Vec2.mul(mx, v.ex), Vec2.mul(mx, v.ey));\n const a = mx.ex.x * v.ex.x + mx.ey.x * v.ex.y;\n const b = mx.ex.x * v.ey.x + mx.ey.x * v.ey.y;\n const c = mx.ex.y * v.ex.x + mx.ey.y * v.ex.y;\n const d = mx.ex.y * v.ey.x + mx.ey.y * v.ey.y;\n return new Mat22(a, b, c, d);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulVec2(mx: Mat22, v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n const x = mx.ex.x * v.x + mx.ey.x * v.y;\n const y = mx.ex.y * v.x + mx.ey.y * v.y;\n return Vec2.neo(x, y);\n }\n\n static mulMat22(mx: Mat22, v: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(v);\n // return new Mat22(Vec2.mul(mx, v.ex), Vec2.mul(mx, v.ey));\n const a = mx.ex.x * v.ex.x + mx.ey.x * v.ex.y;\n const b = mx.ex.x * v.ey.x + mx.ey.x * v.ey.y;\n const c = mx.ex.y * v.ex.x + mx.ey.y * v.ex.y;\n const d = mx.ex.y * v.ey.x + mx.ey.y * v.ey.y;\n return new Mat22(a, b, c, d);\n }\n\n /**\n * Multiply a matrix transpose times a vector. If a rotation matrix is provided,\n * then this transforms the vector from one frame to another (inverse\n * transform).\n */\n static mulT(mx: Mat22, my: Mat22): Mat22;\n static mulT(mx: Mat22, v: Vec2Value): Vec2;\n static mulT(mx, v) {\n if (v && \"x\" in v && \"y\" in v) { // Vec2\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(Vec2.dot(v, mx.ex), Vec2.dot(v, mx.ey));\n\n } else if (v && \"ex\" in v && \"ey\" in v) { // Mat22\n if (_ASSERT) Mat22.assert(v);\n const c1 = Vec2.neo(Vec2.dot(mx.ex, v.ex), Vec2.dot(mx.ey, v.ex));\n const c2 = Vec2.neo(Vec2.dot(mx.ex, v.ey), Vec2.dot(mx.ey, v.ey));\n return new Mat22(c1, c2);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulTVec2(mx: Mat22, v: Vec2Value): Vec2 {\n if (_ASSERT) Mat22.assert(mx);\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(Vec2.dot(v, mx.ex), Vec2.dot(v, mx.ey));\n }\n\n static mulTMat22(mx: Mat22, v: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx);\n if (_ASSERT) Mat22.assert(v);\n const c1 = Vec2.neo(Vec2.dot(mx.ex, v.ex), Vec2.dot(mx.ey, v.ex));\n const c2 = Vec2.neo(Vec2.dot(mx.ex, v.ey), Vec2.dot(mx.ey, v.ey));\n return new Mat22(c1, c2);\n }\n\n static abs(mx: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx);\n return new Mat22(Vec2.abs(mx.ex), Vec2.abs(mx.ey));\n }\n\n static add(mx1: Mat22, mx2: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx1);\n if (_ASSERT) Mat22.assert(mx2);\n return new Mat22(Vec2.add(mx1.ex, mx2.ex), Vec2.add(mx1.ey, mx2.ey));\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { Vec2Value } from \"../common/Vec2\";\nimport { TransformValue } from \"../common/Transform\";\nimport { EPSILON } from \"../common/Math\";\n\n\n/** @internal */ const math_sqrt = Math.sqrt;\n\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const cA = matrix.vec2(0, 0);\n/** @internal */ const cB = matrix.vec2(0, 0);\n/** @internal */ const dist = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const clipPoint = matrix.vec2(0, 0);\n\nexport enum ManifoldType {\n e_unset = -1,\n e_circles = 0,\n e_faceA = 1,\n e_faceB = 2\n}\n\nexport enum ContactFeatureType {\n e_unset = -1,\n e_vertex = 0,\n e_face = 1\n}\n\n/**\n * This is used for determining the state of contact points.\n */\n export enum PointState {\n /** Point does not exist */\n nullState = 0,\n /** Point was added in the update */\n addState = 1,\n /** Point persisted across the update */\n persistState = 2,\n /** Point was removed in the update */\n removeState = 3\n}\n\n/**\n * Used for computing contact manifolds.\n */\n export class ClipVertex {\n v = matrix.vec2(0, 0);\n id: ContactID = new ContactID();\n\n set(o: ClipVertex): void {\n matrix.copyVec2(this.v, o.v);\n this.id.set(o.id);\n }\n recycle() {\n matrix.zeroVec2(this.v);\n this.id.recycle();\n }\n}\n\n/**\n * A manifold for two touching convex shapes. Manifolds are created in `evaluate`\n * method of Contact subclasses.\n *\n * Supported manifold types are e_faceA or e_faceB for clip point versus plane\n * with radius and e_circles point versus point with radius.\n *\n * We store contacts in this way so that position correction can account for\n * movement, which is critical for continuous physics. All contact scenarios\n * must be expressed in one of these types. This structure is stored across time\n * steps, so we keep it small.\n */\nexport class Manifold {\n type: ManifoldType;\n\n /**\n * Usage depends on manifold type:\n * - circles: not used\n * - faceA: the normal on polygonA\n * - faceB: the normal on polygonB\n */\n localNormal = matrix.vec2(0, 0);\n\n /**\n * Usage depends on manifold type:\n * - circles: the local center of circleA\n * - faceA: the center of faceA\n * - faceB: the center of faceB\n */\n localPoint = matrix.vec2(0, 0);\n\n /** The points of contact */\n points: ManifoldPoint[] = [ new ManifoldPoint(), new ManifoldPoint() ];\n\n /** The number of manifold points */\n pointCount: number = 0;\n\n set(that: Manifold): void {\n this.type = that.type;\n matrix.copyVec2(this.localNormal, that.localNormal);\n matrix.copyVec2(this.localPoint, that.localPoint);\n this.pointCount = that.pointCount;\n this.points[0].set(that.points[0]);\n this.points[1].set(that.points[1]);\n }\n\n recycle(): void {\n this.type = ManifoldType.e_unset;\n matrix.zeroVec2(this.localNormal);\n matrix.zeroVec2(this.localPoint);\n this.pointCount = 0;\n this.points[0].recycle();\n this.points[1].recycle();\n }\n\n /**\n * Evaluate the manifold with supplied transforms. This assumes modest motion\n * from the original state. This does not change the point count, impulses, etc.\n * The radii must come from the shapes that generated the manifold.\n */\n getWorldManifold(wm: WorldManifold | null, xfA: TransformValue, radiusA: number, xfB: TransformValue, radiusB: number): WorldManifold {\n if (this.pointCount == 0) {\n return wm;\n }\n\n wm = wm || new WorldManifold();\n\n wm.pointCount = this.pointCount;\n\n const normal = wm.normal;\n const points = wm.points;\n const separations = wm.separations;\n\n switch (this.type) {\n case ManifoldType.e_circles: {\n matrix.setVec2(normal, 1.0, 0.0);\n const manifoldPoint = this.points[0];\n matrix.transformVec2(pointA, xfA, this.localPoint);\n matrix.transformVec2(pointB, xfB, manifoldPoint.localPoint);\n matrix.subVec2(dist, pointB, pointA);\n const lengthSqr = matrix.lengthSqrVec2(dist);\n if (lengthSqr > EPSILON * EPSILON) {\n const length = math_sqrt(lengthSqr);\n matrix.scaleVec2(normal, 1 / length, dist);\n }\n matrix.combine2Vec2(cA, 1, pointA, radiusA, normal);\n matrix.combine2Vec2(cB, 1, pointB, -radiusB, normal);\n matrix.combine2Vec2(points[0], 0.5, cA, 0.5, cB);\n separations[0] = matrix.dotVec2(matrix.subVec2(temp, cB, cA), normal);\n break;\n }\n\n case ManifoldType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.localNormal);\n matrix.transformVec2(planePoint, xfA, this.localPoint);\n\n for (let i = 0; i < this.pointCount; ++i) {\n const manifoldPoint = this.points[i];\n matrix.transformVec2(clipPoint, xfB, manifoldPoint.localPoint);\n matrix.combine2Vec2(cA, 1, clipPoint, radiusA - matrix.dotVec2(matrix.subVec2(temp, clipPoint, planePoint), normal), normal);\n matrix.combine2Vec2(cB, 1, clipPoint, -radiusB, normal);\n matrix.combine2Vec2(points[i], 0.5, cA, 0.5, cB);\n separations[i] = matrix.dotVec2(matrix.subVec2(temp, cB, cA), normal);\n }\n break;\n }\n\n case ManifoldType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.localNormal);\n matrix.transformVec2(planePoint, xfB, this.localPoint);\n\n for (let i = 0; i < this.pointCount; ++i) {\n const manifoldPoint = this.points[i];\n matrix.transformVec2(clipPoint, xfA, manifoldPoint.localPoint);\n matrix.combine2Vec2(cB, 1, clipPoint, radiusB - matrix.dotVec2(matrix.subVec2(temp, clipPoint, planePoint), normal), normal);\n matrix.combine2Vec2(cA, 1, clipPoint, -radiusA, normal);\n matrix.combine2Vec2(points[i], 0.5, cA, 0.5, cB);\n separations[i] = matrix.dotVec2(matrix.subVec2(temp, cA, cB), normal);\n }\n // Ensure normal points from A to B.\n matrix.negVec2(normal);\n break;\n }\n }\n\n return wm;\n }\n\n static clipSegmentToLine = clipSegmentToLine;\n static ClipVertex = ClipVertex;\n static getPointStates = getPointStates;\n static PointState = PointState;\n}\n\n/**\n * A manifold point is a contact point belonging to a contact manifold. It holds\n * details related to the geometry and dynamics of the contact points.\n *\n * This structure is stored across time steps, so we keep it small.\n *\n * Note: impulses are used for internal caching and may not provide reliable\n * contact forces, especially for high speed collisions.\n */\nexport class ManifoldPoint {\n /**\n * Usage depends on manifold type:\n * - circles: the local center of circleB\n * - faceA: the local center of circleB or the clip point of polygonB\n * - faceB: the clip point of polygonA\n */\n localPoint = matrix.vec2(0, 0);\n /**\n * The non-penetration impulse\n */\n normalImpulse = 0;\n /**\n * The friction impulse\n */\n tangentImpulse = 0;\n /**\n * Uniquely identifies a contact point between two shapes to facilitate warm starting\n */\n readonly id = new ContactID();\n\n set(that: ManifoldPoint): void {\n matrix.copyVec2(this.localPoint, that.localPoint);\n this.normalImpulse = that.normalImpulse;\n this.tangentImpulse = that.tangentImpulse;\n this.id.set(that.id);\n }\n\n recycle(): void {\n matrix.zeroVec2(this.localPoint);\n this.normalImpulse = 0;\n this.tangentImpulse = 0;\n this.id.recycle();\n }\n}\n\n/**\n * Contact ids to facilitate warm starting.\n * \n * ContactFeature: The features that intersect to form the contact point.\n */\nexport class ContactID {\n\n /**\n * Used to quickly compare contact ids.\n */\n key = -1;\n\n /** ContactFeature index on shapeA */\n indexA = -1;\n\n /** ContactFeature index on shapeB */\n indexB = -1;\n\n /** ContactFeature type on shapeA */\n typeA = ContactFeatureType.e_unset;\n\n /** ContactFeature type on shapeB */\n typeB = ContactFeatureType.e_unset;\n\n setFeatures(indexA: number, typeA: ContactFeatureType, indexB: number, typeB: ContactFeatureType): void {\n this.indexA = indexA;\n this.indexB = indexB;\n this.typeA = typeA;\n this.typeB = typeB;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n set(that: ContactID): void {\n this.indexA = that.indexA;\n this.indexB = that.indexB;\n this.typeA = that.typeA;\n this.typeB = that.typeB;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n swapFeatures(): void {\n const indexA = this.indexA;\n const indexB = this.indexB;\n const typeA = this.typeA;\n const typeB = this.typeB;\n this.indexA = indexB;\n this.indexB = indexA;\n this.typeA = typeB;\n this.typeB = typeA;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n recycle(): void {\n this.indexA = 0;\n this.indexB = 0;\n this.typeA = ContactFeatureType.e_unset;\n this.typeB = ContactFeatureType.e_unset;\n this.key = -1;\n }\n}\n\n/**\n * This is used to compute the current state of a contact manifold.\n */\nexport class WorldManifold {\n /** World vector pointing from A to B */\n normal = matrix.vec2(0, 0);\n\n /** World contact point (point of intersection) */\n points = [matrix.vec2(0, 0), matrix.vec2(0, 0)]; // [maxManifoldPoints]\n\n /** A negative value indicates overlap, in meters */\n separations = [0, 0]; // [maxManifoldPoints]\n\n /** The number of manifold points */\n pointCount = 0;\n\n recycle() {\n matrix.zeroVec2(this.normal);\n matrix.zeroVec2(this.points[0]);\n matrix.zeroVec2(this.points[1]);\n this.separations[0] = 0;\n this.separations[1] = 0;\n this.pointCount = 0;\n }\n}\n\n/**\n * Compute the point states given two manifolds. The states pertain to the\n * transition from manifold1 to manifold2. So state1 is either persist or remove\n * while state2 is either add or persist.\n */\nexport function getPointStates(\n state1: PointState[],\n state2: PointState[],\n manifold1: Manifold,\n manifold2: Manifold\n): void {\n // state1, state2: PointState[Settings.maxManifoldPoints]\n\n // for (var i = 0; i < Settings.maxManifoldPoints; ++i) {\n // state1[i] = PointState.nullState;\n // state2[i] = PointState.nullState;\n // }\n\n // Detect persists and removes.\n for (let i = 0; i < manifold1.pointCount; ++i) {\n const id = manifold1.points[i].id;\n\n state1[i] = PointState.removeState;\n\n for (let j = 0; j < manifold2.pointCount; ++j) {\n if (manifold2.points[j].id.key === id.key) {\n state1[i] = PointState.persistState;\n break;\n }\n }\n }\n\n // Detect persists and adds.\n for (let i = 0; i < manifold2.pointCount; ++i) {\n const id = manifold2.points[i].id;\n\n state2[i] = PointState.addState;\n\n for (let j = 0; j < manifold1.pointCount; ++j) {\n if (manifold1.points[j].id.key === id.key) {\n state2[i] = PointState.persistState;\n break;\n }\n }\n }\n}\n\n/**\n * Clipping for contact manifolds. Sutherland-Hodgman clipping.\n */\nexport function clipSegmentToLine(\n vOut: ClipVertex[],\n vIn: ClipVertex[],\n normal: Vec2Value,\n offset: number,\n vertexIndexA: number\n): number {\n // Start with no output points\n let numOut = 0;\n\n // Calculate the distance of end points to the line\n const distance0 = matrix.dotVec2(normal, vIn[0].v) - offset;\n const distance1 = matrix.dotVec2(normal, vIn[1].v) - offset;\n\n // If the points are behind the plane\n if (distance0 <= 0.0)\n vOut[numOut++].set(vIn[0]);\n if (distance1 <= 0.0)\n vOut[numOut++].set(vIn[1]);\n\n // If the points are on different sides of the plane\n if (distance0 * distance1 < 0.0) {\n // Find intersection point of edge and plane\n const interp = distance0 / (distance0 - distance1);\n matrix.combine2Vec2(vOut[numOut].v, 1 - interp, vIn[0].v, interp, vIn[1].v);\n\n // VertexA is hitting edgeB.\n vOut[numOut].id.setFeatures(vertexIndexA, ContactFeatureType.e_vertex, vIn[0].id.indexB, ContactFeatureType.e_face);\n ++numOut;\n }\n\n return numOut;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { ShapeType } from \"../collision/Shape\";\nimport { clamp } from \"../common/Math\";\nimport { TransformValue } from \"../common/Transform\";\nimport { Mat22 } from \"../common/Mat22\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { Manifold, ManifoldType, WorldManifold } from \"../collision/Manifold\";\nimport { testOverlap } from \"../collision/Distance\";\nimport { Fixture } from \"./Fixture\";\nimport { Body } from \"./Body\";\nimport { ContactImpulse, TimeStep } from \"./Solver\";\nimport { Pool } from \"../util/Pool\";\nimport { getTransform } from \"./Position\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n// Solver debugging is normally disabled because the block solver sometimes has to deal with a poorly conditioned effective mass matrix.\n/** @internal */ const DEBUG_SOLVER = false;\n\n/** @internal */ const contactPool = new Pool({\n create() {\n return new Contact();\n },\n release(contact: Contact) {\n contact.recycle();\n }\n});\n\n/** @internal */ const oldManifold = new Manifold();\n\n/** @internal */ const worldManifold = new WorldManifold();\n\n/**\n * A contact edge is used to connect bodies and contacts together in a contact\n * graph where each body is a node and each contact is an edge. A contact edge\n * belongs to a doubly linked list maintained in each attached body. Each\n * contact has two contact nodes, one for each attached body.\n */\nexport class ContactEdge {\n contact: Contact;\n prev: ContactEdge | null = null;\n next: ContactEdge | null = null;\n other: Body | null = null;\n constructor(contact: Contact) {\n this.contact = contact;\n }\n\n /** @internal */\n recycle() {\n this.prev = null;\n this.next = null;\n this.other = null;\n }\n}\n\nexport type EvaluateFunction = (\n manifold: Manifold,\n xfA: TransformValue,\n fixtureA: Fixture,\n indexA: number,\n xfB: TransformValue,\n fixtureB: Fixture,\n indexB: number\n) => void;\n\n/**\n * Friction mixing law. The idea is to allow either fixture to drive the\n * friction to zero. For example, anything slides on ice.\n */\nexport function mixFriction(friction1: number, friction2: number): number {\n return math_sqrt(friction1 * friction2);\n}\n\n/**\n * Restitution mixing law. The idea is allow for anything to bounce off an\n * inelastic surface. For example, a superball bounces on anything.\n */\nexport function mixRestitution(restitution1: number, restitution2: number): number {\n return restitution1 > restitution2 ? restitution1 : restitution2;\n}\n\n// TODO: move this to Settings?\n/** @internal */ const s_registers = [];\n\n// TODO: merge with ManifoldPoint?\nexport class VelocityConstraintPoint {\n rA = matrix.vec2(0, 0);\n rB = matrix.vec2(0, 0);\n normalImpulse = 0;\n tangentImpulse = 0;\n normalMass = 0;\n tangentMass = 0;\n velocityBias = 0;\n\n recycle() {\n matrix.zeroVec2(this.rA);\n matrix.zeroVec2(this.rB);\n this.normalImpulse = 0;\n this.tangentImpulse = 0;\n this.normalMass = 0;\n this.tangentMass = 0;\n this.velocityBias = 0;\n }\n}\n\n/** @internal */ const cA = matrix.vec2(0, 0);\n/** @internal */ const vA = matrix.vec2(0, 0);\n/** @internal */ const cB = matrix.vec2(0, 0);\n/** @internal */ const vB = matrix.vec2(0, 0);\n/** @internal */ const tangent = matrix.vec2(0, 0);\n/** @internal */ const xfA = matrix.transform(0, 0, 0);\n/** @internal */ const xfB = matrix.transform(0, 0, 0);\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const clipPoint = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const rA = matrix.vec2(0, 0);\n/** @internal */ const rB = matrix.vec2(0, 0);\n/** @internal */ const P = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const point = matrix.vec2(0, 0);\n/** @internal */ const dv = matrix.vec2(0, 0);\n/** @internal */ const dv1 = matrix.vec2(0, 0);\n/** @internal */ const dv2 = matrix.vec2(0, 0);\n/** @internal */ const b = matrix.vec2(0, 0);\n/** @internal */ const a = matrix.vec2(0, 0);\n/** @internal */ const x = matrix.vec2(0, 0);\n/** @internal */ const d = matrix.vec2(0, 0);\n/** @internal */ const P1 = matrix.vec2(0, 0);\n/** @internal */ const P2 = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n\n/**\n * The class manages contact between two shapes. A contact exists for each\n * overlapping AABB in the broad-phase (except if filtered). Therefore a contact\n * object may exist that has no contact points.\n */\nexport class Contact {\n // Nodes for connecting bodies.\n /** @internal */ m_nodeA = new ContactEdge(this);\n /** @internal */ m_nodeB = new ContactEdge(this);\n /** @internal */ m_fixtureA: Fixture | null = null;\n /** @internal */ m_fixtureB: Fixture | null = null;\n /** @internal */ m_indexA = -1;\n /** @internal */ m_indexB = -1;\n /** @internal */ m_evaluateFcn: EvaluateFunction | null = null;\n /** @internal */ m_manifold: Manifold = new Manifold();\n /** @internal */ m_prev: Contact | null = null;\n /** @internal */ m_next: Contact | null = null;\n /** @internal */ m_toi = 1.0;\n /** @internal */ m_toiCount = 0;\n // This contact has a valid TOI in m_toi\n /** @internal */ m_toiFlag = false;\n /** @internal */ m_friction = 0.0;\n /** @internal */ m_restitution = 0.0;\n /** @internal */ m_tangentSpeed = 0.0;\n /** @internal This contact can be disabled (by user) */\n m_enabledFlag = true;\n /** @internal Used when crawling contact graph when forming islands. */\n m_islandFlag = false;\n /** @internal Set when the shapes are touching. */\n m_touchingFlag = false;\n /** @internal This contact needs filtering because a fixture filter was changed. */\n m_filterFlag = false;\n /** @internal This bullet contact had a TOI event */\n m_bulletHitFlag = false;\n\n /** @internal Contact reporting impulse object cache */\n m_impulse: ContactImpulse = new ContactImpulse(this);\n\n // VelocityConstraint\n /** @internal */ v_points = [new VelocityConstraintPoint(), new VelocityConstraintPoint()]; // [maxManifoldPoints];\n /** @internal */ v_normal = matrix.vec2(0, 0);\n /** @internal */ v_normalMass: Mat22 = new Mat22();\n /** @internal */ v_K: Mat22 = new Mat22();\n /** @internal */ v_pointCount = 0;\n /** @internal */ v_tangentSpeed = 0;\n /** @internal */ v_friction = 0;\n /** @internal */ v_restitution = 0;\n /** @internal */ v_invMassA = 0;\n /** @internal */ v_invMassB = 0;\n /** @internal */ v_invIA = 0;\n /** @internal */ v_invIB = 0;\n\n // PositionConstraint\n /** @internal */ p_localPoints = [matrix.vec2(0, 0), matrix.vec2(0, 0)]; // [maxManifoldPoints];\n /** @internal */ p_localNormal = matrix.vec2(0, 0);\n /** @internal */ p_localPoint = matrix.vec2(0, 0);\n /** @internal */ p_localCenterA = matrix.vec2(0, 0);\n /** @internal */ p_localCenterB = matrix.vec2(0, 0);\n /** @internal */ p_type = ManifoldType.e_unset;\n /** @internal */ p_radiusA = 0;\n /** @internal */ p_radiusB = 0;\n /** @internal */ p_pointCount = 0;\n /** @internal */ p_invMassA = 0;\n /** @internal */ p_invMassB = 0;\n /** @internal */ p_invIA = 0;\n /** @internal */ p_invIB = 0;\n\n /** @internal */ \n initialize(fA: Fixture, indexA: number, fB: Fixture, indexB: number, evaluateFcn: EvaluateFunction) {\n this.m_fixtureA = fA;\n this.m_fixtureB = fB;\n\n this.m_indexA = indexA;\n this.m_indexB = indexB;\n\n this.m_evaluateFcn = evaluateFcn;\n\n this.m_friction = mixFriction(this.m_fixtureA.m_friction, this.m_fixtureB.m_friction);\n this.m_restitution = mixRestitution(this.m_fixtureA.m_restitution, this.m_fixtureB.m_restitution);\n }\n\n /** @internal */ \n recycle() {\n this.m_nodeA.recycle();\n this.m_nodeB.recycle();\n this.m_fixtureA = null;\n this.m_fixtureB = null;\n this.m_indexA = -1;\n this.m_indexB = -1;\n this.m_evaluateFcn = null;\n this.m_manifold.recycle();\n this.m_prev = null;\n this.m_next = null;\n this.m_toi = 1;\n this.m_toiCount = 0;\n this.m_toiFlag = false;\n this.m_friction = 0;\n this.m_restitution = 0;\n this.m_tangentSpeed = 0;\n this.m_enabledFlag = true;\n this.m_islandFlag = false;\n this.m_touchingFlag = false;\n this.m_filterFlag = false;\n this.m_bulletHitFlag = false;\n\n this.m_impulse.recycle();\n\n // VelocityConstraint\n for(const point of this.v_points) {\n point.recycle();\n }\n matrix.zeroVec2(this.v_normal);\n this.v_normalMass.setZero();\n this.v_K.setZero();\n this.v_pointCount = 0;\n this.v_tangentSpeed = 0;\n this.v_friction = 0;\n this.v_restitution = 0;\n this.v_invMassA = 0;\n this.v_invMassB = 0;\n this.v_invIA = 0;\n this.v_invIB = 0;\n\n // PositionConstraint\n for(const point of this.p_localPoints) {\n matrix.zeroVec2(point);\n }\n matrix.zeroVec2(this.p_localNormal);\n matrix.zeroVec2(this.p_localPoint);\n matrix.zeroVec2(this.p_localCenterA);\n matrix.zeroVec2(this.p_localCenterB);\n this.p_type = ManifoldType.e_unset;\n this.p_radiusA = 0;\n this.p_radiusB = 0;\n this.p_pointCount = 0;\n this.p_invMassA = 0;\n this.p_invMassB = 0;\n this.p_invIA = 0;\n this.p_invIB = 0;\n }\n\n initConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n const manifold = this.m_manifold;\n\n const pointCount = manifold.pointCount;\n if (_ASSERT) console.assert(pointCount > 0);\n\n this.v_invMassA = bodyA.m_invMass;\n this.v_invMassB = bodyB.m_invMass;\n this.v_invIA = bodyA.m_invI;\n this.v_invIB = bodyB.m_invI;\n\n this.v_friction = this.m_friction;\n this.v_restitution = this.m_restitution;\n this.v_tangentSpeed = this.m_tangentSpeed;\n\n this.v_pointCount = pointCount;\n\n this.v_K.setZero();\n this.v_normalMass.setZero();\n\n this.p_invMassA = bodyA.m_invMass;\n this.p_invMassB = bodyB.m_invMass;\n this.p_invIA = bodyA.m_invI;\n this.p_invIB = bodyB.m_invI;\n matrix.copyVec2(this.p_localCenterA, bodyA.m_sweep.localCenter);\n matrix.copyVec2(this.p_localCenterB, bodyB.m_sweep.localCenter);\n\n this.p_radiusA = shapeA.m_radius;\n this.p_radiusB = shapeB.m_radius;\n\n this.p_type = manifold.type;\n matrix.copyVec2(this.p_localNormal, manifold.localNormal);\n matrix.copyVec2(this.p_localPoint, manifold.localPoint);\n this.p_pointCount = pointCount;\n\n for (let j = 0; j < Settings.maxManifoldPoints; ++j) {\n this.v_points[j].recycle();\n matrix.zeroVec2(this.p_localPoints[j]);\n }\n\n for (let j = 0; j < pointCount; ++j) {\n const cp = manifold.points[j];\n const vcp = this.v_points[j];\n if (step.warmStarting) {\n vcp.normalImpulse = step.dtRatio * cp.normalImpulse;\n vcp.tangentImpulse = step.dtRatio * cp.tangentImpulse;\n }\n matrix.copyVec2(this.p_localPoints[j], cp.localPoint);\n }\n }\n\n /**\n * Get the contact manifold. Do not modify the manifold unless you understand\n * the internals of the library.\n */\n getManifold(): Manifold {\n return this.m_manifold;\n }\n\n /**\n * Get the world manifold.\n */\n getWorldManifold(worldManifold: WorldManifold | null): WorldManifold | undefined {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n return this.m_manifold.getWorldManifold(\n worldManifold,\n bodyA.getTransform(), shapeA.m_radius,\n bodyB.getTransform(), shapeB.m_radius\n );\n }\n\n /**\n * Enable/disable this contact. This can be used inside the pre-solve contact\n * listener. The contact is only disabled for the current time step (or sub-step\n * in continuous collisions).\n */\n setEnabled(flag: boolean): void {\n this.m_enabledFlag = !!flag;\n }\n\n /**\n * Has this contact been disabled?\n */\n isEnabled(): boolean {\n return this.m_enabledFlag;\n }\n\n /**\n * Is this contact touching?\n */\n isTouching(): boolean {\n return this.m_touchingFlag;\n }\n\n /**\n * Get the next contact in the world's contact list.\n */\n getNext(): Contact | null {\n return this.m_next;\n }\n\n /**\n * Get fixture A in this contact.\n */\n getFixtureA(): Fixture {\n return this.m_fixtureA;\n }\n\n /**\n * Get fixture B in this contact.\n */\n getFixtureB(): Fixture {\n return this.m_fixtureB;\n }\n\n /**\n * Get the child primitive index for fixture A.\n */\n getChildIndexA(): number {\n return this.m_indexA;\n }\n\n /**\n * Get the child primitive index for fixture B.\n */\n getChildIndexB(): number {\n return this.m_indexB;\n }\n\n /**\n * Flag this contact for filtering. Filtering will occur the next time step.\n */\n flagForFiltering(): void {\n this.m_filterFlag = true;\n }\n\n /**\n * Override the default friction mixture. You can call this in\n * \"pre-solve\" callback. This value persists until set or reset.\n */\n setFriction(friction: number): void {\n this.m_friction = friction;\n }\n\n /**\n * Get the friction.\n */\n getFriction(): number {\n return this.m_friction;\n }\n\n /**\n * Reset the friction mixture to the default value.\n */\n resetFriction(): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_friction = mixFriction(fixtureA.m_friction, fixtureB.m_friction);\n }\n\n /**\n * Override the default restitution mixture. You can call this in\n * \"pre-solve\" callback. The value persists until you set or reset.\n */\n setRestitution(restitution: number): void {\n this.m_restitution = restitution;\n }\n\n /**\n * Get the restitution.\n */\n getRestitution(): number {\n return this.m_restitution;\n }\n\n /**\n * Reset the restitution to the default value.\n */\n resetRestitution(): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_restitution = mixRestitution(fixtureA.m_restitution, fixtureB.m_restitution);\n }\n\n /**\n * Set the desired tangent speed for a conveyor belt behavior. In meters per\n * second.\n */\n setTangentSpeed(speed: number): void {\n this.m_tangentSpeed = speed;\n }\n\n /**\n * Get the desired tangent speed. In meters per second.\n */\n getTangentSpeed(): number {\n return this.m_tangentSpeed;\n }\n\n /**\n * Called by Update method, and implemented by subclasses.\n */\n evaluate(manifold: Manifold, xfA: TransformValue, xfB: TransformValue): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_evaluateFcn(manifold, xfA, fixtureA, this.m_indexA, xfB, fixtureB, this.m_indexB);\n }\n\n /**\n * Updates the contact manifold and touching status.\n *\n * Note: do not assume the fixture AABBs are overlapping or are valid.\n *\n * @param listener.beginContact\n * @param listener.endContact\n * @param listener.preSolve\n */\n update(listener?: {\n beginContact(contact: Contact): void,\n endContact(contact: Contact): void,\n preSolve(contact: Contact, oldManifold: Manifold): void\n }): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n // Re-enable this contact.\n this.m_enabledFlag = true;\n\n let touching = false;\n const wasTouching = this.m_touchingFlag;\n\n const sensorA = fixtureA.m_isSensor;\n const sensorB = fixtureB.m_isSensor;\n const sensor = sensorA || sensorB;\n\n const xfA = bodyA.m_xf;\n const xfB = bodyB.m_xf;\n\n // Is this contact a sensor?\n if (sensor) {\n touching = testOverlap(shapeA, this.m_indexA, shapeB, this.m_indexB, xfA, xfB);\n\n // Sensors don't generate manifolds.\n this.m_manifold.pointCount = 0;\n } else {\n\n oldManifold.recycle();\n oldManifold.set(this.m_manifold);\n this.m_manifold.recycle();\n\n this.evaluate(this.m_manifold, xfA, xfB);\n touching = this.m_manifold.pointCount > 0;\n\n // Match old contact ids to new contact ids and copy the\n // stored impulses to warm start the solver.\n for (let i = 0; i < this.m_manifold.pointCount; ++i) {\n const nmp = this.m_manifold.points[i];\n nmp.normalImpulse = 0.0;\n nmp.tangentImpulse = 0.0;\n\n for (let j = 0; j < oldManifold.pointCount; ++j) {\n const omp = oldManifold.points[j];\n if (omp.id.key === nmp.id.key) {\n nmp.normalImpulse = omp.normalImpulse;\n nmp.tangentImpulse = omp.tangentImpulse;\n break;\n }\n }\n }\n\n if (touching !== wasTouching) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n }\n\n this.m_touchingFlag = touching;\n\n const hasListener = typeof listener === \"object\" && listener !== null;\n\n if (!wasTouching && touching && hasListener) {\n listener.beginContact(this);\n }\n\n if (wasTouching && !touching && hasListener) {\n listener.endContact(this);\n }\n\n if (!sensor && touching && hasListener && oldManifold) {\n listener.preSolve(this, oldManifold);\n }\n }\n\n solvePositionConstraint(step: TimeStep): number {\n return this._solvePositionConstraint(step, null, null);\n }\n\n solvePositionConstraintTOI(step: TimeStep, toiA: Body, toiB: Body): number {\n return this._solvePositionConstraint(step, toiA, toiB);\n }\n\n private _solvePositionConstraint(step: TimeStep, toiA: Body | null, toiB: Body | null): number {\n const toi = toiA !== null && toiB !== null ? true : false;\n let minSeparation = 0.0;\n\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return minSeparation;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return minSeparation;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const localCenterA = this.p_localCenterA;\n const localCenterB = this.p_localCenterB;\n\n let mA = 0.0;\n let iA = 0.0;\n if (!toi || (bodyA === toiA || bodyA === toiB)) {\n mA = this.p_invMassA;\n iA = this.p_invIA;\n }\n\n let mB = 0.0;\n let iB = 0.0;\n if (!toi || (bodyB === toiA || bodyB === toiB)) {\n mB = this.p_invMassB;\n iB = this.p_invIB;\n }\n\n matrix.copyVec2(cA, positionA.c);\n let aA = positionA.a;\n\n matrix.copyVec2(cB, positionB.c);\n let aB = positionB.a;\n\n // Solve normal constraints\n for (let j = 0; j < this.p_pointCount; ++j) {\n getTransform(xfA, localCenterA, cA, aA);\n getTransform(xfB, localCenterB, cB, aB);\n\n // PositionSolverManifold\n let separation: number;\n switch (this.p_type) {\n case ManifoldType.e_circles: {\n matrix.transformVec2(pointA, xfA, this.p_localPoint);\n matrix.transformVec2(pointB, xfB, this.p_localPoints[0]);\n matrix.subVec2(normal, pointB, pointA);\n matrix.normalizeVec2(normal);\n\n matrix.combine2Vec2(point, 0.5, pointA, 0.5, pointB);\n separation = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal) - this.p_radiusA - this.p_radiusB;\n break;\n }\n\n case ManifoldType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.p_localNormal);\n matrix.transformVec2(planePoint, xfA, this.p_localPoint);\n matrix.transformVec2(clipPoint, xfB, this.p_localPoints[j]);\n separation = matrix.dotVec2(clipPoint, normal) - matrix.dotVec2(planePoint, normal) - this.p_radiusA - this.p_radiusB;\n matrix.copyVec2(point, clipPoint);\n break;\n }\n\n case ManifoldType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.p_localNormal);\n matrix.transformVec2(planePoint, xfB, this.p_localPoint);\n matrix.transformVec2(clipPoint, xfA, this.p_localPoints[j]);\n separation = matrix.dotVec2(clipPoint, normal) - matrix.dotVec2(planePoint, normal) - this.p_radiusA - this.p_radiusB;\n matrix.copyVec2(point, clipPoint);\n\n // Ensure normal points from A to B\n matrix.negVec2(normal);\n break;\n }\n // todo: what should we do here?\n default: {\n return minSeparation;\n }\n }\n\n matrix.subVec2(rA, point, cA);\n matrix.subVec2(rB, point, cB);\n\n // Track max constraint error.\n minSeparation = math_min(minSeparation, separation);\n\n const baumgarte = toi ? Settings.toiBaugarte : Settings.baumgarte;\n const linearSlop = Settings.linearSlop;\n const maxLinearCorrection = Settings.maxLinearCorrection;\n\n // Prevent large corrections and allow slop.\n const C = clamp(baumgarte * (separation + linearSlop), -maxLinearCorrection, 0.0);\n\n // Compute the effective mass.\n const rnA = matrix.crossVec2Vec2(rA, normal);\n const rnB = matrix.crossVec2Vec2(rB, normal);\n const K = mA + mB + iA * rnA * rnA + iB * rnB * rnB;\n\n // Compute normal impulse\n const impulse = K > 0.0 ? -C / K : 0.0;\n\n matrix.scaleVec2(P, impulse, normal);\n\n matrix.minusScaleVec2(cA, mA, P);\n aA -= iA * matrix.crossVec2Vec2(rA, P);\n\n matrix.plusScaleVec2(cB, mB, P);\n aB += iB * matrix.crossVec2Vec2(rB, P);\n }\n\n matrix.copyVec2(positionA.c, cA);\n positionA.a = aA;\n\n matrix.copyVec2(positionB.c, cB);\n positionB.a = aB;\n\n return minSeparation;\n }\n\n initVelocityConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const radiusA = this.p_radiusA;\n const radiusB = this.p_radiusB;\n const manifold = this.m_manifold;\n\n const mA = this.v_invMassA;\n const mB = this.v_invMassB;\n const iA = this.v_invIA;\n const iB = this.v_invIB;\n const localCenterA = this.p_localCenterA;\n const localCenterB = this.p_localCenterB;\n\n matrix.copyVec2(cA, positionA.c);\n const aA = positionA.a;\n matrix.copyVec2(vA, velocityA.v);\n const wA = velocityA.w;\n\n matrix.copyVec2(cB, positionB.c);\n const aB = positionB.a;\n matrix.copyVec2(vB, velocityB.v);\n const wB = velocityB.w;\n\n if (_ASSERT) console.assert(manifold.pointCount > 0);\n\n getTransform(xfA, localCenterA, cA, aA);\n getTransform(xfB, localCenterB, cB, aB);\n\n worldManifold.recycle();\n manifold.getWorldManifold(worldManifold, xfA, radiusA, xfB, radiusB);\n\n matrix.copyVec2(this.v_normal, worldManifold.normal);\n\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n const wmp = worldManifold.points[j];\n\n matrix.subVec2(vcp.rA, wmp, cA);\n matrix.subVec2(vcp.rB, wmp, cB);\n\n const rnA = matrix.crossVec2Vec2(vcp.rA, this.v_normal);\n const rnB = matrix.crossVec2Vec2(vcp.rB, this.v_normal);\n\n const kNormal = mA + mB + iA * rnA * rnA + iB * rnB * rnB;\n\n vcp.normalMass = kNormal > 0.0 ? 1.0 / kNormal : 0.0;\n\n matrix.crossVec2Num(tangent, this.v_normal, 1.0);\n\n const rtA = matrix.crossVec2Vec2(vcp.rA, tangent);\n const rtB = matrix.crossVec2Vec2(vcp.rB, tangent);\n\n const kTangent = mA + mB + iA * rtA * rtA + iB * rtB * rtB;\n\n vcp.tangentMass = kTangent > 0.0 ? 1.0 / kTangent : 0.0;\n\n // Setup a velocity bias for restitution.\n vcp.velocityBias = 0.0;\n let vRel = 0;\n vRel += matrix.dotVec2(this.v_normal, vB);\n vRel += matrix.dotVec2(this.v_normal, matrix.crossNumVec2(temp, wB, vcp.rB));\n vRel -= matrix.dotVec2(this.v_normal, vA);\n vRel -= matrix.dotVec2(this.v_normal, matrix.crossNumVec2(temp, wA, vcp.rA));\n if (vRel < -Settings.velocityThreshold) {\n vcp.velocityBias = -this.v_restitution * vRel;\n }\n }\n\n // If we have two points, then prepare the block solver.\n if (this.v_pointCount == 2 && step.blockSolve) {\n const vcp1 = this.v_points[0]; // VelocityConstraintPoint\n const vcp2 = this.v_points[1]; // VelocityConstraintPoint\n\n const rn1A = matrix.crossVec2Vec2(vcp1.rA, this.v_normal);\n const rn1B = matrix.crossVec2Vec2(vcp1.rB, this.v_normal);\n const rn2A = matrix.crossVec2Vec2(vcp2.rA, this.v_normal);\n const rn2B = matrix.crossVec2Vec2(vcp2.rB, this.v_normal);\n\n const k11 = mA + mB + iA * rn1A * rn1A + iB * rn1B * rn1B;\n const k22 = mA + mB + iA * rn2A * rn2A + iB * rn2B * rn2B;\n const k12 = mA + mB + iA * rn1A * rn2A + iB * rn1B * rn2B;\n\n // Ensure a reasonable condition number.\n const k_maxConditionNumber = 1000.0;\n if (k11 * k11 < k_maxConditionNumber * (k11 * k22 - k12 * k12)) {\n // K is safe to invert.\n this.v_K.ex.setNum(k11, k12);\n this.v_K.ey.setNum(k12, k22);\n // this.v_normalMass.set(this.v_K.getInverse());\n const a = this.v_K.ex.x;\n const b = this.v_K.ey.x;\n const c = this.v_K.ex.y;\n const d = this.v_K.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n this.v_normalMass.ex.x = det * d;\n this.v_normalMass.ey.x = -det * b;\n this.v_normalMass.ex.y = -det * c;\n this.v_normalMass.ey.y = det * a;\n\n } else {\n // The constraints are redundant, just use one.\n // TODO_ERIN use deepest?\n this.v_pointCount = 1;\n }\n }\n\n matrix.copyVec2(positionA.c, cA);\n positionA.a = aA;\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n\n matrix.copyVec2(positionB.c, cB);\n positionB.a = aB;\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n warmStartConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const mA = this.v_invMassA;\n const iA = this.v_invIA;\n const mB = this.v_invMassB;\n const iB = this.v_invIB;\n\n matrix.copyVec2(vA, velocityA.v);\n let wA = velocityA.w;\n matrix.copyVec2(vB, velocityB.v);\n let wB = velocityB.w;\n\n matrix.copyVec2(normal, this.v_normal);\n matrix.crossVec2Num(tangent, normal, 1.0);\n\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n\n matrix.combine2Vec2(P, vcp.normalImpulse, normal, vcp.tangentImpulse, tangent);\n\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n matrix.minusScaleVec2(vA, mA, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n matrix.plusScaleVec2(vB, mB, P);\n }\n\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n storeConstraintImpulses(step: TimeStep): void {\n const manifold = this.m_manifold;\n for (let j = 0; j < this.v_pointCount; ++j) {\n manifold.points[j].normalImpulse = this.v_points[j].normalImpulse;\n manifold.points[j].tangentImpulse = this.v_points[j].tangentImpulse;\n }\n }\n\n solveVelocityConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const positionA = bodyA.c_position;\n\n const velocityB = bodyB.c_velocity;\n const positionB = bodyB.c_position;\n\n const mA = this.v_invMassA;\n const iA = this.v_invIA;\n const mB = this.v_invMassB;\n const iB = this.v_invIB;\n\n matrix.copyVec2(vA, velocityA.v);\n let wA = velocityA.w;\n matrix.copyVec2(vB, velocityB.v);\n let wB = velocityB.w;\n\n matrix.copyVec2(normal, this.v_normal);\n matrix.crossVec2Num(tangent, normal, 1.0);\n const friction = this.v_friction;\n\n if (_ASSERT) console.assert(this.v_pointCount == 1 || this.v_pointCount == 2);\n\n // Solve tangent constraints first because non-penetration is more important\n // than friction.\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n\n // Relative velocity at contact\n matrix.zeroVec2(dv);\n matrix.plusVec2(dv, vB);\n matrix.plusVec2(dv, matrix.crossNumVec2(temp, wB, vcp.rB));\n matrix.minusVec2(dv, vA);\n matrix.minusVec2(dv, matrix.crossNumVec2(temp, wA, vcp.rA));\n\n // Compute tangent force\n const vt = matrix.dotVec2(dv, tangent) - this.v_tangentSpeed;\n let lambda = vcp.tangentMass * (-vt);\n\n // Clamp the accumulated force\n const maxFriction = friction * vcp.normalImpulse;\n const newImpulse = clamp(vcp.tangentImpulse + lambda, -maxFriction, maxFriction);\n lambda = newImpulse - vcp.tangentImpulse;\n vcp.tangentImpulse = newImpulse;\n\n // Apply contact impulse\n matrix.scaleVec2(P, lambda, tangent);\n\n matrix.minusScaleVec2(vA, mA, P);\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n\n matrix.plusScaleVec2(vB, mB, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n }\n\n // Solve normal constraints\n if (this.v_pointCount == 1 || step.blockSolve == false) {\n for (let i = 0; i < this.v_pointCount; ++i) {\n const vcp = this.v_points[i]; // VelocityConstraintPoint\n\n // Relative velocity at contact\n matrix.zeroVec2(dv);\n matrix.plusVec2(dv, vB);\n matrix.plusVec2(dv, matrix.crossNumVec2(temp, wB, vcp.rB));\n matrix.minusVec2(dv, vA);\n matrix.minusVec2(dv, matrix.crossNumVec2(temp, wA, vcp.rA));\n\n // Compute normal impulse\n const vn = matrix.dotVec2(dv, normal);\n let lambda = -vcp.normalMass * (vn - vcp.velocityBias);\n\n // Clamp the accumulated impulse\n const newImpulse = math_max(vcp.normalImpulse + lambda, 0.0);\n lambda = newImpulse - vcp.normalImpulse;\n vcp.normalImpulse = newImpulse;\n\n // Apply contact impulse\n matrix.scaleVec2(P, lambda, normal);\n\n matrix.minusScaleVec2(vA, mA, P);\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n\n matrix.plusScaleVec2(vB, mB, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n }\n } else {\n // Block solver developed in collaboration with Dirk Gregorius (back in\n // 01/07 on Box2D_Lite).\n // Build the mini LCP for this contact patch\n //\n // vn = A * x + b, vn >= 0, x >= 0 and vn_i * x_i = 0 with i = 1..2\n //\n // A = J * W * JT and J = ( -n, -r1 x n, n, r2 x n )\n // b = vn0 - velocityBias\n //\n // The system is solved using the \"Total enumeration method\" (s. Murty).\n // The complementary constraint vn_i * x_i\n // implies that we must have in any solution either vn_i = 0 or x_i = 0.\n // So for the 2D contact problem the cases\n // vn1 = 0 and vn2 = 0, x1 = 0 and x2 = 0, x1 = 0 and vn2 = 0, x2 = 0 and\n // vn1 = 0 need to be tested. The first valid\n // solution that satisfies the problem is chosen.\n //\n // In order to account of the accumulated impulse 'a' (because of the\n // iterative nature of the solver which only requires\n // that the accumulated impulse is clamped and not the incremental\n // impulse) we change the impulse variable (x_i).\n //\n // Substitute:\n //\n // x = a + d\n //\n // a := old total impulse\n // x := new total impulse\n // d := incremental impulse\n //\n // For the current iteration we extend the formula for the incremental\n // impulse\n // to compute the new total impulse:\n //\n // vn = A * d + b\n // = A * (x - a) + b\n // = A * x + b - A * a\n // = A * x + b'\n // b' = b - A * a;\n\n const vcp1 = this.v_points[0]; // VelocityConstraintPoint\n const vcp2 = this.v_points[1]; // VelocityConstraintPoint\n\n matrix.setVec2(a, vcp1.normalImpulse, vcp2.normalImpulse);\n if (_ASSERT) console.assert(a.x >= 0.0 && a.y >= 0.0);\n\n // Relative velocity at contact\n // let dv1 = Vec2.zero().add(vB).add(Vec2.crossNumVec2(wB, vcp1.rB)).sub(vA).sub(Vec2.crossNumVec2(wA, vcp1.rA));\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n // let dv2 = Vec2.zero().add(vB).add(Vec2.crossNumVec2(wB, vcp2.rB)).sub(vA).sub(Vec2.crossNumVec2(wA, vcp2.rA));\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n let vn1 = matrix.dotVec2(dv1, normal);\n let vn2 = matrix.dotVec2(dv2, normal);\n\n matrix.setVec2(b, vn1 - vcp1.velocityBias, vn2 - vcp2.velocityBias);\n\n // Compute b'\n // b.sub(Mat22.mulVec2(this.v_K, a));\n b.x -= this.v_K.ex.x * a.x + this.v_K.ey.x * a.y;\n b.y -= this.v_K.ex.y * a.x + this.v_K.ey.y * a.y;\n\n const k_errorTol = 1e-3;\n // NOT_USED(k_errorTol);\n\n while (true) {\n //\n // Case 1: vn = 0\n //\n // 0 = A * x + b'\n //\n // Solve for x:\n //\n // x = - inv(A) * b'\n //\n // const x = Mat22.mulVec2(this.v_normalMass, b).neg();\n matrix.zeroVec2(x);\n x.x = -(this.v_normalMass.ex.x * b.x + this.v_normalMass.ey.x * b.y);\n x.y = -(this.v_normalMass.ex.y * b.x + this.v_normalMass.ey.y * b.y);\n\n if (x.x >= 0.0 && x.y >= 0.0) {\n // Get the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n vn1 = matrix.dotVec2(dv1, normal);\n vn2 = matrix.dotVec2(dv2, normal);\n\n if (_ASSERT) console.assert(math_abs(vn1 - vcp1.velocityBias) < k_errorTol);\n if (_ASSERT) console.assert(math_abs(vn2 - vcp2.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 2: vn1 = 0 and x2 = 0\n //\n // 0 = a11 * x1 + a12 * 0 + b1'\n // vn2 = a21 * x1 + a22 * 0 + b2'\n //\n x.x = -vcp1.normalMass * b.x;\n x.y = 0.0;\n vn1 = 0.0;\n vn2 = this.v_K.ex.y * x.x + b.y;\n\n if (x.x >= 0.0 && vn2 >= 0.0) {\n // Get the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n // Compute normal velocity\n vn1 = matrix.dotVec2(dv1, normal);\n\n if (_ASSERT) console.assert(math_abs(vn1 - vcp1.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 3: vn2 = 0 and x1 = 0\n //\n // vn1 = a11 * 0 + a12 * x2 + b1'\n // 0 = a21 * 0 + a22 * x2 + b2'\n //\n x.x = 0.0;\n x.y = -vcp2.normalMass * b.y;\n vn1 = this.v_K.ey.x * x.y + b.x;\n vn2 = 0.0;\n\n if (x.y >= 0.0 && vn1 >= 0.0) {\n // Resubstitute for the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n vn2 = matrix.dotVec2(dv2, normal);\n\n if (_ASSERT) console.assert(math_abs(vn2 - vcp2.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 4: x1 = 0 and x2 = 0\n //\n // vn1 = b1\n // vn2 = b2;\n //\n x.x = 0.0;\n x.y = 0.0;\n vn1 = b.x;\n vn2 = b.y;\n\n if (vn1 >= 0.0 && vn2 >= 0.0) {\n // Resubstitute for the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n break;\n }\n\n // No solution, give up. This is hit sometimes, but it doesn't seem to\n // matter.\n break;\n }\n }\n\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n /** @internal */\n static addType(type1: ShapeType, type2: ShapeType, callback: EvaluateFunction): void {\n s_registers[type1] = s_registers[type1] || {};\n s_registers[type1][type2] = callback;\n }\n\n /** @internal */\n static create(fixtureA: Fixture, indexA: number, fixtureB: Fixture, indexB: number): Contact | null {\n const typeA = fixtureA.m_shape.m_type;\n const typeB = fixtureB.m_shape.m_type;\n\n const contact = contactPool.allocate();\n let evaluateFcn;\n if (evaluateFcn = s_registers[typeA] && s_registers[typeA][typeB]) {\n contact.initialize(fixtureA, indexA, fixtureB, indexB, evaluateFcn);\n } else if (evaluateFcn = s_registers[typeB] && s_registers[typeB][typeA]) {\n contact.initialize(fixtureB, indexB, fixtureA, indexA, evaluateFcn);\n } else {\n return null;\n }\n\n // Contact creation may swap fixtures.\n fixtureA = contact.m_fixtureA;\n fixtureB = contact.m_fixtureB;\n indexA = contact.getChildIndexA();\n indexB = contact.getChildIndexB();\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n\n // Connect to body A\n contact.m_nodeA.contact = contact;\n contact.m_nodeA.other = bodyB;\n\n contact.m_nodeA.prev = null;\n contact.m_nodeA.next = bodyA.m_contactList;\n if (bodyA.m_contactList != null) {\n bodyA.m_contactList.prev = contact.m_nodeA;\n }\n bodyA.m_contactList = contact.m_nodeA;\n\n // Connect to body B\n contact.m_nodeB.contact = contact;\n contact.m_nodeB.other = bodyA;\n\n contact.m_nodeB.prev = null;\n contact.m_nodeB.next = bodyB.m_contactList;\n if (bodyB.m_contactList != null) {\n bodyB.m_contactList.prev = contact.m_nodeB;\n }\n bodyB.m_contactList = contact.m_nodeB;\n\n // Wake up the bodies\n if (fixtureA.isSensor() == false && fixtureB.isSensor() == false) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n\n return contact;\n }\n\n /** @internal */\n static destroy(contact: Contact, listener: { endContact: (contact: Contact) => void }): void {\n const fixtureA = contact.m_fixtureA;\n const fixtureB = contact.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n if (contact.isTouching()) {\n listener.endContact(contact);\n }\n\n // Remove from body 1\n if (contact.m_nodeA.prev) {\n contact.m_nodeA.prev.next = contact.m_nodeA.next;\n }\n\n if (contact.m_nodeA.next) {\n contact.m_nodeA.next.prev = contact.m_nodeA.prev;\n }\n\n if (contact.m_nodeA == bodyA.m_contactList) {\n bodyA.m_contactList = contact.m_nodeA.next;\n }\n\n // Remove from body 2\n if (contact.m_nodeB.prev) {\n contact.m_nodeB.prev.next = contact.m_nodeB.next;\n }\n\n if (contact.m_nodeB.next) {\n contact.m_nodeB.next.prev = contact.m_nodeB.prev;\n }\n\n if (contact.m_nodeB == bodyB.m_contactList) {\n bodyB.m_contactList = contact.m_nodeB.next;\n }\n\n if (contact.m_manifold.pointCount > 0 && !fixtureA.m_isSensor && !fixtureB.m_isSensor) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n\n // const typeA = fixtureA.getType();\n // const typeB = fixtureB.getType();\n\n // const destroyFcn = s_registers[typeA][typeB].destroyFcn;\n // if (typeof destroyFcn === 'function') {\n // destroyFcn(contact);\n // }\n\n contactPool.release(contact);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../util/options\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { BroadPhase } from \"../collision/BroadPhase\";\nimport { Solver, ContactImpulse, TimeStep } from \"./Solver\";\nimport { Body, BodyDef } from \"./Body\";\nimport { Joint } from \"./Joint\";\nimport { Contact } from \"./Contact\";\nimport { AABBValue, RayCastInput, RayCastOutput } from \"../collision/AABB\";\nimport { Fixture, FixtureProxy } from \"./Fixture\";\nimport { Manifold } from \"../collision/Manifold\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\nexport interface WorldDef {\n /** [default: { x : 0, y : 0}] */\n gravity?: Vec2Value;\n\n /** [default: true] */\n allowSleep?: boolean;\n\n /** [default: true] */\n warmStarting?: boolean;\n\n /** [default: true] */\n continuousPhysics?: boolean;\n\n /** [default: false] */\n subStepping?: boolean;\n\n /** [default: true] */\n blockSolve?: boolean;\n\n /** @internal [8] For the velocity constraint solver. */\n velocityIterations?: number;\n\n /** @internal [3] For the position constraint solver. */\n positionIterations?: number;\n}\n\n/** @internal */ const DEFAULTS: WorldDef = {\n gravity : Vec2.zero(),\n allowSleep : true,\n warmStarting : true,\n continuousPhysics : true,\n subStepping : false,\n blockSolve : true,\n velocityIterations : 8,\n positionIterations : 3\n};\n\n/**\n * Callback function for ray casts, see {@link World.rayCast}.\n *\n * Called for each fixture found in the query.\n * The returned value replaces the ray-cast input maxFraction.\n * You control how the ray cast proceeds by returning a numeric/float value.\n * \n * - `0` to terminate the ray cast\n * - `fraction` to clip the ray cast at current point\n * - `1` don't clip the ray and continue\n * - `-1` (or anything else) to continue\n *\n * @param fixture The fixture hit by the ray\n * @param point The point of initial intersection\n * @param normal The normal vector at the point of intersection\n * @param fraction The fraction along the ray at the point of intersection\n *\n * @returns A number to update the maxFraction\n */\nexport type WorldRayCastCallback = (fixture: Fixture, point: Vec2, normal: Vec2, fraction: number) => number;\n\n/**\n * Called for each fixture found in the query AABB. It may return `false` to terminate the query.\n */\nexport type WorldAABBQueryCallback = (fixture: Fixture) => boolean;\n\ndeclare module \"./World\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(deg: WorldDef): World;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(gravity: Vec2): World;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(): World;\n}\n\n/**\n * The `World` class contains the bodies and joints. It manages all aspects\n * of the simulation and allows for asynchronous queries (like AABB queries\n * and ray-casts). Much of your interactions with Planck.js will be with a\n * World object.\n */\n// @ts-expect-error\nexport class World {\n /** @internal */ m_solver: Solver;\n /** @internal */ m_broadPhase: BroadPhase;\n /** @internal */ m_contactList: Contact | null;\n /** @internal */ m_contactCount: number;\n /** @internal */ m_bodyList: Body | null;\n /** @internal */ m_bodyCount: number;\n /** @internal */ m_jointList: Joint | null;\n /** @internal */ m_jointCount: number;\n /** @internal */ m_stepComplete: boolean;\n /** @internal */ m_allowSleep: boolean;\n /** @internal */ m_gravity: Vec2;\n /** @internal */ m_clearForces: boolean;\n /** @internal */ m_newFixture: boolean;\n /** @internal */ m_locked: boolean;\n /** @internal */ m_warmStarting: boolean;\n /** @internal */ m_continuousPhysics: boolean;\n /** @internal */ m_subStepping: boolean;\n /** @internal */ m_blockSolve: boolean;\n /** @internal */ m_velocityIterations: number;\n /** @internal */ m_positionIterations: number;\n /** @internal */ m_t: number;\n\n // TODO\n /** @internal */ _listeners: {\n [key: string]: any[]\n };\n\n /**\n * @param def World definition or gravity vector.\n */\n constructor(def?: WorldDef | Vec2Value) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof World)) {\n return new World(def);\n }\n\n this.s_step = new TimeStep();\n\n\n if (!def) {\n def = {};\n } else if (Vec2.isValid(def)) {\n def = { gravity: def as Vec2 };\n }\n\n def = options(def, DEFAULTS) as WorldDef;\n\n this.m_solver = new Solver(this);\n\n this.m_broadPhase = new BroadPhase();\n\n this.m_contactList = null;\n this.m_contactCount = 0;\n\n this.m_bodyList = null;\n this.m_bodyCount = 0;\n\n this.m_jointList = null;\n this.m_jointCount = 0;\n\n this.m_stepComplete = true;\n\n this.m_allowSleep = def.allowSleep;\n this.m_gravity = Vec2.clone(def.gravity);\n\n this.m_clearForces = true;\n this.m_newFixture = false;\n this.m_locked = false;\n\n // These are for debugging the solver.\n this.m_warmStarting = def.warmStarting;\n this.m_continuousPhysics = def.continuousPhysics;\n this.m_subStepping = def.subStepping;\n\n this.m_blockSolve = def.blockSolve;\n this.m_velocityIterations = def.velocityIterations;\n this.m_positionIterations = def.positionIterations;\n\n this.m_t = 0;\n }\n\n /** @internal */\n _serialize(): object {\n const bodies = [];\n const joints = [];\n\n for (let b = this.getBodyList(); b; b = b.getNext()) {\n bodies.push(b);\n }\n\n for (let j = this.getJointList(); j; j = j.getNext()) {\n // @ts-ignore\n if (typeof j._serialize === \"function\") {\n joints.push(j);\n }\n }\n\n return {\n gravity: this.m_gravity,\n bodies,\n joints,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, context: any, restore: any): World {\n if (!data) {\n return new World();\n }\n\n const world = new World(data.gravity);\n\n if (data.bodies) {\n for (let i = data.bodies.length - 1; i >= 0; i -= 1) {\n world._addBody(restore(Body, data.bodies[i], world));\n }\n }\n\n if (data.joints) {\n for (let i = data.joints.length - 1; i >= 0; i--) {\n world.createJoint(restore(Joint, data.joints[i], world));\n }\n }\n\n return world;\n }\n\n /**\n * Get the world body list. With the returned body, use Body.getNext to get the\n * next body in the world list. A null body indicates the end of the list.\n *\n * @return the head of the world body list.\n */\n getBodyList(): Body | null {\n return this.m_bodyList;\n }\n\n /**\n * Get the world joint list. With the returned joint, use Joint.getNext to get\n * the next joint in the world list. A null joint indicates the end of the list.\n *\n * @return the head of the world joint list.\n */\n getJointList(): Joint | null {\n return this.m_jointList;\n }\n\n /**\n * Get the world contact list. With the returned contact, use Contact.getNext to\n * get the next contact in the world list. A null contact indicates the end of\n * the list.\n *\n * Warning: contacts are created and destroyed in the middle of a time step.\n * Use ContactListener to avoid missing contacts.\n *\n * @return the head of the world contact list.\n */\n getContactList(): Contact | null {\n return this.m_contactList;\n }\n\n getBodyCount(): number {\n return this.m_bodyCount;\n }\n\n getJointCount(): number {\n return this.m_jointCount;\n }\n\n /**\n * Get the number of contacts (each may have 0 or more contact points).\n */\n getContactCount(): number {\n return this.m_contactCount;\n }\n\n /**\n * Change the global gravity vector.\n */\n setGravity(gravity: Vec2Value): void {\n this.m_gravity.set(gravity);\n }\n\n /**\n * Get the global gravity vector.\n */\n getGravity(): Vec2 {\n return this.m_gravity;\n }\n\n /**\n * Is the world locked (in the middle of a time step).\n */\n isLocked(): boolean {\n return this.m_locked;\n }\n\n /**\n * Enable/disable sleep.\n */\n setAllowSleeping(flag: boolean): void {\n if (flag == this.m_allowSleep) {\n return;\n }\n\n this.m_allowSleep = flag;\n if (this.m_allowSleep == false) {\n for (let b = this.m_bodyList; b; b = b.m_next) {\n b.setAwake(true);\n }\n }\n }\n\n getAllowSleeping(): boolean {\n return this.m_allowSleep;\n }\n\n /**\n * Enable/disable warm starting. For testing.\n */\n setWarmStarting(flag: boolean): void {\n this.m_warmStarting = flag;\n }\n\n getWarmStarting(): boolean {\n return this.m_warmStarting;\n }\n\n /**\n * Enable/disable continuous physics. For testing.\n */\n setContinuousPhysics(flag: boolean): void {\n this.m_continuousPhysics = flag;\n }\n\n getContinuousPhysics(): boolean {\n return this.m_continuousPhysics;\n }\n\n /**\n * Enable/disable single stepped continuous physics. For testing.\n */\n setSubStepping(flag: boolean): void {\n this.m_subStepping = flag;\n }\n\n getSubStepping(): boolean {\n return this.m_subStepping;\n }\n\n /**\n * Set flag to control automatic clearing of forces after each time step.\n */\n setAutoClearForces(flag: boolean): void {\n this.m_clearForces = flag;\n }\n\n /**\n * Get the flag that controls automatic clearing of forces after each time step.\n */\n getAutoClearForces(): boolean {\n return this.m_clearForces;\n }\n\n /**\n * Manually clear the force buffer on all bodies. By default, forces are cleared\n * automatically after each call to step. The default behavior is modified by\n * calling setAutoClearForces. The purpose of this function is to support\n * sub-stepping. Sub-stepping is often used to maintain a fixed sized time step\n * under a variable frame-rate. When you perform sub-stepping you will disable\n * auto clearing of forces and instead call clearForces after all sub-steps are\n * complete in one pass of your game loop.\n *\n * See {@link World.setAutoClearForces}\n */\n clearForces(): void {\n for (let body = this.m_bodyList; body; body = body.getNext()) {\n body.m_force.setZero();\n body.m_torque = 0.0;\n }\n }\n\n /**\n * Query the world for all fixtures that potentially overlap the provided AABB.\n *\n * @param aabb The query box.\n * @param callback Called for each fixture found in the query AABB. It may return `false` to terminate the query.\n */\n queryAABB(aabb: AABBValue, callback: WorldAABBQueryCallback): void {\n if (_ASSERT) console.assert(typeof callback === \"function\");\n const broadPhase = this.m_broadPhase;\n this.m_broadPhase.query(aabb, function(proxyId: number): boolean { // TODO GC\n const proxy = broadPhase.getUserData(proxyId);\n return callback(proxy.fixture);\n });\n }\n\n /**\n * Ray-cast the world for all fixtures in the path of the ray. Your callback\n * controls whether you get the closest point, any point, or n-points. The\n * ray-cast ignores shapes that contain the starting point.\n *\n * @param point1 The ray starting point\n * @param point2 The ray ending point\n * @param callback A function that is called for each fixture that is hit by the ray. You control how the ray cast proceeds by returning a numeric/float value.\n */\n rayCast(point1: Vec2Value, point2: Vec2Value, callback: WorldRayCastCallback): void {\n if (_ASSERT) console.assert(typeof callback === \"function\");\n const broadPhase = this.m_broadPhase;\n\n this.m_broadPhase.rayCast({\n maxFraction : 1.0,\n p1 : point1,\n p2 : point2\n }, function(input: RayCastInput, proxyId: number): number { // TODO GC\n const proxy = broadPhase.getUserData(proxyId);\n const fixture = proxy.fixture;\n const index = proxy.childIndex;\n // @ts-ignore\n const output: RayCastOutput = {}; // TODO GC\n const hit = fixture.rayCast(output, input, index);\n if (hit) {\n const fraction = output.fraction;\n const point = Vec2.add(Vec2.mulNumVec2((1.0 - fraction), input.p1), Vec2.mulNumVec2(fraction, input.p2));\n return callback(fixture, point, output.normal, fraction);\n }\n return input.maxFraction;\n });\n }\n\n /**\n * Get the number of broad-phase proxies.\n */\n getProxyCount(): number {\n return this.m_broadPhase.getProxyCount();\n }\n\n /**\n * Get the height of broad-phase dynamic tree.\n */\n getTreeHeight(): number {\n return this.m_broadPhase.getTreeHeight();\n }\n\n /**\n * Get the balance of broad-phase dynamic tree.\n */\n getTreeBalance(): number {\n return this.m_broadPhase.getTreeBalance();\n }\n\n /**\n * Get the quality metric of broad-phase dynamic tree. The smaller the better.\n * The minimum is 1.\n */\n getTreeQuality(): number {\n return this.m_broadPhase.getTreeQuality();\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The body shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n if (_ASSERT) console.assert(this.m_locked == false);\n if (this.m_locked) {\n return;\n }\n\n for (let b = this.m_bodyList; b; b = b.m_next) {\n b.m_xf.p.sub(newOrigin);\n b.m_sweep.c0.sub(newOrigin);\n b.m_sweep.c.sub(newOrigin);\n }\n\n for (let j = this.m_jointList; j; j = j.m_next) {\n j.shiftOrigin(newOrigin);\n }\n\n this.m_broadPhase.shiftOrigin(newOrigin);\n }\n\n /** @internal Used for deserialize. */\n _addBody(body: Body): void {\n if (_ASSERT) console.assert(this.isLocked() === false);\n if (this.isLocked()) {\n return;\n }\n\n // Add to world doubly linked list.\n body.m_prev = null;\n body.m_next = this.m_bodyList;\n if (this.m_bodyList) {\n this.m_bodyList.m_prev = body;\n }\n this.m_bodyList = body;\n ++this.m_bodyCount;\n }\n\n /**\n * Create a rigid body given a definition. No reference to the definition is\n * retained.\n *\n * Warning: This function is locked during callbacks.\n */\n createBody(def?: BodyDef): Body;\n createBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createBody(arg1?, arg2?) {\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return null;\n }\n\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n\n const body = new Body(this, def);\n this._addBody(body);\n return body;\n }\n\n createDynamicBody(def?: BodyDef): Body;\n createDynamicBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createDynamicBody(arg1?, arg2?) {\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n def.type = \"dynamic\";\n return this.createBody(def);\n }\n\n createKinematicBody(def?: BodyDef): Body;\n createKinematicBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createKinematicBody(arg1?, arg2?) {\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n def.type = \"kinematic\";\n return this.createBody(def);\n }\n\n /**\n * Destroy a rigid body given a definition. No reference to the definition is\n * retained.\n *\n * Warning: This automatically deletes all associated shapes and joints.\n *\n * Warning: This function is locked during callbacks.\n */\n destroyBody(b: Body): boolean {\n if (_ASSERT) console.assert(this.m_bodyCount > 0);\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return;\n }\n\n if (b.m_destroyed) {\n return false;\n }\n\n // Delete the attached joints.\n let je = b.m_jointList;\n while (je) {\n const je0 = je;\n je = je.next;\n\n this.publish(\"remove-joint\", je0.joint);\n this.destroyJoint(je0.joint);\n\n b.m_jointList = je;\n }\n b.m_jointList = null;\n\n // Delete the attached contacts.\n let ce = b.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n\n this.destroyContact(ce0.contact);\n\n b.m_contactList = ce;\n }\n b.m_contactList = null;\n\n // Delete the attached fixtures. This destroys broad-phase proxies.\n let f = b.m_fixtureList;\n while (f) {\n const f0 = f;\n f = f.m_next;\n\n this.publish(\"remove-fixture\", f0);\n f0.destroyProxies(this.m_broadPhase);\n\n b.m_fixtureList = f;\n }\n b.m_fixtureList = null;\n\n // Remove world body list.\n if (b.m_prev) {\n b.m_prev.m_next = b.m_next;\n }\n\n if (b.m_next) {\n b.m_next.m_prev = b.m_prev;\n }\n\n if (b == this.m_bodyList) {\n this.m_bodyList = b.m_next;\n }\n\n b.m_destroyed = true;\n\n --this.m_bodyCount;\n\n this.publish(\"remove-body\", b);\n\n return true;\n }\n\n /**\n * Create a joint to constrain bodies together. No reference to the definition\n * is retained. This may cause the connected bodies to cease colliding.\n *\n * Warning: This function is locked during callbacks.\n */\n createJoint(joint: T): T | null {\n if (_ASSERT) console.assert(!!joint.m_bodyA);\n if (_ASSERT) console.assert(!!joint.m_bodyB);\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return null;\n }\n\n // Connect to the world list.\n joint.m_prev = null;\n joint.m_next = this.m_jointList;\n if (this.m_jointList) {\n this.m_jointList.m_prev = joint;\n }\n this.m_jointList = joint;\n ++this.m_jointCount;\n\n // Connect to the bodies' doubly linked lists.\n joint.m_edgeA.joint = joint;\n joint.m_edgeA.other = joint.m_bodyB;\n joint.m_edgeA.prev = null;\n joint.m_edgeA.next = joint.m_bodyA.m_jointList;\n if (joint.m_bodyA.m_jointList)\n joint.m_bodyA.m_jointList.prev = joint.m_edgeA;\n joint.m_bodyA.m_jointList = joint.m_edgeA;\n\n joint.m_edgeB.joint = joint;\n joint.m_edgeB.other = joint.m_bodyA;\n joint.m_edgeB.prev = null;\n joint.m_edgeB.next = joint.m_bodyB.m_jointList;\n if (joint.m_bodyB.m_jointList)\n joint.m_bodyB.m_jointList.prev = joint.m_edgeB;\n joint.m_bodyB.m_jointList = joint.m_edgeB;\n\n // If the joint prevents collisions, then flag any contacts for filtering.\n if (joint.m_collideConnected == false) {\n for (let edge = joint.m_bodyB.getContactList(); edge; edge = edge.next) {\n if (edge.other == joint.m_bodyA) {\n // Flag the contact for filtering at the next time step (where either\n // body is awake).\n edge.contact.flagForFiltering();\n }\n }\n }\n\n // Note: creating a joint doesn't wake the bodies.\n\n return joint;\n }\n\n /**\n * Destroy a joint. This may cause the connected bodies to begin colliding.\n * Warning: This function is locked during callbacks.\n */\n destroyJoint(joint: Joint): void {\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return;\n }\n\n // Remove from the doubly linked list.\n if (joint.m_prev) {\n joint.m_prev.m_next = joint.m_next;\n }\n\n if (joint.m_next) {\n joint.m_next.m_prev = joint.m_prev;\n }\n\n if (joint == this.m_jointList) {\n this.m_jointList = joint.m_next;\n }\n\n // Disconnect from bodies.\n const bodyA = joint.m_bodyA;\n const bodyB = joint.m_bodyB;\n\n // Wake up connected bodies.\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n\n // Remove from body 1.\n if (joint.m_edgeA.prev) {\n joint.m_edgeA.prev.next = joint.m_edgeA.next;\n }\n\n if (joint.m_edgeA.next) {\n joint.m_edgeA.next.prev = joint.m_edgeA.prev;\n }\n\n if (joint.m_edgeA == bodyA.m_jointList) {\n bodyA.m_jointList = joint.m_edgeA.next;\n }\n\n joint.m_edgeA.prev = null;\n joint.m_edgeA.next = null;\n\n // Remove from body 2\n if (joint.m_edgeB.prev) {\n joint.m_edgeB.prev.next = joint.m_edgeB.next;\n }\n\n if (joint.m_edgeB.next) {\n joint.m_edgeB.next.prev = joint.m_edgeB.prev;\n }\n\n if (joint.m_edgeB == bodyB.m_jointList) {\n bodyB.m_jointList = joint.m_edgeB.next;\n }\n\n joint.m_edgeB.prev = null;\n joint.m_edgeB.next = null;\n\n if (_ASSERT) console.assert(this.m_jointCount > 0);\n --this.m_jointCount;\n\n // If the joint prevents collisions, then flag any contacts for filtering.\n if (joint.m_collideConnected == false) {\n let edge = bodyB.getContactList();\n while (edge) {\n if (edge.other == bodyA) {\n // Flag the contact for filtering at the next time step (where either\n // body is awake).\n edge.contact.flagForFiltering();\n }\n\n edge = edge.next;\n }\n }\n\n this.publish(\"remove-joint\", joint);\n }\n\n /** @internal */\n s_step: TimeStep; // reuse\n\n /**\n * Take a time step. This performs collision detection, integration, and\n * constraint solution.\n *\n * Broad-phase, narrow-phase, solve and solve time of impacts.\n *\n * @param timeStep Time step, this should not vary.\n */\n step(timeStep: number, velocityIterations?: number, positionIterations?: number): void {\n this.publish(\"pre-step\", timeStep);\n\n if ((velocityIterations | 0) !== velocityIterations) {\n // TODO: remove this in future\n velocityIterations = 0;\n }\n\n velocityIterations = velocityIterations || this.m_velocityIterations;\n positionIterations = positionIterations || this.m_positionIterations;\n\n // If new fixtures were added, we need to find the new contacts.\n if (this.m_newFixture) {\n this.findNewContacts();\n this.m_newFixture = false;\n }\n\n this.m_locked = true;\n\n this.s_step.reset(timeStep);\n this.s_step.velocityIterations = velocityIterations;\n this.s_step.positionIterations = positionIterations;\n this.s_step.warmStarting = this.m_warmStarting;\n this.s_step.blockSolve = this.m_blockSolve;\n\n // Update contacts. This is where some contacts are destroyed.\n this.updateContacts();\n\n // Integrate velocities, solve velocity constraints, and integrate positions.\n if (this.m_stepComplete && timeStep > 0.0) {\n this.m_solver.solveWorld(this.s_step);\n\n // Synchronize fixtures, check for out of range bodies.\n for (let b = this.m_bodyList; b; b = b.getNext()) {\n // If a body was not in an island then it did not move.\n if (b.m_islandFlag == false) {\n continue;\n }\n\n if (b.isStatic()) {\n continue;\n }\n\n // Update fixtures (for broad-phase).\n b.synchronizeFixtures();\n }\n // Look for new contacts.\n this.findNewContacts();\n }\n\n // Handle TOI events.\n if (this.m_continuousPhysics && timeStep > 0.0) {\n this.m_solver.solveWorldTOI(this.s_step);\n }\n\n if (this.m_clearForces) {\n this.clearForces();\n }\n\n this.m_locked = false;\n\n this.publish(\"post-step\", timeStep);\n }\n\n /**\n * @internal\n * Call this method to find new contacts.\n */\n findNewContacts(): void {\n this.m_broadPhase.updatePairs(\n (proxyA: FixtureProxy, proxyB: FixtureProxy) => this.createContact(proxyA, proxyB)\n );\n }\n\n /**\n * @internal\n * Callback for broad-phase.\n */\n createContact(proxyA: FixtureProxy, proxyB: FixtureProxy): void {\n const fixtureA = proxyA.fixture;\n const fixtureB = proxyB.fixture;\n\n const indexA = proxyA.childIndex;\n const indexB = proxyB.childIndex;\n\n const bodyA = fixtureA.getBody();\n const bodyB = fixtureB.getBody();\n\n // Are the fixtures on the same body?\n if (bodyA == bodyB) {\n return;\n }\n\n // TODO_ERIN use a hash table to remove a potential bottleneck when both\n // bodies have a lot of contacts.\n // Does a contact already exist?\n let edge = bodyB.getContactList(); // ContactEdge\n while (edge) {\n if (edge.other == bodyA) {\n const fA = edge.contact.getFixtureA();\n const fB = edge.contact.getFixtureB();\n const iA = edge.contact.getChildIndexA();\n const iB = edge.contact.getChildIndexB();\n\n if (fA == fixtureA && fB == fixtureB && iA == indexA && iB == indexB) {\n // A contact already exists.\n return;\n }\n\n if (fA == fixtureB && fB == fixtureA && iA == indexB && iB == indexA) {\n // A contact already exists.\n return;\n }\n }\n\n edge = edge.next;\n }\n\n if (bodyB.shouldCollide(bodyA) == false) {\n return;\n }\n if (fixtureB.shouldCollide(fixtureA) == false) {\n return;\n }\n\n // Call the factory.\n const contact = Contact.create(fixtureA, indexA, fixtureB, indexB);\n if (contact == null) {\n return;\n }\n\n // Insert into the world.\n contact.m_prev = null;\n if (this.m_contactList != null) {\n contact.m_next = this.m_contactList;\n this.m_contactList.m_prev = contact;\n }\n this.m_contactList = contact;\n\n ++this.m_contactCount;\n }\n\n /**\n * @internal\n * Removes old non-overlapping contacts, applies filters and updates contacts.\n */\n updateContacts(): void {\n // Update awake contacts.\n let c: Contact;\n let next_c = this.m_contactList;\n while (c = next_c) {\n next_c = c.getNext();\n const fixtureA = c.getFixtureA();\n const fixtureB = c.getFixtureB();\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n const bodyA = fixtureA.getBody();\n const bodyB = fixtureB.getBody();\n\n // Is this contact flagged for filtering?\n if (c.m_filterFlag) {\n if (bodyB.shouldCollide(bodyA) == false) {\n this.destroyContact(c);\n continue;\n }\n\n if (fixtureB.shouldCollide(fixtureA) == false) {\n this.destroyContact(c);\n continue;\n }\n\n // Clear the filtering flag.\n c.m_filterFlag = false;\n }\n\n const activeA = bodyA.isAwake() && !bodyA.isStatic();\n const activeB = bodyB.isAwake() && !bodyB.isStatic();\n\n // At least one body must be awake and it must be dynamic or kinematic.\n if (activeA == false && activeB == false) {\n continue;\n }\n\n const proxyIdA = fixtureA.m_proxies[indexA].proxyId;\n const proxyIdB = fixtureB.m_proxies[indexB].proxyId;\n const overlap = this.m_broadPhase.testOverlap(proxyIdA, proxyIdB);\n\n // Here we destroy contacts that cease to overlap in the broad-phase.\n if (overlap == false) {\n this.destroyContact(c);\n continue;\n }\n\n // The contact persists.\n c.update(this);\n }\n }\n\n /** @internal */\n destroyContact(contact: Contact): void {\n // Remove from the world.\n if (contact.m_prev) {\n contact.m_prev.m_next = contact.m_next;\n }\n if (contact.m_next) {\n contact.m_next.m_prev = contact.m_prev;\n }\n if (contact == this.m_contactList) {\n this.m_contactList = contact.m_next;\n }\n\n Contact.destroy(contact, this);\n\n --this.m_contactCount;\n }\n\n\n /**\n * Called when two fixtures begin to touch.\n *\n * Implement contact callbacks to get contact information. You can use these\n * results for things like sounds and game logic. You can also get contact\n * results by traversing the contact lists after the time step. However, you\n * might miss some contacts because continuous physics leads to sub-stepping.\n * Additionally you may receive multiple callbacks for the same contact in a\n * single time step. You should strive to make your callbacks efficient because\n * there may be many callbacks per time step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"begin-contact\", listener: (contact: Contact) => void): World;\n /**\n * Called when two fixtures cease to touch.\n *\n * Implement contact callbacks to get contact information. You can use these\n * results for things like sounds and game logic. You can also get contact\n * results by traversing the contact lists after the time step. However, you\n * might miss some contacts because continuous physics leads to sub-stepping.\n * Additionally you may receive multiple callbacks for the same contact in a\n * single time step. You should strive to make your callbacks efficient because\n * there may be many callbacks per time step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"end-contact\", listener: (contact: Contact) => void): World;\n /**\n * This is called after a contact is updated. This allows you to inspect a\n * contact before it goes to the solver. If you are careful, you can modify the\n * contact manifold (e.g. disable contact). A copy of the old manifold is\n * provided so that you can detect changes. Note: this is called only for awake\n * bodies. Note: this is called even when the number of contact points is zero.\n * Note: this is not called for sensors. Note: if you set the number of contact\n * points to zero, you will not get an end-contact callback. However, you may get\n * a begin-contact callback the next step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"pre-solve\", listener: (contact: Contact, oldManifold: Manifold) => void): World;\n /**\n * This lets you inspect a contact after the solver is finished. This is useful\n * for inspecting impulses. Note: the contact manifold does not include time of\n * impact impulses, which can be arbitrarily large if the sub-step is small.\n * Hence the impulse is provided explicitly in a separate data structure. Note:\n * this is only called for contacts that are touching, solid, and awake.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"post-solve\", listener: (contact: Contact, impulse: ContactImpulse) => void): World;\n /** Listener is called whenever a body is removed. */\n on(name: \"remove-body\", listener: (body: Body) => void): World;\n /** Listener is called whenever a joint is removed implicitly or explicitly. */\n on(name: \"remove-joint\", listener: (joint: Joint) => void): World;\n /** Listener is called whenever a fixture is removed implicitly or explicitly. */\n on(name: \"remove-fixture\", listener: (fixture: Fixture) => void): World;\n /**\n * Register an event listener.\n */\n // tslint:disable-next-line:typedef\n on(name, listener) {\n if (typeof name !== \"string\" || typeof listener !== \"function\") {\n return this;\n }\n if (!this._listeners) {\n this._listeners = {};\n }\n if (!this._listeners[name]) {\n this._listeners[name] = [];\n }\n this._listeners[name].push(listener);\n return this;\n }\n\n off(name: \"begin-contact\", listener: (contact: Contact) => void): World;\n off(name: \"end-contact\", listener: (contact: Contact) => void): World;\n off(name: \"pre-solve\", listener: (contact: Contact, oldManifold: Manifold) => void): World;\n off(name: \"post-solve\", listener: (contact: Contact, impulse: ContactImpulse) => void): World;\n off(name: \"remove-body\", listener: (body: Body) => void): World;\n off(name: \"remove-joint\", listener: (joint: Joint) => void): World;\n off(name: \"remove-fixture\", listener: (fixture: Fixture) => void): World;\n /**\n * Remove an event listener.\n */\n // tslint:disable-next-line:typedef\n off(name, listener) {\n if (typeof name !== \"string\" || typeof listener !== \"function\") {\n return this;\n }\n const listeners = this._listeners && this._listeners[name];\n if (!listeners || !listeners.length) {\n return this;\n }\n const index = listeners.indexOf(listener);\n if (index >= 0) {\n listeners.splice(index, 1);\n }\n return this;\n }\n\n publish(name: string, arg1?: any, arg2?: any, arg3?: any): number {\n const listeners = this._listeners && this._listeners[name];\n if (!listeners || !listeners.length) {\n return 0;\n }\n for (let l = 0; l < listeners.length; l++) {\n listeners[l].call(this, arg1, arg2, arg3);\n }\n return listeners.length;\n }\n\n /** @internal */\n beginContact(contact: Contact): void {\n this.publish(\"begin-contact\", contact);\n }\n\n /** @internal */\n endContact(contact: Contact): void {\n this.publish(\"end-contact\", contact);\n }\n\n /** @internal */\n preSolve(contact: Contact, oldManifold: Manifold): void {\n this.publish(\"pre-solve\", contact, oldManifold);\n }\n\n /** @internal */\n postSolve(contact: Contact, impulse: ContactImpulse): void {\n this.publish(\"post-solve\", contact, impulse);\n }\n\n /**\n * Joints and fixtures are destroyed when their associated body is destroyed.\n * Register a destruction listener so that you may nullify references to these\n * joints and shapes.\n *\n * `function(object)` is called when any joint or fixture is about to\n * be destroyed due to the destruction of one of its attached or parent bodies.\n */\n\n /**\n * Register a contact filter to provide specific control over collision.\n * Otherwise the default filter is used (defaultFilter). The listener is owned\n * by you and must remain in scope.\n *\n * Moved to Fixture.\n */\n}","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/** 3D vector */\nexport interface Vec3Value {\n x: number;\n y: number;\n z: number;\n}\n\ndeclare module \"./Vec3\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(x: number, y: number, z: number): Vec3;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(obj: Vec3Value): Vec3;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(): Vec3;\n}\n\n/** 3D vector */\n// @ts-expect-error\nexport class Vec3 {\n x: number;\n y: number;\n z: number;\n\n constructor(x: number, y: number, z: number);\n constructor(obj: Vec3Value);\n constructor();\n constructor(x?, y?, z?) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Vec3)) {\n return new Vec3(x, y, z);\n }\n if (typeof x === \"undefined\") {\n this.x = 0;\n this.y = 0;\n this.z = 0;\n } else if (typeof x === \"object\") {\n this.x = x.x;\n this.y = x.y;\n this.z = x.z;\n } else {\n this.x = x;\n this.y = y;\n this.z = z;\n }\n if (_ASSERT) Vec3.assert(this);\n }\n\n /** @internal */\n _serialize(): object {\n return {\n x: this.x,\n y: this.y,\n z: this.z\n };\n }\n\n /** @internal */\n static _deserialize(data: any): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = data.x;\n obj.y = data.y;\n obj.z = data.z;\n return obj;\n }\n\n /** @hidden */\n static neo(x: number, y: number, z: number): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = x;\n obj.y = y;\n obj.z = z;\n return obj;\n }\n\n static zero(): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = 0;\n obj.y = 0;\n obj.z = 0;\n return obj;\n }\n\n static clone(v: Vec3Value): Vec3 {\n if (_ASSERT) Vec3.assert(v);\n return Vec3.neo(v.x, v.y, v.z);\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n /** Does this vector contain finite coordinates? */\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.x) && Number.isFinite(obj.y) && Number.isFinite(obj.z);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Vec3.isValid(o), \"Invalid Vec3!\", o);\n }\n\n setZero(): Vec3 {\n this.x = 0.0;\n this.y = 0.0;\n this.z = 0.0;\n return this;\n }\n\n set(x: number, y: number, z: number): Vec3 {\n this.x = x;\n this.y = y;\n this.z = z;\n return this;\n }\n\n add(w: Vec3Value): Vec3 {\n this.x += w.x;\n this.y += w.y;\n this.z += w.z;\n return this;\n }\n\n sub(w: Vec3Value): Vec3 {\n this.x -= w.x;\n this.y -= w.y;\n this.z -= w.z;\n return this;\n }\n\n mul(m: number): Vec3 {\n this.x *= m;\n this.y *= m;\n this.z *= m;\n return this;\n }\n\n static areEqual(v: Vec3Value, w: Vec3Value): boolean {\n if (_ASSERT) Vec3.assert(v);\n if (_ASSERT) Vec3.assert(w);\n return v === w ||\n typeof v === \"object\" && v !== null &&\n typeof w === \"object\" && w !== null &&\n v.x === w.x && v.y === w.y && v.z === w.z;\n }\n\n /** Dot product on two vectors */\n static dot(v: Vec3Value, w: Vec3Value): number {\n return v.x * w.x + v.y * w.y + v.z * w.z;\n }\n\n /** Cross product on two vectors */\n static cross(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(\n v.y * w.z - v.z * w.y,\n v.z * w.x - v.x * w.z,\n v.x * w.y - v.y * w.x\n );\n }\n\n static add(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(v.x + w.x, v.y + w.y, v.z + w.z);\n }\n\n static sub(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(v.x - w.x, v.y - w.y, v.z - w.z);\n }\n\n static mul(v: Vec3Value, m: number): Vec3 {\n return new Vec3(m * v.x, m * v.y, m * v.z);\n }\n\n neg(): Vec3 {\n this.x = -this.x;\n this.y = -this.y;\n this.z = -this.z;\n return this;\n }\n\n static neg(v: Vec3Value): Vec3 {\n return new Vec3(-v.x, -v.y, -v.z);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport * as matrix from \"../../common/Matrix\";\nimport { Shape } from \"../Shape\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { AABB, AABBValue, RayCastInput, RayCastOutput } from \"../AABB\";\nimport { MassData } from \"../../dynamics/Body\";\nimport { DistanceProxy } from \"../Distance\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const v2 = matrix.vec2(0, 0);\n\ndeclare module \"./EdgeShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function EdgeShape(v1?: Vec2Value, v2?: Vec2Value): EdgeShape;\n}\n\n/**\n * A line segment (edge) shape. These can be connected in chains or loops to\n * other edge shapes. The connectivity information is used to ensure correct\n * contact normals.\n */\n// @ts-expect-error\nexport class EdgeShape extends Shape {\n static TYPE = \"edge\" as const;\n /** @hidden */ m_type: \"edge\";\n\n /** @hidden */ m_radius: number;\n\n // These are the edge vertices\n /** @hidden */ m_vertex1: Vec2;\n /** @hidden */ m_vertex2: Vec2;\n\n // Optional adjacent vertices. These are used for smooth collision.\n // Used by chain shape.\n /** @hidden */ m_vertex0: Vec2;\n /** @hidden */ m_vertex3: Vec2;\n /** @hidden */ m_hasVertex0: boolean;\n /** @hidden */ m_hasVertex3: boolean;\n\n constructor(v1?: Vec2Value, v2?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof EdgeShape)) {\n return new EdgeShape(v1, v2);\n }\n\n super();\n\n this.m_type = EdgeShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n\n this.m_vertex1 = v1 ? Vec2.clone(v1) : Vec2.zero();\n this.m_vertex2 = v2 ? Vec2.clone(v2) : Vec2.zero();\n\n this.m_vertex0 = Vec2.zero();\n this.m_vertex3 = Vec2.zero();\n this.m_hasVertex0 = false;\n this.m_hasVertex3 = false;\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n vertex1: this.m_vertex1,\n vertex2: this.m_vertex2,\n\n vertex0: this.m_vertex0,\n vertex3: this.m_vertex3,\n hasVertex0: this.m_hasVertex0,\n hasVertex3: this.m_hasVertex3,\n };\n }\n\n /** @internal */\n static _deserialize(data: any): EdgeShape {\n const shape = new EdgeShape(data.vertex1, data.vertex2);\n if (shape.m_hasVertex0) {\n shape.setPrevVertex(data.vertex0);\n }\n if (shape.m_hasVertex3) {\n shape.setNextVertex(data.vertex3);\n }\n return shape;\n }\n\n /** @hidden */\n _reset(): void {\n // noop\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n getType(): \"edge\" {\n return this.m_type;\n }\n\n /** @internal @deprecated */\n setNext(v?: Vec2Value): EdgeShape {\n return this.setNextVertex(v);\n }\n\n /**\n * Optional next vertex, used for smooth collision.\n */\n setNextVertex(v?: Vec2Value): EdgeShape {\n if (v) {\n this.m_vertex3.setVec2(v);\n this.m_hasVertex3 = true;\n } else {\n this.m_vertex3.setZero();\n this.m_hasVertex3 = false;\n }\n return this;\n }\n\n /**\n * Optional next vertex, used for smooth collision.\n */\n getNextVertex(): Vec2 {\n return this.m_vertex3;\n }\n\n /** @internal @deprecated */\n setPrev(v?: Vec2Value): EdgeShape {\n return this.setPrevVertex(v);\n }\n\n /**\n * Optional prev vertex, used for smooth collision.\n */\n setPrevVertex(v?: Vec2Value): EdgeShape {\n if (v) {\n this.m_vertex0.setVec2(v);\n this.m_hasVertex0 = true;\n } else {\n this.m_vertex0.setZero();\n this.m_hasVertex0 = false;\n }\n return this;\n }\n\n /**\n * Optional prev vertex, used for smooth collision.\n */\n getPrevVertex(): Vec2 {\n return this.m_vertex0;\n }\n\n /**\n * Set this as an isolated edge.\n */\n _set(v1: Vec2Value, v2: Vec2Value): EdgeShape {\n this.m_vertex1.setVec2(v1);\n this.m_vertex2.setVec2(v2);\n this.m_hasVertex0 = false;\n this.m_hasVertex3 = false;\n return this;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): EdgeShape {\n const clone = new EdgeShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_vertex1.setVec2(this.m_vertex1);\n clone.m_vertex2.setVec2(this.m_vertex2);\n clone.m_vertex0.setVec2(this.m_vertex0);\n clone.m_vertex3.setVec2(this.m_vertex3);\n clone.m_hasVertex0 = this.m_hasVertex0;\n clone.m_hasVertex3 = this.m_hasVertex3;\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): false {\n return false;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n // p = p1 + t * d\n // v = v1 + s * e\n // p1 + t * d = v1 + s * e\n // s * e - t * d = p1 - v1\n\n // NOT_USED(childIndex);\n\n // Put the ray into the edge's frame of reference.\n const p1 = Rot.mulTVec2(xf.q, Vec2.sub(input.p1, xf.p));\n const p2 = Rot.mulTVec2(xf.q, Vec2.sub(input.p2, xf.p));\n const d = Vec2.sub(p2, p1);\n\n const v1 = this.m_vertex1;\n const v2 = this.m_vertex2;\n const e = Vec2.sub(v2, v1);\n const normal = Vec2.neo(e.y, -e.x);\n normal.normalize();\n\n // q = p1 + t * d\n // dot(normal, q - v1) = 0\n // dot(normal, p1 - v1) + t * dot(normal, d) = 0\n const numerator = Vec2.dot(normal, Vec2.sub(v1, p1));\n const denominator = Vec2.dot(normal, d);\n\n if (denominator == 0.0) {\n return false;\n }\n\n const t = numerator / denominator;\n if (t < 0.0 || input.maxFraction < t) {\n return false;\n }\n\n const q = Vec2.add(p1, Vec2.mulNumVec2(t, d));\n\n // q = v1 + s * r\n // s = dot(q - v1, r) / dot(r, r)\n const r = Vec2.sub(v2, v1);\n const rr = Vec2.dot(r, r);\n if (rr == 0.0) {\n return false;\n }\n\n const s = Vec2.dot(Vec2.sub(q, v1), r) / rr;\n if (s < 0.0 || 1.0 < s) {\n return false;\n }\n\n output.fraction = t;\n if (numerator > 0.0) {\n output.normal = Rot.mulVec2(xf.q, normal).neg();\n } else {\n output.normal = Rot.mulVec2(xf.q, normal);\n }\n return true;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n matrix.transformVec2(v1, xf, this.m_vertex1);\n matrix.transformVec2(v2, xf, this.m_vertex2);\n\n AABB.combinePoints(aabb, v1, v2);\n AABB.extend(aabb, this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density?: number): void {\n massData.mass = 0.0;\n matrix.combine2Vec2(massData.center, 0.5, this.m_vertex1, 0.5, this.m_vertex2);\n massData.I = 0.0;\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n proxy.m_vertices[0] = this.m_vertex1;\n proxy.m_vertices[1] = this.m_vertex2;\n proxy.m_vertices.length = 2;\n proxy.m_count = 2;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Edge = EdgeShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport type { MassData } from \"../../dynamics/Body\";\nimport { AABBValue, RayCastOutput, RayCastInput, AABB } from \"../AABB\";\nimport { DistanceProxy } from \"../Distance\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Shape } from \"../Shape\";\nimport { EdgeShape } from \"./EdgeShape\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const v2 = matrix.vec2(0, 0);\n\ndeclare module \"./ChainShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function ChainShape(vertices?: Vec2Value[], loop?: boolean): ChainShape;\n}\n\n/**\n * A chain shape is a free form sequence of line segments. The chain has\n * two-sided collision, so you can use inside and outside collision. Therefore,\n * you may use any winding order. Connectivity information is used to create\n * smooth collisions.\n *\n * WARNING: The chain will not collide properly if there are self-intersections.\n */\n// @ts-expect-error\nexport class ChainShape extends Shape {\n static TYPE = \"chain\" as const;\n /** @hidden */ m_type: \"chain\";\n\n /** @hidden */ m_radius: number;\n\n /** @hidden */ m_vertices: Vec2[];\n /** @hidden */ m_count: number;\n /** @hidden */ m_prevVertex: Vec2 | null;\n /** @hidden */ m_nextVertex: Vec2 | null;\n /** @hidden */ m_hasPrevVertex: boolean;\n /** @hidden */ m_hasNextVertex: boolean;\n\n /** @hidden */ m_isLoop: boolean;\n\n constructor(vertices?: Vec2Value[], loop?: boolean) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof ChainShape)) {\n return new ChainShape(vertices, loop);\n }\n\n super();\n\n this.m_type = ChainShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n this.m_vertices = [];\n this.m_count = 0;\n this.m_prevVertex = null;\n this.m_nextVertex = null;\n this.m_hasPrevVertex = false;\n this.m_hasNextVertex = false;\n\n this.m_isLoop = !!loop;\n\n if (vertices && vertices.length) {\n if (loop) {\n this._createLoop(vertices);\n } else {\n this._createChain(vertices);\n }\n }\n }\n\n /** @internal */\n _serialize(): object {\n const data = {\n type: this.m_type,\n vertices: this.m_isLoop ? this.m_vertices.slice(0, this.m_vertices.length - 1) : this.m_vertices,\n isLoop: this.m_isLoop,\n hasPrevVertex: this.m_hasPrevVertex,\n hasNextVertex: this.m_hasNextVertex,\n prevVertex: null as Vec2 | null,\n nextVertex: null as Vec2 | null,\n };\n if (this.m_prevVertex) {\n data.prevVertex = this.m_prevVertex;\n }\n if (this.m_nextVertex) {\n data.nextVertex = this.m_nextVertex;\n }\n return data;\n }\n\n /** @internal */\n static _deserialize(data: any, fixture: any, restore: any): ChainShape {\n const vertices: Vec2[] = [];\n if (data.vertices) {\n for (let i = 0; i < data.vertices.length; i++) {\n vertices.push(restore(Vec2, data.vertices[i]));\n }\n }\n const shape = new ChainShape(vertices, data.isLoop);\n if (data.prevVertex) {\n shape.setPrevVertex(data.prevVertex);\n }\n if (data.nextVertex) {\n shape.setNextVertex(data.nextVertex);\n }\n return shape;\n }\n\n // clear() {\n // this.m_vertices.length = 0;\n // this.m_count = 0;\n // }\n\n getType(): \"chain\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n /**\n * @internal\n * Create a loop. This automatically adjusts connectivity.\n *\n * @param vertices an array of vertices, these are copied\n */\n _createLoop(vertices: Vec2Value[]): ChainShape {\n if (_ASSERT) console.assert(this.m_vertices.length == 0 && this.m_count == 0);\n if (_ASSERT) console.assert(vertices.length >= 3);\n if (vertices.length < 3) {\n return;\n }\n\n for (let i = 1; i < vertices.length; ++i) {\n const v1 = vertices[i - 1];\n const v2 = vertices[i];\n // If the code crashes here, it means your vertices are too close together.\n if (_ASSERT) console.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);\n }\n\n this.m_vertices = [];\n this.m_count = vertices.length + 1;\n for (let i = 0; i < vertices.length; ++i) {\n this.m_vertices[i] = Vec2.clone(vertices[i]);\n }\n this.m_vertices[vertices.length] = Vec2.clone(vertices[0]);\n\n this.m_prevVertex = this.m_vertices[this.m_count - 2];\n this.m_nextVertex = this.m_vertices[1];\n this.m_hasPrevVertex = true;\n this.m_hasNextVertex = true;\n return this;\n }\n\n /**\n * @internal\n * Create a chain with isolated end vertices.\n *\n * @param vertices an array of vertices, these are copied\n */\n _createChain(vertices: Vec2Value[]): ChainShape {\n if (_ASSERT) console.assert(this.m_vertices.length == 0 && this.m_count == 0);\n if (_ASSERT) console.assert(vertices.length >= 2);\n for (let i = 1; i < vertices.length; ++i) {\n const v1 = vertices[i - 1];\n const v2 = vertices[i];\n // If the code crashes here, it means your vertices are too close together.\n if (_ASSERT) console.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);\n }\n\n this.m_vertices = [];\n this.m_count = vertices.length;\n for (let i = 0; i < vertices.length; ++i) {\n this.m_vertices[i] = Vec2.clone(vertices[i]);\n }\n\n this.m_prevVertex = null;\n this.m_nextVertex = null;\n this.m_hasPrevVertex = false;\n this.m_hasNextVertex = false;\n return this;\n }\n\n /** @hidden */\n _reset(): void {\n if (this.m_isLoop) {\n this._createLoop(this.m_vertices.slice(0, this.m_vertices.length - 1));\n } else {\n this._createChain(this.m_vertices);\n }\n }\n\n /**\n * Establish connectivity to a vertex that precedes the first vertex. Don't call\n * this for loops.\n */\n setPrevVertex(prevVertex: Vec2): void {\n // todo: copy or reference\n this.m_prevVertex = prevVertex;\n this.m_hasPrevVertex = true;\n }\n\n getPrevVertex(): Vec2 {\n return this.m_prevVertex;\n }\n\n /**\n * Establish connectivity to a vertex that follows the last vertex. Don't call\n * this for loops.\n */\n setNextVertex(nextVertex: Vec2): void {\n // todo: copy or reference\n this.m_nextVertex = nextVertex;\n this.m_hasNextVertex = true;\n }\n\n getNextVertex(): Vec2 {\n return this.m_nextVertex;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): ChainShape {\n const clone = new ChainShape();\n clone._createChain(this.m_vertices);\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_prevVertex = this.m_prevVertex;\n clone.m_nextVertex = this.m_nextVertex;\n clone.m_hasPrevVertex = this.m_hasPrevVertex;\n clone.m_hasNextVertex = this.m_hasNextVertex;\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): number {\n // edge count = vertex count - 1\n return this.m_count - 1;\n }\n\n // Get a child edge.\n getChildEdge(edge: EdgeShape, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count - 1);\n edge.m_type = EdgeShape.TYPE;\n edge.m_radius = this.m_radius;\n\n edge.m_vertex1 = this.m_vertices[childIndex];\n edge.m_vertex2 = this.m_vertices[childIndex + 1];\n\n if (childIndex > 0) {\n edge.m_vertex0 = this.m_vertices[childIndex - 1];\n edge.m_hasVertex0 = true;\n } else {\n edge.m_vertex0 = this.m_prevVertex;\n edge.m_hasVertex0 = this.m_hasPrevVertex;\n }\n\n if (childIndex < this.m_count - 2) {\n edge.m_vertex3 = this.m_vertices[childIndex + 2];\n edge.m_hasVertex3 = true;\n } else {\n edge.m_vertex3 = this.m_nextVertex;\n edge.m_hasVertex3 = this.m_hasNextVertex;\n }\n }\n\n getVertex(index: number): Vec2 {\n if (_ASSERT) console.assert(0 <= index && index <= this.m_count);\n if (index < this.m_count) {\n return this.m_vertices[index];\n } else {\n return this.m_vertices[0];\n }\n }\n\n isLoop(): boolean {\n return this.m_isLoop;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * This always return false.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): false {\n return false;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n\n const edgeShape = new EdgeShape(this.getVertex(childIndex), this.getVertex(childIndex + 1));\n return edgeShape.rayCast(output, input, xf, 0);\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n\n matrix.transformVec2(v1, xf, this.getVertex(childIndex));\n matrix.transformVec2(v2, xf, this.getVertex(childIndex + 1));\n\n AABB.combinePoints(aabb, v1, v2);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * Chains have zero mass.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density?: number): void {\n massData.mass = 0.0;\n matrix.zeroVec2(massData.center);\n massData.I = 0.0;\n }\n\n computeDistanceProxy(proxy: DistanceProxy, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n proxy.m_vertices[0] = this.getVertex(childIndex);\n proxy.m_vertices[1] = this.getVertex(childIndex + 1);\n proxy.m_count = 2;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Chain = ChainShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport type { MassData } from \"../../dynamics/Body\";\nimport { RayCastOutput, RayCastInput, AABBValue } from \"../AABB\";\nimport { DistanceProxy } from \"../Distance\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Shape } from \"../Shape\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const e = matrix.vec2(0, 0);\n/** @internal */ const e1 = matrix.vec2(0, 0);\n/** @internal */ const e2 = matrix.vec2(0, 0);\n/** @internal */ const center = matrix.vec2(0, 0);\n/** @internal */ const s = matrix.vec2(0, 0);\n\ndeclare module \"./PolygonShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PolygonShape(vertices?: Vec2Value[]): PolygonShape;\n}\n\n/**\n * A convex polygon. It is assumed that the interior of the polygon is to the\n * left of each edge. Polygons have a maximum number of vertices equal to\n * Settings.maxPolygonVertices. In most cases you should not need many vertices\n * for a convex polygon. extends Shape\n */\n// @ts-expect-error\nexport class PolygonShape extends Shape {\n static TYPE = \"polygon\" as const;\n /** @hidden */ m_type: \"polygon\";\n\n /** @hidden */ m_centroid: Vec2;\n /** @hidden */ m_vertices: Vec2[]; // [Settings.maxPolygonVertices]\n /** @hidden */ m_normals: Vec2[]; // [Settings.maxPolygonVertices]\n /** @hidden */ m_count: number;\n /** @hidden */ m_radius: number;\n\n constructor(vertices?: Vec2Value[]) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PolygonShape)) {\n return new PolygonShape(vertices);\n }\n\n super();\n\n this.m_type = PolygonShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n this.m_centroid = Vec2.zero();\n this.m_vertices = [];\n this.m_normals = [];\n this.m_count = 0;\n\n if (vertices && vertices.length) {\n this._set(vertices);\n }\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n vertices: this.m_vertices,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, fixture: any, restore: any): PolygonShape {\n const vertices: Vec2[] = [];\n if (data.vertices) {\n for (let i = 0; i < data.vertices.length; i++) {\n vertices.push(restore(Vec2, data.vertices[i]));\n }\n }\n\n const shape = new PolygonShape(vertices);\n return shape;\n }\n\n getType(): \"polygon\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): PolygonShape {\n const clone = new PolygonShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_count = this.m_count;\n clone.m_centroid.setVec2(this.m_centroid);\n for (let i = 0; i < this.m_count; i++) {\n clone.m_vertices.push(this.m_vertices[i].clone());\n }\n for (let i = 0; i < this.m_normals.length; i++) {\n clone.m_normals.push(this.m_normals[i].clone());\n }\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /** @hidden */\n _reset(): void {\n this._set(this.m_vertices);\n }\n\n /**\n * @internal\n *\n * Create a convex hull from the given array of local points. The count must be\n * in the range [3, Settings.maxPolygonVertices].\n *\n * Warning: the points may be re-ordered, even if they form a convex polygon\n * Warning: collinear points are handled but not removed. Collinear points may\n * lead to poor stacking behavior.\n */\n _set(vertices: Vec2Value[]): void {\n if (_ASSERT) console.assert(3 <= vertices.length && vertices.length <= Settings.maxPolygonVertices);\n if (vertices.length < 3) {\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n let n = math_min(vertices.length, Settings.maxPolygonVertices);\n\n // Perform welding and copy vertices into local buffer.\n const ps: Vec2[] = []; // [Settings.maxPolygonVertices];\n for (let i = 0; i < n; ++i) {\n const v = vertices[i];\n\n let unique = true;\n for (let j = 0; j < ps.length; ++j) {\n if (Vec2.distanceSquared(v, ps[j]) < 0.25 * Settings.linearSlopSquared) {\n unique = false;\n break;\n }\n }\n\n if (unique) {\n ps.push(Vec2.clone(v));\n }\n }\n\n n = ps.length;\n if (n < 3) {\n // Polygon is degenerate.\n if (_ASSERT) console.assert(false);\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n // Create the convex hull using the Gift wrapping algorithm\n // http://en.wikipedia.org/wiki/Gift_wrapping_algorithm\n\n // Find the right most point on the hull (in case of multiple points bottom most is used)\n let i0 = 0;\n let x0 = ps[0].x;\n for (let i = 1; i < n; ++i) {\n const x = ps[i].x;\n if (x > x0 || (x === x0 && ps[i].y < ps[i0].y)) {\n i0 = i;\n x0 = x;\n }\n }\n\n const hull = [] as number[]; // [Settings.maxPolygonVertices];\n let m = 0;\n let ih = i0;\n\n while (true) {\n if (_ASSERT) console.assert(m < Settings.maxPolygonVertices);\n hull[m] = ih;\n\n let ie = 0;\n for (let j = 1; j < n; ++j) {\n if (ie === ih) {\n ie = j;\n continue;\n }\n\n const r = Vec2.sub(ps[ie], ps[hull[m]]);\n const v = Vec2.sub(ps[j], ps[hull[m]]);\n const c = Vec2.crossVec2Vec2(r, v);\n // c < 0 means counter-clockwise wrapping, c > 0 means clockwise wrapping\n if (c < 0.0) {\n ie = j;\n }\n\n // Collinearity check\n if (c === 0.0 && v.lengthSquared() > r.lengthSquared()) {\n ie = j;\n }\n }\n\n ++m;\n ih = ie;\n\n if (ie === i0) {\n break;\n }\n }\n\n if (m < 3) {\n // Polygon is degenerate.\n if (_ASSERT) console.assert(false);\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n this.m_count = m;\n\n // Copy vertices.\n this.m_vertices = [];\n for (let i = 0; i < m; ++i) {\n this.m_vertices[i] = ps[hull[i]];\n }\n\n // Compute normals. Ensure the edges have non-zero length.\n for (let i = 0; i < m; ++i) {\n const i1 = i;\n const i2 = i + 1 < m ? i + 1 : 0;\n const edge = Vec2.sub(this.m_vertices[i2], this.m_vertices[i1]);\n if (_ASSERT) console.assert(edge.lengthSquared() > EPSILON * EPSILON);\n this.m_normals[i] = Vec2.crossVec2Num(edge, 1.0);\n this.m_normals[i].normalize();\n }\n\n // Compute the polygon centroid.\n this.m_centroid = computeCentroid(this.m_vertices, m);\n }\n\n /** @internal */ _setAsBox(hx: number, hy: number, center?: Vec2Value, angle?: number): void {\n // start with right-bottom, counter-clockwise, as in Gift wrapping algorithm in PolygonShape._set()\n this.m_vertices[0] = Vec2.neo(hx, -hy);\n this.m_vertices[1] = Vec2.neo(hx, hy);\n this.m_vertices[2] = Vec2.neo(-hx, hy);\n this.m_vertices[3] = Vec2.neo(-hx, -hy);\n\n this.m_normals[0] = Vec2.neo(1.0, 0.0);\n this.m_normals[1] = Vec2.neo(0.0, 1.0);\n this.m_normals[2] = Vec2.neo(-1.0, 0.0);\n this.m_normals[3] = Vec2.neo(0.0, -1.0);\n\n this.m_count = 4;\n\n if (center && Vec2.isValid(center)) {\n angle = angle || 0;\n\n matrix.copyVec2(this.m_centroid, center);\n\n const xf = Transform.identity();\n xf.p.setVec2(center);\n xf.q.setAngle(angle);\n\n // Transform vertices and normals.\n for (let i = 0; i < this.m_count; ++i) {\n this.m_vertices[i] = Transform.mulVec2(xf, this.m_vertices[i]);\n this.m_normals[i] = Rot.mulVec2(xf.q, this.m_normals[i]);\n }\n }\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): boolean {\n const pLocal = matrix.detransformVec2(temp, xf, p);\n\n for (let i = 0; i < this.m_count; ++i) {\n const dot = matrix.dotVec2(this.m_normals[i], pLocal) - matrix.dotVec2(this.m_normals[i], this.m_vertices[i]);\n if (dot > 0.0) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n\n // Put the ray into the polygon's frame of reference.\n const p1 = Rot.mulTVec2(xf.q, Vec2.sub(input.p1, xf.p));\n const p2 = Rot.mulTVec2(xf.q, Vec2.sub(input.p2, xf.p));\n const d = Vec2.sub(p2, p1);\n\n let lower = 0.0;\n let upper = input.maxFraction;\n\n let index = -1;\n\n for (let i = 0; i < this.m_count; ++i) {\n // p = p1 + a * d\n // dot(normal, p - v) = 0\n // dot(normal, p1 - v) + a * dot(normal, d) = 0\n const numerator = Vec2.dot(this.m_normals[i], Vec2.sub(this.m_vertices[i], p1));\n const denominator = Vec2.dot(this.m_normals[i], d);\n\n if (denominator == 0.0) {\n if (numerator < 0.0) {\n return false;\n }\n } else {\n // Note: we want this predicate without division:\n // lower < numerator / denominator, where denominator < 0\n // Since denominator < 0, we have to flip the inequality:\n // lower < numerator / denominator <==> denominator * lower > numerator.\n if (denominator < 0.0 && numerator < lower * denominator) {\n // Increase lower.\n // The segment enters this half-space.\n lower = numerator / denominator;\n index = i;\n } else if (denominator > 0.0 && numerator < upper * denominator) {\n // Decrease upper.\n // The segment exits this half-space.\n upper = numerator / denominator;\n }\n }\n\n // The use of epsilon here causes the assert on lower to trip\n // in some cases. Apparently the use of epsilon was to make edge\n // shapes work, but now those are handled separately.\n // if (upper < lower - matrix.EPSILON)\n if (upper < lower) {\n return false;\n }\n }\n\n if (_ASSERT) console.assert(0.0 <= lower && lower <= input.maxFraction);\n\n if (index >= 0) {\n output.fraction = lower;\n output.normal = Rot.mulVec2(xf.q, this.m_normals[index]);\n return true;\n }\n\n return false;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (let i = 0; i < this.m_count; ++i) {\n const v = matrix.transformVec2(temp, xf, this.m_vertices[i]);\n minX = math_min(minX, v.x);\n maxX = math_max(maxX, v.x);\n minY = math_min(minY, v.y);\n maxY = math_max(maxY, v.y);\n }\n\n matrix.setVec2(aabb.lowerBound, minX - this.m_radius, minY - this.m_radius);\n matrix.setVec2(aabb.upperBound, maxX + this.m_radius, maxY + this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density: number): void {\n // Polygon mass, centroid, and inertia.\n // Let rho be the polygon density in mass per unit area.\n // Then:\n // mass = rho * int(dA)\n // centroid.x = (1/mass) * rho * int(x * dA)\n // centroid.y = (1/mass) * rho * int(y * dA)\n // I = rho * int((x*x + y*y) * dA)\n //\n // We can compute these integrals by summing all the integrals\n // for each triangle of the polygon. To evaluate the integral\n // for a single triangle, we make a change of variables to\n // the (u,v) coordinates of the triangle:\n // x = x0 + e1x * u + e2x * v\n // y = y0 + e1y * u + e2y * v\n // where 0 <= u && 0 <= v && u + v <= 1.\n //\n // We integrate u from [0,1-v] and then v from [0,1].\n // We also need to use the Jacobian of the transformation:\n // D = cross(e1, e2)\n //\n // Simplification: triangle centroid = (1/3) * (p1 + p2 + p3)\n //\n // The rest of the derivation is handled by computer algebra.\n\n if (_ASSERT) console.assert(this.m_count >= 3);\n\n matrix.zeroVec2(center);\n let area = 0.0;\n let I = 0.0;\n\n // s is the reference point for forming triangles.\n // It's location doesn't change the result (except for rounding error).\n matrix.zeroVec2(s);\n\n // This code would put the reference point inside the polygon.\n for (let i = 0; i < this.m_count; ++i) {\n matrix.plusVec2(s, this.m_vertices[i]);\n }\n matrix.scaleVec2(s, 1.0 / this.m_count, s);\n\n const k_inv3 = 1.0 / 3.0;\n\n for (let i = 0; i < this.m_count; ++i) {\n // Triangle vertices.\n matrix.subVec2(e1, this.m_vertices[i], s);\n if ( i + 1 < this.m_count) {\n matrix.subVec2(e2, this.m_vertices[i + 1], s);\n } else {\n matrix.subVec2(e2, this.m_vertices[0], s);\n }\n\n const D = matrix.crossVec2Vec2(e1, e2);\n\n const triangleArea = 0.5 * D;\n area += triangleArea;\n\n // Area weighted centroid\n matrix.combine2Vec2(temp, triangleArea * k_inv3, e1, triangleArea * k_inv3, e2);\n matrix.plusVec2(center, temp);\n\n const ex1 = e1.x;\n const ey1 = e1.y;\n const ex2 = e2.x;\n const ey2 = e2.y;\n\n const intx2 = ex1 * ex1 + ex2 * ex1 + ex2 * ex2;\n const inty2 = ey1 * ey1 + ey2 * ey1 + ey2 * ey2;\n\n I += (0.25 * k_inv3 * D) * (intx2 + inty2);\n }\n\n // Total mass\n massData.mass = density * area;\n\n // Center of mass\n if (_ASSERT) console.assert(area > EPSILON);\n matrix.scaleVec2(center, 1.0 / area, center);\n matrix.addVec2(massData.center, center, s);\n\n // Inertia tensor relative to the local origin (point s).\n massData.I = density * I;\n\n // Shift to center of mass then to original body origin.\n massData.I += massData.mass * (matrix.dotVec2(massData.center, massData.center) - matrix.dotVec2(center, center));\n }\n\n /**\n * Validate convexity. This is a very time consuming operation.\n * @returns true if valid\n */\n validate(): boolean {\n for (let i = 0; i < this.m_count; ++i) {\n const i1 = i;\n const i2 = i < this.m_count - 1 ? i1 + 1 : 0;\n const p = this.m_vertices[i1];\n matrix.subVec2(e, this.m_vertices[i2], p);\n\n for (let j = 0; j < this.m_count; ++j) {\n if (j == i1 || j == i2) {\n continue;\n }\n\n const c = matrix.crossVec2Vec2(e, matrix.subVec2(temp, this.m_vertices[j], p));\n if (c < 0.0) {\n return false;\n }\n }\n }\n\n return true;\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n for (let i = 0; i < this.m_count; ++i) {\n proxy.m_vertices[i] = this.m_vertices[i];\n }\n proxy.m_vertices.length = this.m_count;\n proxy.m_count = this.m_count;\n proxy.m_radius = this.m_radius;\n }\n}\n\n/** @internal */ function computeCentroid(vs: Vec2[], count: number): Vec2 {\n if (_ASSERT) console.assert(count >= 3);\n\n const c = Vec2.zero();\n let area = 0.0;\n\n // pRef is the reference point for forming triangles.\n // It's location doesn't change the result (except for rounding error).\n const pRef = Vec2.zero();\n if (false) {\n // This code would put the reference point inside the polygon.\n for (let i = 0; i < count; ++i) {\n pRef.add(vs[i]);\n }\n pRef.mul(1.0 / count);\n }\n\n const inv3 = 1.0 / 3.0;\n\n for (let i = 0; i < count; ++i) {\n // Triangle vertices.\n const p1 = pRef;\n const p2 = vs[i];\n const p3 = i + 1 < count ? vs[i + 1] : vs[0];\n\n const e1 = Vec2.sub(p2, p1);\n const e2 = Vec2.sub(p3, p1);\n\n const D = Vec2.crossVec2Vec2(e1, e2);\n\n const triangleArea = 0.5 * D;\n area += triangleArea;\n\n // Area weighted centroid\n matrix.combine3Vec2(temp, 1, p1, 1, p2, 1, p3);\n matrix.plusScaleVec2(c, triangleArea * inv3, temp);\n }\n\n // Centroid\n if (_ASSERT) console.assert(area > EPSILON);\n c.mul(1.0 / area);\n return c;\n}\n\nexport const Polygon = PolygonShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Shape } from \"../Shape\";\nimport { AABBValue, RayCastInput, RayCastOutput } from \"../AABB\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { MassData } from \"../../dynamics/Body\";\nimport { DistanceProxy } from \"../Distance\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_PI = Math.PI;\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n\ndeclare module \"./CircleShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function CircleShape(position: Vec2Value, radius?: number): CircleShape;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function CircleShape(radius?: number): CircleShape;\n}\n\n/** Circle shape. */\n// @ts-expect-error\nexport class CircleShape extends Shape {\n static TYPE = \"circle\" as const;\n /** @hidden */ m_type: \"circle\";\n\n /** @hidden */ m_p: Vec2;\n /** @hidden */ m_radius: number;\n\n constructor(position: Vec2Value, radius?: number);\n constructor(radius?: number);\n constructor(a: any, b?: any) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof CircleShape)) {\n return new CircleShape(a, b);\n }\n\n super();\n\n this.m_type = CircleShape.TYPE;\n this.m_p = Vec2.zero();\n this.m_radius = 1;\n\n if (typeof a === \"object\" && Vec2.isValid(a)) {\n this.m_p.setVec2(a);\n\n if (typeof b === \"number\") {\n this.m_radius = b;\n }\n\n } else if (typeof a === \"number\") {\n this.m_radius = a;\n }\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n p: this.m_p,\n radius: this.m_radius,\n };\n }\n\n /** @internal */\n static _deserialize(data: any): CircleShape {\n return new CircleShape(data.p, data.radius);\n }\n\n /** @hidden */\n _reset(): void {\n // noop\n }\n\n getType(): \"circle\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n getCenter(): Vec2 {\n return this.m_p;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): CircleShape {\n const clone = new CircleShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_p = this.m_p.clone();\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): boolean {\n const center = matrix.transformVec2(temp, xf, this.m_p);\n return matrix.distSqrVec2(p, center) <= this.m_radius * this.m_radius;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n // Collision Detection in Interactive 3D Environments by Gino van den Bergen\n // From Section 3.1.2\n // x = s + a * r\n // norm(x) = radius\n\n const position = Vec2.add(xf.p, Rot.mulVec2(xf.q, this.m_p));\n const s = Vec2.sub(input.p1, position);\n const b = Vec2.dot(s, s) - this.m_radius * this.m_radius;\n\n // Solve quadratic equation.\n const r = Vec2.sub(input.p2, input.p1);\n const c = Vec2.dot(s, r);\n const rr = Vec2.dot(r, r);\n const sigma = c * c - rr * b;\n\n // Check for negative discriminant and short segment.\n if (sigma < 0.0 || rr < EPSILON) {\n return false;\n }\n\n // Find the point of intersection of the line with the circle.\n let a = -(c + math_sqrt(sigma));\n\n // Is the intersection point on the segment?\n if (0.0 <= a && a <= input.maxFraction * rr) {\n a /= rr;\n output.fraction = a;\n output.normal = Vec2.add(s, Vec2.mulNumVec2(a, r));\n output.normal.normalize();\n return true;\n }\n\n return false;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n const p = matrix.transformVec2(temp, xf, this.m_p);\n\n matrix.setVec2(aabb.lowerBound, p.x - this.m_radius, p.y - this.m_radius);\n matrix.setVec2(aabb.upperBound, p.x + this.m_radius, p.y + this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density: number): void {\n massData.mass = density * math_PI * this.m_radius * this.m_radius;\n matrix.copyVec2(massData.center, this.m_p);\n // inertia about the local origin\n massData.I = massData.mass * (0.5 * this.m_radius * this.m_radius + matrix.lengthSqrVec2(this.m_p));\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n proxy.m_vertices[0] = this.m_p;\n proxy.m_vertices.length = 1;\n proxy.m_count = 1;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Circle = CircleShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Distance joint definition. This requires defining an anchor point on both\n * bodies and the non-zero length of the distance joint. The definition uses\n * local anchor points so that the initial configuration can violate the\n * constraint slightly. This helps when saving and loading a game. Warning: Do\n * not use a zero or short length.\n */\nexport interface DistanceJointOpt extends JointOpt {\n /**\n * The mass-spring-damper frequency in Hertz. A value of 0 disables softness.\n */\n frequencyHz?: number;\n /**\n * The damping ratio. 0 = no damping, 1 = critical damping.\n */\n dampingRatio?: number;\n /**\n * Distance length.\n */\n length?: number;\n}\n/**\n * Distance joint definition. This requires defining an anchor point on both\n * bodies and the non-zero length of the distance joint. The definition uses\n * local anchor points so that the initial configuration can violate the\n * constraint slightly. This helps when saving and loading a game. Warning: Do\n * not use a zero or short length.\n */\nexport interface DistanceJointDef extends JointDef, DistanceJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n frequencyHz : 0.0,\n dampingRatio : 0.0\n};\n\ndeclare module \"./DistanceJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function DistanceJoint(def: DistanceJointDef): DistanceJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function DistanceJoint(def: DistanceJointOpt, bodyA: Body, bodyB: Body, anchorA: Vec2Value, anchorB: Vec2Value): DistanceJoint;\n}\n\n/**\n * A distance joint constrains two points on two bodies to remain at a fixed\n * distance from each other. You can view this as a massless, rigid rod.\n */\n// @ts-expect-error\nexport class DistanceJoint extends Joint {\n static TYPE = \"distance-joint\" as const;\n\n // Solver shared\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_length: number;\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_gamma: number;\n /** @internal */ m_bias: number;\n\n // Solver temp\n /** @internal */ m_u: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: number;\n\n /**\n * @param def DistanceJoint definition.\n */\n constructor(def: DistanceJointDef);\n /**\n * @param anchorA Anchor A in global coordination.\n * @param anchorB Anchor B in global coordination.\n */\n constructor(def: DistanceJointOpt, bodyA: Body, bodyB: Body, anchorA?: Vec2Value, anchorB?: Vec2Value);\n constructor(def: DistanceJointDef, bodyA?: Body, bodyB?: Body, anchorA?: Vec2Value, anchorB?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof DistanceJoint)) {\n return new DistanceJoint(def, bodyA, bodyB, anchorA, anchorB);\n }\n\n // order of constructor arguments is changed in v0.2\n if (bodyB && anchorA && (\"m_type\" in anchorA) && (\"x\" in bodyB) && (\"y\" in bodyB)) {\n const temp = bodyB;\n bodyB = anchorA as any as Body;\n anchorA = temp as any as Vec2;\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = DistanceJoint.TYPE;\n\n // Solver shared\n this.m_localAnchorA = Vec2.clone(anchorA ? bodyA.getLocalPoint(anchorA) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchorB ? bodyB.getLocalPoint(anchorB) : def.localAnchorB || Vec2.zero());\n this.m_length = Number.isFinite(def.length) ? def.length :\n Vec2.distance(bodyA.getWorldPoint(this.m_localAnchorA), bodyB.getWorldPoint(this.m_localAnchorB));\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n this.m_impulse = 0.0;\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n\n // 1-D constrained system\n // m (v2 - v1) = lambda\n // v2 + (beta/h) * x1 + gamma * lambda = 0, gamma has units of inverse mass.\n // x2 = x1 + h * v2\n\n // 1-D mass-damper-spring system\n // m (v2 - v1) + h * d * v2 + h * k *\n\n // C = norm(p2 - p1) - L\n // u = (p2 - p1) / norm(p2 - p1)\n // Cdot = dot(u, v2 + cross(w2, r2) - v1 - cross(w1, r1))\n // J = [-u -cross(r1, u) u cross(r2, u)]\n // K = J * invM * JT\n // = invMass1 + invI1 * cross(r1, u)^2 + invMass2 + invI2 * cross(r2, u)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n length: this.m_length,\n\n impulse: this.m_impulse,\n gamma: this.m_gamma,\n bias: this.m_bias,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): DistanceJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new DistanceJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n\n if (def.length > 0) {\n this.m_length = +def.length;\n } else if (def.length < 0) { // don't change length\n } else if (def.anchorA || def.anchorA || def.anchorA || def.anchorA) {\n this.m_length = Vec2.distance(\n this.m_bodyA.getWorldPoint(this.m_localAnchorA),\n this.m_bodyB.getWorldPoint(this.m_localAnchorB)\n );\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the natural length. Manipulating the length can lead to non-physical\n * behavior when the frequency is zero.\n */\n setLength(length: number): void {\n this.m_length = length;\n }\n\n /**\n * Get the natural length.\n */\n getLength(): number {\n return this.m_length;\n }\n\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_u).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n this.m_u = Vec2.sub(Vec2.add(cB, this.m_rB), Vec2.add(cA, this.m_rA));\n\n // Handle singularity.\n const length = this.m_u.length();\n if (length > Settings.linearSlop) {\n this.m_u.mul(1.0 / length);\n } else {\n this.m_u.setNum(0.0, 0.0);\n }\n\n const crAu = Vec2.crossVec2Vec2(this.m_rA, this.m_u);\n const crBu = Vec2.crossVec2Vec2(this.m_rB, this.m_u);\n let invMass = this.m_invMassA + this.m_invIA * crAu * crAu + this.m_invMassB + this.m_invIB * crBu * crBu;\n\n // Compute the effective mass matrix.\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n\n if (this.m_frequencyHz > 0.0) {\n const C = length - this.m_length;\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * this.m_mass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = this.m_mass * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (d + h * k);\n this.m_gamma = this.m_gamma != 0.0 ? 1.0 / this.m_gamma : 0.0;\n this.m_bias = C * h * k * this.m_gamma;\n\n invMass += this.m_gamma;\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n } else {\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n }\n\n if (step.warmStarting) {\n // Scale the impulse to support a variable time step.\n this.m_impulse *= step.dtRatio;\n\n const P = Vec2.mulNumVec2(this.m_impulse, this.m_u);\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Cdot = dot(u, v + cross(w, r))\n const vpA = Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA));\n const vpB = Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB));\n const Cdot = Vec2.dot(this.m_u, vpB) - Vec2.dot(this.m_u, vpA);\n\n const impulse = -this.m_mass * (Cdot + this.m_bias + this.m_gamma * this.m_impulse);\n this.m_impulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_u);\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n if (this.m_frequencyHz > 0.0) {\n // There is no position correction for soft distance constraints.\n return true;\n }\n\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n const u = Vec2.sub(Vec2.add(cB, rB), Vec2.add(cA, rA));\n\n const length = u.normalize();\n const C = clamp(length - this.m_length, -Settings.maxLinearCorrection, Settings.maxLinearCorrection);\n\n const impulse = -this.m_mass * C;\n const P = Vec2.mulNumVec2(impulse, u);\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * Vec2.crossVec2Vec2(rA, P);\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, P);\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return math_abs(C) < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Friction joint definition.\n */\nexport interface FrictionJointOpt extends JointOpt {\n /**\n * The maximum friction force in N.\n */\n maxForce?: number;\n /**\n * The maximum friction torque in N-m.\n */\n maxTorque?: number;\n}\n\n/**\n * Friction joint definition.\n */\nexport interface FrictionJointDef extends JointDef, FrictionJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 0.0,\n maxTorque : 0.0,\n};\n\ndeclare module \"./FrictionJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function FrictionJoint(def: FrictionJointDef): FrictionJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function FrictionJoint(def: FrictionJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): FrictionJoint;\n}\n\n/**\n * Friction joint. This is used for top-down friction. It provides 2D\n * translational friction and angular friction.\n */\n// @ts-expect-error\nexport class FrictionJoint extends Joint {\n static TYPE = \"friction-joint\" as const;\n\n /** @internal */ m_type: \"friction-joint\";\n\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n\n // Solver shared\n /** @internal */ m_linearImpulse: Vec2;\n /** @internal */ m_angularImpulse: number;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_maxTorque: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_linearMass: Mat22;\n /** @internal */ m_angularMass: number;\n\n constructor(def: FrictionJointDef);\n /**\n * @param anchor Anchor in global coordination.\n */\n constructor(def: FrictionJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: FrictionJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof FrictionJoint)) {\n return new FrictionJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = FrictionJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n\n // Solver shared\n this.m_linearImpulse = Vec2.zero();\n this.m_angularImpulse = 0.0;\n this.m_maxForce = def.maxForce;\n this.m_maxTorque = def.maxTorque;\n\n // Point-to-point constraint\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Angle constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n maxForce: this.m_maxForce,\n maxTorque: this.m_maxTorque,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): FrictionJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new FrictionJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.maxTorque)) {\n this.m_maxTorque = def.maxTorque;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the maximum friction force in N.\n */\n setMaxForce(force: number): void {\n if (_ASSERT) console.assert(Number.isFinite(force) && force >= 0.0);\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum friction force in N.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the maximum friction torque in N*m.\n */\n setMaxTorque(torque: number): void {\n if (_ASSERT) console.assert(Number.isFinite(torque) && torque >= 0.0);\n this.m_maxTorque = torque;\n }\n\n /**\n * Get the maximum friction torque in N*m.\n */\n getMaxTorque(): number {\n return this.m_maxTorque;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_linearImpulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_angularImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective mass matrix.\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat22();\n K.ex.x = mA + mB + iA * this.m_rA.y * this.m_rA.y + iB * this.m_rB.y\n * this.m_rB.y;\n K.ex.y = -iA * this.m_rA.x * this.m_rA.y - iB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * this.m_rA.x * this.m_rA.x + iB * this.m_rB.x\n * this.m_rB.x;\n\n this.m_linearMass = K.getInverse();\n\n this.m_angularMass = iA + iB;\n if (this.m_angularMass > 0.0) {\n this.m_angularMass = 1.0 / this.m_angularMass;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_linearImpulse.mul(step.dtRatio);\n this.m_angularImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_linearImpulse.x, this.m_linearImpulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_angularImpulse);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_angularImpulse);\n\n } else {\n this.m_linearImpulse.setZero();\n this.m_angularImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const h = step.dt;\n\n // Solve angular friction\n {\n const Cdot = wB - wA;\n let impulse = -this.m_angularMass * Cdot;\n\n const oldImpulse = this.m_angularImpulse;\n const maxImpulse = h * this.m_maxTorque;\n this.m_angularImpulse = clamp(this.m_angularImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_angularImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve linear friction\n {\n const Cdot = Vec2.sub(\n Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB)),\n Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA))\n );\n\n let impulse = Vec2.neg(Mat22.mulVec2(this.m_linearMass, Cdot));\n const oldImpulse = this.m_linearImpulse;\n this.m_linearImpulse.add(impulse);\n\n const maxImpulse = h * this.m_maxForce;\n\n if (this.m_linearImpulse.lengthSquared() > maxImpulse * maxImpulse) {\n this.m_linearImpulse.normalize();\n this.m_linearImpulse.mul(maxImpulse);\n }\n\n impulse = Vec2.sub(this.m_linearImpulse, oldImpulse);\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { Vec3, Vec3Value } from \"./Vec3\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A 3-by-3 matrix. Stored in column-major order.\n */\nexport class Mat33 {\n ex: Vec3;\n ey: Vec3;\n ez: Vec3;\n\n constructor(a: Vec3Value, b: Vec3Value, c: Vec3Value);\n constructor();\n constructor(a?: Vec3Value, b?: Vec3Value, c?: Vec3Value) {\n if (typeof a === \"object\" && a !== null) {\n this.ex = Vec3.clone(a);\n this.ey = Vec3.clone(b);\n this.ez = Vec3.clone(c);\n } else {\n this.ex = Vec3.zero();\n this.ey = Vec3.zero();\n this.ez = Vec3.zero();\n }\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec3.isValid(obj.ex) && Vec3.isValid(obj.ey) && Vec3.isValid(obj.ez);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Mat33.isValid(o), \"Invalid Mat33!\", o);\n }\n\n /**\n * Set this matrix to all zeros.\n */\n setZero(): Mat33 {\n this.ex.setZero();\n this.ey.setZero();\n this.ez.setZero();\n return this;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases.\n */\n solve33(v: Vec3Value): Vec3 {\n // let det = matrix.dotVec3(this.ex, matrix.newCrossVec3(this.ey, this.ez));\n let cross_x = this.ey.y * this.ez.z - this.ey.z * this.ez.y;\n let cross_y = this.ey.z * this.ez.x - this.ey.x * this.ez.z;\n let cross_z = this.ey.x * this.ez.y - this.ey.y * this.ez.x;\n let det = this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const r = new Vec3();\n // r.x = det * matrix.dotVec3(v, matrix.newCrossVec3(this.ey, this.ez));\n cross_x = this.ey.y * this.ez.z - this.ey.z * this.ez.y;\n cross_y = this.ey.z * this.ez.x - this.ey.x * this.ez.z;\n cross_z = this.ey.x * this.ez.y - this.ey.y * this.ez.x;\n r.x = det * (v.x * cross_x + v.y * cross_y + v.z * cross_z);\n\n // r.y = det * matrix.dotVec3(this.ex, matrix.newCrossVec3(v, this.ez));\n cross_x = v.y * this.ez.z - v.z * this.ez.y;\n cross_y = v.z * this.ez.x - v.x * this.ez.z;\n cross_z = v.x * this.ez.y - v.y * this.ez.x;\n r.y = det * (this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z);\n\n // r.z = det * matrix.dotVec3(this.ex, matrix.newCrossVec3(this.ey, v));\n cross_x = this.ey.y * v.z - this.ey.z * v.y;\n cross_y = this.ey.z * v.x - this.ey.x * v.z;\n cross_z = this.ey.x * v.y - this.ey.y * v.x;\n r.z = det * (this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z);\n return r;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases. Solve only the upper 2-by-2 matrix\n * equation.\n */\n solve22(v: Vec2Value): Vec2 {\n const a11 = this.ex.x;\n const a12 = this.ey.x;\n const a21 = this.ex.y;\n const a22 = this.ey.y;\n let det = a11 * a22 - a12 * a21;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const r = Vec2.zero();\n r.x = det * (a22 * v.x - a12 * v.y);\n r.y = det * (a11 * v.y - a21 * v.x);\n return r;\n }\n\n /**\n * Get the inverse of this matrix as a 2-by-2. Returns the zero matrix if\n * singular.\n */\n getInverse22(M: Mat33): void {\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n M.ex.x = det * d;\n M.ey.x = -det * b;\n M.ex.z = 0.0;\n M.ex.y = -det * c;\n M.ey.y = det * a;\n M.ey.z = 0.0;\n M.ez.x = 0.0;\n M.ez.y = 0.0;\n M.ez.z = 0.0;\n }\n\n /**\n * Get the symmetric inverse of this matrix as a 3-by-3. Returns the zero matrix\n * if singular.\n */\n getSymInverse33(M: Mat33): void {\n let det = Vec3.dot(this.ex, Vec3.cross(this.ey, this.ez));\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const a11 = this.ex.x;\n const a12 = this.ey.x;\n const a13 = this.ez.x;\n const a22 = this.ey.y;\n const a23 = this.ez.y;\n const a33 = this.ez.z;\n\n M.ex.x = det * (a22 * a33 - a23 * a23);\n M.ex.y = det * (a13 * a23 - a12 * a33);\n M.ex.z = det * (a12 * a23 - a13 * a22);\n\n M.ey.x = M.ex.y;\n M.ey.y = det * (a11 * a33 - a13 * a13);\n M.ey.z = det * (a13 * a12 - a11 * a23);\n\n M.ez.x = M.ex.z;\n M.ez.y = M.ey.z;\n M.ez.z = det * (a11 * a22 - a12 * a12);\n }\n\n /**\n * Multiply a matrix times a vector.\n */\n static mul(a: Mat33, b: Vec2Value): Vec2;\n static mul(a: Mat33, b: Vec3Value): Vec3;\n static mul(a, b) {\n if (_ASSERT) Mat33.assert(a);\n if (b && \"z\" in b && \"y\" in b && \"x\" in b) {\n if (_ASSERT) Vec3.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y + a.ez.x * b.z;\n const y = a.ex.y * b.x + a.ey.y * b.y + a.ez.y * b.z;\n const z = a.ex.z * b.x + a.ey.z * b.y + a.ez.z * b.z;\n return new Vec3(x, y, z);\n\n } else if (b && \"y\" in b && \"x\" in b) {\n if (_ASSERT) Vec2.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y;\n const y = a.ex.y * b.x + a.ey.y * b.y;\n return Vec2.neo(x, y);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulVec3(a: Mat33, b: Vec3Value): Vec3 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Vec3.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y + a.ez.x * b.z;\n const y = a.ex.y * b.x + a.ey.y * b.y + a.ez.y * b.z;\n const z = a.ex.z * b.x + a.ey.z * b.y + a.ez.z * b.z;\n return new Vec3(x, y, z);\n }\n\n static mulVec2(a: Mat33, b: Vec2Value): Vec2 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y;\n const y = a.ex.y * b.x + a.ey.y * b.y;\n return Vec2.neo(x, y);\n }\n\n static add(a: Mat33, b: Mat33): Mat33 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Mat33.assert(b);\n return new Mat33(\n Vec3.add(a.ex, b.ex),\n Vec3.add(a.ey, b.ey),\n Vec3.add(a.ez, b.ez)\n );\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n\n\n// todo: use string?\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3,\n} \n\n/**\n * Revolute joint definition. This requires defining an anchor point where the\n * bodies are joined. The definition uses local anchor points so that the\n * initial configuration can violate the constraint slightly. You also need to\n * specify the initial relative angle for joint limits. This helps when saving\n * and loading a game.\n *\n * The local anchor points are measured from the body's origin rather than the\n * center of mass because: 1. you might not know where the center of mass will\n * be. 2. if you add/remove shapes from a body and recompute the mass, the\n * joints will be broken.\n */\nexport interface RevoluteJointOpt extends JointOpt {\n /**\n * The lower angle for the joint limit (radians).\n */\n lowerAngle?: number;\n /**\n * The upper angle for the joint limit (radians).\n */\n upperAngle?: number;\n /**\n * The maximum motor torque used to achieve the desired motor speed. Usually\n * in N-m.\n */\n maxMotorTorque?: number;\n /**\n * The desired motor speed. Usually in radians per second.\n */\n motorSpeed?: number;\n /**\n * A flag to enable joint limits.\n */\n enableLimit?: boolean;\n /**\n * A flag to enable the joint motor.\n */\n enableMotor?: boolean;\n}\n\n/**\n * Revolute joint definition. This requires defining an anchor point where the\n * bodies are joined. The definition uses local anchor points so that the\n * initial configuration can violate the constraint slightly. You also need to\n * specify the initial relative angle for joint limits. This helps when saving\n * and loading a game.\n *\n * The local anchor points are measured from the body's origin rather than the\n * center of mass because: 1. you might not know where the center of mass will\n * be. 2. if you add/remove shapes from a body and recompute the mass, the\n * joints will be broken.\n */\nexport interface RevoluteJointDef extends JointDef, RevoluteJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The bodyB angle minus bodyA angle in the reference state (radians).\n */\n referenceAngle?: number;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n lowerAngle : 0.0,\n upperAngle : 0.0,\n maxMotorTorque : 0.0,\n motorSpeed : 0.0,\n enableLimit : false,\n enableMotor : false\n};\n\ndeclare module \"./RevoluteJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RevoluteJoint(def: RevoluteJointDef): RevoluteJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RevoluteJoint(def: RevoluteJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): RevoluteJoint;\n}\n\n/**\n * A revolute joint constrains two bodies to share a common point while they are\n * free to rotate about the point. The relative rotation about the shared point\n * is the joint angle. You can limit the relative rotation with a joint limit\n * that specifies a lower and upper angle. You can use a motor to drive the\n * relative rotation about the shared point. A maximum motor torque is provided\n * so that infinite forces are not generated.\n */\n// @ts-expect-error\nexport class RevoluteJoint extends Joint {\n static TYPE = \"revolute-joint\" as const;\n\n /** @internal */ m_type: \"revolute-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngle: number;\n /** @internal */ m_impulse: Vec3;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_lowerAngle: number;\n /** @internal */ m_upperAngle: number;\n /** @internal */ m_maxMotorTorque: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableLimit: boolean;\n /** @internal */ m_enableMotor: boolean;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n // effective mass for point-to-point constraint.\n /** @internal */ m_mass: Mat33;\n // effective mass for motor/limit angular constraint.\n /** @internal */ m_motorMass: number;\n /** @internal */ m_limitState: number;\n\n constructor(def: RevoluteJointDef);\n constructor(def: RevoluteJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: RevoluteJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof RevoluteJoint)) {\n return new RevoluteJoint(def, bodyA, bodyB, anchor);\n }\n\n def = def ?? {} as RevoluteJointDef;\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_mass = new Mat33();\n this.m_limitState = LimitState.inactiveLimit;\n\n this.m_type = RevoluteJoint.TYPE;\n\n if (Vec2.isValid(anchor)) {\n this.m_localAnchorA = bodyA.getLocalPoint(anchor);\n } else if (Vec2.isValid(def.localAnchorA)) {\n this.m_localAnchorA = Vec2.clone(def.localAnchorA);\n } else {\n this.m_localAnchorA = Vec2.zero();\n }\n\n if (Vec2.isValid(anchor)) {\n this.m_localAnchorB = bodyB.getLocalPoint(anchor);\n } else if (Vec2.isValid(def.localAnchorB)) {\n this.m_localAnchorB = Vec2.clone(def.localAnchorB);\n } else {\n this.m_localAnchorB = Vec2.zero();\n }\n\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n } else {\n this.m_referenceAngle = bodyB.getAngle() - bodyA.getAngle();\n }\n\n this.m_impulse = new Vec3();\n this.m_motorImpulse = 0.0;\n\n this.m_lowerAngle = def.lowerAngle ?? DEFAULTS.lowerAngle;\n this.m_upperAngle = def.upperAngle ?? DEFAULTS.upperAngle;\n this.m_maxMotorTorque = def.maxMotorTorque ?? DEFAULTS.maxMotorTorque;\n this.m_motorSpeed = def.motorSpeed ?? DEFAULTS.motorSpeed;\n this.m_enableLimit = def.enableLimit ?? DEFAULTS.enableLimit;\n this.m_enableMotor = def.enableMotor ?? DEFAULTS.enableMotor;\n\n // Point-to-point constraint\n // C = p2 - p1\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Motor constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n lowerAngle: this.m_lowerAngle,\n upperAngle: this.m_upperAngle,\n maxMotorTorque: this.m_maxMotorTorque,\n motorSpeed: this.m_motorSpeed,\n enableLimit: this.m_enableLimit,\n enableMotor: this.m_enableMotor,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any):RevoluteJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new RevoluteJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n }\n if (def.enableLimit !== undefined) {\n this.m_enableLimit = def.enableLimit;\n }\n if (Number.isFinite(def.lowerAngle)) {\n this.m_lowerAngle = def.lowerAngle;\n }\n if (Number.isFinite(def.upperAngle)) {\n this.m_upperAngle = def.upperAngle;\n }\n if (Number.isFinite(def.maxMotorTorque)) {\n this.m_maxMotorTorque = def.maxMotorTorque;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n if (def.enableMotor !== undefined) {\n this.m_enableMotor = def.enableMotor;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Get the current joint angle in radians.\n */\n getJointAngle(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n return bB.m_sweep.a - bA.m_sweep.a - this.m_referenceAngle;\n }\n\n /**\n * Get the current joint angle speed in radians per second.\n */\n getJointSpeed(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n return bB.m_angularVelocity - bA.m_angularVelocity;\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Get the current motor torque given the inverse time step. Unit is N*m.\n */\n getMotorTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Set the motor speed in radians per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Get the motor speed in radians per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Set the maximum motor torque, usually in N-m.\n */\n setMaxMotorTorque(torque: number): void {\n if (torque == this.m_maxMotorTorque) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorTorque = torque;\n }\n\n getMaxMotorTorque(): number {\n return this.m_maxMotorTorque;\n }\n\n /**\n * Is the joint limit enabled?\n */\n isLimitEnabled(): boolean {\n return this.m_enableLimit;\n }\n\n /**\n * Enable/disable the joint limit.\n */\n enableLimit(flag: boolean): void {\n if (flag != this.m_enableLimit) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableLimit = flag;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Get the lower joint limit in radians.\n */\n getLowerLimit(): number {\n return this.m_lowerAngle;\n }\n\n /**\n * Get the upper joint limit in radians.\n */\n getUpperLimit(): number {\n return this.m_upperAngle;\n }\n\n /**\n * Set the joint limits in radians.\n */\n setLimits(lower: number, upper: number): void {\n if (_ASSERT) console.assert(lower <= upper);\n\n if (lower != this.m_lowerAngle || upper != this.m_upperAngle) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_impulse.z = 0.0;\n this.m_lowerAngle = lower;\n this.m_upperAngle = upper;\n }\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force given the inverse time step. Unit is N.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.neo(this.m_impulse.x, this.m_impulse.y).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque due to the joint limit given the inverse time step.\n * Unit is N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.z;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const fixedRotation = (iA + iB === 0.0);\n\n this.m_mass.ex.x = mA + mB + this.m_rA.y * this.m_rA.y * iA + this.m_rB.y * this.m_rB.y * iB;\n this.m_mass.ey.x = -this.m_rA.y * this.m_rA.x * iA - this.m_rB.y * this.m_rB.x * iB;\n this.m_mass.ez.x = -this.m_rA.y * iA - this.m_rB.y * iB;\n this.m_mass.ex.y = this.m_mass.ey.x;\n this.m_mass.ey.y = mA + mB + this.m_rA.x * this.m_rA.x * iA + this.m_rB.x * this.m_rB.x * iB;\n this.m_mass.ez.y = this.m_rA.x * iA + this.m_rB.x * iB;\n this.m_mass.ex.z = this.m_mass.ez.x;\n this.m_mass.ey.z = this.m_mass.ez.y;\n this.m_mass.ez.z = iA + iB;\n\n this.m_motorMass = iA + iB;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n\n if (this.m_enableMotor == false || fixedRotation) {\n this.m_motorImpulse = 0.0;\n }\n\n if (this.m_enableLimit && fixedRotation == false) {\n const jointAngle = aB - aA - this.m_referenceAngle;\n\n if (math_abs(this.m_upperAngle - this.m_lowerAngle) < 2.0 * Settings.angularSlop) {\n this.m_limitState = LimitState.equalLimits;\n\n } else if (jointAngle <= this.m_lowerAngle) {\n if (this.m_limitState != LimitState.atLowerLimit) {\n this.m_impulse.z = 0.0;\n }\n this.m_limitState = LimitState.atLowerLimit;\n\n } else if (jointAngle >= this.m_upperAngle) {\n if (this.m_limitState != LimitState.atUpperLimit) {\n this.m_impulse.z = 0.0;\n }\n this.m_limitState = LimitState.atUpperLimit;\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_impulse.mul(step.dtRatio);\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_impulse.x, this.m_impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_motorImpulse + this.m_impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_motorImpulse + this.m_impulse.z);\n\n } else {\n this.m_impulse.setZero();\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const fixedRotation = (iA + iB === 0.0);\n\n // Solve motor constraint.\n if (this.m_enableMotor && this.m_limitState != LimitState.equalLimits && fixedRotation == false) {\n const Cdot = wB - wA - this.m_motorSpeed;\n let impulse = -this.m_motorMass * Cdot;\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorTorque;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve limit constraint.\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit && fixedRotation == false) {\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const Cdot2 = wB - wA;\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const impulse = Vec3.neg(this.m_mass.solve33(Cdot));\n\n if (this.m_limitState == LimitState.equalLimits) {\n this.m_impulse.add(impulse);\n\n } else if (this.m_limitState == LimitState.atLowerLimit) {\n const newImpulse = this.m_impulse.z + impulse.z;\n\n if (newImpulse < 0.0) {\n const rhs = Vec2.combine(-1, Cdot1, this.m_impulse.z, Vec2.neo(this.m_mass.ez.x, this.m_mass.ez.y));\n const reduced = this.m_mass.solve22(rhs);\n impulse.x = reduced.x;\n impulse.y = reduced.y;\n impulse.z = -this.m_impulse.z;\n this.m_impulse.x += reduced.x;\n this.m_impulse.y += reduced.y;\n this.m_impulse.z = 0.0;\n\n } else {\n this.m_impulse.add(impulse);\n }\n\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n const newImpulse = this.m_impulse.z + impulse.z;\n\n if (newImpulse > 0.0) {\n const rhs = Vec2.combine(-1, Cdot1, this.m_impulse.z, Vec2.neo(this.m_mass.ez.x, this.m_mass.ez.y));\n const reduced = this.m_mass.solve22(rhs);\n impulse.x = reduced.x;\n impulse.y = reduced.y;\n impulse.z = -this.m_impulse.z;\n this.m_impulse.x += reduced.x;\n this.m_impulse.y += reduced.y;\n this.m_impulse.z = 0.0;\n\n } else {\n this.m_impulse.add(impulse);\n }\n }\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + impulse.z);\n\n } else {\n // Solve point-to-point constraint\n const Cdot = Vec2.zero();\n Cdot.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const impulse = this.m_mass.solve22(Vec2.neg(Cdot));\n\n this.m_impulse.x += impulse.x;\n this.m_impulse.y += impulse.y;\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n let angularError = 0.0;\n let positionError = 0.0;\n\n const fixedRotation = (this.m_invIA + this.m_invIB == 0.0);\n\n // Solve angular limit constraint.\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit && fixedRotation == false) {\n const angle = aB - aA - this.m_referenceAngle;\n let limitImpulse = 0.0;\n\n if (this.m_limitState == LimitState.equalLimits) {\n // Prevent large angular corrections\n const C = clamp(angle - this.m_lowerAngle, -Settings.maxAngularCorrection, Settings.maxAngularCorrection);\n limitImpulse = -this.m_motorMass * C;\n angularError = math_abs(C);\n\n } else if (this.m_limitState == LimitState.atLowerLimit) {\n let C = angle - this.m_lowerAngle;\n angularError = -C;\n\n // Prevent large angular corrections and allow some slop.\n C = clamp(C + Settings.angularSlop, -Settings.maxAngularCorrection, 0.0);\n limitImpulse = -this.m_motorMass * C;\n\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n let C = angle - this.m_upperAngle;\n angularError = C;\n\n // Prevent large angular corrections and allow some slop.\n C = clamp(C - Settings.angularSlop, 0.0, Settings.maxAngularCorrection);\n limitImpulse = -this.m_motorMass * C;\n }\n\n aA -= this.m_invIA * limitImpulse;\n aB += this.m_invIB * limitImpulse;\n }\n\n // Solve point-to-point constraint.\n {\n qA.setAngle(aA);\n qB.setAngle(aB);\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n const C = Vec2.zero();\n C.addCombine(1, cB, 1, rB);\n C.subCombine(1, cA, 1, rA);\n positionError = C.length();\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat22();\n K.ex.x = mA + mB + iA * rA.y * rA.y + iB * rB.y * rB.y;\n K.ex.y = -iA * rA.x * rA.y - iB * rB.x * rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * rA.x * rA.x + iB * rB.x * rB.x;\n\n const impulse = Vec2.neg(K.solve(C));\n\n cA.subMul(mA, impulse);\n aA -= iA * Vec2.crossVec2Vec2(rA, impulse);\n\n cB.addMul(mB, impulse);\n aB += iB * Vec2.crossVec2Vec2(rB, impulse);\n }\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return positionError <= Settings.linearSlop && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3, \n}\n\n/**\n * Prismatic joint definition. This requires defining a line of motion using an\n * axis and an anchor point. The definition uses local anchor points and a local\n * axis so that the initial configuration can violate the constraint slightly.\n * The joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface PrismaticJointOpt extends JointOpt {\n /**\n * Enable/disable the joint limit.\n */\n enableLimit?: boolean;\n /**\n * The lower translation limit, usually in meters.\n */\n lowerTranslation?: number;\n /**\n * The upper translation limit, usually in meters.\n */\n upperTranslation?: number;\n /**\n * Enable/disable the joint motor.\n */\n enableMotor?: boolean;\n /**\n * The maximum motor torque, usually in N-m.\n */\n maxMotorForce?: number;\n /**\n * The desired motor speed in radians per second.\n */\n motorSpeed?: number;\n}\n\n/**\n * Prismatic joint definition. This requires defining a line of motion using an\n * axis and an anchor point. The definition uses local anchor points and a local\n * axis so that the initial configuration can violate the constraint slightly.\n * The joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface PrismaticJointDef extends JointDef, PrismaticJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The local translation unit axis in bodyA.\n */\n localAxisA: Vec2Value;\n /**\n * referenceAngle The constrained angle between the bodies:\n * bodyB_angle - bodyA_angle.\n */\n referenceAngle?: number;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n enableLimit : false,\n lowerTranslation : 0.0,\n upperTranslation : 0.0,\n enableMotor : false,\n maxMotorForce : 0.0,\n motorSpeed : 0.0\n};\n\ndeclare module \"./PrismaticJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PrismaticJoint(def: PrismaticJointDef): PrismaticJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PrismaticJoint(def: PrismaticJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value, axis: Vec2Value): PrismaticJoint;\n}\n\n/**\n * A prismatic joint. This joint provides one degree of freedom: translation\n * along an axis fixed in bodyA. Relative rotation is prevented. You can use a\n * joint limit to restrict the range of motion and a joint motor to drive the\n * motion or to model joint friction.\n */\n// @ts-expect-error\nexport class PrismaticJoint extends Joint {\n static TYPE = \"prismatic-joint\" as const;\n\n /** @internal */ m_type: \"prismatic-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_localXAxisA: Vec2;\n /** @internal */ m_localYAxisA: Vec2;\n /** @internal */ m_referenceAngle: number;\n /** @internal */ m_impulse: Vec3;\n /** @internal */ m_motorMass: number;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_lowerTranslation: number;\n /** @internal */ m_upperTranslation: number;\n /** @internal */ m_maxMotorForce: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableLimit: boolean;\n /** @internal */ m_enableMotor: boolean;\n /** @internal */ m_limitState: number; // TODO enum\n /** @internal */ m_axis: Vec2;\n /** @internal */ m_perp: Vec2;\n // Solver temp\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_s1: number;\n /** @internal */ m_s2: number;\n /** @internal */ m_a1: number;\n /** @internal */ m_a2: number;\n /** @internal */ m_K: Mat33;\n\n constructor(def: PrismaticJointDef);\n constructor(def: PrismaticJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value, axis?: Vec2Value);\n constructor(def: PrismaticJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value, axis?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PrismaticJoint)) {\n return new PrismaticJoint(def, bodyA, bodyB, anchor, axis);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = PrismaticJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n this.m_localXAxisA = Vec2.clone(axis ? bodyA.getLocalVector(axis) : def.localAxisA || Vec2.neo(1.0, 0.0));\n this.m_localXAxisA.normalize();\n this.m_localYAxisA = Vec2.crossNumVec2(1.0, this.m_localXAxisA);\n this.m_referenceAngle = Number.isFinite(def.referenceAngle) ? def.referenceAngle : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_impulse = new Vec3();\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n\n this.m_lowerTranslation = def.lowerTranslation;\n this.m_upperTranslation = def.upperTranslation;\n this.m_maxMotorForce = def.maxMotorForce;\n this.m_motorSpeed = def.motorSpeed;\n this.m_enableLimit = def.enableLimit;\n this.m_enableMotor = def.enableMotor;\n this.m_limitState = LimitState.inactiveLimit;\n\n this.m_axis = Vec2.zero();\n this.m_perp = Vec2.zero();\n\n this.m_K = new Mat33();\n\n // Linear constraint (point-to-line)\n // d = p2 - p1 = x2 + r2 - x1 - r1\n // C = dot(perp, d)\n // Cdot = dot(d, cross(w1, perp)) + dot(perp, v2 + cross(w2, r2) - v1 -\n // cross(w1, r1))\n // = -dot(perp, v1) - dot(cross(d + r1, perp), w1) + dot(perp, v2) +\n // dot(cross(r2, perp), v2)\n // J = [-perp, -cross(d + r1, perp), perp, cross(r2,perp)]\n //\n // Angular constraint\n // C = a2 - a1 + a_initial\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n //\n // K = J * invM * JT\n //\n // J = [-a -s1 a s2]\n // [0 -1 0 1]\n // a = perp\n // s1 = cross(d + r1, a) = cross(p2 - x1, a)\n // s2 = cross(r2, a) = cross(p2 - x2, a)\n\n // Motor/Limit linear constraint\n // C = dot(ax1, d)\n // Cdot = = -dot(ax1, v1) - dot(cross(d + r1, ax1), w1) + dot(ax1, v2) +\n // dot(cross(r2, ax1), v2)\n // J = [-ax1 -cross(d+r1,ax1) ax1 cross(r2,ax1)]\n\n // Block Solver\n // We develop a block solver that includes the joint limit. This makes the\n // limit stiff (inelastic) even\n // when the mass has poor distribution (leading to large torques about the\n // joint anchor points).\n //\n // The Jacobian has 3 rows:\n // J = [-uT -s1 uT s2] // linear\n // [0 -1 0 1] // angular\n // [-vT -a1 vT a2] // limit\n //\n // u = perp\n // v = axis\n // s1 = cross(d + r1, u), s2 = cross(r2, u)\n // a1 = cross(d + r1, v), a2 = cross(r2, v)\n\n // M * (v2 - v1) = JT * df\n // J * v2 = bias\n //\n // v2 = v1 + invM * JT * df\n // J * (v1 + invM * JT * df) = bias\n // K * df = bias - J * v1 = -Cdot\n // K = J * invM * JT\n // Cdot = J * v1 - bias\n //\n // Now solve for f2.\n // df = f2 - f1\n // K * (f2 - f1) = -Cdot\n // f2 = invK * (-Cdot) + f1\n //\n // Clamp accumulated limit impulse.\n // lower: f2(3) = max(f2(3), 0)\n // upper: f2(3) = min(f2(3), 0)\n //\n // Solve for correct f2(1:2)\n // K(1:2, 1:2) * f2(1:2) = -Cdot(1:2) - K(1:2,3) * f2(3) + K(1:2,1:3) * f1\n // = -Cdot(1:2) - K(1:2,3) * f2(3) + K(1:2,1:2) * f1(1:2) + K(1:2,3) * f1(3)\n // K(1:2, 1:2) * f2(1:2) = -Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3)) +\n // K(1:2,1:2) * f1(1:2)\n // f2(1:2) = invK(1:2,1:2) * (-Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3))) +\n // f1(1:2)\n //\n // Now compute impulse to be applied:\n // df = f2 - f1\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n lowerTranslation: this.m_lowerTranslation,\n upperTranslation: this.m_upperTranslation,\n maxMotorForce: this.m_maxMotorForce,\n motorSpeed: this.m_motorSpeed,\n enableLimit: this.m_enableLimit,\n enableMotor: this.m_enableMotor,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n localAxisA: this.m_localXAxisA,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): PrismaticJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.localAxisA = Vec2.clone(data.localAxisA);\n const joint = new PrismaticJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (def.localAxisA) {\n this.m_localXAxisA.setVec2(def.localAxisA);\n this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1.0, def.localAxisA));\n }\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n }\n if (typeof def.enableLimit !== \"undefined\") {\n this.m_enableLimit = !!def.enableLimit;\n }\n if (Number.isFinite(def.lowerTranslation)) {\n this.m_lowerTranslation = def.lowerTranslation;\n }\n if (Number.isFinite(def.upperTranslation)) {\n this.m_upperTranslation = def.upperTranslation;\n }\n if (typeof def.enableMotor !== \"undefined\") {\n this.m_enableMotor = !!def.enableMotor;\n }\n if (Number.isFinite(def.maxMotorForce)) {\n this.m_maxMotorForce = def.maxMotorForce;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * The local joint axis relative to bodyA.\n */\n getLocalAxisA(): Vec2 {\n return this.m_localXAxisA;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Get the current joint translation, usually in meters.\n */\n getJointTranslation(): number {\n const pA = this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n const pB = this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n const d = Vec2.sub(pB, pA);\n const axis = this.m_bodyA.getWorldVector(this.m_localXAxisA);\n\n const translation = Vec2.dot(d, axis);\n return translation;\n }\n\n /**\n * Get the current joint translation speed, usually in meters per second.\n */\n getJointSpeed(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n\n const rA = Rot.mulVec2(bA.m_xf.q, Vec2.sub(this.m_localAnchorA, bA.m_sweep.localCenter));\n const rB = Rot.mulVec2(bB.m_xf.q, Vec2.sub(this.m_localAnchorB, bB.m_sweep.localCenter));\n const p1 = Vec2.add(bA.m_sweep.c, rA);\n const p2 = Vec2.add(bB.m_sweep.c, rB);\n const d = Vec2.sub(p2, p1);\n const axis = Rot.mulVec2(bA.m_xf.q, this.m_localXAxisA);\n\n const vA = bA.m_linearVelocity;\n const vB = bB.m_linearVelocity;\n const wA = bA.m_angularVelocity;\n const wB = bB.m_angularVelocity;\n\n const speed = Vec2.dot(d, Vec2.crossNumVec2(wA, axis)) + Vec2.dot(axis, Vec2.sub(Vec2.addCrossNumVec2(vB, wB, rB), Vec2.addCrossNumVec2(vA, wA, rA)));\n return speed;\n }\n\n /**\n * Is the joint limit enabled?\n */\n isLimitEnabled(): boolean {\n return this.m_enableLimit;\n }\n\n /**\n * Enable/disable the joint limit.\n */\n enableLimit(flag: boolean): void {\n if (flag != this.m_enableLimit) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableLimit = flag;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Get the lower joint limit, usually in meters.\n */\n getLowerLimit(): number {\n return this.m_lowerTranslation;\n }\n\n /**\n * Get the upper joint limit, usually in meters.\n */\n getUpperLimit(): number {\n return this.m_upperTranslation;\n }\n\n /**\n * Set the joint limits, usually in meters.\n */\n setLimits(lower: number, upper: number): void {\n if (_ASSERT) console.assert(lower <= upper);\n if (lower != this.m_lowerTranslation || upper != this.m_upperTranslation) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_lowerTranslation = lower;\n this.m_upperTranslation = upper;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Set the motor speed, usually in meters per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Set the maximum motor force, usually in N.\n */\n setMaxMotorForce(force: number): void {\n if (force == this.m_maxMotorForce) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorForce = force;\n }\n\n getMaxMotorForce(): number {\n return this.m_maxMotorForce;\n }\n\n /**\n * Get the motor speed, usually in meters per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Get the current motor force given the inverse time step, usually in N.\n */\n getMotorForce(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.combine(this.m_impulse.x, this.m_perp, this.m_motorImpulse + this.m_impulse.z, this.m_axis).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.y;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective masses.\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Compute motor Jacobian and effective mass.\n {\n this.m_axis = Rot.mulVec2(qA, this.m_localXAxisA);\n this.m_a1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_axis);\n this.m_a2 = Vec2.crossVec2Vec2(rB, this.m_axis);\n\n this.m_motorMass = mA + mB + iA * this.m_a1 * this.m_a1 + iB * this.m_a2\n * this.m_a2;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n }\n\n // Prismatic constraint.\n {\n this.m_perp = Rot.mulVec2(qA, this.m_localYAxisA);\n\n this.m_s1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_perp);\n this.m_s2 = Vec2.crossVec2Vec2(rB, this.m_perp);\n\n const s1test = Vec2.crossVec2Vec2(rA, this.m_perp);\n\n const k11 = mA + mB + iA * this.m_s1 * this.m_s1 + iB * this.m_s2 * this.m_s2;\n const k12 = iA * this.m_s1 + iB * this.m_s2;\n const k13 = iA * this.m_s1 * this.m_a1 + iB * this.m_s2 * this.m_a2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n // For bodies with fixed rotation.\n k22 = 1.0;\n }\n const k23 = iA * this.m_a1 + iB * this.m_a2;\n const k33 = mA + mB + iA * this.m_a1 * this.m_a1 + iB * this.m_a2 * this.m_a2;\n\n this.m_K.ex.set(k11, k12, k13);\n this.m_K.ey.set(k12, k22, k23);\n this.m_K.ez.set(k13, k23, k33);\n }\n\n // Compute motor and limit terms.\n if (this.m_enableLimit) {\n\n const jointTranslation = Vec2.dot(this.m_axis, d);\n if (math_abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * Settings.linearSlop) {\n this.m_limitState = LimitState.equalLimits;\n\n } else if (jointTranslation <= this.m_lowerTranslation) {\n if (this.m_limitState != LimitState.atLowerLimit) {\n this.m_limitState = LimitState.atLowerLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else if (jointTranslation >= this.m_upperTranslation) {\n if (this.m_limitState != LimitState.atUpperLimit) {\n this.m_limitState = LimitState.atUpperLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n if (this.m_enableMotor == false) {\n this.m_motorImpulse = 0.0;\n }\n\n if (step.warmStarting) {\n // Account for variable time step.\n this.m_impulse.mul(step.dtRatio);\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.combine(this.m_impulse.x, this.m_perp, this.m_motorImpulse\n + this.m_impulse.z, this.m_axis);\n const LA = this.m_impulse.x * this.m_s1 + this.m_impulse.y\n + (this.m_motorImpulse + this.m_impulse.z) * this.m_a1;\n const LB = this.m_impulse.x * this.m_s2 + this.m_impulse.y\n + (this.m_motorImpulse + this.m_impulse.z) * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n } else {\n this.m_impulse.setZero();\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Solve linear motor constraint.\n if (this.m_enableMotor && this.m_limitState != LimitState.equalLimits) {\n const Cdot = Vec2.dot(this.m_axis, Vec2.sub(vB, vA)) + this.m_a2 * wB\n - this.m_a1 * wA;\n let impulse = this.m_motorMass * (this.m_motorSpeed - Cdot);\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorForce;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse,\n -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_axis);\n const LA = impulse * this.m_a1;\n const LB = impulse * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n const Cdot1 = Vec2.zero();\n Cdot1.x += Vec2.dot(this.m_perp, vB) + this.m_s2 * wB;\n Cdot1.x -= Vec2.dot(this.m_perp, vA) + this.m_s1 * wA;\n Cdot1.y = wB - wA;\n\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit) {\n // Solve prismatic and limit constraint in block form.\n let Cdot2 = 0;\n Cdot2 += Vec2.dot(this.m_axis, vB) + this.m_a2 * wB;\n Cdot2 -= Vec2.dot(this.m_axis, vA) + this.m_a1 * wA;\n\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const f1 = Vec3.clone(this.m_impulse);\n let df = this.m_K.solve33(Vec3.neg(Cdot));\n this.m_impulse.add(df);\n\n if (this.m_limitState == LimitState.atLowerLimit) {\n this.m_impulse.z = math_max(this.m_impulse.z, 0.0);\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n this.m_impulse.z = math_min(this.m_impulse.z, 0.0);\n }\n\n // f2(1:2) = invK(1:2,1:2) * (-Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3))) +\n // f1(1:2)\n const b = Vec2.combine(-1, Cdot1, -(this.m_impulse.z - f1.z), Vec2.neo(this.m_K.ez.x, this.m_K.ez.y));\n const f2r = Vec2.add(this.m_K.solve22(b), Vec2.neo(f1.x, f1.y));\n this.m_impulse.x = f2r.x;\n this.m_impulse.y = f2r.y;\n\n df = Vec3.sub(this.m_impulse, f1);\n\n const P = Vec2.combine(df.x, this.m_perp, df.z, this.m_axis);\n const LA = df.x * this.m_s1 + df.y + df.z * this.m_a1;\n const LB = df.x * this.m_s2 + df.y + df.z * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n } else {\n // Limit is inactive, just solve the prismatic constraint in block form.\n const df = this.m_K.solve22(Vec2.neg(Cdot1));\n this.m_impulse.x += df.x;\n this.m_impulse.y += df.y;\n\n const P = Vec2.mulNumVec2(df.x, this.m_perp);\n const LA = df.x * this.m_s1 + df.y;\n const LB = df.x * this.m_s2 + df.y;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Compute fresh Jacobians\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.sub(Vec2.add(cB, rB), Vec2.add(cA, rA));\n\n const axis = Rot.mulVec2(qA, this.m_localXAxisA);\n const a1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), axis);\n const a2 = Vec2.crossVec2Vec2(rB, axis);\n const perp = Rot.mulVec2(qA, this.m_localYAxisA);\n\n const s1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), perp);\n const s2 = Vec2.crossVec2Vec2(rB, perp);\n\n let impulse = new Vec3();\n const C1 = Vec2.zero();\n C1.x = Vec2.dot(perp, d);\n C1.y = aB - aA - this.m_referenceAngle;\n\n let linearError = math_abs(C1.x);\n const angularError = math_abs(C1.y);\n\n const linearSlop = Settings.linearSlop;\n const maxLinearCorrection = Settings.maxLinearCorrection;\n\n let active = false; // bool\n let C2 = 0.0;\n if (this.m_enableLimit) {\n\n const translation = Vec2.dot(axis, d);\n if (math_abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * linearSlop) {\n // Prevent large angular corrections\n C2 = clamp(translation, -maxLinearCorrection, maxLinearCorrection);\n linearError = math_max(linearError, math_abs(translation));\n active = true;\n\n } else if (translation <= this.m_lowerTranslation) {\n // Prevent large linear corrections and allow some slop.\n C2 = clamp(translation - this.m_lowerTranslation + linearSlop,\n -maxLinearCorrection, 0.0);\n linearError = Math\n .max(linearError, this.m_lowerTranslation - translation);\n active = true;\n\n } else if (translation >= this.m_upperTranslation) {\n // Prevent large linear corrections and allow some slop.\n C2 = clamp(translation - this.m_upperTranslation - linearSlop, 0.0,\n maxLinearCorrection);\n linearError = Math\n .max(linearError, translation - this.m_upperTranslation);\n active = true;\n }\n }\n\n if (active) {\n const k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2;\n const k12 = iA * s1 + iB * s2;\n const k13 = iA * s1 * a1 + iB * s2 * a2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n // For fixed rotation\n k22 = 1.0;\n }\n const k23 = iA * a1 + iB * a2;\n const k33 = mA + mB + iA * a1 * a1 + iB * a2 * a2;\n\n const K = new Mat33();\n K.ex.set(k11, k12, k13);\n K.ey.set(k12, k22, k23);\n K.ez.set(k13, k23, k33);\n\n const C = new Vec3();\n C.x = C1.x;\n C.y = C1.y;\n C.z = C2;\n\n impulse = K.solve33(Vec3.neg(C));\n } else {\n const k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2;\n const k12 = iA * s1 + iB * s2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n k22 = 1.0;\n }\n\n const K = new Mat22();\n K.ex.setNum(k11, k12);\n K.ey.setNum(k12, k22);\n\n const impulse1 = K.solve(Vec2.neg(C1));\n impulse.x = impulse1.x;\n impulse.y = impulse1.y;\n impulse.z = 0.0;\n }\n\n const P = Vec2.combine(impulse.x, perp, impulse.z, axis);\n const LA = impulse.x * s1 + impulse.y + impulse.z * a1;\n const LB = impulse.x * s2 + impulse.y + impulse.z * a2;\n\n cA.subMul(mA, P);\n aA -= iA * LA;\n cB.addMul(mB, P);\n aB += iB * LB;\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return linearError <= Settings.linearSlop\n && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { } from \"../../common/Math\";\nimport { Vec2 } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { RevoluteJoint } from \"./RevoluteJoint\";\nimport { PrismaticJoint } from \"./PrismaticJoint\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Gear joint definition.\n */\nexport interface GearJointOpt extends JointOpt {\n /**\n * The gear ratio. See {@link GearJoint} for explanation.\n */\n ratio?: number;\n}\n\n/**\n * Gear joint definition.\n */\nexport interface GearJointDef extends JointDef, GearJointOpt {\n /**\n * The first revolute/prismatic joint attached to the gear joint.\n */\n joint1: RevoluteJoint | PrismaticJoint;\n /**\n * The second prismatic/revolute joint attached to the gear joint.\n */\n joint2: RevoluteJoint | PrismaticJoint;\n}\n\n/** @internal */ const DEFAULTS = {\n ratio : 1.0\n};\n\ndeclare module \"./GearJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function GearJoint(def: GearJointDef): GearJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function GearJoint(def: GearJointOpt, bodyA: Body, bodyB: Body, joint1: RevoluteJoint | PrismaticJoint, joint2: RevoluteJoint | PrismaticJoint, ratio?: number): GearJoint;\n}\n\n/**\n * A gear joint is used to connect two joints together. Either joint can be a\n * revolute or prismatic joint. You specify a gear ratio to bind the motions\n * together: coordinate1 + ratio * coordinate2 = constant\n *\n * The ratio can be negative or positive. If one joint is a revolute joint and\n * the other joint is a prismatic joint, then the ratio will have units of\n * length or units of 1/length. Warning: You have to manually destroy the gear\n * joint if joint1 or joint2 is destroyed.\n *\n * This definition requires two existing revolute or prismatic joints (any\n * combination will work).\n */\n// @ts-expect-error\nexport class GearJoint extends Joint {\n static TYPE = \"gear-joint\" as const;\n\n /** @internal */ m_type: \"gear-joint\";\n /** @internal */ m_joint1: RevoluteJoint | PrismaticJoint;\n /** @internal */ m_joint2: RevoluteJoint | PrismaticJoint;\n /** @internal */ m_type1: \"revolute-joint\" | \"prismatic-joint\";\n /** @internal */ m_type2: \"revolute-joint\" | \"prismatic-joint\";\n /** @internal */ m_bodyC: Body;\n /** @internal */ m_localAnchorC: Vec2;\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_referenceAngleA: number;\n /** @internal */ m_localAxisC: Vec2;\n /** @internal */ m_bodyD: Body;\n /** @internal */ m_localAnchorD: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngleB: number;\n /** @internal */ m_localAxisD: Vec2;\n /** @internal */ m_ratio: number;\n /** @internal */ m_constant: number;\n /** @internal */ m_impulse: number;\n\n // Solver temp\n /** @internal */ m_lcA: Vec2;\n /** @internal */ m_lcB: Vec2;\n /** @internal */ m_lcC: Vec2;\n /** @internal */ m_lcD: Vec2;\n /** @internal */ m_mA: number;\n /** @internal */ m_mB: number;\n /** @internal */ m_mC: number;\n /** @internal */ m_mD: number;\n /** @internal */ m_iA: number;\n /** @internal */ m_iB: number;\n /** @internal */ m_iC: number;\n /** @internal */ m_iD: number;\n /** @internal */ m_JvAC: Vec2;\n /** @internal */ m_JvBD: Vec2;\n /** @internal */ m_JwA: number;\n /** @internal */ m_JwB: number;\n /** @internal */ m_JwC: number;\n /** @internal */ m_JwD: number;\n /** @internal */ m_mass: number;\n\n constructor(def: GearJointDef);\n constructor(def: GearJointOpt, bodyA: Body, bodyB: Body, joint1: RevoluteJoint | PrismaticJoint, joint2: RevoluteJoint | PrismaticJoint, ratio?: number);\n constructor(def: GearJointDef, bodyA?: Body, bodyB?: Body, joint1?: RevoluteJoint | PrismaticJoint, joint2?: RevoluteJoint | PrismaticJoint, ratio?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof GearJoint)) {\n return new GearJoint(def, bodyA, bodyB, joint1, joint2, ratio);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = GearJoint.TYPE;\n\n if (_ASSERT) console.assert(joint1.m_type === RevoluteJoint.TYPE || joint1.m_type === PrismaticJoint.TYPE);\n if (_ASSERT) console.assert(joint2.m_type === RevoluteJoint.TYPE || joint2.m_type === PrismaticJoint.TYPE);\n\n this.m_joint1 = joint1 ? joint1 : def.joint1;\n this.m_joint2 = joint2 ? joint2 : def.joint2;\n this.m_ratio = Number.isFinite(ratio) ? ratio : def.ratio;\n\n this.m_type1 = this.m_joint1.getType() as \"revolute-joint\" | \"prismatic-joint\";\n this.m_type2 = this.m_joint2.getType() as \"revolute-joint\" | \"prismatic-joint\";\n\n // joint1 connects body A to body C\n // joint2 connects body B to body D\n\n let coordinateA: number;\n let coordinateB: number;\n\n // TODO_ERIN there might be some problem with the joint edges in Joint.\n\n this.m_bodyC = this.m_joint1.getBodyA();\n this.m_bodyA = this.m_joint1.getBodyB();\n\n // Get geometry of joint1\n const xfA = this.m_bodyA.m_xf;\n const aA = this.m_bodyA.m_sweep.a;\n const xfC = this.m_bodyC.m_xf;\n const aC = this.m_bodyC.m_sweep.a;\n\n if (this.m_type1 === RevoluteJoint.TYPE) {\n const revolute = this.m_joint1 as RevoluteJoint;\n this.m_localAnchorC = revolute.m_localAnchorA;\n this.m_localAnchorA = revolute.m_localAnchorB;\n this.m_referenceAngleA = revolute.m_referenceAngle;\n this.m_localAxisC = Vec2.zero();\n\n coordinateA = aA - aC - this.m_referenceAngleA;\n } else {\n const prismatic = this.m_joint1 as PrismaticJoint;\n this.m_localAnchorC = prismatic.m_localAnchorA;\n this.m_localAnchorA = prismatic.m_localAnchorB;\n this.m_referenceAngleA = prismatic.m_referenceAngle;\n this.m_localAxisC = prismatic.m_localXAxisA;\n\n const pC = this.m_localAnchorC;\n const pA = Rot.mulTVec2(xfC.q, Vec2.add(Rot.mulVec2(xfA.q, this.m_localAnchorA), Vec2.sub(xfA.p, xfC.p)));\n coordinateA = Vec2.dot(pA, this.m_localAxisC) - Vec2.dot(pC, this.m_localAxisC);\n }\n\n this.m_bodyD = this.m_joint2.getBodyA();\n this.m_bodyB = this.m_joint2.getBodyB();\n\n // Get geometry of joint2\n const xfB = this.m_bodyB.m_xf;\n const aB = this.m_bodyB.m_sweep.a;\n const xfD = this.m_bodyD.m_xf;\n const aD = this.m_bodyD.m_sweep.a;\n\n if (this.m_type2 === RevoluteJoint.TYPE) {\n const revolute = this.m_joint2 as RevoluteJoint;\n this.m_localAnchorD = revolute.m_localAnchorA;\n this.m_localAnchorB = revolute.m_localAnchorB;\n this.m_referenceAngleB = revolute.m_referenceAngle;\n this.m_localAxisD = Vec2.zero();\n\n coordinateB = aB - aD - this.m_referenceAngleB;\n } else {\n const prismatic = this.m_joint2 as PrismaticJoint;\n this.m_localAnchorD = prismatic.m_localAnchorA;\n this.m_localAnchorB = prismatic.m_localAnchorB;\n this.m_referenceAngleB = prismatic.m_referenceAngle;\n this.m_localAxisD = prismatic.m_localXAxisA;\n\n const pD = this.m_localAnchorD;\n const pB = Rot.mulTVec2(xfD.q, Vec2.add(Rot.mulVec2(xfB.q, this.m_localAnchorB), Vec2.sub(xfB.p, xfD.p)));\n coordinateB = Vec2.dot(pB, this.m_localAxisD) - Vec2.dot(pD, this.m_localAxisD);\n }\n\n this.m_constant = coordinateA + this.m_ratio * coordinateB;\n\n this.m_impulse = 0.0;\n\n // Gear Joint:\n // C0 = (coordinate1 + ratio * coordinate2)_initial\n // C = (coordinate1 + ratio * coordinate2) - C0 = 0\n // J = [J1 ratio * J2]\n // K = J * invM * JT\n // = J1 * invM1 * J1T + ratio * ratio * J2 * invM2 * J2T\n //\n // Revolute:\n // coordinate = rotation\n // Cdot = angularVelocity\n // J = [0 0 1]\n // K = J * invM * JT = invI\n //\n // Prismatic:\n // coordinate = dot(p - pg, ug)\n // Cdot = dot(v + cross(w, r), ug)\n // J = [ug cross(r, ug)]\n // K = J * invM * JT = invMass + invI * cross(r, ug)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n joint1: this.m_joint1,\n joint2: this.m_joint2,\n ratio: this.m_ratio,\n\n // _constant: this.m_constant,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): GearJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.joint1 = restore(Joint, data.joint1, world);\n data.joint2 = restore(Joint, data.joint2, world);\n const joint = new GearJoint(data);\n // if (data._constant) joint.m_constant = data._constant;\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n // todo: implement other fields\n if (Number.isFinite(def.ratio)) {\n this.m_ratio = def.ratio;\n }\n }\n\n /**\n * Get the first joint.\n */\n getJoint1(): Joint {\n return this.m_joint1;\n }\n\n /**\n * Get the second joint.\n */\n getJoint2(): Joint {\n return this.m_joint2;\n }\n\n /**\n * Set the gear ratio.\n */\n setRatio(ratio: number): void {\n if (_ASSERT) console.assert(Number.isFinite(ratio));\n this.m_ratio = ratio;\n }\n\n /**\n * Get the gear ratio.\n */\n getRatio(): number {\n return this.m_ratio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_JvAC).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n const L = this.m_impulse * this.m_JwA;\n return inv_dt * L;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_lcA = this.m_bodyA.m_sweep.localCenter;\n this.m_lcB = this.m_bodyB.m_sweep.localCenter;\n this.m_lcC = this.m_bodyC.m_sweep.localCenter;\n this.m_lcD = this.m_bodyD.m_sweep.localCenter;\n this.m_mA = this.m_bodyA.m_invMass;\n this.m_mB = this.m_bodyB.m_invMass;\n this.m_mC = this.m_bodyC.m_invMass;\n this.m_mD = this.m_bodyD.m_invMass;\n this.m_iA = this.m_bodyA.m_invI;\n this.m_iB = this.m_bodyB.m_invI;\n this.m_iC = this.m_bodyC.m_invI;\n this.m_iD = this.m_bodyD.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const aC = this.m_bodyC.c_position.a;\n const vC = this.m_bodyC.c_velocity.v;\n let wC = this.m_bodyC.c_velocity.w;\n\n const aD = this.m_bodyD.c_position.a;\n const vD = this.m_bodyD.c_velocity.v;\n let wD = this.m_bodyD.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n const qC = Rot.neo(aC);\n const qD = Rot.neo(aD);\n\n this.m_mass = 0.0;\n\n if (this.m_type1 == RevoluteJoint.TYPE) {\n this.m_JvAC = Vec2.zero();\n this.m_JwA = 1.0;\n this.m_JwC = 1.0;\n this.m_mass += this.m_iA + this.m_iC;\n } else {\n const u = Rot.mulVec2(qC, this.m_localAxisC);\n const rC = Rot.mulSub(qC, this.m_localAnchorC, this.m_lcC);\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_lcA);\n this.m_JvAC = u;\n this.m_JwC = Vec2.crossVec2Vec2(rC, u);\n this.m_JwA = Vec2.crossVec2Vec2(rA, u);\n this.m_mass += this.m_mC + this.m_mA + this.m_iC * this.m_JwC * this.m_JwC + this.m_iA * this.m_JwA * this.m_JwA;\n }\n\n if (this.m_type2 == RevoluteJoint.TYPE) {\n this.m_JvBD = Vec2.zero();\n this.m_JwB = this.m_ratio;\n this.m_JwD = this.m_ratio;\n this.m_mass += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD);\n } else {\n const u = Rot.mulVec2(qD, this.m_localAxisD);\n const rD = Rot.mulSub(qD, this.m_localAnchorD, this.m_lcD);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_lcB);\n this.m_JvBD = Vec2.mulNumVec2(this.m_ratio, u);\n this.m_JwD = this.m_ratio * Vec2.crossVec2Vec2(rD, u);\n this.m_JwB = this.m_ratio * Vec2.crossVec2Vec2(rB, u);\n this.m_mass += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * this.m_JwD * this.m_JwD + this.m_iB * this.m_JwB * this.m_JwB;\n }\n\n // Compute effective mass.\n this.m_mass = this.m_mass > 0.0 ? 1.0 / this.m_mass : 0.0;\n\n if (step.warmStarting) {\n vA.addMul(this.m_mA * this.m_impulse, this.m_JvAC);\n wA += this.m_iA * this.m_impulse * this.m_JwA;\n\n vB.addMul(this.m_mB * this.m_impulse, this.m_JvBD);\n wB += this.m_iB * this.m_impulse * this.m_JwB;\n\n vC.subMul(this.m_mC * this.m_impulse, this.m_JvAC);\n wC -= this.m_iC * this.m_impulse * this.m_JwC;\n\n vD.subMul(this.m_mD * this.m_impulse, this.m_JvBD);\n wD -= this.m_iD * this.m_impulse * this.m_JwD;\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n this.m_bodyC.c_velocity.v.setVec2(vC);\n this.m_bodyC.c_velocity.w = wC;\n this.m_bodyD.c_velocity.v.setVec2(vD);\n this.m_bodyD.c_velocity.w = wD;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n const vC = this.m_bodyC.c_velocity.v;\n let wC = this.m_bodyC.c_velocity.w;\n const vD = this.m_bodyD.c_velocity.v;\n let wD = this.m_bodyD.c_velocity.w;\n\n let Cdot = Vec2.dot(this.m_JvAC, vA) - Vec2.dot(this.m_JvAC, vC) + Vec2.dot(this.m_JvBD, vB) - Vec2.dot(this.m_JvBD, vD);\n Cdot += (this.m_JwA * wA - this.m_JwC * wC) + (this.m_JwB * wB - this.m_JwD * wD);\n\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n vA.addMul(this.m_mA * impulse, this.m_JvAC);\n wA += this.m_iA * impulse * this.m_JwA;\n vB.addMul(this.m_mB * impulse, this.m_JvBD);\n wB += this.m_iB * impulse * this.m_JwB;\n vC.subMul(this.m_mC * impulse, this.m_JvAC);\n wC -= this.m_iC * impulse * this.m_JwC;\n vD.subMul(this.m_mD * impulse, this.m_JvBD);\n wD -= this.m_iD * impulse * this.m_JwD;\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n this.m_bodyC.c_velocity.v.setVec2(vC);\n this.m_bodyC.c_velocity.w = wC;\n this.m_bodyD.c_velocity.v.setVec2(vD);\n this.m_bodyD.c_velocity.w = wD;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n const cC = this.m_bodyC.c_position.c;\n let aC = this.m_bodyC.c_position.a;\n const cD = this.m_bodyD.c_position.c;\n let aD = this.m_bodyD.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n const qC = Rot.neo(aC);\n const qD = Rot.neo(aD);\n\n const linearError = 0.0;\n\n let coordinateA: number;\n let coordinateB: number;\n\n let JvAC: Vec2;\n let JvBD: Vec2;\n let JwA: number;\n let JwB: number;\n let JwC: number;\n let JwD: number;\n let mass = 0.0;\n\n if (this.m_type1 == RevoluteJoint.TYPE) {\n JvAC = Vec2.zero();\n JwA = 1.0;\n JwC = 1.0;\n mass += this.m_iA + this.m_iC;\n\n coordinateA = aA - aC - this.m_referenceAngleA;\n } else {\n const u = Rot.mulVec2(qC, this.m_localAxisC);\n const rC = Rot.mulSub(qC, this.m_localAnchorC, this.m_lcC);\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_lcA);\n JvAC = u;\n JwC = Vec2.crossVec2Vec2(rC, u);\n JwA = Vec2.crossVec2Vec2(rA, u);\n mass += this.m_mC + this.m_mA + this.m_iC * JwC * JwC + this.m_iA * JwA * JwA;\n\n const pC = Vec2.sub(this.m_localAnchorC, this.m_lcC);\n const pA = Rot.mulTVec2(qC, Vec2.add(rA, Vec2.sub(cA, cC)));\n coordinateA = Vec2.dot(Vec2.sub(pA, pC), this.m_localAxisC);\n }\n\n if (this.m_type2 == RevoluteJoint.TYPE) {\n JvBD = Vec2.zero();\n JwB = this.m_ratio;\n JwD = this.m_ratio;\n mass += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD);\n\n coordinateB = aB - aD - this.m_referenceAngleB;\n } else {\n const u = Rot.mulVec2(qD, this.m_localAxisD);\n const rD = Rot.mulSub(qD, this.m_localAnchorD, this.m_lcD);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_lcB);\n JvBD = Vec2.mulNumVec2(this.m_ratio, u);\n JwD = this.m_ratio * Vec2.crossVec2Vec2(rD, u);\n JwB = this.m_ratio * Vec2.crossVec2Vec2(rB, u);\n mass += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * JwD * JwD + this.m_iB * JwB * JwB;\n\n const pD = Vec2.sub(this.m_localAnchorD, this.m_lcD);\n const pB = Rot.mulTVec2(qD, Vec2.add(rB, Vec2.sub(cB, cD)));\n coordinateB = Vec2.dot(pB, this.m_localAxisD) - Vec2.dot(pD, this.m_localAxisD);\n }\n\n const C = (coordinateA + this.m_ratio * coordinateB) - this.m_constant;\n\n let impulse = 0.0;\n if (mass > 0.0) {\n impulse = -C / mass;\n }\n\n cA.addMul(this.m_mA * impulse, JvAC);\n aA += this.m_iA * impulse * JwA;\n cB.addMul(this.m_mB * impulse, JvBD);\n aB += this.m_iB * impulse * JwB;\n cC.subMul(this.m_mC * impulse, JvAC);\n aC -= this.m_iC * impulse * JwC;\n cD.subMul(this.m_mD * impulse, JvBD);\n aD -= this.m_iD * impulse * JwD;\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n this.m_bodyC.c_position.c.setVec2(cC);\n this.m_bodyC.c_position.a = aC;\n this.m_bodyD.c_position.c.setVec2(cD);\n this.m_bodyD.c_position.a = aD;\n\n // TODO_ERIN not implemented\n return linearError < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Motor joint definition.\n */\nexport interface MotorJointOpt extends JointOpt {\n /**\n * The bodyB angle minus bodyA angle in radians.\n */\n angularOffset?: number;\n /**\n * The maximum motor force in N.\n */\n maxForce?: number;\n /**\n * The maximum motor torque in N-m.\n */\n maxTorque?: number;\n /**\n * Position correction factor in the range [0,1].\n */\n correctionFactor?: number;\n /**\n * Position of bodyB minus the position of bodyA, in bodyA's frame, in meters.\n */\n linearOffset?: Vec2Value;\n}\n\n/**\n * Motor joint definition.\n */\nexport interface MotorJointDef extends JointDef, MotorJointOpt {\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 1.0,\n maxTorque : 1.0,\n correctionFactor : 0.3\n};\n\ndeclare module \"./MotorJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MotorJoint(def: MotorJointDef): MotorJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MotorJoint(def: MotorJointOpt, bodyA: Body, bodyB: Body): MotorJoint;\n}\n\n/**\n * A motor joint is used to control the relative motion between two bodies. A\n * typical usage is to control the movement of a dynamic body with respect to\n * the ground.\n */\n// @ts-expect-error\nexport class MotorJoint extends Joint {\n static TYPE = \"motor-joint\" as const;\n\n /** @internal */ m_type: \"motor-joint\";\n /** @internal */ m_linearOffset: Vec2;\n /** @internal */ m_angularOffset: number;\n /** @internal */ m_linearImpulse: Vec2;\n /** @internal */ m_angularImpulse: number;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_maxTorque: number;\n /** @internal */ m_correctionFactor: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_linearError: Vec2;\n /** @internal */ m_angularError: number;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_linearMass: Mat22;\n /** @internal */ m_angularMass: number;\n\n constructor(def: MotorJointDef);\n constructor(def: MotorJointOpt, bodyA: Body, bodyB: Body);\n constructor(def: MotorJointDef | MotorJointOpt, bodyA?: Body, bodyB?: Body) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof MotorJoint)) {\n return new MotorJoint(def, bodyA, bodyB);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = MotorJoint.TYPE;\n\n this.m_linearOffset = Vec2.isValid(def.linearOffset) ? Vec2.clone(def.linearOffset) : bodyA.getLocalPoint(bodyB.getPosition());\n this.m_angularOffset = Number.isFinite(def.angularOffset) ? def.angularOffset : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_linearImpulse = Vec2.zero();\n this.m_angularImpulse = 0.0;\n\n this.m_maxForce = def.maxForce;\n this.m_maxTorque = def.maxTorque;\n this.m_correctionFactor = def.correctionFactor;\n\n // Point-to-point constraint\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n //\n // r1 = offset - c1\n // r2 = -c2\n\n // Angle constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n maxForce: this.m_maxForce,\n maxTorque: this.m_maxTorque,\n correctionFactor: this.m_correctionFactor,\n\n linearOffset: this.m_linearOffset,\n angularOffset: this.m_angularOffset,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): MotorJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new MotorJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.angularOffset)) {\n this.m_angularOffset = def.angularOffset;\n }\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.maxTorque)) {\n this.m_maxTorque = def.maxTorque;\n }\n if (Number.isFinite(def.correctionFactor)) {\n this.m_correctionFactor = def.correctionFactor;\n }\n if (Vec2.isValid(def.linearOffset)) {\n this.m_linearOffset.set(def.linearOffset); \n }\n }\n\n /**\n * Set the maximum friction force in N.\n */\n setMaxForce(force: number): void {\n if (_ASSERT) console.assert(Number.isFinite(force) && force >= 0.0);\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum friction force in N.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the maximum friction torque in N*m.\n */\n setMaxTorque(torque: number): void {\n if (_ASSERT) console.assert(Number.isFinite(torque) && torque >= 0.0);\n this.m_maxTorque = torque;\n }\n\n /**\n * Get the maximum friction torque in N*m.\n */\n getMaxTorque(): number {\n return this.m_maxTorque;\n }\n\n /**\n * Set the position correction factor in the range [0,1].\n */\n setCorrectionFactor(factor: number): void {\n if (_ASSERT) console.assert(Number.isFinite(factor) && 0.0 <= factor && factor <= 1.0);\n this.m_correctionFactor = factor;\n }\n\n /**\n * Get the position correction factor in the range [0,1].\n */\n getCorrectionFactor(): number {\n return this.m_correctionFactor;\n }\n\n /**\n * Set/get the target linear offset, in frame A, in meters.\n */\n setLinearOffset(linearOffset: Vec2Value): void {\n if (linearOffset.x != this.m_linearOffset.x || linearOffset.y != this.m_linearOffset.y) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_linearOffset.set(linearOffset);\n }\n }\n\n getLinearOffset(): Vec2 {\n return this.m_linearOffset;\n }\n\n /**\n * Set/get the target angular offset, in radians.\n */\n setAngularOffset(angularOffset: number): void {\n if (angularOffset != this.m_angularOffset) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_angularOffset = angularOffset;\n }\n }\n\n getAngularOffset(): number {\n return this.m_angularOffset;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getPosition();\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getPosition();\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_linearImpulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_angularImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective mass matrix.\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_linearOffset, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.neg(this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Upper 2 by 2 of K for point to point\n const K = new Mat22();\n K.ex.x = mA + mB + iA * this.m_rA.y * this.m_rA.y + iB * this.m_rB.y * this.m_rB.y;\n K.ex.y = -iA * this.m_rA.x * this.m_rA.y - iB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * this.m_rA.x * this.m_rA.x + iB * this.m_rB.x * this.m_rB.x;\n\n this.m_linearMass = K.getInverse();\n\n this.m_angularMass = iA + iB;\n if (this.m_angularMass > 0.0) {\n this.m_angularMass = 1.0 / this.m_angularMass;\n }\n\n this.m_linearError = Vec2.zero();\n this.m_linearError.addCombine(1, cB, 1, this.m_rB);\n this.m_linearError.subCombine(1, cA, 1, this.m_rA);\n\n this.m_angularError = aB - aA - this.m_angularOffset;\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_linearImpulse.mul(step.dtRatio);\n this.m_angularImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_linearImpulse.x, this.m_linearImpulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_angularImpulse);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_angularImpulse);\n\n } else {\n this.m_linearImpulse.setZero();\n this.m_angularImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const h = step.dt;\n const inv_h = step.inv_dt;\n\n // Solve angular friction\n {\n const Cdot = wB - wA + inv_h * this.m_correctionFactor * this.m_angularError;\n let impulse = -this.m_angularMass * Cdot;\n\n const oldImpulse = this.m_angularImpulse;\n const maxImpulse = h * this.m_maxTorque;\n this.m_angularImpulse = clamp(this.m_angularImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_angularImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve linear friction\n {\n const Cdot = Vec2.zero();\n Cdot.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n Cdot.addMul(inv_h * this.m_correctionFactor, this.m_linearError);\n\n let impulse = Vec2.neg(Mat22.mulVec2(this.m_linearMass, Cdot));\n const oldImpulse = Vec2.clone(this.m_linearImpulse);\n this.m_linearImpulse.add(impulse);\n\n const maxImpulse = h * this.m_maxForce;\n\n this.m_linearImpulse.clamp(maxImpulse);\n\n impulse = Vec2.sub(this.m_linearImpulse, oldImpulse);\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Transform } from \"../../common/Transform\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Mouse joint definition. This requires a world target point, tuning\n * parameters, and the time step.\n */\nexport interface MouseJointOpt extends JointOpt {\n /**\n * [maxForce = 0.0] The maximum constraint force that can be exerted to move\n * the candidate body. Usually you will express as some multiple of the\n * weight (multiplier * mass * gravity).\n */\n maxForce?: number;\n /**\n * [frequencyHz = 5.0] The response speed.\n */\n frequencyHz?: number;\n /**\n * [dampingRatio = 0.7] The damping ratio. 0 = no damping, 1 = critical\n * damping.\n */\n dampingRatio?: number;\n}\n\n/**\n * Mouse joint definition. This requires a world target point, tuning\n * parameters, and the time step.\n */\nexport interface MouseJointDef extends JointDef, MouseJointOpt {\n /**\n * The initial world target point. This is assumed to coincide with the body\n * anchor initially.\n */\n target: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 0.0,\n frequencyHz : 5.0,\n dampingRatio : 0.7\n};\n\ndeclare module \"./MouseJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MouseJoint(def: MouseJointDef): MouseJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MouseJoint(def: MouseJointOpt, bodyA: Body, bodyB: Body, target: Vec2Value): MouseJoint;\n}\n\n/**\n * A mouse joint is used to make a point on a body track a specified world\n * point. This a soft constraint with a maximum force. This allows the\n * constraint to stretch and without applying huge forces.\n *\n * You need to call setTarget(target) every time that mouse is \n * moved, to track the new location of the mouse.\n *\n * NOTE: this joint is not documented in the manual because it was developed to\n * be used in the testbed. If you want to learn how to use the mouse joint, look\n * at the testbed.\n */\n// @ts-expect-error\nexport class MouseJoint extends Joint {\n static TYPE = \"mouse-joint\" as const;\n\n /** @internal */ m_type: \"mouse-joint\";\n /** @internal */ m_targetA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_impulse: Vec2;\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n /** @internal */ m_beta: number;\n /** @internal */ m_gamma: number;\n // Solver temp\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: Mat22;\n /** @internal */ m_C: Vec2;\n\n constructor(def: MouseJointDef);\n constructor(def: MouseJointOpt, bodyA: Body, bodyB: Body, target?: Vec2Value);\n constructor(def: MouseJointDef, bodyA?: Body, bodyB?: Body, target?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof MouseJoint)) {\n return new MouseJoint(def, bodyA, bodyB, target);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = MouseJoint.TYPE;\n\n if (_ASSERT) console.assert(Number.isFinite(def.maxForce) && def.maxForce >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.frequencyHz) && def.frequencyHz >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.dampingRatio) && def.dampingRatio >= 0.0);\n\n if (Vec2.isValid(target)) {\n this.m_targetA = Vec2.clone(target);\n } else if (Vec2.isValid(def.target)) {\n this.m_targetA = Vec2.clone(def.target);\n } else {\n this.m_targetA = Vec2.zero();\n }\n\n this.m_localAnchorB = Transform.mulTVec2(bodyB.getTransform(), this.m_targetA);\n\n this.m_maxForce = def.maxForce;\n this.m_impulse = Vec2.zero();\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_beta = 0.0;\n this.m_gamma = 0.0;\n\n // Solver temp\n this.m_rB = Vec2.zero();\n this.m_localCenterB = Vec2.zero();\n this.m_invMassB = 0.0;\n this.m_invIB = 0.0;\n this.m_mass = new Mat22();\n this.m_C = Vec2.zero();\n\n // p = attached point, m = mouse point\n // C = p - m\n // Cdot = v\n // = v + cross(w, r)\n // J = [I r_skew]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n target: this.m_targetA,\n maxForce: this.m_maxForce,\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n _localAnchorB: this.m_localAnchorB,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): MouseJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.target = Vec2.clone(data.target);\n const joint = new MouseJoint(data);\n if (data._localAnchorB) {\n joint.m_localAnchorB = data._localAnchorB;\n }\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * Use this to update the target point.\n */\n setTarget(target: Vec2Value): void {\n if (Vec2.areEqual(target, this.m_targetA)) return;\n this.m_bodyB.setAwake(true);\n this.m_targetA.set(target);\n }\n\n getTarget(): Vec2 {\n return this.m_targetA;\n }\n\n /**\n * Set the maximum force in Newtons.\n */\n setMaxForce(force: number): void {\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum force in Newtons.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the frequency in Hertz.\n */\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n /**\n * Get the frequency in Hertz.\n */\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set the damping ratio (dimensionless).\n */\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n /**\n * Get the damping ratio (dimensionless).\n */\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return Vec2.clone(this.m_targetA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_impulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * 0.0;\n }\n\n /**\n * Shift the origin for any points stored in world coordinates.\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_targetA.sub(newOrigin);\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const position = this.m_bodyB.c_position;\n const velocity = this.m_bodyB.c_velocity;\n\n const cB = position.c;\n const aB = position.a;\n const vB = velocity.v;\n let wB = velocity.w;\n\n const qB = Rot.neo(aB);\n\n const mass = this.m_bodyB.getMass();\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * mass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = mass * (omega * omega);\n\n // magic formulas\n // gamma has units of inverse mass.\n // beta has units of inverse time.\n const h = step.dt;\n if (_ASSERT) console.assert(d + h * k > EPSILON);\n this.m_gamma = h * (d + h * k);\n if (this.m_gamma != 0.0) {\n this.m_gamma = 1.0 / this.m_gamma;\n }\n this.m_beta = h * k * this.m_gamma;\n\n // Compute the effective mass matrix.\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // K = [(1/m1 + 1/m2) * eye(2) - skew(r1) * invI1 * skew(r1) - skew(r2) *\n // invI2 * skew(r2)]\n // = [1/m1+1/m2 0 ] + invI1 * [r1.y*r1.y -r1.x*r1.y] + invI2 * [r1.y*r1.y\n // -r1.x*r1.y]\n // [ 0 1/m1+1/m2] [-r1.x*r1.y r1.x*r1.x] [-r1.x*r1.y r1.x*r1.x]\n const K = new Mat22();\n K.ex.x = this.m_invMassB + this.m_invIB * this.m_rB.y * this.m_rB.y\n + this.m_gamma;\n K.ex.y = -this.m_invIB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = this.m_invMassB + this.m_invIB * this.m_rB.x * this.m_rB.x\n + this.m_gamma;\n\n this.m_mass = K.getInverse();\n\n this.m_C.setVec2(cB);\n this.m_C.addCombine(1, this.m_rB, -1, this.m_targetA);\n this.m_C.mul(this.m_beta);\n\n // Cheat with some damping\n wB *= 0.98;\n\n if (step.warmStarting) {\n this.m_impulse.mul(step.dtRatio);\n vB.addMul(this.m_invMassB, this.m_impulse);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, this.m_impulse);\n\n } else {\n this.m_impulse.setZero();\n }\n\n velocity.v.setVec2(vB);\n velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const velocity = this.m_bodyB.c_velocity;\n const vB = Vec2.clone(velocity.v);\n let wB = velocity.w;\n\n // Cdot = v + cross(w, r)\n\n const Cdot = Vec2.crossNumVec2(wB, this.m_rB);\n Cdot.add(vB);\n\n Cdot.addCombine(1, this.m_C, this.m_gamma, this.m_impulse);\n Cdot.neg();\n\n let impulse = Mat22.mulVec2(this.m_mass, Cdot);\n\n const oldImpulse = Vec2.clone(this.m_impulse);\n this.m_impulse.add(impulse);\n const maxImpulse = step.dt * this.m_maxForce;\n this.m_impulse.clamp(maxImpulse);\n impulse = Vec2.sub(this.m_impulse, oldImpulse);\n\n vB.addMul(this.m_invMassB, impulse);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n\n velocity.v.setVec2(vB);\n velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n\n\n/**\n * Pulley joint definition. This requires two ground anchors, two dynamic body\n * anchor points, and a pulley ratio.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface PulleyJointOpt extends JointOpt {\n}\n\n/**\n * Pulley joint definition. This requires two ground anchors, two dynamic body\n * anchor points, and a pulley ratio.\n */\nexport interface PulleyJointDef extends JointDef, PulleyJointOpt {\n /**\n * The first ground anchor in world coordinates. This point never moves.\n */\n groundAnchorA: Vec2Value;\n /**\n * The second ground anchor in world coordinates. This point never moves.\n */\n groundAnchorB: Vec2Value;\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The reference length for the segment attached to bodyA.\n */\n lengthA: number;\n /**\n * The reference length for the segment attached to bodyB.\n */\n lengthB: number;\n /**\n * The pulley ratio, used to simulate a block-and-tackle.\n */\n ratio: number;\n\n /** @hidden */ anchorA?: Vec2Value;\n /** @hidden */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n collideConnected : true\n};\n\ndeclare module \"./PulleyJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PulleyJoint(def: PulleyJointDef): PulleyJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PulleyJoint(def: PulleyJointOpt, bodyA: Body, bodyB: Body, groundA: Vec2Value, groundB: Vec2Value, anchorA: Vec2Value, anchorB: Vec2Value, ratio: number): PulleyJoint;\n}\n\n/**\n * The pulley joint is connected to two bodies and two fixed ground points. The\n * pulley supports a ratio such that: length1 + ratio * length2 <= constant\n *\n * Yes, the force transmitted is scaled by the ratio.\n *\n * Warning: the pulley joint can get a bit squirrelly by itself. They often work\n * better when combined with prismatic joints. You should also cover the the\n * anchor points with static shapes to prevent one side from going to zero\n * length.\n */\n// @ts-expect-error\nexport class PulleyJoint extends Joint {\n static TYPE = \"pulley-joint\" as const;\n // static MIN_PULLEY_LENGTH: number = 2.0; // TODO where this is used?\n\n /** @internal */ m_type: \"pulley-joint\";\n /** @internal */ m_groundAnchorA: Vec2;\n /** @internal */ m_groundAnchorB: Vec2;\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_lengthA: number;\n /** @internal */ m_lengthB: number;\n /** @internal */ m_ratio: number;\n /** @internal */ m_constant: number;\n /** @internal */ m_impulse: number;\n\n // Solver temp\n /** @internal */ m_uA: Vec2;\n /** @internal */ m_uB: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: number;\n\n constructor(def: PulleyJointDef);\n constructor(def: PulleyJointOpt, bodyA: Body, bodyB: Body, groundA?: Vec2Value, groundB?: Vec2Value, anchorA?: Vec2Value, anchorB?: Vec2Value, ratio?: number);\n constructor(def: PulleyJointDef, bodyA?: Body, bodyB?: Body, groundA?: Vec2Value, groundB?: Vec2Value, anchorA?: Vec2Value, anchorB?: Vec2Value, ratio?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PulleyJoint)) {\n return new PulleyJoint(def, bodyA, bodyB, groundA, groundB, anchorA, anchorB, ratio);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = PulleyJoint.TYPE;\n this.m_groundAnchorA = Vec2.clone(groundA ? groundA : def.groundAnchorA || Vec2.neo(-1.0, 1.0));\n this.m_groundAnchorB = Vec2.clone(groundB ? groundB : def.groundAnchorB || Vec2.neo(1.0, 1.0));\n this.m_localAnchorA = Vec2.clone(anchorA ? bodyA.getLocalPoint(anchorA) : def.localAnchorA || Vec2.neo(-1.0, 0.0));\n this.m_localAnchorB = Vec2.clone(anchorB ? bodyB.getLocalPoint(anchorB) : def.localAnchorB || Vec2.neo(1.0, 0.0));\n this.m_lengthA = Number.isFinite(def.lengthA) ? def.lengthA : Vec2.distance(anchorA, groundA);\n this.m_lengthB = Number.isFinite(def.lengthB) ? def.lengthB : Vec2.distance(anchorB, groundB);\n this.m_ratio = Number.isFinite(ratio) ? ratio : def.ratio;\n\n if (_ASSERT) console.assert(ratio > EPSILON);\n\n this.m_constant = this.m_lengthA + this.m_ratio * this.m_lengthB;\n\n this.m_impulse = 0.0;\n\n // Pulley:\n // length1 = norm(p1 - s1)\n // length2 = norm(p2 - s2)\n // C0 = (length1 + ratio * length2)_initial\n // C = C0 - (length1 + ratio * length2)\n // u1 = (p1 - s1) / norm(p1 - s1)\n // u2 = (p2 - s2) / norm(p2 - s2)\n // Cdot = -dot(u1, v1 + cross(w1, r1)) - ratio * dot(u2, v2 + cross(w2, r2))\n // J = -[u1 cross(r1, u1) ratio * u2 ratio * cross(r2, u2)]\n // K = J * invM * JT\n // = invMass1 + invI1 * cross(r1, u1)^2 + ratio^2 * (invMass2 + invI2 *\n // cross(r2, u2)^2)\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n groundAnchorA: this.m_groundAnchorA,\n groundAnchorB: this.m_groundAnchorB,\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n lengthA: this.m_lengthA,\n lengthB: this.m_lengthB,\n ratio: this.m_ratio,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): PulleyJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new PulleyJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Vec2.isValid(def.groundAnchorA)) {\n this.m_groundAnchorA.set(def.groundAnchorA);\n }\n if (Vec2.isValid(def.groundAnchorB)) {\n this.m_groundAnchorB.set(def.groundAnchorB);\n }\n if (Vec2.isValid(def.localAnchorA)) {\n this.m_localAnchorA.set(def.localAnchorA);\n } else if (Vec2.isValid(def.anchorA)) {\n this.m_localAnchorA.set(this.m_bodyA.getLocalPoint(def.anchorA));\n }\n if (Vec2.isValid(def.localAnchorB)) {\n this.m_localAnchorB.set(def.localAnchorB);\n } else if (Vec2.isValid(def.anchorB)) {\n this.m_localAnchorB.set(this.m_bodyB.getLocalPoint(def.anchorB));\n }\n if (Number.isFinite(def.lengthA)) {\n this.m_lengthA = def.lengthA;\n }\n if (Number.isFinite(def.lengthB)) {\n this.m_lengthB = def.lengthB;\n }\n if (Number.isFinite(def.ratio)) {\n this.m_ratio = def.ratio;\n }\n }\n\n /**\n * Get the first ground anchor.\n */\n getGroundAnchorA(): Vec2 {\n return this.m_groundAnchorA;\n }\n\n /**\n * Get the second ground anchor.\n */\n getGroundAnchorB(): Vec2 {\n return this.m_groundAnchorB;\n }\n\n /**\n * Get the current length of the segment attached to bodyA.\n */\n getLengthA(): number {\n return this.m_lengthA;\n }\n\n /**\n * Get the current length of the segment attached to bodyB.\n */\n getLengthB(): number {\n return this.m_lengthB;\n }\n\n /**\n * Get the pulley ratio.\n */\n getRatio(): number {\n return this.m_ratio;\n }\n\n /**\n * Get the current length of the segment attached to bodyA.\n */\n getCurrentLengthA(): number {\n const p = this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n const s = this.m_groundAnchorA;\n return Vec2.distance(p, s);\n }\n\n /**\n * Get the current length of the segment attached to bodyB.\n */\n getCurrentLengthB(): number {\n const p = this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n const s = this.m_groundAnchorB;\n return Vec2.distance(p, s);\n }\n\n /**\n * Shift the origin for any points stored in world coordinates.\n *\n * @param newOrigin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_groundAnchorA.sub(newOrigin);\n this.m_groundAnchorB.sub(newOrigin);\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_uB).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // Get the pulley axes.\n this.m_uA = Vec2.sub(Vec2.add(cA, this.m_rA), this.m_groundAnchorA);\n this.m_uB = Vec2.sub(Vec2.add(cB, this.m_rB), this.m_groundAnchorB);\n\n const lengthA = this.m_uA.length();\n const lengthB = this.m_uB.length();\n\n if (lengthA > 10.0 * Settings.linearSlop) {\n this.m_uA.mul(1.0 / lengthA);\n } else {\n this.m_uA.setZero();\n }\n\n if (lengthB > 10.0 * Settings.linearSlop) {\n this.m_uB.mul(1.0 / lengthB);\n } else {\n this.m_uB.setZero();\n }\n\n // Compute effective mass.\n const ruA = Vec2.crossVec2Vec2(this.m_rA, this.m_uA);\n const ruB = Vec2.crossVec2Vec2(this.m_rB, this.m_uB);\n\n const mA = this.m_invMassA + this.m_invIA * ruA * ruA;\n const mB = this.m_invMassB + this.m_invIB * ruB * ruB;\n\n this.m_mass = mA + this.m_ratio * this.m_ratio * mB;\n\n if (this.m_mass > 0.0) {\n this.m_mass = 1.0 / this.m_mass;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support variable time steps.\n this.m_impulse *= step.dtRatio;\n\n // Warm starting.\n const PA = Vec2.mulNumVec2(-this.m_impulse, this.m_uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * this.m_impulse, this.m_uB);\n\n vA.addMul(this.m_invMassA, PA);\n wA += this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, PA);\n\n vB.addMul(this.m_invMassB, PB);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, PB);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const vpA = Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA));\n const vpB = Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB));\n\n const Cdot = -Vec2.dot(this.m_uA, vpA) - this.m_ratio * Vec2.dot(this.m_uB, vpB);\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n const PA = Vec2.mulNumVec2(-impulse, this.m_uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * impulse, this.m_uB);\n vA.addMul(this.m_invMassA, PA);\n wA += this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, PA);\n vB.addMul(this.m_invMassB, PB);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, PB);\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // Get the pulley axes.\n const uA = Vec2.sub(Vec2.add(cA, this.m_rA), this.m_groundAnchorA);\n const uB = Vec2.sub(Vec2.add(cB, this.m_rB), this.m_groundAnchorB);\n\n const lengthA = uA.length();\n const lengthB = uB.length();\n\n if (lengthA > 10.0 * Settings.linearSlop) {\n uA.mul(1.0 / lengthA);\n } else {\n uA.setZero();\n }\n\n if (lengthB > 10.0 * Settings.linearSlop) {\n uB.mul(1.0 / lengthB);\n } else {\n uB.setZero();\n }\n\n // Compute effective mass.\n const ruA = Vec2.crossVec2Vec2(rA, uA);\n const ruB = Vec2.crossVec2Vec2(rB, uB);\n\n const mA = this.m_invMassA + this.m_invIA * ruA * ruA;\n const mB = this.m_invMassB + this.m_invIB * ruB * ruB;\n\n let mass = mA + this.m_ratio * this.m_ratio * mB;\n\n if (mass > 0.0) {\n mass = 1.0 / mass;\n }\n\n const C = this.m_constant - lengthA - this.m_ratio * lengthB;\n const linearError = math_abs(C);\n\n const impulse = -mass * C;\n\n const PA = Vec2.mulNumVec2(-impulse, uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * impulse, uB);\n\n cA.addMul(this.m_invMassA, PA);\n aA += this.m_invIA * Vec2.crossVec2Vec2(rA, PA);\n cB.addMul(this.m_invMassB, PB);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, PB);\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return linearError < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_min = Math.min;\n\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3,\n}\n\n/**\n * Rope joint definition. This requires two body anchor points and a maximum\n * lengths. Note: by default the connected objects will not collide. see\n * collideConnected in JointDef.\n */\nexport interface RopeJointOpt extends JointOpt {\n /**\n * The maximum length of the rope.\n * Warning: this must be larger than linearSlop or the joint will have no effect.\n */\n maxLength?: number;\n}\n\n/**\n * Rope joint definition. This requires two body anchor points and a maximum\n * lengths. Note: by default the connected objects will not collide. see\n * collideConnected in JointDef.\n */\nexport interface RopeJointDef extends JointDef, RopeJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxLength : 0.0,\n};\n\ndeclare module \"./RopeJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RopeJoint(def: RopeJointDef): RopeJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RopeJoint(def: RopeJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): RopeJoint;\n}\n\n/**\n * A rope joint enforces a maximum distance between two points on two bodies. It\n * has no other effect.\n *\n * Warning: if you attempt to change the maximum length during the simulation\n * you will get some non-physical behavior.\n *\n * A model that would allow you to dynamically modify the length would have some\n * sponginess, so I chose not to implement it that way. See {@link DistanceJoint} if you\n * want to dynamically control length.\n */\n// @ts-expect-error\nexport class RopeJoint extends Joint {\n static TYPE = \"rope-joint\" as const;\n\n /** @internal */ m_type: \"rope-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n\n /** @internal */ m_maxLength: number;\n\n /** @internal */ m_mass: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_length: number;\n /** @internal */ m_state: number; // TODO enum\n\n // Solver temp\n /** @internal */ m_u: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n\n constructor(def: RopeJointDef);\n constructor(def: RopeJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: RopeJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof RopeJoint)) {\n return new RopeJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = RopeJoint.TYPE;\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.neo(-1.0, 0.0));\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.neo(1.0, 0.0));\n\n this.m_maxLength = def.maxLength;\n\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n this.m_length = 0.0;\n this.m_state = LimitState.inactiveLimit;\n\n // Limit:\n // C = norm(pB - pA) - L\n // u = (pB - pA) / norm(pB - pA)\n // Cdot = dot(u, vB + cross(wB, rB) - vA - cross(wA, rA))\n // J = [-u -cross(rA, u) u cross(rB, u)]\n // K = J * invM * JT\n // = invMassA + invIA * cross(rA, u)^2 + invMassB + invIB * cross(rB, u)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n maxLength: this.m_maxLength,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): RopeJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new RopeJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.maxLength)) {\n this.m_maxLength = def.maxLength;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the maximum length of the rope.\n */\n setMaxLength(length: number): void {\n this.m_maxLength = length;\n }\n\n /**\n * Get the maximum length of the rope.\n */\n getMaxLength(): number {\n return this.m_maxLength;\n }\n\n getLimitState(): number {\n // TODO LimitState\n return this.m_state;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_u).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n this.m_rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n this.m_u = Vec2.zero();\n this.m_u.addCombine(1, cB, 1, this.m_rB);\n this.m_u.subCombine(1, cA, 1, this.m_rA);\n\n this.m_length = this.m_u.length();\n\n const C = this.m_length - this.m_maxLength;\n if (C > 0.0) {\n this.m_state = LimitState.atUpperLimit;\n } else {\n this.m_state = LimitState.inactiveLimit;\n }\n\n if (this.m_length > Settings.linearSlop) {\n this.m_u.mul(1.0 / this.m_length);\n } else {\n this.m_u.setZero();\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n return;\n }\n\n // Compute effective mass.\n const crA = Vec2.crossVec2Vec2(this.m_rA, this.m_u);\n const crB = Vec2.crossVec2Vec2(this.m_rB, this.m_u);\n const invMass = this.m_invMassA + this.m_invIA * crA * crA + this.m_invMassB + this.m_invIB * crB * crB;\n\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n\n if (step.warmStarting) {\n // Scale the impulse to support a variable time step.\n this.m_impulse *= step.dtRatio;\n\n const P = Vec2.mulNumVec2(this.m_impulse, this.m_u);\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Cdot = dot(u, v + cross(w, r))\n const vpA = Vec2.addCrossNumVec2(vA, wA, this.m_rA);\n const vpB = Vec2.addCrossNumVec2(vB, wB, this.m_rB);\n const C = this.m_length - this.m_maxLength;\n let Cdot = Vec2.dot(this.m_u, Vec2.sub(vpB, vpA));\n\n // Predictive constraint.\n if (C < 0.0) {\n Cdot += step.inv_dt * C;\n }\n\n let impulse = -this.m_mass * Cdot;\n const oldImpulse = this.m_impulse;\n this.m_impulse = math_min(0.0, this.m_impulse + impulse);\n impulse = this.m_impulse - oldImpulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_u);\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n const u = Vec2.zero();\n u.addCombine(1, cB, 1, rB);\n u.subCombine(1, cA, 1, rA);\n\n const length = u.normalize();\n let C = length - this.m_maxLength;\n\n C = clamp(C, 0.0, Settings.maxLinearCorrection);\n\n const impulse = -this.m_mass * C;\n const P = Vec2.mulNumVec2(impulse, u);\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * Vec2.crossVec2Vec2(rA, P);\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, P);\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return length - this.m_maxLength < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Weld joint definition. You need to specify local anchor points where they are\n * attached and the relative body angle. The position of the anchor points is\n * important for computing the reaction torque.\n */\nexport interface WeldJointOpt extends JointOpt {\n /**\n * The mass-spring-damper frequency in Hertz. Rotation only. Disable softness\n * with a value of 0.\n */\n frequencyHz?: number;\n /**\n * The damping ratio. 0 = no damping, 1 = critical damping.\n */\n dampingRatio?: number;\n /**\n * The bodyB angle minus bodyA angle in the reference state (radians).\n */\n referenceAngle?: number;\n}\n\n/**\n * Weld joint definition. You need to specify local anchor points where they are\n * attached and the relative body angle. The position of the anchor points is\n * important for computing the reaction torque.\n */\nexport interface WeldJointDef extends JointDef, WeldJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n frequencyHz : 0.0,\n dampingRatio : 0.0,\n};\n\ndeclare module \"./WeldJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WeldJoint(def: WeldJointDef): WeldJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WeldJoint(def: WeldJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): WeldJoint;\n}\n\n/**\n * A weld joint essentially glues two bodies together. A weld joint may distort\n * somewhat because the island constraint solver is approximate.\n */\n// @ts-expect-error\nexport class WeldJoint extends Joint {\n static TYPE = \"weld-joint\" as const;\n\n /** @internal */ m_type: \"weld-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngle: number;\n\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n\n /** @internal */ m_impulse: Vec3;\n\n /** @internal */ m_bias: number;\n /** @internal */ m_gamma: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: Mat33;\n\n constructor(def: WeldJointDef);\n constructor(def: WeldJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: WeldJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof WeldJoint)) {\n return new WeldJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = WeldJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n this.m_referenceAngle = Number.isFinite(def.referenceAngle) ? def.referenceAngle : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_impulse = new Vec3();\n\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n\n // Solver temp\n // todo: do we need to initialize?\n // this.m_rA;\n // this.m_rB;\n // this.m_localCenterA;\n // this.m_localCenterB;\n // this.m_invMassA;\n // this.m_invMassB;\n // this.m_invIA;\n // this.m_invIB;\n this.m_mass = new Mat33();\n\n // Point-to-point constraint\n // C = p2 - p1\n // Cdot = v2 - v1\n // / = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Angle constraint\n // C = angle2 - angle1 - referenceAngle\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): WeldJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new WeldJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Set frequency in Hz.\n */\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n /**\n * Get frequency in Hz.\n */\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set damping ratio.\n */\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n /**\n * Get damping ratio.\n */\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.neo(this.m_impulse.x, this.m_impulse.y).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.z;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat33();\n K.ex.x = mA + mB + this.m_rA.y * this.m_rA.y * iA + this.m_rB.y * this.m_rB.y\n * iB;\n K.ey.x = -this.m_rA.y * this.m_rA.x * iA - this.m_rB.y * this.m_rB.x * iB;\n K.ez.x = -this.m_rA.y * iA - this.m_rB.y * iB;\n K.ex.y = K.ey.x;\n K.ey.y = mA + mB + this.m_rA.x * this.m_rA.x * iA + this.m_rB.x * this.m_rB.x\n * iB;\n K.ez.y = this.m_rA.x * iA + this.m_rB.x * iB;\n K.ex.z = K.ez.x;\n K.ey.z = K.ez.y;\n K.ez.z = iA + iB;\n\n if (this.m_frequencyHz > 0.0) {\n K.getInverse22(this.m_mass);\n\n let invM = iA + iB;\n const m = invM > 0.0 ? 1.0 / invM : 0.0;\n\n const C = aB - aA - this.m_referenceAngle;\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * m * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = m * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (d + h * k);\n this.m_gamma = this.m_gamma != 0.0 ? 1.0 / this.m_gamma : 0.0;\n this.m_bias = C * h * k * this.m_gamma;\n\n invM += this.m_gamma;\n this.m_mass.ez.z = invM != 0.0 ? 1.0 / invM : 0.0;\n } else if (K.ez.z == 0.0) {\n K.getInverse22(this.m_mass);\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n } else {\n K.getSymInverse33(this.m_mass);\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_impulse.mul(step.dtRatio);\n\n const P = Vec2.neo(this.m_impulse.x, this.m_impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_impulse.z);\n\n } else {\n this.m_impulse.setZero();\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n if (this.m_frequencyHz > 0.0) {\n const Cdot2 = wB - wA;\n\n const impulse2 = -this.m_mass.ez.z * (Cdot2 + this.m_bias + this.m_gamma * this.m_impulse.z);\n this.m_impulse.z += impulse2;\n\n wA -= iA * impulse2;\n wB += iB * impulse2;\n\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n\n const impulse1 = Vec2.neg(Mat33.mulVec2(this.m_mass, Cdot1));\n this.m_impulse.x += impulse1.x;\n this.m_impulse.y += impulse1.y;\n\n const P = Vec2.clone(impulse1);\n\n vA.subMul(mA, P);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(mB, P);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, P);\n } else {\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const Cdot2 = wB - wA;\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const impulse = Vec3.neg(Mat33.mulVec3(this.m_mass, Cdot));\n this.m_impulse.add(impulse);\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + impulse.z);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n let positionError: number;\n let angularError: number;\n\n const K = new Mat33();\n K.ex.x = mA + mB + rA.y * rA.y * iA + rB.y * rB.y * iB;\n K.ey.x = -rA.y * rA.x * iA - rB.y * rB.x * iB;\n K.ez.x = -rA.y * iA - rB.y * iB;\n K.ex.y = K.ey.x;\n K.ey.y = mA + mB + rA.x * rA.x * iA + rB.x * rB.x * iB;\n K.ez.y = rA.x * iA + rB.x * iB;\n K.ex.z = K.ez.x;\n K.ey.z = K.ez.y;\n K.ez.z = iA + iB;\n\n if (this.m_frequencyHz > 0.0) {\n const C1 = Vec2.zero();\n C1.addCombine(1, cB, 1, rB);\n C1.subCombine(1, cA, 1, rA);\n\n positionError = C1.length();\n angularError = 0.0;\n\n const P = Vec2.neg(K.solve22(C1));\n\n cA.subMul(mA, P);\n aA -= iA * Vec2.crossVec2Vec2(rA, P);\n\n cB.addMul(mB, P);\n aB += iB * Vec2.crossVec2Vec2(rB, P);\n } else {\n const C1 = Vec2.zero();\n C1.addCombine(1, cB, 1, rB);\n C1.subCombine(1, cA, 1, rA);\n\n const C2 = aB - aA - this.m_referenceAngle;\n\n positionError = C1.length();\n angularError = math_abs(C2);\n\n const C = new Vec3(C1.x, C1.y, C2);\n\n let impulse = new Vec3();\n if (K.ez.z > 0.0) {\n impulse = Vec3.neg(K.solve33(C));\n } else {\n const impulse2 = Vec2.neg(K.solve22(C1));\n impulse.set(impulse2.x, impulse2.y, 0.0);\n }\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n cA.subMul(mA, P);\n aA -= iA * (Vec2.crossVec2Vec2(rA, P) + impulse.z);\n\n cB.addMul(mB, P);\n aB += iB * (Vec2.crossVec2Vec2(rB, P) + impulse.z);\n }\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return positionError <= Settings.linearSlop && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Wheel joint definition. This requires defining a line of motion using an axis\n * and an anchor point. The definition uses local anchor points and a local axis\n * so that the initial configuration can violate the constraint slightly. The\n * joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface WheelJointOpt extends JointOpt {\n /**\n * Enable/disable the joint motor.\n */\n enableMotor?: boolean;\n /**\n * The maximum motor torque, usually in N-m.\n */\n maxMotorTorque?: number;\n /**\n * The desired motor speed in radians per second.\n */\n motorSpeed?: number;\n /**\n * Suspension frequency, zero indicates no suspension.\n */\n frequencyHz?: number;\n /**\n * Suspension damping ratio, one indicates critical damping.\n */\n dampingRatio?: number;\n}\n\n/**\n * Wheel joint definition. This requires defining a line of motion using an axis\n * and an anchor point. The definition uses local anchor points and a local axis\n * so that the initial configuration can violate the constraint slightly. The\n * joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface WheelJointDef extends JointDef, WheelJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The local translation axis in bodyA.\n */\n localAxisA: Vec2Value;\n\n /** @internal renamed to localAxisA */\n localAxis?: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n enableMotor : false,\n maxMotorTorque : 0.0,\n motorSpeed : 0.0,\n frequencyHz : 2.0,\n dampingRatio : 0.7,\n};\n\ndeclare module \"./WheelJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WheelJoint(def: WheelJointDef): WheelJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WheelJoint(def: WheelJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value, axis: Vec2Value): WheelJoint;\n}\n\n/**\n * A wheel joint. This joint provides two degrees of freedom: translation along\n * an axis fixed in bodyA and rotation in the plane. In other words, it is a\n * point to line constraint with a rotational motor and a linear spring/damper.\n * This joint is designed for vehicle suspensions.\n */\n// @ts-expect-error\nexport class WheelJoint extends Joint {\n static TYPE = \"wheel-joint\" as const;\n\n /** @internal */ m_type: \"wheel-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_localXAxisA: Vec2;\n /** @internal */ m_localYAxisA: Vec2;\n\n /** @internal */ m_mass: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_motorMass: number;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_springMass: number;\n /** @internal */ m_springImpulse: number;\n\n /** @internal */ m_maxMotorTorque: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableMotor: boolean;\n\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n\n /** @internal */ m_bias: number;\n /** @internal */ m_gamma: number;\n\n // Solver temp\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n\n /** @internal */ m_ax: Vec2;\n /** @internal */ m_ay: Vec2;\n /** @internal */ m_sAx: number;\n /** @internal */ m_sBx: number;\n /** @internal */ m_sAy: number;\n /** @internal */ m_sBy: number;\n\n constructor(def: WheelJointDef);\n constructor(def: WheelJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value, axis?: Vec2Value);\n constructor(def: WheelJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value, axis?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof WheelJoint)) {\n return new WheelJoint(def, bodyA, bodyB, anchor, axis);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_ax = Vec2.zero();\n this.m_ay = Vec2.zero();\n\n this.m_type = WheelJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n\n if (Vec2.isValid(axis)) {\n this.m_localXAxisA = bodyA.getLocalVector(axis);\n } else if (Vec2.isValid(def.localAxisA)) {\n this.m_localXAxisA = Vec2.clone(def.localAxisA);\n } else if (Vec2.isValid(def.localAxis)) {\n // localAxis is renamed to localAxisA, this is for backward compatibility\n this.m_localXAxisA = Vec2.clone(def.localAxis);\n } else {\n this.m_localXAxisA = Vec2.neo(1.0, 0.0);\n }\n\n this.m_localYAxisA = Vec2.crossNumVec2(1.0, this.m_localXAxisA);\n\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n this.m_springMass = 0.0;\n this.m_springImpulse = 0.0;\n\n this.m_maxMotorTorque = def.maxMotorTorque;\n this.m_motorSpeed = def.motorSpeed;\n this.m_enableMotor = def.enableMotor;\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n\n // Linear constraint (point-to-line)\n // d = pB - pA = xB + rB - xA - rA\n // C = dot(ay, d)\n // Cdot = dot(d, cross(wA, ay)) + dot(ay, vB + cross(wB, rB) - vA - cross(wA,\n // rA))\n // = -dot(ay, vA) - dot(cross(d + rA, ay), wA) + dot(ay, vB) + dot(cross(rB,\n // ay), vB)\n // J = [-ay, -cross(d + rA, ay), ay, cross(rB, ay)]\n\n // Spring linear constraint\n // C = dot(ax, d)\n // Cdot = = -dot(ax, vA) - dot(cross(d + rA, ax), wA) + dot(ax, vB) +\n // dot(cross(rB, ax), vB)\n // J = [-ax -cross(d+rA, ax) ax cross(rB, ax)]\n\n // Motor rotational constraint\n // Cdot = wB - wA\n // J = [0 0 -1 0 0 1]\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n enableMotor: this.m_enableMotor,\n maxMotorTorque: this.m_maxMotorTorque,\n motorSpeed: this.m_motorSpeed,\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n localAxisA: this.m_localXAxisA,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): WheelJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new WheelJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (def.localAxisA) {\n this.m_localXAxisA.setVec2(def.localAxisA);\n this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1.0, def.localAxisA));\n }\n if (def.enableMotor !== undefined) {\n this.m_enableMotor = def.enableMotor;\n }\n if (Number.isFinite(def.maxMotorTorque)) {\n this.m_maxMotorTorque = def.maxMotorTorque;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * The local joint axis relative to bodyA.\n */\n getLocalAxisA(): Vec2 {\n return this.m_localXAxisA;\n }\n\n /**\n * Get the current joint translation, usually in meters.\n */\n getJointTranslation(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n\n const pA = bA.getWorldPoint(this.m_localAnchorA);\n const pB = bB.getWorldPoint(this.m_localAnchorB);\n const d = Vec2.sub(pB, pA);\n const axis = bA.getWorldVector(this.m_localXAxisA);\n\n const translation = Vec2.dot(d, axis);\n return translation;\n }\n\n /**\n * Get the current joint translation speed, usually in meters per second.\n */\n getJointSpeed(): number {\n const wA = this.m_bodyA.m_angularVelocity;\n const wB = this.m_bodyB.m_angularVelocity;\n return wB - wA;\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Set the motor speed, usually in radians per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Get the motor speed, usually in radians per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Set/Get the maximum motor force, usually in N-m.\n */\n setMaxMotorTorque(torque: number): void {\n if (torque == this.m_maxMotorTorque) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorTorque = torque;\n }\n\n getMaxMotorTorque(): number {\n return this.m_maxMotorTorque;\n }\n\n /**\n * Get the current motor torque given the inverse time step, usually in N-m.\n */\n getMotorTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Set/Get the spring frequency in hertz. Setting the frequency to zero disables\n * the spring.\n */\n setSpringFrequencyHz(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n getSpringFrequencyHz(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set/Get the spring damping ratio\n */\n setSpringDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n getSpringDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.combine(this.m_impulse, this.m_ay, this.m_springImpulse, this.m_ax).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective masses.\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n // Point to line constraint\n {\n this.m_ay = Rot.mulVec2(qA, this.m_localYAxisA);\n this.m_sAy = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_ay);\n this.m_sBy = Vec2.crossVec2Vec2(rB, this.m_ay);\n\n this.m_mass = mA + mB + iA * this.m_sAy * this.m_sAy + iB * this.m_sBy\n * this.m_sBy;\n\n if (this.m_mass > 0.0) {\n this.m_mass = 1.0 / this.m_mass;\n }\n }\n\n // Spring constraint\n this.m_springMass = 0.0;\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n if (this.m_frequencyHz > 0.0) {\n this.m_ax = Rot.mulVec2(qA, this.m_localXAxisA);\n this.m_sAx = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_ax);\n this.m_sBx = Vec2.crossVec2Vec2(rB, this.m_ax);\n\n const invMass = mA + mB + iA * this.m_sAx * this.m_sAx + iB * this.m_sBx\n * this.m_sBx;\n\n if (invMass > 0.0) {\n this.m_springMass = 1.0 / invMass;\n\n const C = Vec2.dot(d, this.m_ax);\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const damp = 2.0 * this.m_springMass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = this.m_springMass * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (damp + h * k);\n if (this.m_gamma > 0.0) {\n this.m_gamma = 1.0 / this.m_gamma;\n }\n\n this.m_bias = C * h * k * this.m_gamma;\n\n this.m_springMass = invMass + this.m_gamma;\n if (this.m_springMass > 0.0) {\n this.m_springMass = 1.0 / this.m_springMass;\n }\n }\n } else {\n this.m_springImpulse = 0.0;\n }\n\n // Rotational motor\n if (this.m_enableMotor) {\n this.m_motorMass = iA + iB;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n } else {\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n }\n\n if (step.warmStarting) {\n // Account for variable time step.\n this.m_impulse *= step.dtRatio;\n this.m_springImpulse *= step.dtRatio;\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.combine(this.m_impulse, this.m_ay, this.m_springImpulse, this.m_ax);\n const LA = this.m_impulse * this.m_sAy + this.m_springImpulse * this.m_sAx + this.m_motorImpulse;\n const LB = this.m_impulse * this.m_sBy + this.m_springImpulse * this.m_sBx + this.m_motorImpulse;\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * LA;\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * LB;\n\n } else {\n this.m_impulse = 0.0;\n this.m_springImpulse = 0.0;\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Solve spring constraint\n {\n const Cdot = Vec2.dot(this.m_ax, vB) - Vec2.dot(this.m_ax, vA) + this.m_sBx * wB - this.m_sAx * wA;\n const impulse = -this.m_springMass * (Cdot + this.m_bias + this.m_gamma * this.m_springImpulse);\n this.m_springImpulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_ax);\n const LA = impulse * this.m_sAx;\n const LB = impulse * this.m_sBx;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n // Solve rotational motor constraint\n {\n const Cdot = wB - wA - this.m_motorSpeed;\n let impulse = -this.m_motorMass * Cdot;\n\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorTorque;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve point to line constraint\n {\n const Cdot = Vec2.dot(this.m_ay, vB) - Vec2.dot(this.m_ay, vA) + this.m_sBy * wB - this.m_sAy * wA;\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_ay);\n const LA = impulse * this.m_sAy;\n const LB = impulse * this.m_sBy;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n const ay = Rot.mulVec2(qA, this.m_localYAxisA);\n\n const sAy = Vec2.crossVec2Vec2(Vec2.add(d, rA), ay);\n const sBy = Vec2.crossVec2Vec2(rB, ay);\n\n const C = Vec2.dot(d, ay);\n\n const k = this.m_invMassA + this.m_invMassB + this.m_invIA * this.m_sAy * this.m_sAy + this.m_invIB * this.m_sBy * this.m_sBy;\n\n const impulse = k != 0.0 ? -C / k : 0.0;\n\n const P = Vec2.mulNumVec2(impulse, ay);\n const LA = impulse * sAy;\n const LB = impulse * sBy;\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * LA;\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * LB;\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return math_abs(C) <= Settings.linearSlop;\n }\n\n}\n","import { World } from \"../dynamics/World\";\nimport { Body } from \"../dynamics/Body\";\nimport { Joint } from \"../dynamics/Joint\";\nimport { Fixture } from \"../dynamics/Fixture\";\nimport { Shape } from \"../collision/Shape\";\nimport { Vec2 } from \"../common/Vec2\";\nimport { Vec3 } from \"../common/Vec3\";\nimport { ChainShape } from \"../collision/shape/ChainShape\";\n// import { BoxShape } from \"../collision/shape/BoxShape\";\nimport { EdgeShape } from \"../collision/shape/EdgeShape\";\nimport { PolygonShape } from \"../collision/shape/PolygonShape\";\nimport { CircleShape } from \"../collision/shape/CircleShape\";\nimport { DistanceJoint } from \"../dynamics/joint/DistanceJoint\";\nimport { FrictionJoint } from \"../dynamics/joint/FrictionJoint\";\nimport { GearJoint } from \"../dynamics/joint/GearJoint\";\nimport { MotorJoint } from \"../dynamics/joint/MotorJoint\";\nimport { MouseJoint } from \"../dynamics/joint/MouseJoint\";\nimport { PrismaticJoint } from \"../dynamics/joint/PrismaticJoint\";\nimport { PulleyJoint } from \"../dynamics/joint/PulleyJoint\";\nimport { RevoluteJoint } from \"../dynamics/joint/RevoluteJoint\";\nimport { RopeJoint } from \"../dynamics/joint/RopeJoint\";\nimport { WeldJoint } from \"../dynamics/joint/WeldJoint\";\nimport { WheelJoint } from \"../dynamics/joint/WheelJoint\";\n\nlet SID = 0;\n\n// Classes to be serialized as reference objects\nconst SERIALIZE_REF_TYPES = {\n \"World\": World,\n \"Body\": Body,\n \"Joint\": Joint,\n \"Fixture\": Fixture,\n \"Shape\": Shape,\n};\n\n// For deserializing reference objects by reference type\nconst DESERIALIZE_BY_REF_TYPE = {\n \"Vec2\": Vec2,\n \"Vec3\": Vec3,\n \"World\": World,\n \"Body\": Body,\n \"Joint\": Joint,\n \"Fixture\": Fixture,\n \"Shape\": Shape,\n};\n\n// For deserializing data objects by type field\nconst DESERIALIZE_BY_TYPE_FIELD = {\n [Body.STATIC]: Body,\n [Body.DYNAMIC]: Body,\n [Body.KINEMATIC]: Body,\n [ChainShape.TYPE]: ChainShape,\n // [BoxShape.TYPE]: BoxShape,\n [PolygonShape.TYPE]: PolygonShape,\n [EdgeShape.TYPE]: EdgeShape,\n [CircleShape.TYPE]: CircleShape,\n [DistanceJoint.TYPE]: DistanceJoint,\n [FrictionJoint.TYPE]: FrictionJoint,\n [GearJoint.TYPE]: GearJoint,\n [MotorJoint.TYPE]: MotorJoint,\n [MouseJoint.TYPE]: MouseJoint,\n [PrismaticJoint.TYPE]: PrismaticJoint,\n [PulleyJoint.TYPE]: PulleyJoint,\n [RevoluteJoint.TYPE]: RevoluteJoint,\n [RopeJoint.TYPE]: RopeJoint,\n [WeldJoint.TYPE]: WeldJoint,\n [WheelJoint.TYPE]: WheelJoint,\n};\n\n// dummy types\ntype DataType = any;\ntype ObjectType = any;\ntype ClassName = any;\n\ntype SerializedType = object[];\n\ntype RefType = {\n refIndex: number,\n refType: string,\n};\n\ntype SerializerOptions = {\n rootClass: ClassName,\n preSerialize?: (obj: ObjectType) => DataType,\n postSerialize?: (data: DataType, obj: any) => DataType,\n preDeserialize?: (data: DataType) => DataType,\n postDeserialize?: (obj: ObjectType, data: DataType) => ObjectType,\n};\n\nconst DEFAULT_OPTIONS: SerializerOptions = {\n rootClass: World,\n preSerialize: function(obj) { return obj; },\n postSerialize: function(data, obj) { return data; },\n preDeserialize: function(data: DataType) { return data; },\n postDeserialize: function(obj, data) { return obj; },\n};\n\ntype DeserializeChildCallback = (classHint: any, obj: any, context: any) => any;\ntype ClassDeserializerMethod = (data: any, context: any, deserialize: DeserializeChildCallback) => any;\n\nexport class Serializer {\n private options: SerializerOptions;\n constructor(options: SerializerOptions) {\n this.options = {\n ...DEFAULT_OPTIONS,\n ...options,\n };\n }\n\n toJson = (root: T): SerializedType => {\n const preSerialize = this.options.preSerialize;\n const postSerialize = this.options.postSerialize;\n const json = [];\n\n // Breadth-first ref serialization queue\n const refQueue = [root];\n\n const refMemoById: Record = {};\n\n function addToRefQueue(value: any, typeName: string) {\n value.__sid = value.__sid || ++SID;\n if (!refMemoById[value.__sid]) {\n refQueue.push(value);\n const index = json.length + refQueue.length;\n const ref = {\n refIndex: index,\n refType: typeName\n };\n refMemoById[value.__sid] = ref;\n }\n return refMemoById[value.__sid];\n }\n\n function serializeWithHooks(obj: ObjectType) {\n obj = preSerialize(obj);\n let data = obj._serialize();\n data = postSerialize(data, obj);\n return data;\n }\n\n // traverse the object graph\n // ref objects are pushed into the queue\n // other objects are serialize in-place \n function traverse(value: any, noRefType = false) {\n if (typeof value !== \"object\" || value === null) {\n return value;\n }\n // object with _serialize function\n if (typeof value._serialize === \"function\") {\n if (!noRefType) {\n for (const typeName in SERIALIZE_REF_TYPES) {\n if (value instanceof SERIALIZE_REF_TYPES[typeName]) {\n return addToRefQueue(value, typeName);\n }\n }\n }\n // object with _serialize function\n value = serializeWithHooks(value);\n }\n // recursive for arrays any objects\n if (Array.isArray(value)) {\n const newValue = [];\n for (let key = 0; key < value.length; key++) {\n newValue[key] = traverse(value[key]);\n }\n value = newValue;\n\n } else {\n const newValue = {};\n for (const key in value) {\n if (value.hasOwnProperty(key)) {\n newValue[key] = traverse(value[key]);\n }\n }\n value = newValue;\n }\n return value;\n }\n\n while (refQueue.length) {\n const obj = refQueue.shift();\n const str = traverse(obj, true);\n json.push(str);\n }\n\n return json;\n };\n\n fromJson = (json: SerializedType): T => {\n const preDeserialize = this.options.preDeserialize;\n const postDeserialize = this.options.postDeserialize;\n const rootClass = this.options.rootClass;\n\n const deserializedRefMemoByIndex: Record = {};\n\n function deserializeWithHooks(classHint: ClassName, data: DataType, context: any): ObjectType {\n if (!classHint || !classHint._deserialize) {\n classHint = DESERIALIZE_BY_TYPE_FIELD[data.type];\n }\n const deserializer = classHint && classHint._deserialize;\n if (!deserializer) {\n return;\n }\n data = preDeserialize(data);\n const classDeserializeFn = classHint._deserialize as ClassDeserializerMethod;\n let obj = classDeserializeFn(data, context, deserializeChild);\n obj = postDeserialize(obj, data);\n return obj;\n }\n\n /**\n * Recursive callback function to deserialize a child data object or reference object.\n * \n * @param classHint suggested class to deserialize obj to\n * @param dataOrRef data or reference object\n * @param context for example world when deserializing bodies and joints\n */\n function deserializeChild(classHint: ClassName, dataOrRef: DataType | RefType, context: any) {\n const isRefObject = dataOrRef.refIndex && dataOrRef.refType;\n if (!isRefObject) {\n return deserializeWithHooks(classHint, dataOrRef, context); \n }\n const ref = dataOrRef as RefType;\n if (DESERIALIZE_BY_REF_TYPE[ref.refType]) {\n classHint = DESERIALIZE_BY_REF_TYPE[ref.refType];\n }\n const refIndex = ref.refIndex;\n if (!deserializedRefMemoByIndex[refIndex]) {\n const data = json[refIndex];\n const obj = deserializeWithHooks(classHint, data, context);\n deserializedRefMemoByIndex[refIndex] = obj;\n }\n return deserializedRefMemoByIndex[refIndex];\n }\n\n const root = deserializeWithHooks(rootClass, json[0], null);\n\n return root;\n };\n\n static toJson: (root: World) => SerializedType;\n static fromJson: (json: SerializedType) => World;\n}\n\nconst worldSerializer = new Serializer({\n rootClass: World,\n});\n\nSerializer.fromJson = worldSerializer.fromJson;\nSerializer.toJson = worldSerializer.toJson;\n","import type { AABBValue } from \"../collision/AABB\";\nimport type { World } from \"../dynamics/World\";\nimport type { Joint } from \"../dynamics/Joint\";\nimport type { Fixture } from \"../dynamics/Fixture\";\nimport type { Body } from \"../dynamics/Body\";\n\nexport interface Style {\n stroke?: string;\n fill?: string;\n lineWidth?: number;\n}\n\ntype KEY = \"0\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" |\n \"8\" | \"9\" | \"A\" | \"B\" | \"C\" | \"D\" | \"E\" | \"F\" | \"G\" |\n \"H\" | \"I\" | \"J\" | \"K\" | \"L\" | \"M\" | \"N\" | \"O\" | \"P\" |\n \"Q\" | \"R\" | \"S\" | \"T\" | \"U\" | \"V\" | \"W\" | \"X\" | \"Y\" |\n \"Z\" | \"right\" | \"left\" | \"up\" | \"down\" | \"fire\";\n\nexport type ActiveKeys = { [key in KEY]?: boolean };\n\ntype TestbedMountOptions = { [key: string]: any };\n\nexport abstract class Testbed {\n /**\n * Mounts testbed. Call start with a world to start simulation and rendering.\n */\n static mount(options?: TestbedMountOptions): Testbed {\n throw new Error(\"Not implemented\");\n }\n\n /**\n * Mounts testbed if needed, then starts simulation and rendering.\n * \n * If you need to customize testbed before starting, first run `const testbed = Testbed.mount()` and then `testbed.start()`.\n */\n static start(world: World): Testbed {\n const testbed = Testbed.mount();\n testbed.start(world);\n return testbed;\n }\n\n /** World viewbox width. */\n width: number = 80;\n\n /** World viewbox height. */\n height: number = 60;\n\n /** World viewbox center vertical offset. */\n x: number = 0;\n\n /** World viewbox center horizontal offset. */\n y: number = -10;\n\n /** @hidden */\n scaleY: number = -1;\n\n /** World simulation step frequency */\n hz: number = 60;\n\n /** World simulation speed, default is 1 */\n speed: number = 1;\n\n background: string = \"#222222\";\n\n mouseForce?: number;\n activeKeys: ActiveKeys = {};\n\n /** callback, to be implemented by user */\n step = (dt: number, t: number): void => {\n return;\n };\n\n /** callback, to be implemented by user */\n keydown = (keyCode: number, label: string): void => {\n return;\n };\n\n /** callback, to be implemented by user */\n keyup = (keyCode: number, label: string): void => {\n return;\n };\n\n abstract status(name: string, value: any): void;\n abstract status(value: object | string): void;\n\n abstract info(text: string): void;\n\n color(r: number, g: number, b: number): string {\n r = r * 256 | 0;\n g = g * 256 | 0;\n b = b * 256 | 0;\n return \"rgb(\" + r + \", \" + g + \", \" + b + \")\";\n }\n\n abstract drawPoint(p: {x: number, y: number}, r: any, color: string): void;\n abstract drawCircle(p: {x: number, y: number}, r: number, color: string): void;\n abstract drawEdge(a: {x: number, y: number}, b: {x: number, y: number}, color: string): void;\n abstract drawSegment(a: {x: number, y: number}, b: {x: number, y: number}, color: string): void;\n abstract drawPolygon(points: Array<{x: number, y: number}>, color: string): void;\n abstract drawAABB(aabb: AABBValue, color: string): void;\n\n abstract start(world: World): void;\n\n abstract findOne(query: string): (Body | Joint | Fixture | null);\n abstract findAll(query: string): (Body | Joint | Fixture)[];\n}\n\ntype TestbedFactoryOptions = string | TestbedMountOptions;\n\n/** @deprecated */\ntype TestbedCallback = (testbed: Testbed) => (World | undefined);\n\n/** @deprecated */\nexport function testbed(callback: TestbedCallback): void;\n/** @deprecated */\nexport function testbed(options: TestbedFactoryOptions, callback: TestbedCallback): void;\n/** @internal */\nexport function testbed(a?: any, b?: any) {\n let callback: TestbedCallback | undefined;\n let options;\n if (typeof a === \"function\") {\n callback = a;\n options = b;\n } else if (typeof b === \"function\") {\n callback = b;\n options = a;\n } else {\n options = a ?? b;\n }\n const testbed = Testbed.mount(options);\n if (callback) {\n // this is for backwards compatibility\n const world = callback(testbed) || (testbed as any).world;\n testbed.start(world);\n } else {\n return testbed;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { Vec2Value } from \"../../common/Vec2\";\nimport { PolygonShape } from \"./PolygonShape\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\ndeclare module \"./BoxShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function BoxShape(halfWidth: number, halfHeight: number, center?: Vec2Value, angle?: number): BoxShape;\n}\n\n/**\n * A rectangle polygon which extend PolygonShape.\n */\n// @ts-expect-error\nexport class BoxShape extends PolygonShape {\n // note that box is serialized/deserialized as polygon\n static TYPE = \"polygon\" as const;\n\n /**\n * \n * @param halfWidth \n * @param halfHeight \n * @param center coordinate of the center of the box relative to the body\n * @param angle angle of the box relative to the body\n */\n constructor(halfWidth: number, halfHeight: number, center?: Vec2Value, angle?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof BoxShape)) {\n return new BoxShape(halfWidth, halfHeight, center, angle);\n }\n\n super();\n\n this._setAsBox(halfWidth, halfHeight, center, angle);\n }\n}\n\nexport const Box = BoxShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { CircleShape } from \"./CircleShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(CircleShape.TYPE, CircleShape.TYPE, CircleCircleContact);\n\n/** @internal */ function CircleCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == CircleShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n CollideCircles(manifold, fixtureA.getShape() as CircleShape, xfA, fixtureB.getShape() as CircleShape, xfB);\n}\n\n/** @internal */ const pA = matrix.vec2(0, 0);\n/** @internal */ const pB = matrix.vec2(0, 0);\n\nexport const CollideCircles = function (manifold: Manifold, circleA: CircleShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n matrix.transformVec2(pA, xfA, circleA.m_p);\n matrix.transformVec2(pB, xfB, circleB.m_p);\n\n const distSqr = matrix.distSqrVec2(pB, pA);\n const rA = circleA.m_radius;\n const rB = circleB.m_radius;\n const radius = rA + rB;\n if (distSqr > radius * radius) {\n return;\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.copyVec2(manifold.localPoint, circleA.m_p);\n matrix.zeroVec2(manifold.localNormal);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { TransformValue } from \"../../common/Transform\";\nimport * as matrix from \"../../common/Matrix\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { EdgeShape } from \"./EdgeShape\";\nimport { ChainShape } from \"./ChainShape\";\nimport { CircleShape } from \"./CircleShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(EdgeShape.TYPE, CircleShape.TYPE, EdgeCircleContact);\nContact.addType(ChainShape.TYPE, CircleShape.TYPE, ChainCircleContact);\n\n/** @internal */ function EdgeCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == EdgeShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n\n const shapeA = fixtureA.getShape() as EdgeShape;\n const shapeB = fixtureB.getShape() as CircleShape;\n\n CollideEdgeCircle(manifold, shapeA, xfA, shapeB, xfB);\n}\n\nfunction ChainCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == ChainShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n\n const chain = fixtureA.getShape() as ChainShape;\n const edge = new EdgeShape();\n chain.getChildEdge(edge, indexA);\n\n const shapeA = edge;\n const shapeB = fixtureB.getShape() as CircleShape;\n\n CollideEdgeCircle(manifold, shapeA, xfA, shapeB, xfB);\n}\n\n/** @internal */ const e = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const e1 = matrix.vec2(0, 0);\n/** @internal */ const e2 = matrix.vec2(0, 0);\n/** @internal */ const Q = matrix.vec2(0, 0);\n/** @internal */ const P = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n\n// Compute contact points for edge versus circle.\n// This accounts for edge connectivity.\nexport const CollideEdgeCircle = function (manifold: Manifold, edgeA: EdgeShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n // Compute circle in frame of edge\n matrix.retransformVec2(Q, xfB, xfA, circleB.m_p);\n\n const A = edgeA.m_vertex1;\n const B = edgeA.m_vertex2;\n matrix.subVec2(e, B, A);\n\n // Barycentric coordinates\n const u = matrix.dotVec2(e, B) - matrix.dotVec2(e, Q);\n const v = matrix.dotVec2(e, Q) - matrix.dotVec2(e, A);\n\n const radius = edgeA.m_radius + circleB.m_radius;\n\n // Region A\n if (v <= 0.0) {\n matrix.copyVec2(P, A);\n const dd = matrix.distSqrVec2(Q, A);\n if (dd > radius * radius) {\n return;\n }\n\n // Is there an edge connected to A?\n if (edgeA.m_hasVertex0) {\n const A1 = edgeA.m_vertex0;\n const B1 = A;\n matrix.subVec2(e1, B1, A1);\n const u1 = matrix.dotVec2(e1, B1) - matrix.dotVec2(e1, Q);\n\n // Is the circle in Region AB of the previous edge?\n if (u1 > 0.0) {\n return;\n }\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.zeroVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, P);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n return;\n }\n\n // Region B\n if (u <= 0.0) {\n matrix.copyVec2(P, B);\n const dd = matrix.distSqrVec2(Q, P);\n if (dd > radius * radius) {\n return;\n }\n\n // Is there an edge connected to B?\n if (edgeA.m_hasVertex3) {\n const B2 = edgeA.m_vertex3;\n const A2 = B;\n matrix.subVec2(e2, B2, A2);\n const v2 = matrix.dotVec2(e2, Q) - matrix.dotVec2(e2, A2);\n\n // Is the circle in Region AB of the next edge?\n if (v2 > 0.0) {\n return;\n }\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.zeroVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, P);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(1, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n\n return;\n }\n\n // Region AB\n const den = matrix.lengthSqrVec2(e);\n if (_ASSERT) console.assert(den > 0.0);\n matrix.combine2Vec2(P, u / den, A, v / den, B);\n const dd = matrix.distSqrVec2(Q, P);\n if (dd > radius * radius) {\n return;\n }\n\n matrix.crossNumVec2(n, 1, e);\n if (matrix.dotVec2(n, Q) - matrix.dotVec2(n, A) < 0.0) {\n matrix.negVec2(n);\n }\n matrix.normalizeVec2(n);\n\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, n);\n matrix.copyVec2(manifold.localPoint, A);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_face, 0, ContactFeatureType.e_vertex);\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { TransformValue } from \"../../common/Transform\";\nimport * as matrix from \"../../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Manifold, clipSegmentToLine, ClipVertex, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/** @internal */ const incidentEdge = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints1 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints2 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipSegmentToLineNormal = matrix.vec2(0, 0);\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const v11 = matrix.vec2(0, 0);\n/** @internal */ const v12 = matrix.vec2(0, 0);\n/** @internal */ const localTangent = matrix.vec2(0, 0);\n/** @internal */ const localNormal = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const tangent = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const normal1 = matrix.vec2(0, 0);\n\n\nContact.addType(PolygonShape.TYPE, PolygonShape.TYPE, PolygonContact);\n\n/** @internal */ function PolygonContact(\n manifold: Manifold,\n xfA: TransformValue,\n fixtureA: Fixture,\n indexA: number,\n xfB: TransformValue,\n fixtureB: Fixture,\n indexB: number,\n): void {\n if (_ASSERT) console.assert(fixtureA.getType() == PolygonShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == PolygonShape.TYPE);\n CollidePolygons(manifold, fixtureA.getShape() as PolygonShape, xfA, fixtureB.getShape() as PolygonShape, xfB);\n}\n\n/** @internal */ interface MaxSeparation {\n maxSeparation: number;\n bestIndex: number;\n}\n\n/**\n * Find the max separation between poly1 and poly2 using edge normals from\n * poly1.\n */\n/** @internal */ function findMaxSeparation(\n poly1: PolygonShape,\n xf1: TransformValue,\n poly2: PolygonShape,\n xf2: TransformValue,\n output: MaxSeparation,\n): void {\n const count1 = poly1.m_count;\n const count2 = poly2.m_count;\n const n1s = poly1.m_normals;\n const v1s = poly1.m_vertices;\n const v2s = poly2.m_vertices;\n\n matrix.detransformTransform(xf, xf2, xf1);\n\n let bestIndex = 0;\n let maxSeparation = -Infinity;\n for (let i = 0; i < count1; ++i) {\n // Get poly1 normal in frame2.\n matrix.rotVec2(n, xf.q, n1s[i]);\n matrix.transformVec2(v1, xf, v1s[i]);\n\n // Find deepest point for normal i.\n let si = Infinity;\n for (let j = 0; j < count2; ++j) {\n const sij = matrix.dotVec2(n, v2s[j]) - matrix.dotVec2(n, v1);\n if (sij < si) {\n si = sij;\n }\n }\n\n if (si > maxSeparation) {\n maxSeparation = si;\n bestIndex = i;\n }\n }\n\n // used to keep last FindMaxSeparation call values\n output.maxSeparation = maxSeparation;\n output.bestIndex = bestIndex;\n}\n\n/** @internal */ function findIncidentEdge(\n clipVertex: ClipVertex[],\n poly1: PolygonShape,\n xf1: TransformValue,\n edge1: number,\n poly2: PolygonShape,\n xf2: TransformValue,\n): void {\n const normals1 = poly1.m_normals;\n\n const count2 = poly2.m_count;\n const vertices2 = poly2.m_vertices;\n const normals2 = poly2.m_normals;\n\n if (_ASSERT) console.assert(0 <= edge1 && edge1 < poly1.m_count);\n\n // Get the normal of the reference edge in poly2's frame.\n matrix.rerotVec2(normal1, xf2.q, xf1.q, normals1[edge1]);\n\n // Find the incident edge on poly2.\n let index = 0;\n let minDot = Infinity;\n for (let i = 0; i < count2; ++i) {\n const dot = matrix.dotVec2(normal1, normals2[i]);\n if (dot < minDot) {\n minDot = dot;\n index = i;\n }\n }\n\n // Build the clip vertices for the incident edge.\n const i1 = index;\n const i2 = i1 + 1 < count2 ? i1 + 1 : 0;\n\n matrix.transformVec2(clipVertex[0].v, xf2, vertices2[i1]);\n clipVertex[0].id.setFeatures(edge1, ContactFeatureType.e_face, i1, ContactFeatureType.e_vertex);\n\n matrix.transformVec2(clipVertex[1].v, xf2, vertices2[i2]);\n clipVertex[1].id.setFeatures(edge1, ContactFeatureType.e_face, i2, ContactFeatureType.e_vertex);\n}\n\n/** @internal */ const maxSeparation = {\n maxSeparation: 0,\n bestIndex: 0,\n};\n\n/**\n *\n * Find edge normal of max separation on A - return if separating axis is found
\n * Find edge normal of max separation on B - return if separation axis is found
\n * Choose reference edge as min(minA, minB)
\n * Find incident edge
\n * Clip\n *\n * The normal points from 1 to 2\n */\nexport const CollidePolygons = function (\n manifold: Manifold,\n polyA: PolygonShape,\n xfA: TransformValue,\n polyB: PolygonShape,\n xfB: TransformValue,\n): void {\n manifold.pointCount = 0;\n const totalRadius = polyA.m_radius + polyB.m_radius;\n\n findMaxSeparation(polyA, xfA, polyB, xfB, maxSeparation);\n const edgeA = maxSeparation.bestIndex;\n const separationA = maxSeparation.maxSeparation;\n if (separationA > totalRadius)\n return;\n\n findMaxSeparation(polyB, xfB, polyA, xfA, maxSeparation);\n const edgeB = maxSeparation.bestIndex;\n const separationB = maxSeparation.maxSeparation;\n if (separationB > totalRadius)\n return;\n\n let poly1: PolygonShape; // reference polygon\n let poly2: PolygonShape; // incident polygon\n let xf1: TransformValue;\n let xf2: TransformValue;\n let edge1: number; // reference edge\n let flip: boolean;\n const k_tol = 0.1 * Settings.linearSlop;\n\n if (separationB > separationA + k_tol) {\n poly1 = polyB;\n poly2 = polyA;\n xf1 = xfB;\n xf2 = xfA;\n edge1 = edgeB;\n manifold.type = ManifoldType.e_faceB;\n flip = true;\n } else {\n poly1 = polyA;\n poly2 = polyB;\n xf1 = xfA;\n xf2 = xfB;\n edge1 = edgeA;\n manifold.type = ManifoldType.e_faceA;\n flip = false;\n }\n\n incidentEdge[0].recycle();\n incidentEdge[1].recycle();\n findIncidentEdge(incidentEdge, poly1, xf1, edge1, poly2, xf2);\n\n const count1 = poly1.m_count;\n const vertices1 = poly1.m_vertices;\n\n const iv1 = edge1;\n const iv2 = edge1 + 1 < count1 ? edge1 + 1 : 0;\n\n matrix.copyVec2(v11, vertices1[iv1]);\n matrix.copyVec2(v12, vertices1[iv2]);\n\n matrix.subVec2(localTangent, v12, v11);\n matrix.normalizeVec2(localTangent);\n\n matrix.crossVec2Num(localNormal, localTangent, 1.0);\n matrix.combine2Vec2(planePoint, 0.5, v11, 0.5, v12);\n\n matrix.rotVec2(tangent, xf1.q, localTangent);\n matrix.crossVec2Num(normal, tangent, 1.0);\n\n matrix.transformVec2(v11, xf1, v11);\n matrix.transformVec2(v12, xf1, v12);\n\n // Face offset.\n const frontOffset = matrix.dotVec2(normal, v11);\n\n // Side offsets, extended by polytope skin thickness.\n const sideOffset1 = -matrix.dotVec2(tangent, v11) + totalRadius;\n const sideOffset2 = matrix.dotVec2(tangent, v12) + totalRadius;\n\n // Clip incident edge against extruded edge1 side edges.\n clipPoints1[0].recycle();\n clipPoints1[1].recycle();\n clipPoints2[0].recycle();\n clipPoints2[1].recycle();\n\n // Clip to box side 1\n matrix.setVec2(clipSegmentToLineNormal, -tangent.x, -tangent.y);\n const np1 = clipSegmentToLine(clipPoints1, incidentEdge, clipSegmentToLineNormal, sideOffset1, iv1);\n\n if (np1 < 2) {\n return;\n }\n\n // Clip to negative box side 1\n matrix.setVec2(clipSegmentToLineNormal, tangent.x, tangent.y);\n const np2 = clipSegmentToLine(clipPoints2, clipPoints1, clipSegmentToLineNormal, sideOffset2, iv2);\n\n if (np2 < 2) {\n return;\n }\n\n // Now clipPoints2 contains the clipped points.\n matrix.copyVec2(manifold.localNormal, localNormal);\n matrix.copyVec2(manifold.localPoint, planePoint);\n\n let pointCount = 0;\n for (let i = 0; i < clipPoints2.length/* maxManifoldPoints */; ++i) {\n const separation = matrix.dotVec2(normal, clipPoints2[i].v) - frontOffset;\n\n if (separation <= totalRadius) {\n const cp = manifold.points[pointCount];\n matrix.detransformVec2(cp.localPoint, xf2, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n if (flip) {\n // Swap features\n cp.id.swapFeatures();\n }\n ++pointCount;\n }\n }\n\n manifold.pointCount = pointCount;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { EPSILON } from \"../../common/Math\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { CircleShape } from \"./CircleShape\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(PolygonShape.TYPE, CircleShape.TYPE, PolygonCircleContact);\n\n/** @internal */ function PolygonCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == PolygonShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n CollidePolygonCircle(manifold, fixtureA.getShape() as PolygonShape, xfA, fixtureB.getShape() as CircleShape, xfB);\n}\n\n/** @internal */ const cLocal = matrix.vec2(0, 0);\n/** @internal */ const faceCenter = matrix.vec2(0, 0);\n\nexport const CollidePolygonCircle = function (manifold: Manifold, polygonA: PolygonShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n // Compute circle position in the frame of the polygon.\n matrix.retransformVec2(cLocal, xfB, xfA, circleB.m_p);\n\n // Find the min separating edge.\n let normalIndex = 0;\n let separation = -Infinity;\n const radius = polygonA.m_radius + circleB.m_radius;\n const vertexCount = polygonA.m_count;\n const vertices = polygonA.m_vertices;\n const normals = polygonA.m_normals;\n\n for (let i = 0; i < vertexCount; ++i) {\n const s = matrix.dotVec2(normals[i], cLocal) - matrix.dotVec2(normals[i], vertices[i]);\n\n if (s > radius) {\n // Early out.\n return;\n }\n\n if (s > separation) {\n separation = s;\n normalIndex = i;\n }\n }\n\n // Vertices that subtend the incident face.\n const vertIndex1 = normalIndex;\n const vertIndex2 = vertIndex1 + 1 < vertexCount ? vertIndex1 + 1 : 0;\n const v1 = vertices[vertIndex1];\n const v2 = vertices[vertIndex2];\n\n // If the center is inside the polygon ...\n if (separation < EPSILON) {\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, normals[normalIndex]);\n matrix.combine2Vec2(manifold.localPoint, 0.5, v1, 0.5, v2);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n return;\n }\n\n // Compute barycentric coordinates\n // u1 = (cLocal - v1) dot (v2 - v1))\n const u1 = matrix.dotVec2(cLocal, v2) - matrix.dotVec2(cLocal, v1) - matrix.dotVec2(v1, v2) + matrix.dotVec2(v1, v1);\n // u2 = (cLocal - v2) dot (v1 - v2)\n const u2 = matrix.dotVec2(cLocal, v1) - matrix.dotVec2(cLocal, v2) - matrix.dotVec2(v2, v1) + matrix.dotVec2(v2, v2);\n if (u1 <= 0.0) {\n if (matrix.distSqrVec2(cLocal, v1) > radius * radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.subVec2(manifold.localNormal, cLocal, v1);\n matrix.normalizeVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, v1);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n } else if (u2 <= 0.0) {\n if (matrix.distSqrVec2(cLocal, v2) > radius * radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.subVec2(manifold.localNormal, cLocal, v2);\n matrix.normalizeVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, v2);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n } else {\n matrix.combine2Vec2(faceCenter, 0.5, v1, 0.5, v2);\n const separation = matrix.dotVec2(cLocal, normals[vertIndex1]) - matrix.dotVec2(faceCenter, normals[vertIndex1]);\n if (separation > radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, normals[vertIndex1]);\n matrix.copyVec2(manifold.localPoint, faceCenter);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n }\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { Manifold, clipSegmentToLine, ClipVertex, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { EdgeShape } from \"./EdgeShape\";\nimport { ChainShape } from \"./ChainShape\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_min = Math.min;\n\nContact.addType(EdgeShape.TYPE, PolygonShape.TYPE, EdgePolygonContact);\nContact.addType(ChainShape.TYPE, PolygonShape.TYPE, ChainPolygonContact);\n\n/** @internal */ function EdgePolygonContact(manifold: Manifold, xfA: TransformValue, fA: Fixture, indexA: number, xfB: TransformValue, fB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fA.getType() == EdgeShape.TYPE);\n if (_ASSERT) console.assert(fB.getType() == PolygonShape.TYPE);\n\n CollideEdgePolygon(manifold, fA.getShape() as EdgeShape, xfA, fB.getShape() as PolygonShape, xfB);\n}\n\n// reused\n/** @internal */ const edge_reuse = new EdgeShape();\n\n/** @internal */ function ChainPolygonContact(manifold: Manifold, xfA: TransformValue, fA: Fixture, indexA: number, xfB: TransformValue, fB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fA.getType() == ChainShape.TYPE);\n if (_ASSERT) console.assert(fB.getType() == PolygonShape.TYPE);\n\n const chain = fA.getShape() as ChainShape;\n chain.getChildEdge(edge_reuse, indexA);\n\n CollideEdgePolygon(manifold, edge_reuse, xfA, fB.getShape() as PolygonShape, xfB);\n}\n\n/** @internal */ enum EPAxisType {\n e_unknown = -1,\n e_edgeA = 1,\n e_edgeB = 2,\n}\n\n// unused?\n/** @internal */ enum VertexType {\n e_isolated = 0,\n e_concave = 1,\n e_convex = 2,\n}\n\n/**\n * This structure is used to keep track of the best separating axis.\n */\n/** @internal */ class EPAxis {\n type: EPAxisType;\n index: number;\n separation: number;\n}\n\n/**\n * This holds polygon B expressed in frame A.\n */\n/** @internal */ class TempPolygon {\n vertices: Vec2Value[] = []; // [Settings.maxPolygonVertices]\n normals: Vec2Value[] = []; // [Settings.maxPolygonVertices];\n count: number = 0;\n constructor() {\n for (let i = 0; i < Settings.maxPolygonVertices; i++) {\n this.vertices.push(matrix.vec2(0, 0));\n this.normals.push(matrix.vec2(0, 0));\n }\n }\n}\n\n/**\n * Reference face used for clipping\n */\n/** @internal */ class ReferenceFace {\n i1: number;\n i2: number;\n readonly v1 = matrix.vec2(0 ,0);\n readonly v2 = matrix.vec2(0 ,0);\n readonly normal = matrix.vec2(0 ,0);\n readonly sideNormal1 = matrix.vec2(0 ,0);\n sideOffset1: number;\n readonly sideNormal2 = matrix.vec2(0 ,0);\n sideOffset2: number;\n recycle() {\n matrix.zeroVec2(this.v1);\n matrix.zeroVec2(this.v2);\n matrix.zeroVec2(this.normal);\n matrix.zeroVec2(this.sideNormal1);\n matrix.zeroVec2(this.sideNormal2);\n }\n}\n\n// reused\n/** @internal */ const clipPoints1 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints2 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const ie = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const edgeAxis = new EPAxis();\n/** @internal */ const polygonAxis = new EPAxis();\n/** @internal */ const polygonBA = new TempPolygon();\n/** @internal */ const rf = new ReferenceFace();\n/** @internal */ const centroidB = matrix.vec2(0, 0);\n/** @internal */ const edge0 = matrix.vec2(0, 0);\n/** @internal */ const edge1 = matrix.vec2(0, 0);\n/** @internal */ const edge2 = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const normal0 = matrix.vec2(0, 0);\n/** @internal */ const normal1 = matrix.vec2(0, 0);\n/** @internal */ const normal2 = matrix.vec2(0, 0);\n/** @internal */ const lowerLimit = matrix.vec2(0, 0);\n/** @internal */ const upperLimit = matrix.vec2(0, 0);\n/** @internal */ const perp = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n\n/**\n * This function collides and edge and a polygon, taking into account edge\n * adjacency.\n */\nexport const CollideEdgePolygon = function (manifold: Manifold, edgeA: EdgeShape, xfA: TransformValue, polygonB: PolygonShape, xfB: TransformValue): void {\n // Algorithm:\n // 1. Classify v1 and v2\n // 2. Classify polygon centroid as front or back\n // 3. Flip normal if necessary\n // 4. Initialize normal range to [-pi, pi] about face normal\n // 5. Adjust normal range according to adjacent edges\n // 6. Visit each separating axes, only accept axes within the range\n // 7. Return if _any_ axis indicates separation\n // 8. Clip\n\n // let m_type1: VertexType;\n // let m_type2: VertexType;\n\n matrix.detransformTransform(xf, xfA, xfB);\n matrix.transformVec2(centroidB, xf, polygonB.m_centroid);\n\n const v0 = edgeA.m_vertex0;\n const v1 = edgeA.m_vertex1;\n const v2 = edgeA.m_vertex2;\n const v3 = edgeA.m_vertex3;\n\n const hasVertex0 = edgeA.m_hasVertex0;\n const hasVertex3 = edgeA.m_hasVertex3;\n\n matrix.subVec2(edge1, v2, v1);\n matrix.normalizeVec2(edge1);\n matrix.setVec2(normal1, edge1.y, -edge1.x);\n const offset1 = matrix.dotVec2(normal1, centroidB) - matrix.dotVec2(normal1, v1);\n let offset0 = 0.0;\n let offset2 = 0.0;\n let convex1 = false;\n let convex2 = false;\n\n matrix.zeroVec2(normal0);\n matrix.zeroVec2(normal2);\n\n // Is there a preceding edge?\n if (hasVertex0) {\n matrix.subVec2(edge0, v1, v0);\n matrix.normalizeVec2(edge0);\n matrix.setVec2(normal0, edge0.y, -edge0.x);\n convex1 = matrix.crossVec2Vec2(edge0, edge1) >= 0.0;\n offset0 = Vec2.dot(normal0, centroidB) - Vec2.dot(normal0, v0);\n }\n\n // Is there a following edge?\n if (hasVertex3) {\n matrix.subVec2(edge2, v3, v2);\n matrix.normalizeVec2(edge2);\n matrix.setVec2(normal2, edge2.y, -edge2.x);\n convex2 = Vec2.crossVec2Vec2(edge1, edge2) > 0.0;\n offset2 = Vec2.dot(normal2, centroidB) - Vec2.dot(normal2, v2);\n }\n\n let front: boolean;\n matrix.zeroVec2(normal);\n matrix.zeroVec2(lowerLimit);\n matrix.zeroVec2(upperLimit);\n\n // Determine front or back collision. Determine collision normal limits.\n if (hasVertex0 && hasVertex3) {\n if (convex1 && convex2) {\n front = offset0 >= 0.0 || offset1 >= 0.0 || offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else if (convex1) {\n front = offset0 >= 0.0 || (offset1 >= 0.0 && offset2 >= 0.0);\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else if (convex2) {\n front = offset2 >= 0.0 || (offset0 >= 0.0 && offset1 >= 0.0);\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n } else {\n front = offset0 >= 0.0 && offset1 >= 0.0 && offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n }\n } else if (hasVertex0) {\n if (convex1) {\n front = offset0 >= 0.0 || offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else {\n front = offset0 >= 0.0 && offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n }\n } else if (hasVertex3) {\n if (convex2) {\n front = offset1 >= 0.0 || offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal1);\n }\n } else {\n front = offset1 >= 0.0 && offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.copyVec2(upperLimit, normal1);\n }\n }\n } else {\n front = offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal1);\n }\n }\n\n // Get polygonB in frameA\n polygonBA.count = polygonB.m_count;\n for (let i = 0; i < polygonB.m_count; ++i) {\n matrix.transformVec2(polygonBA.vertices[i], xf, polygonB.m_vertices[i]);\n matrix.rotVec2(polygonBA.normals[i], xf.q, polygonB.m_normals[i]);\n }\n\n const radius = polygonB.m_radius + edgeA.m_radius;\n\n manifold.pointCount = 0;\n\n { // ComputeEdgeSeparation\n edgeAxis.type = EPAxisType.e_edgeA;\n edgeAxis.index = front ? 0 : 1;\n edgeAxis.separation = Infinity;\n\n for (let i = 0; i < polygonBA.count; ++i) {\n const v = polygonBA.vertices[i];\n const s = matrix.dotVec2(normal, v) - matrix.dotVec2(normal, v1);\n if (s < edgeAxis.separation) {\n edgeAxis.separation = s;\n }\n }\n }\n\n // If no valid normal can be found than this edge should not collide.\n // @ts-ignore todo: why we need this if here?\n if (edgeAxis.type == EPAxisType.e_unknown) {\n return;\n }\n\n if (edgeAxis.separation > radius) {\n return;\n }\n\n { // ComputePolygonSeparation\n polygonAxis.type = EPAxisType.e_unknown;\n polygonAxis.index = -1;\n polygonAxis.separation = -Infinity;\n\n matrix.setVec2(perp, -normal.y, normal.x);\n\n for (let i = 0; i < polygonBA.count; ++i) {\n matrix.scaleVec2(n, -1, polygonBA.normals[i]);\n\n const s1 = matrix.dotVec2(n, polygonBA.vertices[i]) - matrix.dotVec2(n, v1);\n const s2 = matrix.dotVec2(n, polygonBA.vertices[i]) - matrix.dotVec2(n, v2);\n const s = math_min(s1, s2);\n\n if (s > radius) {\n // No collision\n polygonAxis.type = EPAxisType.e_edgeB;\n polygonAxis.index = i;\n polygonAxis.separation = s;\n break;\n }\n\n // Adjacency\n if (matrix.dotVec2(n, perp) >= 0.0) {\n if (matrix.dotVec2(n, normal) - matrix.dotVec2(upperLimit, normal) < -Settings.angularSlop) {\n continue;\n }\n } else {\n if (matrix.dotVec2(n, normal) - matrix.dotVec2(lowerLimit, normal) < -Settings.angularSlop) {\n continue;\n }\n }\n\n if (s > polygonAxis.separation) {\n polygonAxis.type = EPAxisType.e_edgeB;\n polygonAxis.index = i;\n polygonAxis.separation = s;\n }\n }\n }\n\n if (polygonAxis.type != EPAxisType.e_unknown && polygonAxis.separation > radius) {\n return;\n }\n\n // Use hysteresis for jitter reduction.\n const k_relativeTol = 0.98;\n const k_absoluteTol = 0.001;\n\n let primaryAxis: EPAxis;\n if (polygonAxis.type == EPAxisType.e_unknown) {\n primaryAxis = edgeAxis;\n } else if (polygonAxis.separation > k_relativeTol * edgeAxis.separation + k_absoluteTol) {\n primaryAxis = polygonAxis;\n } else {\n primaryAxis = edgeAxis;\n }\n\n ie[0].recycle();\n ie[1].recycle();\n\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n manifold.type = ManifoldType.e_faceA;\n\n // Search for the polygon normal that is most anti-parallel to the edge\n // normal.\n let bestIndex = 0;\n let bestValue = matrix.dotVec2(normal, polygonBA.normals[0]);\n for (let i = 1; i < polygonBA.count; ++i) {\n const value = matrix.dotVec2(normal, polygonBA.normals[i]);\n if (value < bestValue) {\n bestValue = value;\n bestIndex = i;\n }\n }\n\n const i1 = bestIndex;\n const i2 = i1 + 1 < polygonBA.count ? i1 + 1 : 0;\n\n matrix.copyVec2(ie[0].v, polygonBA.vertices[i1]);\n ie[0].id.setFeatures(0, ContactFeatureType.e_face, i1, ContactFeatureType.e_vertex);\n\n matrix.copyVec2(ie[1].v, polygonBA.vertices[i2]);\n ie[1].id.setFeatures(0, ContactFeatureType.e_face, i2, ContactFeatureType.e_vertex);\n\n if (front) {\n rf.i1 = 0;\n rf.i2 = 1;\n matrix.copyVec2(rf.v1, v1);\n matrix.copyVec2(rf.v2, v2);\n matrix.copyVec2(rf.normal, normal1);\n } else {\n rf.i1 = 1;\n rf.i2 = 0;\n matrix.copyVec2(rf.v1, v2);\n matrix.copyVec2(rf.v2, v1);\n matrix.scaleVec2(rf.normal, -1, normal1);\n }\n } else {\n manifold.type = ManifoldType.e_faceB;\n\n matrix.copyVec2(ie[0].v, v1);\n ie[0].id.setFeatures(0, ContactFeatureType.e_vertex, primaryAxis.index, ContactFeatureType.e_face);\n\n matrix.copyVec2(ie[1].v, v2);\n ie[1].id.setFeatures(0, ContactFeatureType.e_vertex, primaryAxis.index, ContactFeatureType.e_face);\n\n rf.i1 = primaryAxis.index;\n rf.i2 = rf.i1 + 1 < polygonBA.count ? rf.i1 + 1 : 0;\n matrix.copyVec2(rf.v1, polygonBA.vertices[rf.i1]);\n matrix.copyVec2(rf.v2, polygonBA.vertices[rf.i2]);\n matrix.copyVec2(rf.normal, polygonBA.normals[rf.i1]);\n }\n\n matrix.setVec2(rf.sideNormal1, rf.normal.y, -rf.normal.x);\n matrix.setVec2(rf.sideNormal2, -rf.sideNormal1.x, -rf.sideNormal1.y);\n rf.sideOffset1 = matrix.dotVec2(rf.sideNormal1, rf.v1);\n rf.sideOffset2 = matrix.dotVec2(rf.sideNormal2, rf.v2);\n\n // Clip incident edge against extruded edge1 side edges.\n clipPoints1[0].recycle();\n clipPoints1[1].recycle();\n clipPoints2[0].recycle();\n clipPoints2[1].recycle();\n\n // Clip to box side 1\n const np1 = clipSegmentToLine(clipPoints1, ie, rf.sideNormal1, rf.sideOffset1, rf.i1);\n\n if (np1 < Settings.maxManifoldPoints) {\n return;\n }\n\n // Clip to negative box side 1\n const np2 = clipSegmentToLine(clipPoints2, clipPoints1, rf.sideNormal2, rf.sideOffset2, rf.i2);\n\n if (np2 < Settings.maxManifoldPoints) {\n return;\n }\n\n // Now clipPoints2 contains the clipped points.\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n matrix.copyVec2(manifold.localNormal, rf.normal);\n matrix.copyVec2(manifold.localPoint, rf.v1);\n } else {\n matrix.copyVec2(manifold.localNormal, polygonB.m_normals[rf.i1]);\n matrix.copyVec2(manifold.localPoint, polygonB.m_vertices[rf.i1]);\n }\n\n let pointCount = 0;\n for (let i = 0; i < Settings.maxManifoldPoints; ++i) {\n const separation = matrix.dotVec2(rf.normal, clipPoints2[i].v) - matrix.dotVec2(rf.normal, rf.v1);\n\n if (separation <= radius) {\n const cp = manifold.points[pointCount]; // ManifoldPoint\n\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n matrix.detransformVec2(cp.localPoint, xf, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n } else {\n matrix.copyVec2(cp.localPoint, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n cp.id.swapFeatures();\n }\n\n ++pointCount;\n }\n }\n\n manifold.pointCount = pointCount;\n};\n","import { CollidePolygons } from \"./collision/shape/CollidePolygon\";\nimport { Settings } from \"./Settings\";\nimport { Sweep } from \"./common/Sweep\";\nimport { DynamicTree } from \"./collision/DynamicTree\";\nimport { Manifold } from \"./collision/Manifold\";\nimport { Distance } from \"./collision/Distance\";\nimport { TimeOfImpact } from \"./collision/TimeOfImpact\";\nimport { stats } from \"./util/stats\";\n\n/** @hidden @deprecated Merged with main namespace */\nexport const internal = {\n CollidePolygons,\n Settings,\n Sweep,\n Manifold,\n Distance,\n TimeOfImpact,\n DynamicTree,\n stats\n};\n","/**\n * Stage.js 1.0.0-alpha.5\n *\n * @copyright Copyright (c) 2024 Ali Shakiba\n * @license The MIT License (MIT)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\nvar math_random = Math.random;\nvar math_sqrt = Math.sqrt;\nfunction random(min, max) {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n return min == max ? min : math_random() * (max - min) + min;\n}\nfunction wrap(num, min, max) {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n if (max > min) {\n num = (num - min) % (max - min);\n return num + (num < 0 ? max : min);\n } else {\n num = (num - max) % (min - max);\n return num + (num <= 0 ? min : max);\n }\n}\nfunction clamp(num, min, max) {\n if (num < min) {\n return min;\n } else if (num > max) {\n return max;\n } else {\n return num;\n }\n}\nfunction length(x, y) {\n return math_sqrt(x * x + y * y);\n}\nvar math = Object.create(Math);\nmath.random = random;\nmath.wrap = wrap;\nmath.clamp = clamp;\nmath.length = length;\nmath.rotate = wrap;\nmath.limit = clamp;\nvar Matrix = (\n /** @class */\n function() {\n function Matrix2(a, b, c, d, e, f) {\n this.a = 1;\n this.b = 0;\n this.c = 0;\n this.d = 1;\n this.e = 0;\n this.f = 0;\n if (typeof a === \"object\") {\n this.reset(a);\n } else {\n this.reset(a, b, c, d, e, f);\n }\n }\n Matrix2.prototype.toString = function() {\n return \"[\" + this.a + \", \" + this.b + \", \" + this.c + \", \" + this.d + \", \" + this.e + \", \" + this.f + \"]\";\n };\n Matrix2.prototype.clone = function() {\n return new Matrix2(this.a, this.b, this.c, this.d, this.e, this.f);\n };\n Matrix2.prototype.reset = function(a, b, c, d, e, f) {\n this._dirty = true;\n if (typeof a === \"object\") {\n this.a = a.a;\n this.d = a.d;\n this.b = a.b;\n this.c = a.c;\n this.e = a.e;\n this.f = a.f;\n } else {\n this.a = typeof a === \"number\" ? a : 1;\n this.b = typeof b === \"number\" ? b : 0;\n this.c = typeof c === \"number\" ? c : 0;\n this.d = typeof d === \"number\" ? d : 1;\n this.e = typeof e === \"number\" ? e : 0;\n this.f = typeof f === \"number\" ? f : 0;\n }\n return this;\n };\n Matrix2.prototype.identity = function() {\n this._dirty = true;\n this.a = 1;\n this.b = 0;\n this.c = 0;\n this.d = 1;\n this.e = 0;\n this.f = 0;\n return this;\n };\n Matrix2.prototype.rotate = function(angle) {\n if (!angle) {\n return this;\n }\n this._dirty = true;\n var u = angle ? Math.cos(angle) : 1;\n var v = angle ? Math.sin(angle) : 0;\n var a = u * this.a - v * this.b;\n var b = u * this.b + v * this.a;\n var c = u * this.c - v * this.d;\n var d = u * this.d + v * this.c;\n var e = u * this.e - v * this.f;\n var f = u * this.f + v * this.e;\n this.a = a;\n this.b = b;\n this.c = c;\n this.d = d;\n this.e = e;\n this.f = f;\n return this;\n };\n Matrix2.prototype.translate = function(x, y) {\n if (!x && !y) {\n return this;\n }\n this._dirty = true;\n this.e += x;\n this.f += y;\n return this;\n };\n Matrix2.prototype.scale = function(x, y) {\n if (!(x - 1) && !(y - 1)) {\n return this;\n }\n this._dirty = true;\n this.a *= x;\n this.b *= y;\n this.c *= x;\n this.d *= y;\n this.e *= x;\n this.f *= y;\n return this;\n };\n Matrix2.prototype.skew = function(x, y) {\n if (!x && !y) {\n return this;\n }\n this._dirty = true;\n var a = this.a + this.b * x;\n var b = this.b + this.a * y;\n var c = this.c + this.d * x;\n var d = this.d + this.c * y;\n var e = this.e + this.f * x;\n var f = this.f + this.e * y;\n this.a = a;\n this.b = b;\n this.c = c;\n this.d = d;\n this.e = e;\n this.f = f;\n return this;\n };\n Matrix2.prototype.concat = function(m) {\n this._dirty = true;\n var a = this.a * m.a + this.b * m.c;\n var b = this.b * m.d + this.a * m.b;\n var c = this.c * m.a + this.d * m.c;\n var d = this.d * m.d + this.c * m.b;\n var e = this.e * m.a + m.e + this.f * m.c;\n var f = this.f * m.d + m.f + this.e * m.b;\n this.a = a;\n this.b = b;\n this.c = c;\n this.d = d;\n this.e = e;\n this.f = f;\n return this;\n };\n Matrix2.prototype.inverse = function() {\n if (this._dirty) {\n this._dirty = false;\n if (!this.inverted) {\n this.inverted = new Matrix2();\n }\n var z = this.a * this.d - this.b * this.c;\n this.inverted.a = this.d / z;\n this.inverted.b = -this.b / z;\n this.inverted.c = -this.c / z;\n this.inverted.d = this.a / z;\n this.inverted.e = (this.c * this.f - this.e * this.d) / z;\n this.inverted.f = (this.e * this.b - this.a * this.f) / z;\n }\n return this.inverted;\n };\n Matrix2.prototype.map = function(p, q) {\n q = q || { x: 0, y: 0 };\n q.x = this.a * p.x + this.c * p.y + this.e;\n q.y = this.b * p.x + this.d * p.y + this.f;\n return q;\n };\n Matrix2.prototype.mapX = function(x, y) {\n if (typeof x === \"object\") {\n y = x.y;\n x = x.x;\n }\n return this.a * x + this.c * y + this.e;\n };\n Matrix2.prototype.mapY = function(x, y) {\n if (typeof x === \"object\") {\n y = x.y;\n x = x.x;\n }\n return this.b * x + this.d * y + this.f;\n };\n return Matrix2;\n }()\n);\nvar objectToString = Object.prototype.toString;\nfunction isFn(value) {\n var str = objectToString.call(value);\n return str === \"[object Function]\" || str === \"[object GeneratorFunction]\" || str === \"[object AsyncFunction]\";\n}\nfunction isHash(value) {\n return objectToString.call(value) === \"[object Object]\" && value.constructor === Object;\n}\nconst stats = {\n create: 0,\n tick: 0,\n node: 0,\n draw: 0,\n fps: 0\n};\nvar uid = function() {\n return Date.now().toString(36) + Math.random().toString(36).slice(2);\n};\nvar Texture = (\n /** @class */\n function() {\n function Texture2() {\n this.uid = \"texture:\" + uid();\n this.sx = 0;\n this.sy = 0;\n this.dx = 0;\n this.dy = 0;\n }\n Texture2.prototype.setSourceCoordinate = function(x, y) {\n this.sx = x;\n this.sy = y;\n };\n Texture2.prototype.setSourceDimension = function(w, h) {\n this.sw = w;\n this.sh = h;\n };\n Texture2.prototype.setDestinationCoordinate = function(x, y) {\n this.dx = x;\n this.dy = y;\n };\n Texture2.prototype.setDestinationDimension = function(w, h) {\n this.dw = w;\n this.dh = h;\n };\n Texture2.prototype.draw = function(context, x1, y1, w1, h1, x2, y2, w2, h2) {\n var sx = this.sx;\n var sy = this.sy;\n var sw = this.sw;\n var sh = this.sh;\n var dx = this.dx;\n var dy = this.dy;\n var dw = this.dw;\n var dh = this.dh;\n if (typeof x1 === \"number\" || typeof y1 === \"number\" || typeof w1 === \"number\" || typeof h1 === \"number\" || typeof x2 === \"number\" || typeof y2 === \"number\" || typeof w2 === \"number\" || typeof h2 === \"number\") {\n if (typeof x2 === \"number\" || typeof y2 === \"number\" || typeof w2 === \"number\" || typeof h2 === \"number\") {\n sx += x1;\n sy += y1;\n sw = w1 !== null && w1 !== void 0 ? w1 : sw;\n sh = h1 !== null && h1 !== void 0 ? h1 : sh;\n dx += x2;\n dy += y2;\n dw = w2 !== null && w2 !== void 0 ? w2 : dw;\n dh = h2 !== null && h2 !== void 0 ? h2 : dh;\n } else {\n dx += x1;\n dy += y1;\n dw = w1;\n dh = h1;\n }\n }\n this.drawWithNormalizedArgs(context, sx, sy, sw, sh, dx, dy, dw, dh);\n };\n return Texture2;\n }()\n);\nvar __extends$9 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar ImageTexture = (\n /** @class */\n function(_super) {\n __extends$9(ImageTexture2, _super);\n function ImageTexture2(source, pixelRatio) {\n var _this = _super.call(this) || this;\n _this._pixelRatio = 1;\n if (typeof source === \"object\") {\n _this.setSourceImage(source, pixelRatio);\n }\n return _this;\n }\n ImageTexture2.prototype.setSourceImage = function(image2, pixelRatio) {\n if (pixelRatio === void 0) {\n pixelRatio = 1;\n }\n this._source = image2;\n this._pixelRatio = pixelRatio;\n };\n ImageTexture2.prototype.getWidth = function() {\n return this._source.width / this._pixelRatio;\n };\n ImageTexture2.prototype.getHeight = function() {\n return this._source.height / this._pixelRatio;\n };\n ImageTexture2.prototype.prerender = function(context) {\n return false;\n };\n ImageTexture2.prototype.drawWithNormalizedArgs = function(context, sx, sy, sw, sh, dx, dy, dw, dh) {\n var image2 = this._source;\n if (image2 === null || typeof image2 !== \"object\") {\n return;\n }\n sw = sw !== null && sw !== void 0 ? sw : this.getWidth();\n sh = sh !== null && sh !== void 0 ? sh : this.getHeight();\n dw = dw !== null && dw !== void 0 ? dw : sw;\n dh = dh !== null && dh !== void 0 ? dh : sh;\n sx *= this._pixelRatio;\n sy *= this._pixelRatio;\n sw *= this._pixelRatio;\n sh *= this._pixelRatio;\n try {\n stats.draw++;\n context.drawImage(image2, sx, sy, sw, sh, dx, dy, dw, dh);\n } catch (ex) {\n if (!this._draw_failed) {\n console.log(\"Unable to draw: \", image2);\n console.log(ex);\n this._draw_failed = true;\n }\n }\n };\n return ImageTexture2;\n }(Texture)\n);\nvar __extends$8 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar PipeTexture = (\n /** @class */\n function(_super) {\n __extends$8(PipeTexture2, _super);\n function PipeTexture2(source) {\n var _this = _super.call(this) || this;\n _this._source = source;\n return _this;\n }\n PipeTexture2.prototype.setSourceTexture = function(texture2) {\n this._source = texture2;\n };\n PipeTexture2.prototype.getWidth = function() {\n var _a, _b;\n return (_b = (_a = this.dw) !== null && _a !== void 0 ? _a : this.sw) !== null && _b !== void 0 ? _b : this._source.getWidth();\n };\n PipeTexture2.prototype.getHeight = function() {\n var _a, _b;\n return (_b = (_a = this.dh) !== null && _a !== void 0 ? _a : this.sh) !== null && _b !== void 0 ? _b : this._source.getHeight();\n };\n PipeTexture2.prototype.prerender = function(context) {\n return this._source.prerender(context);\n };\n PipeTexture2.prototype.drawWithNormalizedArgs = function(context, sx, sy, sw, sh, dx, dy, dw, dh) {\n var texture2 = this._source;\n if (texture2 === null || typeof texture2 !== \"object\") {\n return;\n }\n texture2.draw(context, sx, sy, sw, sh, dx, dy, dw, dh);\n };\n return PipeTexture2;\n }(Texture)\n);\nvar __extends$7 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar __awaiter$1 = function(thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function(resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function(resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator$1 = function(thisArg, body) {\n var _ = { label: 0, sent: function() {\n if (t[0] & 1)\n throw t[1];\n return t[1];\n }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() {\n return this;\n }), g;\n function verb(n) {\n return function(v) {\n return step([n, v]);\n };\n }\n function step(op) {\n if (f)\n throw new TypeError(\"Generator is already executing.\");\n while (_)\n try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)\n return t;\n if (y = 0, t)\n op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0:\n case 1:\n t = op;\n break;\n case 4:\n _.label++;\n return { value: op[1], done: false };\n case 5:\n _.label++;\n y = op[1];\n op = [0];\n continue;\n case 7:\n op = _.ops.pop();\n _.trys.pop();\n continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {\n _ = 0;\n continue;\n }\n if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {\n _.label = op[1];\n break;\n }\n if (op[0] === 6 && _.label < t[1]) {\n _.label = t[1];\n t = op;\n break;\n }\n if (t && _.label < t[2]) {\n _.label = t[2];\n _.ops.push(op);\n break;\n }\n if (t[2])\n _.ops.pop();\n _.trys.pop();\n continue;\n }\n op = body.call(thisArg, _);\n } catch (e) {\n op = [6, e];\n y = 0;\n } finally {\n f = t = 0;\n }\n if (op[0] & 5)\n throw op[1];\n return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar Atlas = (\n /** @class */\n function(_super) {\n __extends$7(Atlas2, _super);\n function Atlas2(def) {\n if (def === void 0) {\n def = {};\n }\n var _this = _super.call(this) || this;\n _this.pipeSpriteTexture = function(def2) {\n var map = _this._map;\n var ppu = _this._ppu;\n var trim = _this._trim;\n if (!def2) {\n return void 0;\n }\n def2 = Object.assign({}, def2);\n if (isFn(map)) {\n def2 = map(def2);\n }\n if (ppu != 1) {\n def2.x *= ppu;\n def2.y *= ppu;\n def2.width *= ppu;\n def2.height *= ppu;\n def2.top *= ppu;\n def2.bottom *= ppu;\n def2.left *= ppu;\n def2.right *= ppu;\n }\n if (trim != 0) {\n def2.x += trim;\n def2.y += trim;\n def2.width -= 2 * trim;\n def2.height -= 2 * trim;\n def2.top -= trim;\n def2.bottom -= trim;\n def2.left -= trim;\n def2.right -= trim;\n }\n var texture2 = new PipeTexture(_this);\n texture2.top = def2.top;\n texture2.bottom = def2.bottom;\n texture2.left = def2.left;\n texture2.right = def2.right;\n texture2.setSourceCoordinate(def2.x, def2.y);\n texture2.setSourceDimension(def2.width, def2.height);\n return texture2;\n };\n _this.findSpriteDefinition = function(query) {\n var textures = _this._textures;\n if (textures) {\n if (isFn(textures)) {\n return textures(query);\n } else if (isHash(textures)) {\n return textures[query];\n }\n }\n };\n _this.select = function(query) {\n if (!query) {\n return new TextureSelection(new PipeTexture(_this));\n }\n var textureDefinition = _this.findSpriteDefinition(query);\n if (textureDefinition) {\n return new TextureSelection(textureDefinition, _this);\n }\n };\n _this.name = def.name;\n _this._ppu = def.ppu || def.ratio || 1;\n _this._trim = def.trim || 0;\n _this._map = def.map || def.filter;\n _this._textures = def.textures;\n if (typeof def.image === \"object\" && isHash(def.image)) {\n _this._imageSrc = def.image.src || def.image.url;\n if (typeof def.image.ratio === \"number\") {\n _this._pixelRatio = def.image.ratio;\n }\n } else {\n if (typeof def.imagePath === \"string\") {\n _this._imageSrc = def.imagePath;\n } else if (typeof def.image === \"string\") {\n _this._imageSrc = def.image;\n }\n if (typeof def.imageRatio === \"number\") {\n _this._pixelRatio = def.imageRatio;\n }\n }\n deprecatedWarning(def);\n return _this;\n }\n Atlas2.prototype.load = function() {\n return __awaiter$1(this, void 0, void 0, function() {\n var image2;\n return __generator$1(this, function(_a) {\n switch (_a.label) {\n case 0:\n if (!this._imageSrc)\n return [3, 2];\n return [4, asyncLoadImage(this._imageSrc)];\n case 1:\n image2 = _a.sent();\n this.setSourceImage(image2, this._pixelRatio);\n _a.label = 2;\n case 2:\n return [\n 2\n /*return*/\n ];\n }\n });\n });\n };\n return Atlas2;\n }(ImageTexture)\n);\nfunction asyncLoadImage(src) {\n return new Promise(function(resolve, reject) {\n var img = new Image();\n img.onload = function() {\n resolve(img);\n };\n img.onerror = function(error) {\n console.error(\"Loading failed: \" + src);\n reject(error);\n };\n img.src = src;\n });\n}\nfunction deprecatedWarning(def) {\n if (\"filter\" in def)\n console.warn(\"'filter' field of atlas definition is deprecated\");\n if (\"cutouts\" in def)\n console.warn(\"'cutouts' field of atlas definition is deprecated\");\n if (\"sprites\" in def)\n console.warn(\"'sprites' field of atlas definition is deprecated\");\n if (\"factory\" in def)\n console.warn(\"'factory' field of atlas definition is deprecated\");\n if (\"ratio\" in def)\n console.warn(\"'ratio' field of atlas definition is deprecated\");\n if (\"imagePath\" in def)\n console.warn(\"'imagePath' field of atlas definition is deprecated\");\n if (\"imageRatio\" in def)\n console.warn(\"'imageRatio' field of atlas definition is deprecated\");\n if (typeof def.image === \"object\" && \"url\" in def.image)\n console.warn(\"'image.url' field of atlas definition is deprecated\");\n}\nvar __extends$6 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar __awaiter = function(thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function(resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function(resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = function(thisArg, body) {\n var _ = { label: 0, sent: function() {\n if (t[0] & 1)\n throw t[1];\n return t[1];\n }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() {\n return this;\n }), g;\n function verb(n) {\n return function(v) {\n return step([n, v]);\n };\n }\n function step(op) {\n if (f)\n throw new TypeError(\"Generator is already executing.\");\n while (_)\n try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)\n return t;\n if (y = 0, t)\n op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0:\n case 1:\n t = op;\n break;\n case 4:\n _.label++;\n return { value: op[1], done: false };\n case 5:\n _.label++;\n y = op[1];\n op = [0];\n continue;\n case 7:\n op = _.ops.pop();\n _.trys.pop();\n continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {\n _ = 0;\n continue;\n }\n if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {\n _.label = op[1];\n break;\n }\n if (op[0] === 6 && _.label < t[1]) {\n _.label = t[1];\n t = op;\n break;\n }\n if (t && _.label < t[2]) {\n _.label = t[2];\n _.ops.push(op);\n break;\n }\n if (t[2])\n _.ops.pop();\n _.trys.pop();\n continue;\n }\n op = body.call(thisArg, _);\n } catch (e) {\n op = [6, e];\n y = 0;\n } finally {\n f = t = 0;\n }\n if (op[0] & 5)\n throw op[1];\n return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nfunction isAtlasSpriteDefinition(selection) {\n return typeof selection === \"object\" && isHash(selection) && \"number\" === typeof selection.width && \"number\" === typeof selection.height;\n}\nvar TextureSelection = (\n /** @class */\n function() {\n function TextureSelection2(selection, atlas2) {\n this.selection = selection;\n this.atlas = atlas2;\n }\n TextureSelection2.prototype.resolve = function(selection, subquery) {\n if (!selection) {\n return NO_TEXTURE;\n } else if (Array.isArray(selection)) {\n return this.resolve(selection[0]);\n } else if (selection instanceof Texture) {\n return selection;\n } else if (isAtlasSpriteDefinition(selection)) {\n if (!this.atlas) {\n return NO_TEXTURE;\n }\n return this.atlas.pipeSpriteTexture(selection);\n } else if (typeof selection === \"object\" && isHash(selection) && typeof subquery !== \"undefined\") {\n return this.resolve(selection[subquery]);\n } else if (typeof selection === \"function\" && isFn(selection)) {\n return this.resolve(selection(subquery));\n } else if (typeof selection === \"string\") {\n if (!this.atlas) {\n return NO_TEXTURE;\n }\n return this.resolve(this.atlas.findSpriteDefinition(selection));\n }\n };\n TextureSelection2.prototype.one = function(subquery) {\n return this.resolve(this.selection, subquery);\n };\n TextureSelection2.prototype.array = function(arr) {\n var array = Array.isArray(arr) ? arr : [];\n if (Array.isArray(this.selection)) {\n for (var i = 0; i < this.selection.length; i++) {\n array[i] = this.resolve(this.selection[i]);\n }\n } else {\n array[0] = this.resolve(this.selection);\n }\n return array;\n };\n return TextureSelection2;\n }()\n);\nvar NO_TEXTURE = new /** @class */\n(function(_super) {\n __extends$6(class_1, _super);\n function class_1() {\n var _this = _super.call(this) || this;\n _this.setSourceDimension(0, 0);\n return _this;\n }\n class_1.prototype.getWidth = function() {\n return 0;\n };\n class_1.prototype.getHeight = function() {\n return 0;\n };\n class_1.prototype.prerender = function(context) {\n return false;\n };\n class_1.prototype.drawWithNormalizedArgs = function(context, sx, sy, sw, sh, dx, dy, dw, dh) {\n };\n class_1.prototype.setSourceCoordinate = function(x, y) {\n };\n class_1.prototype.setSourceDimension = function(w, h) {\n };\n class_1.prototype.setDestinationCoordinate = function(x, y) {\n };\n class_1.prototype.setDestinationDimension = function(w, h) {\n };\n class_1.prototype.draw = function() {\n };\n return class_1;\n}(Texture))();\nvar NO_SELECTION = new TextureSelection(NO_TEXTURE);\nvar ATLAS_MEMO_BY_NAME = {};\nvar ATLAS_ARRAY = [];\nfunction atlas(def) {\n return __awaiter(this, void 0, Promise, function() {\n var atlas2;\n return __generator(this, function(_a) {\n switch (_a.label) {\n case 0:\n if (def instanceof Atlas) {\n atlas2 = def;\n } else {\n atlas2 = new Atlas(def);\n }\n if (atlas2.name) {\n ATLAS_MEMO_BY_NAME[atlas2.name] = atlas2;\n }\n ATLAS_ARRAY.push(atlas2);\n return [4, atlas2.load()];\n case 1:\n _a.sent();\n return [2, atlas2];\n }\n });\n });\n}\nfunction texture(query) {\n if (\"string\" !== typeof query) {\n return new TextureSelection(query);\n }\n var result = null;\n var colonIndex = query.indexOf(\":\");\n if (colonIndex > 0 && query.length > colonIndex + 1) {\n var atlas_1 = ATLAS_MEMO_BY_NAME[query.slice(0, colonIndex)];\n result = atlas_1 && atlas_1.select(query.slice(colonIndex + 1));\n }\n if (!result) {\n var atlas_2 = ATLAS_MEMO_BY_NAME[query];\n result = atlas_2 && atlas_2.select();\n }\n if (!result) {\n for (var i = 0; i < ATLAS_ARRAY.length; i++) {\n result = ATLAS_ARRAY[i].select(query);\n if (result) {\n break;\n }\n }\n }\n if (!result) {\n console.error(\"Texture not found: \" + query);\n result = NO_SELECTION;\n }\n return result;\n}\nvar __extends$5 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar ResizableTexture = (\n /** @class */\n function(_super) {\n __extends$5(ResizableTexture2, _super);\n function ResizableTexture2(source, mode) {\n var _this = _super.call(this) || this;\n _this._source = source;\n _this._resizeMode = mode;\n return _this;\n }\n ResizableTexture2.prototype.getWidth = function() {\n var _a;\n return (_a = this.dw) !== null && _a !== void 0 ? _a : this._source.getWidth();\n };\n ResizableTexture2.prototype.getHeight = function() {\n var _a;\n return (_a = this.dh) !== null && _a !== void 0 ? _a : this._source.getHeight();\n };\n ResizableTexture2.prototype.prerender = function(context) {\n return false;\n };\n ResizableTexture2.prototype.drawWithNormalizedArgs = function(context, sx, sy, sw, sh, dx, dy, dw, dh) {\n var texture2 = this._source;\n if (texture2 === null || typeof texture2 !== \"object\") {\n return;\n }\n var outWidth = dw;\n var outHeight = dh;\n var left = Number.isFinite(texture2.left) ? texture2.left : 0;\n var right = Number.isFinite(texture2.right) ? texture2.right : 0;\n var top = Number.isFinite(texture2.top) ? texture2.top : 0;\n var bottom = Number.isFinite(texture2.bottom) ? texture2.bottom : 0;\n var width = texture2.getWidth() - left - right;\n var height = texture2.getHeight() - top - bottom;\n if (!this._innerSize) {\n outWidth = Math.max(outWidth - left - right, 0);\n outHeight = Math.max(outHeight - top - bottom, 0);\n }\n if (top > 0 && left > 0) {\n texture2.draw(context, 0, 0, left, top, 0, 0, left, top);\n }\n if (bottom > 0 && left > 0) {\n texture2.draw(context, 0, height + top, left, bottom, 0, outHeight + top, left, bottom);\n }\n if (top > 0 && right > 0) {\n texture2.draw(context, width + left, 0, right, top, outWidth + left, 0, right, top);\n }\n if (bottom > 0 && right > 0) {\n texture2.draw(context, width + left, height + top, right, bottom, outWidth + left, outHeight + top, right, bottom);\n }\n if (this._resizeMode === \"stretch\") {\n if (top > 0) {\n texture2.draw(context, left, 0, width, top, left, 0, outWidth, top);\n }\n if (bottom > 0) {\n texture2.draw(context, left, height + top, width, bottom, left, outHeight + top, outWidth, bottom);\n }\n if (left > 0) {\n texture2.draw(context, 0, top, left, height, 0, top, left, outHeight);\n }\n if (right > 0) {\n texture2.draw(context, width + left, top, right, height, outWidth + left, top, right, outHeight);\n }\n texture2.draw(context, left, top, width, height, left, top, outWidth, outHeight);\n } else if (this._resizeMode === \"tile\") {\n var l = left;\n var r = outWidth;\n var w = void 0;\n while (r > 0) {\n w = Math.min(width, r);\n r -= width;\n var t = top;\n var b = outHeight;\n var h = void 0;\n while (b > 0) {\n h = Math.min(height, b);\n b -= height;\n texture2.draw(context, left, top, w, h, l, t, w, h);\n if (r <= 0) {\n if (left) {\n texture2.draw(context, 0, top, left, h, 0, t, left, h);\n }\n if (right) {\n texture2.draw(context, width + left, top, right, h, l + w, t, right, h);\n }\n }\n t += h;\n }\n if (top) {\n texture2.draw(context, left, 0, w, top, l, 0, w, top);\n }\n if (bottom) {\n texture2.draw(context, left, height + top, w, bottom, l, t, w, bottom);\n }\n l += w;\n }\n }\n };\n return ResizableTexture2;\n }(Texture)\n);\nfunction getPixelRatio() {\n return typeof window !== \"undefined\" ? window.devicePixelRatio || 1 : 1;\n}\nfunction isValidFitMode(value) {\n return value && (value === \"cover\" || value === \"contain\" || value === \"fill\" || value === \"in\" || value === \"in-pad\" || value === \"out\" || value === \"out-crop\");\n}\nvar iid$1 = 0;\nvar Pin = (\n /** @class */\n function() {\n function Pin2(owner) {\n this.uid = \"pin:\" + uid();\n this._owner = owner;\n this._parent = null;\n this._relativeMatrix = new Matrix();\n this._absoluteMatrix = new Matrix();\n this.reset();\n }\n Pin2.prototype.reset = function() {\n this._textureAlpha = 1;\n this._alpha = 1;\n this._width = 0;\n this._height = 0;\n this._scaleX = 1;\n this._scaleY = 1;\n this._skewX = 0;\n this._skewY = 0;\n this._rotation = 0;\n this._pivoted = false;\n this._pivotX = 0;\n this._pivotY = 0;\n this._handled = false;\n this._handleX = 0;\n this._handleY = 0;\n this._aligned = false;\n this._alignX = 0;\n this._alignY = 0;\n this._offsetX = 0;\n this._offsetY = 0;\n this._boxX = 0;\n this._boxY = 0;\n this._boxWidth = this._width;\n this._boxHeight = this._height;\n this._ts_translate = ++iid$1;\n this._ts_transform = ++iid$1;\n this._ts_matrix = ++iid$1;\n };\n Pin2.prototype._update = function() {\n this._parent = this._owner._parent && this._owner._parent._pin;\n if (this._handled && this._mo_handle != this._ts_transform) {\n this._mo_handle = this._ts_transform;\n this._ts_translate = ++iid$1;\n }\n if (this._aligned && this._parent && this._mo_align != this._parent._ts_transform) {\n this._mo_align = this._parent._ts_transform;\n this._ts_translate = ++iid$1;\n }\n return this;\n };\n Pin2.prototype.toString = function() {\n return this._owner + \" (\" + (this._parent ? this._parent._owner : null) + \")\";\n };\n Pin2.prototype.absoluteMatrix = function() {\n this._update();\n var ts = Math.max(this._ts_transform, this._ts_translate, this._parent ? this._parent._ts_matrix : 0);\n if (this._mo_abs == ts) {\n return this._absoluteMatrix;\n }\n this._mo_abs = ts;\n var abs = this._absoluteMatrix;\n abs.reset(this.relativeMatrix());\n this._parent && abs.concat(this._parent._absoluteMatrix);\n this._ts_matrix = ++iid$1;\n return abs;\n };\n Pin2.prototype.relativeMatrix = function() {\n this._update();\n var ts = Math.max(this._ts_transform, this._ts_translate, this._parent ? this._parent._ts_transform : 0);\n if (this._mo_rel == ts) {\n return this._relativeMatrix;\n }\n this._mo_rel = ts;\n var rel = this._relativeMatrix;\n rel.identity();\n if (this._pivoted) {\n rel.translate(-this._pivotX * this._width, -this._pivotY * this._height);\n }\n rel.scale(this._scaleX, this._scaleY);\n rel.skew(this._skewX, this._skewY);\n rel.rotate(this._rotation);\n if (this._pivoted) {\n rel.translate(this._pivotX * this._width, this._pivotY * this._height);\n }\n if (this._pivoted) {\n this._boxX = 0;\n this._boxY = 0;\n this._boxWidth = this._width;\n this._boxHeight = this._height;\n } else {\n var p = void 0;\n var q = void 0;\n if (rel.a > 0 && rel.c > 0 || rel.a < 0 && rel.c < 0) {\n p = 0;\n q = rel.a * this._width + rel.c * this._height;\n } else {\n p = rel.a * this._width;\n q = rel.c * this._height;\n }\n if (p > q) {\n this._boxX = q;\n this._boxWidth = p - q;\n } else {\n this._boxX = p;\n this._boxWidth = q - p;\n }\n if (rel.b > 0 && rel.d > 0 || rel.b < 0 && rel.d < 0) {\n p = 0;\n q = rel.b * this._width + rel.d * this._height;\n } else {\n p = rel.b * this._width;\n q = rel.d * this._height;\n }\n if (p > q) {\n this._boxY = q;\n this._boxHeight = p - q;\n } else {\n this._boxY = p;\n this._boxHeight = q - p;\n }\n }\n this._x = this._offsetX;\n this._y = this._offsetY;\n this._x -= this._boxX + this._handleX * this._boxWidth;\n this._y -= this._boxY + this._handleY * this._boxHeight;\n if (this._aligned && this._parent) {\n this._parent.relativeMatrix();\n this._x += this._alignX * this._parent._width;\n this._y += this._alignY * this._parent._height;\n }\n rel.translate(this._x, this._y);\n return this._relativeMatrix;\n };\n Pin2.prototype.get = function(key) {\n if (typeof getters[key] === \"function\") {\n return getters[key](this);\n }\n };\n Pin2.prototype.set = function(a, b) {\n if (typeof a === \"string\") {\n if (typeof setters[a] === \"function\" && typeof b !== \"undefined\") {\n setters[a](this, b);\n }\n } else if (typeof a === \"object\") {\n for (b in a) {\n if (typeof setters[b] === \"function\" && typeof a[b] !== \"undefined\") {\n setters[b](this, a[b], a);\n }\n }\n }\n if (this._owner) {\n this._owner._ts_pin = ++iid$1;\n this._owner.touch();\n }\n return this;\n };\n Pin2.prototype.fit = function(width, height, mode) {\n this._ts_transform = ++iid$1;\n if (mode === \"contain\") {\n mode = \"in-pad\";\n }\n if (mode === \"cover\") {\n mode = \"out-crop\";\n }\n if (typeof width === \"number\") {\n this._scaleX = width / this._unscaled_width;\n this._width = this._unscaled_width;\n }\n if (typeof height === \"number\") {\n this._scaleY = height / this._unscaled_height;\n this._height = this._unscaled_height;\n }\n if (typeof width === \"number\" && typeof height === \"number\" && typeof mode === \"string\") {\n if (mode === \"fill\")\n ;\n else if (mode === \"out\" || mode === \"out-crop\") {\n this._scaleX = this._scaleY = Math.max(this._scaleX, this._scaleY);\n } else if (mode === \"in\" || mode === \"in-pad\") {\n this._scaleX = this._scaleY = Math.min(this._scaleX, this._scaleY);\n }\n if (mode === \"out-crop\" || mode === \"in-pad\") {\n this._width = width / this._scaleX;\n this._height = height / this._scaleY;\n }\n }\n };\n return Pin2;\n }()\n);\nvar getters = {\n alpha: function(pin) {\n return pin._alpha;\n },\n textureAlpha: function(pin) {\n return pin._textureAlpha;\n },\n width: function(pin) {\n return pin._width;\n },\n height: function(pin) {\n return pin._height;\n },\n boxWidth: function(pin) {\n return pin._boxWidth;\n },\n boxHeight: function(pin) {\n return pin._boxHeight;\n },\n // scale : function(pin: Pin) {\n // },\n scaleX: function(pin) {\n return pin._scaleX;\n },\n scaleY: function(pin) {\n return pin._scaleY;\n },\n // skew : function(pin: Pin) {\n // },\n skewX: function(pin) {\n return pin._skewX;\n },\n skewY: function(pin) {\n return pin._skewY;\n },\n rotation: function(pin) {\n return pin._rotation;\n },\n // pivot : function(pin: Pin) {\n // },\n pivotX: function(pin) {\n return pin._pivotX;\n },\n pivotY: function(pin) {\n return pin._pivotY;\n },\n // offset : function(pin: Pin) {\n // },\n offsetX: function(pin) {\n return pin._offsetX;\n },\n offsetY: function(pin) {\n return pin._offsetY;\n },\n // align : function(pin: Pin) {\n // },\n alignX: function(pin) {\n return pin._alignX;\n },\n alignY: function(pin) {\n return pin._alignY;\n },\n // handle : function(pin: Pin) {\n // },\n handleX: function(pin) {\n return pin._handleX;\n },\n handleY: function(pin) {\n return pin._handleY;\n }\n};\nvar setters = {\n alpha: function(pin, value) {\n pin._alpha = value;\n },\n textureAlpha: function(pin, value) {\n pin._textureAlpha = value;\n },\n width: function(pin, value) {\n pin._unscaled_width = value;\n pin._width = value;\n pin._ts_transform = ++iid$1;\n },\n height: function(pin, value) {\n pin._unscaled_height = value;\n pin._height = value;\n pin._ts_transform = ++iid$1;\n },\n scale: function(pin, value) {\n pin._scaleX = value;\n pin._scaleY = value;\n pin._ts_transform = ++iid$1;\n },\n scaleX: function(pin, value) {\n pin._scaleX = value;\n pin._ts_transform = ++iid$1;\n },\n scaleY: function(pin, value) {\n pin._scaleY = value;\n pin._ts_transform = ++iid$1;\n },\n skew: function(pin, value) {\n pin._skewX = value;\n pin._skewY = value;\n pin._ts_transform = ++iid$1;\n },\n skewX: function(pin, value) {\n pin._skewX = value;\n pin._ts_transform = ++iid$1;\n },\n skewY: function(pin, value) {\n pin._skewY = value;\n pin._ts_transform = ++iid$1;\n },\n rotation: function(pin, value) {\n pin._rotation = value;\n pin._ts_transform = ++iid$1;\n },\n pivot: function(pin, value) {\n pin._pivotX = value;\n pin._pivotY = value;\n pin._pivoted = true;\n pin._ts_transform = ++iid$1;\n },\n pivotX: function(pin, value) {\n pin._pivotX = value;\n pin._pivoted = true;\n pin._ts_transform = ++iid$1;\n },\n pivotY: function(pin, value) {\n pin._pivotY = value;\n pin._pivoted = true;\n pin._ts_transform = ++iid$1;\n },\n offset: function(pin, value) {\n pin._offsetX = value;\n pin._offsetY = value;\n pin._ts_translate = ++iid$1;\n },\n offsetX: function(pin, value) {\n pin._offsetX = value;\n pin._ts_translate = ++iid$1;\n },\n offsetY: function(pin, value) {\n pin._offsetY = value;\n pin._ts_translate = ++iid$1;\n },\n align: function(pin, value) {\n this.alignX(pin, value);\n this.alignY(pin, value);\n },\n alignX: function(pin, value) {\n pin._alignX = value;\n pin._aligned = true;\n pin._ts_translate = ++iid$1;\n this.handleX(pin, value);\n },\n alignY: function(pin, value) {\n pin._alignY = value;\n pin._aligned = true;\n pin._ts_translate = ++iid$1;\n this.handleY(pin, value);\n },\n handle: function(pin, value) {\n this.handleX(pin, value);\n this.handleY(pin, value);\n },\n handleX: function(pin, value) {\n pin._handleX = value;\n pin._handled = true;\n pin._ts_translate = ++iid$1;\n },\n handleY: function(pin, value) {\n pin._handleY = value;\n pin._handled = true;\n pin._ts_translate = ++iid$1;\n },\n resizeMode: function(pin, value, all) {\n if (all) {\n if (value == \"in\") {\n value = \"in-pad\";\n } else if (value == \"out\") {\n value = \"out-crop\";\n }\n pin.fit(all.resizeWidth, all.resizeHeight, value);\n }\n },\n resizeWidth: function(pin, value, all) {\n if (!all || !all.resizeMode) {\n pin.fit(value, null);\n }\n },\n resizeHeight: function(pin, value, all) {\n if (!all || !all.resizeMode) {\n pin.fit(null, value);\n }\n },\n scaleMode: function(pin, value, all) {\n if (all) {\n pin.fit(all.scaleWidth, all.scaleHeight, value);\n }\n },\n scaleWidth: function(pin, value, all) {\n if (!all || !all.scaleMode) {\n pin.fit(value, null);\n }\n },\n scaleHeight: function(pin, value, all) {\n if (!all || !all.scaleMode) {\n pin.fit(null, value);\n }\n },\n matrix: function(pin, value) {\n this.scaleX(pin, value.a);\n this.skewX(pin, value.c / value.d);\n this.skewY(pin, value.b / value.a);\n this.scaleY(pin, value.d);\n this.offsetX(pin, value.e);\n this.offsetY(pin, value.f);\n this.rotation(pin, 0);\n }\n};\nfunction IDENTITY(x) {\n return x;\n}\nvar LOOKUP_CACHE = {};\nvar MODE_BY_NAME = {};\nvar EASE_BY_NAME = {};\nvar Easing = (\n /** @class */\n function() {\n function Easing2() {\n }\n Easing2.get = function(token, fallback) {\n fallback = fallback || IDENTITY;\n if (typeof token === \"function\") {\n return token;\n }\n if (typeof token !== \"string\") {\n return fallback;\n }\n var easeFn = LOOKUP_CACHE[token];\n if (easeFn) {\n return easeFn;\n }\n var tokens = /^(\\w+)(-(in|out|in-out|out-in))?(\\((.*)\\))?$/i.exec(token);\n if (!tokens || !tokens.length) {\n return fallback;\n }\n var easeName = tokens[1];\n var easing = EASE_BY_NAME[easeName];\n var modeName = tokens[3];\n var modeFn = MODE_BY_NAME[modeName];\n var params = tokens[5];\n if (!easing) {\n easeFn = fallback;\n } else if (\"fn\" in easing && typeof easing.fn === \"function\") {\n easeFn = easing.fn;\n } else if (\"fc\" in easing && typeof easing.fc === \"function\") {\n var args = params ? params.replace(/\\s+/, \"\").split(\",\") : void 0;\n easeFn = easing.fc.apply(easing.fc, args);\n } else {\n easeFn = fallback;\n }\n if (modeFn) {\n easeFn = modeFn(easeFn);\n }\n LOOKUP_CACHE[token] = easeFn;\n return easeFn;\n };\n return Easing2;\n }()\n);\nfunction addMode(name, fn) {\n MODE_BY_NAME[name] = fn;\n}\nfunction addEaseFn(data) {\n var names = data.name.split(/\\s+/);\n for (var i = 0; i < names.length; i++) {\n var key = names[i];\n if (key) {\n EASE_BY_NAME[key] = data;\n }\n }\n}\naddMode(\"in\", function(f) {\n return f;\n});\naddMode(\"out\", function(f) {\n return function(t) {\n return 1 - f(1 - t);\n };\n});\naddMode(\"in-out\", function(f) {\n return function(t) {\n return t < 0.5 ? f(2 * t) / 2 : 1 - f(2 * (1 - t)) / 2;\n };\n});\naddMode(\"out-in\", function(f) {\n return function(t) {\n return t < 0.5 ? 1 - f(2 * (1 - t)) / 2 : f(2 * t) / 2;\n };\n});\naddEaseFn({\n name: \"linear\",\n fn: function(t) {\n return t;\n }\n});\naddEaseFn({\n name: \"quad\",\n fn: function(t) {\n return t * t;\n }\n});\naddEaseFn({\n name: \"cubic\",\n fn: function(t) {\n return t * t * t;\n }\n});\naddEaseFn({\n name: \"quart\",\n fn: function(t) {\n return t * t * t * t;\n }\n});\naddEaseFn({\n name: \"quint\",\n fn: function(t) {\n return t * t * t * t * t;\n }\n});\naddEaseFn({\n name: \"sin sine\",\n fn: function(t) {\n return 1 - Math.cos(t * Math.PI / 2);\n }\n});\naddEaseFn({\n name: \"exp expo\",\n fn: function(t) {\n return t == 0 ? 0 : Math.pow(2, 10 * (t - 1));\n }\n});\naddEaseFn({\n name: \"circle circ\",\n fn: function(t) {\n return 1 - Math.sqrt(1 - t * t);\n }\n});\naddEaseFn({\n name: \"bounce\",\n fn: function(t) {\n return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + 0.75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + 0.9375 : 7.5625 * (t -= 2.625 / 2.75) * t + 0.984375;\n }\n});\naddEaseFn({\n name: \"poly\",\n fc: function(e) {\n return function(t) {\n return Math.pow(t, e);\n };\n }\n});\naddEaseFn({\n name: \"elastic\",\n fc: function(a, p) {\n p = p || 0.45;\n a = a || 1;\n var s = p / (2 * Math.PI) * Math.asin(1 / a);\n return function(t) {\n return 1 + a * Math.pow(2, -10 * t) * Math.sin((t - s) * (2 * Math.PI) / p);\n };\n }\n});\naddEaseFn({\n name: \"back\",\n fc: function(s) {\n s = typeof s !== \"undefined\" ? s : 1.70158;\n return function(t) {\n return t * t * ((s + 1) * t - s);\n };\n }\n});\nvar Transition = (\n /** @class */\n function() {\n function Transition2(owner, options) {\n if (options === void 0) {\n options = {};\n }\n this.uid = \"transition:\" + uid();\n this._ending = [];\n this._end = {};\n this._duration = options.duration || 400;\n this._delay = options.delay || 0;\n this._owner = owner;\n this._time = 0;\n }\n Transition2.prototype.tick = function(node, elapsed, now, last) {\n this._time += elapsed;\n if (this._time < this._delay) {\n return;\n }\n var time = this._time - this._delay;\n if (!this._start) {\n this._start = {};\n for (var key in this._end) {\n this._start[key] = this._owner.pin(key);\n }\n }\n var p = Math.min(time / this._duration, 1);\n var ended = p >= 1;\n if (typeof this._easing == \"function\") {\n p = this._easing(p);\n }\n var q = 1 - p;\n for (var key in this._end) {\n this._owner.pin(key, this._start[key] * q + this._end[key] * p);\n }\n return ended;\n };\n Transition2.prototype.finish = function() {\n var _this = this;\n this._ending.forEach(function(callback) {\n try {\n callback.call(_this._owner);\n } catch (e) {\n console.error(e);\n }\n });\n return this._next;\n };\n Transition2.prototype.tween = function(a, b) {\n var options;\n if (typeof a === \"object\" && a !== null) {\n options = a;\n } else {\n options = {};\n if (typeof a === \"number\") {\n options.duration = a;\n if (typeof b === \"number\") {\n options.delay = b;\n }\n }\n }\n return this._next = new Transition2(this._owner, options);\n };\n Transition2.prototype.duration = function(duration) {\n this._duration = duration;\n return this;\n };\n Transition2.prototype.delay = function(delay) {\n this._delay = delay;\n return this;\n };\n Transition2.prototype.ease = function(easing) {\n this._easing = Easing.get(easing);\n return this;\n };\n Transition2.prototype.done = function(fn) {\n this._ending.push(fn);\n return this;\n };\n Transition2.prototype.hide = function() {\n this._ending.push(function() {\n this.hide();\n });\n this._hide = true;\n return this;\n };\n Transition2.prototype.remove = function() {\n this._ending.push(function() {\n this.remove();\n });\n this._remove = true;\n return this;\n };\n Transition2.prototype.pin = function(a, b) {\n if (typeof a === \"object\") {\n for (var attr in a) {\n pinning(this._owner, this._end, attr, a[attr]);\n }\n } else if (typeof b !== \"undefined\") {\n pinning(this._owner, this._end, a, b);\n }\n return this;\n };\n Transition2.prototype.then = function(fn) {\n this.done(fn);\n return this;\n };\n Transition2.prototype.clear = function(forward) {\n return this;\n };\n Transition2.prototype.size = function(w, h) {\n this.pin(\"width\", w);\n this.pin(\"height\", h);\n return this;\n };\n Transition2.prototype.width = function(w) {\n if (typeof w === \"undefined\") {\n return this.pin(\"width\");\n }\n this.pin(\"width\", w);\n return this;\n };\n Transition2.prototype.height = function(h) {\n if (typeof h === \"undefined\") {\n return this.pin(\"height\");\n }\n this.pin(\"height\", h);\n return this;\n };\n Transition2.prototype.offset = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n }\n this.pin(\"offsetX\", a);\n this.pin(\"offsetY\", b);\n return this;\n };\n Transition2.prototype.rotate = function(a) {\n this.pin(\"rotation\", a);\n return this;\n };\n Transition2.prototype.skew = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n } else if (typeof b === \"undefined\") {\n b = a;\n }\n this.pin(\"skewX\", a);\n this.pin(\"skewY\", b);\n return this;\n };\n Transition2.prototype.scale = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n } else if (typeof b === \"undefined\") {\n b = a;\n }\n this.pin(\"scaleX\", a);\n this.pin(\"scaleY\", b);\n return this;\n };\n Transition2.prototype.alpha = function(a, ta) {\n this.pin(\"alpha\", a);\n if (typeof ta !== \"undefined\") {\n this.pin(\"textureAlpha\", ta);\n }\n return this;\n };\n return Transition2;\n }()\n);\nfunction pinning(node, map, key, value) {\n if (typeof node.pin(key) === \"number\") {\n map[key] = value;\n } else if (typeof node.pin(key + \"X\") === \"number\" && typeof node.pin(key + \"Y\") === \"number\") {\n map[key + \"X\"] = value;\n map[key + \"Y\"] = value;\n }\n}\nvar iid = 0;\nstats.create = 0;\nfunction assertType(obj) {\n if (obj && obj instanceof Node) {\n return obj;\n }\n throw \"Invalid node: \" + obj;\n}\nfunction create() {\n return layout();\n}\nfunction layer() {\n return maximize();\n}\nfunction box() {\n return minimize();\n}\nfunction layout() {\n return new Node();\n}\nfunction row(align) {\n return layout().row(align).label(\"Row\");\n}\nfunction column(align) {\n return layout().column(align).label(\"Column\");\n}\nfunction minimize() {\n return layout().minimize().label(\"Minimize\");\n}\nfunction maximize() {\n return layout().maximize().label(\"Maximize\");\n}\nvar Node = (\n /** @class */\n function() {\n function Node2() {\n var _this = this;\n this.uid = \"node:\" + uid();\n this._label = \"\";\n this._parent = null;\n this._next = null;\n this._prev = null;\n this._first = null;\n this._last = null;\n this._visible = true;\n this._alpha = 1;\n this._padding = 0;\n this._spacing = 0;\n this._pin = new Pin(this);\n this._listeners = {};\n this._attrs = {};\n this._flags = {};\n this._transitions = [];\n this._tickBefore = [];\n this._tickAfter = [];\n this.MAX_ELAPSE = Infinity;\n this._transitionTickInitied = false;\n this._transitionTickLastTime = 0;\n this._transitionTick = function(elapsed, now, last) {\n if (!_this._transitions.length) {\n return false;\n }\n var ignore = _this._transitionTickLastTime !== last;\n _this._transitionTickLastTime = now;\n if (ignore) {\n return true;\n }\n var head = _this._transitions[0];\n var ended = head.tick(_this, elapsed, now, last);\n if (ended) {\n if (head === _this._transitions[0]) {\n _this._transitions.shift();\n }\n var next = head.finish();\n if (next) {\n _this._transitions.unshift(next);\n }\n }\n return true;\n };\n stats.create++;\n }\n Node2.prototype.matrix = function(relative) {\n if (relative === void 0) {\n relative = false;\n }\n if (relative === true) {\n return this._pin.relativeMatrix();\n }\n return this._pin.absoluteMatrix();\n };\n Node2.prototype.getPixelRatio = function() {\n var _a;\n var m = (_a = this._parent) === null || _a === void 0 ? void 0 : _a.matrix();\n var pixelRatio = !m ? 1 : Math.max(Math.abs(m.a), Math.abs(m.b)) / getPixelRatio();\n return pixelRatio;\n };\n Node2.prototype.pin = function(a, b) {\n if (typeof a === \"object\") {\n this._pin.set(a);\n return this;\n } else if (typeof a === \"string\") {\n if (typeof b === \"undefined\") {\n return this._pin.get(a);\n } else {\n this._pin.set(a, b);\n return this;\n }\n } else if (typeof a === \"undefined\") {\n return this._pin;\n }\n };\n Node2.prototype.fit = function(a, b, c) {\n if (typeof a === \"object\") {\n c = b;\n b = a.y;\n a = a.x;\n }\n this._pin.fit(a, b, c);\n return this;\n };\n Node2.prototype.scaleTo = function(a, b, c) {\n return this.fit(a, b, c);\n };\n Node2.prototype.toString = function() {\n return \"[\" + this._label + \"]\";\n };\n Node2.prototype.id = function(id) {\n return this.label(id);\n };\n Node2.prototype.label = function(label) {\n if (typeof label === \"undefined\") {\n return this._label;\n }\n this._label = label;\n return this;\n };\n Node2.prototype.attr = function(name, value) {\n if (typeof value === \"undefined\") {\n return this._attrs !== null ? this._attrs[name] : void 0;\n }\n (this._attrs !== null ? this._attrs : this._attrs = {})[name] = value;\n return this;\n };\n Node2.prototype.visible = function(visible) {\n if (typeof visible === \"undefined\") {\n return this._visible;\n }\n this._visible = visible;\n this._parent && (this._parent._ts_children = ++iid);\n this._ts_pin = ++iid;\n this.touch();\n return this;\n };\n Node2.prototype.hide = function() {\n this.visible(false);\n return this;\n };\n Node2.prototype.show = function() {\n this.visible(true);\n return this;\n };\n Node2.prototype.parent = function() {\n return this._parent;\n };\n Node2.prototype.next = function(visible) {\n var next = this._next;\n while (next && visible && !next._visible) {\n next = next._next;\n }\n return next;\n };\n Node2.prototype.prev = function(visible) {\n var prev = this._prev;\n while (prev && visible && !prev._visible) {\n prev = prev._prev;\n }\n return prev;\n };\n Node2.prototype.first = function(visible) {\n var next = this._first;\n while (next && visible && !next._visible) {\n next = next._next;\n }\n return next;\n };\n Node2.prototype.last = function(visible) {\n var prev = this._last;\n while (prev && visible && !prev._visible) {\n prev = prev._prev;\n }\n return prev;\n };\n Node2.prototype.visit = function(visitor, payload) {\n var reverse = visitor.reverse;\n var visible = visitor.visible;\n if (visitor.start && visitor.start(this, payload)) {\n return;\n }\n var child;\n var next = reverse ? this.last(visible) : this.first(visible);\n while (child = next) {\n next = reverse ? child.prev(visible) : child.next(visible);\n if (child.visit(visitor, payload)) {\n return true;\n }\n }\n return visitor.end && visitor.end(this, payload);\n };\n Node2.prototype.append = function(child, more) {\n if (Array.isArray(child)) {\n for (var i = 0; i < child.length; i++) {\n Node2.append(this, child[i]);\n }\n } else if (typeof more !== \"undefined\") {\n for (var i = 0; i < arguments.length; i++) {\n Node2.append(this, arguments[i]);\n }\n } else if (typeof child !== \"undefined\")\n Node2.append(this, child);\n return this;\n };\n Node2.prototype.prepend = function(child, more) {\n if (Array.isArray(child)) {\n for (var i = child.length - 1; i >= 0; i--) {\n Node2.prepend(this, child[i]);\n }\n } else if (typeof more !== \"undefined\") {\n for (var i = arguments.length - 1; i >= 0; i--) {\n Node2.prepend(this, arguments[i]);\n }\n } else if (typeof child !== \"undefined\")\n Node2.prepend(this, child);\n return this;\n };\n Node2.prototype.appendTo = function(parent) {\n Node2.append(parent, this);\n return this;\n };\n Node2.prototype.prependTo = function(parent) {\n Node2.prepend(parent, this);\n return this;\n };\n Node2.prototype.insertNext = function(sibling, more) {\n if (Array.isArray(sibling)) {\n for (var i = 0; i < sibling.length; i++) {\n Node2.insertAfter(sibling[i], this);\n }\n } else if (typeof more !== \"undefined\") {\n for (var i = 0; i < arguments.length; i++) {\n Node2.insertAfter(arguments[i], this);\n }\n } else if (typeof sibling !== \"undefined\") {\n Node2.insertAfter(sibling, this);\n }\n return this;\n };\n Node2.prototype.insertPrev = function(sibling, more) {\n if (Array.isArray(sibling)) {\n for (var i = sibling.length - 1; i >= 0; i--) {\n Node2.insertBefore(sibling[i], this);\n }\n } else if (typeof more !== \"undefined\") {\n for (var i = arguments.length - 1; i >= 0; i--) {\n Node2.insertBefore(arguments[i], this);\n }\n } else if (typeof sibling !== \"undefined\") {\n Node2.insertBefore(sibling, this);\n }\n return this;\n };\n Node2.prototype.insertAfter = function(prev) {\n Node2.insertAfter(this, prev);\n return this;\n };\n Node2.prototype.insertBefore = function(next) {\n Node2.insertBefore(this, next);\n return this;\n };\n Node2.append = function(parent, child) {\n assertType(child);\n assertType(parent);\n child.remove();\n if (parent._last) {\n parent._last._next = child;\n child._prev = parent._last;\n }\n child._parent = parent;\n parent._last = child;\n if (!parent._first) {\n parent._first = child;\n }\n child._parent._flag(child, true);\n child._ts_parent = ++iid;\n parent._ts_children = ++iid;\n parent.touch();\n };\n Node2.prepend = function(parent, child) {\n assertType(child);\n assertType(parent);\n child.remove();\n if (parent._first) {\n parent._first._prev = child;\n child._next = parent._first;\n }\n child._parent = parent;\n parent._first = child;\n if (!parent._last) {\n parent._last = child;\n }\n child._parent._flag(child, true);\n child._ts_parent = ++iid;\n parent._ts_children = ++iid;\n parent.touch();\n };\n Node2.insertBefore = function(self, next) {\n assertType(self);\n assertType(next);\n self.remove();\n var parent = next._parent;\n var prev = next._prev;\n if (!parent) {\n return;\n }\n next._prev = self;\n prev && (prev._next = self) || parent && (parent._first = self);\n self._parent = parent;\n self._prev = prev;\n self._next = next;\n self._parent._flag(self, true);\n self._ts_parent = ++iid;\n self.touch();\n };\n Node2.insertAfter = function(self, prev) {\n assertType(self);\n assertType(prev);\n self.remove();\n var parent = prev._parent;\n var next = prev._next;\n if (!parent) {\n return;\n }\n prev._next = self;\n next && (next._prev = self) || parent && (parent._last = self);\n self._parent = parent;\n self._prev = prev;\n self._next = next;\n self._parent._flag(self, true);\n self._ts_parent = ++iid;\n self.touch();\n };\n Node2.prototype.remove = function(child, more) {\n if (typeof child !== \"undefined\") {\n if (Array.isArray(child)) {\n for (var i = 0; i < child.length; i++) {\n assertType(child[i]).remove();\n }\n } else if (typeof more !== \"undefined\") {\n for (var i = 0; i < arguments.length; i++) {\n assertType(arguments[i]).remove();\n }\n } else {\n assertType(child).remove();\n }\n return this;\n }\n if (this._prev) {\n this._prev._next = this._next;\n }\n if (this._next) {\n this._next._prev = this._prev;\n }\n if (this._parent) {\n if (this._parent._first === this) {\n this._parent._first = this._next;\n }\n if (this._parent._last === this) {\n this._parent._last = this._prev;\n }\n this._parent._flag(this, false);\n this._parent._ts_children = ++iid;\n this._parent.touch();\n }\n this._prev = this._next = this._parent = null;\n this._ts_parent = ++iid;\n return this;\n };\n Node2.prototype.empty = function() {\n var child = null;\n var next = this._first;\n while (child = next) {\n next = child._next;\n child._prev = child._next = child._parent = null;\n this._flag(child, false);\n }\n this._first = this._last = null;\n this._ts_children = ++iid;\n this.touch();\n return this;\n };\n Node2.prototype.touch = function() {\n this._ts_touch = ++iid;\n this._parent && this._parent.touch();\n return this;\n };\n Node2.prototype._flag = function(key, value) {\n if (typeof value === \"undefined\") {\n return this._flags !== null && this._flags[key] || 0;\n }\n if (typeof key === \"string\") {\n if (value) {\n this._flags = this._flags || {};\n if (!this._flags[key] && this._parent) {\n this._parent._flag(key, true);\n }\n this._flags[key] = (this._flags[key] || 0) + 1;\n } else if (this._flags && this._flags[key] > 0) {\n if (this._flags[key] == 1 && this._parent) {\n this._parent._flag(key, false);\n }\n this._flags[key] = this._flags[key] - 1;\n }\n }\n if (typeof key === \"object\") {\n if (key._flags) {\n for (var type in key._flags) {\n if (key._flags[type] > 0) {\n this._flag(type, value);\n }\n }\n }\n }\n return this;\n };\n Node2.prototype.hitTest = function(hit) {\n var width = this._pin._width;\n var height = this._pin._height;\n return hit.x >= 0 && hit.x <= width && hit.y >= 0 && hit.y <= height;\n };\n Node2.prototype.prerender = function() {\n if (!this._visible) {\n return;\n }\n var child;\n var next = this._first;\n while (child = next) {\n next = child._next;\n child.prerender();\n }\n };\n Node2.prototype.render = function(context) {\n if (!this._visible) {\n return;\n }\n stats.node++;\n var m = this.matrix();\n context.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);\n this._alpha = this._pin._alpha * (this._parent ? this._parent._alpha : 1);\n var alpha = this._pin._textureAlpha * this._alpha;\n if (context.globalAlpha != alpha) {\n context.globalAlpha = alpha;\n }\n if (this._textures) {\n for (var i = 0, n = this._textures.length; i < n; i++) {\n this._textures[i].draw(context);\n }\n }\n if (context.globalAlpha != this._alpha) {\n context.globalAlpha = this._alpha;\n }\n var child;\n var next = this._first;\n while (child = next) {\n next = child._next;\n child.render(context);\n }\n };\n Node2.prototype._tick = function(elapsed, now, last) {\n if (!this._visible) {\n return;\n }\n if (elapsed > this.MAX_ELAPSE) {\n elapsed = this.MAX_ELAPSE;\n }\n var ticked = false;\n if (this._tickBefore !== null) {\n for (var i = 0; i < this._tickBefore.length; i++) {\n stats.tick++;\n var tickFn = this._tickBefore[i];\n ticked = tickFn.call(this, elapsed, now, last) === true || ticked;\n }\n }\n var child;\n var next = this._first;\n while (child = next) {\n next = child._next;\n if (child._flag(\"_tick\")) {\n ticked = child._tick(elapsed, now, last) === true ? true : ticked;\n }\n }\n if (this._tickAfter !== null) {\n for (var i = 0; i < this._tickAfter.length; i++) {\n stats.tick++;\n var tickFn = this._tickAfter[i];\n ticked = tickFn.call(this, elapsed, now, last) === true || ticked;\n }\n }\n return ticked;\n };\n Node2.prototype.tick = function(callback, before) {\n var _a, _b;\n if (before === void 0) {\n before = false;\n }\n if (typeof callback !== \"function\") {\n return;\n }\n if (before) {\n if (this._tickBefore === null) {\n this._tickBefore = [];\n }\n this._tickBefore.push(callback);\n } else {\n if (this._tickAfter === null) {\n this._tickAfter = [];\n }\n this._tickAfter.push(callback);\n }\n var hasTickListener = ((_a = this._tickAfter) === null || _a === void 0 ? void 0 : _a.length) > 0 || ((_b = this._tickBefore) === null || _b === void 0 ? void 0 : _b.length) > 0;\n this._flag(\"_tick\", hasTickListener);\n };\n Node2.prototype.untick = function(callback) {\n if (typeof callback !== \"function\") {\n return;\n }\n var i;\n if (this._tickBefore !== null && (i = this._tickBefore.indexOf(callback)) >= 0) {\n this._tickBefore.splice(i, 1);\n }\n if (this._tickAfter !== null && (i = this._tickAfter.indexOf(callback)) >= 0) {\n this._tickAfter.splice(i, 1);\n }\n };\n Node2.prototype.timeout = function(callback, time) {\n this.setTimeout(callback, time);\n };\n Node2.prototype.setTimeout = function(callback, time) {\n function timer(t) {\n if ((time -= t) < 0) {\n this.untick(timer);\n callback.call(this);\n } else {\n return true;\n }\n }\n this.tick(timer);\n return timer;\n };\n Node2.prototype.clearTimeout = function(timer) {\n this.untick(timer);\n };\n Node2.prototype.on = function(type, listener) {\n if (!type || !type.length || typeof listener !== \"function\") {\n return this;\n }\n if (typeof type !== \"string\" && typeof type.join === \"function\") {\n for (var i = 0; i < type.length; i++) {\n this.on(type[i], listener);\n }\n } else if (typeof type === \"string\" && type.indexOf(\" \") > -1) {\n type = type.match(/\\S+/g);\n for (var i = 0; i < type.length; i++) {\n this._on(type[i], listener);\n }\n } else if (typeof type === \"string\") {\n this._on(type, listener);\n } else\n ;\n return this;\n };\n Node2.prototype._on = function(type, listener) {\n if (typeof type !== \"string\" && typeof listener !== \"function\") {\n return;\n }\n this._listeners[type] = this._listeners[type] || [];\n this._listeners[type].push(listener);\n this._flag(type, true);\n };\n Node2.prototype.off = function(type, listener) {\n if (!type || !type.length || typeof listener !== \"function\") {\n return this;\n }\n if (typeof type !== \"string\" && typeof type.join === \"function\") {\n for (var i = 0; i < type.length; i++) {\n this.off(type[i], listener);\n }\n } else if (typeof type === \"string\" && type.indexOf(\" \") > -1) {\n type = type.match(/\\S+/g);\n for (var i = 0; i < type.length; i++) {\n this._off(type[i], listener);\n }\n } else if (typeof type === \"string\") {\n this._off(type, listener);\n } else\n ;\n return this;\n };\n Node2.prototype._off = function(type, listener) {\n if (typeof type !== \"string\" && typeof listener !== \"function\") {\n return;\n }\n var listeners = this._listeners[type];\n if (!listeners || !listeners.length) {\n return;\n }\n var index = listeners.indexOf(listener);\n if (index >= 0) {\n listeners.splice(index, 1);\n this._flag(type, false);\n }\n };\n Node2.prototype.listeners = function(type) {\n return this._listeners[type];\n };\n Node2.prototype.publish = function(name, args) {\n var listeners = this.listeners(name);\n if (!listeners || !listeners.length) {\n return 0;\n }\n for (var l = 0; l < listeners.length; l++) {\n listeners[l].apply(this, args);\n }\n return listeners.length;\n };\n Node2.prototype.trigger = function(name, args) {\n this.publish(name, args);\n return this;\n };\n Node2.prototype.size = function(w, h) {\n this.pin(\"width\", w);\n this.pin(\"height\", h);\n return this;\n };\n Node2.prototype.width = function(w) {\n if (typeof w === \"undefined\") {\n return this.pin(\"width\");\n }\n this.pin(\"width\", w);\n return this;\n };\n Node2.prototype.height = function(h) {\n if (typeof h === \"undefined\") {\n return this.pin(\"height\");\n }\n this.pin(\"height\", h);\n return this;\n };\n Node2.prototype.offset = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n }\n this.pin(\"offsetX\", a);\n this.pin(\"offsetY\", b);\n return this;\n };\n Node2.prototype.rotate = function(a) {\n this.pin(\"rotation\", a);\n return this;\n };\n Node2.prototype.skew = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n } else if (typeof b === \"undefined\")\n b = a;\n this.pin(\"skewX\", a);\n this.pin(\"skewY\", b);\n return this;\n };\n Node2.prototype.scale = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n } else if (typeof b === \"undefined\")\n b = a;\n this.pin(\"scaleX\", a);\n this.pin(\"scaleY\", b);\n return this;\n };\n Node2.prototype.alpha = function(a, ta) {\n this.pin(\"alpha\", a);\n if (typeof ta !== \"undefined\") {\n this.pin(\"textureAlpha\", ta);\n }\n return this;\n };\n Node2.prototype.tween = function(a, b, c) {\n var options;\n if (typeof a === \"object\" && a !== null) {\n options = a;\n } else {\n options = {};\n if (typeof a === \"number\") {\n options.duration = a;\n if (typeof b === \"number\") {\n options.delay = b;\n if (typeof c === \"boolean\") {\n options.append = c;\n }\n } else if (typeof b === \"boolean\") {\n options.append = b;\n }\n } else if (typeof a === \"boolean\") {\n options.append = a;\n }\n }\n if (!this._transitionTickInitied) {\n this.tick(this._transitionTick, true);\n this._transitionTickInitied = true;\n }\n this.touch();\n if (!options.append) {\n this._transitions.length = 0;\n }\n var transition = new Transition(this, options);\n this._transitions.push(transition);\n return transition;\n };\n Node2.prototype.row = function(align) {\n this.align(\"row\", align);\n return this;\n };\n Node2.prototype.column = function(align) {\n this.align(\"column\", align);\n return this;\n };\n Node2.prototype.align = function(type, align) {\n var _this = this;\n this._padding = this._padding;\n this._spacing = this._spacing;\n this._layoutTicker && this.untick(this._layoutTicker);\n this.tick(this._layoutTicker = function() {\n if (_this._mo_seq == _this._ts_touch) {\n return;\n }\n _this._mo_seq = _this._ts_touch;\n var alignChildren = _this._mo_seqAlign != _this._ts_children;\n _this._mo_seqAlign = _this._ts_children;\n var width = 0;\n var height = 0;\n var child;\n var next = _this.first(true);\n var first = true;\n while (child = next) {\n next = child.next(true);\n child.matrix(true);\n var w = child.pin(\"boxWidth\");\n var h = child.pin(\"boxHeight\");\n if (type == \"column\") {\n !first && (height += _this._spacing);\n child.pin(\"offsetY\") != height && child.pin(\"offsetY\", height);\n width = Math.max(width, w);\n height = height + h;\n alignChildren && child.pin(\"alignX\", align);\n } else if (type == \"row\") {\n !first && (width += _this._spacing);\n child.pin(\"offsetX\") != width && child.pin(\"offsetX\", width);\n width = width + w;\n height = Math.max(height, h);\n alignChildren && child.pin(\"alignY\", align);\n }\n first = false;\n }\n width += 2 * _this._padding;\n height += 2 * _this._padding;\n _this.pin(\"width\") != width && _this.pin(\"width\", width);\n _this.pin(\"height\") != height && _this.pin(\"height\", height);\n });\n return this;\n };\n Node2.prototype.box = function() {\n return this.minimize();\n };\n Node2.prototype.layer = function() {\n return this.maximize();\n };\n Node2.prototype.minimize = function() {\n var _this = this;\n this._padding = this._padding;\n this._layoutTicker && this.untick(this._layoutTicker);\n this.tick(this._layoutTicker = function() {\n if (_this._mo_box == _this._ts_touch) {\n return;\n }\n _this._mo_box = _this._ts_touch;\n var width = 0;\n var height = 0;\n var child;\n var next = _this.first(true);\n while (child = next) {\n next = child.next(true);\n child.matrix(true);\n var w = child.pin(\"boxWidth\");\n var h = child.pin(\"boxHeight\");\n width = Math.max(width, w);\n height = Math.max(height, h);\n }\n width += 2 * _this._padding;\n height += 2 * _this._padding;\n _this.pin(\"width\") != width && _this.pin(\"width\", width);\n _this.pin(\"height\") != height && _this.pin(\"height\", height);\n });\n return this;\n };\n Node2.prototype.maximize = function() {\n var _this = this;\n this._layoutTicker && this.untick(this._layoutTicker);\n this.tick(this._layoutTicker = function() {\n var parent = _this.parent();\n if (parent) {\n var width = parent.pin(\"width\");\n if (_this.pin(\"width\") != width) {\n _this.pin(\"width\", width);\n }\n var height = parent.pin(\"height\");\n if (_this.pin(\"height\") != height) {\n _this.pin(\"height\", height);\n }\n }\n }, true);\n return this;\n };\n Node2.prototype.padding = function(pad) {\n this._padding = pad;\n return this;\n };\n Node2.prototype.spacing = function(space) {\n this._spacing = space;\n return this;\n };\n return Node2;\n }()\n);\nvar __extends$4 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nfunction sprite(frame) {\n var sprite2 = new Sprite();\n frame && sprite2.texture(frame);\n return sprite2;\n}\nvar Sprite = (\n /** @class */\n function(_super) {\n __extends$4(Sprite2, _super);\n function Sprite2() {\n var _this = _super.call(this) || this;\n _this._tiled = false;\n _this._stretched = false;\n _this.prerenderContext = {};\n _this.label(\"Sprite\");\n _this._textures = [];\n _this._image = null;\n return _this;\n }\n Sprite2.prototype.texture = function(frame) {\n this._image = texture(frame).one();\n if (this._image) {\n this.pin(\"width\", this._image.getWidth());\n this.pin(\"height\", this._image.getHeight());\n if (this._tiled) {\n this._textures[0] = new ResizableTexture(this._image, \"tile\");\n } else if (this._stretched) {\n this._textures[0] = new ResizableTexture(this._image, \"stretch\");\n } else {\n this._textures[0] = new PipeTexture(this._image);\n }\n this._textures.length = 1;\n } else {\n this.pin(\"width\", 0);\n this.pin(\"height\", 0);\n this._textures.length = 0;\n }\n return this;\n };\n Sprite2.prototype.image = function(frame) {\n return this.texture(frame);\n };\n Sprite2.prototype.tile = function(inner) {\n this._tiled = true;\n var texture2 = new ResizableTexture(this._image, \"tile\");\n this._textures[0] = texture2;\n return this;\n };\n Sprite2.prototype.stretch = function(inner) {\n this._stretched = true;\n var texture2 = new ResizableTexture(this._image, \"stretch\");\n this._textures[0] = texture2;\n return this;\n };\n Sprite2.prototype.prerender = function() {\n if (!this._visible) {\n return;\n }\n if (this._image) {\n var pixelRatio = this.getPixelRatio();\n this.prerenderContext.pixelRatio = pixelRatio;\n var updated = this._image.prerender(this.prerenderContext);\n if (updated === true) {\n var w = this._image.getWidth();\n var h = this._image.getHeight();\n this.size(w, h);\n }\n }\n _super.prototype.prerender.call(this);\n };\n Sprite2.prototype.render = function(context) {\n var texture2 = this._textures[0];\n if (texture2 === null || texture2 === void 0 ? void 0 : texture2[\"_resizeMode\"]) {\n texture2.dw = this.pin(\"width\");\n texture2.dh = this.pin(\"height\");\n }\n _super.prototype.render.call(this, context);\n };\n return Sprite2;\n }(Node)\n);\nvar image = sprite;\nvar Image$1 = Sprite;\nvar __extends$3 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar CanvasTexture = (\n /** @class */\n function(_super) {\n __extends$3(CanvasTexture2, _super);\n function CanvasTexture2() {\n var _this = _super.call(this, document.createElement(\"canvas\")) || this;\n _this._lastPixelRatio = 0;\n return _this;\n }\n CanvasTexture2.prototype.setSize = function(textureWidth, textureHeight, pixelRatio) {\n if (pixelRatio === void 0) {\n pixelRatio = 1;\n }\n this._source.width = textureWidth * pixelRatio;\n this._source.height = textureHeight * pixelRatio;\n this._pixelRatio = pixelRatio;\n };\n CanvasTexture2.prototype.getContext = function(type, attributes) {\n if (type === void 0) {\n type = \"2d\";\n }\n return this._source.getContext(type, attributes);\n };\n CanvasTexture2.prototype.getOptimalPixelRatio = function() {\n return Math.ceil(this._lastPixelRatio);\n };\n CanvasTexture2.prototype.setMemoizer = function(memoizer) {\n this._memoizer = memoizer;\n };\n CanvasTexture2.prototype.setDrawer = function(drawer) {\n this._drawer = drawer;\n };\n CanvasTexture2.prototype.prerender = function(context) {\n var newPixelRatio = context.pixelRatio;\n var lastPixelRatio = this._lastPixelRatio;\n var pixelRationChange = lastPixelRatio / newPixelRatio;\n var pixelRatioChanged = lastPixelRatio === 0 || pixelRationChange > 1.25 || pixelRationChange < 0.8;\n if (pixelRatioChanged) {\n this._lastPixelRatio = newPixelRatio;\n }\n var newMemoKey = this._memoizer ? this._memoizer.call(this) : null;\n var memoKeyChanged = this._lastMemoKey !== newMemoKey;\n if (pixelRatioChanged || memoKeyChanged) {\n this._lastMemoKey = newMemoKey;\n this._lastPixelRatio = newPixelRatio;\n if (typeof this._drawer === \"function\") {\n this._drawer.call(this);\n }\n return true;\n }\n };\n CanvasTexture2.prototype.size = function(width, height, pixelRatio) {\n this.setSize(width, height, pixelRatio);\n return this;\n };\n CanvasTexture2.prototype.context = function(type, attributes) {\n if (type === void 0) {\n type = \"2d\";\n }\n return this.getContext(type, attributes);\n };\n CanvasTexture2.prototype.canvas = function(legacyTextureDrawer) {\n if (typeof legacyTextureDrawer === \"function\") {\n legacyTextureDrawer.call(this, this.getContext());\n } else if (typeof legacyTextureDrawer === \"undefined\") {\n if (typeof this._drawer === \"function\") {\n this._drawer.call(this);\n }\n }\n return this;\n };\n return CanvasTexture2;\n }(ImageTexture)\n);\nfunction canvas(type, attributes, legacyTextureDrawer) {\n if (typeof type === \"function\") {\n var texture_1 = new CanvasTexture();\n legacyTextureDrawer = type;\n texture_1.setDrawer(function() {\n legacyTextureDrawer.call(texture_1, texture_1.getContext());\n });\n return texture_1;\n } else if (typeof attributes === \"function\") {\n var texture_2 = new CanvasTexture();\n legacyTextureDrawer = attributes;\n texture_2.setDrawer(function() {\n legacyTextureDrawer.call(texture_2, texture_2.getContext(type));\n });\n return texture_2;\n } else if (typeof legacyTextureDrawer === \"function\") {\n var texture_3 = new CanvasTexture();\n texture_3.setDrawer(function() {\n legacyTextureDrawer.call(texture_3, texture_3.getContext(type, attributes));\n });\n return texture_3;\n } else {\n var texture2 = new CanvasTexture();\n return texture2;\n }\n}\nfunction memoizeDraw(legacySpriteDrawer, legacySpriteMemoizer) {\n if (legacySpriteMemoizer === void 0) {\n legacySpriteMemoizer = function() {\n return null;\n };\n }\n var sprite2 = new Sprite();\n var texture2 = new CanvasTexture();\n sprite2.texture(texture2);\n texture2.setDrawer(function() {\n legacySpriteDrawer(2.5 * texture2._lastPixelRatio, texture2, sprite2);\n });\n texture2.setMemoizer(legacySpriteMemoizer);\n return sprite2;\n}\nvar POINTER_CLICK = \"click\";\nvar POINTER_START = \"touchstart mousedown\";\nvar POINTER_MOVE = \"touchmove mousemove\";\nvar POINTER_END = \"touchend mouseup\";\nvar POINTER_CANCEL = \"touchcancel mousecancel\";\nvar EventPoint = (\n /** @class */\n function() {\n function EventPoint2() {\n }\n EventPoint2.prototype.clone = function(obj) {\n if (obj) {\n obj.x = this.x;\n obj.y = this.y;\n } else {\n obj = {\n x: this.x,\n y: this.y\n };\n }\n return obj;\n };\n EventPoint2.prototype.toString = function() {\n return (this.x | 0) + \"x\" + (this.y | 0);\n };\n return EventPoint2;\n }()\n);\nvar PointerSyntheticEvent = (\n /** @class */\n function() {\n function PointerSyntheticEvent2() {\n this.abs = new EventPoint();\n }\n PointerSyntheticEvent2.prototype.clone = function(obj) {\n if (obj) {\n obj.x = this.x;\n obj.y = this.y;\n } else {\n obj = {\n x: this.x,\n y: this.y\n };\n }\n return obj;\n };\n PointerSyntheticEvent2.prototype.toString = function() {\n return this.type + \": \" + (this.x | 0) + \"x\" + (this.y | 0);\n };\n return PointerSyntheticEvent2;\n }()\n);\nvar VisitPayload = (\n /** @class */\n function() {\n function VisitPayload2() {\n this.type = \"\";\n this.x = 0;\n this.y = 0;\n this.timeStamp = -1;\n this.event = null;\n this.root = null;\n this.collected = null;\n }\n VisitPayload2.prototype.toString = function() {\n return this.type + \": \" + (this.x | 0) + \"x\" + (this.y | 0);\n };\n return VisitPayload2;\n }()\n);\nvar syntheticEvent = new PointerSyntheticEvent();\nvar PAYLOAD = new VisitPayload();\nvar Pointer = (\n /** @class */\n function() {\n function Pointer2() {\n var _this = this;\n this.ratio = 1;\n this.clickList = [];\n this.cancelList = [];\n this.handleStart = function(event) {\n event.preventDefault();\n _this.localPoint(event);\n _this.dispatchEvent(event.type, event);\n _this.findTargets(\"click\", _this.clickList);\n _this.findTargets(\"mousecancel\", _this.cancelList);\n };\n this.handleMove = function(event) {\n event.preventDefault();\n _this.localPoint(event);\n _this.dispatchEvent(event.type, event);\n };\n this.handleEnd = function(event) {\n event.preventDefault();\n _this.dispatchEvent(event.type, event);\n if (_this.clickList.length) {\n _this.dispatchEvent(\"click\", event, _this.clickList);\n }\n _this.cancelList.length = 0;\n };\n this.handleCancel = function(event) {\n if (_this.cancelList.length) {\n _this.dispatchEvent(\"mousecancel\", event, _this.cancelList);\n }\n _this.clickList.length = 0;\n };\n this.visitStart = function(node, payload) {\n return !node._flag(payload.type);\n };\n this.visitEnd = function(node, payload) {\n syntheticEvent.raw = payload.event;\n syntheticEvent.type = payload.type;\n syntheticEvent.timeStamp = payload.timeStamp;\n syntheticEvent.abs.x = payload.x;\n syntheticEvent.abs.y = payload.y;\n var listeners = node.listeners(payload.type);\n if (!listeners) {\n return;\n }\n node.matrix().inverse().map(payload, syntheticEvent);\n var isEventTarget = node === payload.root || node.attr(\"spy\") || node.hitTest(syntheticEvent);\n if (!isEventTarget) {\n return;\n }\n if (payload.collected) {\n payload.collected.push(node);\n }\n if (payload.event) {\n var cancel = false;\n for (var l = 0; l < listeners.length; l++) {\n cancel = listeners[l].call(node, syntheticEvent) ? true : cancel;\n }\n return cancel;\n }\n };\n }\n Pointer2.prototype.mount = function(stage, elem) {\n var _this = this;\n this.stage = stage;\n this.elem = elem;\n this.ratio = stage.viewport().ratio || 1;\n stage.on(\"viewport\", function(viewport) {\n var _a;\n _this.ratio = (_a = viewport.ratio) !== null && _a !== void 0 ? _a : _this.ratio;\n });\n elem.addEventListener(\"touchstart\", this.handleStart);\n elem.addEventListener(\"touchend\", this.handleEnd);\n elem.addEventListener(\"touchmove\", this.handleMove);\n elem.addEventListener(\"touchcancel\", this.handleCancel);\n elem.addEventListener(\"mousedown\", this.handleStart);\n elem.addEventListener(\"mouseup\", this.handleEnd);\n elem.addEventListener(\"mousemove\", this.handleMove);\n document.addEventListener(\"mouseup\", this.handleCancel);\n window.addEventListener(\"blur\", this.handleCancel);\n return this;\n };\n Pointer2.prototype.unmount = function() {\n var elem = this.elem;\n elem.removeEventListener(\"touchstart\", this.handleStart);\n elem.removeEventListener(\"touchend\", this.handleEnd);\n elem.removeEventListener(\"touchmove\", this.handleMove);\n elem.removeEventListener(\"touchcancel\", this.handleCancel);\n elem.removeEventListener(\"mousedown\", this.handleStart);\n elem.removeEventListener(\"mouseup\", this.handleEnd);\n elem.removeEventListener(\"mousemove\", this.handleMove);\n document.removeEventListener(\"mouseup\", this.handleCancel);\n window.removeEventListener(\"blur\", this.handleCancel);\n return this;\n };\n Pointer2.prototype.localPoint = function(event) {\n var _a;\n var elem = this.elem;\n var x;\n var y;\n if ((_a = event.touches) === null || _a === void 0 ? void 0 : _a.length) {\n x = event.touches[0].clientX;\n y = event.touches[0].clientY;\n } else {\n x = event.clientX;\n y = event.clientY;\n }\n var rect = elem.getBoundingClientRect();\n x -= rect.left;\n y -= rect.top;\n x -= elem.clientLeft | 0;\n y -= elem.clientTop | 0;\n PAYLOAD.x = x * this.ratio;\n PAYLOAD.y = y * this.ratio;\n };\n Pointer2.prototype.findTargets = function(type, result) {\n var payload = PAYLOAD;\n payload.type = type;\n payload.root = this.stage;\n payload.event = null;\n payload.collected = result;\n payload.collected.length = 0;\n this.stage.visit({\n reverse: true,\n visible: true,\n start: this.visitStart,\n end: this.visitEnd\n }, payload);\n };\n Pointer2.prototype.dispatchEvent = function(type, event, targets) {\n var payload = PAYLOAD;\n payload.type = type;\n payload.root = this.stage;\n payload.event = event;\n payload.timeStamp = Date.now();\n payload.collected = null;\n if (targets) {\n while (targets.length) {\n var node = targets.shift();\n if (this.visitEnd(node, payload)) {\n break;\n }\n }\n targets.length = 0;\n } else {\n this.stage.visit({\n reverse: true,\n visible: true,\n start: this.visitStart,\n end: this.visitEnd\n }, payload);\n }\n };\n return Pointer2;\n }()\n);\nvar Mouse = {\n CLICK: \"click\",\n START: \"touchstart mousedown\",\n MOVE: \"touchmove mousemove\",\n END: \"touchend mouseup\",\n CANCEL: \"touchcancel mousecancel\"\n};\nvar __extends$2 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar __assign = function() {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s)\n if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar ROOTS = [];\nfunction pause() {\n for (var i = ROOTS.length - 1; i >= 0; i--) {\n ROOTS[i].pause();\n }\n}\nfunction resume() {\n for (var i = ROOTS.length - 1; i >= 0; i--) {\n ROOTS[i].resume();\n }\n}\nfunction mount(configs) {\n if (configs === void 0) {\n configs = {};\n }\n var root = new Root();\n root.mount(configs);\n root.pointer = new Pointer().mount(root, root.dom);\n return root;\n}\nvar Root = (\n /** @class */\n function(_super) {\n __extends$2(Root2, _super);\n function Root2() {\n var _this = _super.call(this) || this;\n _this.canvas = null;\n _this.dom = null;\n _this.context = null;\n _this.pixelWidth = -1;\n _this.pixelHeight = -1;\n _this.pixelRatio = 1;\n _this.drawingWidth = 0;\n _this.drawingHeight = 0;\n _this.mounted = false;\n _this.paused = false;\n _this.sleep = false;\n _this.mount = function(configs) {\n if (configs === void 0) {\n configs = {};\n }\n if (typeof configs.canvas === \"string\") {\n _this.canvas = document.getElementById(configs.canvas);\n if (!_this.canvas) {\n console.error(\"Canvas element not found: \", configs.canvas);\n }\n } else if (configs.canvas instanceof HTMLCanvasElement) {\n _this.canvas = configs.canvas;\n } else if (configs.canvas) {\n console.error(\"Unknown value for canvas:\", configs.canvas);\n }\n if (!_this.canvas) {\n _this.canvas = document.getElementById(\"cutjs\") || document.getElementById(\"stage\");\n }\n if (!_this.canvas) {\n _this.canvas = document.createElement(\"canvas\");\n Object.assign(_this.canvas.style, {\n position: \"absolute\",\n display: \"block\",\n top: \"0\",\n left: \"0\",\n bottom: \"0\",\n right: \"0\",\n width: \"100%\",\n height: \"100%\"\n });\n var body = document.body;\n body.insertBefore(_this.canvas, body.firstChild);\n }\n _this.dom = _this.canvas;\n _this.context = _this.canvas.getContext(\"2d\");\n var devicePixelRatio = window.devicePixelRatio || 1;\n var backingStorePixelRatio = (\n // @ts-ignore\n _this.context.webkitBackingStorePixelRatio || // @ts-ignore\n _this.context.mozBackingStorePixelRatio || // @ts-ignore\n _this.context.msBackingStorePixelRatio || // @ts-ignore\n _this.context.oBackingStorePixelRatio || // @ts-ignore\n _this.context.backingStorePixelRatio || 1\n );\n _this.devicePixelRatio = devicePixelRatio;\n _this.backingStoreRatio = backingStorePixelRatio;\n _this.pixelRatio = _this.devicePixelRatio / _this.backingStoreRatio;\n _this.mounted = true;\n ROOTS.push(_this);\n _this.requestFrame();\n };\n _this.frameRequested = false;\n _this.requestFrame = function() {\n if (!_this.frameRequested) {\n _this.frameRequested = true;\n requestAnimationFrame(_this.onFrame);\n }\n };\n _this._lastFrameTime = 0;\n _this._mo_touch = null;\n _this.onFrame = function(now) {\n _this.frameRequested = false;\n if (!_this.mounted || !_this.canvas || !_this.context) {\n return;\n }\n _this.requestFrame();\n var newPixelWidth = _this.canvas.clientWidth;\n var newPixelHeight = _this.canvas.clientHeight;\n if (_this.pixelWidth !== newPixelWidth || _this.pixelHeight !== newPixelHeight) {\n _this.pixelWidth = newPixelWidth;\n _this.pixelHeight = newPixelHeight;\n _this.drawingWidth = newPixelWidth * _this.pixelRatio;\n _this.drawingHeight = newPixelHeight * _this.pixelRatio;\n if (_this.canvas.width !== _this.drawingWidth || _this.canvas.height !== _this.drawingHeight) {\n _this.canvas.width = _this.drawingWidth;\n _this.canvas.height = _this.drawingHeight;\n _this.viewport({\n width: _this.drawingWidth,\n height: _this.drawingHeight,\n ratio: _this.pixelRatio\n });\n }\n }\n var last = _this._lastFrameTime || now;\n var elapsed = now - last;\n if (!_this.mounted || _this.paused || _this.sleep) {\n return;\n }\n _this._lastFrameTime = now;\n _this.prerender();\n var tickRequest = _this._tick(elapsed, now, last);\n if (_this._mo_touch != _this._ts_touch) {\n _this._mo_touch = _this._ts_touch;\n _this.sleep = false;\n if (_this.drawingWidth > 0 && _this.drawingHeight > 0) {\n _this.context.setTransform(1, 0, 0, 1, 0, 0);\n _this.context.clearRect(0, 0, _this.drawingWidth, _this.drawingHeight);\n _this.render(_this.context);\n }\n } else if (tickRequest) {\n _this.sleep = false;\n } else {\n _this.sleep = true;\n }\n stats.fps = elapsed ? 1e3 / elapsed : 0;\n };\n _this.label(\"Root\");\n return _this;\n }\n Root2.prototype.resume = function() {\n if (this.sleep || this.paused) {\n this.requestFrame();\n }\n this.paused = false;\n this.sleep = false;\n this.publish(\"resume\");\n return this;\n };\n Root2.prototype.pause = function() {\n if (!this.paused) {\n this.publish(\"pause\");\n }\n this.paused = true;\n return this;\n };\n Root2.prototype.touch = function() {\n if (this.sleep || this.paused) {\n this.requestFrame();\n }\n this.sleep = false;\n return _super.prototype.touch.call(this);\n };\n Root2.prototype.unmount = function() {\n var _a;\n this.mounted = false;\n var index = ROOTS.indexOf(this);\n if (index >= 0) {\n ROOTS.splice(index, 1);\n }\n (_a = this.pointer) === null || _a === void 0 ? void 0 : _a.unmount();\n return this;\n };\n Root2.prototype.background = function(color) {\n if (this.dom) {\n this.dom.style.backgroundColor = color;\n }\n return this;\n };\n Root2.prototype.viewport = function(width, height, ratio) {\n if (typeof width === \"undefined\") {\n return Object.assign({}, this._viewport);\n }\n if (typeof width === \"object\") {\n var options = width;\n width = options.width;\n height = options.height;\n ratio = options.ratio;\n }\n if (typeof width === \"number\" && typeof height === \"number\") {\n this._viewport = {\n width,\n height,\n ratio: typeof ratio === \"number\" ? ratio : 1\n };\n this.viewbox();\n var data_1 = Object.assign({}, this._viewport);\n this.visit({\n start: function(node) {\n if (!node._flag(\"viewport\")) {\n return true;\n }\n node.publish(\"viewport\", [data_1]);\n }\n });\n }\n return this;\n };\n Root2.prototype.viewbox = function(width, height, mode) {\n if (typeof width === \"number\" && typeof height === \"number\") {\n this._viewbox = {\n width,\n height,\n mode\n };\n } else if (typeof width === \"object\" && width !== null) {\n this._viewbox = __assign({}, width);\n }\n this.rescale();\n return this;\n };\n Root2.prototype.camera = function(matrix) {\n this._camera = matrix;\n this.rescale();\n return this;\n };\n Root2.prototype.rescale = function() {\n var viewbox = this._viewbox;\n var viewport = this._viewport;\n var camera = this._camera;\n if (viewport && viewbox) {\n var viewportWidth = viewport.width;\n var viewportHeight = viewport.height;\n var viewboxMode = isValidFitMode(viewbox.mode) ? viewbox.mode : \"in-pad\";\n var viewboxWidth = viewbox.width;\n var viewboxHeight = viewbox.height;\n this.pin({\n width: viewboxWidth,\n height: viewboxHeight\n });\n this.scaleTo(viewportWidth, viewportHeight, viewboxMode);\n var viewboxX = viewbox.x || 0;\n var viewboxY = viewbox.y || 0;\n var cameraZoom = (camera === null || camera === void 0 ? void 0 : camera.a) || 1;\n var cameraX = (camera === null || camera === void 0 ? void 0 : camera.e) || 0;\n var cameraY = (camera === null || camera === void 0 ? void 0 : camera.f) || 0;\n var scaleX = this.pin(\"scaleX\");\n var scaleY = this.pin(\"scaleY\");\n this.pin(\"scaleX\", scaleX * cameraZoom);\n this.pin(\"scaleY\", scaleY * cameraZoom);\n this.pin(\"offsetX\", cameraX - viewboxX * scaleX * cameraZoom);\n this.pin(\"offsetY\", cameraY - viewboxY * scaleY * cameraZoom);\n } else if (viewport) {\n this.pin({\n width: viewport.width,\n height: viewport.height\n });\n }\n return this;\n };\n return Root2;\n }(Node)\n);\nvar __extends$1 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nfunction anim(frames, fps) {\n var anim2 = new Anim();\n anim2.frames(frames).gotoFrame(0);\n fps && anim2.fps(fps);\n return anim2;\n}\nvar FPS = 15;\nvar Anim = (\n /** @class */\n function(_super) {\n __extends$1(Anim2, _super);\n function Anim2() {\n var _this = _super.call(this) || this;\n _this.label(\"Anim\");\n _this._textures = [];\n _this._fps = FPS;\n _this._ft = 1e3 / _this._fps;\n _this._time = -1;\n _this._repeat = 0;\n _this._index = 0;\n _this._frames = [];\n var lastTime = 0;\n _this.tick(function(t, now, last) {\n if (this._time < 0 || this._frames.length <= 1) {\n return;\n }\n var ignore = lastTime != last;\n lastTime = now;\n if (ignore) {\n return true;\n }\n this._time += t;\n if (this._time < this._ft) {\n return true;\n }\n var n = this._time / this._ft | 0;\n this._time -= n * this._ft;\n this.moveFrame(n);\n if (this._repeat > 0 && (this._repeat -= n) <= 0) {\n this.stop();\n this._callback && this._callback();\n return false;\n }\n return true;\n }, false);\n return _this;\n }\n Anim2.prototype.fps = function(fps) {\n if (typeof fps === \"undefined\") {\n return this._fps;\n }\n this._fps = fps > 0 ? fps : FPS;\n this._ft = 1e3 / this._fps;\n return this;\n };\n Anim2.prototype.setFrames = function(frames) {\n return this.frames(frames);\n };\n Anim2.prototype.frames = function(frames) {\n this._index = 0;\n this._frames = texture(frames).array();\n this.touch();\n return this;\n };\n Anim2.prototype.length = function() {\n return this._frames ? this._frames.length : 0;\n };\n Anim2.prototype.gotoFrame = function(frame, resize) {\n if (resize === void 0) {\n resize = false;\n }\n this._index = math.wrap(frame, this._frames.length) | 0;\n resize = resize || !this._textures[0];\n this._textures[0] = this._frames[this._index];\n if (resize) {\n this.pin(\"width\", this._textures[0].getWidth());\n this.pin(\"height\", this._textures[0].getHeight());\n }\n this.touch();\n return this;\n };\n Anim2.prototype.moveFrame = function(move) {\n return this.gotoFrame(this._index + move);\n };\n Anim2.prototype.repeat = function(repeat, callback) {\n this._repeat = repeat * this._frames.length - 1;\n this._callback = callback;\n this.play();\n return this;\n };\n Anim2.prototype.play = function(frame) {\n if (typeof frame !== \"undefined\") {\n this.gotoFrame(frame);\n this._time = 0;\n } else if (this._time < 0) {\n this._time = 0;\n }\n this.touch();\n return this;\n };\n Anim2.prototype.stop = function(frame) {\n this._time = -1;\n if (typeof frame !== \"undefined\") {\n this.gotoFrame(frame);\n }\n return this;\n };\n return Anim2;\n }(Node)\n);\nvar __extends = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nfunction monotype(chars) {\n return new Monotype().frames(chars);\n}\nvar Monotype = (\n /** @class */\n function(_super) {\n __extends(Monotype2, _super);\n function Monotype2() {\n var _this = _super.call(this) || this;\n _this.label(\"String\");\n _this._textures = [];\n return _this;\n }\n Monotype2.prototype.setFont = function(frames) {\n return this.frames(frames);\n };\n Monotype2.prototype.frames = function(frames) {\n this._textures = [];\n if (typeof frames == \"string\") {\n var selection_1 = texture(frames);\n this._font = function(value) {\n return selection_1.one(value);\n };\n } else if (typeof frames === \"object\") {\n this._font = function(value) {\n return frames[value];\n };\n } else if (typeof frames === \"function\") {\n this._font = frames;\n }\n return this;\n };\n Monotype2.prototype.setValue = function(value) {\n return this.value(value);\n };\n Monotype2.prototype.value = function(value) {\n if (typeof value === \"undefined\") {\n return this._value;\n }\n if (this._value === value) {\n return this;\n }\n this._value = value;\n if (value === null) {\n value = \"\";\n } else if (typeof value !== \"string\" && !Array.isArray(value)) {\n value = value.toString();\n }\n this._spacing = this._spacing || 0;\n var width = 0;\n var height = 0;\n for (var i = 0; i < value.length; i++) {\n var v = value[i];\n var texture_1 = this._textures[i] = this._font(typeof v === \"string\" ? v : v + \"\");\n width += i > 0 ? this._spacing : 0;\n texture_1.setDestinationCoordinate(width, 0);\n width = width + texture_1.getWidth();\n height = Math.max(height, texture_1.getHeight());\n }\n this.pin(\"width\", width);\n this.pin(\"height\", height);\n this._textures.length = value.length;\n return this;\n };\n return Monotype2;\n }(Node)\n);\nvar string = monotype;\nvar Str = Monotype;\nconst Stage = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({\n __proto__: null,\n Anim,\n Atlas,\n CanvasTexture,\n Image: Image$1,\n ImageTexture,\n Math: math,\n Matrix,\n Monotype,\n Mouse,\n Node,\n POINTER_CANCEL,\n POINTER_CLICK,\n POINTER_END,\n POINTER_MOVE,\n POINTER_START,\n Pin,\n PipeTexture,\n Pointer,\n ResizableTexture,\n Root,\n Sprite,\n Str,\n Texture,\n TextureSelection,\n Transition,\n anim,\n atlas,\n box,\n canvas,\n clamp,\n column,\n create,\n image,\n isValidFitMode,\n layer,\n layout,\n length,\n math,\n maximize,\n memoizeDraw,\n minimize,\n monotype,\n mount,\n pause,\n random,\n resume,\n row,\n sprite,\n string,\n texture,\n wrap\n}, Symbol.toStringTag, { value: \"Module\" }));\nexport {\n Anim,\n Atlas,\n CanvasTexture,\n Image$1 as Image,\n ImageTexture,\n math as Math,\n Matrix,\n Monotype,\n Mouse,\n Node,\n POINTER_CANCEL,\n POINTER_CLICK,\n POINTER_END,\n POINTER_MOVE,\n POINTER_START,\n Pin,\n PipeTexture,\n Pointer,\n ResizableTexture,\n Root,\n Sprite,\n Str,\n Texture,\n TextureSelection,\n Transition,\n anim,\n atlas,\n box,\n canvas,\n clamp,\n column,\n create,\n Stage as default,\n image,\n isValidFitMode,\n layer,\n layout,\n length,\n math,\n maximize,\n memoizeDraw,\n minimize,\n monotype,\n mount,\n pause,\n random,\n resume,\n row,\n sprite,\n string,\n texture,\n wrap\n};\n","import * as Stage from \"stage-js\";\n\nimport type { Vec2Value } from \"../src/common/Vec2\";\nimport type { World } from \"../src/dynamics/World\";\nimport type { Joint } from \"../src/dynamics/Joint\";\nimport type { Fixture } from \"../src/dynamics/Fixture\";\nimport type { Body } from \"../src/dynamics/Body\";\nimport type { AABBValue } from \"../src/collision/AABB\";\nimport type { Shape } from \"../src/collision/Shape\";\nimport type { Style } from \"../src/util/Testbed\";\nimport { Testbed } from \"../src/util/Testbed\";\nimport type { EdgeShape } from \"../src/collision/shape/EdgeShape\";\nimport type { PolygonShape } from \"../src/collision/shape/PolygonShape\";\nimport type { ChainShape } from \"../src/collision/shape/ChainShape\";\nimport type { CircleShape } from \"../src/collision/shape/CircleShape\";\nimport type { PulleyJoint } from \"../src/dynamics/joint/PulleyJoint\";\nimport { MouseJoint } from \"../src/dynamics/joint/MouseJoint\";\n\nconst math_atan2 = Math.atan2;\nconst math_abs = Math.abs;\nconst math_sqrt = Math.sqrt;\nconst math_PI = Math.PI;\nconst math_max = Math.max;\nconst math_min = Math.min;\n\ninterface DrawOptions {\n scaleY: number;\n lineWidth: number;\n stroke: string;\n fill: string;\n}\n\nlet mounted: StageTestbed | null = null;\n\n/** @internal */\nfunction memo() {\n const memory: any = [];\n function recall(...rest: any[]) {\n let equal = memory.length === rest.length;\n for (let i = 0; equal && i < rest.length; i++) {\n equal = equal && memory[i] === rest[i];\n memory[i] = rest[i];\n }\n memory.length = rest.length;\n return equal;\n }\n function reset() {\n memory.length = 0;\n // void 0;\n }\n return {\n recall,\n reset,\n };\n}\n\nTestbed.mount = () => {\n if (mounted) {\n return mounted;\n }\n\n mounted = new StageTestbed();\n\n // todo: merge rest of this into StageTestbed\n\n // todo: should we create these elements if not exists?\n const playButton = document.getElementById(\"testbed-play\");\n const statusElement = document.getElementById(\"testbed-status\");\n const infoElement = document.getElementById(\"testbed-info\");\n\n if (playButton) {\n playButton.addEventListener(\"click\", () => {\n if (mounted.isPaused() ) {\n mounted.resume();\n } else {\n mounted.pause();\n }\n });\n\n mounted._pause = () => {\n playButton.classList.add(\"pause\");\n playButton.classList.remove(\"play\");\n };\n\n mounted._resume = () => {\n playButton.classList.add(\"play\");\n playButton.classList.remove(\"pause\");\n };\n } else {\n console.log(\"Please create a button with id='testbed-play'\");\n }\n\n let lastStatus = \"\";\n if (statusElement) {\n statusElement.innerText = lastStatus;\n }\n mounted._status = (text: string) => {\n if (lastStatus === text) {\n return;\n }\n lastStatus = text;\n if (statusElement) {\n statusElement.innerText = text;\n }\n };\n\n let lastInfo = \"\";\n if (infoElement) {\n infoElement.innerText = lastInfo;\n }\n mounted._info = (text: string) => {\n if (lastInfo === text) {\n return;\n }\n lastInfo = text;\n if (infoElement) {\n infoElement.innerText = text;\n }\n };\n\n return mounted;\n};\n\nfunction getStyle(obj: Body | Fixture | Joint | Shape): Style {\n if (typeof obj[\"render\"] === \"object\" && (\"stroke\" in obj[\"render\"] || \"fill\" in obj[\"render\"])) {\n // this was used in planck before v1\n return obj[\"render\"];\n } else if (typeof obj[\"style\"] === \"object\") {\n return obj[\"style\"];\n }\n}\n\nfunction findBody(world: World, point: Vec2Value) {\n let body: Body | null = null;\n const aabb = {\n lowerBound: point,\n upperBound: point,\n };\n world.queryAABB(aabb, (fixture: Fixture) => {\n if (!fixture.getBody().isDynamic() || !fixture.testPoint(point)) {\n return true;\n }\n body = fixture.getBody();\n return false;\n });\n return body;\n}\n\n/** @internal */\nexport class StageTestbed extends Testbed {\n private canvas: HTMLCanvasElement;\n private stage: Stage.Root;\n private paused: boolean = false;\n private lastDrawHash = \"\";\n private newDrawHash = \"\";\n private buffer: ((context: CanvasRenderingContext2D, ratio: number)=> void)[] = [];\n\n start(world: World) {\n const stage = this.stage = Stage.mount();\n const canvas = this.canvas = stage.dom as HTMLCanvasElement;\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const testbed = this;\n this.canvas = canvas;\n\n stage.on(Stage.POINTER_START, () => {\n window.focus();\n // @ts-ignore\n document.activeElement?.blur();\n canvas.focus();\n });\n\n stage.MAX_ELAPSE = 1000 / 30;\n\n stage.on(\"resume\", () => {\n this.paused = false;\n this._resume();\n });\n stage.on(\"pause\", () => {\n this.paused = true;\n this._pause();\n });\n\n const drawingTexture = new Stage.CanvasTexture();\n drawingTexture.draw = (ctx: CanvasRenderingContext2D) => {\n const pixelRatio = 2 * drawingTexture.getOptimalPixelRatio();\n ctx.save();\n ctx.transform(1, 0, 0, this.scaleY, -this.x, -this.y);\n ctx.lineWidth = 3 / pixelRatio;\n ctx.lineCap = \"round\";\n for (let drawing = this.buffer.shift(); drawing; drawing = this.buffer.shift()) {\n drawing(ctx, pixelRatio);\n }\n ctx.restore();\n };\n\n const drawingElement = Stage.sprite(drawingTexture);\n stage.append(drawingElement);\n stage.tick(() => {\n this.buffer.length = 0;\n }, true);\n\n\n stage.background(this.background);\n stage.viewbox(this.width, this.height);\n stage.pin(\"alignX\", -0.5);\n stage.pin(\"alignY\", -0.5);\n\n const worldNode = new WorldStageNode(world, this);\n\n // stage.empty();\n stage.prepend(worldNode);\n\n let lastX = 0;\n let lastY = 0;\n stage.tick((dt: number, t: number) => {\n // update camera position\n if (lastX !== this.x || lastY !== this.y) {\n worldNode.offset(-this.x, -this.y);\n lastX = this.x;\n lastY = this.y;\n }\n });\n\n worldNode.tick((dt: number, t: number) => {\n this.step(dt, t);\n\n if (targetBody) {\n this.drawSegment(targetBody.getPosition(), mouseMove, \"rgba(255,255,255,0.2)\");\n }\n\n if (this.lastDrawHash !== this.newDrawHash) {\n this.lastDrawHash = this.newDrawHash;\n stage.touch();\n }\n this.newDrawHash = \"\";\n\n return true;\n });\n\n const mouseGround = world.createBody();\n let mouseJoint: MouseJoint | null = null;\n let targetBody: Body | null = null;\n const mouseMove = {x: 0, y: 0};\n\n worldNode.attr(\"spy\", true);\n\n worldNode.on(Stage.POINTER_START, (point: Vec2Value) => {\n point = { x: point.x, y: testbed.scaleY * point.y };\n if (targetBody) {\n return;\n }\n\n const body = findBody(world, point);\n if (!body) {\n return;\n }\n\n if (this.mouseForce) {\n targetBody = body;\n\n } else {\n mouseJoint = new MouseJoint({maxForce: 1000}, mouseGround, body, { x: point.x, y: point.y });\n world.createJoint(mouseJoint);\n }\n });\n\n worldNode.on(Stage.POINTER_MOVE, (point: Vec2Value) => {\n point = { x: point.x, y: testbed.scaleY * point.y };\n if (mouseJoint) {\n mouseJoint.setTarget(point);\n }\n\n mouseMove.x = point.x;\n mouseMove.y = point.y;\n });\n\n worldNode.on(Stage.POINTER_END, (point: Vec2Value) => {\n point = { x: point.x, y: testbed.scaleY * point.y };\n if (mouseJoint) {\n world.destroyJoint(mouseJoint);\n mouseJoint = null;\n }\n if (targetBody && this.mouseForce) {\n const target = targetBody.getPosition();\n const force = {\n x: (point.x - target.x) * this.mouseForce,\n y: (point.y - target.y) * this.mouseForce,\n };\n targetBody.applyForceToCenter(force, true);\n targetBody = null;\n }\n });\n\n worldNode.on(Stage.POINTER_CANCEL, (point: Vec2Value) => {\n point = { x: point.x, y: testbed.scaleY * point.y };\n if (mouseJoint) {\n world.destroyJoint(mouseJoint);\n mouseJoint = null;\n }\n if (targetBody) {\n targetBody = null;\n }\n });\n\n const activeKeys = testbed.activeKeys;\n const downKeys: Record = {};\n function updateActiveKeys(keyCode: number, down: boolean) {\n const char = String.fromCharCode(keyCode);\n if (/\\w/.test(char)) {\n activeKeys[char] = down;\n }\n activeKeys.right = downKeys[39] || activeKeys[\"D\"];\n activeKeys.left = downKeys[37] || activeKeys[\"A\"];\n activeKeys.up = downKeys[38] || activeKeys[\"W\"];\n activeKeys.down = downKeys[40] || activeKeys[\"S\"];\n activeKeys.fire = downKeys[32] || downKeys[13] ;\n }\n\n window.addEventListener(\"keydown\", function(e) {\n const keyCode = e.keyCode;\n downKeys[keyCode] = true;\n updateActiveKeys(keyCode, true);\n testbed.keydown?.(keyCode, String.fromCharCode(keyCode));\n });\n window.addEventListener(\"keyup\", function(e) {\n const keyCode = e.keyCode;\n downKeys[keyCode] = false;\n updateActiveKeys(keyCode, false);\n testbed.keyup?.(keyCode, String.fromCharCode(keyCode));\n });\n\n this.resume();\n }\n\n /** @private @internal */\n focus() {\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n document.activeElement && document.activeElement.blur();\n this.canvas.focus();\n }\n\n /** @internal */\n _pause() {\n }\n\n /** @internal */\n _resume() {\n }\n\n private statusText = \"\";\n private statusMap: Record = {};\n\n status(name: string, value: any): void;\n status(value: object | string): void;\n status(a: any, b?: any) {\n if (typeof b !== \"undefined\") {\n const key = a;\n const value = b;\n if (typeof value !== \"function\" && typeof value !== \"object\") {\n this.statusMap[key] = value;\n }\n } else if (a && typeof a === \"object\") {\n // tslint:disable-next-line:no-for-in\n for (const key in a) {\n const value = a[key];\n if (typeof value !== \"function\" && typeof value !== \"object\") {\n this.statusMap[key] = value;\n }\n }\n } else if (typeof a === \"string\") {\n this.statusText = a;\n }\n\n var newline = \"\\n\";\n var text = this.statusText || \"\";\n for (var key in this.statusMap) {\n var value = this.statusMap[key];\n if (typeof value === \"function\") continue;\n text += (text && newline) + key + \": \" + value;\n }\n\n this._status(text);\n }\n\n info(text: string): void {\n this._info(text);\n }\n\n /** @internal */\n _status(string: string) {\n }\n\n /** @internal */ \n _info(text: string) {\n }\n\n /** @internal */\n isPaused() {\n return this.paused;\n }\n\n /** @internal */\n togglePause() {\n if (this.paused) {\n this.resume();\n } else {\n this.pause();\n }\n }\n\n /** @internal */\n pause() {\n this.stage.pause();\n }\n\n /** @internal */\n resume() {\n this.stage.resume();\n this.focus();\n }\n\n drawPoint(p: {x: number, y: number}, r: number, color: string): void {\n this.buffer.push(function(ctx, ratio) {\n ctx.beginPath();\n ctx.arc(p.x, p.y, 5 / ratio, 0, 2 * math_PI);\n ctx.strokeStyle = color;\n ctx.stroke();\n });\n this.newDrawHash += \"point\" + p.x + \",\" + p.y + \",\" + r + \",\" + color;\n }\n\n drawCircle(p: {x: number, y: number}, r: number, color: string): void {\n this.buffer.push(function(ctx) {\n ctx.beginPath();\n ctx.arc(p.x, p.y, r, 0, 2 * math_PI);\n ctx.strokeStyle = color;\n ctx.stroke();\n });\n this.newDrawHash += \"circle\" + p.x + \",\" + p.y + \",\" + r + \",\" + color;\n }\n\n drawEdge(a: {x: number, y: number}, b: {x: number, y: number}, color: string): void {\n this.buffer.push(function(ctx) {\n ctx.beginPath();\n ctx.moveTo(a.x, a.y);\n ctx.lineTo(b.x, b.y);\n ctx.strokeStyle = color;\n ctx.stroke();\n });\n this.newDrawHash += \"segment\" + a.x + \",\" + a.y + \",\" + b.x + \",\" + b.y + \",\" + color;\n }\n\n drawSegment = this.drawEdge;\n\n drawPolygon(points: Array<{x: number, y: number}>, color: string): void {\n if (!points || !points.length) {\n return;\n }\n this.buffer.push(function(ctx) {\n ctx.beginPath();\n ctx.moveTo(points[0].x, points[0].y);\n for (let i = 1; i < points.length; i++) {\n ctx.lineTo(points[i].x, points[i].y);\n }\n ctx.strokeStyle = color;\n ctx.closePath();\n ctx.stroke();\n });\n this.newDrawHash += \"segment\";\n for (let i = 1; i < points.length; i++) {\n this.newDrawHash += points[i].x + \",\" + points[i].y + \",\";\n }\n this.newDrawHash += color;\n }\n\n drawAABB(aabb: AABBValue, color: string): void {\n this.buffer.push(function(ctx) {\n ctx.beginPath();\n ctx.moveTo(aabb.lowerBound.x, aabb.lowerBound.y);\n ctx.lineTo(aabb.upperBound.x, aabb.lowerBound.y);\n ctx.lineTo(aabb.upperBound.x, aabb.upperBound.y);\n ctx.lineTo(aabb.lowerBound.x, aabb.upperBound.y);\n ctx.strokeStyle = color;\n ctx.closePath();\n ctx.stroke();\n });\n this.newDrawHash += \"aabb\";\n this.newDrawHash += aabb.lowerBound.x + \",\" + aabb.lowerBound.y + \",\";\n this.newDrawHash += aabb.upperBound.x + \",\" + aabb.upperBound.y + \",\";\n this.newDrawHash += color;\n }\n\n findOne(query: string): (Body | Joint | Fixture | null) {\n throw new Error(\"Not implemented\");\n }\n\n findAll(query: string): (Body | Joint | Fixture)[] {\n throw new Error(\"Not implemented\");\n }\n}\n\ninterface WorldStageOptions {\n speed: number;\n hz: number;\n scaleY: number;\n lineWidth: number;\n stroke: string | undefined;\n fill: string | undefined;\n}\n\nclass WorldStageNode extends Stage.Node {\n private nodes = new WeakMap();\n\n private options: WorldStageOptions = {\n speed: 1,\n hz: 60,\n scaleY: -1,\n lineWidth: 3,\n stroke: undefined,\n fill: undefined\n };\n\n private world: World;\n private testbed: Testbed;\n\n constructor(world: World, opts: Partial = {}) {\n super();\n this.label(\"Planck\");\n\n this.options = { ...this.options, ...opts };\n\n if (math_abs(this.options.hz) < 1) {\n this.options.hz = 1 / this.options.hz;\n }\n\n this.world = world;\n this.testbed = opts as Testbed;\n\n const timeStep = 1 / this.options.hz;\n let elapsedTime = 0;\n let errored = false;\n this.tick((dt: number) => {\n if (errored) {\n return false;\n }\n try {\n dt = dt * 0.001 * this.options.speed;\n elapsedTime += dt;\n while (elapsedTime > timeStep) {\n world.step(timeStep);\n elapsedTime -= timeStep;\n }\n this.renderWorld();\n return true; \n } catch (error) {\n errored = true;\n console.error(error);\n return false;\n }\n }, true);\n\n world.on(\"remove-fixture\", (obj: Fixture) => {\n this.nodes.get(obj)?.remove();\n });\n\n world.on(\"remove-joint\", (obj: Joint) => {\n this.nodes.get(obj)?.remove();\n });\n }\n\n renderWorld() {\n const world = this.world;\n const options = this.options;\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const viewer = this;\n\n for (let b = world.getBodyList(); b; b = b.getNext()) {\n for (let f = b.getFixtureList(); f; f = f.getNext()) {\n\n let node = this.nodes.get(f);\n if (!node) {\n const type = f.getType();\n const shape = f.getShape();\n\n const opts: DrawOptions = Object.assign({\n stroke: options.stroke,\n fill: options.fill,\n scaleY: options.scaleY,\n lineWidth: options.lineWidth,\n }, getStyle(b), getStyle(f), getStyle(shape));\n\n if (opts.stroke) {\n // good\n } else if (b.isDynamic()) {\n opts.stroke = \"rgba(255,255,255,0.9)\";\n } else if (b.isKinematic()) {\n opts.stroke = \"rgba(255,255,255,0.7)\";\n } else if (b.isStatic()) {\n opts.stroke = \"rgba(255,255,255,0.5)\";\n }\n\n if (type == \"circle\") {\n node = viewer.drawCircle(shape as CircleShape, opts);\n }\n if (type == \"edge\") {\n node = viewer.drawEdge(shape as EdgeShape, opts);\n }\n if (type == \"polygon\") {\n node = viewer.drawPolygon(shape as PolygonShape, opts);\n }\n if (type == \"chain\") {\n node = viewer.drawChain(shape as ChainShape, opts);\n }\n\n if (node) {\n node.appendTo(viewer);\n this.nodes.set(f, node);\n }\n }\n\n if (node) {\n const p = b.getPosition();\n const r = b.getAngle();\n // @ts-ignore\n const isChanged = node.__lastX !== p.x || node.__lastY !== p.y || node.__lastR !== r;\n if (isChanged) {\n // @ts-ignore\n node.__lastX = p.x;\n // @ts-ignore\n node.__lastY = p.y;\n // @ts-ignore\n node.__lastR = r;\n node.offset(p.x, options.scaleY * p.y);\n node.rotate(options.scaleY * r);\n }\n }\n\n }\n }\n\n for (let j = world.getJointList(); j; j = j.getNext()) {\n const type = j.getType();\n if (type == \"pulley-joint\") {\n this.testbed.drawSegment(j.getAnchorA(), (j as PulleyJoint).getGroundAnchorA(), \"rgba(255,255,255,0.5)\");\n this.testbed.drawSegment(j.getAnchorB(), (j as PulleyJoint).getGroundAnchorB(), \"rgba(255,255,255,0.5)\");\n this.testbed.drawSegment((j as PulleyJoint).getGroundAnchorB(), (j as PulleyJoint).getGroundAnchorA(), \"rgba(255,255,255,0.5)\");\n } else {\n this.testbed.drawSegment(j.getAnchorA(), j.getAnchorB(), \"rgba(255,255,255,0.5)\");\n }\n }\n }\n\n drawCircle(shape: CircleShape, options: DrawOptions) {\n let offsetX = 0;\n let offsetY = 0;\n const offsetMemo = memo();\n\n const texture = Stage.canvas();\n texture.setDrawer(function () {\n const ctx = this.getContext();\n const ratio = 2 * this.getOptimalPixelRatio();\n const lw = options.lineWidth / ratio;\n\n const r = shape.m_radius;\n const cx = r + lw;\n const cy = r + lw;\n const w = r * 2 + lw * 2;\n const h = r * 2 + lw * 2;\n\n offsetX = shape.m_p.x - cx;\n offsetY = options.scaleY * shape.m_p.y - cy;\n\n this.setSize(w, h, ratio);\n\n ctx.scale(ratio, ratio);\n ctx.arc(cx, cy, r, 0, 2 * math_PI);\n if (options.fill) {\n ctx.fillStyle = options.fill;\n ctx.fill();\n }\n ctx.lineTo(cx, cy);\n ctx.lineWidth = options.lineWidth / ratio;\n ctx.strokeStyle = options.stroke ?? \"\";\n ctx.stroke();\n });\n\n const sprite = Stage.sprite(texture);\n sprite.tick(() => {\n if (!offsetMemo.recall(offsetX, offsetY)) {\n sprite.offset(offsetX, offsetY);\n }\n });\n\n const node = Stage.layout().append(sprite);\n return node;\n }\n\n drawEdge(edge: EdgeShape, options: DrawOptions) {\n let offsetX = 0;\n let offsetY = 0;\n let offsetA = 0;\n const offsetMemo = memo();\n\n const texture = Stage.canvas();\n texture.setDrawer(function () {\n const ctx = this.getContext();\n const ratio = 2 * this.getOptimalPixelRatio();\n const lw = options.lineWidth / ratio;\n\n const v1 = edge.m_vertex1;\n const v2 = edge.m_vertex2;\n\n const dx = v2.x - v1.x;\n const dy = v2.y - v1.y;\n\n const length = math_sqrt(dx * dx + dy * dy);\n\n this.setSize(length + 2 * lw, 2 * lw, ratio);\n\n const minX = math_min(v1.x, v2.x);\n const minY = math_min(options.scaleY * v1.y, options.scaleY * v2.y);\n \n offsetX = minX - lw;\n offsetY = minY - lw;\n offsetA = options.scaleY * math_atan2(dy, dx);\n\n ctx.scale(ratio, ratio);\n ctx.beginPath();\n ctx.moveTo(lw, lw);\n ctx.lineTo(lw + length, lw);\n\n ctx.lineCap = \"round\";\n ctx.lineWidth = options.lineWidth / ratio;\n ctx.strokeStyle = options.stroke ?? \"\";\n ctx.stroke();\n });\n\n const sprite = Stage.sprite(texture);\n sprite.tick(() => {\n if(!offsetMemo.recall(offsetX, offsetY, offsetA)) {\n sprite.offset(offsetX, offsetY);\n sprite.rotate(offsetA);\n }\n });\n const node = Stage.layout().append(sprite);\n return node;\n }\n\n drawPolygon(shape: PolygonShape, options: DrawOptions) {\n let offsetX = 0;\n let offsetY = 0;\n const offsetMemo = memo();\n\n const texture = Stage.canvas();\n texture.setDrawer(function () {\n const ctx = this.getContext();\n const ratio = 2 * this.getOptimalPixelRatio();\n const lw = options.lineWidth / ratio;\n\n const vertices = shape.m_vertices;\n\n if (!vertices.length) {\n return;\n }\n \n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (let i = 0; i < vertices.length; ++i) {\n const v = vertices[i];\n minX = math_min(minX, v.x);\n maxX = math_max(maxX, v.x);\n minY = math_min(minY, options.scaleY * v.y);\n maxY = math_max(maxY, options.scaleY * v.y);\n }\n \n const width = maxX - minX;\n const height = maxY - minY;\n\n offsetX = minX;\n offsetY = minY;\n\n this.setSize(width + 2 * lw, height + 2 * lw, ratio);\n\n ctx.scale(ratio, ratio);\n ctx.beginPath();\n for (let i = 0; i < vertices.length; ++i) {\n const v = vertices[i];\n const x = v.x - minX + lw;\n const y = options.scaleY * v.y - minY + lw;\n if (i == 0)\n ctx.moveTo(x, y);\n\n else\n ctx.lineTo(x, y);\n }\n\n if (vertices.length > 2) {\n ctx.closePath();\n }\n\n if (options.fill) {\n ctx.fillStyle = options.fill;\n ctx.fill();\n ctx.closePath();\n }\n\n ctx.lineCap = \"round\";\n ctx.lineWidth = options.lineWidth / ratio;\n ctx.strokeStyle = options.stroke ?? \"\";\n ctx.stroke();\n });\n\n const sprite = Stage.sprite(texture);\n sprite.tick(() => {\n if(!offsetMemo.recall(offsetX, offsetY)) {\n sprite.offset(offsetX, offsetY);\n }\n });\n\n const node = Stage.layout().append(sprite);\n return node;\n }\n\n drawChain(shape: ChainShape, options: DrawOptions) {\n let offsetX = 0;\n let offsetY = 0;\n const offsetMemo = memo();\n\n const texture = Stage.canvas();\n texture.setDrawer(function () {\n const ctx = this.getContext();\n const ratio = 2 * this.getOptimalPixelRatio();\n const lw = options.lineWidth / ratio;\n\n const vertices = shape.m_vertices;\n\n if (!vertices.length) {\n return;\n }\n \n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (let i = 0; i < vertices.length; ++i) {\n const v = vertices[i];\n minX = math_min(minX, v.x);\n maxX = math_max(maxX, v.x);\n minY = math_min(minY, options.scaleY * v.y);\n maxY = math_max(maxY, options.scaleY * v.y);\n }\n \n const width = maxX - minX;\n const height = maxY - minY;\n\n offsetX = minX;\n offsetY = minY;\n\n this.setSize(width + 2 * lw, height + 2 * lw, ratio);\n\n ctx.scale(ratio, ratio);\n ctx.beginPath();\n for (let i = 0; i < vertices.length; ++i) {\n const v = vertices[i];\n const x = v.x - minX + lw;\n const y = options.scaleY * v.y - minY + lw;\n if (i == 0)\n ctx.moveTo(x, y);\n\n else\n ctx.lineTo(x, y);\n }\n\n // TODO: if loop\n if (vertices.length > 2) {\n // ctx.closePath();\n }\n\n if (options.fill) {\n ctx.fillStyle = options.fill;\n ctx.fill();\n ctx.closePath();\n }\n\n ctx.lineCap = \"round\";\n ctx.lineWidth = options.lineWidth / ratio;\n ctx.strokeStyle = options.stroke ?? \"\";\n ctx.stroke();\n });\n\n const sprite = Stage.sprite(texture);\n sprite.tick(() => {\n if(!offsetMemo.recall(offsetX, offsetY)) {\n sprite.offset(offsetX, offsetY);\n }\n });\n\n const node = Stage.layout().append(sprite);\n return node;\n }\n}\n"],"names":["d","b","__extends","__assign","s","n","input","output","math_random","x","clamp","random","math","math_abs","math_sqrt","math_max","math_min","Vec2","v","a","length","AABB","normal","temp","math_PI","Settings","SettingsInternal","Pool","TreeNode","DynamicTree","c","Iterator","BroadPhase","displacement","math_sin","math_cos","transform","xf","math_atan2","Rot","matrix.vec2","Sweep","matrix.zeroVec2","matrix.transformVec2","matrix.copyVec2","localCenter","matrix.setRotAngle","matrix.combine2Vec2","matrix.minusVec2","matrix.rotVec2","Transform","rotation","Velocity","Position","Shape","FixtureProxy","Fixture","matrix.subVec2","matrix.transform","Body","matrix.plusScaleVec2","matrix.scaleVec2","matrix.dotVec2","matrix.crossNumVec2","matrix.plusVec2","point","JointEdge","Joint","stats","DistanceInput","DistanceOutput","SimplexCache","cache","xfA","xfB","matrix.lengthSqrVec2","matrix.derotVec2","matrix.distVec2","rA","rB","matrix.normalizeVec2","matrix.minusScaleVec2","DistanceProxy","SimplexVertex","Simplex","v1","v2","matrix.setVec2","matrix.crossVec2Vec2","pA","pB","matrix.combine3Vec2","matrix.copyTransform","ShapeCastInput","ShapeCastOutput","simplex","pointA","pointB","TOIInput","TOIOutputState","TOIOutput","SeparationFunctionType","SeparationFunction","matrix.normalizeVec2Length","matrix.crossVec2Num","matrix.negVec2","TimeStep","ContactImpulse","Solver","matrix.mulVec2","Mat22","cA","cB","planePoint","clipPoint","ManifoldType","ContactFeatureType","PointState","ClipVertex","Manifold","ManifoldPoint","ContactID","WorldManifold","ContactEdge","VelocityConstraintPoint","tangent","P","Contact","_a","worldManifold","DEFAULTS","World","oldManifold","Vec3","EdgeShape","e","ChainShape","e1","e2","PolygonShape","ie","center","matrix.detransformVec2","matrix.addVec2","CircleShape","matrix.distSqrVec2","DistanceJoint","vA","vB","FrictionJoint","Mat33","LimitState","RevoluteJoint","PrismaticJoint","translation","perp","GearJoint","MotorJoint","MouseJoint","PulleyJoint","RopeJoint","WeldJoint","WheelJoint","Serializer","options","obj","Testbed","testbed","BoxShape","matrix.retransformVec2","clipPoints1","clipPoints2","normal1","matrix.detransformTransform","maxSeparation","edge1","matrix.rerotVec2","EPAxisType","VertexType","EPAxis","TempPolygon","ReferenceFace","s2","extendStatics","d2","b2","now","self","StageTestbed","Stage.mount","canvas","Stage.POINTER_START","Stage.CanvasTexture","Stage.sprite","Stage.POINTER_MOVE","Stage.POINTER_END","Stage.POINTER_CANCEL","i","WorldStageNode","texture","Stage.canvas","sprite","Stage.layout","Stage.Node"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,MAAI,gBAAgB,SAASA,IAAGC,IAAG;AAC/B,oBAAgB,OAAO,kBAClB,EAAE,WAAW,CAAA,eAAgB,SAAS,SAAUD,IAAGC,IAAG;AAAE,MAAAD,GAAE,YAAYC;AAAA,IAAE,KACzE,SAAUD,IAAGC,IAAG;AAAE,eAAS,KAAKA,GAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","x_google_ignoreList":[0,54]} \ No newline at end of file +{"version":3,"file":"planck-with-testbed.js","sources":["../node_modules/tslib/tslib.es6.js","../src/util/options.ts","../src/common/Math.ts","../src/common/Vec2.ts","../src/collision/AABB.ts","../src/Settings.ts","../src/util/Pool.ts","../src/collision/DynamicTree.ts","../src/collision/BroadPhase.ts","../src/common/Matrix.ts","../src/common/Rot.ts","../src/common/Sweep.ts","../src/common/Transform.ts","../src/dynamics/Velocity.ts","../src/dynamics/Position.ts","../src/collision/Shape.ts","../src/dynamics/Fixture.ts","../src/dynamics/Body.ts","../src/dynamics/Joint.ts","../src/util/stats.ts","../src/util/Timer.ts","../src/collision/Distance.ts","../src/collision/TimeOfImpact.ts","../src/dynamics/Solver.ts","../src/common/Mat22.ts","../src/collision/Manifold.ts","../src/dynamics/Contact.ts","../src/dynamics/World.ts","../src/common/Vec3.ts","../src/collision/shape/EdgeShape.ts","../src/collision/shape/ChainShape.ts","../src/collision/shape/PolygonShape.ts","../src/collision/shape/CircleShape.ts","../src/dynamics/joint/DistanceJoint.ts","../src/dynamics/joint/FrictionJoint.ts","../src/common/Mat33.ts","../src/dynamics/joint/RevoluteJoint.ts","../src/dynamics/joint/PrismaticJoint.ts","../src/dynamics/joint/GearJoint.ts","../src/dynamics/joint/MotorJoint.ts","../src/dynamics/joint/MouseJoint.ts","../src/dynamics/joint/PulleyJoint.ts","../src/dynamics/joint/RopeJoint.ts","../src/dynamics/joint/WeldJoint.ts","../src/dynamics/joint/WheelJoint.ts","../src/serializer/index.ts","../src/util/Testbed.ts","../src/collision/shape/BoxShape.ts","../src/collision/shape/CollideCircle.ts","../src/collision/shape/CollideEdgeCircle.ts","../src/collision/shape/CollidePolygon.ts","../src/collision/shape/CollideCirclePolygon.ts","../src/collision/shape/CollideEdgePolygon.ts","../src/internal.ts","../node_modules/stage-js/dist/stage.js","../testbed/StageTestbed.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from) {\r\n for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)\r\n to[j] = from[i];\r\n return to;\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","/** @internal */\nexport const options = function(input: T, defaults: object): T {\n if (input === null || typeof input === \"undefined\") {\n // tslint:disable-next-line:no-object-literal-type-assertion\n input = {} as T;\n }\n\n const output = {...input};\n\n // tslint:disable-next-line:no-for-in\n for (const key in defaults) {\n if (defaults.hasOwnProperty(key) && typeof input[key] === \"undefined\") {\n output[key] = defaults[key];\n }\n }\n\n if (typeof Object.getOwnPropertySymbols === \"function\") {\n const symbols = Object.getOwnPropertySymbols(defaults);\n for (let i = 0; i < symbols.length; i++) {\n const symbol = symbols[i];\n if (defaults.propertyIsEnumerable(symbol) && typeof input[symbol] === \"undefined\") {\n output[symbol] = defaults[symbol];\n }\n }\n }\n\n return output;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_random = Math.random;\n\n\nexport const EPSILON = 1e-9;\n\n/** @internal @deprecated */\nexport const isFinite = Number.isFinite;\n\n/**\n * @deprecated\n * Next Largest Power of 2 Given a binary integer value x, the next largest\n * power of 2 can be computed by a SWAR algorithm that recursively \"folds\" the\n * upper bits into the lower bits. This process yields a bit vector with the\n * same most significant 1 as x, but all 1's below it. Adding 1 to that value\n * yields the next largest power of 2. For a 32-bit value:\n */\nexport function nextPowerOfTwo(x: number): number {\n x |= (x >> 1);\n x |= (x >> 2);\n x |= (x >> 4);\n x |= (x >> 8);\n x |= (x >> 16);\n return x + 1;\n}\n\n/** @deprecated */\nexport function isPowerOfTwo(x: number): boolean {\n return x > 0 && (x & (x - 1)) === 0;\n}\n\n/** @deprecated */\nexport function mod(num: number, min?: number, max?: number): number {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n if (max > min) {\n num = (num - min) % (max - min);\n return num + (num < 0 ? max : min);\n } else {\n num = (num - max) % (min - max);\n return num + (num <= 0 ? min : max);\n }\n}\n\n/**\n * @deprecated\n * Returns a min if num is less than min, and max if more than max, otherwise returns num.\n */\nexport function clamp(num: number, min: number, max: number): number {\n if (num < min) {\n return min;\n } else if (num > max) {\n return max;\n } else {\n return num;\n }\n}\n\n/**\n * @deprecated\n * Returns a random number between min and max when two arguments are provided.\n * If one arg is provided between 0 to max.\n * If one arg is passed between 0 to 1.\n */\nexport function random(min?: number, max?: number): number {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n return min === max ? min : math_random() * (max - min) + min;\n}\n\n/** @ignore */\nexport const math = Object.create(Math);\nmath.EPSILON = EPSILON;\nmath.isFinite = isFinite;\nmath.nextPowerOfTwo = nextPowerOfTwo;\nmath.isPowerOfTwo = isPowerOfTwo;\nmath.mod = mod;\nmath.clamp = clamp;\nmath.random = random;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { clamp, EPSILON } from \"./Math\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/** 2D vector */\nexport interface Vec2Value {\n x: number;\n y: number;\n}\n\ndeclare module \"./Vec2\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(x: number, y: number): Vec2;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(obj: Vec2Value): Vec2;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(): Vec2;\n}\n\n/** 2D vector */\n// @ts-expect-error\nexport class Vec2 {\n x: number;\n y: number;\n\n constructor(x: number, y: number);\n constructor(obj: Vec2Value);\n constructor();\n // tslint:disable-next-line:typedef\n constructor(x?, y?) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Vec2)) {\n return new Vec2(x, y);\n }\n if (typeof x === \"undefined\") {\n this.x = 0;\n this.y = 0;\n } else if (typeof x === \"object\") {\n this.x = x.x;\n this.y = x.y;\n } else {\n this.x = x;\n this.y = y;\n }\n if (_ASSERT) Vec2.assert(this);\n }\n\n /** @internal */\n _serialize(): object {\n return {\n x: this.x,\n y: this.y\n };\n }\n\n /** @internal */\n static _deserialize(data: any): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = data.x;\n obj.y = data.y;\n return obj;\n }\n\n static zero(): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = 0;\n obj.y = 0;\n return obj;\n }\n\n /** @hidden */\n static neo(x: number, y: number): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = x;\n obj.y = y;\n return obj;\n }\n\n static clone(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(v.x, v.y);\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n /**\n * Does this vector contain finite coordinates?\n */\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.x) && Number.isFinite(obj.y);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Vec2.isValid(o), \"Invalid Vec2!\", o);\n }\n\n clone(): Vec2 {\n return Vec2.clone(this);\n }\n\n /**\n * Set this vector to all zeros.\n *\n * @returns this\n */\n setZero(): Vec2 {\n this.x = 0.0;\n this.y = 0.0;\n return this;\n }\n\n set(x: number, y: number): Vec2;\n set(value: Vec2Value): Vec2;\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n // tslint:disable-next-line:typedef\n set(x, y?) {\n if (typeof x === \"object\") {\n if (_ASSERT) Vec2.assert(x);\n this.x = x.x;\n this.y = x.y;\n } else {\n if (_ASSERT) console.assert(Number.isFinite(x));\n if (_ASSERT) console.assert(Number.isFinite(y));\n this.x = x;\n this.y = y;\n }\n return this;\n }\n\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n setNum(x: number, y: number) {\n if (_ASSERT) console.assert(Number.isFinite(x));\n if (_ASSERT) console.assert(Number.isFinite(y));\n this.x = x;\n this.y = y;\n\n return this;\n }\n\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n setVec2(value: Vec2Value) {\n if (_ASSERT) Vec2.assert(value);\n this.x = value.x;\n this.y = value.y;\n\n return this;\n }\n\n /** @internal @deprecated Use setCombine or setMul */\n wSet(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.setCombine(a, v, b, w);\n } else {\n return this.setMul(a, v);\n }\n }\n\n /**\n * Set linear combination of v and w: `a * v + b * w`\n */\n setCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x = x;\n this.y = y;\n return this;\n }\n\n setMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x = x;\n this.y = y;\n return this;\n }\n\n /**\n * Add a vector to this vector.\n *\n * @returns this\n */\n add(w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(w);\n this.x += w.x;\n this.y += w.y;\n return this;\n }\n\n /** @internal @deprecated Use addCombine or addMul */\n wAdd(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.addCombine(a, v, b, w);\n } else {\n return this.addMul(a, v);\n }\n }\n\n /**\n * Add linear combination of v and w: `a * v + b * w`\n */\n addCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x += x;\n this.y += y;\n return this;\n }\n\n addMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x += x;\n this.y += y;\n return this;\n }\n\n /**\n * @deprecated Use subCombine or subMul\n */\n wSub(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.subCombine(a, v, b, w);\n } else {\n return this.subMul(a, v);\n }}\n\n /**\n * Subtract linear combination of v and w: `a * v + b * w`\n */\n subCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x -= x;\n this.y -= y;\n return this;\n }\n\n subMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x -= x;\n this.y -= y;\n return this;\n }\n\n /**\n * Subtract a vector from this vector\n *\n * @returns this\n */\n sub(w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(w);\n this.x -= w.x;\n this.y -= w.y;\n return this;\n }\n\n /**\n * Multiply this vector by a scalar.\n *\n * @returns this\n */\n mul(m: number): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(m));\n this.x *= m;\n this.y *= m;\n return this;\n }\n\n /**\n * Get the length of this vector (the norm).\n *\n * For performance, use this instead of lengthSquared (if possible).\n */\n length(): number {\n return Vec2.lengthOf(this);\n }\n\n /**\n * Get the length squared.\n */\n lengthSquared(): number {\n return Vec2.lengthSquared(this);\n }\n\n /**\n * Convert this vector into a unit vector.\n *\n * @returns old length\n */\n normalize(): number {\n const length = this.length();\n if (length < EPSILON) {\n return 0.0;\n }\n const invLength = 1.0 / length;\n this.x *= invLength;\n this.y *= invLength;\n return length;\n }\n\n /**\n * Returns a new unit vector from the provided vector.\n *\n * @returns new unit vector\n */\n static normalize(v: Vec2Value): Vec2 {\n const length = Vec2.lengthOf(v);\n if (length < EPSILON) {\n return Vec2.zero();\n }\n const invLength = 1.0 / length;\n return Vec2.neo(v.x * invLength, v.y * invLength);\n }\n\n /**\n * Get the length of this vector (the norm).\n *\n * For performance, use this instead of lengthSquared (if possible).\n */\n static lengthOf(v: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n return math_sqrt(v.x * v.x + v.y * v.y);\n }\n\n /**\n * Get the length squared.\n */\n static lengthSquared(v: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n return v.x * v.x + v.y * v.y;\n }\n\n static distance(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n const dx = v.x - w.x;\n const dy = v.y - w.y;\n return math_sqrt(dx * dx + dy * dy);\n }\n\n static distanceSquared(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n const dx = v.x - w.x;\n const dy = v.y - w.y;\n return dx * dx + dy * dy;\n }\n\n static areEqual(v: Vec2Value, w: Vec2Value): boolean {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v === w || typeof w === \"object\" && w !== null && v.x === w.x && v.y === w.y;\n }\n\n /**\n * Get the skew vector such that dot(skew_vec, other) == cross(vec, other)\n */\n static skew(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(-v.y, v.x);\n }\n\n /** Dot product on two vectors */\n static dot(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.x + v.y * w.y;\n }\n\n /** Cross product between two vectors */\n static cross(v: Vec2Value, w: Vec2Value): number;\n /** Cross product between a vector and a scalar */\n static cross(v: Vec2Value, w: number): Vec2;\n /** Cross product between a scalar and a vector */\n static cross(v: number, w: Vec2Value): Vec2;\n static cross(v: any, w: any): any {\n if (typeof w === \"number\") {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y, -w * v.x);\n\n } else if (typeof v === \"number\") {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y, v * w.x);\n\n } else {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.y - v.y * w.x;\n }\n }\n\n /** Cross product on two vectors */\n static crossVec2Vec2(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.y - v.y * w.x;\n }\n\n /** Cross product on a vector and a scalar */\n static crossVec2Num(v: Vec2Value, w: number): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y, -w * v.x);\n }\n\n /** Cross product on a vector and a scalar */\n static crossNumVec2(v: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y, v * w.x);\n }\n\n /** Returns `a + (v x w)` */\n static addCross(a: Vec2Value, v: Vec2Value, w: number): Vec2;\n /** Returns `a + (v x w)` */\n static addCross(a: Vec2Value, v: number, w: Vec2Value): Vec2;\n static addCross(a: Vec2Value, v: any, w: any): Vec2 {\n if (typeof w === \"number\") {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y + a.x, -w * v.x + a.y);\n\n } else if (typeof v === \"number\") {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y + a.x, v * w.x + a.y);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n /**\n * Returns `a + (v x w)`\n */\n static addCrossVec2Num(a: Vec2Value, v: Vec2Value, w: number): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y + a.x, -w * v.x + a.y);\n }\n\n /**\n * Returns `a + (v x w)`\n */\n static addCrossNumVec2(a: Vec2Value, v: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y + a.x, v * w.x + a.y);\n }\n\n static add(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(v.x + w.x, v.y + w.y);\n }\n\n /** @hidden @deprecated */\n static wAdd(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return Vec2.combine(a, v, b, w);\n } else {\n return Vec2.mulNumVec2(a, v);\n }\n }\n\n static combine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n return Vec2.zero().setCombine(a, v, b, w);\n }\n\n static sub(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(v.x - w.x, v.y - w.y);\n }\n\n static mul(a: Vec2Value, b: number): Vec2;\n static mul(a: number, b: Vec2Value): Vec2;\n static mul(a: any, b: any): Vec2 {\n if (typeof a === \"object\") {\n if (_ASSERT) Vec2.assert(a);\n if (_ASSERT) console.assert(Number.isFinite(b));\n return Vec2.neo(a.x * b, a.y * b);\n\n } else if (typeof b === \"object\") {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(b);\n return Vec2.neo(a * b.x, a * b.y);\n }\n }\n\n static mulVec2Num(a: Vec2Value, b: number): Vec2 {\n if (_ASSERT) Vec2.assert(a);\n if (_ASSERT) console.assert(Number.isFinite(b));\n return Vec2.neo(a.x * b, a.y * b);\n }\n\n static mulNumVec2(a: number, b: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(b);\n return Vec2.neo(a * b.x, a * b.y);\n }\n\n neg(): Vec2 {\n this.x = -this.x;\n this.y = -this.y;\n return this;\n }\n\n static neg(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(-v.x, -v.y);\n }\n\n static abs(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(math_abs(v.x), math_abs(v.y));\n }\n\n static mid(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo((v.x + w.x) * 0.5, (v.y + w.y) * 0.5);\n }\n\n static upper(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(math_max(v.x, w.x), math_max(v.y, w.y));\n }\n\n static lower(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(math_min(v.x, w.x), math_min(v.y, w.y));\n }\n\n clamp(max: number): Vec2 {\n const lengthSqr = this.x * this.x + this.y * this.y;\n if (lengthSqr > max * max) {\n const scale = max / math_sqrt(lengthSqr);\n this.x *= scale;\n this.y *= scale;\n }\n return this;\n }\n\n static clamp(v: Vec2Value, max: number): Vec2 {\n const r = Vec2.neo(v.x, v.y);\n r.clamp(max);\n return r;\n }\n\n /** @hidden */\n static clampVec2(v: Vec2Value, min?: Vec2Value, max?: Vec2Value): Vec2Value {\n return {\n x: clamp(v.x, min?.x, max?.x),\n y: clamp(v.y, min?.y, max?.y)\n };\n }\n\n /** @hidden @deprecated */\n static scaleFn(x: number, y: number) {\n // todo: this was used in examples, remove in the future\n return function(v: Vec2Value): Vec2 {\n return Vec2.neo(v.x * x, v.y * y);\n };\n }\n\n /** @hidden @deprecated */\n static translateFn(x: number, y: number) {\n // todo: this was used in examples, remove in the future\n return function(v: Vec2Value): Vec2 {\n return Vec2.neo(v.x + x, v.y + y);\n };\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { EPSILON } from \"../common/Math\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n/**\n * Ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n */\nexport interface RayCastInput {\n p1: Vec2Value;\n p2: Vec2Value;\n maxFraction: number;\n}\n\nexport type RayCastCallback = (subInput: RayCastInput, id: number) => number;\n\n/**\n * Ray-cast output data. The ray hits at `p1 + fraction * (p2 - p1)`,\n * where `p1` and `p2` come from RayCastInput.\n */\nexport interface RayCastOutput {\n normal: Vec2;\n fraction: number;\n}\n\n/** Axis-aligned bounding box */\nexport interface AABBValue {\n lowerBound: Vec2Value;\n upperBound: Vec2Value;\n}\n\ndeclare module \"./AABB\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function AABB(lower?: Vec2Value, upper?: Vec2Value): AABB;\n}\n\n/** Axis-aligned bounding box */\n// @ts-expect-error\nexport class AABB {\n lowerBound: Vec2;\n upperBound: Vec2;\n\n constructor(lower?: Vec2Value, upper?: Vec2Value) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof AABB)) {\n return new AABB(lower, upper);\n }\n\n this.lowerBound = Vec2.zero();\n this.upperBound = Vec2.zero();\n\n if (typeof lower === \"object\") {\n this.lowerBound.setVec2(lower);\n }\n if (typeof upper === \"object\") {\n this.upperBound.setVec2(upper);\n } else if (typeof lower === \"object\") {\n this.upperBound.setVec2(lower);\n }\n }\n\n /**\n * Verify that the bounds are sorted.\n */\n isValid(): boolean {\n return AABB.isValid(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.lowerBound) && Vec2.isValid(obj.upperBound) && Vec2.sub(obj.upperBound, obj.lowerBound).lengthSquared() >= 0;\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!AABB.isValid(o), \"Invalid AABB!\", o);\n }\n\n /**\n * Get the center of the AABB.\n */\n getCenter(): Vec2 {\n return Vec2.neo((this.lowerBound.x + this.upperBound.x) * 0.5, (this.lowerBound.y + this.upperBound.y) * 0.5);\n }\n\n /**\n * Get the extents of the AABB (half-widths).\n */\n getExtents(): Vec2 {\n return Vec2.neo((this.upperBound.x - this.lowerBound.x) * 0.5, (this.upperBound.y - this.lowerBound.y) * 0.5);\n }\n\n /**\n * Get the perimeter length.\n */\n getPerimeter(): number {\n return 2.0 * (this.upperBound.x - this.lowerBound.x + this.upperBound.y - this.lowerBound.y);\n }\n\n /**\n * Combine one or two AABB into this one.\n */\n combine(a: AABBValue, b?: AABBValue): void {\n b = b || this;\n\n const lowerA = a.lowerBound;\n const upperA = a.upperBound;\n const lowerB = b.lowerBound;\n const upperB = b.upperBound;\n\n const lowerX = math_min(lowerA.x, lowerB.x);\n const lowerY = math_min(lowerA.y, lowerB.y);\n const upperX = math_max(upperB.x, upperA.x);\n const upperY = math_max(upperB.y, upperA.y);\n\n this.lowerBound.setNum(lowerX, lowerY);\n this.upperBound.setNum(upperX, upperY);\n }\n\n combinePoints(a: Vec2Value, b: Vec2Value): void {\n this.lowerBound.setNum(math_min(a.x, b.x), math_min(a.y, b.y));\n this.upperBound.setNum(math_max(a.x, b.x), math_max(a.y, b.y));\n }\n\n set(aabb: AABBValue): void {\n this.lowerBound.setNum(aabb.lowerBound.x, aabb.lowerBound.y);\n this.upperBound.setNum(aabb.upperBound.x, aabb.upperBound.y);\n }\n\n contains(aabb: AABBValue): boolean {\n let result = true;\n result = result && this.lowerBound.x <= aabb.lowerBound.x;\n result = result && this.lowerBound.y <= aabb.lowerBound.y;\n result = result && aabb.upperBound.x <= this.upperBound.x;\n result = result && aabb.upperBound.y <= this.upperBound.y;\n return result;\n }\n\n extend(value: number): AABB {\n AABB.extend(this, value);\n return this;\n }\n\n static extend(out: AABBValue, value: number): AABBValue {\n out.lowerBound.x -= value;\n out.lowerBound.y -= value;\n out.upperBound.x += value;\n out.upperBound.y += value;\n return out;\n }\n\n static testOverlap(a: AABBValue, b: AABBValue): boolean {\n const d1x = b.lowerBound.x - a.upperBound.x;\n const d2x = a.lowerBound.x - b.upperBound.x;\n\n const d1y = b.lowerBound.y - a.upperBound.y;\n const d2y = a.lowerBound.y - b.upperBound.y;\n\n if (d1x > 0 || d1y > 0 || d2x > 0 || d2y > 0) {\n return false;\n }\n return true;\n }\n\n static areEqual(a: AABBValue, b: AABBValue): boolean {\n return Vec2.areEqual(a.lowerBound, b.lowerBound) && Vec2.areEqual(a.upperBound, b.upperBound);\n }\n\n static diff(a: AABBValue, b: AABBValue): number {\n const wD = math_max(0, math_min(a.upperBound.x, b.upperBound.x) - math_max(b.lowerBound.x, a.lowerBound.x));\n const hD = math_max(0, math_min(a.upperBound.y, b.upperBound.y) - math_max(b.lowerBound.y, a.lowerBound.y));\n\n const wA = a.upperBound.x - a.lowerBound.x;\n const hA = a.upperBound.y - a.lowerBound.y;\n\n const wB = b.upperBound.x - b.lowerBound.x;\n const hB = b.upperBound.y - b.lowerBound.y;\n\n return wA * hA + wB * hB - wD * hD;\n }\n\n rayCast(output: RayCastOutput, input: RayCastInput): boolean {\n // From Real-time Collision Detection, p179.\n\n let tmin = -Infinity;\n let tmax = Infinity;\n\n const p = input.p1;\n const d = Vec2.sub(input.p2, input.p1);\n const absD = Vec2.abs(d);\n\n const normal = Vec2.zero();\n\n for (let f: \"x\" | \"y\" = \"x\"; f !== null; f = (f === \"x\" ? \"y\" : null)) {\n if (absD.x < EPSILON) {\n // Parallel.\n if (p[f] < this.lowerBound[f] || this.upperBound[f] < p[f]) {\n return false;\n }\n } else {\n const inv_d = 1.0 / d[f];\n let t1 = (this.lowerBound[f] - p[f]) * inv_d;\n let t2 = (this.upperBound[f] - p[f]) * inv_d;\n\n // Sign of the normal vector.\n let s = -1.0;\n\n if (t1 > t2) {\n const temp = t1;\n t1 = t2;\n t2 = temp;\n s = 1.0;\n }\n\n // Push the min up\n if (t1 > tmin) {\n normal.setZero();\n normal[f] = s;\n tmin = t1;\n }\n\n // Pull the max down\n tmax = math_min(tmax, t2);\n\n if (tmin > tmax) {\n return false;\n }\n }\n }\n\n // Does the ray start inside the box?\n // Does the ray intersect beyond the max fraction?\n if (tmin < 0.0 || input.maxFraction < tmin) {\n return false;\n }\n\n // Intersection.\n output.fraction = tmin;\n output.normal = normal;\n return true;\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static combinePoints(out: AABBValue, a: Vec2Value, b: Vec2Value): AABBValue {\n out.lowerBound.x = math_min(a.x, b.x);\n out.lowerBound.y = math_min(a.y, b.y);\n out.upperBound.x = math_max(a.x, b.x);\n out.upperBound.y = math_max(a.y, b.y);\n return out;\n }\n\n static combinedPerimeter(a: AABBValue, b: AABBValue) {\n const lx = math_min(a.lowerBound.x, b.lowerBound.x);\n const ly = math_min(a.lowerBound.y, b.lowerBound.y);\n const ux = math_max(a.upperBound.x, b.upperBound.x);\n const uy = math_max(a.upperBound.y, b.upperBound.y);\n return 2.0 * (ux - lx + uy - ly); \n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Tuning constants based on meters-kilograms-seconds (MKS) units.\n * \n * Some tolerances are absolute and some are relative. Absolute tolerances use MKS units.\n */\nexport class Settings {\n /**\n * You can use this to change the length scale used by your game.\n * \n * For example for inches you could use 39.4.\n */\n static lengthUnitsPerMeter = 1.0;\n \n // Collision\n /**\n * The maximum number of contact points between two convex shapes. Do not change\n * this value.\n */\n static maxManifoldPoints: number = 2;\n\n /**\n * The maximum number of vertices on a convex polygon. You cannot increase this\n * too much because BlockAllocator has a maximum object size.\n */\n static maxPolygonVertices: number = 12;\n\n /**\n * This is used to fatten AABBs in the dynamic tree. This allows proxies to move\n * by a small amount without triggering a tree adjustment. This is in meters.\n */\n static aabbExtension: number = 0.1;\n\n /**\n * This is used to fatten AABBs in the dynamic tree. This is used to predict the\n * future position based on the current displacement. This is a dimensionless\n * multiplier.\n */\n static aabbMultiplier: number = 2.0;\n\n /**\n * A small length used as a collision and constraint tolerance. Usually it is\n * chosen to be numerically significant, but visually insignificant.\n */\n static linearSlop: number = 0.005;\n\n /**\n * A small angle used as a collision and constraint tolerance. Usually it is\n * chosen to be numerically significant, but visually insignificant.\n */\n static angularSlop: number = (2.0 / 180.0 * math_PI);\n\n /**\n * The radius of the polygon/edge shape skin. This should not be modified.\n * Making this smaller means polygons will have an insufficient buffer for\n * continuous collision. Making it larger may create artifacts for vertex\n * collision.\n */\n static get polygonRadius(): number { return 2.0 * Settings.linearSlop; }\n\n /**\n * Maximum number of sub-steps per contact in continuous physics simulation.\n */\n static maxSubSteps: number = 8;\n\n // Dynamics\n\n /**\n * Maximum number of contacts to be handled to solve a TOI impact.\n */\n static maxTOIContacts: number = 32;\n\n /**\n * Maximum iterations to solve a TOI.\n */\n static maxTOIIterations: number = 20;\n\n /**\n * Maximum iterations to find Distance.\n */\n static maxDistanceIterations: number = 20;\n\n /**\n * A velocity threshold for elastic collisions. Any collision with a relative\n * linear velocity below this threshold will be treated as inelastic.\n */\n static velocityThreshold: number = 1.0;\n\n /**\n * The maximum linear position correction used when solving constraints. This\n * helps to prevent overshoot.\n */\n static maxLinearCorrection: number = 0.2;\n\n /**\n * The maximum angular position correction used when solving constraints. This\n * helps to prevent overshoot.\n */\n static maxAngularCorrection: number = (8.0 / 180.0 * math_PI);\n\n /**\n * The maximum linear velocity of a body. This limit is very large and is used\n * to prevent numerical problems. You shouldn't need to adjust Settings.\n */\n static maxTranslation: number = 2.0;\n\n /**\n * The maximum angular velocity of a body. This limit is very large and is used\n * to prevent numerical problems. You shouldn't need to adjust Settings.\n */\n static maxRotation: number = (0.5 * math_PI);\n\n /**\n * This scale factor controls how fast overlap is resolved. Ideally this would\n * be 1 so that overlap is removed in one time step. However using values close\n * to 1 often lead to overshoot.\n */\n static baumgarte: number = 0.2;\n static toiBaugarte: number = 0.75;\n\n // Sleep\n\n /**\n * The time that a body must be still before it will go to sleep.\n */\n static timeToSleep: number = 0.5;\n\n /**\n * A body cannot sleep if its linear velocity is above this tolerance.\n */\n static linearSleepTolerance: number = 0.01;\n\n /**\n * A body cannot sleep if its angular velocity is above this tolerance.\n */\n static angularSleepTolerance: number = (2.0 / 180.0 * math_PI);\n}\n\n/** @internal */\nexport class SettingsInternal {\n static get maxManifoldPoints() {\n return Settings.maxManifoldPoints;\n }\n static get maxPolygonVertices() {\n return Settings.maxPolygonVertices;\n }\n static get aabbExtension() {\n return Settings.aabbExtension * Settings.lengthUnitsPerMeter;\n }\n static get aabbMultiplier() {\n return Settings.aabbMultiplier;\n }\n static get linearSlop() {\n return Settings.linearSlop * Settings.lengthUnitsPerMeter;\n }\n static get linearSlopSquared() {\n return Settings.linearSlop * Settings.lengthUnitsPerMeter * Settings.linearSlop * Settings.lengthUnitsPerMeter;\n }\n static get angularSlop() {\n return Settings.angularSlop;\n }\n static get polygonRadius() {\n return 2.0 * Settings.linearSlop;\n }\n static get maxSubSteps() {\n return Settings.maxSubSteps;\n }\n static get maxTOIContacts() {\n return Settings.maxTOIContacts;\n }\n static get maxTOIIterations() {\n return Settings.maxTOIIterations;\n }\n static get maxDistanceIterations() {\n return Settings.maxDistanceIterations;\n }\n static get velocityThreshold() {\n return Settings.velocityThreshold * Settings.lengthUnitsPerMeter;\n }\n static get maxLinearCorrection() {\n return Settings.maxLinearCorrection * Settings.lengthUnitsPerMeter;\n }\n static get maxAngularCorrection() {\n return Settings.maxAngularCorrection;\n }\n static get maxTranslation() {\n return Settings.maxTranslation * Settings.lengthUnitsPerMeter;\n }\n static get maxTranslationSquared() {\n return Settings.maxTranslation * Settings.lengthUnitsPerMeter * Settings.maxTranslation * Settings.lengthUnitsPerMeter;\n }\n static get maxRotation() {\n return Settings.maxRotation;\n }\n static get maxRotationSquared() {\n return Settings.maxRotation * Settings.maxRotation;\n }\n static get baumgarte() {\n return Settings.baumgarte;\n }\n static get toiBaugarte() {\n return Settings.toiBaugarte;\n }\n static get timeToSleep() {\n return Settings.timeToSleep;\n }\n static get linearSleepTolerance() {\n return Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter;\n }\n static get linearSleepToleranceSqr() {\n return Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter * Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter;\n }\n static get angularSleepTolerance() {\n return Settings.angularSleepTolerance;\n }\n static get angularSleepToleranceSqr() {\n return Settings.angularSleepTolerance * Settings.angularSleepTolerance;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */\nexport interface PoolOptions {\n max?: number,\n create?: () => T,\n /** Called when an object is being re-allocated. */\n allocate?: (item: T) => void,\n /** Called when an object is returned to pool. */\n release?: (item: T) => void,\n /** Called when an object is returned to the pool but will be disposed from pool. */\n dispose?: (item: T) => T,\n}\n\n/** @internal */\nexport class Pool {\n _list: T[] = [];\n _max: number = Infinity;\n\n _createFn: () => T;\n _hasCreateFn: boolean = false;\n _createCount: number = 0;\n\n _allocateFn: (item: T) => void;\n _hasAllocateFn: boolean = false;\n _allocateCount: number = 0;\n\n _releaseFn: (item: T) => void;\n _hasReleaseFn: boolean = false;\n _releaseCount: number = 0;\n\n _disposeFn: (item: T) => T;\n _hasDisposeFn: boolean = false;\n _disposeCount: number = 0;\n\n constructor(opts: PoolOptions) {\n this._list = [];\n this._max = opts.max || this._max;\n\n this._createFn = opts.create;\n this._hasCreateFn = typeof this._createFn === \"function\";\n this._allocateFn = opts.allocate;\n this._hasAllocateFn = typeof this._allocateFn === \"function\";\n this._releaseFn = opts.release;\n this._hasReleaseFn = typeof this._releaseFn === \"function\";\n this._disposeFn = opts.dispose;\n this._hasDisposeFn = typeof this._disposeFn === \"function\";\n }\n\n max(n?: number): number | Pool {\n if (typeof n === \"number\") {\n this._max = n;\n return this;\n }\n return this._max;\n }\n\n size(): number {\n return this._list.length;\n }\n\n allocate(): T {\n let item: T;\n if (this._list.length > 0) {\n item = this._list.shift();\n } else {\n this._createCount++;\n if (this._hasCreateFn) {\n item = this._createFn();\n } else {\n // tslint:disable-next-line:no-object-literal-type-assertion\n item = {} as T;\n }\n }\n this._allocateCount++;\n if (this._hasAllocateFn) {\n this._allocateFn(item);\n }\n return item;\n }\n\n release(item: T): void {\n if (this._list.length < this._max) {\n this._releaseCount++;\n if (this._hasReleaseFn) {\n this._releaseFn(item);\n }\n this._list.push(item);\n } else {\n this._disposeCount++;\n if (this._hasDisposeFn) {\n item = this._disposeFn(item);\n }\n }\n }\n\n toString(): string {\n return \" +\" + this._createCount + \" >\" + this._allocateCount + \" <\" + this._releaseCount + \" -\"\n + this._disposeCount + \" =\" + this._list.length + \"/\" + this._max;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { Pool } from \"../util/Pool\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { AABB, AABBValue, RayCastCallback, RayCastInput } from \"./AABB\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n\n\nexport type DynamicTreeQueryCallback = (nodeId: number) => boolean;\n\n/**\n * A node in the dynamic tree. The client does not interact with this directly.\n */\nexport class TreeNode {\n id: number;\n /** Enlarged AABB */\n aabb: AABB = new AABB();\n userData: T = null;\n parent: TreeNode = null;\n child1: TreeNode = null;\n child2: TreeNode = null;\n /** 0: leaf, -1: free node */\n height: number = -1;\n\n constructor(id?: number) {\n this.id = id;\n }\n\n /** @internal */\n toString(): string {\n return this.id + \": \" + this.userData;\n }\n\n isLeaf(): boolean {\n return this.child1 == null;\n }\n}\n\n/** @internal */ const poolTreeNode = new Pool>({\n create(): TreeNode {\n return new TreeNode();\n },\n release(node: TreeNode) {\n node.userData = null;\n node.parent = null;\n node.child1 = null;\n node.child2 = null;\n node.height = -1;\n node.id = undefined;\n }\n});\n\n/**\n * A dynamic AABB tree broad-phase, inspired by Nathanael Presson's btDbvt. A\n * dynamic tree arranges data in a binary tree to accelerate queries such as\n * volume queries and ray casts. Leafs are proxies with an AABB. In the tree we\n * expand the proxy AABB by `aabbExtension` so that the proxy AABB is bigger\n * than the client object. This allows the client object to move by small\n * amounts without triggering a tree update.\n *\n * Nodes are pooled and relocatable, so we use node indices rather than\n * pointers.\n */\nexport class DynamicTree {\n m_root: TreeNode;\n m_lastProxyId: number;\n m_nodes: {\n [id: number]: TreeNode\n };\n\n constructor() {\n this.m_root = null;\n this.m_nodes = {};\n this.m_lastProxyId = 0;\n }\n\n /**\n * Get proxy user data.\n *\n * @return the proxy user data or 0 if the id is invalid.\n */\n getUserData(id: number): T {\n const node = this.m_nodes[id];\n if (_ASSERT) console.assert(!!node);\n return node.userData;\n }\n\n /**\n * Get the fat AABB for a node id.\n *\n * @return the proxy user data or 0 if the id is invalid.\n */\n getFatAABB(id: number): AABB {\n const node = this.m_nodes[id];\n if (_ASSERT) console.assert(!!node);\n return node.aabb;\n }\n\n allocateNode(): TreeNode {\n const node = poolTreeNode.allocate();\n node.id = ++this.m_lastProxyId;\n this.m_nodes[node.id] = node;\n return node;\n }\n\n freeNode(node: TreeNode): void {\n // tslint:disable-next-line:no-dynamic-delete\n delete this.m_nodes[node.id];\n poolTreeNode.release(node);\n }\n\n /**\n * Create a proxy in the tree as a leaf node. We return the index of the node\n * instead of a pointer so that we can grow the node pool.\n *\n * Create a proxy. Provide a tight fitting AABB and a userData pointer.\n */\n createProxy(aabb: AABBValue, userData: T): number {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n\n const node = this.allocateNode();\n\n node.aabb.set(aabb);\n\n // Fatten the aabb.\n AABB.extend(node.aabb, Settings.aabbExtension);\n\n node.userData = userData;\n node.height = 0;\n\n this.insertLeaf(node);\n\n return node.id;\n }\n\n /**\n * Destroy a proxy. This asserts if the id is invalid.\n */\n destroyProxy(id: number): void {\n const node = this.m_nodes[id];\n\n if (_ASSERT) console.assert(!!node);\n if (_ASSERT) console.assert(node.isLeaf());\n\n this.removeLeaf(node);\n this.freeNode(node);\n }\n\n /**\n * Move a proxy with a swepted AABB. If the proxy has moved outside of its\n * fattened AABB, then the proxy is removed from the tree and re-inserted.\n * Otherwise the function returns immediately.\n *\n * @param d Displacement\n *\n * @return true if the proxy was re-inserted.\n */\n moveProxy(id: number, aabb: AABBValue, d: Vec2Value): boolean {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n if (_ASSERT) console.assert(!d || Vec2.isValid(d));\n\n const node = this.m_nodes[id];\n\n if (_ASSERT) console.assert(!!node);\n if (_ASSERT) console.assert(node.isLeaf());\n\n if (node.aabb.contains(aabb)) {\n return false;\n }\n\n this.removeLeaf(node);\n\n node.aabb.set(aabb);\n\n // Extend AABB.\n aabb = node.aabb;\n AABB.extend(aabb, Settings.aabbExtension);\n\n // Predict AABB displacement.\n // const d = Vec2.mul(Settings.aabbMultiplier, displacement);\n\n if (d.x < 0.0) {\n aabb.lowerBound.x += d.x * Settings.aabbMultiplier;\n } else {\n aabb.upperBound.x += d.x * Settings.aabbMultiplier;\n }\n\n if (d.y < 0.0) {\n aabb.lowerBound.y += d.y * Settings.aabbMultiplier;\n } else {\n aabb.upperBound.y += d.y * Settings.aabbMultiplier;\n }\n\n this.insertLeaf(node);\n\n return true;\n }\n\n insertLeaf(leaf: TreeNode): void {\n if (_ASSERT) console.assert(AABB.isValid(leaf.aabb));\n\n if (this.m_root == null) {\n this.m_root = leaf;\n this.m_root.parent = null;\n return;\n }\n\n // Find the best sibling for this node\n const leafAABB = leaf.aabb;\n let index = this.m_root;\n while (!index.isLeaf()) {\n const child1 = index.child1;\n const child2 = index.child2;\n\n const area = index.aabb.getPerimeter();\n\n const combinedArea = AABB.combinedPerimeter(index.aabb, leafAABB);\n\n // Cost of creating a new parent for this node and the new leaf\n const cost = 2.0 * combinedArea;\n\n // Minimum cost of pushing the leaf further down the tree\n const inheritanceCost = 2.0 * (combinedArea - area);\n\n // Cost of descending into child1\n const newArea1 = AABB.combinedPerimeter(leafAABB, child1.aabb);\n let cost1 = newArea1 + inheritanceCost;\n if (!child1.isLeaf()) {\n const oldArea = child1.aabb.getPerimeter();\n cost1 -= oldArea;\n }\n\n // Cost of descending into child2\n const newArea2 = AABB.combinedPerimeter(leafAABB, child2.aabb);\n let cost2 = newArea2 + inheritanceCost;\n if (!child2.isLeaf()) {\n const oldArea = child2.aabb.getPerimeter();\n cost2 -= oldArea;\n }\n\n // Descend according to the minimum cost.\n if (cost < cost1 && cost < cost2) {\n break;\n }\n\n // Descend\n if (cost1 < cost2) {\n index = child1;\n } else {\n index = child2;\n }\n }\n\n const sibling = index;\n\n // Create a new parent.\n const oldParent = sibling.parent;\n const newParent = this.allocateNode();\n newParent.parent = oldParent;\n newParent.userData = null;\n newParent.aabb.combine(leafAABB, sibling.aabb);\n newParent.height = sibling.height + 1;\n\n if (oldParent != null) {\n // The sibling was not the root.\n if (oldParent.child1 === sibling) {\n oldParent.child1 = newParent;\n } else {\n oldParent.child2 = newParent;\n }\n\n newParent.child1 = sibling;\n newParent.child2 = leaf;\n sibling.parent = newParent;\n leaf.parent = newParent;\n } else {\n // The sibling was the root.\n newParent.child1 = sibling;\n newParent.child2 = leaf;\n sibling.parent = newParent;\n leaf.parent = newParent;\n this.m_root = newParent;\n }\n\n // Walk back up the tree fixing heights and AABBs\n index = leaf.parent;\n while (index != null) {\n index = this.balance(index);\n\n const child1 = index.child1;\n const child2 = index.child2;\n\n if (_ASSERT) console.assert(child1 != null);\n if (_ASSERT) console.assert(child2 != null);\n\n index.height = 1 + math_max(child1.height, child2.height);\n index.aabb.combine(child1.aabb, child2.aabb);\n\n index = index.parent;\n }\n\n // validate();\n }\n\n removeLeaf(leaf: TreeNode): void {\n if (leaf === this.m_root) {\n this.m_root = null;\n return;\n }\n\n const parent = leaf.parent;\n const grandParent = parent.parent;\n let sibling;\n if (parent.child1 === leaf) {\n sibling = parent.child2;\n } else {\n sibling = parent.child1;\n }\n\n if (grandParent != null) {\n // Destroy parent and connect sibling to grandParent.\n if (grandParent.child1 === parent) {\n grandParent.child1 = sibling;\n } else {\n grandParent.child2 = sibling;\n }\n sibling.parent = grandParent;\n this.freeNode(parent);\n\n // Adjust ancestor bounds.\n let index = grandParent;\n while (index != null) {\n index = this.balance(index);\n\n const child1 = index.child1;\n const child2 = index.child2;\n\n index.aabb.combine(child1.aabb, child2.aabb);\n index.height = 1 + math_max(child1.height, child2.height);\n\n index = index.parent;\n }\n } else {\n this.m_root = sibling;\n sibling.parent = null;\n this.freeNode(parent);\n }\n\n // validate();\n }\n\n /**\n * Perform a left or right rotation if node A is imbalanced. Returns the new\n * root index.\n */\n balance(iA: TreeNode): TreeNode {\n if (_ASSERT) console.assert(iA != null);\n\n const A = iA;\n if (A.isLeaf() || A.height < 2) {\n return iA;\n }\n\n const B = A.child1;\n const C = A.child2;\n\n const balance = C.height - B.height;\n\n // Rotate C up\n if (balance > 1) {\n const F = C.child1;\n const G = C.child2;\n\n // Swap A and C\n C.child1 = A;\n C.parent = A.parent;\n A.parent = C;\n\n // A's old parent should point to C\n if (C.parent != null) {\n if (C.parent.child1 === iA) {\n C.parent.child1 = C;\n } else {\n C.parent.child2 = C;\n }\n } else {\n this.m_root = C;\n }\n\n // Rotate\n if (F.height > G.height) {\n C.child2 = F;\n A.child2 = G;\n G.parent = A;\n A.aabb.combine(B.aabb, G.aabb);\n C.aabb.combine(A.aabb, F.aabb);\n\n A.height = 1 + math_max(B.height, G.height);\n C.height = 1 + math_max(A.height, F.height);\n } else {\n C.child2 = G;\n A.child2 = F;\n F.parent = A;\n A.aabb.combine(B.aabb, F.aabb);\n C.aabb.combine(A.aabb, G.aabb);\n\n A.height = 1 + math_max(B.height, F.height);\n C.height = 1 + math_max(A.height, G.height);\n }\n\n return C;\n }\n\n // Rotate B up\n if (balance < -1) {\n const D = B.child1;\n const E = B.child2;\n\n // Swap A and B\n B.child1 = A;\n B.parent = A.parent;\n A.parent = B;\n\n // A's old parent should point to B\n if (B.parent != null) {\n if (B.parent.child1 === A) {\n B.parent.child1 = B;\n } else {\n B.parent.child2 = B;\n }\n } else {\n this.m_root = B;\n }\n\n // Rotate\n if (D.height > E.height) {\n B.child2 = D;\n A.child1 = E;\n E.parent = A;\n A.aabb.combine(C.aabb, E.aabb);\n B.aabb.combine(A.aabb, D.aabb);\n\n A.height = 1 + math_max(C.height, E.height);\n B.height = 1 + math_max(A.height, D.height);\n } else {\n B.child2 = E;\n A.child1 = D;\n D.parent = A;\n A.aabb.combine(C.aabb, D.aabb);\n B.aabb.combine(A.aabb, E.aabb);\n\n A.height = 1 + math_max(C.height, D.height);\n B.height = 1 + math_max(A.height, E.height);\n }\n\n return B;\n }\n\n return A;\n }\n\n /**\n * Compute the height of the binary tree in O(N) time. Should not be called\n * often.\n */\n getHeight(): number {\n if (this.m_root == null) {\n return 0;\n }\n\n return this.m_root.height;\n }\n\n /**\n * Get the ratio of the sum of the node areas to the root area.\n */\n getAreaRatio(): number {\n if (this.m_root == null) {\n return 0.0;\n }\n\n const root = this.m_root;\n const rootArea = root.aabb.getPerimeter();\n\n let totalArea = 0.0;\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height < 0) {\n // Free node in pool\n continue;\n }\n\n totalArea += node.aabb.getPerimeter();\n }\n\n this.iteratorPool.release(it);\n\n return totalArea / rootArea;\n }\n\n /**\n * Compute the height of a sub-tree.\n */\n computeHeight(id?: number): number {\n let node;\n if (typeof id !== \"undefined\") {\n node = this.m_nodes[id];\n } else {\n node = this.m_root;\n }\n\n // if (_ASSERT) console.assert(0 <= id && id < this.m_nodeCapacity);\n\n if (node.isLeaf()) {\n return 0;\n }\n\n const height1 = this.computeHeight(node.child1.id);\n const height2 = this.computeHeight(node.child2.id);\n return 1 + math_max(height1, height2);\n }\n\n validateStructure(node: TreeNode): void {\n if (node == null) {\n return;\n }\n\n if (node === this.m_root) {\n if (_ASSERT) console.assert(node.parent == null);\n }\n\n const child1 = node.child1;\n const child2 = node.child2;\n\n if (node.isLeaf()) {\n if (_ASSERT) console.assert(child1 == null);\n if (_ASSERT) console.assert(child2 == null);\n if (_ASSERT) console.assert(node.height === 0);\n return;\n }\n\n // if (_ASSERT) console.assert(0 <= child1 && child1 < this.m_nodeCapacity);\n // if (_ASSERT) console.assert(0 <= child2 && child2 < this.m_nodeCapacity);\n\n if (_ASSERT) console.assert(child1.parent === node);\n if (_ASSERT) console.assert(child2.parent === node);\n\n this.validateStructure(child1);\n this.validateStructure(child2);\n }\n\n validateMetrics(node: TreeNode): void {\n if (node == null) {\n return;\n }\n\n const child1 = node.child1;\n const child2 = node.child2;\n\n if (node.isLeaf()) {\n if (_ASSERT) console.assert(child1 == null);\n if (_ASSERT) console.assert(child2 == null);\n if (_ASSERT) console.assert(node.height === 0);\n return;\n }\n\n // if (_ASSERT) console.assert(0 <= child1 && child1 < this.m_nodeCapacity);\n // if (_ASSERT) console.assert(0 <= child2 && child2 < this.m_nodeCapacity);\n\n const height1 = child1.height;\n const height2 = child2.height;\n const height = 1 + math_max(height1, height2);\n if (_ASSERT) console.assert(node.height === height);\n\n const aabb = new AABB();\n aabb.combine(child1.aabb, child2.aabb);\n\n if (_ASSERT) console.assert(AABB.areEqual(aabb, node.aabb));\n\n this.validateMetrics(child1);\n this.validateMetrics(child2);\n }\n\n /**\n * Validate this tree. For testing.\n */\n validate(): void {\n if (!_ASSERT) return;\n this.validateStructure(this.m_root);\n this.validateMetrics(this.m_root);\n\n console.assert(this.getHeight() === this.computeHeight());\n }\n\n /**\n * Get the maximum balance of an node in the tree. The balance is the difference\n * in height of the two children of a node.\n */\n getMaxBalance(): number {\n let maxBalance = 0;\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height <= 1) {\n continue;\n }\n\n if (_ASSERT) console.assert(!node.isLeaf());\n\n const balance = math_abs(node.child2.height - node.child1.height);\n maxBalance = math_max(maxBalance, balance);\n }\n this.iteratorPool.release(it);\n\n return maxBalance;\n }\n\n /**\n * Build an optimal tree. Very expensive. For testing.\n */\n rebuildBottomUp(): void {\n const nodes = [];\n let count = 0;\n\n // Build array of leaves. Free the rest.\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height < 0) {\n // free node in pool\n continue;\n }\n\n if (node.isLeaf()) {\n node.parent = null;\n nodes[count] = node;\n ++count;\n } else {\n this.freeNode(node);\n }\n }\n this.iteratorPool.release(it);\n\n while (count > 1) {\n let minCost = Infinity;\n let iMin = -1;\n let jMin = -1;\n for (let i = 0; i < count; ++i) {\n const aabbi = nodes[i].aabb;\n for (let j = i + 1; j < count; ++j) {\n const aabbj = nodes[j].aabb;\n const cost = AABB.combinedPerimeter(aabbi, aabbj);\n if (cost < minCost) {\n iMin = i;\n jMin = j;\n minCost = cost;\n }\n }\n }\n\n const child1 = nodes[iMin];\n const child2 = nodes[jMin];\n\n const parent = this.allocateNode();\n parent.child1 = child1;\n parent.child2 = child2;\n parent.height = 1 + math_max(child1.height, child2.height);\n parent.aabb.combine(child1.aabb, child2.aabb);\n parent.parent = null;\n\n child1.parent = parent;\n child2.parent = parent;\n\n nodes[jMin] = nodes[count - 1];\n nodes[iMin] = parent;\n --count;\n }\n\n this.m_root = nodes[0];\n\n if (_ASSERT) this.validate();\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n // Build array of leaves. Free the rest.\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n const aabb = node.aabb;\n aabb.lowerBound.x -= newOrigin.x;\n aabb.lowerBound.y -= newOrigin.y;\n aabb.upperBound.x -= newOrigin.x;\n aabb.upperBound.y -= newOrigin.y;\n }\n this.iteratorPool.release(it);\n }\n\n /**\n * Query an AABB for overlapping proxies. The callback class is called for each\n * proxy that overlaps the supplied AABB.\n */\n query(aabb: AABBValue, queryCallback: DynamicTreeQueryCallback): void {\n if (_ASSERT) console.assert(typeof queryCallback === \"function\");\n const stack = this.stackPool.allocate();\n\n stack.push(this.m_root);\n while (stack.length > 0) {\n const node = stack.pop();\n if (node == null) {\n continue;\n }\n\n if (AABB.testOverlap(node.aabb, aabb)) {\n if (node.isLeaf()) {\n const proceed = queryCallback(node.id);\n if (proceed === false) {\n return;\n }\n } else {\n stack.push(node.child1);\n stack.push(node.child2);\n }\n }\n }\n\n this.stackPool.release(stack);\n }\n\n /**\n * Ray-cast against the proxies in the tree. This relies on the callback to\n * perform a exact ray-cast in the case were the proxy contains a shape. The\n * callback also performs the any collision filtering. This has performance\n * roughly equal to k * log(n), where k is the number of collisions and n is the\n * number of proxies in the tree.\n *\n * @param input The ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n * @param rayCastCallback A function that is called for each proxy that is hit by the ray. If the return value is a positive number it will update the maxFraction of the ray cast input, and if it is zero it will terminate they ray cast.\n */\n rayCast(input: RayCastInput, rayCastCallback: RayCastCallback): void {\n // TODO: GC\n if (_ASSERT) console.assert(typeof rayCastCallback === \"function\");\n const p1 = input.p1;\n const p2 = input.p2;\n const r = Vec2.sub(p2, p1);\n if (_ASSERT) console.assert(r.lengthSquared() > 0.0);\n r.normalize();\n\n // v is perpendicular to the segment.\n const v = Vec2.crossNumVec2(1.0, r);\n const abs_v = Vec2.abs(v);\n\n // Separating axis for segment (Gino, p80).\n // |dot(v, p1 - c)| > dot(|v|, h)\n\n let maxFraction = input.maxFraction;\n\n // Build a bounding box for the segment.\n const segmentAABB = new AABB();\n let t = Vec2.combine((1 - maxFraction), p1, maxFraction, p2);\n segmentAABB.combinePoints(p1, t);\n\n const stack = this.stackPool.allocate();\n const subInput = this.inputPool.allocate();\n\n stack.push(this.m_root);\n while (stack.length > 0) {\n const node = stack.pop();\n if (node == null) {\n continue;\n }\n\n if (AABB.testOverlap(node.aabb, segmentAABB) === false) {\n continue;\n }\n\n // Separating axis for segment (Gino, p80).\n // |dot(v, p1 - c)| > dot(|v|, h)\n const c = node.aabb.getCenter();\n const h = node.aabb.getExtents();\n const separation = math_abs(Vec2.dot(v, Vec2.sub(p1, c))) - Vec2.dot(abs_v, h);\n if (separation > 0.0) {\n continue;\n }\n\n if (node.isLeaf()) {\n subInput.p1 = Vec2.clone(input.p1);\n subInput.p2 = Vec2.clone(input.p2);\n subInput.maxFraction = maxFraction;\n\n const value = rayCastCallback(subInput, node.id);\n\n if (value === 0.0) {\n // The client has terminated the ray cast.\n break;\n } else if (value > 0.0) {\n // update segment bounding box.\n maxFraction = value;\n t = Vec2.combine((1 - maxFraction), p1, maxFraction, p2);\n segmentAABB.combinePoints(p1, t);\n }\n } else {\n stack.push(node.child1);\n stack.push(node.child2);\n }\n }\n this.stackPool.release(stack);\n this.inputPool.release(subInput);\n }\n\n private inputPool: Pool = new Pool({\n create(): RayCastInput {\n // tslint:disable-next-line:no-object-literal-type-assertion\n return {} as RayCastInput;\n },\n release(stack: RayCastInput): void {\n }\n });\n\n private stackPool: Pool>> = new Pool>>({\n create(): Array> {\n return [];\n },\n release(stack: Array>): void {\n stack.length = 0;\n }\n });\n\n private iteratorPool: Pool> = new Pool>({\n create(): Iterator {\n return new Iterator();\n },\n release(iterator: Iterator): void {\n iterator.close();\n }\n });\n\n}\n\n/** @internal */\nclass Iterator {\n parents: Array> = [];\n states: number[] = [];\n preorder(root: TreeNode): Iterator {\n this.parents.length = 0;\n this.parents.push(root);\n this.states.length = 0;\n this.states.push(0);\n return this;\n }\n next(): TreeNode {\n while (this.parents.length > 0) {\n const i = this.parents.length - 1;\n const node = this.parents[i];\n if (this.states[i] === 0) {\n this.states[i] = 1;\n return node;\n }\n if (this.states[i] === 1) {\n this.states[i] = 2;\n if (node.child1) {\n this.parents.push(node.child1);\n this.states.push(1);\n return node.child1;\n }\n }\n if (this.states[i] === 2) {\n this.states[i] = 3;\n if (node.child2) {\n this.parents.push(node.child2);\n this.states.push(1);\n return node.child2;\n }\n }\n this.parents.pop();\n this.states.pop();\n }\n }\n close(): void {\n this.parents.length = 0;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2Value } from \"../common/Vec2\";\nimport { AABB, AABBValue, RayCastCallback, RayCastInput } from \"./AABB\";\nimport { DynamicTree, DynamicTreeQueryCallback } from \"./DynamicTree\";\nimport { FixtureProxy } from \"../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/**\n * The broad-phase wraps and extends a dynamic-tree to keep track of moved\n * objects and query them on update.\n */\nexport class BroadPhase {\n m_tree: DynamicTree = new DynamicTree();\n m_moveBuffer: number[] = [];\n\n m_callback: (userDataA: any, userDataB: any) => void;\n m_queryProxyId: number;\n\n /**\n * Get user data from a proxy. Returns null if the id is invalid.\n */\n getUserData(proxyId: number): FixtureProxy {\n return this.m_tree.getUserData(proxyId);\n }\n\n /**\n * Test overlap of fat AABBs.\n */\n testOverlap(proxyIdA: number, proxyIdB: number): boolean {\n const aabbA = this.m_tree.getFatAABB(proxyIdA);\n const aabbB = this.m_tree.getFatAABB(proxyIdB);\n return AABB.testOverlap(aabbA, aabbB);\n }\n\n /**\n * Get the fat AABB for a proxy.\n */\n getFatAABB(proxyId: number): AABB {\n return this.m_tree.getFatAABB(proxyId);\n }\n\n /**\n * Get the number of proxies.\n */\n getProxyCount(): number {\n return this.m_moveBuffer.length;\n }\n\n /**\n * Get the height of the embedded tree.\n */\n getTreeHeight(): number {\n return this.m_tree.getHeight();\n }\n\n /**\n * Get the balance (integer) of the embedded tree.\n */\n getTreeBalance(): number {\n return this.m_tree.getMaxBalance();\n }\n\n /**\n * Get the quality metric of the embedded tree.\n */\n getTreeQuality(): number {\n return this.m_tree.getAreaRatio();\n }\n\n /**\n * Query an AABB for overlapping proxies. The callback class is called for each\n * proxy that overlaps the supplied AABB.\n */\n query = (aabb: AABBValue, queryCallback: DynamicTreeQueryCallback): void => {\n this.m_tree.query(aabb, queryCallback);\n };\n\n /**\n * Ray-cast against the proxies in the tree. This relies on the callback to\n * perform a exact ray-cast in the case were the proxy contains a shape. The\n * callback also performs the any collision filtering. This has performance\n * roughly equal to k * log(n), where k is the number of collisions and n is the\n * number of proxies in the tree.\n *\n * @param input The ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n * @param rayCastCallback A function that is called for each proxy that is hit by the ray. If the return value is a positive number it will update the maxFraction of the ray cast input, and if it is zero it will terminate they ray cast.\n */\n rayCast(input: RayCastInput, rayCastCallback: RayCastCallback): void {\n this.m_tree.rayCast(input, rayCastCallback);\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_tree.shiftOrigin(newOrigin);\n }\n\n /**\n * Create a proxy with an initial AABB. Pairs are not reported until UpdatePairs\n * is called.\n */\n createProxy(aabb: AABBValue, userData: FixtureProxy): number {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n const proxyId = this.m_tree.createProxy(aabb, userData);\n this.bufferMove(proxyId);\n return proxyId;\n }\n\n /**\n * Destroy a proxy. It is up to the client to remove any pairs.\n */\n destroyProxy(proxyId: number): void {\n this.unbufferMove(proxyId);\n this.m_tree.destroyProxy(proxyId);\n }\n\n /**\n * Call moveProxy as many times as you like, then when you are done call\n * UpdatePairs to finalized the proxy pairs (for your time step).\n */\n moveProxy(proxyId: number, aabb: AABB, displacement: Vec2Value): void {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n const changed = this.m_tree.moveProxy(proxyId, aabb, displacement);\n if (changed) {\n this.bufferMove(proxyId);\n }\n }\n\n /**\n * Call to trigger a re-processing of it's pairs on the next call to\n * UpdatePairs.\n */\n touchProxy(proxyId: number): void {\n this.bufferMove(proxyId);\n }\n\n bufferMove(proxyId: number): void {\n this.m_moveBuffer.push(proxyId);\n }\n\n unbufferMove(proxyId: number): void {\n for (let i = 0; i < this.m_moveBuffer.length; ++i) {\n if (this.m_moveBuffer[i] === proxyId) {\n this.m_moveBuffer[i] = null;\n }\n }\n }\n\n /**\n * Update the pairs. This results in pair callbacks. This can only add pairs.\n */\n updatePairs(addPairCallback: (userDataA: FixtureProxy, userDataB: FixtureProxy) => void): void {\n if (_ASSERT) console.assert(typeof addPairCallback === \"function\");\n this.m_callback = addPairCallback;\n\n // Perform tree queries for all moving proxies.\n while (this.m_moveBuffer.length > 0) {\n this.m_queryProxyId = this.m_moveBuffer.pop();\n if (this.m_queryProxyId === null) {\n continue;\n }\n\n // We have to query the tree with the fat AABB so that\n // we don't fail to create a pair that may touch later.\n const fatAABB = this.m_tree.getFatAABB(this.m_queryProxyId);\n\n // Query tree, create pairs and add them pair buffer.\n this.m_tree.query(fatAABB, this.queryCallback);\n }\n\n // Try to keep the tree balanced.\n // this.m_tree.rebalance(4);\n }\n\n queryCallback = (proxyId: number): boolean => {\n // A proxy cannot form a pair with itself.\n if (proxyId === this.m_queryProxyId) {\n return true;\n }\n\n const proxyIdA = math_min(proxyId, this.m_queryProxyId);\n const proxyIdB = math_max(proxyId, this.m_queryProxyId);\n\n // TODO: Skip any duplicate pairs.\n\n const userDataA = this.m_tree.getUserData(proxyIdA);\n const userDataB = this.m_tree.getUserData(proxyIdB);\n\n // Send the pairs back to the client.\n this.m_callback(userDataA, userDataB);\n\n return true;\n };\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n/** @internal */ const math_sqrt = Math.sqrt;\n\n\nimport { RotValue } from \"./Rot\";\nimport { TransformValue } from \"./Transform\";\nimport { Vec2Value } from \"./Vec2\";\nimport { Vec3Value } from \"./Vec3\";\n\nexport function vec2(x: number, y: number): Vec2Value {\n return { x, y };\n}\n\nexport function vec3(x: number, y: number, z: number): Vec3Value {\n return { x, y, z };\n}\n\nexport function rotation(angle: number): RotValue {\n return { s: math_sin(angle), c: math_cos(angle) };\n}\n\nexport function setVec2(out: Vec2Value, x: number, y: number): Vec2Value {\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function copyVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = w.x;\n out.y = w.y;\n return out;\n}\n\nexport function zeroVec2(out: Vec2Value): Vec2Value {\n out.x = 0;\n out.y = 0;\n return out;\n}\n\nexport function negVec2(out: Vec2Value): Vec2Value {\n out.x = -out.x;\n out.y = -out.y;\n return out;\n}\n\nexport function plusVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x += w.x;\n out.y += w.y;\n return out;\n}\n\nexport function addVec2(out: Vec2Value, v: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = v.x + w.x;\n out.y = v.x + w.y;\n return out;\n}\n\nexport function minusVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x -= w.x;\n out.y -= w.y;\n return out;\n}\n\nexport function subVec2(out: Vec2Value, v: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = v.x - w.x;\n out.y = v.y - w.y;\n return out;\n}\n\nexport function mulVec2(out: Vec2Value, m: number): Vec2Value {\n out.x *= m;\n out.y *= m;\n return out;\n}\n\nexport function scaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x = m * w.x;\n out.y = m * w.y;\n return out;\n}\n\nexport function plusScaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x += m * w.x;\n out.y += m * w.y;\n return out;\n}\n\nexport function minusScaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x -= m * w.x;\n out.y -= m * w.y;\n return out;\n}\n\nexport function combine2Vec2(out: Vec2Value, am: number, a: Vec2Value, bm: number, b: Vec2Value): Vec2Value {\n out.x = am * a.x + bm * b.x;\n out.y = am * a.y + bm * b.y;\n return out;\n}\n\nexport function combine3Vec2(out: Vec2Value, am: number, a: Vec2Value, bm: number, b: Vec2Value, cm: number, c: Vec2Value): Vec2Value {\n out.x = am * a.x + bm * b.x + cm * c.x;\n out.y = am * a.y + bm * b.y + cm * c.y;\n return out;\n}\n\nexport function normalizeVec2Length(out: Vec2Value): number {\n const length = math_sqrt(out.x * out.x + out.y * out.y);\n if (length !== 0) {\n const invLength = 1 / length;\n out.x *= invLength;\n out.y *= invLength;\n }\n return length;\n}\n\nexport function normalizeVec2(out: Vec2Value): Vec2Value {\n const length = math_sqrt(out.x * out.x + out.y * out.y);\n if (length > 0) {\n const invLength = 1 / length;\n out.x *= invLength;\n out.y *= invLength;\n }\n return out;\n}\n\nexport function crossVec2Num(out: Vec2Value, v: Vec2Value, w: number): Vec2Value {\n const x = w * v.y;\n const y = -w * v.x;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function crossNumVec2(out: Vec2Value, w: number, v: Vec2Value): Vec2Value {\n const x = -w * v.y;\n const y = w * v.x;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function crossVec2Vec2(a: Vec2Value, b: Vec2Value): number {\n return a.x * b.y - a.y * b.x;\n}\n\nexport function dotVec2(a: Vec2Value, b: Vec2Value): number {\n return a.x * b.x + a.y * b.y;\n}\n\nexport function lengthVec2(a: Vec2Value): number {\n return math_sqrt(a.x * a.x + a.y * a.y);\n}\n\nexport function lengthSqrVec2(a: Vec2Value): number {\n return a.x * a.x + a.y * a.y;\n}\n\nexport function distVec2(a: Vec2Value, b: Vec2Value): number {\n const dx = a.x - b.x;\n const dy = a.y - b.y;\n return math_sqrt(dx * dx + dy * dy);\n}\n\nexport function distSqrVec2(a: Vec2Value, b: Vec2Value): number {\n const dx = a.x - b.x;\n const dy = a.y - b.y;\n return dx * dx + dy * dy;\n}\n\nexport function dotVec3(v: Vec3Value, w: Vec3Value): number {\n return v.x * w.x + v.y * w.y + v.z * w.z;\n}\n\nexport function setRotAngle(out: RotValue, a: number): RotValue {\n out.c = math_cos(a);\n out.s = math_sin(a);\n return out;\n}\n\nexport function rotVec2(out: Vec2Value, q: RotValue, v: Vec2Value): Vec2Value {\n out.x = q.c * v.x - q.s * v.y;\n out.y = q.s * v.x + q.c * v.y;\n return out;\n}\n\nexport function derotVec2(out: Vec2Value, q: RotValue, v: Vec2Value): Vec2Value {\n const x = q.c * v.x + q.s * v.y;\n const y = -q.s * v.x + q.c * v.y;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function rerotVec2(out: Vec2Value, before: RotValue, after: RotValue, v: Vec2Value): Vec2Value {\n const x0 = before.c * v.x + before.s * v.y;\n const y0 = -before.s * v.x + before.c * v.y;\n const x = after.c * x0 - after.s * y0;\n const y = after.s * x0 + after.c * y0;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function transform(x: number, y: number, a: number): TransformValue {\n return { p: vec2(x, y), q: rotation(a) };\n}\n\nexport function copyTransform(out: TransformValue, transform: TransformValue): TransformValue {\n out.p.x = transform.p.x;\n out.p.y = transform.p.y;\n out.q.s = transform.q.s;\n out.q.c = transform.q.c;\n return out;\n}\n\nexport function transformVec2(out: Vec2Value, xf: TransformValue, v: Vec2Value): Vec2Value {\n const x = xf.q.c * v.x - xf.q.s * v.y + xf.p.x;\n const y = xf.q.s * v.x + xf.q.c * v.y + xf.p.y;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function detransformVec2(out: Vec2Value, xf: TransformValue, v: Vec2Value): Vec2Value {\n const px = v.x - xf.p.x;\n const py = v.y - xf.p.y;\n const x = (xf.q.c * px + xf.q.s * py);\n const y = (-xf.q.s * px + xf.q.c * py);\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function retransformVec2(out: Vec2Value, from: TransformValue, to: TransformValue, v: Vec2Value): Vec2Value {\n const x0 = from.q.c * v.x - from.q.s * v.y + from.p.x;\n const y0 = from.q.s * v.x + from.q.c * v.y + from.p.y;\n const px = x0 - to.p.x;\n const py = y0 - to.p.y;\n const x = to.q.c * px + to.q.s * py;\n const y = -to.q.s * px + to.q.c * py;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function detransformTransform(out: TransformValue, a: TransformValue, b: TransformValue): TransformValue {\n const c = a.q.c * b.q.c + a.q.s * b.q.s;\n const s = a.q.c * b.q.s - a.q.s * b.q.c;\n const x = a.q.c * (b.p.x - a.p.x) + a.q.s * (b.p.y - a.p.y);\n const y = -a.q.s * (b.p.x - a.p.x) + a.q.c * (b.p.y - a.p.y);\n out.q.c = c;\n out.q.s = s;\n out.p.x = x;\n out.p.y = y;\n return out;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n/** @internal */ const math_atan2 = Math.atan2;\n\nexport interface RotValue {\n /** sin(angle) */\n s: number;\n /** cos(angle) */\n c: number;\n}\n\ndeclare module \"./Rot\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(angle: number): Rot;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(obj: RotValue): Rot;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(): Rot;\n}\n\n/** Rotation */\n// @ts-expect-error\nexport class Rot {\n /** sin(angle) */\n s: number;\n /** cos(angle) */\n c: number;\n\n /** Initialize from an angle in radians. */\n constructor(angle?: number | RotValue) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Rot)) {\n return new Rot(angle);\n }\n if (typeof angle === \"number\") {\n this.setAngle(angle);\n } else if (typeof angle === \"object\") {\n this.setRot(angle);\n } else {\n this.setIdentity();\n }\n }\n\n /** @hidden */\n static neo(angle: number): Rot {\n const obj = Object.create(Rot.prototype);\n obj.setAngle(angle);\n return obj;\n }\n\n static clone(rot: RotValue): Rot {\n if (_ASSERT) Rot.assert(rot);\n const obj = Object.create(Rot.prototype);\n obj.s = rot.s;\n obj.c = rot.c;\n return obj;\n }\n\n static identity(): Rot {\n const obj = Object.create(Rot.prototype);\n obj.s = 0.0;\n obj.c = 1.0;\n return obj;\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.s) && Number.isFinite(obj.c);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Rot.isValid(o), \"Invalid Rot!\", o);\n }\n\n /** Set to the identity rotation. */\n setIdentity(): void {\n this.s = 0.0;\n this.c = 1.0;\n }\n\n set(angle: number | RotValue): void {\n if (typeof angle === \"object\") {\n if (_ASSERT) Rot.assert(angle);\n this.s = angle.s;\n this.c = angle.c;\n\n } else {\n if (_ASSERT) console.assert(Number.isFinite(angle));\n // TODO_ERIN optimize\n this.s = math_sin(angle);\n this.c = math_cos(angle);\n }\n }\n\n setRot(angle: RotValue): void {\n if (_ASSERT) Rot.assert(angle);\n this.s = angle.s;\n this.c = angle.c;\n }\n\n /** Set using an angle in radians. */\n setAngle(angle: number): void {\n if (_ASSERT) console.assert(Number.isFinite(angle));\n // TODO_ERIN optimize\n this.s = math_sin(angle);\n this.c = math_cos(angle);\n }\n\n /** Get the angle in radians. */\n getAngle(): number {\n return math_atan2(this.s, this.c);\n }\n\n /** Get the x-axis. */\n getXAxis(): Vec2 {\n return Vec2.neo(this.c, this.s);\n }\n\n /** Get the y-axis. */\n getYAxis(): Vec2 {\n return Vec2.neo(-this.s, this.c);\n }\n\n /** Multiply two rotations: q * r */\n static mul(rot: RotValue, m: RotValue): Rot;\n /** Rotate a vector */\n static mul(rot: RotValue, m: Vec2Value): Vec2;\n static mul(rot, m) {\n if (_ASSERT) Rot.assert(rot);\n if (\"c\" in m && \"s\" in m) {\n if (_ASSERT) Rot.assert(m);\n // [qc -qs] * [rc -rs] = [qc*rc-qs*rs -qc*rs-qs*rc]\n // [qs qc] [rs rc] [qs*rc+qc*rs -qs*rs+qc*rc]\n // s = qs * rc + qc * rs\n // c = qc * rc - qs * rs\n const qr = Rot.identity();\n qr.s = rot.s * m.c + rot.c * m.s;\n qr.c = rot.c * m.c - rot.s * m.s;\n return qr;\n\n } else if (\"x\" in m && \"y\" in m) {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x - rot.s * m.y, rot.s * m.x + rot.c * m.y);\n }\n }\n\n /** Multiply two rotations: q * r */\n static mulRot(rot: RotValue, m: RotValue): Rot {\n if (_ASSERT) Rot.assert(rot);\n if (_ASSERT) Rot.assert(m);\n // [qc -qs] * [rc -rs] = [qc*rc-qs*rs -qc*rs-qs*rc]\n // [qs qc] [rs rc] [qs*rc+qc*rs -qs*rs+qc*rc]\n // s = qs * rc + qc * rs\n // c = qc * rc - qs * rs\n const qr = Rot.identity();\n qr.s = rot.s * m.c + rot.c * m.s;\n qr.c = rot.c * m.c - rot.s * m.s;\n return qr;\n }\n\n /** Rotate a vector */\n static mulVec2(rot: RotValue, m: Vec2Value): Vec2 {\n if (_ASSERT) Rot.assert(rot);\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x - rot.s * m.y, rot.s * m.x + rot.c * m.y);\n }\n\n static mulSub(rot: RotValue, v: Vec2Value, w: Vec2Value): Vec2 {\n const x = rot.c * (v.x - w.x) - rot.s * (v.y - w.y);\n const y = rot.s * (v.x - w.x) + rot.c * (v.y - w.y);\n return Vec2.neo(x, y);\n }\n\n /** Transpose multiply two rotations: qT * r */\n static mulT(rot: RotValue, m: RotValue): Rot;\n /** Inverse rotate a vector */\n static mulT(rot: RotValue, m: Vec2Value): Vec2;\n static mulT(rot, m) {\n if (\"c\" in m && \"s\" in m) {\n if (_ASSERT) Rot.assert(m);\n // [ qc qs] * [rc -rs] = [qc*rc+qs*rs -qc*rs+qs*rc]\n // [-qs qc] [rs rc] [-qs*rc+qc*rs qs*rs+qc*rc]\n // s = qc * rs - qs * rc\n // c = qc * rc + qs * rs\n const qr = Rot.identity();\n qr.s = rot.c * m.s - rot.s * m.c;\n qr.c = rot.c * m.c + rot.s * m.s;\n return qr;\n\n } else if (\"x\" in m && \"y\" in m) {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x + rot.s * m.y, -rot.s * m.x + rot.c * m.y);\n }\n }\n\n /** Transpose multiply two rotations: qT * r */\n static mulTRot(rot: RotValue, m: RotValue): Rot {\n if (_ASSERT) Rot.assert(m);\n // [ qc qs] * [rc -rs] = [qc*rc+qs*rs -qc*rs+qs*rc]\n // [-qs qc] [rs rc] [-qs*rc+qc*rs qs*rs+qc*rc]\n // s = qc * rs - qs * rc\n // c = qc * rc + qs * rs\n const qr = Rot.identity();\n qr.s = rot.c * m.s - rot.s * m.c;\n qr.c = rot.c * m.c + rot.s * m.s;\n return qr;\n }\n\n /** Inverse rotate a vector */\n static mulTVec2(rot: RotValue, m: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x + rot.s * m.y, -rot.s * m.x + rot.c * m.y);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"./Matrix\";\nimport { mod } from \"./Math\";\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { TransformValue } from \"./Transform\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_atan2 = Math.atan2;\n/** @internal */ const math_PI = Math.PI;\n\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n\n/**\n * This describes the motion of a body/shape for TOI computation. Shapes are\n * defined with respect to the body origin, which may not coincide with the\n * center of mass. However, to support dynamics we must interpolate the center\n * of mass position.\n */\nexport class Sweep {\n /** Local center of mass position */\n localCenter = Vec2.zero();\n\n /** World center position */\n c = Vec2.zero();\n\n /** World angle */\n a = 0;\n\n /** Fraction of the current time step in the range [0,1], c0 and a0 are c and a at alpha0. */\n alpha0 = 0;\n\n c0 = Vec2.zero();\n a0 = 0;\n\n /** @internal */\n recycle() {\n matrix.zeroVec2(this.localCenter);\n matrix.zeroVec2(this.c);\n this.a = 0;\n this.alpha0 = 0;\n matrix.zeroVec2(this.c0);\n this.a0 = 0;\n }\n\n setTransform(xf: TransformValue): void {\n matrix.transformVec2(temp, xf, this.localCenter);\n matrix.copyVec2(this.c, temp);\n matrix.copyVec2(this.c0, temp);\n\n this.a = this.a0 = math_atan2(xf.q.s, xf.q.c);\n }\n\n setLocalCenter(localCenter: Vec2Value, xf: TransformValue): void {\n matrix.copyVec2(this.localCenter, localCenter);\n\n matrix.transformVec2(temp, xf, this.localCenter);\n matrix.copyVec2(this.c, temp);\n matrix.copyVec2(this.c0, temp);\n }\n\n /**\n * Get the interpolated transform at a specific time.\n *\n * @param xf\n * @param beta A factor in [0,1], where 0 indicates alpha0\n */\n getTransform(xf: TransformValue, beta: number = 0): void {\n matrix.setRotAngle(xf.q, (1.0 - beta) * this.a0 + beta * this.a);\n matrix.combine2Vec2(xf.p, (1.0 - beta), this.c0, beta, this.c);\n\n // shift to origin\n matrix.minusVec2(xf.p, matrix.rotVec2(temp, xf.q, this.localCenter));\n }\n\n /**\n * Advance the sweep forward, yielding a new initial state.\n *\n * @param alpha The new initial time\n */\n advance(alpha: number): void {\n if (_ASSERT) console.assert(this.alpha0 < 1.0);\n const beta = (alpha - this.alpha0) / (1.0 - this.alpha0);\n matrix.combine2Vec2(this.c0, beta, this.c, 1 - beta, this.c0);\n this.a0 = beta * this.a + (1 - beta) * this.a0;\n this.alpha0 = alpha;\n }\n\n forward(): void {\n this.a0 = this.a;\n matrix.copyVec2(this.c0, this.c);\n }\n\n /**\n * normalize the angles in radians to be between -pi and pi.\n */\n normalize(): void {\n const a0 = mod(this.a0, -math_PI, +math_PI);\n this.a -= this.a0 - a0;\n this.a0 = a0;\n }\n\n set(that: Sweep): void {\n matrix.copyVec2(this.localCenter, that.localCenter);\n matrix.copyVec2(this.c, that.c);\n this.a = that.a;\n this.alpha0 = that.alpha0;\n matrix.copyVec2(this.c0, that.c0);\n this.a0 = that.a0;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { Rot, RotValue } from \"./Rot\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\nexport type TransformValue = {\n p: Vec2Value;\n q: RotValue;\n};\n\ndeclare module \"./Transform\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Transform(position?: Vec2Value, rotation?: number): Transform;\n}\n\n/**\n * A transform contains translation and rotation. It is used to represent the\n * position and orientation of rigid frames. Initialize using a position vector\n * and a rotation.\n */\n// @ts-expect-error\nexport class Transform {\n /** position */\n p: Vec2;\n\n /** rotation */\n q: Rot;\n\n constructor(position?: Vec2Value, rotation?: number) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Transform)) {\n return new Transform(position, rotation);\n }\n this.p = Vec2.zero();\n this.q = Rot.identity();\n if (typeof position !== \"undefined\") {\n this.p.setVec2(position);\n }\n if (typeof rotation !== \"undefined\") {\n this.q.setAngle(rotation);\n }\n }\n\n static clone(xf: Transform): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.clone(xf.p);\n obj.q = Rot.clone(xf.q);\n return obj;\n }\n\n /** @hidden */\n static neo(position: Vec2Value, rotation: Rot): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.clone(position);\n obj.q = Rot.clone(rotation);\n return obj;\n }\n\n static identity(): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.zero();\n obj.q = Rot.identity();\n return obj;\n }\n\n /** Set this to the identity transform */\n setIdentity(): void {\n this.p.setZero();\n this.q.setIdentity();\n }\n\n /** Set position and angle */\n set(position: Vec2Value, rotation: number): void;\n /** Copy from another transform */\n set(xf: TransformValue): void;\n set(a: any, b?: any) {\n if (typeof b === \"undefined\") {\n this.p.set(a.p);\n this.q.set(a.q);\n } else {\n this.p.set(a);\n this.q.set(b);\n }\n }\n\n /** Set position and angle */\n setNum(position: Vec2Value, rotation: number) {\n this.p.setVec2(position);\n this.q.setAngle(rotation);\n }\n\n setTransform(xf: TransformValue): void {\n this.p.setVec2(xf.p);\n this.q.setRot(xf.q);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.p) && Rot.isValid(obj.q);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Transform.isValid(o), \"Invalid Transform!\", o);\n }\n\n static mul(a: TransformValue, b: Vec2Value): Vec2;\n static mul(a: TransformValue, b: TransformValue): Transform;\n // static mul(a: Transform, b: Vec2Value[]): Vec2[];\n // static mul(a: Transform, b: Transform[]): Transform[];\n static mul(a, b) {\n if (Array.isArray(b)) {\n // todo: this was used in examples, remove in the future\n if (_ASSERT) Transform.assert(a);\n const arr = [];\n for (let i = 0; i < b.length; i++) {\n arr[i] = Transform.mul(a, b[i]);\n }\n return arr;\n\n } else if (\"x\" in b && \"y\" in b) {\n return Transform.mulVec2(a, b);\n\n } else if (\"p\" in b && \"q\" in b) {\n return Transform.mulXf(a, b);\n }\n }\n\n static mulAll(a: Transform, b: Vec2Value[]): Vec2[];\n static mulAll(a: Transform, b: Transform[]): Transform[];\n static mulAll(a: TransformValue, b) {\n if (_ASSERT) Transform.assert(a);\n const arr = [];\n for (let i = 0; i < b.length; i++) {\n arr[i] = Transform.mul(a, b[i]);\n }\n return arr;\n }\n\n /** @hidden @deprecated */\n static mulFn(a: TransformValue) {\n // todo: this was used in examples, remove in the future\n if (_ASSERT) Transform.assert(a);\n return function(b: Vec2Value): Vec2 {\n return Transform.mul(a, b);\n };\n }\n\n static mulVec2(a: TransformValue, b: Vec2Value): Vec2 {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const x = (a.q.c * b.x - a.q.s * b.y) + a.p.x;\n const y = (a.q.s * b.x + a.q.c * b.y) + a.p.y;\n return Vec2.neo(x, y);\n }\n\n static mulXf(a: TransformValue, b: TransformValue): Transform {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Transform.assert(b);\n // v2 = A.q.Rot(B.q.Rot(v1) + B.p) + A.p\n // = (A.q * B.q).Rot(v1) + A.q.Rot(B.p) + A.p\n const xf = Transform.identity();\n xf.q = Rot.mulRot(a.q, b.q);\n xf.p = Vec2.add(Rot.mulVec2(a.q, b.p), a.p);\n return xf;\n }\n\n static mulT(a: TransformValue, b: Vec2Value): Vec2;\n static mulT(a: TransformValue, b: TransformValue): Transform;\n static mulT(a, b) {\n if (\"x\" in b && \"y\" in b) {\n return Transform.mulTVec2(a, b);\n\n } else if (\"p\" in b && \"q\" in b) {\n return Transform.mulTXf(a, b);\n }\n }\n\n static mulTVec2(a: TransformValue, b: Vec2Value): Vec2 {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const px = b.x - a.p.x;\n const py = b.y - a.p.y;\n const x = (a.q.c * px + a.q.s * py);\n const y = (-a.q.s * px + a.q.c * py);\n return Vec2.neo(x, y);\n }\n\n static mulTXf(a: TransformValue, b: TransformValue): Transform {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Transform.assert(b);\n // v2 = A.q' * (B.q * v1 + B.p - A.p)\n // = A.q' * B.q * v1 + A.q' * (B.p - A.p)\n const xf = Transform.identity();\n xf.q.setRot(Rot.mulTRot(a.q, b.q));\n xf.p.setVec2(Rot.mulTVec2(a.q, Vec2.sub(b.p, a.p)));\n return xf;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2 } from \"../common/Vec2\";\n\nexport class Velocity {\n /** linear */\n v = Vec2.zero();\n\n /** angular */\n w = 0;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { TransformValue } from \"../common/Transform\";\n\n\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n\n\nexport class Position {\n /** location */\n c = Vec2.zero();\n\n /** angle */\n a = 0;\n\n // todo: cache sin/cos\n getTransform(xf: TransformValue, p: Vec2Value): TransformValue {\n // xf.q = rotation(this.a);\n // xf.p = this.c - xf.q * p\n xf.q.c = math_cos(this.a);\n xf.q.s = math_sin(this.a);\n xf.p.x = this.c.x - (xf.q.c * p.x - xf.q.s * p.y);\n xf.p.y = this.c.y - (xf.q.s * p.x + xf.q.c * p.y);\n return xf;\n }\n}\n\nexport function getTransform(xf: TransformValue, p: Vec2Value, c: Vec2Value, a: number): TransformValue {\n // xf.q = rotation(a);\n // xf.p = this.c - xf.q * p\n xf.q.c = math_cos(a);\n xf.q.s = math_sin(a);\n xf.p.x = c.x - (xf.q.c * p.x - xf.q.s * p.y);\n xf.p.y = c.y - (xf.q.s * p.x + xf.q.c * p.y);\n return xf;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { MassData } from \"../dynamics/Body\";\nimport { RayCastOutput, RayCastInput, AABBValue } from \"./AABB\";\nimport { DistanceProxy } from \"./Distance\";\nimport type { Transform, TransformValue } from \"../common/Transform\";\nimport type { Vec2Value } from \"../common/Vec2\";\nimport { Style } from \"../util/Testbed\";\n\n// todo make shape an interface\n\n/**\n * A shape is used for collision detection. You can create a shape however you\n * like. Shapes used for simulation in World are created automatically when a\n * Fixture is created. Shapes may encapsulate one or more child shapes.\n */\nexport abstract class Shape {\n /** @hidden */ m_type: ShapeType;\n\n /**\n * @hidden\n * Radius of a shape. For polygonal shapes this must be b2_polygonRadius.\n * There is no support for making rounded polygons.\n */\n m_radius: number;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n /** @hidden */\n abstract _reset(): void;\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return typeof obj.m_type === \"string\" && typeof obj.m_radius === \"number\";\n }\n\n abstract getRadius(): number;\n\n /**\n * Get the type of this shape. You can use this to down cast to the concrete\n * shape.\n *\n * @return the shape type.\n */\n abstract getType(): ShapeType;\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n abstract _clone(): Shape;\n\n /**\n * Get the number of child primitives.\n */\n abstract getChildCount(): number;\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n abstract testPoint(xf: TransformValue, p: Vec2Value): boolean;\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n abstract rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean;\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n abstract computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void;\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n abstract computeMass(massData: MassData, density?: number): void;\n\n abstract computeDistanceProxy(proxy: DistanceProxy, childIndex: number): void;\n\n}\n\nexport type ShapeType = \"circle\" | \"edge\" | \"polygon\" | \"chain\";\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { options } from \"../util/options\";\nimport { Vec2Value } from \"../common/Vec2\";\nimport { AABB, RayCastInput, RayCastOutput } from \"../collision/AABB\";\nimport { Shape, ShapeType } from \"../collision/Shape\";\nimport { Body, MassData } from \"./Body\";\nimport { BroadPhase } from \"../collision/BroadPhase\";\nimport { TransformValue } from \"../common/Transform\";\nimport { Style } from \"../util/Testbed\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/** @internal */ const synchronize_aabb1 = new AABB();\n/** @internal */ const synchronize_aabb2 = new AABB();\n/** @internal */ const displacement = matrix.vec2(0, 0);\n\n/**\n * A fixture definition is used to create a fixture. This class defines an\n * abstract fixture definition. You can reuse fixture definitions safely.\n */\nexport interface FixtureOpt {\n userData?: unknown;\n /**\n * The friction coefficient, usually in the range [0,1]\n */\n friction?: number;\n /**\n * The restitution (elasticity) usually in the range [0,1]\n */\n restitution?: number;\n /**\n * The density, usually in kg/m^2\n */\n density?: number;\n /**\n * A sensor shape collects contact information but never generates a collision response.\n */\n isSensor?: boolean;\n /**\n * Zero, positive or negative collision group.\n * Fixtures with same positive groupIndex always collide and fixtures with same negative groupIndex never collide.\n */\n filterGroupIndex?: number;\n /**\n * Collision category bit or bits that this fixture belongs to.\n * If groupIndex is zero or not matching, then at least one bit in this fixture categoryBits should match other fixture maskBits and vice versa.\n */\n filterCategoryBits?: number;\n /**\n * Collision category bit or bits that this fixture accept for collision.\n */\n filterMaskBits?: number;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\nexport interface FixtureDef extends FixtureOpt {\n shape: Shape;\n}\n\n/** @internal */ const FixtureDefDefault: FixtureOpt = {\n userData : null,\n friction : 0.2,\n restitution : 0.0,\n density : 0.0,\n isSensor : false,\n\n filterGroupIndex : 0,\n filterCategoryBits : 0x0001,\n filterMaskBits : 0xFFFF\n};\n\n/**\n * This proxy is used internally to connect shape children to the broad-phase.\n */\nexport class FixtureProxy {\n aabb: AABB;\n fixture: Fixture;\n childIndex: number;\n proxyId: number;\n constructor(fixture: Fixture, childIndex: number) {\n this.aabb = new AABB();\n this.fixture = fixture;\n this.childIndex = childIndex;\n // this.proxyId;\n }\n}\n\n/**\n * A fixture is used to attach a shape to a body for collision detection. A\n * fixture inherits its transform from its parent. Fixtures hold additional\n * non-geometric data such as friction, collision filters, etc.\n *\n * To create a new Fixture use {@link Body.createFixture}.\n */\nexport class Fixture {\n /** @internal */ m_body: Body;\n /** @internal */ m_friction: number;\n /** @internal */ m_restitution: number;\n /** @internal */ m_density: number;\n /** @internal */ m_isSensor: boolean;\n /** @internal */ m_filterGroupIndex: number;\n /** @internal */ m_filterCategoryBits: number;\n /** @internal */ m_filterMaskBits: number;\n /** @internal */ m_shape: Shape;\n /** @internal */ m_next: Fixture | null;\n /** @internal */ m_proxies: FixtureProxy[];\n // 0 indicates inactive state, this is not the same as m_proxies.length\n /** @internal */ m_proxyCount: number;\n /** @internal */ m_userData: unknown;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n constructor(body: Body, def: FixtureDef);\n constructor(body: Body, shape: Shape, def?: FixtureOpt);\n constructor(body: Body, shape: Shape, density?: number);\n /** @internal */\n constructor(body: Body, shape?, def?) {\n if (shape.shape) {\n def = shape;\n shape = shape.shape;\n\n } else if (typeof def === \"number\") {\n def = {density : def};\n }\n\n def = options(def, FixtureDefDefault);\n\n this.m_body = body;\n\n this.m_friction = def.friction;\n this.m_restitution = def.restitution;\n this.m_density = def.density;\n this.m_isSensor = def.isSensor;\n\n this.m_filterGroupIndex = def.filterGroupIndex;\n this.m_filterCategoryBits = def.filterCategoryBits;\n this.m_filterMaskBits = def.filterMaskBits;\n\n // TODO validate shape\n this.m_shape = shape; // .clone();\n\n this.m_next = null;\n\n this.m_proxies = [];\n this.m_proxyCount = 0;\n\n // fixture proxies are created here,\n // but they are activate in when a fixture is added to body\n const childCount = this.m_shape.getChildCount();\n for (let i = 0; i < childCount; ++i) {\n this.m_proxies[i] = new FixtureProxy(this, i);\n }\n\n this.m_userData = def.userData;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /** @hidden Re-setup fixture. */\n _reset(): void {\n const body = this.getBody();\n const broadPhase = body.m_world.m_broadPhase;\n this.destroyProxies(broadPhase);\n if (this.m_shape._reset) {\n this.m_shape._reset();\n }\n const childCount = this.m_shape.getChildCount();\n for (let i = 0; i < childCount; ++i) {\n this.m_proxies[i] = new FixtureProxy(this, i);\n }\n this.createProxies(broadPhase, body.m_xf);\n body.resetMassData();\n }\n\n /** @internal */\n _serialize(): object {\n return {\n friction: this.m_friction,\n restitution: this.m_restitution,\n density: this.m_density,\n isSensor: this.m_isSensor,\n\n filterGroupIndex: this.m_filterGroupIndex,\n filterCategoryBits: this.m_filterCategoryBits,\n filterMaskBits: this.m_filterMaskBits,\n\n shape: this.m_shape,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, body: any, restore: any): Fixture {\n const shape = restore(Shape, data.shape);\n const fixture = shape && new Fixture(body, shape, data);\n return fixture;\n }\n\n /**\n * Get the type of the child shape. You can use this to down cast to the\n * concrete shape.\n */\n getType(): ShapeType {\n return this.m_shape.m_type;\n }\n\n /**\n * Get the child shape. You can modify the child shape, however you should not\n * change the number of vertices because this will crash some collision caching\n * mechanisms. Manipulating the shape may lead to non-physical behavior.\n */\n getShape(): Shape {\n return this.m_shape;\n }\n\n /**\n * A sensor shape collects contact information but never generates a collision\n * response.\n */\n isSensor(): boolean {\n return this.m_isSensor;\n }\n\n /**\n * Set if this fixture is a sensor.\n */\n setSensor(sensor: boolean): void {\n if (sensor != this.m_isSensor) {\n this.m_body.setAwake(true);\n this.m_isSensor = sensor;\n }\n }\n\n // /**\n // * Get the contact filtering data.\n // */\n // getFilterData() {\n // return this.m_filter;\n // }\n\n /**\n * Get the user data that was assigned in the fixture definition. Use this to\n * store your application specific data.\n */\n getUserData(): unknown {\n return this.m_userData;\n }\n\n /**\n * Set the user data. Use this to store your application specific data.\n */\n setUserData(data: unknown): void {\n this.m_userData = data;\n }\n\n /**\n * Get the parent body of this fixture. This is null if the fixture is not\n * attached.\n */\n getBody(): Body {\n return this.m_body;\n }\n\n /**\n * Get the next fixture in the parent body's fixture list.\n */\n getNext(): Fixture | null {\n return this.m_next;\n }\n\n /**\n * Get the density of this fixture.\n */\n getDensity(): number {\n return this.m_density;\n }\n\n /**\n * Set the density of this fixture. This will _not_ automatically adjust the\n * mass of the body. You must call Body.resetMassData to update the body's mass.\n */\n setDensity(density: number): void {\n if (_ASSERT) console.assert(Number.isFinite(density) && density >= 0.0);\n this.m_density = density;\n }\n\n /**\n * Get the coefficient of friction, usually in the range [0,1].\n */\n getFriction(): number {\n return this.m_friction;\n }\n\n /**\n * Set the coefficient of friction. This will not change the friction of\n * existing contacts.\n */\n setFriction(friction: number): void {\n this.m_friction = friction;\n }\n\n /**\n * Get the coefficient of restitution.\n */\n getRestitution(): number {\n return this.m_restitution;\n }\n\n /**\n * Set the coefficient of restitution. This will not change the restitution of\n * existing contacts.\n */\n setRestitution(restitution: number): void {\n this.m_restitution = restitution;\n }\n\n /**\n * Test a point in world coordinates for containment in this fixture.\n */\n testPoint(p: Vec2Value): boolean {\n return this.m_shape.testPoint(this.m_body.getTransform(), p);\n }\n\n /**\n * Cast a ray against this shape.\n */\n rayCast(output: RayCastOutput, input: RayCastInput, childIndex: number): boolean {\n return this.m_shape.rayCast(output, input, this.m_body.getTransform(), childIndex);\n }\n\n /**\n * Get the mass data for this fixture. The mass data is based on the density and\n * the shape. The rotational inertia is about the shape's origin. This operation\n * may be expensive.\n */\n getMassData(massData: MassData): void {\n this.m_shape.computeMass(massData, this.m_density);\n }\n\n /**\n * Get the fixture's AABB. This AABB may be enlarge and/or stale. If you need a\n * more accurate AABB, compute it using the shape and the body transform.\n */\n getAABB(childIndex: number): AABB {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_proxies.length);\n return this.m_proxies[childIndex].aabb;\n }\n\n /**\n * These support body activation/deactivation.\n */\n createProxies(broadPhase: BroadPhase, xf: TransformValue): void {\n if (_ASSERT) console.assert(this.m_proxyCount == 0);\n\n // Create proxies in the broad-phase.\n this.m_proxyCount = this.m_shape.getChildCount();\n\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n this.m_shape.computeAABB(proxy.aabb, xf, i);\n proxy.proxyId = broadPhase.createProxy(proxy.aabb, proxy);\n }\n }\n\n destroyProxies(broadPhase: BroadPhase): void {\n // Destroy proxies in the broad-phase.\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n broadPhase.destroyProxy(proxy.proxyId);\n proxy.proxyId = null;\n }\n\n this.m_proxyCount = 0;\n }\n\n /**\n * Updates this fixture proxy in broad-phase (with combined AABB of current and\n * next transformation).\n */\n synchronize(broadPhase: BroadPhase, xf1: TransformValue, xf2: TransformValue): void {\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n // Compute an AABB that covers the swept shape (may miss some rotation\n // effect).\n this.m_shape.computeAABB(synchronize_aabb1, xf1, proxy.childIndex);\n this.m_shape.computeAABB(synchronize_aabb2, xf2, proxy.childIndex);\n\n proxy.aabb.combine(synchronize_aabb1, synchronize_aabb2);\n\n matrix.subVec2(displacement, xf2.p, xf1.p);\n\n broadPhase.moveProxy(proxy.proxyId, proxy.aabb, displacement);\n }\n }\n\n /**\n * Set the contact filtering data. This will not update contacts until the next\n * time step when either parent body is active and awake. This automatically\n * calls refilter.\n */\n setFilterData(filter: { groupIndex: number, categoryBits: number, maskBits: number }): void {\n this.m_filterGroupIndex = filter.groupIndex;\n this.m_filterCategoryBits = filter.categoryBits;\n this.m_filterMaskBits = filter.maskBits;\n this.refilter();\n }\n\n getFilterGroupIndex(): number {\n return this.m_filterGroupIndex;\n }\n\n setFilterGroupIndex(groupIndex: number): void {\n this.m_filterGroupIndex = groupIndex;\n this.refilter();\n }\n\n getFilterCategoryBits(): number {\n return this.m_filterCategoryBits;\n }\n\n setFilterCategoryBits(categoryBits: number): void {\n this.m_filterCategoryBits = categoryBits;\n this.refilter();\n }\n\n getFilterMaskBits(): number {\n return this.m_filterMaskBits;\n }\n\n setFilterMaskBits(maskBits: number): void {\n this.m_filterMaskBits = maskBits;\n this.refilter();\n }\n\n /**\n * Call this if you want to establish collision that was previously disabled by\n * ContactFilter.\n */\n refilter(): void {\n if (this.m_body == null) {\n return;\n }\n\n // Flag associated contacts for filtering.\n let edge = this.m_body.getContactList();\n while (edge) {\n const contact = edge.contact;\n const fixtureA = contact.getFixtureA();\n const fixtureB = contact.getFixtureB();\n if (fixtureA == this || fixtureB == this) {\n contact.flagForFiltering();\n }\n\n edge = edge.next;\n }\n\n const world = this.m_body.getWorld();\n\n if (world == null) {\n return;\n }\n\n // Touch each proxy so that new pairs may be created\n const broadPhase = world.m_broadPhase;\n for (let i = 0; i < this.m_proxyCount; ++i) {\n broadPhase.touchProxy(this.m_proxies[i].proxyId);\n }\n }\n\n /**\n * Implement this method to provide collision filtering, if you want finer\n * control over contact creation.\n *\n * Return true if contact calculations should be performed between these two\n * fixtures.\n *\n * Warning: for performance reasons this is only called when the AABBs begin to\n * overlap.\n */\n shouldCollide(that: Fixture): boolean {\n\n if (that.m_filterGroupIndex === this.m_filterGroupIndex && that.m_filterGroupIndex !== 0) {\n return that.m_filterGroupIndex > 0;\n }\n\n const collideA = (that.m_filterMaskBits & this.m_filterCategoryBits) !== 0;\n const collideB = (that.m_filterCategoryBits & this.m_filterMaskBits) !== 0;\n const collide = collideA && collideB;\n return collide;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { options } from \"../util/options\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { Rot } from \"../common/Rot\";\nimport { Sweep } from \"../common/Sweep\";\nimport { Transform, TransformValue } from \"../common/Transform\";\nimport { Velocity } from \"./Velocity\";\nimport { Position } from \"./Position\";\nimport { Fixture, FixtureDef, FixtureOpt } from \"./Fixture\";\nimport { Shape } from \"../collision/Shape\";\nimport { JointEdge } from \"./Joint\";\nimport { World } from \"./World\";\nimport { ContactEdge } from \"./Contact\";\nimport { Style } from \"../util/Testbed\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A static body does not move under simulation and behaves as if it has infinite mass.\n * Internally, zero is stored for the mass and the inverse mass.\n * Static bodies can be moved manually by the user.\n * A static body has zero velocity.\n * Static bodies do not collide with other static or kinematic bodies.\n * \n * A kinematic body moves under simulation according to its velocity.\n * Kinematic bodies do not respond to forces.\n * They can be moved manually by the user, but normally a kinematic body is moved by setting its velocity.\n * A kinematic body behaves as if it has infinite mass, however, zero is stored for the mass and the inverse mass.\n * Kinematic bodies do not collide with other kinematic or static bodies.\n * \n * A dynamic body is fully simulated.\n * They can be moved manually by the user, but normally they move according to forces.\n * A dynamic body can collide with all body types.\n * A dynamic body always has finite, non-zero mass.\n * If you try to set the mass of a dynamic body to zero, it will automatically acquire a mass of one kilogram and it won't rotate.\n */\nexport type BodyType = \"static\" | \"kinematic\" | \"dynamic\";\n\n/** @internal */ const STATIC = \"static\";\n/** @internal */ const KINEMATIC = \"kinematic\";\n/** @internal */ const DYNAMIC = \"dynamic\";\n\n/** @internal */ const oldCenter = matrix.vec2(0, 0);\n/** @internal */ const localCenter = matrix.vec2(0, 0);\n/** @internal */ const shift = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n\nexport interface BodyDef {\n /**\n * Body types are static, kinematic, or dynamic. Note: if a dynamic\n * body would have zero mass, the mass is set to one.\n */\n type?: BodyType;\n /**\n * The world position of the body. Avoid creating bodies at the\n * origin since this can lead to many overlapping shapes.\n */\n position?: Vec2Value;\n /**\n * The world angle of the body in radians.\n */\n angle?: number;\n /**\n * The linear velocity of the body's origin in world co-ordinates.\n */\n linearVelocity?: Vec2Value;\n angularVelocity?: number;\n /**\n * Linear damping is use to reduce the linear velocity. The\n * damping parameter can be larger than 1.0 but the damping effect becomes\n * sensitive to the time step when the damping parameter is large.\n * Units are 1/time\n */\n linearDamping?: number;\n /**\n * Angular damping is use to reduce the angular velocity.\n * The damping parameter can be larger than 1.0 but the damping effect\n * becomes sensitive to the time step when the damping parameter is large.\n * Units are 1/time\n */\n angularDamping?: number;\n /**\n * Should this body be prevented from rotating? Useful for characters.\n */\n fixedRotation?: boolean;\n /**\n * Is this a fast moving body that should be prevented from\n * tunneling through other moving bodies? Note that all bodies are\n * prevented from tunneling through kinematic and static bodies. This\n * setting is only considered on dynamic bodies. Warning: You should use\n * this flag sparingly since it increases processing time.\n */\n bullet?: boolean;\n gravityScale?: number;\n /**\n * Set this flag to false if this body should never fall asleep. Note that this increases CPU usage.\n */\n allowSleep?: boolean;\n /**\n * Is this body initially awake or sleeping?\n */\n awake?: boolean;\n /**\n * Does this body start out active?\n */\n active?: boolean;\n userData?: any;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\n/** @internal */ const BodyDefDefault: BodyDef = {\n type : STATIC,\n position : Vec2.zero(),\n angle : 0.0,\n\n linearVelocity : Vec2.zero(),\n angularVelocity : 0.0,\n\n linearDamping : 0.0,\n angularDamping : 0.0,\n\n fixedRotation : false,\n bullet : false,\n gravityScale : 1.0,\n\n allowSleep : true,\n awake : true,\n active : true,\n\n userData : null\n};\n\n/**\n * MassData This holds the mass data computed for a shape.\n */\nexport interface MassData {\n /** The mass of the shape, usually in kilograms. */\n mass: number;\n /** The position of the shape's centroid relative to the shape's origin. */\n center: Vec2Value;\n /** The rotational inertia of the shape about the local origin. */\n I: number;\n}\n\n/**\n * A rigid body composed of one or more fixtures.\n *\n * To create a new Body use {@link World.createBody}.\n */\nexport class Body {\n /** @hidden */\n static readonly STATIC: BodyType = \"static\";\n /** @hidden */\n static readonly KINEMATIC: BodyType = \"kinematic\";\n /** @hidden */\n static readonly DYNAMIC: BodyType = \"dynamic\";\n\n /** @internal */ m_world: World;\n /** @internal */ m_awakeFlag: boolean;\n /** @internal */ m_autoSleepFlag: boolean;\n /** @internal */ m_bulletFlag: boolean;\n /** @internal */ m_fixedRotationFlag: boolean;\n /** @internal */ m_activeFlag: boolean;\n /** @internal */ m_islandFlag: boolean;\n /** @internal */ m_toiFlag: boolean;\n /** @internal */ m_userData: unknown;\n /** @internal */ m_type: BodyType;\n /** @internal */ m_mass: number;\n /** @internal */ m_invMass: number;\n /** @internal Rotational inertia about the center of mass. */\n m_I: number;\n /** @internal */ m_invI: number;\n /** @internal the body origin transform */\n m_xf: Transform;\n /** @internal the swept motion for CCD */\n m_sweep: Sweep;\n // position and velocity correction\n /** @internal */ c_velocity: Velocity;\n /** @internal */ c_position: Position;\n /** @internal */ m_force: Vec2;\n /** @internal */ m_torque: number;\n /** @internal */ m_linearVelocity: Vec2;\n /** @internal */ m_angularVelocity: number;\n /** @internal */ m_linearDamping: number;\n /** @internal */ m_angularDamping: number;\n /** @internal */ m_gravityScale: number;\n /** @internal */ m_sleepTime: number;\n /** @internal */ m_jointList: JointEdge | null;\n /** @internal */ m_contactList: ContactEdge | null;\n /** @internal */ m_fixtureList: Fixture | null;\n /** @internal */ m_prev: Body | null;\n /** @internal */ m_next: Body | null;\n /** @internal */ m_destroyed: boolean;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n /** @internal */\n constructor(world: World, def: BodyDef) {\n def = options(def, BodyDefDefault);\n\n if (_ASSERT) console.assert(Vec2.isValid(def.position));\n if (_ASSERT) console.assert(Vec2.isValid(def.linearVelocity));\n if (_ASSERT) console.assert(Number.isFinite(def.angle));\n if (_ASSERT) console.assert(Number.isFinite(def.angularVelocity));\n if (_ASSERT) console.assert(Number.isFinite(def.angularDamping) && def.angularDamping >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.linearDamping) && def.linearDamping >= 0.0);\n\n this.m_world = world;\n\n this.m_awakeFlag = def.awake;\n this.m_autoSleepFlag = def.allowSleep;\n this.m_bulletFlag = def.bullet;\n this.m_fixedRotationFlag = def.fixedRotation;\n this.m_activeFlag = def.active;\n\n this.m_islandFlag = false;\n this.m_toiFlag = false;\n\n this.m_userData = def.userData;\n this.m_type = def.type;\n\n if (this.m_type == DYNAMIC) {\n this.m_mass = 1.0;\n this.m_invMass = 1.0;\n } else {\n this.m_mass = 0.0;\n this.m_invMass = 0.0;\n }\n\n // Rotational inertia about the center of mass.\n this.m_I = 0.0;\n this.m_invI = 0.0;\n\n // the body origin transform\n this.m_xf = Transform.identity();\n this.m_xf.p.setVec2(def.position);\n this.m_xf.q.setAngle(def.angle);\n\n // the swept motion for CCD\n this.m_sweep = new Sweep();\n this.m_sweep.setTransform(this.m_xf);\n\n // position and velocity correction\n this.c_velocity = new Velocity();\n this.c_position = new Position();\n\n this.m_force = Vec2.zero();\n this.m_torque = 0.0;\n\n this.m_linearVelocity = Vec2.clone(def.linearVelocity);\n this.m_angularVelocity = def.angularVelocity;\n\n this.m_linearDamping = def.linearDamping;\n this.m_angularDamping = def.angularDamping;\n this.m_gravityScale = def.gravityScale;\n\n this.m_sleepTime = 0.0;\n\n this.m_jointList = null;\n this.m_contactList = null;\n this.m_fixtureList = null;\n\n this.m_prev = null;\n this.m_next = null;\n\n this.m_destroyed = false;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /** @internal */\n _serialize(): object {\n const fixtures = [];\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n fixtures.push(f);\n }\n return {\n type: this.m_type,\n bullet: this.m_bulletFlag,\n position: this.m_xf.p,\n angle: this.m_xf.q.getAngle(),\n linearVelocity: this.m_linearVelocity,\n angularVelocity: this.m_angularVelocity,\n fixtures,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): Body {\n const body = new Body(world, data);\n\n if (data.fixtures) {\n for (let i = data.fixtures.length - 1; i >= 0; i--) {\n const fixture = restore(Fixture, data.fixtures[i], body);\n body._addFixture(fixture);\n }\n }\n return body;\n }\n\n isWorldLocked(): boolean {\n return this.m_world && this.m_world.isLocked() ? true : false;\n }\n\n getWorld(): World {\n return this.m_world;\n }\n\n getNext(): Body | null {\n return this.m_next;\n }\n\n setUserData(data: any): void {\n this.m_userData = data;\n }\n\n getUserData(): unknown {\n return this.m_userData;\n }\n\n getFixtureList(): Fixture | null {\n return this.m_fixtureList;\n }\n\n getJointList(): JointEdge | null {\n return this.m_jointList;\n }\n\n /**\n * Warning: this list changes during the time step and you may miss some\n * collisions if you don't use ContactListener.\n */\n getContactList(): ContactEdge | null {\n return this.m_contactList;\n }\n\n isStatic(): boolean {\n return this.m_type == STATIC;\n }\n\n isDynamic(): boolean {\n return this.m_type == DYNAMIC;\n }\n\n isKinematic(): boolean {\n return this.m_type == KINEMATIC;\n }\n\n /**\n * This will alter the mass and velocity.\n */\n setStatic(): Body {\n this.setType(STATIC);\n return this;\n }\n\n setDynamic(): Body {\n this.setType(DYNAMIC);\n return this;\n }\n\n setKinematic(): Body {\n this.setType(KINEMATIC);\n return this;\n }\n\n /**\n * Get the type of the body.\n */\n getType(): BodyType {\n return this.m_type;\n }\n\n /**\n * Set the type of the body to \"static\", \"kinematic\" or \"dynamic\".\n * @param type The type of the body.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n setType(type: BodyType): void {\n if (_ASSERT) console.assert(type === STATIC || type === KINEMATIC || type === DYNAMIC);\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (this.m_type == type) {\n return;\n }\n\n this.m_type = type;\n\n this.resetMassData();\n\n if (this.m_type == STATIC) {\n this.m_linearVelocity.setZero();\n this.m_angularVelocity = 0.0;\n this.m_sweep.forward();\n this.synchronizeFixtures();\n }\n\n this.setAwake(true);\n\n this.m_force.setZero();\n this.m_torque = 0.0;\n\n // Delete the attached contacts.\n let ce = this.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n this.m_world.destroyContact(ce0.contact);\n }\n this.m_contactList = null;\n\n // Touch the proxies so that new contacts will be created (when appropriate)\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n for (let i = 0; i < f.m_proxyCount; ++i) {\n broadPhase.touchProxy(f.m_proxies[i].proxyId);\n }\n }\n }\n\n isBullet(): boolean {\n return this.m_bulletFlag;\n }\n\n /**\n * Should this body be treated like a bullet for continuous collision detection?\n */\n setBullet(flag: boolean): void {\n this.m_bulletFlag = !!flag;\n }\n\n isSleepingAllowed(): boolean {\n return this.m_autoSleepFlag;\n }\n\n setSleepingAllowed(flag: boolean): void {\n this.m_autoSleepFlag = !!flag;\n if (this.m_autoSleepFlag == false) {\n this.setAwake(true);\n }\n }\n\n isAwake(): boolean {\n return this.m_awakeFlag;\n }\n\n /**\n * Set the sleep state of the body. A sleeping body has very low CPU cost.\n *\n * @param flag Set to true to wake the body, false to put it to sleep.\n */\n setAwake(flag: boolean): void {\n if (flag) {\n this.m_awakeFlag = true;\n this.m_sleepTime = 0.0;\n } else {\n this.m_awakeFlag = false;\n this.m_sleepTime = 0.0;\n this.m_linearVelocity.setZero();\n this.m_angularVelocity = 0.0;\n this.m_force.setZero();\n this.m_torque = 0.0;\n }\n }\n\n isActive(): boolean {\n return this.m_activeFlag;\n }\n\n /**\n * Set the active state of the body. An inactive body is not simulated and\n * cannot be collided with or woken up. If you pass a flag of true, all fixtures\n * will be added to the broad-phase. If you pass a flag of false, all fixtures\n * will be removed from the broad-phase and all contacts will be destroyed.\n * Fixtures and joints are otherwise unaffected.\n *\n * You may continue to create/destroy fixtures and joints on inactive bodies.\n * Fixtures on an inactive body are implicitly inactive and will not participate\n * in collisions, ray-casts, or queries. Joints connected to an inactive body\n * are implicitly inactive. An inactive body is still owned by a World object\n * and remains\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n setActive(flag: boolean): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (flag == this.m_activeFlag) {\n return;\n }\n\n this.m_activeFlag = !!flag;\n\n if (this.m_activeFlag) {\n // Create all proxies.\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.createProxies(broadPhase, this.m_xf);\n }\n\t\t // Contacts are created at the beginning of the next\n\t\t this.m_world.m_newFixture = true;\n } else {\n // Destroy all proxies.\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.destroyProxies(broadPhase);\n }\n\n // Destroy the attached contacts.\n let ce = this.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n this.m_world.destroyContact(ce0.contact);\n }\n this.m_contactList = null;\n }\n }\n\n isFixedRotation(): boolean {\n return this.m_fixedRotationFlag;\n }\n\n /**\n * Set this body to have fixed rotation. This causes the mass to be reset.\n */\n setFixedRotation(flag: boolean): void {\n if (this.m_fixedRotationFlag == flag) {\n return;\n }\n\n this.m_fixedRotationFlag = !!flag;\n\n this.m_angularVelocity = 0.0;\n\n this.resetMassData();\n }\n\n /**\n * Get the world transform for the body's origin.\n */\n getTransform(): Transform {\n return this.m_xf;\n }\n\n /**\n * Set the position of the body's origin and rotation. Manipulating a body's\n * transform may cause non-physical behavior. Note: contacts are updated on the\n * next call to World.step.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n *\n * @param position The world position of the body's local origin.\n * @param angle The world rotation in radians.\n */\n setTransform(position: Vec2Value, angle: number): void;\n /**\n * Set the position of the body's origin and rotation. Manipulating a body's\n * transform may cause non-physical behavior. Note: contacts are updated on the\n * next call to World.step.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n setTransform(xf: Transform): void;\n setTransform(a: Vec2Value | Transform, b?: number): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return;\n }\n if (typeof b === \"number\") {\n this.m_xf.setNum(a as Vec2Value, b);\n } else {\n this.m_xf.setTransform(a as TransformValue);\n }\n\n this.m_sweep.setTransform(this.m_xf);\n\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.synchronize(broadPhase, this.m_xf, this.m_xf);\n }\n this.setAwake(true);\n }\n\n synchronizeTransform(): void {\n this.m_sweep.getTransform(this.m_xf, 1);\n }\n\n /**\n * Update fixtures in broad-phase.\n */\n synchronizeFixtures(): void {\n this.m_sweep.getTransform(xf, 0);\n\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.synchronize(broadPhase, xf, this.m_xf);\n }\n }\n\n /**\n * Used in TOI.\n */\n advance(alpha: number): void {\n // Advance to the new safe time. This doesn't sync the broad-phase.\n this.m_sweep.advance(alpha);\n matrix.copyVec2(this.m_sweep.c, this.m_sweep.c0);\n this.m_sweep.a = this.m_sweep.a0;\n this.m_sweep.getTransform(this.m_xf, 1);\n }\n\n /**\n * Get the world position for the body's origin.\n */\n getPosition(): Vec2 {\n return this.m_xf.p;\n }\n\n setPosition(p: Vec2Value): void {\n this.setTransform(p, this.m_sweep.a);\n }\n\n /**\n * Get the current world rotation angle in radians.\n */\n getAngle(): number {\n return this.m_sweep.a;\n }\n\n setAngle(angle: number): void {\n this.setTransform(this.m_xf.p, angle);\n }\n\n /**\n * Get the world position of the center of mass.\n */\n getWorldCenter(): Vec2 {\n return this.m_sweep.c;\n }\n\n /**\n * Get the local position of the center of mass.\n */\n getLocalCenter(): Vec2 {\n return this.m_sweep.localCenter;\n }\n\n /**\n * Get the linear velocity of the center of mass.\n *\n * @return the linear velocity of the center of mass.\n */\n getLinearVelocity(): Vec2 {\n return this.m_linearVelocity;\n }\n\n /**\n * Get the world linear velocity of a world point attached to this body.\n *\n * @param worldPoint A point in world coordinates.\n */\n getLinearVelocityFromWorldPoint(worldPoint: Vec2Value): Vec2 {\n const localCenter = Vec2.sub(worldPoint, this.m_sweep.c);\n return Vec2.add(this.m_linearVelocity, Vec2.crossNumVec2(this.m_angularVelocity,\n localCenter));\n }\n\n /**\n * Get the world velocity of a local point.\n *\n * @param localPoint A point in local coordinates.\n */\n getLinearVelocityFromLocalPoint(localPoint: Vec2Value): Vec2 {\n return this.getLinearVelocityFromWorldPoint(this.getWorldPoint(localPoint));\n }\n\n /**\n * Set the linear velocity of the center of mass.\n *\n * @param v The new linear velocity of the center of mass.\n */\n setLinearVelocity(v: Vec2Value): void {\n if (this.m_type == STATIC) {\n return;\n }\n if (Vec2.dot(v, v) > 0.0) {\n this.setAwake(true);\n }\n this.m_linearVelocity.setVec2(v);\n }\n\n /**\n * Get the angular velocity.\n *\n * @returns the angular velocity in radians/second.\n */\n getAngularVelocity(): number {\n return this.m_angularVelocity;\n }\n\n /**\n * Set the angular velocity.\n *\n * @param w The new angular velocity in radians/second.\n */\n setAngularVelocity(w: number): void {\n if (this.m_type == STATIC) {\n return;\n }\n if (w * w > 0.0) {\n this.setAwake(true);\n }\n this.m_angularVelocity = w;\n }\n\n getLinearDamping(): number {\n return this.m_linearDamping;\n }\n\n setLinearDamping(linearDamping: number): void {\n this.m_linearDamping = linearDamping;\n }\n\n getAngularDamping(): number {\n return this.m_angularDamping;\n }\n\n setAngularDamping(angularDamping: number): void {\n this.m_angularDamping = angularDamping;\n }\n\n getGravityScale(): number {\n return this.m_gravityScale;\n }\n\n /**\n * Scale the gravity applied to this body.\n */\n setGravityScale(scale: number): void {\n this.m_gravityScale = scale;\n }\n\n /**\n * Get the total mass of the body.\n *\n * @returns The mass, usually in kilograms (kg).\n */\n getMass(): number {\n return this.m_mass;\n }\n\n /**\n * Get the rotational inertia of the body about the local origin.\n *\n * @return the rotational inertia, usually in kg-m^2.\n */\n getInertia(): number {\n return this.m_I + this.m_mass\n * Vec2.dot(this.m_sweep.localCenter, this.m_sweep.localCenter);\n }\n\n /**\n * Copy the mass data of the body to data.\n */\n getMassData(data: MassData): void {\n data.mass = this.m_mass;\n data.I = this.getInertia();\n matrix.copyVec2(data.center, this.m_sweep.localCenter);\n }\n\n /**\n * This resets the mass properties to the sum of the mass properties of the\n * fixtures. This normally does not need to be called unless you called\n * SetMassData to override the mass and you later want to reset the mass.\n */\n resetMassData(): void {\n // Compute mass data from shapes. Each shape has its own density.\n this.m_mass = 0.0;\n this.m_invMass = 0.0;\n this.m_I = 0.0;\n this.m_invI = 0.0;\n matrix.zeroVec2(this.m_sweep.localCenter);\n\n // Static and kinematic bodies have zero mass.\n if (this.isStatic() || this.isKinematic()) {\n matrix.copyVec2(this.m_sweep.c0, this.m_xf.p);\n matrix.copyVec2(this.m_sweep.c, this.m_xf.p);\n this.m_sweep.a0 = this.m_sweep.a;\n return;\n }\n\n if (_ASSERT) console.assert(this.isDynamic());\n\n // Accumulate mass over all fixtures.\n matrix.zeroVec2(localCenter);\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n if (f.m_density == 0.0) {\n continue;\n }\n\n const massData: MassData = {\n mass: 0,\n center: matrix.vec2(0, 0),\n I: 0\n };\n f.getMassData(massData);\n this.m_mass += massData.mass;\n matrix.plusScaleVec2(localCenter, massData.mass, massData.center);\n this.m_I += massData.I;\n }\n\n // Compute center of mass.\n if (this.m_mass > 0.0) {\n this.m_invMass = 1.0 / this.m_mass;\n matrix.scaleVec2(localCenter, this.m_invMass, localCenter);\n\n } else {\n // Force all dynamic bodies to have a positive mass.\n this.m_mass = 1.0;\n this.m_invMass = 1.0;\n }\n\n if (this.m_I > 0.0 && this.m_fixedRotationFlag == false) {\n // Center the inertia about the center of mass.\n this.m_I -= this.m_mass * matrix.dotVec2(localCenter, localCenter);\n if (_ASSERT) console.assert(this.m_I > 0.0);\n this.m_invI = 1.0 / this.m_I;\n\n } else {\n this.m_I = 0.0;\n this.m_invI = 0.0;\n }\n\n // Move center of mass.\n matrix.copyVec2(oldCenter, this.m_sweep.c);\n this.m_sweep.setLocalCenter(localCenter, this.m_xf);\n\n // Update center of mass velocity.\n matrix.subVec2(shift, this.m_sweep.c, oldCenter);\n matrix.crossNumVec2(temp, this.m_angularVelocity, shift);\n matrix.plusVec2(this.m_linearVelocity, temp);\n }\n\n /**\n * Set the mass properties to override the mass properties of the fixtures. Note\n * that this changes the center of mass position. Note that creating or\n * destroying fixtures can also alter the mass. This function has no effect if\n * the body isn't dynamic.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n *\n * @param massData The mass properties.\n */\n setMassData(massData: MassData): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (this.m_type != DYNAMIC) {\n return;\n }\n\n this.m_invMass = 0.0;\n this.m_I = 0.0;\n this.m_invI = 0.0;\n\n this.m_mass = massData.mass;\n if (this.m_mass <= 0.0) {\n this.m_mass = 1.0;\n }\n\n this.m_invMass = 1.0 / this.m_mass;\n\n if (massData.I > 0.0 && this.m_fixedRotationFlag == false) {\n this.m_I = massData.I - this.m_mass * matrix.dotVec2(massData.center, massData.center);\n if (_ASSERT) console.assert(this.m_I > 0.0);\n this.m_invI = 1.0 / this.m_I;\n }\n\n // Move center of mass.\n matrix.copyVec2(oldCenter, this.m_sweep.c);\n this.m_sweep.setLocalCenter(massData.center, this.m_xf);\n\n // Update center of mass velocity.\n matrix.subVec2(shift, this.m_sweep.c, oldCenter);\n matrix.crossNumVec2(temp, this.m_angularVelocity, shift);\n matrix.plusVec2(this.m_linearVelocity, temp);\n }\n\n /**\n * Apply a force at a world point. If the force is not applied at the center of\n * mass, it will generate a torque and affect the angular velocity. This wakes\n * up the body.\n *\n * @param force The world force vector, usually in Newtons (N).\n * @param point The world position of the point of application.\n * @param wake Also wake up the body\n */\n applyForce(force: Vec2Value, point: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping.\n if (this.m_awakeFlag) {\n this.m_force.add(force);\n this.m_torque += Vec2.crossVec2Vec2(Vec2.sub(point, this.m_sweep.c), force);\n }\n }\n\n /**\n * Apply a force to the center of mass. This wakes up the body.\n *\n * @param force The world force vector, usually in Newtons (N).\n * @param wake Also wake up the body\n */\n applyForceToCenter(force: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_force.add(force);\n }\n }\n\n /**\n * Apply a torque. This affects the angular velocity without affecting the\n * linear velocity of the center of mass. This wakes up the body.\n *\n * @param torque About the z-axis (out of the screen), usually in N-m.\n * @param wake Also wake up the body\n */\n applyTorque(torque: number, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_torque += torque;\n }\n }\n\n /**\n * Apply an impulse at a point. This immediately modifies the velocity. It also\n * modifies the angular velocity if the point of application is not at the\n * center of mass. This wakes up the body.\n *\n * @param impulse The world impulse vector, usually in N-seconds or kg-m/s.\n * @param point The world position of the point of application.\n * @param wake Also wake up the body\n */\n applyLinearImpulse(impulse: Vec2Value, point: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n\n // Don't accumulate velocity if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_linearVelocity.addMul(this.m_invMass, impulse);\n this.m_angularVelocity += this.m_invI * Vec2.crossVec2Vec2(Vec2.sub(point, this.m_sweep.c), impulse);\n }\n }\n\n /**\n * Apply an angular impulse.\n *\n * @param impulse The angular impulse in units of kg*m*m/s\n * @param wake Also wake up the body\n */\n applyAngularImpulse(impulse: number, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate velocity if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_angularVelocity += this.m_invI * impulse;\n }\n }\n\n /**\n * This is used to test if two bodies should collide.\n * \n * Bodies do not collide when:\n * - Neither of them is dynamic\n * - They are connected by a joint with collideConnected == false\n */\n shouldCollide(that: Body): boolean {\n // At least one body should be dynamic.\n if (this.m_type != DYNAMIC && that.m_type != DYNAMIC) {\n return false;\n }\n // Does a joint prevent collision?\n for (let jn = this.m_jointList; jn; jn = jn.next) {\n if (jn.other == that) {\n if (jn.joint.m_collideConnected == false) {\n return false;\n }\n }\n }\n return true;\n }\n\n /** @internal Used for deserialize. */\n _addFixture(fixture: Fixture): Fixture {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return null;\n }\n\n if (this.m_activeFlag) {\n const broadPhase = this.m_world.m_broadPhase;\n fixture.createProxies(broadPhase, this.m_xf);\n }\n\n fixture.m_next = this.m_fixtureList;\n this.m_fixtureList = fixture;\n\n // Adjust mass properties if needed.\n if (fixture.m_density > 0.0) {\n this.resetMassData();\n }\n\n // Let the world know we have a new fixture. This will cause new contacts\n // to be created at the beginning of the next time step.\n this.m_world.m_newFixture = true;\n\n return fixture;\n }\n\n /**\n * Creates a fixture and attach it to this body.\n *\n * If the density is non-zero, this function automatically updates the mass of\n * the body.\n *\n * Contacts are not created until the next time step.\n *\n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n createFixture(def: FixtureDef): Fixture;\n createFixture(shape: Shape, opt?: FixtureOpt): Fixture;\n createFixture(shape: Shape, density?: number): Fixture;\n // tslint:disable-next-line:typedef\n createFixture(shape, fixdef?) {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return null;\n }\n\n const fixture = new Fixture(this, shape, fixdef);\n this._addFixture(fixture);\n return fixture;\n }\n\n /**\n * Destroy a fixture. This removes the fixture from the broad-phase and destroys\n * all contacts associated with this fixture. This will automatically adjust the\n * mass of the body if the body is dynamic and the fixture has positive density.\n * All fixtures attached to a body are implicitly destroyed when the body is\n * destroyed.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n *\n * @param fixture The fixture to be removed.\n */\n destroyFixture(fixture: Fixture): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (_ASSERT) console.assert(fixture.m_body == this);\n\n // Remove the fixture from this body's singly linked list.\n let found = false;\n if (this.m_fixtureList === fixture) {\n this.m_fixtureList = fixture.m_next;\n found = true;\n\n } else {\n let node = this.m_fixtureList;\n while (node != null) {\n if (node.m_next === fixture) {\n node.m_next = fixture.m_next;\n found = true;\n break;\n }\n node = node.m_next;\n }\n }\n\n // You tried to remove a shape that is not attached to this body.\n if (_ASSERT) console.assert(found);\n\n // Destroy any contacts associated with the fixture.\n let edge = this.m_contactList;\n while (edge) {\n const c = edge.contact;\n edge = edge.next;\n\n const fixtureA = c.getFixtureA();\n const fixtureB = c.getFixtureB();\n\n if (fixture == fixtureA || fixture == fixtureB) {\n // This destroys the contact and removes it from\n // this body's contact list.\n this.m_world.destroyContact(c);\n }\n }\n\n if (this.m_activeFlag) {\n const broadPhase = this.m_world.m_broadPhase;\n fixture.destroyProxies(broadPhase);\n }\n\n fixture.m_body = null;\n fixture.m_next = null;\n\n this.m_world.publish(\"remove-fixture\", fixture);\n\n // Reset the mass data.\n this.resetMassData();\n }\n\n /**\n * Get the corresponding world point of a local point.\n */\n getWorldPoint(localPoint: Vec2Value): Vec2 {\n return Transform.mulVec2(this.m_xf, localPoint);\n }\n\n /**\n * Get the corresponding world vector of a local vector.\n */\n getWorldVector(localVector: Vec2Value): Vec2 {\n return Rot.mulVec2(this.m_xf.q, localVector);\n }\n\n /**\n * Gets the corresponding local point of a world point.\n */\n getLocalPoint(worldPoint: Vec2Value): Vec2 {\n return Transform.mulTVec2(this.m_xf, worldPoint);\n }\n\n /**\n * Gets the corresponding local vector of a world vector.\n */\n getLocalVector(worldVector: Vec2Value): Vec2 {\n return Rot.mulTVec2(this.m_xf.q, worldVector);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { Vec2, Vec2Value } from \"../common/Vec2\";\nimport type { Body } from \"./Body\";\nimport { TimeStep } from \"./Solver\";\nimport { Style } from \"../util/Testbed\";\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/**\n * A joint edge is used to connect bodies and joints together in a joint graph\n * where each body is a node and each joint is an edge. A joint edge belongs to\n * a doubly linked list maintained in each attached body. Each joint has two\n * joint nodes, one for each attached body.\n */\nexport class JointEdge {\n /**\n * provides quick access to the other body attached.\n */\n other: Body | null = null;\n /**\n * the joint\n */\n joint: Joint | null = null;\n /**\n * prev the previous joint edge in the body's joint list\n */\n prev: JointEdge | null = null;\n /**\n * the next joint edge in the body's joint list\n */\n next: JointEdge | null = null;\n}\n\n/**\n * Joint definitions are used to construct joints.\n */\nexport interface JointOpt {\n /**\n * Use this to attach application specific data to your joints.\n */\n userData?: any;\n /**\n * Set this flag to true if the attached bodies\n * should collide.\n */\n collideConnected?: boolean;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\n/**\n * Joint definitions are used to construct joints.\n */\nexport interface JointDef extends JointOpt {\n /**\n * The first attached body.\n */\n bodyA: Body;\n /**\n * The second attached body.\n */\n bodyB: Body;\n}\n\n/** @internal */ const DEFAULTS = {\n userData : null,\n collideConnected : false\n};\n\n/**\n * The base joint class. Joints are used to constraint two bodies together in\n * various fashions. Some joints also feature limits and motors.\n */\nexport abstract class Joint {\n\n /** @internal */ m_type: string = \"unknown-joint\";\n\n /** @internal */ m_bodyA: Body;\n /** @internal */ m_bodyB: Body;\n\n /** @internal */ m_collideConnected: boolean;\n\n /** @internal */ m_prev: Joint | null = null;\n /** @internal */ m_next: Joint | null = null;\n\n /** @internal */ m_edgeA: JointEdge = new JointEdge();\n /** @internal */ m_edgeB: JointEdge = new JointEdge();\n\n /** @internal */ m_islandFlag: boolean = false;\n /** @internal */ m_userData: unknown;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n constructor(def: JointDef);\n constructor(def: JointOpt, bodyA: Body, bodyB: Body);\n constructor(def: JointDef | JointOpt, bodyA?: Body, bodyB?: Body) {\n bodyA = \"bodyA\" in def ? def.bodyA : bodyA;\n bodyB = \"bodyB\" in def ? def.bodyB : bodyB;\n\n if (_ASSERT) console.assert(!!bodyA);\n if (_ASSERT) console.assert(!!bodyB);\n if (_ASSERT) console.assert(bodyA != bodyB);\n\n this.m_bodyA = bodyA!;\n this.m_bodyB = bodyB!;\n\n this.m_collideConnected = !!def.collideConnected;\n this.m_userData = def.userData;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /**\n * Short-cut function to determine if either body is inactive.\n */\n isActive(): boolean {\n return this.m_bodyA.isActive() && this.m_bodyB.isActive();\n }\n\n /**\n * Get the type of the concrete joint.\n */\n getType(): string {\n return this.m_type;\n }\n\n /**\n * Get the first body attached to this joint.\n */\n getBodyA(): Body {\n return this.m_bodyA;\n }\n\n /**\n * Get the second body attached to this joint.\n */\n getBodyB(): Body {\n return this.m_bodyB;\n }\n\n /**\n * Get the next joint the world joint list.\n */\n getNext(): Joint {\n return this.m_next;\n }\n\n getUserData(): unknown {\n return this.m_userData;\n }\n\n setUserData(data: unknown): void {\n this.m_userData = data;\n }\n\n /**\n * Get collide connected. Note: modifying the collide connect flag won't work\n * correctly because the flag is only checked when fixture AABBs begin to\n * overlap.\n */\n getCollideConnected(): boolean {\n return this.m_collideConnected;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n abstract getAnchorA(): Vec2;\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n abstract getAnchorB(): Vec2;\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n abstract getReactionForce(inv_dt: number): Vec2;\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n abstract getReactionTorque(inv_dt: number): number;\n\n /**\n * Shift the origin for any points stored in world coordinates.\n */\n shiftOrigin(newOrigin: Vec2Value): void {}\n\n abstract initVelocityConstraints(step: TimeStep): void;\n\n abstract solveVelocityConstraints(step: TimeStep): void;\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n abstract solvePositionConstraints(step: TimeStep): boolean;\n\n /**\n * @hidden @experimental\n * Update joint with new props.\n */\n abstract _reset(def: Partial): void;\n\n /**\n * @internal @deprecated\n * Temporary for backward compatibility, will be removed.\n */\n _resetAnchors(def: any): void {\n return this._reset(def);\n }\n}\n","/** @hidden */\nexport const stats = {\n gjkCalls: 0,\n gjkIters: 0,\n gjkMaxIters: 0,\n\n toiTime: 0,\n toiMaxTime: 0,\n toiCalls: 0,\n toiIters: 0,\n toiMaxIters: 0,\n toiRootIters: 0,\n toiMaxRootIters: 0,\n\n toString(newline?: string): string {\n newline = typeof newline === \"string\" ? newline : \"\\n\";\n let string = \"\";\n // tslint:disable-next-line:no-for-in\n for (const name in this) {\n if (typeof this[name] !== \"function\" && typeof this[name] !== \"object\") {\n string += name + \": \" + this[name] + newline;\n }\n }\n return string;\n }\n};\n","/** @internal */\nexport const now = function(): number {\n return Date.now();\n};\n\n/** @internal */\nexport const diff = function(time: number): number {\n return Date.now() - time;\n};\n\n/** @internal */\nexport default {\n now,\n diff,\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { stats } from \"../util/stats\";\nimport { Shape } from \"./Shape\";\nimport { EPSILON } from \"../common/Math\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { Rot } from \"../common/Rot\";\nimport { Transform, TransformValue } from \"../common/Transform\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_max = Math.max;\n\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const e12 = matrix.vec2(0, 0);\n/** @internal */ const e13 = matrix.vec2(0, 0);\n/** @internal */ const e23 = matrix.vec2(0, 0);\n/** @internal */ const temp1 = matrix.vec2(0, 0);\n/** @internal */ const temp2 = matrix.vec2(0, 0);\n\n/**\n * GJK using Voronoi regions (Christer Ericson) and Barycentric coordinates.\n */\n\nstats.gjkCalls = 0;\nstats.gjkIters = 0;\nstats.gjkMaxIters = 0;\n\n/**\n * Input for Distance. You have to option to use the shape radii in the\n * computation. Even\n */\nexport class DistanceInput {\n readonly proxyA = new DistanceProxy();\n readonly proxyB = new DistanceProxy();\n readonly transformA = Transform.identity();\n readonly transformB = Transform.identity();\n useRadii = false;\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.transformA.setIdentity();\n this.transformB.setIdentity();\n this.useRadii = false;\n }\n}\n\n/**\n * Output for Distance.\n */\nexport class DistanceOutput {\n /** closest point on shapeA */\n pointA = matrix.vec2(0, 0);\n /** closest point on shapeB */\n pointB = matrix.vec2(0, 0);\n distance = 0;\n /** iterations number of GJK iterations used */\n iterations = 0;\n recycle() {\n matrix.zeroVec2(this.pointA);\n matrix.zeroVec2(this.pointB);\n this.distance = 0;\n this.iterations = 0;\n }\n}\n\n/**\n * Used to warm start Distance. Set count to zero on first call.\n */\nexport class SimplexCache {\n /** length or area */\n metric: number = 0;\n /** vertices on shape A */\n indexA: number[] = [];\n /** vertices on shape B */\n indexB: number[] = [];\n count: number = 0;\n recycle() {\n this.metric = 0;\n this.indexA.length = 0;\n this.indexB.length = 0;\n this.count = 0;\n }\n}\n\n/**\n * Compute the closest points between two shapes. Supports any combination of:\n * CircleShape, PolygonShape, EdgeShape. The simplex cache is input/output. On\n * the first call set SimplexCache.count to zero.\n */\nexport const Distance = function (output: DistanceOutput, cache: SimplexCache, input: DistanceInput): void {\n ++stats.gjkCalls;\n\n const proxyA = input.proxyA;\n const proxyB = input.proxyB;\n const xfA = input.transformA;\n const xfB = input.transformB;\n\n // Initialize the simplex.\n // const simplex = new Simplex();\n simplex.recycle();\n simplex.readCache(cache, proxyA, xfA, proxyB, xfB);\n\n // Get simplex vertices as an array.\n const vertices = simplex.m_v;\n const k_maxIters = Settings.maxDistanceIterations;\n\n // These store the vertices of the last simplex so that we\n // can check for duplicates and prevent cycling.\n const saveA = [];\n const saveB = []; // int[3]\n let saveCount = 0;\n\n // Main iteration loop.\n let iter = 0;\n while (iter < k_maxIters) {\n // Copy simplex so we can identify duplicates.\n saveCount = simplex.m_count;\n for (let i = 0; i < saveCount; ++i) {\n saveA[i] = vertices[i].indexA;\n saveB[i] = vertices[i].indexB;\n }\n\n simplex.solve();\n\n // If we have 3 points, then the origin is in the corresponding triangle.\n if (simplex.m_count === 3) {\n break;\n }\n\n // Get search direction.\n const d = simplex.getSearchDirection();\n\n // Ensure the search direction is numerically fit.\n if (matrix.lengthSqrVec2(d) < EPSILON * EPSILON) {\n // The origin is probably contained by a line segment\n // or triangle. Thus the shapes are overlapped.\n\n // We can't return zero here even though there may be overlap.\n // In case the simplex is a point, segment, or triangle it is difficult\n // to determine if the origin is contained in the CSO or very close to it.\n break;\n }\n\n // Compute a tentative new simplex vertex using support points.\n const vertex = vertices[simplex.m_count]; // SimplexVertex\n\n vertex.indexA = proxyA.getSupport(matrix.derotVec2(temp, xfA.q, matrix.scaleVec2(temp, -1, d)));\n matrix.transformVec2(vertex.wA, xfA, proxyA.getVertex(vertex.indexA));\n\n vertex.indexB = proxyB.getSupport(matrix.derotVec2(temp, xfB.q, d));\n matrix.transformVec2(vertex.wB, xfB, proxyB.getVertex(vertex.indexB));\n\n matrix.subVec2(vertex.w, vertex.wB, vertex.wA);\n\n // Iteration count is equated to the number of support point calls.\n ++iter;\n ++stats.gjkIters;\n\n // Check for duplicate support points. This is the main termination\n // criteria.\n let duplicate = false;\n for (let i = 0; i < saveCount; ++i) {\n if (vertex.indexA === saveA[i] && vertex.indexB === saveB[i]) {\n duplicate = true;\n break;\n }\n }\n\n // If we found a duplicate support point we must exit to avoid cycling.\n if (duplicate) {\n break;\n }\n\n // New vertex is ok and needed.\n ++simplex.m_count;\n }\n\n stats.gjkMaxIters = math_max(stats.gjkMaxIters, iter);\n\n // Prepare output.\n simplex.getWitnessPoints(output.pointA, output.pointB);\n output.distance = matrix.distVec2(output.pointA, output.pointB);\n output.iterations = iter;\n\n // Cache the simplex.\n simplex.writeCache(cache);\n\n // Apply radii if requested.\n if (input.useRadii) {\n const rA = proxyA.m_radius;\n const rB = proxyB.m_radius;\n\n if (output.distance > rA + rB && output.distance > EPSILON) {\n // Shapes are still no overlapped.\n // Move the witness points to the outer surface.\n output.distance -= rA + rB;\n matrix.subVec2(normal, output.pointB, output.pointA);\n matrix.normalizeVec2(normal);\n matrix.plusScaleVec2(output.pointA, rA, normal);\n matrix.minusScaleVec2(output.pointB, rB, normal);\n } else {\n // Shapes are overlapped when radii are considered.\n // Move the witness points to the middle.\n const p = matrix.subVec2(temp, output.pointA, output.pointB);\n matrix.copyVec2(output.pointA, p);\n matrix.copyVec2(output.pointB, p);\n output.distance = 0.0;\n }\n }\n};\n\n/**\n * A distance proxy is used by the GJK algorithm. It encapsulates any shape.\n */\nexport class DistanceProxy {\n /** @internal */ m_vertices: Vec2Value[] = [];\n // todo: remove this?\n /** @internal */ m_count = 0;\n /** @internal */ m_radius = 0;\n\n recycle() {\n this.m_vertices.length = 0;\n this.m_count = 0;\n this.m_radius = 0;\n }\n\n /**\n * Get the vertex count.\n */\n getVertexCount(): number {\n return this.m_count;\n }\n\n /**\n * Get a vertex by index. Used by Distance.\n */\n getVertex(index: number): Vec2Value {\n if (_ASSERT) console.assert(0 <= index && index < this.m_count);\n return this.m_vertices[index];\n }\n\n /**\n * Get the supporting vertex index in the given direction.\n */\n getSupport(d: Vec2Value): number {\n let bestIndex = -1;\n let bestValue = -Infinity;\n for (let i = 0; i < this.m_count; ++i) {\n const value = matrix.dotVec2(this.m_vertices[i], d);\n if (value > bestValue) {\n bestIndex = i;\n bestValue = value;\n }\n }\n return bestIndex;\n }\n\n /**\n * Get the supporting vertex in the given direction.\n */\n getSupportVertex(d: Vec2Value): Vec2Value {\n return this.m_vertices[this.getSupport(d)];\n }\n\n /**\n * Initialize the proxy using the given shape. The shape must remain in scope\n * while the proxy is in use.\n */\n set(shape: Shape, index: number): void {\n // TODO remove, use shape instead\n if (_ASSERT) console.assert(typeof shape.computeDistanceProxy === \"function\");\n shape.computeDistanceProxy(this, index);\n }\n\n /**\n * Initialize the proxy using a vertex cloud and radius. The vertices\n * must remain in scope while the proxy is in use.\n */\n setVertices(vertices: Vec2Value[], count: number, radius: number) {\n this.m_vertices = vertices;\n this.m_count = count;\n this.m_radius = radius;\n }\n}\n\nclass SimplexVertex {\n /** support point in proxyA */\n wA = matrix.vec2(0, 0);\n /** wA index */\n indexA = 0;\n\n /** support point in proxyB */\n wB = matrix.vec2(0, 0);\n /** wB index */\n indexB = 0;\n\n /** wB - wA; */\n w = matrix.vec2(0, 0);\n /** barycentric coordinate for closest point */\n a = 0;\n\n recycle() {\n this.indexA = 0;\n this.indexB = 0;\n matrix.zeroVec2(this.wA);\n matrix.zeroVec2(this.wB);\n matrix.zeroVec2(this.w);\n this.a = 0;\n }\n set(v: SimplexVertex): void {\n this.indexA = v.indexA;\n this.indexB = v.indexB;\n matrix.copyVec2(this.wA, v.wA);\n matrix.copyVec2(this.wB, v.wB);\n matrix.copyVec2(this.w, v.w);\n this.a = v.a;\n }\n}\n\n/** @internal */ const searchDirection_reuse = matrix.vec2(0, 0);\n/** @internal */ const closestPoint_reuse = matrix.vec2(0, 0); \n\nclass Simplex {\n m_v1 = new SimplexVertex();\n m_v2 = new SimplexVertex();\n m_v3 = new SimplexVertex();\n m_v = [this.m_v1, this.m_v2, this.m_v3];\n m_count: number;\n recycle() {\n this.m_v1.recycle();\n this.m_v2.recycle();\n this.m_v3.recycle();\n this.m_count = 0;\n }\n\n /** @internal */ toString(): string {\n if (this.m_count === 3) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y,\n this.m_v2.a, this.m_v2.wA.x, this.m_v2.wA.y, this.m_v2.wB.x, this.m_v2.wB.y,\n this.m_v3.a, this.m_v3.wA.x, this.m_v3.wA.y, this.m_v3.wB.x, this.m_v3.wB.y\n ].toString();\n\n } else if (this.m_count === 2) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y,\n this.m_v2.a, this.m_v2.wA.x, this.m_v2.wA.y, this.m_v2.wB.x, this.m_v2.wB.y\n ].toString();\n\n } else if (this.m_count === 1) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y\n ].toString();\n\n } else {\n return \"+\" + this.m_count;\n }\n }\n\n readCache(cache: SimplexCache, proxyA: DistanceProxy, transformA: TransformValue, proxyB: DistanceProxy, transformB: TransformValue): void {\n if (_ASSERT) console.assert(cache.count <= 3);\n\n // Copy data from cache.\n this.m_count = cache.count;\n for (let i = 0; i < this.m_count; ++i) {\n const v = this.m_v[i];\n v.indexA = cache.indexA[i];\n v.indexB = cache.indexB[i];\n const wALocal = proxyA.getVertex(v.indexA);\n const wBLocal = proxyB.getVertex(v.indexB);\n matrix.transformVec2(v.wA, transformA, wALocal);\n matrix.transformVec2(v.wB, transformB, wBLocal);\n matrix.subVec2(v.w,v.wB, v.wA);\n v.a = 0.0;\n }\n\n // Compute the new simplex metric, if it is substantially different than\n // old metric then flush the simplex.\n if (this.m_count > 1) {\n const metric1 = cache.metric;\n const metric2 = this.getMetric();\n if (metric2 < 0.5 * metric1 || 2.0 * metric1 < metric2 || metric2 < EPSILON) {\n // Reset the simplex.\n this.m_count = 0;\n }\n }\n\n // If the cache is empty or invalid...\n if (this.m_count === 0) {\n const v = this.m_v[0];\n v.indexA = 0;\n v.indexB = 0;\n const wALocal = proxyA.getVertex(0);\n const wBLocal = proxyB.getVertex(0);\n matrix.transformVec2(v.wA, transformA, wALocal);\n matrix.transformVec2(v.wB, transformB, wBLocal);\n matrix.subVec2(v.w,v.wB, v.wA);\n v.a = 1.0;\n this.m_count = 1;\n }\n }\n\n writeCache(cache: SimplexCache): void {\n cache.metric = this.getMetric();\n cache.count = this.m_count;\n for (let i = 0; i < this.m_count; ++i) {\n cache.indexA[i] = this.m_v[i].indexA;\n cache.indexB[i] = this.m_v[i].indexB;\n }\n }\n\n getSearchDirection(): Vec2Value {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 1:\n return matrix.setVec2(searchDirection_reuse, -v1.w.x, -v1.w.y);\n\n case 2: {\n matrix.subVec2(e12, v2.w, v1.w);\n const sgn = -matrix.crossVec2Vec2(e12, v1.w);\n if (sgn > 0.0) {\n // Origin is left of e12.\n return matrix.setVec2(searchDirection_reuse, -e12.y, e12.x);\n } else {\n // Origin is right of e12.\n return matrix.setVec2(searchDirection_reuse, e12.y, -e12.x);\n }\n }\n\n default:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(searchDirection_reuse);\n }\n }\n\n getClosestPoint(): Vec2Value {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(closestPoint_reuse);\n\n case 1:\n return matrix.copyVec2(closestPoint_reuse, v1.w);\n\n case 2:\n return matrix.combine2Vec2(closestPoint_reuse, v1.a, v1.w, v2.a, v2.w);\n\n case 3:\n return matrix.zeroVec2(closestPoint_reuse);\n\n default:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(closestPoint_reuse);\n }\n }\n\n getWitnessPoints(pA: Vec2Value, pB: Vec2Value): void {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n break;\n\n case 1:\n matrix.copyVec2(pA, v1.wA);\n matrix.copyVec2(pB, v1.wB);\n break;\n\n case 2:\n matrix.combine2Vec2(pA, v1.a, v1.wA, v2.a, v2.wA);\n matrix.combine2Vec2(pB, v1.a, v1.wB, v2.a, v2.wB);\n break;\n\n case 3:\n matrix.combine3Vec2(pA, v1.a, v1.wA, v2.a, v2.wA, v3.a, v3.wA);\n matrix.copyVec2(pB, pA);\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n break;\n }\n }\n\n getMetric(): number {\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n return 0.0;\n\n case 1:\n return 0.0;\n\n case 2:\n return matrix.distVec2(this.m_v1.w, this.m_v2.w);\n\n case 3:\n return matrix.crossVec2Vec2(\n matrix.subVec2(temp1, this.m_v2.w, this.m_v1.w),\n matrix.subVec2(temp2, this.m_v3.w, this.m_v1.w),\n );\n\n default:\n if (_ASSERT) console.assert(false);\n return 0.0;\n }\n }\n\n solve(): void {\n switch (this.m_count) {\n case 1:\n break;\n\n case 2:\n this.solve2();\n break;\n\n case 3:\n this.solve3();\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n }\n }\n\n// Solve a line segment using barycentric coordinates.\n//\n// p = a1 * w1 + a2 * w2\n// a1 + a2 = 1\n//\n// The vector from the origin to the closest point on the line is\n// perpendicular to the line.\n// e12 = w2 - w1\n// dot(p, e) = 0\n// a1 * dot(w1, e) + a2 * dot(w2, e) = 0\n//\n// 2-by-2 linear system\n// [1 1 ][a1] = [1]\n// [w1.e12 w2.e12][a2] = [0]\n//\n// Define\n// d12_1 = dot(w2, e12)\n// d12_2 = -dot(w1, e12)\n// d12 = d12_1 + d12_2\n//\n// Solution\n// a1 = d12_1 / d12\n// a2 = d12_2 / d12\n solve2(): void {\n const w1 = this.m_v1.w;\n const w2 = this.m_v2.w;\n matrix.subVec2(e12, w2, w1);\n\n // w1 region\n const d12_2 = -matrix.dotVec2(w1, e12);\n if (d12_2 <= 0.0) {\n // a2 <= 0, so we clamp it to 0\n this.m_v1.a = 1.0;\n this.m_count = 1;\n return;\n }\n\n // w2 region\n const d12_1 = matrix.dotVec2(w2, e12);\n if (d12_1 <= 0.0) {\n // a1 <= 0, so we clamp it to 0\n this.m_v2.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v2);\n return;\n }\n\n // Must be in e12 region.\n const inv_d12 = 1.0 / (d12_1 + d12_2);\n this.m_v1.a = d12_1 * inv_d12;\n this.m_v2.a = d12_2 * inv_d12;\n this.m_count = 2;\n }\n\n// Possible regions:\n// - points[2]\n// - edge points[0]-points[2]\n// - edge points[1]-points[2]\n// - inside the triangle\n solve3(): void {\n const w1 = this.m_v1.w;\n const w2 = this.m_v2.w;\n const w3 = this.m_v3.w;\n\n // Edge12\n // [1 1 ][a1] = [1]\n // [w1.e12 w2.e12][a2] = [0]\n // a3 = 0\n matrix.subVec2(e12, w2, w1);\n const w1e12 = matrix.dotVec2(w1, e12);\n const w2e12 = matrix.dotVec2(w2, e12);\n const d12_1 = w2e12;\n const d12_2 = -w1e12;\n\n // Edge13\n // [1 1 ][a1] = [1]\n // [w1.e13 w3.e13][a3] = [0]\n // a2 = 0\n matrix.subVec2(e13, w3, w1);\n const w1e13 = matrix.dotVec2(w1, e13);\n const w3e13 = matrix.dotVec2(w3, e13);\n const d13_1 = w3e13;\n const d13_2 = -w1e13;\n\n // Edge23\n // [1 1 ][a2] = [1]\n // [w2.e23 w3.e23][a3] = [0]\n // a1 = 0\n matrix.subVec2(e23, w3, w2);\n const w2e23 = matrix.dotVec2(w2, e23);\n const w3e23 = matrix.dotVec2(w3, e23);\n const d23_1 = w3e23;\n const d23_2 = -w2e23;\n\n // Triangle123\n const n123 = matrix.crossVec2Vec2(e12, e13);\n\n const d123_1 = n123 * matrix.crossVec2Vec2(w2, w3);\n const d123_2 = n123 * matrix.crossVec2Vec2(w3, w1);\n const d123_3 = n123 * matrix.crossVec2Vec2(w1, w2);\n\n // w1 region\n if (d12_2 <= 0.0 && d13_2 <= 0.0) {\n this.m_v1.a = 1.0;\n this.m_count = 1;\n return;\n }\n\n // e12\n if (d12_1 > 0.0 && d12_2 > 0.0 && d123_3 <= 0.0) {\n const inv_d12 = 1.0 / (d12_1 + d12_2);\n this.m_v1.a = d12_1 * inv_d12;\n this.m_v2.a = d12_2 * inv_d12;\n this.m_count = 2;\n return;\n }\n\n // e13\n if (d13_1 > 0.0 && d13_2 > 0.0 && d123_2 <= 0.0) {\n const inv_d13 = 1.0 / (d13_1 + d13_2);\n this.m_v1.a = d13_1 * inv_d13;\n this.m_v3.a = d13_2 * inv_d13;\n this.m_count = 2;\n this.m_v2.set(this.m_v3);\n return;\n }\n\n // w2 region\n if (d12_1 <= 0.0 && d23_2 <= 0.0) {\n this.m_v2.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v2);\n return;\n }\n\n // w3 region\n if (d13_1 <= 0.0 && d23_1 <= 0.0) {\n this.m_v3.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v3);\n return;\n }\n\n // e23\n if (d23_1 > 0.0 && d23_2 > 0.0 && d123_1 <= 0.0) {\n const inv_d23 = 1.0 / (d23_1 + d23_2);\n this.m_v2.a = d23_1 * inv_d23;\n this.m_v3.a = d23_2 * inv_d23;\n this.m_count = 2;\n this.m_v1.set(this.m_v3);\n return;\n }\n\n // Must be in triangle123\n const inv_d123 = 1.0 / (d123_1 + d123_2 + d123_3);\n this.m_v1.a = d123_1 * inv_d123;\n this.m_v2.a = d123_2 * inv_d123;\n this.m_v3.a = d123_3 * inv_d123;\n this.m_count = 3;\n }\n}\n\n/** @internal */ const simplex = new Simplex();\n\n/** @internal */ const input = new DistanceInput();\n/** @internal */ const cache = new SimplexCache();\n/** @internal */ const output = new DistanceOutput();\n\n/**\n * Determine if two generic shapes overlap.\n */\nexport const testOverlap = function (shapeA: Shape, indexA: number, shapeB: Shape, indexB: number, xfA: TransformValue, xfB: TransformValue): boolean {\n input.recycle();\n input.proxyA.set(shapeA, indexA);\n input.proxyB.set(shapeB, indexB);\n matrix.copyTransform(input.transformA, xfA);\n matrix.copyTransform(input.transformB, xfB);\n input.useRadii = true;\n\n output.recycle();\n cache.recycle();\n\n Distance(output, cache, input);\n\n return output.distance < 10.0 * EPSILON;\n};\n\n// legacy exports\nDistance.testOverlap = testOverlap;\nDistance.Input = DistanceInput;\nDistance.Output = DistanceOutput;\nDistance.Proxy = DistanceProxy;\nDistance.Cache = SimplexCache;\n\n/**\n * Input parameters for ShapeCast\n */\nexport class ShapeCastInput {\n readonly proxyA = new DistanceProxy();\n readonly proxyB = new DistanceProxy();\n readonly transformA = Transform.identity();\n readonly transformB = Transform.identity();\n readonly translationB = Vec2.zero();\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.transformA.setIdentity();\n this.transformB.setIdentity();\n matrix.zeroVec2(this.translationB);\n }\n}\n\n/**\n * Output results for b2ShapeCast\n */\nexport class ShapeCastOutput {\n point: Vec2 = Vec2.zero();\n normal: Vec2 = Vec2.zero();\n lambda = 1.0;\n iterations = 0;\n}\n\n/**\n * Perform a linear shape cast of shape B moving and shape A fixed. Determines\n * the hit point, normal, and translation fraction.\n * \n * @returns true if hit, false if there is no hit or an initial overlap\n */\n//\n// GJK-raycast\n// Algorithm by Gino van den Bergen.\n// \"Smooth Mesh Contacts with GJK\" in Game Physics Pearls. 2010\nexport const ShapeCast = function(output: ShapeCastOutput, input: ShapeCastInput): boolean {\n output.iterations = 0;\n output.lambda = 1.0;\n output.normal.setZero();\n output.point.setZero();\n\n const proxyA = input.proxyA;\n const proxyB = input.proxyB;\n\n const radiusA = math_max(proxyA.m_radius, Settings.polygonRadius);\n const radiusB = math_max(proxyB.m_radius, Settings.polygonRadius);\n const radius = radiusA + radiusB;\n\n const xfA = input.transformA;\n const xfB = input.transformB;\n\n const r = input.translationB;\n const n = Vec2.zero();\n let lambda = 0.0;\n\n // Initial simplex\n const simplex = new Simplex();\n simplex.m_count = 0;\n\n // Get simplex vertices as an array.\n const vertices = simplex.m_v;\n\n // Get support point in -r direction\n let indexA = proxyA.getSupport(Rot.mulTVec2(xfA.q, Vec2.neg(r)));\n let wA = Transform.mulVec2(xfA, proxyA.getVertex(indexA));\n let indexB = proxyB.getSupport(Rot.mulTVec2(xfB.q, r));\n let wB = Transform.mulVec2(xfB, proxyB.getVertex(indexB));\n const v = Vec2.sub(wA, wB);\n\n // Sigma is the target distance between polygons\n const sigma = math_max(Settings.polygonRadius, radius - Settings.polygonRadius);\n const tolerance = 0.5 * Settings.linearSlop;\n\n // Main iteration loop.\n const k_maxIters = 20;\n let iter = 0;\n while (iter < k_maxIters && v.length() - sigma > tolerance) {\n if (_ASSERT) console.assert(simplex.m_count < 3);\n\n output.iterations += 1;\n\n // Support in direction -v (A - B)\n indexA = proxyA.getSupport(Rot.mulTVec2(xfA.q, Vec2.neg(v)));\n wA = Transform.mulVec2(xfA, proxyA.getVertex(indexA));\n indexB = proxyB.getSupport(Rot.mulTVec2(xfB.q, v));\n wB = Transform.mulVec2(xfB, proxyB.getVertex(indexB));\n const p = Vec2.sub(wA, wB);\n\n // -v is a normal at p\n v.normalize();\n\n // Intersect ray with plane\n const vp = Vec2.dot(v, p);\n const vr = Vec2.dot(v, r);\n if (vp - sigma > lambda * vr) {\n if (vr <= 0.0) {\n return false;\n }\n\n lambda = (vp - sigma) / vr;\n if (lambda > 1.0) {\n return false;\n }\n\n n.setMul(-1, v);\n simplex.m_count = 0;\n }\n\n // Reverse simplex since it works with B - A.\n // Shift by lambda * r because we want the closest point to the current clip point.\n // Note that the support point p is not shifted because we want the plane equation\n // to be formed in unshifted space.\n const vertex = vertices[simplex.m_count];\n vertex.indexA = indexB;\n vertex.wA = Vec2.combine(1, wB, lambda, r);\n vertex.indexB = indexA;\n vertex.wB = wA;\n vertex.w = Vec2.sub(vertex.wB, vertex.wA);\n vertex.a = 1.0;\n simplex.m_count += 1;\n\n switch (simplex.m_count) {\n case 1:\n break;\n\n case 2:\n simplex.solve2();\n break;\n\n case 3:\n simplex.solve3();\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n }\n \n // If we have 3 points, then the origin is in the corresponding triangle.\n if (simplex.m_count == 3) {\n // Overlap\n return false;\n }\n\n // Get search direction.\n v.setVec2(simplex.getClosestPoint());\n\n // Iteration count is equated to the number of support point calls.\n ++iter;\n }\n\n if (iter == 0) {\n // Initial overlap\n return false;\n\t}\n\n // Prepare output.\n const pointA = Vec2.zero();\n const pointB = Vec2.zero();\n simplex.getWitnessPoints(pointB, pointA);\n\n if (v.lengthSquared() > 0.0) {\n n.setMul(-1, v);\n n.normalize();\n }\n\n output.point = Vec2.combine(1, pointA, radiusA, n);\n output.normal = n;\n output.lambda = lambda;\n output.iterations = iter;\n return true;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { stats } from \"../util/stats\";\nimport Timer from \"../util/Timer\";\nimport { Sweep } from \"../common/Sweep\";\nimport { Transform } from \"../common/Transform\";\nimport { Distance, DistanceInput, DistanceOutput, DistanceProxy, SimplexCache } from \"./Distance\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n\n\n/**\n * Input parameters for TimeOfImpact.\n */\nexport class TOIInput {\n proxyA = new DistanceProxy();\n proxyB = new DistanceProxy();\n sweepA = new Sweep();\n sweepB = new Sweep();\n /** defines sweep interval [0, tMax] */\n tMax: number;\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.sweepA.recycle();\n this.sweepB.recycle();\n this.tMax = -1;\n }\n}\n\nexport enum TOIOutputState {\n e_unset = -1,\n e_unknown = 0,\n e_failed = 1,\n e_overlapped = 2,\n e_touching = 3,\n e_separated = 4,\n}\n\n/**\n * Output parameters for TimeOfImpact.\n */\nexport class TOIOutput {\n state = TOIOutputState.e_unset;\n t = -1;\n recycle() {\n this.state = TOIOutputState.e_unset;\n this.t = -1;\n }\n}\n\nstats.toiTime = 0;\nstats.toiMaxTime = 0;\nstats.toiCalls = 0;\nstats.toiIters = 0;\nstats.toiMaxIters = 0;\nstats.toiRootIters = 0;\nstats.toiMaxRootIters = 0;\n\n/** @internal */ const distanceInput = new DistanceInput();\n/** @internal */ const distanceOutput = new DistanceOutput();\n// this is passed to Distance and SeparationFunction\n/** @internal */ const cache = new SimplexCache();\n\n/** @internal */ const xfA = matrix.transform(0, 0, 0);\n/** @internal */ const xfB = matrix.transform(0, 0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const axisA = matrix.vec2(0, 0);\n/** @internal */ const axisB = matrix.vec2(0, 0);\n/** @internal */ const localPointA = matrix.vec2(0, 0);\n/** @internal */ const localPointB = matrix.vec2(0, 0);\n\n\n/**\n * Compute the upper bound on time before two shapes penetrate. Time is\n * represented as a fraction between [0,tMax]. This uses a swept separating axis\n * and may miss some intermediate, non-tunneling collisions. If you change the\n * time interval, you should call this function again.\n *\n * Note: use Distance to compute the contact point and normal at the time of\n * impact.\n *\n * CCD via the local separating axis method. This seeks progression by computing\n * the largest time at which separation is maintained.\n */\nexport const TimeOfImpact = function (output: TOIOutput, input: TOIInput): void {\n const timer = Timer.now();\n\n ++stats.toiCalls;\n\n output.state = TOIOutputState.e_unknown;\n output.t = input.tMax;\n\n const proxyA = input.proxyA; // DistanceProxy\n const proxyB = input.proxyB; // DistanceProxy\n\n const sweepA = input.sweepA; // Sweep\n const sweepB = input.sweepB; // Sweep\n\n // Large rotations can make the root finder fail, so we normalize the\n // sweep angles.\n sweepA.normalize();\n sweepB.normalize();\n\n const tMax = input.tMax;\n\n const totalRadius = proxyA.m_radius + proxyB.m_radius;\n const target = math_max(Settings.linearSlop, totalRadius - 3.0 * Settings.linearSlop);\n const tolerance = 0.25 * Settings.linearSlop;\n if (_ASSERT) console.assert(target > tolerance);\n\n let t1 = 0.0;\n const k_maxIterations = Settings.maxTOIIterations;\n let iter = 0;\n\n // Prepare input for distance query.\n // const cache = new SimplexCache();\n cache.recycle();\n\n distanceInput.proxyA.setVertices(proxyA.m_vertices, proxyA.m_count, proxyA.m_radius);\n distanceInput.proxyB.setVertices(proxyB.m_vertices, proxyB.m_count, proxyB.m_radius);\n distanceInput.useRadii = false;\n\n // The outer loop progressively attempts to compute new separating axes.\n // This loop terminates when an axis is repeated (no progress is made).\n while (true) {\n sweepA.getTransform(xfA, t1);\n sweepB.getTransform(xfB, t1);\n\n // Get the distance between shapes. We can also use the results\n // to get a separating axis.\n matrix.copyTransform(distanceInput.transformA, xfA);\n matrix.copyTransform(distanceInput.transformB, xfB);\n Distance(distanceOutput, cache, distanceInput);\n\n // If the shapes are overlapped, we give up on continuous collision.\n if (distanceOutput.distance <= 0.0) {\n // Failure!\n output.state = TOIOutputState.e_overlapped;\n output.t = 0.0;\n break;\n }\n\n if (distanceOutput.distance < target + tolerance) {\n // Victory!\n output.state = TOIOutputState.e_touching;\n output.t = t1;\n break;\n }\n\n // Initialize the separating axis.\n separationFunction.initialize(cache, proxyA, sweepA, proxyB, sweepB, t1);\n\n // if (false) {\n // // Dump the curve seen by the root finder\n // const N = 100;\n // const dx = 1.0 / N;\n // const xs = []; // [ N + 1 ];\n // const fs = []; // [ N + 1 ];\n // const x = 0.0;\n // for (const i = 0; i <= N; ++i) {\n // sweepA.getTransform(xfA, x);\n // sweepB.getTransform(xfB, x);\n // const f = fcn.evaluate(xfA, xfB) - target;\n // printf(\"%g %g\\n\", x, f);\n // xs[i] = x;\n // fs[i] = f;\n // x += dx;\n // }\n // }\n\n // Compute the TOI on the separating axis. We do this by successively\n // resolving the deepest point. This loop is bounded by the number of\n // vertices.\n let done = false;\n let t2 = tMax;\n let pushBackIter = 0;\n while (true) {\n // Find the deepest point at t2. Store the witness point indices.\n let s2 = separationFunction.findMinSeparation(t2);\n\n // Is the final configuration separated?\n if (s2 > target + tolerance) {\n // Victory!\n output.state = TOIOutputState.e_separated;\n output.t = tMax;\n done = true;\n break;\n }\n\n // Has the separation reached tolerance?\n if (s2 > target - tolerance) {\n // Advance the sweeps\n t1 = t2;\n break;\n }\n\n // Compute the initial separation of the witness points.\n let s1 = separationFunction.evaluate(t1);\n\n // Check for initial overlap. This might happen if the root finder\n // runs out of iterations.\n if (s1 < target - tolerance) {\n output.state = TOIOutputState.e_failed;\n output.t = t1;\n done = true;\n break;\n }\n\n // Check for touching\n if (s1 <= target + tolerance) {\n // Victory! t1 should hold the TOI (could be 0.0).\n output.state = TOIOutputState.e_touching;\n output.t = t1;\n done = true;\n break;\n }\n\n // Compute 1D root of: f(x) - target = 0\n let rootIterCount = 0;\n let a1 = t1;\n let a2 = t2;\n while (true) {\n // Use a mix of the secant rule and bisection.\n let t;\n if (rootIterCount & 1) {\n // Secant rule to improve convergence.\n t = a1 + (target - s1) * (a2 - a1) / (s2 - s1);\n } else {\n // Bisection to guarantee progress.\n t = 0.5 * (a1 + a2);\n }\n\n ++rootIterCount;\n ++stats.toiRootIters;\n\n const s = separationFunction.evaluate(t);\n\n if (math_abs(s - target) < tolerance) {\n // t2 holds a tentative value for t1\n t2 = t;\n break;\n }\n\n // Ensure we continue to bracket the root.\n if (s > target) {\n a1 = t;\n s1 = s;\n } else {\n a2 = t;\n s2 = s;\n }\n\n if (rootIterCount === 50) {\n break;\n }\n }\n\n stats.toiMaxRootIters = math_max(stats.toiMaxRootIters, rootIterCount);\n\n ++pushBackIter;\n\n if (pushBackIter === Settings.maxPolygonVertices) {\n break;\n }\n }\n\n ++iter;\n ++stats.toiIters;\n\n if (done) {\n break;\n }\n\n if (iter === k_maxIterations) {\n // Root finder got stuck. Semi-victory.\n output.state = TOIOutputState.e_failed;\n output.t = t1;\n break;\n }\n }\n\n stats.toiMaxIters = math_max(stats.toiMaxIters, iter);\n\n const time = Timer.diff(timer);\n stats.toiMaxTime = math_max(stats.toiMaxTime, time);\n stats.toiTime += time;\n\n separationFunction.recycle();\n};\n\nenum SeparationFunctionType {\n e_unset = -1,\n e_points = 1,\n e_faceA = 2,\n e_faceB = 3,\n}\n\nclass SeparationFunction {\n // input cache\n // todo: maybe assign by copy instead of reference?\n m_proxyA: DistanceProxy = null;\n m_proxyB: DistanceProxy = null;\n m_sweepA: Sweep = null;\n m_sweepB: Sweep = null;\n\n // initialize cache\n m_type = SeparationFunctionType.e_unset;\n m_localPoint = matrix.vec2(0, 0);\n m_axis = matrix.vec2(0, 0);\n\n // compute output\n indexA = -1;\n indexB = -1;\n\n recycle() {\n this.m_proxyA = null;\n this.m_proxyB = null;\n this.m_sweepA = null;\n this.m_sweepB = null;\n\n this.m_type = SeparationFunctionType.e_unset;\n matrix.zeroVec2(this.m_localPoint);\n matrix.zeroVec2(this.m_axis);\n\n this.indexA = -1;\n this.indexB = -1;\n }\n\n // TODO_ERIN might not need to return the separation\n\n initialize(cache: SimplexCache, proxyA: DistanceProxy, sweepA: Sweep, proxyB: DistanceProxy, sweepB: Sweep, t1: number): number {\n const count = cache.count;\n if (_ASSERT) console.assert(0 < count && count < 3);\n\n this.m_proxyA = proxyA;\n this.m_proxyB = proxyB;\n this.m_sweepA = sweepA;\n this.m_sweepB = sweepB;\n\n this.m_sweepA.getTransform(xfA, t1);\n this.m_sweepB.getTransform(xfB, t1);\n\n if (count === 1) {\n this.m_type = SeparationFunctionType.e_points;\n const localPointA = this.m_proxyA.getVertex(cache.indexA[0]);\n const localPointB = this.m_proxyB.getVertex(cache.indexB[0]);\n matrix.transformVec2(pointA, xfA, localPointA);\n matrix.transformVec2(pointB, xfB, localPointB);\n matrix.subVec2(this.m_axis, pointB, pointA);\n const s = matrix.normalizeVec2Length(this.m_axis);\n return s;\n\n } else if (cache.indexA[0] === cache.indexA[1]) {\n // Two points on B and one on A.\n this.m_type = SeparationFunctionType.e_faceB;\n const localPointB1 = proxyB.getVertex(cache.indexB[0]);\n const localPointB2 = proxyB.getVertex(cache.indexB[1]);\n\n matrix.crossVec2Num(this.m_axis, matrix.subVec2(temp, localPointB2, localPointB1), 1.0);\n matrix.normalizeVec2(this.m_axis);\n matrix.rotVec2(normal, xfB.q, this.m_axis);\n\n matrix.combine2Vec2(this.m_localPoint, 0.5, localPointB1, 0.5, localPointB2);\n matrix.transformVec2(pointB, xfB, this.m_localPoint);\n\n const localPointA = proxyA.getVertex(cache.indexA[0]);\n const pointA = Transform.mulVec2(xfA, localPointA);\n\n let s = matrix.dotVec2(pointA, normal) - matrix.dotVec2(pointB, normal);\n if (s < 0.0) {\n matrix.negVec2(this.m_axis);\n s = -s;\n }\n return s;\n\n } else {\n // Two points on A and one or two points on B.\n this.m_type = SeparationFunctionType.e_faceA;\n const localPointA1 = this.m_proxyA.getVertex(cache.indexA[0]);\n const localPointA2 = this.m_proxyA.getVertex(cache.indexA[1]);\n\n matrix.crossVec2Num(this.m_axis, matrix.subVec2(temp, localPointA2, localPointA1), 1.0);\n matrix.normalizeVec2(this.m_axis);\n matrix.rotVec2(normal, xfA.q, this.m_axis);\n\n matrix.combine2Vec2(this.m_localPoint, 0.5, localPointA1, 0.5, localPointA2);\n matrix.transformVec2(pointA, xfA, this.m_localPoint);\n\n const localPointB = this.m_proxyB.getVertex(cache.indexB[0]);\n matrix.transformVec2(pointB, xfB, localPointB);\n\n let s = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal);\n if (s < 0.0) {\n matrix.negVec2(this.m_axis);\n s = -s;\n }\n return s;\n }\n }\n\n compute(find: boolean, t: number): number {\n // It was findMinSeparation and evaluate\n this.m_sweepA.getTransform(xfA, t);\n this.m_sweepB.getTransform(xfB, t);\n\n switch (this.m_type) {\n case SeparationFunctionType.e_points: {\n if (find) {\n matrix.derotVec2(axisA, xfA.q, this.m_axis);\n matrix.derotVec2(axisB, xfB.q, matrix.scaleVec2(temp, -1, this.m_axis));\n\n this.indexA = this.m_proxyA.getSupport(axisA);\n this.indexB = this.m_proxyB.getSupport(axisB);\n }\n\n matrix.copyVec2(localPointA, this.m_proxyA.getVertex(this.indexA));\n matrix.copyVec2(localPointB, this.m_proxyB.getVertex(this.indexB));\n\n matrix.transformVec2(pointA, xfA, localPointA);\n matrix.transformVec2(pointB, xfB, localPointB);\n\n const sep = matrix.dotVec2(pointB, this.m_axis) - matrix.dotVec2(pointA, this.m_axis);\n return sep;\n }\n\n case SeparationFunctionType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.m_axis);\n matrix.transformVec2(pointA, xfA, this.m_localPoint);\n\n if (find) {\n matrix.derotVec2(axisB, xfB.q, matrix.scaleVec2(temp, -1, normal));\n\n this.indexA = -1;\n this.indexB = this.m_proxyB.getSupport(axisB);\n }\n\n matrix.copyVec2(localPointB, this.m_proxyB.getVertex(this.indexB));\n matrix.transformVec2(pointB, xfB, localPointB);\n\n const sep = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal);\n return sep;\n }\n\n case SeparationFunctionType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.m_axis);\n matrix.transformVec2(pointB, xfB, this.m_localPoint);\n\n if (find) {\n matrix.derotVec2(axisA, xfA.q, matrix.scaleVec2(temp, -1, normal));\n\n this.indexB = -1;\n this.indexA = this.m_proxyA.getSupport(axisA);\n }\n\n matrix.copyVec2(localPointA, this.m_proxyA.getVertex(this.indexA));\n matrix.transformVec2(pointA, xfA, localPointA);\n\n const sep = matrix.dotVec2(pointA, normal) - matrix.dotVec2(pointB, normal);\n return sep;\n }\n\n default:\n if (_ASSERT) console.assert(false);\n if (find) {\n this.indexA = -1;\n this.indexB = -1;\n }\n return 0.0;\n }\n }\n\n findMinSeparation(t: number): number {\n return this.compute(true, t);\n }\n\n evaluate(t: number): number {\n return this.compute(false, t);\n }\n}\n\n/** @internal */ const separationFunction = new SeparationFunction();\n\n// legacy exports\nTimeOfImpact.Input = TOIInput;\nTimeOfImpact.Output = TOIOutput;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { EPSILON } from \"../common/Math\";\nimport { Body } from \"./Body\";\nimport type { Contact } from \"./Contact\";\nimport { Joint } from \"./Joint\";\nimport { TimeOfImpact, TOIInput, TOIOutput, TOIOutputState } from \"../collision/TimeOfImpact\";\nimport { Distance, DistanceInput, DistanceOutput, SimplexCache } from \"../collision/Distance\";\nimport { World } from \"./World\";\nimport { Sweep } from \"../common/Sweep\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_min = Math.min;\n\n\nexport class TimeStep {\n /** time step */\n dt: number = 0;\n /** inverse time step (0 if dt == 0) */\n inv_dt: number = 0;\n velocityIterations: number = 0;\n positionIterations: number = 0;\n warmStarting: boolean = false;\n blockSolve: boolean = true;\n\n /** timestep ratio for variable timestep */\n inv_dt0: number = 0.0;\n /** dt * inv_dt0 */\n dtRatio: number = 1;\n\n reset(dt: number): void {\n if (this.dt > 0.0) {\n this.inv_dt0 = this.inv_dt;\n }\n this.dt = dt;\n this.inv_dt = dt == 0 ? 0 : 1 / dt;\n this.dtRatio = dt * this.inv_dt0;\n }\n}\n\n// reuse\n/** @internal */ const s_subStep = new TimeStep();\n/** @internal */ const c = matrix.vec2(0, 0);\n/** @internal */ const v = matrix.vec2(0, 0);\n/** @internal */ const translation = matrix.vec2(0, 0);\n/** @internal */ const input = new TOIInput();\n/** @internal */ const output = new TOIOutput();\n/** @internal */ const backup = new Sweep();\n/** @internal */ const backup1 = new Sweep();\n/** @internal */ const backup2 = new Sweep();\n\n/**\n * Contact impulses for reporting. Impulses are used instead of forces because\n * sub-step forces may approach infinity for rigid body collisions. These match\n * up one-to-one with the contact points in Manifold.\n */\nexport class ContactImpulse {\n // TODO: merge with Contact class?\n\n private readonly contact: Contact;\n private readonly normals: number[];\n private readonly tangents: number[];\n\n constructor(contact: Contact) {\n this.contact = contact;\n this.normals = [];\n this.tangents = [];\n }\n\n recycle() {\n this.normals.length = 0;\n this.tangents.length = 0;\n }\n\n get normalImpulses(): number[] {\n const contact = this.contact;\n const normals = this.normals;\n normals.length = 0;\n for (let p = 0; p < contact.v_points.length; ++p) {\n normals.push(contact.v_points[p].normalImpulse);\n }\n return normals;\n }\n\n get tangentImpulses(): number[] {\n const contact = this.contact;\n const tangents = this.tangents;\n tangents.length = 0;\n for (let p = 0; p < contact.v_points.length; ++p) {\n tangents.push(contact.v_points[p].tangentImpulse);\n }\n return tangents;\n }\n}\n\n/**\n * Finds and solves islands. An island is a connected subset of the world.\n */\nexport class Solver {\n m_world: World;\n m_stack: Body[];\n m_bodies: Body[];\n m_contacts: Contact[];\n m_joints: Joint[];\n\n constructor(world: World) {\n this.m_world = world;\n this.m_stack = [];\n this.m_bodies = [];\n this.m_contacts = [];\n this.m_joints = [];\n }\n\n clear(): void {\n this.m_stack.length = 0;\n this.m_bodies.length = 0;\n this.m_contacts.length = 0;\n this.m_joints.length = 0;\n }\n\n addBody(body: Body): void {\n if (_ASSERT) console.assert(body instanceof Body, \"Not a Body!\", body);\n this.m_bodies.push(body);\n // why?\n // body.c_position.c.setZero();\n // body.c_position.a = 0;\n // body.c_velocity.v.setZero();\n // body.c_velocity.w = 0;\n }\n\n addContact(contact: Contact): void {\n // if (_ASSERT) console.assert(contact instanceof Contact, 'Not a Contact!', contact);\n this.m_contacts.push(contact);\n }\n\n addJoint(joint: Joint): void {\n if (_ASSERT) console.assert(joint instanceof Joint, \"Not a Joint!\", joint);\n this.m_joints.push(joint);\n }\n\n solveWorld(step: TimeStep): void {\n const world = this.m_world;\n\n // Clear all the island flags.\n for (let b = world.m_bodyList; b; b = b.m_next) {\n b.m_islandFlag = false;\n }\n for (let c = world.m_contactList; c; c = c.m_next) {\n c.m_islandFlag = false;\n }\n for (let j = world.m_jointList; j; j = j.m_next) {\n j.m_islandFlag = false;\n }\n\n // Build and simulate all awake islands.\n const stack = this.m_stack;\n let loop = -1;\n for (let seed = world.m_bodyList; seed; seed = seed.m_next) {\n loop++;\n if (seed.m_islandFlag) {\n continue;\n }\n\n if (seed.isAwake() == false || seed.isActive() == false) {\n continue;\n }\n\n // The seed can be dynamic or kinematic.\n if (seed.isStatic()) {\n continue;\n }\n\n // Reset island and stack.\n this.clear();\n\n stack.push(seed);\n\n seed.m_islandFlag = true;\n\n // Perform a depth first search (DFS) on the constraint graph.\n while (stack.length > 0) {\n // Grab the next body off the stack and add it to the island.\n const b = stack.pop();\n if (_ASSERT) console.assert(b.isActive() == true);\n this.addBody(b);\n\n // Make sure the body is awake (without resetting sleep timer).\n b.m_awakeFlag = true;\n\n // To keep islands as small as possible, we don't\n // propagate islands across static bodies.\n if (b.isStatic()) {\n continue;\n }\n\n // Search all contacts connected to this body.\n for (let ce = b.m_contactList; ce; ce = ce.next) {\n const contact = ce.contact;\n\n // Has this contact already been added to an island?\n if (contact.m_islandFlag) {\n continue;\n }\n\n // Is this contact solid and touching?\n if (contact.isEnabled() == false || contact.isTouching() == false) {\n continue;\n }\n\n // Skip sensors.\n const sensorA = contact.m_fixtureA.m_isSensor;\n const sensorB = contact.m_fixtureB.m_isSensor;\n if (sensorA || sensorB) {\n continue;\n }\n\n this.addContact(contact);\n contact.m_islandFlag = true;\n\n const other = ce.other;\n\n // Was the other body already added to this island?\n if (other.m_islandFlag) {\n continue;\n }\n\n // if (_ASSERT) console.assert(stack.length < world.m_bodyCount);\n stack.push(other);\n other.m_islandFlag = true;\n }\n\n // Search all joints connect to this body.\n for (let je = b.m_jointList; je; je = je.next) {\n if (je.joint.m_islandFlag == true) {\n continue;\n }\n\n const other = je.other;\n\n // Don't simulate joints connected to inactive bodies.\n if (other.isActive() == false) {\n continue;\n }\n\n this.addJoint(je.joint);\n je.joint.m_islandFlag = true;\n\n if (other.m_islandFlag) {\n continue;\n }\n\n // if (_ASSERT) console.assert(stack.length < world.m_bodyCount);\n stack.push(other);\n other.m_islandFlag = true;\n }\n }\n\n this.solveIsland(step);\n\n // Post solve cleanup.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n // Allow static bodies to participate in other islands.\n // TODO: are they added at all?\n const b = this.m_bodies[i];\n if (b.isStatic()) {\n b.m_islandFlag = false;\n }\n }\n }\n }\n\n solveIsland(step: TimeStep): void {\n // B2: Island Solve\n const world = this.m_world;\n const gravity = world.m_gravity;\n const allowSleep = world.m_allowSleep;\n\n const h = step.dt;\n\n // Integrate velocities and apply damping. Initialize the body state.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.m_sweep.c);\n const a = body.m_sweep.a;\n matrix.copyVec2(v, body.m_linearVelocity);\n let w = body.m_angularVelocity;\n\n // Store positions for continuous collision.\n matrix.copyVec2(body.m_sweep.c0, body.m_sweep.c);\n body.m_sweep.a0 = body.m_sweep.a;\n\n if (body.isDynamic()) {\n // Integrate velocities.\n matrix.plusScaleVec2(v, h * body.m_gravityScale, gravity);\n matrix.plusScaleVec2(v, h * body.m_invMass, body.m_force);\n w += h * body.m_invI * body.m_torque;\n /**\n *
\n         * Apply damping.\n         * ODE: dv/dt + c * v = 0\n         * Solution: v(t) = v0 * exp(-c * t)\n         * Time step: v(t + dt) = v0 * exp(-c * (t + dt)) = v0 * exp(-c * t) * exp(-c * dt) = v * exp(-c * dt)\n         * v2 = exp(-c * dt) * v1\n         * Pade approximation:\n         * v2 = v1 * 1 / (1 + c * dt)\n         * 
\n */\n matrix.scaleVec2(v, 1.0 / (1.0 + h * body.m_linearDamping), v);\n w *= 1.0 / (1.0 + h * body.m_angularDamping);\n }\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initConstraint(step);\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initVelocityConstraint(step);\n }\n\n if (step.warmStarting) {\n // Warm start.\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.warmStartConstraint(step);\n }\n }\n\n for (let i = 0; i < this.m_joints.length; ++i) {\n const joint = this.m_joints[i];\n joint.initVelocityConstraints(step);\n }\n\n // Solve velocity constraints\n for (let i = 0; i < step.velocityIterations; ++i) {\n for (let j = 0; j < this.m_joints.length; ++j) {\n const joint = this.m_joints[j];\n joint.solveVelocityConstraints(step);\n }\n\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n contact.solveVelocityConstraint(step);\n }\n }\n\n // Store impulses for warm starting\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.storeConstraintImpulses(step);\n }\n\n // Integrate positions\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.c_position.c);\n let a = body.c_position.a;\n matrix.copyVec2(v, body.c_velocity.v);\n let w = body.c_velocity.w;\n\n // Check for large velocities\n matrix.scaleVec2(translation, h, v);\n const translationLengthSqr = matrix.lengthSqrVec2(translation);\n if (translationLengthSqr > Settings.maxTranslationSquared) {\n const ratio = Settings.maxTranslation / math_sqrt(translationLengthSqr);\n matrix.mulVec2(v, ratio);\n }\n\n const rotation = h * w;\n if (rotation * rotation > Settings.maxRotationSquared) {\n const ratio = Settings.maxRotation / math_abs(rotation);\n w *= ratio;\n }\n\n // Integrate\n matrix.plusScaleVec2(c, h, v);\n a += h * w;\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n }\n\n // Solve position constraints\n let positionSolved = false;\n for (let i = 0; i < step.positionIterations; ++i) {\n let minSeparation = 0.0;\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n const separation = contact.solvePositionConstraint(step);\n minSeparation = math_min(minSeparation, separation);\n }\n // We can't expect minSpeparation >= -Settings.linearSlop because we don't\n // push the separation above -Settings.linearSlop.\n const contactsOkay = minSeparation >= -3.0 * Settings.linearSlop;\n\n let jointsOkay = true;\n for (let j = 0; j < this.m_joints.length; ++j) {\n const joint = this.m_joints[j];\n const jointOkay = joint.solvePositionConstraints(step);\n jointsOkay = jointsOkay && jointOkay;\n }\n\n if (contactsOkay && jointsOkay) {\n // Exit early if the position errors are small.\n positionSolved = true;\n break;\n }\n }\n\n // Copy state buffers back to the bodies\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(body.m_sweep.c, body.c_position.c);\n body.m_sweep.a = body.c_position.a;\n matrix.copyVec2(body.m_linearVelocity, body.c_velocity.v);\n body.m_angularVelocity = body.c_velocity.w;\n body.synchronizeTransform();\n }\n\n this.postSolveIsland();\n\n if (allowSleep) {\n let minSleepTime = Infinity;\n\n const linTolSqr = Settings.linearSleepToleranceSqr;\n const angTolSqr = Settings.angularSleepToleranceSqr;\n\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n if (body.isStatic()) {\n continue;\n }\n\n if ((body.m_autoSleepFlag == false)\n || (body.m_angularVelocity * body.m_angularVelocity > angTolSqr)\n || (matrix.lengthSqrVec2(body.m_linearVelocity) > linTolSqr)) {\n body.m_sleepTime = 0.0;\n minSleepTime = 0.0;\n } else {\n body.m_sleepTime += h;\n minSleepTime = math_min(minSleepTime, body.m_sleepTime);\n }\n }\n\n if (minSleepTime >= Settings.timeToSleep && positionSolved) {\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n body.setAwake(false);\n }\n }\n }\n }\n\n /**\n * Find TOI contacts and solve them.\n */\n solveWorldTOI(step: TimeStep): void {\n const world = this.m_world;\n\n if (world.m_stepComplete) {\n for (let b = world.m_bodyList; b; b = b.m_next) {\n b.m_islandFlag = false;\n b.m_sweep.alpha0 = 0.0;\n }\n\n for (let c = world.m_contactList; c; c = c.m_next) {\n // Invalidate TOI\n c.m_toiFlag = false;\n c.m_islandFlag = false;\n c.m_toiCount = 0;\n c.m_toi = 1.0;\n }\n }\n\n // Find TOI events and solve them.\n while (true) {\n // Find the first TOI.\n let minContact: Contact | null = null;\n let minAlpha = 1.0;\n\n for (let c = world.m_contactList; c; c = c.m_next) {\n // Is this contact disabled?\n if (c.isEnabled() == false) {\n continue;\n }\n\n // Prevent excessive sub-stepping.\n if (c.m_toiCount > Settings.maxSubSteps) {\n continue;\n }\n\n let alpha = 1.0;\n if (c.m_toiFlag) {\n // This contact has a valid cached TOI.\n alpha = c.m_toi;\n } else {\n const fA = c.getFixtureA();\n const fB = c.getFixtureB();\n\n // Is there a sensor?\n if (fA.isSensor() || fB.isSensor()) {\n continue;\n }\n\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n if (_ASSERT) console.assert(bA.isDynamic() || bB.isDynamic());\n\n const activeA = bA.isAwake() && !bA.isStatic();\n const activeB = bB.isAwake() && !bB.isStatic();\n\n // Is at least one body active (awake and dynamic or kinematic)?\n if (activeA == false && activeB == false) {\n continue;\n }\n\n const collideA = bA.isBullet() || !bA.isDynamic();\n const collideB = bB.isBullet() || !bB.isDynamic();\n\n // Are these two non-bullet dynamic bodies?\n if (collideA == false && collideB == false) {\n continue;\n }\n\n // Compute the TOI for this contact.\n // Put the sweeps onto the same time interval.\n let alpha0 = bA.m_sweep.alpha0;\n\n if (bA.m_sweep.alpha0 < bB.m_sweep.alpha0) {\n alpha0 = bB.m_sweep.alpha0;\n bA.m_sweep.advance(alpha0);\n } else if (bB.m_sweep.alpha0 < bA.m_sweep.alpha0) {\n alpha0 = bA.m_sweep.alpha0;\n bB.m_sweep.advance(alpha0);\n }\n\n if (_ASSERT) console.assert(alpha0 < 1.0);\n\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n\n const sweepA = bA.m_sweep;\n const sweepB = bB.m_sweep;\n\n // Compute the time of impact in interval [0, minTOI]\n input.proxyA.set(fA.getShape(), indexA);\n input.proxyB.set(fB.getShape(), indexB);\n input.sweepA.set(bA.m_sweep);\n input.sweepB.set(bB.m_sweep);\n input.tMax = 1.0;\n\n TimeOfImpact(output, input);\n\n // Beta is the fraction of the remaining portion of the [time?].\n const beta = output.t;\n if (output.state == TOIOutputState.e_touching) {\n alpha = math_min(alpha0 + (1.0 - alpha0) * beta, 1.0);\n } else {\n alpha = 1.0;\n }\n\n c.m_toi = alpha;\n c.m_toiFlag = true;\n }\n\n if (alpha < minAlpha) {\n // This is the minimum TOI found so far.\n minContact = c;\n minAlpha = alpha;\n }\n }\n\n if (minContact == null || 1.0 - 10.0 * EPSILON < minAlpha) {\n // No more TOI events. Done!\n world.m_stepComplete = true;\n break;\n }\n\n // Advance the bodies to the TOI.\n const fA = minContact.getFixtureA();\n const fB = minContact.getFixtureB();\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n backup1.set(bA.m_sweep);\n backup2.set(bB.m_sweep);\n\n bA.advance(minAlpha);\n bB.advance(minAlpha);\n\n // The TOI contact likely has some new contact points.\n minContact.update(world);\n minContact.m_toiFlag = false;\n ++minContact.m_toiCount;\n\n // Is the contact solid?\n if (minContact.isEnabled() == false || minContact.isTouching() == false) {\n // Restore the sweeps.\n minContact.setEnabled(false);\n bA.m_sweep.set(backup1);\n bB.m_sweep.set(backup2);\n bA.synchronizeTransform();\n bB.synchronizeTransform();\n continue;\n }\n\n bA.setAwake(true);\n bB.setAwake(true);\n\n // Build the island\n this.clear();\n this.addBody(bA);\n this.addBody(bB);\n this.addContact(minContact);\n\n bA.m_islandFlag = true;\n bB.m_islandFlag = true;\n minContact.m_islandFlag = true;\n\n // Get contacts on bodyA and bodyB.\n const bodies = [ bA, bB ];\n for (let i = 0; i < bodies.length; ++i) {\n const body = bodies[i];\n if (body.isDynamic()) {\n for (let ce = body.m_contactList; ce; ce = ce.next) {\n // if (this.m_bodyCount == this.m_bodyCapacity) { break; }\n // if (this.m_contactCount == this.m_contactCapacity) { break; }\n\n const contact = ce.contact;\n\n // Has this contact already been added to the island?\n if (contact.m_islandFlag) {\n continue;\n }\n\n // Only add if either is static, kinematic or bullet.\n const other = ce.other;\n if (other.isDynamic() && !body.isBullet() && !other.isBullet()) {\n continue;\n }\n\n // Skip sensors.\n const sensorA = contact.m_fixtureA.m_isSensor;\n const sensorB = contact.m_fixtureB.m_isSensor;\n if (sensorA || sensorB) {\n continue;\n }\n\n // Tentatively advance the body to the TOI.\n backup.set(other.m_sweep);\n if (other.m_islandFlag == false) {\n other.advance(minAlpha);\n }\n\n // Update the contact points\n contact.update(world);\n\n // Was the contact disabled by the user?\n // Are there contact points?\n if (contact.isEnabled() == false || contact.isTouching() == false) {\n other.m_sweep.set(backup);\n other.synchronizeTransform();\n continue;\n }\n\n // Add the contact to the island\n contact.m_islandFlag = true;\n this.addContact(contact);\n\n // Has the other body already been added to the island?\n if (other.m_islandFlag) {\n continue;\n }\n\n // Add the other body to the island.\n other.m_islandFlag = true;\n\n if (!other.isStatic()) {\n other.setAwake(true);\n }\n\n this.addBody(other);\n }\n }\n }\n\n s_subStep.reset((1.0 - minAlpha) * step.dt);\n s_subStep.dtRatio = 1.0;\n s_subStep.positionIterations = 20;\n s_subStep.velocityIterations = step.velocityIterations;\n s_subStep.warmStarting = false;\n\n this.solveIslandTOI(s_subStep, bA, bB);\n\n // Reset island flags and synchronize broad-phase proxies.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n body.m_islandFlag = false;\n\n if (!body.isDynamic()) {\n continue;\n }\n\n body.synchronizeFixtures();\n\n // Invalidate all contact TOIs on this displaced body.\n for (let ce = body.m_contactList; ce; ce = ce.next) {\n ce.contact.m_toiFlag = false;\n ce.contact.m_islandFlag = false;\n }\n }\n\n // Commit fixture proxy movements to the broad-phase so that new contacts\n // are created.\n // Also, some contacts can be destroyed.\n world.findNewContacts();\n\n if (world.m_subStepping) {\n world.m_stepComplete = false;\n break;\n }\n }\n }\n\n solveIslandTOI(subStep: TimeStep, toiA: Body, toiB: Body): void {\n\n // Initialize the body state.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n matrix.copyVec2(body.c_position.c, body.m_sweep.c);\n body.c_position.a = body.m_sweep.a;\n matrix.copyVec2(body.c_velocity.v, body.m_linearVelocity);\n body.c_velocity.w = body.m_angularVelocity;\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initConstraint(subStep);\n }\n\n // Solve position constraints.\n for (let i = 0; i < subStep.positionIterations; ++i) {\n let minSeparation = 0.0;\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n const separation = contact.solvePositionConstraintTOI(subStep, toiA, toiB);\n minSeparation = math_min(minSeparation, separation);\n }\n // We can't expect minSpeparation >= -Settings.linearSlop because we don't\n // push the separation above -Settings.linearSlop.\n const contactsOkay = minSeparation >= -1.5 * Settings.linearSlop;\n if (contactsOkay) {\n break;\n }\n }\n\n if (false) {\n // Is the new position really safe?\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const c = this.m_contacts[i];\n const fA = c.getFixtureA();\n const fB = c.getFixtureB();\n\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n\n const input = new DistanceInput();\n input.proxyA.set(fA.getShape(), indexA);\n input.proxyB.set(fB.getShape(), indexB);\n input.transformA.set(bA.getTransform());\n input.transformB.set(bB.getTransform());\n input.useRadii = false;\n\n const output = new DistanceOutput();\n const cache = new SimplexCache();\n Distance(output, cache, input);\n\n if (output.distance == 0 || cache.count == 3) {\n cache.count += 0;\n }\n }\n }\n\n // Leap of faith to new safe state.\n matrix.copyVec2(toiA.m_sweep.c0, toiA.c_position.c);\n toiA.m_sweep.a0 = toiA.c_position.a;\n matrix.copyVec2(toiB.m_sweep.c0, toiB.c_position.c);\n toiB.m_sweep.a0 = toiB.c_position.a;\n\n // No warm starting is needed for TOI events because warm\n // starting impulses were applied in the discrete solver.\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initVelocityConstraint(subStep);\n }\n\n // Solve velocity constraints.\n for (let i = 0; i < subStep.velocityIterations; ++i) {\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n contact.solveVelocityConstraint(subStep);\n }\n }\n\n // Don't store the TOI contact forces for warm starting\n // because they can be quite large.\n\n const h = subStep.dt;\n\n // Integrate positions\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.c_position.c);\n let a = body.c_position.a;\n matrix.copyVec2(v, body.c_velocity.v);\n let w = body.c_velocity.w;\n\n // Check for large velocities\n matrix.scaleVec2(translation, h, v);\n const translationLengthSqr = matrix.lengthSqrVec2(translation);\n if (translationLengthSqr > Settings.maxTranslationSquared) {\n const ratio = Settings.maxTranslation / math_sqrt(translationLengthSqr);\n matrix.mulVec2(v, ratio);\n }\n\n const rotation = h * w;\n if (rotation * rotation > Settings.maxRotationSquared) {\n const ratio = Settings.maxRotation / math_abs(rotation);\n w *= ratio;\n }\n\n // Integrate\n matrix.plusScaleVec2(c, h, v);\n a += h * w;\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n\n // Sync bodies\n matrix.copyVec2(body.m_sweep.c, c);\n body.m_sweep.a = a;\n matrix.copyVec2(body.m_linearVelocity, v);\n body.m_angularVelocity = w;\n body.synchronizeTransform();\n }\n\n this.postSolveIsland();\n }\n\n /** @internal */\n postSolveIsland(): void {\n for (let c = 0; c < this.m_contacts.length; ++c) {\n const contact = this.m_contacts[c];\n this.m_world.postSolve(contact, contact.m_impulse);\n }\n }\n}\n\n// @ts-ignore\nSolver.TimeStep = TimeStep;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A 2-by-2 matrix. Stored in column-major order.\n */\nexport class Mat22 {\n ex: Vec2;\n ey: Vec2;\n\n constructor(a: number, b: number, c: number, d: number);\n constructor(a: { x: number; y: number }, b: { x: number; y: number });\n constructor();\n constructor(a?, b?, c?, d?) {\n if (typeof a === \"object\" && a !== null) {\n this.ex = Vec2.clone(a);\n this.ey = Vec2.clone(b);\n } else if (typeof a === \"number\") {\n this.ex = Vec2.neo(a, c);\n this.ey = Vec2.neo(b, d);\n } else {\n this.ex = Vec2.zero();\n this.ey = Vec2.zero();\n }\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.ex) && Vec2.isValid(obj.ey);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Mat22.isValid(o), \"Invalid Mat22!\", o);\n }\n\n set(a: Mat22): void;\n set(a: Vec2Value, b: Vec2Value): void;\n set(a: number, b: number, c: number, d: number): void;\n set(a, b?, c?, d?): void {\n if (typeof a === \"number\" && typeof b === \"number\" && typeof c === \"number\"\n && typeof d === \"number\") {\n this.ex.setNum(a, c);\n this.ey.setNum(b, d);\n\n } else if (typeof a === \"object\" && typeof b === \"object\") {\n this.ex.setVec2(a);\n this.ey.setVec2(b);\n\n } else if (typeof a === \"object\") {\n if (_ASSERT) Mat22.assert(a);\n this.ex.setVec2(a.ex);\n this.ey.setVec2(a.ey);\n\n } else {\n if (_ASSERT) console.assert(false);\n }\n }\n\n setIdentity(): void {\n this.ex.x = 1.0;\n this.ey.x = 0.0;\n this.ex.y = 0.0;\n this.ey.y = 1.0;\n }\n\n setZero(): void {\n this.ex.x = 0.0;\n this.ey.x = 0.0;\n this.ex.y = 0.0;\n this.ey.y = 0.0;\n }\n\n getInverse(): Mat22 {\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const imx = new Mat22();\n imx.ex.x = det * d;\n imx.ey.x = -det * b;\n imx.ex.y = -det * c;\n imx.ey.y = det * a;\n return imx;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases.\n */\n solve(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const w = Vec2.zero();\n w.x = det * (d * v.x - b * v.y);\n w.y = det * (a * v.y - c * v.x);\n return w;\n }\n\n /**\n * Multiply a matrix times a vector. If a rotation matrix is provided, then this\n * transforms the vector from one frame to another.\n */\n static mul(mx: Mat22, my: Mat22): Mat22;\n static mul(mx: Mat22, v: Vec2Value): Vec2;\n static mul(mx, v) {\n if (v && \"x\" in v && \"y\" in v) {\n if (_ASSERT) Vec2.assert(v);\n const x = mx.ex.x * v.x + mx.ey.x * v.y;\n const y = mx.ex.y * v.x + mx.ey.y * v.y;\n return Vec2.neo(x, y);\n\n } else if (v && \"ex\" in v && \"ey\" in v) { // Mat22\n if (_ASSERT) Mat22.assert(v);\n // return new Mat22(Vec2.mul(mx, v.ex), Vec2.mul(mx, v.ey));\n const a = mx.ex.x * v.ex.x + mx.ey.x * v.ex.y;\n const b = mx.ex.x * v.ey.x + mx.ey.x * v.ey.y;\n const c = mx.ex.y * v.ex.x + mx.ey.y * v.ex.y;\n const d = mx.ex.y * v.ey.x + mx.ey.y * v.ey.y;\n return new Mat22(a, b, c, d);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulVec2(mx: Mat22, v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n const x = mx.ex.x * v.x + mx.ey.x * v.y;\n const y = mx.ex.y * v.x + mx.ey.y * v.y;\n return Vec2.neo(x, y);\n }\n\n static mulMat22(mx: Mat22, v: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(v);\n // return new Mat22(Vec2.mul(mx, v.ex), Vec2.mul(mx, v.ey));\n const a = mx.ex.x * v.ex.x + mx.ey.x * v.ex.y;\n const b = mx.ex.x * v.ey.x + mx.ey.x * v.ey.y;\n const c = mx.ex.y * v.ex.x + mx.ey.y * v.ex.y;\n const d = mx.ex.y * v.ey.x + mx.ey.y * v.ey.y;\n return new Mat22(a, b, c, d);\n }\n\n /**\n * Multiply a matrix transpose times a vector. If a rotation matrix is provided,\n * then this transforms the vector from one frame to another (inverse\n * transform).\n */\n static mulT(mx: Mat22, my: Mat22): Mat22;\n static mulT(mx: Mat22, v: Vec2Value): Vec2;\n static mulT(mx, v) {\n if (v && \"x\" in v && \"y\" in v) { // Vec2\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(Vec2.dot(v, mx.ex), Vec2.dot(v, mx.ey));\n\n } else if (v && \"ex\" in v && \"ey\" in v) { // Mat22\n if (_ASSERT) Mat22.assert(v);\n const c1 = Vec2.neo(Vec2.dot(mx.ex, v.ex), Vec2.dot(mx.ey, v.ex));\n const c2 = Vec2.neo(Vec2.dot(mx.ex, v.ey), Vec2.dot(mx.ey, v.ey));\n return new Mat22(c1, c2);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulTVec2(mx: Mat22, v: Vec2Value): Vec2 {\n if (_ASSERT) Mat22.assert(mx);\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(Vec2.dot(v, mx.ex), Vec2.dot(v, mx.ey));\n }\n\n static mulTMat22(mx: Mat22, v: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx);\n if (_ASSERT) Mat22.assert(v);\n const c1 = Vec2.neo(Vec2.dot(mx.ex, v.ex), Vec2.dot(mx.ey, v.ex));\n const c2 = Vec2.neo(Vec2.dot(mx.ex, v.ey), Vec2.dot(mx.ey, v.ey));\n return new Mat22(c1, c2);\n }\n\n static abs(mx: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx);\n return new Mat22(Vec2.abs(mx.ex), Vec2.abs(mx.ey));\n }\n\n static add(mx1: Mat22, mx2: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx1);\n if (_ASSERT) Mat22.assert(mx2);\n return new Mat22(Vec2.add(mx1.ex, mx2.ex), Vec2.add(mx1.ey, mx2.ey));\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { Vec2Value } from \"../common/Vec2\";\nimport { TransformValue } from \"../common/Transform\";\nimport { EPSILON } from \"../common/Math\";\n\n\n/** @internal */ const math_sqrt = Math.sqrt;\n\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const cA = matrix.vec2(0, 0);\n/** @internal */ const cB = matrix.vec2(0, 0);\n/** @internal */ const dist = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const clipPoint = matrix.vec2(0, 0);\n\nexport enum ManifoldType {\n e_unset = -1,\n e_circles = 0,\n e_faceA = 1,\n e_faceB = 2\n}\n\nexport enum ContactFeatureType {\n e_unset = -1,\n e_vertex = 0,\n e_face = 1\n}\n\n/**\n * This is used for determining the state of contact points.\n */\n export enum PointState {\n /** Point does not exist */\n nullState = 0,\n /** Point was added in the update */\n addState = 1,\n /** Point persisted across the update */\n persistState = 2,\n /** Point was removed in the update */\n removeState = 3\n}\n\n/**\n * Used for computing contact manifolds.\n */\n export class ClipVertex {\n v = matrix.vec2(0, 0);\n id: ContactID = new ContactID();\n\n set(o: ClipVertex): void {\n matrix.copyVec2(this.v, o.v);\n this.id.set(o.id);\n }\n recycle() {\n matrix.zeroVec2(this.v);\n this.id.recycle();\n }\n}\n\n/**\n * A manifold for two touching convex shapes. Manifolds are created in `evaluate`\n * method of Contact subclasses.\n *\n * Supported manifold types are e_faceA or e_faceB for clip point versus plane\n * with radius and e_circles point versus point with radius.\n *\n * We store contacts in this way so that position correction can account for\n * movement, which is critical for continuous physics. All contact scenarios\n * must be expressed in one of these types. This structure is stored across time\n * steps, so we keep it small.\n */\nexport class Manifold {\n type: ManifoldType;\n\n /**\n * Usage depends on manifold type:\n * - circles: not used\n * - faceA: the normal on polygonA\n * - faceB: the normal on polygonB\n */\n localNormal = matrix.vec2(0, 0);\n\n /**\n * Usage depends on manifold type:\n * - circles: the local center of circleA\n * - faceA: the center of faceA\n * - faceB: the center of faceB\n */\n localPoint = matrix.vec2(0, 0);\n\n /** The points of contact */\n points: ManifoldPoint[] = [ new ManifoldPoint(), new ManifoldPoint() ];\n\n /** The number of manifold points */\n pointCount: number = 0;\n\n set(that: Manifold): void {\n this.type = that.type;\n matrix.copyVec2(this.localNormal, that.localNormal);\n matrix.copyVec2(this.localPoint, that.localPoint);\n this.pointCount = that.pointCount;\n this.points[0].set(that.points[0]);\n this.points[1].set(that.points[1]);\n }\n\n recycle(): void {\n this.type = ManifoldType.e_unset;\n matrix.zeroVec2(this.localNormal);\n matrix.zeroVec2(this.localPoint);\n this.pointCount = 0;\n this.points[0].recycle();\n this.points[1].recycle();\n }\n\n /**\n * Evaluate the manifold with supplied transforms. This assumes modest motion\n * from the original state. This does not change the point count, impulses, etc.\n * The radii must come from the shapes that generated the manifold.\n */\n getWorldManifold(wm: WorldManifold | null, xfA: TransformValue, radiusA: number, xfB: TransformValue, radiusB: number): WorldManifold {\n if (this.pointCount == 0) {\n return wm;\n }\n\n wm = wm || new WorldManifold();\n\n wm.pointCount = this.pointCount;\n\n const normal = wm.normal;\n const points = wm.points;\n const separations = wm.separations;\n\n switch (this.type) {\n case ManifoldType.e_circles: {\n matrix.setVec2(normal, 1.0, 0.0);\n const manifoldPoint = this.points[0];\n matrix.transformVec2(pointA, xfA, this.localPoint);\n matrix.transformVec2(pointB, xfB, manifoldPoint.localPoint);\n matrix.subVec2(dist, pointB, pointA);\n const lengthSqr = matrix.lengthSqrVec2(dist);\n if (lengthSqr > EPSILON * EPSILON) {\n const length = math_sqrt(lengthSqr);\n matrix.scaleVec2(normal, 1 / length, dist);\n }\n matrix.combine2Vec2(cA, 1, pointA, radiusA, normal);\n matrix.combine2Vec2(cB, 1, pointB, -radiusB, normal);\n matrix.combine2Vec2(points[0], 0.5, cA, 0.5, cB);\n separations[0] = matrix.dotVec2(matrix.subVec2(temp, cB, cA), normal);\n break;\n }\n\n case ManifoldType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.localNormal);\n matrix.transformVec2(planePoint, xfA, this.localPoint);\n\n for (let i = 0; i < this.pointCount; ++i) {\n const manifoldPoint = this.points[i];\n matrix.transformVec2(clipPoint, xfB, manifoldPoint.localPoint);\n matrix.combine2Vec2(cA, 1, clipPoint, radiusA - matrix.dotVec2(matrix.subVec2(temp, clipPoint, planePoint), normal), normal);\n matrix.combine2Vec2(cB, 1, clipPoint, -radiusB, normal);\n matrix.combine2Vec2(points[i], 0.5, cA, 0.5, cB);\n separations[i] = matrix.dotVec2(matrix.subVec2(temp, cB, cA), normal);\n }\n break;\n }\n\n case ManifoldType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.localNormal);\n matrix.transformVec2(planePoint, xfB, this.localPoint);\n\n for (let i = 0; i < this.pointCount; ++i) {\n const manifoldPoint = this.points[i];\n matrix.transformVec2(clipPoint, xfA, manifoldPoint.localPoint);\n matrix.combine2Vec2(cB, 1, clipPoint, radiusB - matrix.dotVec2(matrix.subVec2(temp, clipPoint, planePoint), normal), normal);\n matrix.combine2Vec2(cA, 1, clipPoint, -radiusA, normal);\n matrix.combine2Vec2(points[i], 0.5, cA, 0.5, cB);\n separations[i] = matrix.dotVec2(matrix.subVec2(temp, cA, cB), normal);\n }\n // Ensure normal points from A to B.\n matrix.negVec2(normal);\n break;\n }\n }\n\n return wm;\n }\n\n static clipSegmentToLine = clipSegmentToLine;\n static ClipVertex = ClipVertex;\n static getPointStates = getPointStates;\n static PointState = PointState;\n}\n\n/**\n * A manifold point is a contact point belonging to a contact manifold. It holds\n * details related to the geometry and dynamics of the contact points.\n *\n * This structure is stored across time steps, so we keep it small.\n *\n * Note: impulses are used for internal caching and may not provide reliable\n * contact forces, especially for high speed collisions.\n */\nexport class ManifoldPoint {\n /**\n * Usage depends on manifold type:\n * - circles: the local center of circleB\n * - faceA: the local center of circleB or the clip point of polygonB\n * - faceB: the clip point of polygonA\n */\n localPoint = matrix.vec2(0, 0);\n /**\n * The non-penetration impulse\n */\n normalImpulse = 0;\n /**\n * The friction impulse\n */\n tangentImpulse = 0;\n /**\n * Uniquely identifies a contact point between two shapes to facilitate warm starting\n */\n readonly id = new ContactID();\n\n set(that: ManifoldPoint): void {\n matrix.copyVec2(this.localPoint, that.localPoint);\n this.normalImpulse = that.normalImpulse;\n this.tangentImpulse = that.tangentImpulse;\n this.id.set(that.id);\n }\n\n recycle(): void {\n matrix.zeroVec2(this.localPoint);\n this.normalImpulse = 0;\n this.tangentImpulse = 0;\n this.id.recycle();\n }\n}\n\n/**\n * Contact ids to facilitate warm starting.\n * \n * ContactFeature: The features that intersect to form the contact point.\n */\nexport class ContactID {\n\n /**\n * Used to quickly compare contact ids.\n */\n key = -1;\n\n /** ContactFeature index on shapeA */\n indexA = -1;\n\n /** ContactFeature index on shapeB */\n indexB = -1;\n\n /** ContactFeature type on shapeA */\n typeA = ContactFeatureType.e_unset;\n\n /** ContactFeature type on shapeB */\n typeB = ContactFeatureType.e_unset;\n\n setFeatures(indexA: number, typeA: ContactFeatureType, indexB: number, typeB: ContactFeatureType): void {\n this.indexA = indexA;\n this.indexB = indexB;\n this.typeA = typeA;\n this.typeB = typeB;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n set(that: ContactID): void {\n this.indexA = that.indexA;\n this.indexB = that.indexB;\n this.typeA = that.typeA;\n this.typeB = that.typeB;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n swapFeatures(): void {\n const indexA = this.indexA;\n const indexB = this.indexB;\n const typeA = this.typeA;\n const typeB = this.typeB;\n this.indexA = indexB;\n this.indexB = indexA;\n this.typeA = typeB;\n this.typeB = typeA;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n recycle(): void {\n this.indexA = 0;\n this.indexB = 0;\n this.typeA = ContactFeatureType.e_unset;\n this.typeB = ContactFeatureType.e_unset;\n this.key = -1;\n }\n}\n\n/**\n * This is used to compute the current state of a contact manifold.\n */\nexport class WorldManifold {\n /** World vector pointing from A to B */\n normal = matrix.vec2(0, 0);\n\n /** World contact point (point of intersection) */\n points = [matrix.vec2(0, 0), matrix.vec2(0, 0)]; // [maxManifoldPoints]\n\n /** A negative value indicates overlap, in meters */\n separations = [0, 0]; // [maxManifoldPoints]\n\n /** The number of manifold points */\n pointCount = 0;\n\n recycle() {\n matrix.zeroVec2(this.normal);\n matrix.zeroVec2(this.points[0]);\n matrix.zeroVec2(this.points[1]);\n this.separations[0] = 0;\n this.separations[1] = 0;\n this.pointCount = 0;\n }\n}\n\n/**\n * Compute the point states given two manifolds. The states pertain to the\n * transition from manifold1 to manifold2. So state1 is either persist or remove\n * while state2 is either add or persist.\n */\nexport function getPointStates(\n state1: PointState[],\n state2: PointState[],\n manifold1: Manifold,\n manifold2: Manifold\n): void {\n // state1, state2: PointState[Settings.maxManifoldPoints]\n\n // for (var i = 0; i < Settings.maxManifoldPoints; ++i) {\n // state1[i] = PointState.nullState;\n // state2[i] = PointState.nullState;\n // }\n\n // Detect persists and removes.\n for (let i = 0; i < manifold1.pointCount; ++i) {\n const id = manifold1.points[i].id;\n\n state1[i] = PointState.removeState;\n\n for (let j = 0; j < manifold2.pointCount; ++j) {\n if (manifold2.points[j].id.key === id.key) {\n state1[i] = PointState.persistState;\n break;\n }\n }\n }\n\n // Detect persists and adds.\n for (let i = 0; i < manifold2.pointCount; ++i) {\n const id = manifold2.points[i].id;\n\n state2[i] = PointState.addState;\n\n for (let j = 0; j < manifold1.pointCount; ++j) {\n if (manifold1.points[j].id.key === id.key) {\n state2[i] = PointState.persistState;\n break;\n }\n }\n }\n}\n\n/**\n * Clipping for contact manifolds. Sutherland-Hodgman clipping.\n */\nexport function clipSegmentToLine(\n vOut: ClipVertex[],\n vIn: ClipVertex[],\n normal: Vec2Value,\n offset: number,\n vertexIndexA: number\n): number {\n // Start with no output points\n let numOut = 0;\n\n // Calculate the distance of end points to the line\n const distance0 = matrix.dotVec2(normal, vIn[0].v) - offset;\n const distance1 = matrix.dotVec2(normal, vIn[1].v) - offset;\n\n // If the points are behind the plane\n if (distance0 <= 0.0)\n vOut[numOut++].set(vIn[0]);\n if (distance1 <= 0.0)\n vOut[numOut++].set(vIn[1]);\n\n // If the points are on different sides of the plane\n if (distance0 * distance1 < 0.0) {\n // Find intersection point of edge and plane\n const interp = distance0 / (distance0 - distance1);\n matrix.combine2Vec2(vOut[numOut].v, 1 - interp, vIn[0].v, interp, vIn[1].v);\n\n // VertexA is hitting edgeB.\n vOut[numOut].id.setFeatures(vertexIndexA, ContactFeatureType.e_vertex, vIn[0].id.indexB, ContactFeatureType.e_face);\n ++numOut;\n }\n\n return numOut;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { ShapeType } from \"../collision/Shape\";\nimport { clamp } from \"../common/Math\";\nimport { TransformValue } from \"../common/Transform\";\nimport { Mat22 } from \"../common/Mat22\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { Manifold, ManifoldType, WorldManifold } from \"../collision/Manifold\";\nimport { testOverlap } from \"../collision/Distance\";\nimport { Fixture } from \"./Fixture\";\nimport { Body } from \"./Body\";\nimport { ContactImpulse, TimeStep } from \"./Solver\";\nimport { Pool } from \"../util/Pool\";\nimport { getTransform } from \"./Position\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n// Solver debugging is normally disabled because the block solver sometimes has to deal with a poorly conditioned effective mass matrix.\n/** @internal */ const DEBUG_SOLVER = false;\n\n/** @internal */ const contactPool = new Pool({\n create() {\n return new Contact();\n },\n release(contact: Contact) {\n contact.recycle();\n }\n});\n\n/** @internal */ const oldManifold = new Manifold();\n\n/** @internal */ const worldManifold = new WorldManifold();\n\n/**\n * A contact edge is used to connect bodies and contacts together in a contact\n * graph where each body is a node and each contact is an edge. A contact edge\n * belongs to a doubly linked list maintained in each attached body. Each\n * contact has two contact nodes, one for each attached body.\n */\nexport class ContactEdge {\n contact: Contact;\n prev: ContactEdge | null = null;\n next: ContactEdge | null = null;\n other: Body | null = null;\n constructor(contact: Contact) {\n this.contact = contact;\n }\n\n /** @internal */\n recycle() {\n this.prev = null;\n this.next = null;\n this.other = null;\n }\n}\n\nexport type EvaluateFunction = (\n manifold: Manifold,\n xfA: TransformValue,\n fixtureA: Fixture,\n indexA: number,\n xfB: TransformValue,\n fixtureB: Fixture,\n indexB: number\n) => void;\n\n/**\n * Friction mixing law. The idea is to allow either fixture to drive the\n * friction to zero. For example, anything slides on ice.\n */\nexport function mixFriction(friction1: number, friction2: number): number {\n return math_sqrt(friction1 * friction2);\n}\n\n/**\n * Restitution mixing law. The idea is allow for anything to bounce off an\n * inelastic surface. For example, a superball bounces on anything.\n */\nexport function mixRestitution(restitution1: number, restitution2: number): number {\n return restitution1 > restitution2 ? restitution1 : restitution2;\n}\n\n// TODO: move this to Settings?\n/** @internal */ const s_registers = [];\n\n// TODO: merge with ManifoldPoint?\nexport class VelocityConstraintPoint {\n rA = matrix.vec2(0, 0);\n rB = matrix.vec2(0, 0);\n normalImpulse = 0;\n tangentImpulse = 0;\n normalMass = 0;\n tangentMass = 0;\n velocityBias = 0;\n\n recycle() {\n matrix.zeroVec2(this.rA);\n matrix.zeroVec2(this.rB);\n this.normalImpulse = 0;\n this.tangentImpulse = 0;\n this.normalMass = 0;\n this.tangentMass = 0;\n this.velocityBias = 0;\n }\n}\n\n/** @internal */ const cA = matrix.vec2(0, 0);\n/** @internal */ const vA = matrix.vec2(0, 0);\n/** @internal */ const cB = matrix.vec2(0, 0);\n/** @internal */ const vB = matrix.vec2(0, 0);\n/** @internal */ const tangent = matrix.vec2(0, 0);\n/** @internal */ const xfA = matrix.transform(0, 0, 0);\n/** @internal */ const xfB = matrix.transform(0, 0, 0);\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const clipPoint = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const rA = matrix.vec2(0, 0);\n/** @internal */ const rB = matrix.vec2(0, 0);\n/** @internal */ const P = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const point = matrix.vec2(0, 0);\n/** @internal */ const dv = matrix.vec2(0, 0);\n/** @internal */ const dv1 = matrix.vec2(0, 0);\n/** @internal */ const dv2 = matrix.vec2(0, 0);\n/** @internal */ const b = matrix.vec2(0, 0);\n/** @internal */ const a = matrix.vec2(0, 0);\n/** @internal */ const x = matrix.vec2(0, 0);\n/** @internal */ const d = matrix.vec2(0, 0);\n/** @internal */ const P1 = matrix.vec2(0, 0);\n/** @internal */ const P2 = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n\n/**\n * The class manages contact between two shapes. A contact exists for each\n * overlapping AABB in the broad-phase (except if filtered). Therefore a contact\n * object may exist that has no contact points.\n */\nexport class Contact {\n // Nodes for connecting bodies.\n /** @internal */ m_nodeA = new ContactEdge(this);\n /** @internal */ m_nodeB = new ContactEdge(this);\n /** @internal */ m_fixtureA: Fixture | null = null;\n /** @internal */ m_fixtureB: Fixture | null = null;\n /** @internal */ m_indexA = -1;\n /** @internal */ m_indexB = -1;\n /** @internal */ m_evaluateFcn: EvaluateFunction | null = null;\n /** @internal */ m_manifold: Manifold = new Manifold();\n /** @internal */ m_prev: Contact | null = null;\n /** @internal */ m_next: Contact | null = null;\n /** @internal */ m_toi = 1.0;\n /** @internal */ m_toiCount = 0;\n // This contact has a valid TOI in m_toi\n /** @internal */ m_toiFlag = false;\n /** @internal */ m_friction = 0.0;\n /** @internal */ m_restitution = 0.0;\n /** @internal */ m_tangentSpeed = 0.0;\n /** @internal This contact can be disabled (by user) */\n m_enabledFlag = true;\n /** @internal Used when crawling contact graph when forming islands. */\n m_islandFlag = false;\n /** @internal Set when the shapes are touching. */\n m_touchingFlag = false;\n /** @internal This contact needs filtering because a fixture filter was changed. */\n m_filterFlag = false;\n /** @internal This bullet contact had a TOI event */\n m_bulletHitFlag = false;\n\n /** @internal Contact reporting impulse object cache */\n m_impulse: ContactImpulse = new ContactImpulse(this);\n\n // VelocityConstraint\n /** @internal */ v_points = [new VelocityConstraintPoint(), new VelocityConstraintPoint()]; // [maxManifoldPoints];\n /** @internal */ v_normal = matrix.vec2(0, 0);\n /** @internal */ v_normalMass: Mat22 = new Mat22();\n /** @internal */ v_K: Mat22 = new Mat22();\n /** @internal */ v_pointCount = 0;\n /** @internal */ v_tangentSpeed = 0;\n /** @internal */ v_friction = 0;\n /** @internal */ v_restitution = 0;\n /** @internal */ v_invMassA = 0;\n /** @internal */ v_invMassB = 0;\n /** @internal */ v_invIA = 0;\n /** @internal */ v_invIB = 0;\n\n // PositionConstraint\n /** @internal */ p_localPoints = [matrix.vec2(0, 0), matrix.vec2(0, 0)]; // [maxManifoldPoints];\n /** @internal */ p_localNormal = matrix.vec2(0, 0);\n /** @internal */ p_localPoint = matrix.vec2(0, 0);\n /** @internal */ p_localCenterA = matrix.vec2(0, 0);\n /** @internal */ p_localCenterB = matrix.vec2(0, 0);\n /** @internal */ p_type = ManifoldType.e_unset;\n /** @internal */ p_radiusA = 0;\n /** @internal */ p_radiusB = 0;\n /** @internal */ p_pointCount = 0;\n /** @internal */ p_invMassA = 0;\n /** @internal */ p_invMassB = 0;\n /** @internal */ p_invIA = 0;\n /** @internal */ p_invIB = 0;\n\n /** @internal */ \n initialize(fA: Fixture, indexA: number, fB: Fixture, indexB: number, evaluateFcn: EvaluateFunction) {\n this.m_fixtureA = fA;\n this.m_fixtureB = fB;\n\n this.m_indexA = indexA;\n this.m_indexB = indexB;\n\n this.m_evaluateFcn = evaluateFcn;\n\n this.m_friction = mixFriction(this.m_fixtureA.m_friction, this.m_fixtureB.m_friction);\n this.m_restitution = mixRestitution(this.m_fixtureA.m_restitution, this.m_fixtureB.m_restitution);\n }\n\n /** @internal */ \n recycle() {\n this.m_nodeA.recycle();\n this.m_nodeB.recycle();\n this.m_fixtureA = null;\n this.m_fixtureB = null;\n this.m_indexA = -1;\n this.m_indexB = -1;\n this.m_evaluateFcn = null;\n this.m_manifold.recycle();\n this.m_prev = null;\n this.m_next = null;\n this.m_toi = 1;\n this.m_toiCount = 0;\n this.m_toiFlag = false;\n this.m_friction = 0;\n this.m_restitution = 0;\n this.m_tangentSpeed = 0;\n this.m_enabledFlag = true;\n this.m_islandFlag = false;\n this.m_touchingFlag = false;\n this.m_filterFlag = false;\n this.m_bulletHitFlag = false;\n\n this.m_impulse.recycle();\n\n // VelocityConstraint\n for(const point of this.v_points) {\n point.recycle();\n }\n matrix.zeroVec2(this.v_normal);\n this.v_normalMass.setZero();\n this.v_K.setZero();\n this.v_pointCount = 0;\n this.v_tangentSpeed = 0;\n this.v_friction = 0;\n this.v_restitution = 0;\n this.v_invMassA = 0;\n this.v_invMassB = 0;\n this.v_invIA = 0;\n this.v_invIB = 0;\n\n // PositionConstraint\n for(const point of this.p_localPoints) {\n matrix.zeroVec2(point);\n }\n matrix.zeroVec2(this.p_localNormal);\n matrix.zeroVec2(this.p_localPoint);\n matrix.zeroVec2(this.p_localCenterA);\n matrix.zeroVec2(this.p_localCenterB);\n this.p_type = ManifoldType.e_unset;\n this.p_radiusA = 0;\n this.p_radiusB = 0;\n this.p_pointCount = 0;\n this.p_invMassA = 0;\n this.p_invMassB = 0;\n this.p_invIA = 0;\n this.p_invIB = 0;\n }\n\n initConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n const manifold = this.m_manifold;\n\n const pointCount = manifold.pointCount;\n if (_ASSERT) console.assert(pointCount > 0);\n\n this.v_invMassA = bodyA.m_invMass;\n this.v_invMassB = bodyB.m_invMass;\n this.v_invIA = bodyA.m_invI;\n this.v_invIB = bodyB.m_invI;\n\n this.v_friction = this.m_friction;\n this.v_restitution = this.m_restitution;\n this.v_tangentSpeed = this.m_tangentSpeed;\n\n this.v_pointCount = pointCount;\n\n this.v_K.setZero();\n this.v_normalMass.setZero();\n\n this.p_invMassA = bodyA.m_invMass;\n this.p_invMassB = bodyB.m_invMass;\n this.p_invIA = bodyA.m_invI;\n this.p_invIB = bodyB.m_invI;\n matrix.copyVec2(this.p_localCenterA, bodyA.m_sweep.localCenter);\n matrix.copyVec2(this.p_localCenterB, bodyB.m_sweep.localCenter);\n\n this.p_radiusA = shapeA.m_radius;\n this.p_radiusB = shapeB.m_radius;\n\n this.p_type = manifold.type;\n matrix.copyVec2(this.p_localNormal, manifold.localNormal);\n matrix.copyVec2(this.p_localPoint, manifold.localPoint);\n this.p_pointCount = pointCount;\n\n for (let j = 0; j < Settings.maxManifoldPoints; ++j) {\n this.v_points[j].recycle();\n matrix.zeroVec2(this.p_localPoints[j]);\n }\n\n for (let j = 0; j < pointCount; ++j) {\n const cp = manifold.points[j];\n const vcp = this.v_points[j];\n if (step.warmStarting) {\n vcp.normalImpulse = step.dtRatio * cp.normalImpulse;\n vcp.tangentImpulse = step.dtRatio * cp.tangentImpulse;\n }\n matrix.copyVec2(this.p_localPoints[j], cp.localPoint);\n }\n }\n\n /**\n * Get the contact manifold. Do not modify the manifold unless you understand\n * the internals of the library.\n */\n getManifold(): Manifold {\n return this.m_manifold;\n }\n\n /**\n * Get the world manifold.\n */\n getWorldManifold(worldManifold: WorldManifold | null): WorldManifold | undefined {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n return this.m_manifold.getWorldManifold(\n worldManifold,\n bodyA.getTransform(), shapeA.m_radius,\n bodyB.getTransform(), shapeB.m_radius\n );\n }\n\n /**\n * Enable/disable this contact. This can be used inside the pre-solve contact\n * listener. The contact is only disabled for the current time step (or sub-step\n * in continuous collisions).\n */\n setEnabled(flag: boolean): void {\n this.m_enabledFlag = !!flag;\n }\n\n /**\n * Has this contact been disabled?\n */\n isEnabled(): boolean {\n return this.m_enabledFlag;\n }\n\n /**\n * Is this contact touching?\n */\n isTouching(): boolean {\n return this.m_touchingFlag;\n }\n\n /**\n * Get the next contact in the world's contact list.\n */\n getNext(): Contact | null {\n return this.m_next;\n }\n\n /**\n * Get fixture A in this contact.\n */\n getFixtureA(): Fixture {\n return this.m_fixtureA;\n }\n\n /**\n * Get fixture B in this contact.\n */\n getFixtureB(): Fixture {\n return this.m_fixtureB;\n }\n\n /**\n * Get the child primitive index for fixture A.\n */\n getChildIndexA(): number {\n return this.m_indexA;\n }\n\n /**\n * Get the child primitive index for fixture B.\n */\n getChildIndexB(): number {\n return this.m_indexB;\n }\n\n /**\n * Flag this contact for filtering. Filtering will occur the next time step.\n */\n flagForFiltering(): void {\n this.m_filterFlag = true;\n }\n\n /**\n * Override the default friction mixture. You can call this in\n * \"pre-solve\" callback. This value persists until set or reset.\n */\n setFriction(friction: number): void {\n this.m_friction = friction;\n }\n\n /**\n * Get the friction.\n */\n getFriction(): number {\n return this.m_friction;\n }\n\n /**\n * Reset the friction mixture to the default value.\n */\n resetFriction(): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_friction = mixFriction(fixtureA.m_friction, fixtureB.m_friction);\n }\n\n /**\n * Override the default restitution mixture. You can call this in\n * \"pre-solve\" callback. The value persists until you set or reset.\n */\n setRestitution(restitution: number): void {\n this.m_restitution = restitution;\n }\n\n /**\n * Get the restitution.\n */\n getRestitution(): number {\n return this.m_restitution;\n }\n\n /**\n * Reset the restitution to the default value.\n */\n resetRestitution(): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_restitution = mixRestitution(fixtureA.m_restitution, fixtureB.m_restitution);\n }\n\n /**\n * Set the desired tangent speed for a conveyor belt behavior. In meters per\n * second.\n */\n setTangentSpeed(speed: number): void {\n this.m_tangentSpeed = speed;\n }\n\n /**\n * Get the desired tangent speed. In meters per second.\n */\n getTangentSpeed(): number {\n return this.m_tangentSpeed;\n }\n\n /**\n * Called by Update method, and implemented by subclasses.\n */\n evaluate(manifold: Manifold, xfA: TransformValue, xfB: TransformValue): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_evaluateFcn(manifold, xfA, fixtureA, this.m_indexA, xfB, fixtureB, this.m_indexB);\n }\n\n /**\n * Updates the contact manifold and touching status.\n *\n * Note: do not assume the fixture AABBs are overlapping or are valid.\n *\n * @param listener.beginContact\n * @param listener.endContact\n * @param listener.preSolve\n */\n update(listener?: {\n beginContact(contact: Contact): void,\n endContact(contact: Contact): void,\n preSolve(contact: Contact, oldManifold: Manifold): void\n }): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n // Re-enable this contact.\n this.m_enabledFlag = true;\n\n let touching = false;\n const wasTouching = this.m_touchingFlag;\n\n const sensorA = fixtureA.m_isSensor;\n const sensorB = fixtureB.m_isSensor;\n const sensor = sensorA || sensorB;\n\n const xfA = bodyA.m_xf;\n const xfB = bodyB.m_xf;\n\n // Is this contact a sensor?\n if (sensor) {\n touching = testOverlap(shapeA, this.m_indexA, shapeB, this.m_indexB, xfA, xfB);\n\n // Sensors don't generate manifolds.\n this.m_manifold.pointCount = 0;\n } else {\n\n oldManifold.recycle();\n oldManifold.set(this.m_manifold);\n this.m_manifold.recycle();\n\n this.evaluate(this.m_manifold, xfA, xfB);\n touching = this.m_manifold.pointCount > 0;\n\n // Match old contact ids to new contact ids and copy the\n // stored impulses to warm start the solver.\n for (let i = 0; i < this.m_manifold.pointCount; ++i) {\n const nmp = this.m_manifold.points[i];\n nmp.normalImpulse = 0.0;\n nmp.tangentImpulse = 0.0;\n\n for (let j = 0; j < oldManifold.pointCount; ++j) {\n const omp = oldManifold.points[j];\n if (omp.id.key === nmp.id.key) {\n nmp.normalImpulse = omp.normalImpulse;\n nmp.tangentImpulse = omp.tangentImpulse;\n break;\n }\n }\n }\n\n if (touching !== wasTouching) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n }\n\n this.m_touchingFlag = touching;\n\n const hasListener = typeof listener === \"object\" && listener !== null;\n\n if (!wasTouching && touching && hasListener) {\n listener.beginContact(this);\n }\n\n if (wasTouching && !touching && hasListener) {\n listener.endContact(this);\n }\n\n if (!sensor && touching && hasListener && oldManifold) {\n listener.preSolve(this, oldManifold);\n }\n }\n\n solvePositionConstraint(step: TimeStep): number {\n return this._solvePositionConstraint(step, null, null);\n }\n\n solvePositionConstraintTOI(step: TimeStep, toiA: Body, toiB: Body): number {\n return this._solvePositionConstraint(step, toiA, toiB);\n }\n\n private _solvePositionConstraint(step: TimeStep, toiA: Body | null, toiB: Body | null): number {\n const toi = toiA !== null && toiB !== null ? true : false;\n let minSeparation = 0.0;\n\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return minSeparation;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return minSeparation;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const localCenterA = this.p_localCenterA;\n const localCenterB = this.p_localCenterB;\n\n let mA = 0.0;\n let iA = 0.0;\n if (!toi || (bodyA === toiA || bodyA === toiB)) {\n mA = this.p_invMassA;\n iA = this.p_invIA;\n }\n\n let mB = 0.0;\n let iB = 0.0;\n if (!toi || (bodyB === toiA || bodyB === toiB)) {\n mB = this.p_invMassB;\n iB = this.p_invIB;\n }\n\n matrix.copyVec2(cA, positionA.c);\n let aA = positionA.a;\n\n matrix.copyVec2(cB, positionB.c);\n let aB = positionB.a;\n\n // Solve normal constraints\n for (let j = 0; j < this.p_pointCount; ++j) {\n getTransform(xfA, localCenterA, cA, aA);\n getTransform(xfB, localCenterB, cB, aB);\n\n // PositionSolverManifold\n let separation: number;\n switch (this.p_type) {\n case ManifoldType.e_circles: {\n matrix.transformVec2(pointA, xfA, this.p_localPoint);\n matrix.transformVec2(pointB, xfB, this.p_localPoints[0]);\n matrix.subVec2(normal, pointB, pointA);\n matrix.normalizeVec2(normal);\n\n matrix.combine2Vec2(point, 0.5, pointA, 0.5, pointB);\n separation = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal) - this.p_radiusA - this.p_radiusB;\n break;\n }\n\n case ManifoldType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.p_localNormal);\n matrix.transformVec2(planePoint, xfA, this.p_localPoint);\n matrix.transformVec2(clipPoint, xfB, this.p_localPoints[j]);\n separation = matrix.dotVec2(clipPoint, normal) - matrix.dotVec2(planePoint, normal) - this.p_radiusA - this.p_radiusB;\n matrix.copyVec2(point, clipPoint);\n break;\n }\n\n case ManifoldType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.p_localNormal);\n matrix.transformVec2(planePoint, xfB, this.p_localPoint);\n matrix.transformVec2(clipPoint, xfA, this.p_localPoints[j]);\n separation = matrix.dotVec2(clipPoint, normal) - matrix.dotVec2(planePoint, normal) - this.p_radiusA - this.p_radiusB;\n matrix.copyVec2(point, clipPoint);\n\n // Ensure normal points from A to B\n matrix.negVec2(normal);\n break;\n }\n // todo: what should we do here?\n default: {\n return minSeparation;\n }\n }\n\n matrix.subVec2(rA, point, cA);\n matrix.subVec2(rB, point, cB);\n\n // Track max constraint error.\n minSeparation = math_min(minSeparation, separation);\n\n const baumgarte = toi ? Settings.toiBaugarte : Settings.baumgarte;\n const linearSlop = Settings.linearSlop;\n const maxLinearCorrection = Settings.maxLinearCorrection;\n\n // Prevent large corrections and allow slop.\n const C = clamp(baumgarte * (separation + linearSlop), -maxLinearCorrection, 0.0);\n\n // Compute the effective mass.\n const rnA = matrix.crossVec2Vec2(rA, normal);\n const rnB = matrix.crossVec2Vec2(rB, normal);\n const K = mA + mB + iA * rnA * rnA + iB * rnB * rnB;\n\n // Compute normal impulse\n const impulse = K > 0.0 ? -C / K : 0.0;\n\n matrix.scaleVec2(P, impulse, normal);\n\n matrix.minusScaleVec2(cA, mA, P);\n aA -= iA * matrix.crossVec2Vec2(rA, P);\n\n matrix.plusScaleVec2(cB, mB, P);\n aB += iB * matrix.crossVec2Vec2(rB, P);\n }\n\n matrix.copyVec2(positionA.c, cA);\n positionA.a = aA;\n\n matrix.copyVec2(positionB.c, cB);\n positionB.a = aB;\n\n return minSeparation;\n }\n\n initVelocityConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const radiusA = this.p_radiusA;\n const radiusB = this.p_radiusB;\n const manifold = this.m_manifold;\n\n const mA = this.v_invMassA;\n const mB = this.v_invMassB;\n const iA = this.v_invIA;\n const iB = this.v_invIB;\n const localCenterA = this.p_localCenterA;\n const localCenterB = this.p_localCenterB;\n\n matrix.copyVec2(cA, positionA.c);\n const aA = positionA.a;\n matrix.copyVec2(vA, velocityA.v);\n const wA = velocityA.w;\n\n matrix.copyVec2(cB, positionB.c);\n const aB = positionB.a;\n matrix.copyVec2(vB, velocityB.v);\n const wB = velocityB.w;\n\n if (_ASSERT) console.assert(manifold.pointCount > 0);\n\n getTransform(xfA, localCenterA, cA, aA);\n getTransform(xfB, localCenterB, cB, aB);\n\n worldManifold.recycle();\n manifold.getWorldManifold(worldManifold, xfA, radiusA, xfB, radiusB);\n\n matrix.copyVec2(this.v_normal, worldManifold.normal);\n\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n const wmp = worldManifold.points[j];\n\n matrix.subVec2(vcp.rA, wmp, cA);\n matrix.subVec2(vcp.rB, wmp, cB);\n\n const rnA = matrix.crossVec2Vec2(vcp.rA, this.v_normal);\n const rnB = matrix.crossVec2Vec2(vcp.rB, this.v_normal);\n\n const kNormal = mA + mB + iA * rnA * rnA + iB * rnB * rnB;\n\n vcp.normalMass = kNormal > 0.0 ? 1.0 / kNormal : 0.0;\n\n matrix.crossVec2Num(tangent, this.v_normal, 1.0);\n\n const rtA = matrix.crossVec2Vec2(vcp.rA, tangent);\n const rtB = matrix.crossVec2Vec2(vcp.rB, tangent);\n\n const kTangent = mA + mB + iA * rtA * rtA + iB * rtB * rtB;\n\n vcp.tangentMass = kTangent > 0.0 ? 1.0 / kTangent : 0.0;\n\n // Setup a velocity bias for restitution.\n vcp.velocityBias = 0.0;\n let vRel = 0;\n vRel += matrix.dotVec2(this.v_normal, vB);\n vRel += matrix.dotVec2(this.v_normal, matrix.crossNumVec2(temp, wB, vcp.rB));\n vRel -= matrix.dotVec2(this.v_normal, vA);\n vRel -= matrix.dotVec2(this.v_normal, matrix.crossNumVec2(temp, wA, vcp.rA));\n if (vRel < -Settings.velocityThreshold) {\n vcp.velocityBias = -this.v_restitution * vRel;\n }\n }\n\n // If we have two points, then prepare the block solver.\n if (this.v_pointCount == 2 && step.blockSolve) {\n const vcp1 = this.v_points[0]; // VelocityConstraintPoint\n const vcp2 = this.v_points[1]; // VelocityConstraintPoint\n\n const rn1A = matrix.crossVec2Vec2(vcp1.rA, this.v_normal);\n const rn1B = matrix.crossVec2Vec2(vcp1.rB, this.v_normal);\n const rn2A = matrix.crossVec2Vec2(vcp2.rA, this.v_normal);\n const rn2B = matrix.crossVec2Vec2(vcp2.rB, this.v_normal);\n\n const k11 = mA + mB + iA * rn1A * rn1A + iB * rn1B * rn1B;\n const k22 = mA + mB + iA * rn2A * rn2A + iB * rn2B * rn2B;\n const k12 = mA + mB + iA * rn1A * rn2A + iB * rn1B * rn2B;\n\n // Ensure a reasonable condition number.\n const k_maxConditionNumber = 1000.0;\n if (k11 * k11 < k_maxConditionNumber * (k11 * k22 - k12 * k12)) {\n // K is safe to invert.\n this.v_K.ex.setNum(k11, k12);\n this.v_K.ey.setNum(k12, k22);\n // this.v_normalMass.set(this.v_K.getInverse());\n const a = this.v_K.ex.x;\n const b = this.v_K.ey.x;\n const c = this.v_K.ex.y;\n const d = this.v_K.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n this.v_normalMass.ex.x = det * d;\n this.v_normalMass.ey.x = -det * b;\n this.v_normalMass.ex.y = -det * c;\n this.v_normalMass.ey.y = det * a;\n\n } else {\n // The constraints are redundant, just use one.\n // TODO_ERIN use deepest?\n this.v_pointCount = 1;\n }\n }\n\n matrix.copyVec2(positionA.c, cA);\n positionA.a = aA;\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n\n matrix.copyVec2(positionB.c, cB);\n positionB.a = aB;\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n warmStartConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const mA = this.v_invMassA;\n const iA = this.v_invIA;\n const mB = this.v_invMassB;\n const iB = this.v_invIB;\n\n matrix.copyVec2(vA, velocityA.v);\n let wA = velocityA.w;\n matrix.copyVec2(vB, velocityB.v);\n let wB = velocityB.w;\n\n matrix.copyVec2(normal, this.v_normal);\n matrix.crossVec2Num(tangent, normal, 1.0);\n\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n\n matrix.combine2Vec2(P, vcp.normalImpulse, normal, vcp.tangentImpulse, tangent);\n\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n matrix.minusScaleVec2(vA, mA, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n matrix.plusScaleVec2(vB, mB, P);\n }\n\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n storeConstraintImpulses(step: TimeStep): void {\n const manifold = this.m_manifold;\n for (let j = 0; j < this.v_pointCount; ++j) {\n manifold.points[j].normalImpulse = this.v_points[j].normalImpulse;\n manifold.points[j].tangentImpulse = this.v_points[j].tangentImpulse;\n }\n }\n\n solveVelocityConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const positionA = bodyA.c_position;\n\n const velocityB = bodyB.c_velocity;\n const positionB = bodyB.c_position;\n\n const mA = this.v_invMassA;\n const iA = this.v_invIA;\n const mB = this.v_invMassB;\n const iB = this.v_invIB;\n\n matrix.copyVec2(vA, velocityA.v);\n let wA = velocityA.w;\n matrix.copyVec2(vB, velocityB.v);\n let wB = velocityB.w;\n\n matrix.copyVec2(normal, this.v_normal);\n matrix.crossVec2Num(tangent, normal, 1.0);\n const friction = this.v_friction;\n\n if (_ASSERT) console.assert(this.v_pointCount == 1 || this.v_pointCount == 2);\n\n // Solve tangent constraints first because non-penetration is more important\n // than friction.\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n\n // Relative velocity at contact\n matrix.zeroVec2(dv);\n matrix.plusVec2(dv, vB);\n matrix.plusVec2(dv, matrix.crossNumVec2(temp, wB, vcp.rB));\n matrix.minusVec2(dv, vA);\n matrix.minusVec2(dv, matrix.crossNumVec2(temp, wA, vcp.rA));\n\n // Compute tangent force\n const vt = matrix.dotVec2(dv, tangent) - this.v_tangentSpeed;\n let lambda = vcp.tangentMass * (-vt);\n\n // Clamp the accumulated force\n const maxFriction = friction * vcp.normalImpulse;\n const newImpulse = clamp(vcp.tangentImpulse + lambda, -maxFriction, maxFriction);\n lambda = newImpulse - vcp.tangentImpulse;\n vcp.tangentImpulse = newImpulse;\n\n // Apply contact impulse\n matrix.scaleVec2(P, lambda, tangent);\n\n matrix.minusScaleVec2(vA, mA, P);\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n\n matrix.plusScaleVec2(vB, mB, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n }\n\n // Solve normal constraints\n if (this.v_pointCount == 1 || step.blockSolve == false) {\n for (let i = 0; i < this.v_pointCount; ++i) {\n const vcp = this.v_points[i]; // VelocityConstraintPoint\n\n // Relative velocity at contact\n matrix.zeroVec2(dv);\n matrix.plusVec2(dv, vB);\n matrix.plusVec2(dv, matrix.crossNumVec2(temp, wB, vcp.rB));\n matrix.minusVec2(dv, vA);\n matrix.minusVec2(dv, matrix.crossNumVec2(temp, wA, vcp.rA));\n\n // Compute normal impulse\n const vn = matrix.dotVec2(dv, normal);\n let lambda = -vcp.normalMass * (vn - vcp.velocityBias);\n\n // Clamp the accumulated impulse\n const newImpulse = math_max(vcp.normalImpulse + lambda, 0.0);\n lambda = newImpulse - vcp.normalImpulse;\n vcp.normalImpulse = newImpulse;\n\n // Apply contact impulse\n matrix.scaleVec2(P, lambda, normal);\n\n matrix.minusScaleVec2(vA, mA, P);\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n\n matrix.plusScaleVec2(vB, mB, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n }\n } else {\n // Block solver developed in collaboration with Dirk Gregorius (back in\n // 01/07 on Box2D_Lite).\n // Build the mini LCP for this contact patch\n //\n // vn = A * x + b, vn >= 0, x >= 0 and vn_i * x_i = 0 with i = 1..2\n //\n // A = J * W * JT and J = ( -n, -r1 x n, n, r2 x n )\n // b = vn0 - velocityBias\n //\n // The system is solved using the \"Total enumeration method\" (s. Murty).\n // The complementary constraint vn_i * x_i\n // implies that we must have in any solution either vn_i = 0 or x_i = 0.\n // So for the 2D contact problem the cases\n // vn1 = 0 and vn2 = 0, x1 = 0 and x2 = 0, x1 = 0 and vn2 = 0, x2 = 0 and\n // vn1 = 0 need to be tested. The first valid\n // solution that satisfies the problem is chosen.\n //\n // In order to account of the accumulated impulse 'a' (because of the\n // iterative nature of the solver which only requires\n // that the accumulated impulse is clamped and not the incremental\n // impulse) we change the impulse variable (x_i).\n //\n // Substitute:\n //\n // x = a + d\n //\n // a := old total impulse\n // x := new total impulse\n // d := incremental impulse\n //\n // For the current iteration we extend the formula for the incremental\n // impulse\n // to compute the new total impulse:\n //\n // vn = A * d + b\n // = A * (x - a) + b\n // = A * x + b - A * a\n // = A * x + b'\n // b' = b - A * a;\n\n const vcp1 = this.v_points[0]; // VelocityConstraintPoint\n const vcp2 = this.v_points[1]; // VelocityConstraintPoint\n\n matrix.setVec2(a, vcp1.normalImpulse, vcp2.normalImpulse);\n if (_ASSERT) console.assert(a.x >= 0.0 && a.y >= 0.0);\n\n // Relative velocity at contact\n // let dv1 = Vec2.zero().add(vB).add(Vec2.crossNumVec2(wB, vcp1.rB)).sub(vA).sub(Vec2.crossNumVec2(wA, vcp1.rA));\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n // let dv2 = Vec2.zero().add(vB).add(Vec2.crossNumVec2(wB, vcp2.rB)).sub(vA).sub(Vec2.crossNumVec2(wA, vcp2.rA));\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n let vn1 = matrix.dotVec2(dv1, normal);\n let vn2 = matrix.dotVec2(dv2, normal);\n\n matrix.setVec2(b, vn1 - vcp1.velocityBias, vn2 - vcp2.velocityBias);\n\n // Compute b'\n // b.sub(Mat22.mulVec2(this.v_K, a));\n b.x -= this.v_K.ex.x * a.x + this.v_K.ey.x * a.y;\n b.y -= this.v_K.ex.y * a.x + this.v_K.ey.y * a.y;\n\n const k_errorTol = 1e-3;\n // NOT_USED(k_errorTol);\n\n while (true) {\n //\n // Case 1: vn = 0\n //\n // 0 = A * x + b'\n //\n // Solve for x:\n //\n // x = - inv(A) * b'\n //\n // const x = Mat22.mulVec2(this.v_normalMass, b).neg();\n matrix.zeroVec2(x);\n x.x = -(this.v_normalMass.ex.x * b.x + this.v_normalMass.ey.x * b.y);\n x.y = -(this.v_normalMass.ex.y * b.x + this.v_normalMass.ey.y * b.y);\n\n if (x.x >= 0.0 && x.y >= 0.0) {\n // Get the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n vn1 = matrix.dotVec2(dv1, normal);\n vn2 = matrix.dotVec2(dv2, normal);\n\n if (_ASSERT) console.assert(math_abs(vn1 - vcp1.velocityBias) < k_errorTol);\n if (_ASSERT) console.assert(math_abs(vn2 - vcp2.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 2: vn1 = 0 and x2 = 0\n //\n // 0 = a11 * x1 + a12 * 0 + b1'\n // vn2 = a21 * x1 + a22 * 0 + b2'\n //\n x.x = -vcp1.normalMass * b.x;\n x.y = 0.0;\n vn1 = 0.0;\n vn2 = this.v_K.ex.y * x.x + b.y;\n\n if (x.x >= 0.0 && vn2 >= 0.0) {\n // Get the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n // Compute normal velocity\n vn1 = matrix.dotVec2(dv1, normal);\n\n if (_ASSERT) console.assert(math_abs(vn1 - vcp1.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 3: vn2 = 0 and x1 = 0\n //\n // vn1 = a11 * 0 + a12 * x2 + b1'\n // 0 = a21 * 0 + a22 * x2 + b2'\n //\n x.x = 0.0;\n x.y = -vcp2.normalMass * b.y;\n vn1 = this.v_K.ey.x * x.y + b.x;\n vn2 = 0.0;\n\n if (x.y >= 0.0 && vn1 >= 0.0) {\n // Resubstitute for the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n vn2 = matrix.dotVec2(dv2, normal);\n\n if (_ASSERT) console.assert(math_abs(vn2 - vcp2.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 4: x1 = 0 and x2 = 0\n //\n // vn1 = b1\n // vn2 = b2;\n //\n x.x = 0.0;\n x.y = 0.0;\n vn1 = b.x;\n vn2 = b.y;\n\n if (vn1 >= 0.0 && vn2 >= 0.0) {\n // Resubstitute for the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n break;\n }\n\n // No solution, give up. This is hit sometimes, but it doesn't seem to\n // matter.\n break;\n }\n }\n\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n /** @internal */\n static addType(type1: ShapeType, type2: ShapeType, callback: EvaluateFunction): void {\n s_registers[type1] = s_registers[type1] || {};\n s_registers[type1][type2] = callback;\n }\n\n /** @internal */\n static create(fixtureA: Fixture, indexA: number, fixtureB: Fixture, indexB: number): Contact | null {\n const typeA = fixtureA.m_shape.m_type;\n const typeB = fixtureB.m_shape.m_type;\n\n const contact = contactPool.allocate();\n let evaluateFcn;\n if (evaluateFcn = s_registers[typeA] && s_registers[typeA][typeB]) {\n contact.initialize(fixtureA, indexA, fixtureB, indexB, evaluateFcn);\n } else if (evaluateFcn = s_registers[typeB] && s_registers[typeB][typeA]) {\n contact.initialize(fixtureB, indexB, fixtureA, indexA, evaluateFcn);\n } else {\n return null;\n }\n\n // Contact creation may swap fixtures.\n fixtureA = contact.m_fixtureA;\n fixtureB = contact.m_fixtureB;\n indexA = contact.getChildIndexA();\n indexB = contact.getChildIndexB();\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n\n // Connect to body A\n contact.m_nodeA.contact = contact;\n contact.m_nodeA.other = bodyB;\n\n contact.m_nodeA.prev = null;\n contact.m_nodeA.next = bodyA.m_contactList;\n if (bodyA.m_contactList != null) {\n bodyA.m_contactList.prev = contact.m_nodeA;\n }\n bodyA.m_contactList = contact.m_nodeA;\n\n // Connect to body B\n contact.m_nodeB.contact = contact;\n contact.m_nodeB.other = bodyA;\n\n contact.m_nodeB.prev = null;\n contact.m_nodeB.next = bodyB.m_contactList;\n if (bodyB.m_contactList != null) {\n bodyB.m_contactList.prev = contact.m_nodeB;\n }\n bodyB.m_contactList = contact.m_nodeB;\n\n // Wake up the bodies\n if (fixtureA.isSensor() == false && fixtureB.isSensor() == false) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n\n return contact;\n }\n\n /** @internal */\n static destroy(contact: Contact, listener: { endContact: (contact: Contact) => void }): void {\n const fixtureA = contact.m_fixtureA;\n const fixtureB = contact.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n if (contact.isTouching()) {\n listener.endContact(contact);\n }\n\n // Remove from body 1\n if (contact.m_nodeA.prev) {\n contact.m_nodeA.prev.next = contact.m_nodeA.next;\n }\n\n if (contact.m_nodeA.next) {\n contact.m_nodeA.next.prev = contact.m_nodeA.prev;\n }\n\n if (contact.m_nodeA == bodyA.m_contactList) {\n bodyA.m_contactList = contact.m_nodeA.next;\n }\n\n // Remove from body 2\n if (contact.m_nodeB.prev) {\n contact.m_nodeB.prev.next = contact.m_nodeB.next;\n }\n\n if (contact.m_nodeB.next) {\n contact.m_nodeB.next.prev = contact.m_nodeB.prev;\n }\n\n if (contact.m_nodeB == bodyB.m_contactList) {\n bodyB.m_contactList = contact.m_nodeB.next;\n }\n\n if (contact.m_manifold.pointCount > 0 && !fixtureA.m_isSensor && !fixtureB.m_isSensor) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n\n // const typeA = fixtureA.getType();\n // const typeB = fixtureB.getType();\n\n // const destroyFcn = s_registers[typeA][typeB].destroyFcn;\n // if (typeof destroyFcn === 'function') {\n // destroyFcn(contact);\n // }\n\n contactPool.release(contact);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../util/options\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { BroadPhase } from \"../collision/BroadPhase\";\nimport { Solver, ContactImpulse, TimeStep } from \"./Solver\";\nimport { Body, BodyDef } from \"./Body\";\nimport { Joint } from \"./Joint\";\nimport { Contact } from \"./Contact\";\nimport { AABBValue, RayCastInput, RayCastOutput } from \"../collision/AABB\";\nimport { Fixture, FixtureProxy } from \"./Fixture\";\nimport { Manifold } from \"../collision/Manifold\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\nexport interface WorldDef {\n /** [default: { x : 0, y : 0}] */\n gravity?: Vec2Value;\n\n /** [default: true] */\n allowSleep?: boolean;\n\n /** [default: true] */\n warmStarting?: boolean;\n\n /** [default: true] */\n continuousPhysics?: boolean;\n\n /** [default: false] */\n subStepping?: boolean;\n\n /** [default: true] */\n blockSolve?: boolean;\n\n /** @internal [8] For the velocity constraint solver. */\n velocityIterations?: number;\n\n /** @internal [3] For the position constraint solver. */\n positionIterations?: number;\n}\n\n/** @internal */ const DEFAULTS: WorldDef = {\n gravity : Vec2.zero(),\n allowSleep : true,\n warmStarting : true,\n continuousPhysics : true,\n subStepping : false,\n blockSolve : true,\n velocityIterations : 8,\n positionIterations : 3\n};\n\n/**\n * Callback function for ray casts, see {@link World.rayCast}.\n *\n * Called for each fixture found in the query.\n * The returned value replaces the ray-cast input maxFraction.\n * You control how the ray cast proceeds by returning a numeric/float value.\n * \n * - `0` to terminate the ray cast\n * - `fraction` to clip the ray cast at current point\n * - `1` don't clip the ray and continue\n * - `-1` (or anything else) to continue\n *\n * @param fixture The fixture hit by the ray\n * @param point The point of initial intersection\n * @param normal The normal vector at the point of intersection\n * @param fraction The fraction along the ray at the point of intersection\n *\n * @returns A number to update the maxFraction\n */\nexport type WorldRayCastCallback = (fixture: Fixture, point: Vec2, normal: Vec2, fraction: number) => number;\n\n/**\n * Called for each fixture found in the query AABB. It may return `false` to terminate the query.\n */\nexport type WorldAABBQueryCallback = (fixture: Fixture) => boolean;\n\ndeclare module \"./World\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(deg: WorldDef): World;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(gravity: Vec2): World;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(): World;\n}\n\n/**\n * The `World` class contains the bodies and joints. It manages all aspects\n * of the simulation and allows for asynchronous queries (like AABB queries\n * and ray-casts). Much of your interactions with Planck.js will be with a\n * World object.\n */\n// @ts-expect-error\nexport class World {\n /** @internal */ m_solver: Solver;\n /** @internal */ m_broadPhase: BroadPhase;\n /** @internal */ m_contactList: Contact | null;\n /** @internal */ m_contactCount: number;\n /** @internal */ m_bodyList: Body | null;\n /** @internal */ m_bodyCount: number;\n /** @internal */ m_jointList: Joint | null;\n /** @internal */ m_jointCount: number;\n /** @internal */ m_stepComplete: boolean;\n /** @internal */ m_allowSleep: boolean;\n /** @internal */ m_gravity: Vec2;\n /** @internal */ m_clearForces: boolean;\n /** @internal */ m_newFixture: boolean;\n /** @internal */ m_locked: boolean;\n /** @internal */ m_warmStarting: boolean;\n /** @internal */ m_continuousPhysics: boolean;\n /** @internal */ m_subStepping: boolean;\n /** @internal */ m_blockSolve: boolean;\n /** @internal */ m_velocityIterations: number;\n /** @internal */ m_positionIterations: number;\n /** @internal */ m_t: number;\n\n /** @internal */ m_step_callback: ((world: World) => unknown)[];\n\n // TODO\n /** @internal */ _listeners: {\n [key: string]: any[]\n };\n\n /**\n * @param def World definition or gravity vector.\n */\n constructor(def?: WorldDef | Vec2Value) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof World)) {\n return new World(def);\n }\n\n this.s_step = new TimeStep();\n\n\n if (!def) {\n def = {};\n } else if (Vec2.isValid(def)) {\n def = { gravity: def as Vec2 };\n }\n\n def = options(def, DEFAULTS) as WorldDef;\n\n this.m_solver = new Solver(this);\n\n this.m_broadPhase = new BroadPhase();\n\n this.m_contactList = null;\n this.m_contactCount = 0;\n\n this.m_bodyList = null;\n this.m_bodyCount = 0;\n\n this.m_jointList = null;\n this.m_jointCount = 0;\n\n this.m_stepComplete = true;\n\n this.m_allowSleep = def.allowSleep;\n this.m_gravity = Vec2.clone(def.gravity);\n\n this.m_clearForces = true;\n this.m_newFixture = false;\n this.m_locked = false;\n\n // These are for debugging the solver.\n this.m_warmStarting = def.warmStarting;\n this.m_continuousPhysics = def.continuousPhysics;\n this.m_subStepping = def.subStepping;\n\n this.m_blockSolve = def.blockSolve;\n this.m_velocityIterations = def.velocityIterations;\n this.m_positionIterations = def.positionIterations;\n\n this.m_t = 0;\n\n this.m_step_callback = [];\n }\n\n /** @internal */\n _serialize(): object {\n const bodies = [];\n const joints = [];\n\n for (let b = this.getBodyList(); b; b = b.getNext()) {\n bodies.push(b);\n }\n\n for (let j = this.getJointList(); j; j = j.getNext()) {\n // @ts-ignore\n if (typeof j._serialize === \"function\") {\n joints.push(j);\n }\n }\n\n return {\n gravity: this.m_gravity,\n bodies,\n joints,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, context: any, restore: any): World {\n if (!data) {\n return new World();\n }\n\n const world = new World(data.gravity);\n\n if (data.bodies) {\n for (let i = data.bodies.length - 1; i >= 0; i -= 1) {\n world._addBody(restore(Body, data.bodies[i], world));\n }\n }\n\n if (data.joints) {\n for (let i = data.joints.length - 1; i >= 0; i--) {\n world.createJoint(restore(Joint, data.joints[i], world));\n }\n }\n\n return world;\n }\n\n /**\n * Get the world body list. With the returned body, use Body.getNext to get the\n * next body in the world list. A null body indicates the end of the list.\n *\n * @return the head of the world body list.\n */\n getBodyList(): Body | null {\n return this.m_bodyList;\n }\n\n /**\n * Get the world joint list. With the returned joint, use Joint.getNext to get\n * the next joint in the world list. A null joint indicates the end of the list.\n *\n * @return the head of the world joint list.\n */\n getJointList(): Joint | null {\n return this.m_jointList;\n }\n\n /**\n * Get the world contact list. With the returned contact, use Contact.getNext to\n * get the next contact in the world list. A null contact indicates the end of\n * the list.\n *\n * Warning: contacts are created and destroyed in the middle of a time step.\n * Use ContactListener to avoid missing contacts.\n *\n * @return the head of the world contact list.\n */\n getContactList(): Contact | null {\n return this.m_contactList;\n }\n\n getBodyCount(): number {\n return this.m_bodyCount;\n }\n\n getJointCount(): number {\n return this.m_jointCount;\n }\n\n /**\n * Get the number of contacts (each may have 0 or more contact points).\n */\n getContactCount(): number {\n return this.m_contactCount;\n }\n\n /**\n * Change the global gravity vector.\n */\n setGravity(gravity: Vec2Value): void {\n this.m_gravity.set(gravity);\n }\n\n /**\n * Get the global gravity vector.\n */\n getGravity(): Vec2 {\n return this.m_gravity;\n }\n\n /**\n * Is the world locked (in the middle of a time step).\n */\n isLocked(): boolean {\n return this.m_locked;\n }\n\n /**\n * Enable/disable sleep.\n */\n setAllowSleeping(flag: boolean): void {\n if (flag == this.m_allowSleep) {\n return;\n }\n\n this.m_allowSleep = flag;\n if (this.m_allowSleep == false) {\n for (let b = this.m_bodyList; b; b = b.m_next) {\n b.setAwake(true);\n }\n }\n }\n\n getAllowSleeping(): boolean {\n return this.m_allowSleep;\n }\n\n /**\n * Enable/disable warm starting. For testing.\n */\n setWarmStarting(flag: boolean): void {\n this.m_warmStarting = flag;\n }\n\n getWarmStarting(): boolean {\n return this.m_warmStarting;\n }\n\n /**\n * Enable/disable continuous physics. For testing.\n */\n setContinuousPhysics(flag: boolean): void {\n this.m_continuousPhysics = flag;\n }\n\n getContinuousPhysics(): boolean {\n return this.m_continuousPhysics;\n }\n\n /**\n * Enable/disable single stepped continuous physics. For testing.\n */\n setSubStepping(flag: boolean): void {\n this.m_subStepping = flag;\n }\n\n getSubStepping(): boolean {\n return this.m_subStepping;\n }\n\n /**\n * Set flag to control automatic clearing of forces after each time step.\n */\n setAutoClearForces(flag: boolean): void {\n this.m_clearForces = flag;\n }\n\n /**\n * Get the flag that controls automatic clearing of forces after each time step.\n */\n getAutoClearForces(): boolean {\n return this.m_clearForces;\n }\n\n /**\n * Manually clear the force buffer on all bodies. By default, forces are cleared\n * automatically after each call to step. The default behavior is modified by\n * calling setAutoClearForces. The purpose of this function is to support\n * sub-stepping. Sub-stepping is often used to maintain a fixed sized time step\n * under a variable frame-rate. When you perform sub-stepping you will disable\n * auto clearing of forces and instead call clearForces after all sub-steps are\n * complete in one pass of your game loop.\n *\n * See {@link World.setAutoClearForces}\n */\n clearForces(): void {\n for (let body = this.m_bodyList; body; body = body.getNext()) {\n body.m_force.setZero();\n body.m_torque = 0.0;\n }\n }\n\n /**\n * Query the world for all fixtures that potentially overlap the provided AABB.\n *\n * @param aabb The query box.\n * @param callback Called for each fixture found in the query AABB. It may return `false` to terminate the query.\n */\n queryAABB(aabb: AABBValue, callback: WorldAABBQueryCallback): void {\n if (_ASSERT) console.assert(typeof callback === \"function\");\n const broadPhase = this.m_broadPhase;\n this.m_broadPhase.query(aabb, function(proxyId: number): boolean { // TODO GC\n const proxy = broadPhase.getUserData(proxyId);\n return callback(proxy.fixture);\n });\n }\n\n /**\n * Ray-cast the world for all fixtures in the path of the ray. Your callback\n * controls whether you get the closest point, any point, or n-points. The\n * ray-cast ignores shapes that contain the starting point.\n *\n * @param point1 The ray starting point\n * @param point2 The ray ending point\n * @param callback A function that is called for each fixture that is hit by the ray. You control how the ray cast proceeds by returning a numeric/float value.\n */\n rayCast(point1: Vec2Value, point2: Vec2Value, callback: WorldRayCastCallback): void {\n if (_ASSERT) console.assert(typeof callback === \"function\");\n const broadPhase = this.m_broadPhase;\n\n this.m_broadPhase.rayCast({\n maxFraction : 1.0,\n p1 : point1,\n p2 : point2\n }, function(input: RayCastInput, proxyId: number): number { // TODO GC\n const proxy = broadPhase.getUserData(proxyId);\n const fixture = proxy.fixture;\n const index = proxy.childIndex;\n // @ts-ignore\n const output: RayCastOutput = {}; // TODO GC\n const hit = fixture.rayCast(output, input, index);\n if (hit) {\n const fraction = output.fraction;\n const point = Vec2.add(Vec2.mulNumVec2((1.0 - fraction), input.p1), Vec2.mulNumVec2(fraction, input.p2));\n return callback(fixture, point, output.normal, fraction);\n }\n return input.maxFraction;\n });\n }\n\n /**\n * Get the number of broad-phase proxies.\n */\n getProxyCount(): number {\n return this.m_broadPhase.getProxyCount();\n }\n\n /**\n * Get the height of broad-phase dynamic tree.\n */\n getTreeHeight(): number {\n return this.m_broadPhase.getTreeHeight();\n }\n\n /**\n * Get the balance of broad-phase dynamic tree.\n */\n getTreeBalance(): number {\n return this.m_broadPhase.getTreeBalance();\n }\n\n /**\n * Get the quality metric of broad-phase dynamic tree. The smaller the better.\n * The minimum is 1.\n */\n getTreeQuality(): number {\n return this.m_broadPhase.getTreeQuality();\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The body shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return;\n }\n\n for (let b = this.m_bodyList; b; b = b.m_next) {\n b.m_xf.p.sub(newOrigin);\n b.m_sweep.c0.sub(newOrigin);\n b.m_sweep.c.sub(newOrigin);\n }\n\n for (let j = this.m_jointList; j; j = j.m_next) {\n j.shiftOrigin(newOrigin);\n }\n\n this.m_broadPhase.shiftOrigin(newOrigin);\n }\n\n /** @internal Used for deserialize. */\n _addBody(body: Body): void {\n if (_ASSERT) console.assert(this.isLocked() === false);\n if (this.isLocked()) {\n return;\n }\n\n // Add to world doubly linked list.\n body.m_prev = null;\n body.m_next = this.m_bodyList;\n if (this.m_bodyList) {\n this.m_bodyList.m_prev = body;\n }\n this.m_bodyList = body;\n ++this.m_bodyCount;\n }\n\n /**\n * Create a rigid body given a definition. No reference to the definition is\n * retained.\n *\n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n createBody(def?: BodyDef): Body;\n createBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createBody(arg1?, arg2?) {\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return null;\n }\n\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n\n const body = new Body(this, def);\n this._addBody(body);\n return body;\n }\n\n createDynamicBody(def?: BodyDef): Body;\n createDynamicBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createDynamicBody(arg1?, arg2?) {\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n def.type = \"dynamic\";\n return this.createBody(def);\n }\n\n createKinematicBody(def?: BodyDef): Body;\n createKinematicBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createKinematicBody(arg1?, arg2?) {\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n def.type = \"kinematic\";\n return this.createBody(def);\n }\n\n /**\n * Destroy a body from the world.\n *\n * Warning: This automatically deletes all associated shapes and joints.\n *\n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n destroyBody(b: Body): boolean {\n if (_ASSERT) console.assert(this.m_bodyCount > 0);\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return;\n }\n\n if (b.m_destroyed) {\n return false;\n }\n\n // Delete the attached joints.\n let je = b.m_jointList;\n while (je) {\n const je0 = je;\n je = je.next;\n\n this.publish(\"remove-joint\", je0.joint);\n this.destroyJoint(je0.joint);\n\n b.m_jointList = je;\n }\n b.m_jointList = null;\n\n // Delete the attached contacts.\n let ce = b.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n\n this.destroyContact(ce0.contact);\n\n b.m_contactList = ce;\n }\n b.m_contactList = null;\n\n // Delete the attached fixtures. This destroys broad-phase proxies.\n let f = b.m_fixtureList;\n while (f) {\n const f0 = f;\n f = f.m_next;\n\n this.publish(\"remove-fixture\", f0);\n f0.destroyProxies(this.m_broadPhase);\n\n b.m_fixtureList = f;\n }\n b.m_fixtureList = null;\n\n // Remove world body list.\n if (b.m_prev) {\n b.m_prev.m_next = b.m_next;\n }\n\n if (b.m_next) {\n b.m_next.m_prev = b.m_prev;\n }\n\n if (b == this.m_bodyList) {\n this.m_bodyList = b.m_next;\n }\n\n b.m_destroyed = true;\n\n --this.m_bodyCount;\n\n this.publish(\"remove-body\", b);\n\n return true;\n }\n\n /**\n * Create a joint to constrain bodies together. No reference to the definition\n * is retained. This may cause the connected bodies to cease colliding.\n *\n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n createJoint(joint: T): T | null {\n if (_ASSERT) console.assert(!!joint.m_bodyA);\n if (_ASSERT) console.assert(!!joint.m_bodyB);\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return null;\n }\n\n // Connect to the world list.\n joint.m_prev = null;\n joint.m_next = this.m_jointList;\n if (this.m_jointList) {\n this.m_jointList.m_prev = joint;\n }\n this.m_jointList = joint;\n ++this.m_jointCount;\n\n // Connect to the bodies' doubly linked lists.\n joint.m_edgeA.joint = joint;\n joint.m_edgeA.other = joint.m_bodyB;\n joint.m_edgeA.prev = null;\n joint.m_edgeA.next = joint.m_bodyA.m_jointList;\n if (joint.m_bodyA.m_jointList)\n joint.m_bodyA.m_jointList.prev = joint.m_edgeA;\n joint.m_bodyA.m_jointList = joint.m_edgeA;\n\n joint.m_edgeB.joint = joint;\n joint.m_edgeB.other = joint.m_bodyA;\n joint.m_edgeB.prev = null;\n joint.m_edgeB.next = joint.m_bodyB.m_jointList;\n if (joint.m_bodyB.m_jointList)\n joint.m_bodyB.m_jointList.prev = joint.m_edgeB;\n joint.m_bodyB.m_jointList = joint.m_edgeB;\n\n // If the joint prevents collisions, then flag any contacts for filtering.\n if (joint.m_collideConnected == false) {\n for (let edge = joint.m_bodyB.getContactList(); edge; edge = edge.next) {\n if (edge.other == joint.m_bodyA) {\n // Flag the contact for filtering at the next time step (where either\n // body is awake).\n edge.contact.flagForFiltering();\n }\n }\n }\n\n // Note: creating a joint doesn't wake the bodies.\n\n return joint;\n }\n\n /**\n * Destroy a joint.\n * \n * Warning: This may cause the connected bodies to begin colliding.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n destroyJoint(joint: Joint): void {\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return;\n }\n\n // Remove from the doubly linked list.\n if (joint.m_prev) {\n joint.m_prev.m_next = joint.m_next;\n }\n\n if (joint.m_next) {\n joint.m_next.m_prev = joint.m_prev;\n }\n\n if (joint == this.m_jointList) {\n this.m_jointList = joint.m_next;\n }\n\n // Disconnect from bodies.\n const bodyA = joint.m_bodyA;\n const bodyB = joint.m_bodyB;\n\n // Wake up connected bodies.\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n\n // Remove from body 1.\n if (joint.m_edgeA.prev) {\n joint.m_edgeA.prev.next = joint.m_edgeA.next;\n }\n\n if (joint.m_edgeA.next) {\n joint.m_edgeA.next.prev = joint.m_edgeA.prev;\n }\n\n if (joint.m_edgeA == bodyA.m_jointList) {\n bodyA.m_jointList = joint.m_edgeA.next;\n }\n\n joint.m_edgeA.prev = null;\n joint.m_edgeA.next = null;\n\n // Remove from body 2\n if (joint.m_edgeB.prev) {\n joint.m_edgeB.prev.next = joint.m_edgeB.next;\n }\n\n if (joint.m_edgeB.next) {\n joint.m_edgeB.next.prev = joint.m_edgeB.prev;\n }\n\n if (joint.m_edgeB == bodyB.m_jointList) {\n bodyB.m_jointList = joint.m_edgeB.next;\n }\n\n joint.m_edgeB.prev = null;\n joint.m_edgeB.next = null;\n\n if (_ASSERT) console.assert(this.m_jointCount > 0);\n --this.m_jointCount;\n\n // If the joint prevents collisions, then flag any contacts for filtering.\n if (joint.m_collideConnected == false) {\n let edge = bodyB.getContactList();\n while (edge) {\n if (edge.other == bodyA) {\n // Flag the contact for filtering at the next time step (where either\n // body is awake).\n edge.contact.flagForFiltering();\n }\n\n edge = edge.next;\n }\n }\n\n this.publish(\"remove-joint\", joint);\n }\n\n /** @internal */\n s_step: TimeStep; // reuse\n\n /**\n * Take a time step. This performs collision detection, integration, and\n * constraint solution.\n *\n * Broad-phase, narrow-phase, solve and solve time of impacts.\n *\n * @param timeStep Time step, this should not vary.\n */\n step(timeStep: number, velocityIterations?: number, positionIterations?: number): void {\n this.publish(\"pre-step\", timeStep);\n\n if ((velocityIterations | 0) !== velocityIterations) {\n // TODO: remove this in future\n velocityIterations = 0;\n }\n\n velocityIterations = velocityIterations || this.m_velocityIterations;\n positionIterations = positionIterations || this.m_positionIterations;\n\n // If new fixtures were added, we need to find the new contacts.\n if (this.m_newFixture) {\n this.findNewContacts();\n this.m_newFixture = false;\n }\n\n this.m_locked = true;\n\n this.s_step.reset(timeStep);\n this.s_step.velocityIterations = velocityIterations;\n this.s_step.positionIterations = positionIterations;\n this.s_step.warmStarting = this.m_warmStarting;\n this.s_step.blockSolve = this.m_blockSolve;\n\n // Update contacts. This is where some contacts are destroyed.\n this.updateContacts();\n\n // Integrate velocities, solve velocity constraints, and integrate positions.\n if (this.m_stepComplete && timeStep > 0.0) {\n this.m_solver.solveWorld(this.s_step);\n\n // Synchronize fixtures, check for out of range bodies.\n for (let b = this.m_bodyList; b; b = b.getNext()) {\n // If a body was not in an island then it did not move.\n if (b.m_islandFlag == false) {\n continue;\n }\n\n if (b.isStatic()) {\n continue;\n }\n\n // Update fixtures (for broad-phase).\n b.synchronizeFixtures();\n }\n // Look for new contacts.\n this.findNewContacts();\n }\n\n // Handle TOI events.\n if (this.m_continuousPhysics && timeStep > 0.0) {\n this.m_solver.solveWorldTOI(this.s_step);\n }\n\n if (this.m_clearForces) {\n this.clearForces();\n }\n\n this.m_locked = false;\n\n let callback: (world: World) => unknown;\n while(callback = this.m_step_callback.shift()) {\n callback(this);\n }\n\n this.publish(\"post-step\", timeStep);\n }\n\n /**\n * Queue a function to be called after ongoing simulation step. If no simulation is in progress call it immediately.\n */\n queueUpdate(callback: (world: World) => unknown): void {\n if (!this.isLocked()) {\n callback(this);\n } else {\n this.m_step_callback.push(callback);\n }\n }\n\n /**\n * @internal\n * Call this method to find new contacts.\n */\n findNewContacts(): void {\n this.m_broadPhase.updatePairs(\n (proxyA: FixtureProxy, proxyB: FixtureProxy) => this.createContact(proxyA, proxyB)\n );\n }\n\n /**\n * @internal\n * Callback for broad-phase.\n */\n createContact(proxyA: FixtureProxy, proxyB: FixtureProxy): void {\n const fixtureA = proxyA.fixture;\n const fixtureB = proxyB.fixture;\n\n const indexA = proxyA.childIndex;\n const indexB = proxyB.childIndex;\n\n const bodyA = fixtureA.getBody();\n const bodyB = fixtureB.getBody();\n\n // Are the fixtures on the same body?\n if (bodyA == bodyB) {\n return;\n }\n\n // TODO_ERIN use a hash table to remove a potential bottleneck when both\n // bodies have a lot of contacts.\n // Does a contact already exist?\n let edge = bodyB.getContactList(); // ContactEdge\n while (edge) {\n if (edge.other == bodyA) {\n const fA = edge.contact.getFixtureA();\n const fB = edge.contact.getFixtureB();\n const iA = edge.contact.getChildIndexA();\n const iB = edge.contact.getChildIndexB();\n\n if (fA == fixtureA && fB == fixtureB && iA == indexA && iB == indexB) {\n // A contact already exists.\n return;\n }\n\n if (fA == fixtureB && fB == fixtureA && iA == indexB && iB == indexA) {\n // A contact already exists.\n return;\n }\n }\n\n edge = edge.next;\n }\n\n if (bodyB.shouldCollide(bodyA) == false) {\n return;\n }\n if (fixtureB.shouldCollide(fixtureA) == false) {\n return;\n }\n\n // Call the factory.\n const contact = Contact.create(fixtureA, indexA, fixtureB, indexB);\n if (contact == null) {\n return;\n }\n\n // Insert into the world.\n contact.m_prev = null;\n if (this.m_contactList != null) {\n contact.m_next = this.m_contactList;\n this.m_contactList.m_prev = contact;\n }\n this.m_contactList = contact;\n\n ++this.m_contactCount;\n }\n\n /**\n * @internal\n * Removes old non-overlapping contacts, applies filters and updates contacts.\n */\n updateContacts(): void {\n // Update awake contacts.\n let c: Contact;\n let next_c = this.m_contactList;\n while (c = next_c) {\n next_c = c.getNext();\n const fixtureA = c.getFixtureA();\n const fixtureB = c.getFixtureB();\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n const bodyA = fixtureA.getBody();\n const bodyB = fixtureB.getBody();\n\n // Is this contact flagged for filtering?\n if (c.m_filterFlag) {\n if (bodyB.shouldCollide(bodyA) == false) {\n this.destroyContact(c);\n continue;\n }\n\n if (fixtureB.shouldCollide(fixtureA) == false) {\n this.destroyContact(c);\n continue;\n }\n\n // Clear the filtering flag.\n c.m_filterFlag = false;\n }\n\n const activeA = bodyA.isAwake() && !bodyA.isStatic();\n const activeB = bodyB.isAwake() && !bodyB.isStatic();\n\n // At least one body must be awake and it must be dynamic or kinematic.\n if (activeA == false && activeB == false) {\n continue;\n }\n\n const proxyIdA = fixtureA.m_proxies[indexA].proxyId;\n const proxyIdB = fixtureB.m_proxies[indexB].proxyId;\n const overlap = this.m_broadPhase.testOverlap(proxyIdA, proxyIdB);\n\n // Here we destroy contacts that cease to overlap in the broad-phase.\n if (overlap == false) {\n this.destroyContact(c);\n continue;\n }\n\n // The contact persists.\n c.update(this);\n }\n }\n\n /** @internal */\n destroyContact(contact: Contact): void {\n // Remove from the world.\n if (contact.m_prev) {\n contact.m_prev.m_next = contact.m_next;\n }\n if (contact.m_next) {\n contact.m_next.m_prev = contact.m_prev;\n }\n if (contact == this.m_contactList) {\n this.m_contactList = contact.m_next;\n }\n\n Contact.destroy(contact, this);\n\n --this.m_contactCount;\n }\n\n\n /**\n * Called when two fixtures begin to touch.\n *\n * Implement contact callbacks to get contact information. You can use these\n * results for things like sounds and game logic. You can also get contact\n * results by traversing the contact lists after the time step. However, you\n * might miss some contacts because continuous physics leads to sub-stepping.\n * Additionally you may receive multiple callbacks for the same contact in a\n * single time step. You should strive to make your callbacks efficient because\n * there may be many callbacks per time step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"begin-contact\", listener: (contact: Contact) => void): World;\n /**\n * Called when two fixtures cease to touch.\n *\n * Implement contact callbacks to get contact information. You can use these\n * results for things like sounds and game logic. You can also get contact\n * results by traversing the contact lists after the time step. However, you\n * might miss some contacts because continuous physics leads to sub-stepping.\n * Additionally you may receive multiple callbacks for the same contact in a\n * single time step. You should strive to make your callbacks efficient because\n * there may be many callbacks per time step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"end-contact\", listener: (contact: Contact) => void): World;\n /**\n * This is called after a contact is updated. This allows you to inspect a\n * contact before it goes to the solver. If you are careful, you can modify the\n * contact manifold (e.g. disable contact). A copy of the old manifold is\n * provided so that you can detect changes. Note: this is called only for awake\n * bodies. Note: this is called even when the number of contact points is zero.\n * Note: this is not called for sensors. Note: if you set the number of contact\n * points to zero, you will not get an end-contact callback. However, you may get\n * a begin-contact callback the next step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"pre-solve\", listener: (contact: Contact, oldManifold: Manifold) => void): World;\n /**\n * This lets you inspect a contact after the solver is finished. This is useful\n * for inspecting impulses. Note: the contact manifold does not include time of\n * impact impulses, which can be arbitrarily large if the sub-step is small.\n * Hence the impulse is provided explicitly in a separate data structure. Note:\n * this is only called for contacts that are touching, solid, and awake.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"post-solve\", listener: (contact: Contact, impulse: ContactImpulse) => void): World;\n /** Listener is called whenever a body is removed. */\n on(name: \"remove-body\", listener: (body: Body) => void): World;\n /** Listener is called whenever a joint is removed implicitly or explicitly. */\n on(name: \"remove-joint\", listener: (joint: Joint) => void): World;\n /** Listener is called whenever a fixture is removed implicitly or explicitly. */\n on(name: \"remove-fixture\", listener: (fixture: Fixture) => void): World;\n /**\n * Register an event listener.\n */\n // tslint:disable-next-line:typedef\n on(name, listener) {\n if (typeof name !== \"string\" || typeof listener !== \"function\") {\n return this;\n }\n if (!this._listeners) {\n this._listeners = {};\n }\n if (!this._listeners[name]) {\n this._listeners[name] = [];\n }\n this._listeners[name].push(listener);\n return this;\n }\n\n off(name: \"begin-contact\", listener: (contact: Contact) => void): World;\n off(name: \"end-contact\", listener: (contact: Contact) => void): World;\n off(name: \"pre-solve\", listener: (contact: Contact, oldManifold: Manifold) => void): World;\n off(name: \"post-solve\", listener: (contact: Contact, impulse: ContactImpulse) => void): World;\n off(name: \"remove-body\", listener: (body: Body) => void): World;\n off(name: \"remove-joint\", listener: (joint: Joint) => void): World;\n off(name: \"remove-fixture\", listener: (fixture: Fixture) => void): World;\n /**\n * Remove an event listener.\n */\n // tslint:disable-next-line:typedef\n off(name, listener) {\n if (typeof name !== \"string\" || typeof listener !== \"function\") {\n return this;\n }\n const listeners = this._listeners && this._listeners[name];\n if (!listeners || !listeners.length) {\n return this;\n }\n const index = listeners.indexOf(listener);\n if (index >= 0) {\n listeners.splice(index, 1);\n }\n return this;\n }\n\n publish(name: string, arg1?: any, arg2?: any, arg3?: any): number {\n const listeners = this._listeners && this._listeners[name];\n if (!listeners || !listeners.length) {\n return 0;\n }\n for (let l = 0; l < listeners.length; l++) {\n listeners[l].call(this, arg1, arg2, arg3);\n }\n return listeners.length;\n }\n\n /** @internal */\n beginContact(contact: Contact): void {\n this.publish(\"begin-contact\", contact);\n }\n\n /** @internal */\n endContact(contact: Contact): void {\n this.publish(\"end-contact\", contact);\n }\n\n /** @internal */\n preSolve(contact: Contact, oldManifold: Manifold): void {\n this.publish(\"pre-solve\", contact, oldManifold);\n }\n\n /** @internal */\n postSolve(contact: Contact, impulse: ContactImpulse): void {\n this.publish(\"post-solve\", contact, impulse);\n }\n\n /**\n * Joints and fixtures are destroyed when their associated body is destroyed.\n * Register a destruction listener so that you may nullify references to these\n * joints and shapes.\n *\n * `function(object)` is called when any joint or fixture is about to\n * be destroyed due to the destruction of one of its attached or parent bodies.\n */\n\n /**\n * Register a contact filter to provide specific control over collision.\n * Otherwise the default filter is used (defaultFilter). The listener is owned\n * by you and must remain in scope.\n *\n * Moved to Fixture.\n */\n}","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/** 3D vector */\nexport interface Vec3Value {\n x: number;\n y: number;\n z: number;\n}\n\ndeclare module \"./Vec3\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(x: number, y: number, z: number): Vec3;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(obj: Vec3Value): Vec3;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(): Vec3;\n}\n\n/** 3D vector */\n// @ts-expect-error\nexport class Vec3 {\n x: number;\n y: number;\n z: number;\n\n constructor(x: number, y: number, z: number);\n constructor(obj: Vec3Value);\n constructor();\n constructor(x?, y?, z?) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Vec3)) {\n return new Vec3(x, y, z);\n }\n if (typeof x === \"undefined\") {\n this.x = 0;\n this.y = 0;\n this.z = 0;\n } else if (typeof x === \"object\") {\n this.x = x.x;\n this.y = x.y;\n this.z = x.z;\n } else {\n this.x = x;\n this.y = y;\n this.z = z;\n }\n if (_ASSERT) Vec3.assert(this);\n }\n\n /** @internal */\n _serialize(): object {\n return {\n x: this.x,\n y: this.y,\n z: this.z\n };\n }\n\n /** @internal */\n static _deserialize(data: any): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = data.x;\n obj.y = data.y;\n obj.z = data.z;\n return obj;\n }\n\n /** @hidden */\n static neo(x: number, y: number, z: number): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = x;\n obj.y = y;\n obj.z = z;\n return obj;\n }\n\n static zero(): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = 0;\n obj.y = 0;\n obj.z = 0;\n return obj;\n }\n\n static clone(v: Vec3Value): Vec3 {\n if (_ASSERT) Vec3.assert(v);\n return Vec3.neo(v.x, v.y, v.z);\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n /** Does this vector contain finite coordinates? */\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.x) && Number.isFinite(obj.y) && Number.isFinite(obj.z);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Vec3.isValid(o), \"Invalid Vec3!\", o);\n }\n\n setZero(): Vec3 {\n this.x = 0.0;\n this.y = 0.0;\n this.z = 0.0;\n return this;\n }\n\n set(x: number, y: number, z: number): Vec3 {\n this.x = x;\n this.y = y;\n this.z = z;\n return this;\n }\n\n add(w: Vec3Value): Vec3 {\n this.x += w.x;\n this.y += w.y;\n this.z += w.z;\n return this;\n }\n\n sub(w: Vec3Value): Vec3 {\n this.x -= w.x;\n this.y -= w.y;\n this.z -= w.z;\n return this;\n }\n\n mul(m: number): Vec3 {\n this.x *= m;\n this.y *= m;\n this.z *= m;\n return this;\n }\n\n static areEqual(v: Vec3Value, w: Vec3Value): boolean {\n if (_ASSERT) Vec3.assert(v);\n if (_ASSERT) Vec3.assert(w);\n return v === w ||\n typeof v === \"object\" && v !== null &&\n typeof w === \"object\" && w !== null &&\n v.x === w.x && v.y === w.y && v.z === w.z;\n }\n\n /** Dot product on two vectors */\n static dot(v: Vec3Value, w: Vec3Value): number {\n return v.x * w.x + v.y * w.y + v.z * w.z;\n }\n\n /** Cross product on two vectors */\n static cross(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(\n v.y * w.z - v.z * w.y,\n v.z * w.x - v.x * w.z,\n v.x * w.y - v.y * w.x\n );\n }\n\n static add(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(v.x + w.x, v.y + w.y, v.z + w.z);\n }\n\n static sub(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(v.x - w.x, v.y - w.y, v.z - w.z);\n }\n\n static mul(v: Vec3Value, m: number): Vec3 {\n return new Vec3(m * v.x, m * v.y, m * v.z);\n }\n\n neg(): Vec3 {\n this.x = -this.x;\n this.y = -this.y;\n this.z = -this.z;\n return this;\n }\n\n static neg(v: Vec3Value): Vec3 {\n return new Vec3(-v.x, -v.y, -v.z);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport * as matrix from \"../../common/Matrix\";\nimport { Shape } from \"../Shape\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { AABB, AABBValue, RayCastInput, RayCastOutput } from \"../AABB\";\nimport { MassData } from \"../../dynamics/Body\";\nimport { DistanceProxy } from \"../Distance\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const v2 = matrix.vec2(0, 0);\n\ndeclare module \"./EdgeShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function EdgeShape(v1?: Vec2Value, v2?: Vec2Value): EdgeShape;\n}\n\n/**\n * A line segment (edge) shape. These can be connected in chains or loops to\n * other edge shapes. The connectivity information is used to ensure correct\n * contact normals.\n */\n// @ts-expect-error\nexport class EdgeShape extends Shape {\n static TYPE = \"edge\" as const;\n /** @hidden */ m_type: \"edge\";\n\n /** @hidden */ m_radius: number;\n\n // These are the edge vertices\n /** @hidden */ m_vertex1: Vec2;\n /** @hidden */ m_vertex2: Vec2;\n\n // Optional adjacent vertices. These are used for smooth collision.\n // Used by chain shape.\n /** @hidden */ m_vertex0: Vec2;\n /** @hidden */ m_vertex3: Vec2;\n /** @hidden */ m_hasVertex0: boolean;\n /** @hidden */ m_hasVertex3: boolean;\n\n constructor(v1?: Vec2Value, v2?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof EdgeShape)) {\n return new EdgeShape(v1, v2);\n }\n\n super();\n\n this.m_type = EdgeShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n\n this.m_vertex1 = v1 ? Vec2.clone(v1) : Vec2.zero();\n this.m_vertex2 = v2 ? Vec2.clone(v2) : Vec2.zero();\n\n this.m_vertex0 = Vec2.zero();\n this.m_vertex3 = Vec2.zero();\n this.m_hasVertex0 = false;\n this.m_hasVertex3 = false;\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n vertex1: this.m_vertex1,\n vertex2: this.m_vertex2,\n\n vertex0: this.m_vertex0,\n vertex3: this.m_vertex3,\n hasVertex0: this.m_hasVertex0,\n hasVertex3: this.m_hasVertex3,\n };\n }\n\n /** @internal */\n static _deserialize(data: any): EdgeShape {\n const shape = new EdgeShape(data.vertex1, data.vertex2);\n if (shape.m_hasVertex0) {\n shape.setPrevVertex(data.vertex0);\n }\n if (shape.m_hasVertex3) {\n shape.setNextVertex(data.vertex3);\n }\n return shape;\n }\n\n /** @hidden */\n _reset(): void {\n // noop\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n getType(): \"edge\" {\n return this.m_type;\n }\n\n /** @internal @deprecated */\n setNext(v?: Vec2Value): EdgeShape {\n return this.setNextVertex(v);\n }\n\n /**\n * Optional next vertex, used for smooth collision.\n */\n setNextVertex(v?: Vec2Value): EdgeShape {\n if (v) {\n this.m_vertex3.setVec2(v);\n this.m_hasVertex3 = true;\n } else {\n this.m_vertex3.setZero();\n this.m_hasVertex3 = false;\n }\n return this;\n }\n\n /**\n * Optional next vertex, used for smooth collision.\n */\n getNextVertex(): Vec2 {\n return this.m_vertex3;\n }\n\n /** @internal @deprecated */\n setPrev(v?: Vec2Value): EdgeShape {\n return this.setPrevVertex(v);\n }\n\n /**\n * Optional prev vertex, used for smooth collision.\n */\n setPrevVertex(v?: Vec2Value): EdgeShape {\n if (v) {\n this.m_vertex0.setVec2(v);\n this.m_hasVertex0 = true;\n } else {\n this.m_vertex0.setZero();\n this.m_hasVertex0 = false;\n }\n return this;\n }\n\n /**\n * Optional prev vertex, used for smooth collision.\n */\n getPrevVertex(): Vec2 {\n return this.m_vertex0;\n }\n\n /**\n * Set this as an isolated edge.\n */\n _set(v1: Vec2Value, v2: Vec2Value): EdgeShape {\n this.m_vertex1.setVec2(v1);\n this.m_vertex2.setVec2(v2);\n this.m_hasVertex0 = false;\n this.m_hasVertex3 = false;\n return this;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): EdgeShape {\n const clone = new EdgeShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_vertex1.setVec2(this.m_vertex1);\n clone.m_vertex2.setVec2(this.m_vertex2);\n clone.m_vertex0.setVec2(this.m_vertex0);\n clone.m_vertex3.setVec2(this.m_vertex3);\n clone.m_hasVertex0 = this.m_hasVertex0;\n clone.m_hasVertex3 = this.m_hasVertex3;\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): false {\n return false;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n // p = p1 + t * d\n // v = v1 + s * e\n // p1 + t * d = v1 + s * e\n // s * e - t * d = p1 - v1\n\n // NOT_USED(childIndex);\n\n // Put the ray into the edge's frame of reference.\n const p1 = Rot.mulTVec2(xf.q, Vec2.sub(input.p1, xf.p));\n const p2 = Rot.mulTVec2(xf.q, Vec2.sub(input.p2, xf.p));\n const d = Vec2.sub(p2, p1);\n\n const v1 = this.m_vertex1;\n const v2 = this.m_vertex2;\n const e = Vec2.sub(v2, v1);\n const normal = Vec2.neo(e.y, -e.x);\n normal.normalize();\n\n // q = p1 + t * d\n // dot(normal, q - v1) = 0\n // dot(normal, p1 - v1) + t * dot(normal, d) = 0\n const numerator = Vec2.dot(normal, Vec2.sub(v1, p1));\n const denominator = Vec2.dot(normal, d);\n\n if (denominator == 0.0) {\n return false;\n }\n\n const t = numerator / denominator;\n if (t < 0.0 || input.maxFraction < t) {\n return false;\n }\n\n const q = Vec2.add(p1, Vec2.mulNumVec2(t, d));\n\n // q = v1 + s * r\n // s = dot(q - v1, r) / dot(r, r)\n const r = Vec2.sub(v2, v1);\n const rr = Vec2.dot(r, r);\n if (rr == 0.0) {\n return false;\n }\n\n const s = Vec2.dot(Vec2.sub(q, v1), r) / rr;\n if (s < 0.0 || 1.0 < s) {\n return false;\n }\n\n output.fraction = t;\n if (numerator > 0.0) {\n output.normal = Rot.mulVec2(xf.q, normal).neg();\n } else {\n output.normal = Rot.mulVec2(xf.q, normal);\n }\n return true;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n matrix.transformVec2(v1, xf, this.m_vertex1);\n matrix.transformVec2(v2, xf, this.m_vertex2);\n\n AABB.combinePoints(aabb, v1, v2);\n AABB.extend(aabb, this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density?: number): void {\n massData.mass = 0.0;\n matrix.combine2Vec2(massData.center, 0.5, this.m_vertex1, 0.5, this.m_vertex2);\n massData.I = 0.0;\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n proxy.m_vertices[0] = this.m_vertex1;\n proxy.m_vertices[1] = this.m_vertex2;\n proxy.m_vertices.length = 2;\n proxy.m_count = 2;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Edge = EdgeShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport type { MassData } from \"../../dynamics/Body\";\nimport { AABBValue, RayCastOutput, RayCastInput, AABB } from \"../AABB\";\nimport { DistanceProxy } from \"../Distance\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Shape } from \"../Shape\";\nimport { EdgeShape } from \"./EdgeShape\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const v2 = matrix.vec2(0, 0);\n\ndeclare module \"./ChainShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function ChainShape(vertices?: Vec2Value[], loop?: boolean): ChainShape;\n}\n\n/**\n * A chain shape is a free form sequence of line segments. The chain has\n * two-sided collision, so you can use inside and outside collision. Therefore,\n * you may use any winding order. Connectivity information is used to create\n * smooth collisions.\n *\n * WARNING: The chain will not collide properly if there are self-intersections.\n */\n// @ts-expect-error\nexport class ChainShape extends Shape {\n static TYPE = \"chain\" as const;\n /** @hidden */ m_type: \"chain\";\n\n /** @hidden */ m_radius: number;\n\n /** @hidden */ m_vertices: Vec2[];\n /** @hidden */ m_count: number;\n /** @hidden */ m_prevVertex: Vec2 | null;\n /** @hidden */ m_nextVertex: Vec2 | null;\n /** @hidden */ m_hasPrevVertex: boolean;\n /** @hidden */ m_hasNextVertex: boolean;\n\n /** @hidden */ m_isLoop: boolean;\n\n constructor(vertices?: Vec2Value[], loop?: boolean) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof ChainShape)) {\n return new ChainShape(vertices, loop);\n }\n\n super();\n\n this.m_type = ChainShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n this.m_vertices = [];\n this.m_count = 0;\n this.m_prevVertex = null;\n this.m_nextVertex = null;\n this.m_hasPrevVertex = false;\n this.m_hasNextVertex = false;\n\n this.m_isLoop = !!loop;\n\n if (vertices && vertices.length) {\n if (loop) {\n this._createLoop(vertices);\n } else {\n this._createChain(vertices);\n }\n }\n }\n\n /** @internal */\n _serialize(): object {\n const data = {\n type: this.m_type,\n vertices: this.m_isLoop ? this.m_vertices.slice(0, this.m_vertices.length - 1) : this.m_vertices,\n isLoop: this.m_isLoop,\n hasPrevVertex: this.m_hasPrevVertex,\n hasNextVertex: this.m_hasNextVertex,\n prevVertex: null as Vec2 | null,\n nextVertex: null as Vec2 | null,\n };\n if (this.m_prevVertex) {\n data.prevVertex = this.m_prevVertex;\n }\n if (this.m_nextVertex) {\n data.nextVertex = this.m_nextVertex;\n }\n return data;\n }\n\n /** @internal */\n static _deserialize(data: any, fixture: any, restore: any): ChainShape {\n const vertices: Vec2[] = [];\n if (data.vertices) {\n for (let i = 0; i < data.vertices.length; i++) {\n vertices.push(restore(Vec2, data.vertices[i]));\n }\n }\n const shape = new ChainShape(vertices, data.isLoop);\n if (data.prevVertex) {\n shape.setPrevVertex(data.prevVertex);\n }\n if (data.nextVertex) {\n shape.setNextVertex(data.nextVertex);\n }\n return shape;\n }\n\n // clear() {\n // this.m_vertices.length = 0;\n // this.m_count = 0;\n // }\n\n getType(): \"chain\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n /**\n * @internal\n * Create a loop. This automatically adjusts connectivity.\n *\n * @param vertices an array of vertices, these are copied\n */\n _createLoop(vertices: Vec2Value[]): ChainShape {\n if (_ASSERT) console.assert(this.m_vertices.length == 0 && this.m_count == 0);\n if (_ASSERT) console.assert(vertices.length >= 3);\n if (vertices.length < 3) {\n return;\n }\n\n for (let i = 1; i < vertices.length; ++i) {\n const v1 = vertices[i - 1];\n const v2 = vertices[i];\n // If the code crashes here, it means your vertices are too close together.\n if (_ASSERT) console.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);\n }\n\n this.m_vertices = [];\n this.m_count = vertices.length + 1;\n for (let i = 0; i < vertices.length; ++i) {\n this.m_vertices[i] = Vec2.clone(vertices[i]);\n }\n this.m_vertices[vertices.length] = Vec2.clone(vertices[0]);\n\n this.m_prevVertex = this.m_vertices[this.m_count - 2];\n this.m_nextVertex = this.m_vertices[1];\n this.m_hasPrevVertex = true;\n this.m_hasNextVertex = true;\n return this;\n }\n\n /**\n * @internal\n * Create a chain with isolated end vertices.\n *\n * @param vertices an array of vertices, these are copied\n */\n _createChain(vertices: Vec2Value[]): ChainShape {\n if (_ASSERT) console.assert(this.m_vertices.length == 0 && this.m_count == 0);\n if (_ASSERT) console.assert(vertices.length >= 2);\n for (let i = 1; i < vertices.length; ++i) {\n const v1 = vertices[i - 1];\n const v2 = vertices[i];\n // If the code crashes here, it means your vertices are too close together.\n if (_ASSERT) console.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);\n }\n\n this.m_vertices = [];\n this.m_count = vertices.length;\n for (let i = 0; i < vertices.length; ++i) {\n this.m_vertices[i] = Vec2.clone(vertices[i]);\n }\n\n this.m_prevVertex = null;\n this.m_nextVertex = null;\n this.m_hasPrevVertex = false;\n this.m_hasNextVertex = false;\n return this;\n }\n\n /** @hidden */\n _reset(): void {\n if (this.m_isLoop) {\n this._createLoop(this.m_vertices.slice(0, this.m_vertices.length - 1));\n } else {\n this._createChain(this.m_vertices);\n }\n }\n\n /**\n * Establish connectivity to a vertex that precedes the first vertex. Don't call\n * this for loops.\n */\n setPrevVertex(prevVertex: Vec2): void {\n // todo: copy or reference\n this.m_prevVertex = prevVertex;\n this.m_hasPrevVertex = true;\n }\n\n getPrevVertex(): Vec2 {\n return this.m_prevVertex;\n }\n\n /**\n * Establish connectivity to a vertex that follows the last vertex. Don't call\n * this for loops.\n */\n setNextVertex(nextVertex: Vec2): void {\n // todo: copy or reference\n this.m_nextVertex = nextVertex;\n this.m_hasNextVertex = true;\n }\n\n getNextVertex(): Vec2 {\n return this.m_nextVertex;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): ChainShape {\n const clone = new ChainShape();\n clone._createChain(this.m_vertices);\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_prevVertex = this.m_prevVertex;\n clone.m_nextVertex = this.m_nextVertex;\n clone.m_hasPrevVertex = this.m_hasPrevVertex;\n clone.m_hasNextVertex = this.m_hasNextVertex;\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): number {\n // edge count = vertex count - 1\n return this.m_count - 1;\n }\n\n // Get a child edge.\n getChildEdge(edge: EdgeShape, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count - 1);\n edge.m_type = EdgeShape.TYPE;\n edge.m_radius = this.m_radius;\n\n edge.m_vertex1 = this.m_vertices[childIndex];\n edge.m_vertex2 = this.m_vertices[childIndex + 1];\n\n if (childIndex > 0) {\n edge.m_vertex0 = this.m_vertices[childIndex - 1];\n edge.m_hasVertex0 = true;\n } else {\n edge.m_vertex0 = this.m_prevVertex;\n edge.m_hasVertex0 = this.m_hasPrevVertex;\n }\n\n if (childIndex < this.m_count - 2) {\n edge.m_vertex3 = this.m_vertices[childIndex + 2];\n edge.m_hasVertex3 = true;\n } else {\n edge.m_vertex3 = this.m_nextVertex;\n edge.m_hasVertex3 = this.m_hasNextVertex;\n }\n }\n\n getVertex(index: number): Vec2 {\n if (_ASSERT) console.assert(0 <= index && index <= this.m_count);\n if (index < this.m_count) {\n return this.m_vertices[index];\n } else {\n return this.m_vertices[0];\n }\n }\n\n isLoop(): boolean {\n return this.m_isLoop;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * This always return false.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): false {\n return false;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n\n const edgeShape = new EdgeShape(this.getVertex(childIndex), this.getVertex(childIndex + 1));\n return edgeShape.rayCast(output, input, xf, 0);\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n\n matrix.transformVec2(v1, xf, this.getVertex(childIndex));\n matrix.transformVec2(v2, xf, this.getVertex(childIndex + 1));\n\n AABB.combinePoints(aabb, v1, v2);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * Chains have zero mass.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density?: number): void {\n massData.mass = 0.0;\n matrix.zeroVec2(massData.center);\n massData.I = 0.0;\n }\n\n computeDistanceProxy(proxy: DistanceProxy, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n proxy.m_vertices[0] = this.getVertex(childIndex);\n proxy.m_vertices[1] = this.getVertex(childIndex + 1);\n proxy.m_count = 2;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Chain = ChainShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport type { MassData } from \"../../dynamics/Body\";\nimport { RayCastOutput, RayCastInput, AABBValue } from \"../AABB\";\nimport { DistanceProxy } from \"../Distance\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Shape } from \"../Shape\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const e = matrix.vec2(0, 0);\n/** @internal */ const e1 = matrix.vec2(0, 0);\n/** @internal */ const e2 = matrix.vec2(0, 0);\n/** @internal */ const center = matrix.vec2(0, 0);\n/** @internal */ const s = matrix.vec2(0, 0);\n\ndeclare module \"./PolygonShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PolygonShape(vertices?: Vec2Value[]): PolygonShape;\n}\n\n/**\n * A convex polygon. It is assumed that the interior of the polygon is to the\n * left of each edge. Polygons have a maximum number of vertices equal to\n * Settings.maxPolygonVertices. In most cases you should not need many vertices\n * for a convex polygon. extends Shape\n */\n// @ts-expect-error\nexport class PolygonShape extends Shape {\n static TYPE = \"polygon\" as const;\n /** @hidden */ m_type: \"polygon\";\n\n /** @hidden */ m_centroid: Vec2;\n /** @hidden */ m_vertices: Vec2[]; // [Settings.maxPolygonVertices]\n /** @hidden */ m_normals: Vec2[]; // [Settings.maxPolygonVertices]\n /** @hidden */ m_count: number;\n /** @hidden */ m_radius: number;\n\n constructor(vertices?: Vec2Value[]) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PolygonShape)) {\n return new PolygonShape(vertices);\n }\n\n super();\n\n this.m_type = PolygonShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n this.m_centroid = Vec2.zero();\n this.m_vertices = [];\n this.m_normals = [];\n this.m_count = 0;\n\n if (vertices && vertices.length) {\n this._set(vertices);\n }\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n vertices: this.m_vertices,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, fixture: any, restore: any): PolygonShape {\n const vertices: Vec2[] = [];\n if (data.vertices) {\n for (let i = 0; i < data.vertices.length; i++) {\n vertices.push(restore(Vec2, data.vertices[i]));\n }\n }\n\n const shape = new PolygonShape(vertices);\n return shape;\n }\n\n getType(): \"polygon\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): PolygonShape {\n const clone = new PolygonShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_count = this.m_count;\n clone.m_centroid.setVec2(this.m_centroid);\n for (let i = 0; i < this.m_count; i++) {\n clone.m_vertices.push(this.m_vertices[i].clone());\n }\n for (let i = 0; i < this.m_normals.length; i++) {\n clone.m_normals.push(this.m_normals[i].clone());\n }\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /** @hidden */\n _reset(): void {\n this._set(this.m_vertices);\n }\n\n /**\n * @internal\n *\n * Create a convex hull from the given array of local points. The count must be\n * in the range [3, Settings.maxPolygonVertices].\n *\n * Warning: the points may be re-ordered, even if they form a convex polygon\n * Warning: collinear points are handled but not removed. Collinear points may\n * lead to poor stacking behavior.\n */\n _set(vertices: Vec2Value[]): void {\n if (_ASSERT) console.assert(3 <= vertices.length && vertices.length <= Settings.maxPolygonVertices);\n if (vertices.length < 3) {\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n let n = math_min(vertices.length, Settings.maxPolygonVertices);\n\n // Perform welding and copy vertices into local buffer.\n const ps: Vec2[] = []; // [Settings.maxPolygonVertices];\n for (let i = 0; i < n; ++i) {\n const v = vertices[i];\n\n let unique = true;\n for (let j = 0; j < ps.length; ++j) {\n if (Vec2.distanceSquared(v, ps[j]) < 0.25 * Settings.linearSlopSquared) {\n unique = false;\n break;\n }\n }\n\n if (unique) {\n ps.push(Vec2.clone(v));\n }\n }\n\n n = ps.length;\n if (n < 3) {\n // Polygon is degenerate.\n if (_ASSERT) console.assert(false);\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n // Create the convex hull using the Gift wrapping algorithm\n // http://en.wikipedia.org/wiki/Gift_wrapping_algorithm\n\n // Find the right most point on the hull (in case of multiple points bottom most is used)\n let i0 = 0;\n let x0 = ps[0].x;\n for (let i = 1; i < n; ++i) {\n const x = ps[i].x;\n if (x > x0 || (x === x0 && ps[i].y < ps[i0].y)) {\n i0 = i;\n x0 = x;\n }\n }\n\n const hull = [] as number[]; // [Settings.maxPolygonVertices];\n let m = 0;\n let ih = i0;\n\n while (true) {\n if (_ASSERT) console.assert(m < Settings.maxPolygonVertices);\n hull[m] = ih;\n\n let ie = 0;\n for (let j = 1; j < n; ++j) {\n if (ie === ih) {\n ie = j;\n continue;\n }\n\n const r = Vec2.sub(ps[ie], ps[hull[m]]);\n const v = Vec2.sub(ps[j], ps[hull[m]]);\n const c = Vec2.crossVec2Vec2(r, v);\n // c < 0 means counter-clockwise wrapping, c > 0 means clockwise wrapping\n if (c < 0.0) {\n ie = j;\n }\n\n // Collinearity check\n if (c === 0.0 && v.lengthSquared() > r.lengthSquared()) {\n ie = j;\n }\n }\n\n ++m;\n ih = ie;\n\n if (ie === i0) {\n break;\n }\n }\n\n if (m < 3) {\n // Polygon is degenerate.\n if (_ASSERT) console.assert(false);\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n this.m_count = m;\n\n // Copy vertices.\n this.m_vertices = [];\n for (let i = 0; i < m; ++i) {\n this.m_vertices[i] = ps[hull[i]];\n }\n\n // Compute normals. Ensure the edges have non-zero length.\n for (let i = 0; i < m; ++i) {\n const i1 = i;\n const i2 = i + 1 < m ? i + 1 : 0;\n const edge = Vec2.sub(this.m_vertices[i2], this.m_vertices[i1]);\n if (_ASSERT) console.assert(edge.lengthSquared() > EPSILON * EPSILON);\n this.m_normals[i] = Vec2.crossVec2Num(edge, 1.0);\n this.m_normals[i].normalize();\n }\n\n // Compute the polygon centroid.\n this.m_centroid = computeCentroid(this.m_vertices, m);\n }\n\n /** @internal */ _setAsBox(hx: number, hy: number, center?: Vec2Value, angle?: number): void {\n // start with right-bottom, counter-clockwise, as in Gift wrapping algorithm in PolygonShape._set()\n this.m_vertices[0] = Vec2.neo(hx, -hy);\n this.m_vertices[1] = Vec2.neo(hx, hy);\n this.m_vertices[2] = Vec2.neo(-hx, hy);\n this.m_vertices[3] = Vec2.neo(-hx, -hy);\n\n this.m_normals[0] = Vec2.neo(1.0, 0.0);\n this.m_normals[1] = Vec2.neo(0.0, 1.0);\n this.m_normals[2] = Vec2.neo(-1.0, 0.0);\n this.m_normals[3] = Vec2.neo(0.0, -1.0);\n\n this.m_count = 4;\n\n if (center && Vec2.isValid(center)) {\n angle = angle || 0;\n\n matrix.copyVec2(this.m_centroid, center);\n\n const xf = Transform.identity();\n xf.p.setVec2(center);\n xf.q.setAngle(angle);\n\n // Transform vertices and normals.\n for (let i = 0; i < this.m_count; ++i) {\n this.m_vertices[i] = Transform.mulVec2(xf, this.m_vertices[i]);\n this.m_normals[i] = Rot.mulVec2(xf.q, this.m_normals[i]);\n }\n }\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): boolean {\n const pLocal = matrix.detransformVec2(temp, xf, p);\n\n for (let i = 0; i < this.m_count; ++i) {\n const dot = matrix.dotVec2(this.m_normals[i], pLocal) - matrix.dotVec2(this.m_normals[i], this.m_vertices[i]);\n if (dot > 0.0) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n\n // Put the ray into the polygon's frame of reference.\n const p1 = Rot.mulTVec2(xf.q, Vec2.sub(input.p1, xf.p));\n const p2 = Rot.mulTVec2(xf.q, Vec2.sub(input.p2, xf.p));\n const d = Vec2.sub(p2, p1);\n\n let lower = 0.0;\n let upper = input.maxFraction;\n\n let index = -1;\n\n for (let i = 0; i < this.m_count; ++i) {\n // p = p1 + a * d\n // dot(normal, p - v) = 0\n // dot(normal, p1 - v) + a * dot(normal, d) = 0\n const numerator = Vec2.dot(this.m_normals[i], Vec2.sub(this.m_vertices[i], p1));\n const denominator = Vec2.dot(this.m_normals[i], d);\n\n if (denominator == 0.0) {\n if (numerator < 0.0) {\n return false;\n }\n } else {\n // Note: we want this predicate without division:\n // lower < numerator / denominator, where denominator < 0\n // Since denominator < 0, we have to flip the inequality:\n // lower < numerator / denominator <==> denominator * lower > numerator.\n if (denominator < 0.0 && numerator < lower * denominator) {\n // Increase lower.\n // The segment enters this half-space.\n lower = numerator / denominator;\n index = i;\n } else if (denominator > 0.0 && numerator < upper * denominator) {\n // Decrease upper.\n // The segment exits this half-space.\n upper = numerator / denominator;\n }\n }\n\n // The use of epsilon here causes the assert on lower to trip\n // in some cases. Apparently the use of epsilon was to make edge\n // shapes work, but now those are handled separately.\n // if (upper < lower - matrix.EPSILON)\n if (upper < lower) {\n return false;\n }\n }\n\n if (_ASSERT) console.assert(0.0 <= lower && lower <= input.maxFraction);\n\n if (index >= 0) {\n output.fraction = lower;\n output.normal = Rot.mulVec2(xf.q, this.m_normals[index]);\n return true;\n }\n\n return false;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (let i = 0; i < this.m_count; ++i) {\n const v = matrix.transformVec2(temp, xf, this.m_vertices[i]);\n minX = math_min(minX, v.x);\n maxX = math_max(maxX, v.x);\n minY = math_min(minY, v.y);\n maxY = math_max(maxY, v.y);\n }\n\n matrix.setVec2(aabb.lowerBound, minX - this.m_radius, minY - this.m_radius);\n matrix.setVec2(aabb.upperBound, maxX + this.m_radius, maxY + this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density: number): void {\n // Polygon mass, centroid, and inertia.\n // Let rho be the polygon density in mass per unit area.\n // Then:\n // mass = rho * int(dA)\n // centroid.x = (1/mass) * rho * int(x * dA)\n // centroid.y = (1/mass) * rho * int(y * dA)\n // I = rho * int((x*x + y*y) * dA)\n //\n // We can compute these integrals by summing all the integrals\n // for each triangle of the polygon. To evaluate the integral\n // for a single triangle, we make a change of variables to\n // the (u,v) coordinates of the triangle:\n // x = x0 + e1x * u + e2x * v\n // y = y0 + e1y * u + e2y * v\n // where 0 <= u && 0 <= v && u + v <= 1.\n //\n // We integrate u from [0,1-v] and then v from [0,1].\n // We also need to use the Jacobian of the transformation:\n // D = cross(e1, e2)\n //\n // Simplification: triangle centroid = (1/3) * (p1 + p2 + p3)\n //\n // The rest of the derivation is handled by computer algebra.\n\n if (_ASSERT) console.assert(this.m_count >= 3);\n\n matrix.zeroVec2(center);\n let area = 0.0;\n let I = 0.0;\n\n // s is the reference point for forming triangles.\n // It's location doesn't change the result (except for rounding error).\n matrix.zeroVec2(s);\n\n // This code would put the reference point inside the polygon.\n for (let i = 0; i < this.m_count; ++i) {\n matrix.plusVec2(s, this.m_vertices[i]);\n }\n matrix.scaleVec2(s, 1.0 / this.m_count, s);\n\n const k_inv3 = 1.0 / 3.0;\n\n for (let i = 0; i < this.m_count; ++i) {\n // Triangle vertices.\n matrix.subVec2(e1, this.m_vertices[i], s);\n if ( i + 1 < this.m_count) {\n matrix.subVec2(e2, this.m_vertices[i + 1], s);\n } else {\n matrix.subVec2(e2, this.m_vertices[0], s);\n }\n\n const D = matrix.crossVec2Vec2(e1, e2);\n\n const triangleArea = 0.5 * D;\n area += triangleArea;\n\n // Area weighted centroid\n matrix.combine2Vec2(temp, triangleArea * k_inv3, e1, triangleArea * k_inv3, e2);\n matrix.plusVec2(center, temp);\n\n const ex1 = e1.x;\n const ey1 = e1.y;\n const ex2 = e2.x;\n const ey2 = e2.y;\n\n const intx2 = ex1 * ex1 + ex2 * ex1 + ex2 * ex2;\n const inty2 = ey1 * ey1 + ey2 * ey1 + ey2 * ey2;\n\n I += (0.25 * k_inv3 * D) * (intx2 + inty2);\n }\n\n // Total mass\n massData.mass = density * area;\n\n // Center of mass\n if (_ASSERT) console.assert(area > EPSILON);\n matrix.scaleVec2(center, 1.0 / area, center);\n matrix.addVec2(massData.center, center, s);\n\n // Inertia tensor relative to the local origin (point s).\n massData.I = density * I;\n\n // Shift to center of mass then to original body origin.\n massData.I += massData.mass * (matrix.dotVec2(massData.center, massData.center) - matrix.dotVec2(center, center));\n }\n\n /**\n * Validate convexity. This is a very time consuming operation.\n * @returns true if valid\n */\n validate(): boolean {\n for (let i = 0; i < this.m_count; ++i) {\n const i1 = i;\n const i2 = i < this.m_count - 1 ? i1 + 1 : 0;\n const p = this.m_vertices[i1];\n matrix.subVec2(e, this.m_vertices[i2], p);\n\n for (let j = 0; j < this.m_count; ++j) {\n if (j == i1 || j == i2) {\n continue;\n }\n\n const c = matrix.crossVec2Vec2(e, matrix.subVec2(temp, this.m_vertices[j], p));\n if (c < 0.0) {\n return false;\n }\n }\n }\n\n return true;\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n for (let i = 0; i < this.m_count; ++i) {\n proxy.m_vertices[i] = this.m_vertices[i];\n }\n proxy.m_vertices.length = this.m_count;\n proxy.m_count = this.m_count;\n proxy.m_radius = this.m_radius;\n }\n}\n\n/** @internal */ function computeCentroid(vs: Vec2[], count: number): Vec2 {\n if (_ASSERT) console.assert(count >= 3);\n\n const c = Vec2.zero();\n let area = 0.0;\n\n // pRef is the reference point for forming triangles.\n // It's location doesn't change the result (except for rounding error).\n const pRef = Vec2.zero();\n if (false) {\n // This code would put the reference point inside the polygon.\n for (let i = 0; i < count; ++i) {\n pRef.add(vs[i]);\n }\n pRef.mul(1.0 / count);\n }\n\n const inv3 = 1.0 / 3.0;\n\n for (let i = 0; i < count; ++i) {\n // Triangle vertices.\n const p1 = pRef;\n const p2 = vs[i];\n const p3 = i + 1 < count ? vs[i + 1] : vs[0];\n\n const e1 = Vec2.sub(p2, p1);\n const e2 = Vec2.sub(p3, p1);\n\n const D = Vec2.crossVec2Vec2(e1, e2);\n\n const triangleArea = 0.5 * D;\n area += triangleArea;\n\n // Area weighted centroid\n matrix.combine3Vec2(temp, 1, p1, 1, p2, 1, p3);\n matrix.plusScaleVec2(c, triangleArea * inv3, temp);\n }\n\n // Centroid\n if (_ASSERT) console.assert(area > EPSILON);\n c.mul(1.0 / area);\n return c;\n}\n\nexport const Polygon = PolygonShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Shape } from \"../Shape\";\nimport { AABBValue, RayCastInput, RayCastOutput } from \"../AABB\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { MassData } from \"../../dynamics/Body\";\nimport { DistanceProxy } from \"../Distance\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_PI = Math.PI;\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n\ndeclare module \"./CircleShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function CircleShape(position: Vec2Value, radius?: number): CircleShape;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function CircleShape(radius?: number): CircleShape;\n}\n\n/** Circle shape. */\n// @ts-expect-error\nexport class CircleShape extends Shape {\n static TYPE = \"circle\" as const;\n /** @hidden */ m_type: \"circle\";\n\n /** @hidden */ m_p: Vec2;\n /** @hidden */ m_radius: number;\n\n constructor(position: Vec2Value, radius?: number);\n constructor(radius?: number);\n constructor(a: any, b?: any) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof CircleShape)) {\n return new CircleShape(a, b);\n }\n\n super();\n\n this.m_type = CircleShape.TYPE;\n this.m_p = Vec2.zero();\n this.m_radius = 1;\n\n if (typeof a === \"object\" && Vec2.isValid(a)) {\n this.m_p.setVec2(a);\n\n if (typeof b === \"number\") {\n this.m_radius = b;\n }\n\n } else if (typeof a === \"number\") {\n this.m_radius = a;\n }\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n p: this.m_p,\n radius: this.m_radius,\n };\n }\n\n /** @internal */\n static _deserialize(data: any): CircleShape {\n return new CircleShape(data.p, data.radius);\n }\n\n /** @hidden */\n _reset(): void {\n // noop\n }\n\n getType(): \"circle\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n getCenter(): Vec2 {\n return this.m_p;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): CircleShape {\n const clone = new CircleShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_p = this.m_p.clone();\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): boolean {\n const center = matrix.transformVec2(temp, xf, this.m_p);\n return matrix.distSqrVec2(p, center) <= this.m_radius * this.m_radius;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n // Collision Detection in Interactive 3D Environments by Gino van den Bergen\n // From Section 3.1.2\n // x = s + a * r\n // norm(x) = radius\n\n const position = Vec2.add(xf.p, Rot.mulVec2(xf.q, this.m_p));\n const s = Vec2.sub(input.p1, position);\n const b = Vec2.dot(s, s) - this.m_radius * this.m_radius;\n\n // Solve quadratic equation.\n const r = Vec2.sub(input.p2, input.p1);\n const c = Vec2.dot(s, r);\n const rr = Vec2.dot(r, r);\n const sigma = c * c - rr * b;\n\n // Check for negative discriminant and short segment.\n if (sigma < 0.0 || rr < EPSILON) {\n return false;\n }\n\n // Find the point of intersection of the line with the circle.\n let a = -(c + math_sqrt(sigma));\n\n // Is the intersection point on the segment?\n if (0.0 <= a && a <= input.maxFraction * rr) {\n a /= rr;\n output.fraction = a;\n output.normal = Vec2.add(s, Vec2.mulNumVec2(a, r));\n output.normal.normalize();\n return true;\n }\n\n return false;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n const p = matrix.transformVec2(temp, xf, this.m_p);\n\n matrix.setVec2(aabb.lowerBound, p.x - this.m_radius, p.y - this.m_radius);\n matrix.setVec2(aabb.upperBound, p.x + this.m_radius, p.y + this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density: number): void {\n massData.mass = density * math_PI * this.m_radius * this.m_radius;\n matrix.copyVec2(massData.center, this.m_p);\n // inertia about the local origin\n massData.I = massData.mass * (0.5 * this.m_radius * this.m_radius + matrix.lengthSqrVec2(this.m_p));\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n proxy.m_vertices[0] = this.m_p;\n proxy.m_vertices.length = 1;\n proxy.m_count = 1;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Circle = CircleShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Distance joint definition. This requires defining an anchor point on both\n * bodies and the non-zero length of the distance joint. The definition uses\n * local anchor points so that the initial configuration can violate the\n * constraint slightly. This helps when saving and loading a game. Warning: Do\n * not use a zero or short length.\n */\nexport interface DistanceJointOpt extends JointOpt {\n /**\n * The mass-spring-damper frequency in Hertz. A value of 0 disables softness.\n */\n frequencyHz?: number;\n /**\n * The damping ratio. 0 = no damping, 1 = critical damping.\n */\n dampingRatio?: number;\n /**\n * Distance length.\n */\n length?: number;\n}\n/**\n * Distance joint definition. This requires defining an anchor point on both\n * bodies and the non-zero length of the distance joint. The definition uses\n * local anchor points so that the initial configuration can violate the\n * constraint slightly. This helps when saving and loading a game. Warning: Do\n * not use a zero or short length.\n */\nexport interface DistanceJointDef extends JointDef, DistanceJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n frequencyHz : 0.0,\n dampingRatio : 0.0\n};\n\ndeclare module \"./DistanceJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function DistanceJoint(def: DistanceJointDef): DistanceJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function DistanceJoint(def: DistanceJointOpt, bodyA: Body, bodyB: Body, anchorA: Vec2Value, anchorB: Vec2Value): DistanceJoint;\n}\n\n/**\n * A distance joint constrains two points on two bodies to remain at a fixed\n * distance from each other. You can view this as a massless, rigid rod.\n */\n// @ts-expect-error\nexport class DistanceJoint extends Joint {\n static TYPE = \"distance-joint\" as const;\n\n // Solver shared\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_length: number;\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_gamma: number;\n /** @internal */ m_bias: number;\n\n // Solver temp\n /** @internal */ m_u: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: number;\n\n /**\n * @param def DistanceJoint definition.\n */\n constructor(def: DistanceJointDef);\n /**\n * @param anchorA Anchor A in global coordination.\n * @param anchorB Anchor B in global coordination.\n */\n constructor(def: DistanceJointOpt, bodyA: Body, bodyB: Body, anchorA?: Vec2Value, anchorB?: Vec2Value);\n constructor(def: DistanceJointDef, bodyA?: Body, bodyB?: Body, anchorA?: Vec2Value, anchorB?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof DistanceJoint)) {\n return new DistanceJoint(def, bodyA, bodyB, anchorA, anchorB);\n }\n\n // order of constructor arguments is changed in v0.2\n if (bodyB && anchorA && (\"m_type\" in anchorA) && (\"x\" in bodyB) && (\"y\" in bodyB)) {\n const temp = bodyB;\n bodyB = anchorA as any as Body;\n anchorA = temp as any as Vec2;\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = DistanceJoint.TYPE;\n\n // Solver shared\n this.m_localAnchorA = Vec2.clone(anchorA ? bodyA.getLocalPoint(anchorA) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchorB ? bodyB.getLocalPoint(anchorB) : def.localAnchorB || Vec2.zero());\n this.m_length = Number.isFinite(def.length) ? def.length :\n Vec2.distance(bodyA.getWorldPoint(this.m_localAnchorA), bodyB.getWorldPoint(this.m_localAnchorB));\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n this.m_impulse = 0.0;\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n\n // 1-D constrained system\n // m (v2 - v1) = lambda\n // v2 + (beta/h) * x1 + gamma * lambda = 0, gamma has units of inverse mass.\n // x2 = x1 + h * v2\n\n // 1-D mass-damper-spring system\n // m (v2 - v1) + h * d * v2 + h * k *\n\n // C = norm(p2 - p1) - L\n // u = (p2 - p1) / norm(p2 - p1)\n // Cdot = dot(u, v2 + cross(w2, r2) - v1 - cross(w1, r1))\n // J = [-u -cross(r1, u) u cross(r2, u)]\n // K = J * invM * JT\n // = invMass1 + invI1 * cross(r1, u)^2 + invMass2 + invI2 * cross(r2, u)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n length: this.m_length,\n\n impulse: this.m_impulse,\n gamma: this.m_gamma,\n bias: this.m_bias,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): DistanceJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new DistanceJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n\n if (def.length > 0) {\n this.m_length = +def.length;\n } else if (def.length < 0) { // don't change length\n } else if (def.anchorA || def.anchorA || def.anchorA || def.anchorA) {\n this.m_length = Vec2.distance(\n this.m_bodyA.getWorldPoint(this.m_localAnchorA),\n this.m_bodyB.getWorldPoint(this.m_localAnchorB)\n );\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the natural length. Manipulating the length can lead to non-physical\n * behavior when the frequency is zero.\n */\n setLength(length: number): void {\n this.m_length = length;\n }\n\n /**\n * Get the natural length.\n */\n getLength(): number {\n return this.m_length;\n }\n\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_u).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n this.m_u = Vec2.sub(Vec2.add(cB, this.m_rB), Vec2.add(cA, this.m_rA));\n\n // Handle singularity.\n const length = this.m_u.length();\n if (length > Settings.linearSlop) {\n this.m_u.mul(1.0 / length);\n } else {\n this.m_u.setNum(0.0, 0.0);\n }\n\n const crAu = Vec2.crossVec2Vec2(this.m_rA, this.m_u);\n const crBu = Vec2.crossVec2Vec2(this.m_rB, this.m_u);\n let invMass = this.m_invMassA + this.m_invIA * crAu * crAu + this.m_invMassB + this.m_invIB * crBu * crBu;\n\n // Compute the effective mass matrix.\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n\n if (this.m_frequencyHz > 0.0) {\n const C = length - this.m_length;\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * this.m_mass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = this.m_mass * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (d + h * k);\n this.m_gamma = this.m_gamma != 0.0 ? 1.0 / this.m_gamma : 0.0;\n this.m_bias = C * h * k * this.m_gamma;\n\n invMass += this.m_gamma;\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n } else {\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n }\n\n if (step.warmStarting) {\n // Scale the impulse to support a variable time step.\n this.m_impulse *= step.dtRatio;\n\n const P = Vec2.mulNumVec2(this.m_impulse, this.m_u);\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Cdot = dot(u, v + cross(w, r))\n const vpA = Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA));\n const vpB = Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB));\n const Cdot = Vec2.dot(this.m_u, vpB) - Vec2.dot(this.m_u, vpA);\n\n const impulse = -this.m_mass * (Cdot + this.m_bias + this.m_gamma * this.m_impulse);\n this.m_impulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_u);\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n if (this.m_frequencyHz > 0.0) {\n // There is no position correction for soft distance constraints.\n return true;\n }\n\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n const u = Vec2.sub(Vec2.add(cB, rB), Vec2.add(cA, rA));\n\n const length = u.normalize();\n const C = clamp(length - this.m_length, -Settings.maxLinearCorrection, Settings.maxLinearCorrection);\n\n const impulse = -this.m_mass * C;\n const P = Vec2.mulNumVec2(impulse, u);\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * Vec2.crossVec2Vec2(rA, P);\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, P);\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return math_abs(C) < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Friction joint definition.\n */\nexport interface FrictionJointOpt extends JointOpt {\n /**\n * The maximum friction force in N.\n */\n maxForce?: number;\n /**\n * The maximum friction torque in N-m.\n */\n maxTorque?: number;\n}\n\n/**\n * Friction joint definition.\n */\nexport interface FrictionJointDef extends JointDef, FrictionJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 0.0,\n maxTorque : 0.0,\n};\n\ndeclare module \"./FrictionJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function FrictionJoint(def: FrictionJointDef): FrictionJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function FrictionJoint(def: FrictionJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): FrictionJoint;\n}\n\n/**\n * Friction joint. This is used for top-down friction. It provides 2D\n * translational friction and angular friction.\n */\n// @ts-expect-error\nexport class FrictionJoint extends Joint {\n static TYPE = \"friction-joint\" as const;\n\n /** @internal */ m_type: \"friction-joint\";\n\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n\n // Solver shared\n /** @internal */ m_linearImpulse: Vec2;\n /** @internal */ m_angularImpulse: number;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_maxTorque: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_linearMass: Mat22;\n /** @internal */ m_angularMass: number;\n\n constructor(def: FrictionJointDef);\n /**\n * @param anchor Anchor in global coordination.\n */\n constructor(def: FrictionJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: FrictionJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof FrictionJoint)) {\n return new FrictionJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = FrictionJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n\n // Solver shared\n this.m_linearImpulse = Vec2.zero();\n this.m_angularImpulse = 0.0;\n this.m_maxForce = def.maxForce;\n this.m_maxTorque = def.maxTorque;\n\n // Point-to-point constraint\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Angle constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n maxForce: this.m_maxForce,\n maxTorque: this.m_maxTorque,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): FrictionJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new FrictionJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.maxTorque)) {\n this.m_maxTorque = def.maxTorque;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the maximum friction force in N.\n */\n setMaxForce(force: number): void {\n if (_ASSERT) console.assert(Number.isFinite(force) && force >= 0.0);\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum friction force in N.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the maximum friction torque in N*m.\n */\n setMaxTorque(torque: number): void {\n if (_ASSERT) console.assert(Number.isFinite(torque) && torque >= 0.0);\n this.m_maxTorque = torque;\n }\n\n /**\n * Get the maximum friction torque in N*m.\n */\n getMaxTorque(): number {\n return this.m_maxTorque;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_linearImpulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_angularImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective mass matrix.\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat22();\n K.ex.x = mA + mB + iA * this.m_rA.y * this.m_rA.y + iB * this.m_rB.y\n * this.m_rB.y;\n K.ex.y = -iA * this.m_rA.x * this.m_rA.y - iB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * this.m_rA.x * this.m_rA.x + iB * this.m_rB.x\n * this.m_rB.x;\n\n this.m_linearMass = K.getInverse();\n\n this.m_angularMass = iA + iB;\n if (this.m_angularMass > 0.0) {\n this.m_angularMass = 1.0 / this.m_angularMass;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_linearImpulse.mul(step.dtRatio);\n this.m_angularImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_linearImpulse.x, this.m_linearImpulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_angularImpulse);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_angularImpulse);\n\n } else {\n this.m_linearImpulse.setZero();\n this.m_angularImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const h = step.dt;\n\n // Solve angular friction\n {\n const Cdot = wB - wA;\n let impulse = -this.m_angularMass * Cdot;\n\n const oldImpulse = this.m_angularImpulse;\n const maxImpulse = h * this.m_maxTorque;\n this.m_angularImpulse = clamp(this.m_angularImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_angularImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve linear friction\n {\n const Cdot = Vec2.sub(\n Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB)),\n Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA))\n );\n\n let impulse = Vec2.neg(Mat22.mulVec2(this.m_linearMass, Cdot));\n const oldImpulse = this.m_linearImpulse;\n this.m_linearImpulse.add(impulse);\n\n const maxImpulse = h * this.m_maxForce;\n\n if (this.m_linearImpulse.lengthSquared() > maxImpulse * maxImpulse) {\n this.m_linearImpulse.normalize();\n this.m_linearImpulse.mul(maxImpulse);\n }\n\n impulse = Vec2.sub(this.m_linearImpulse, oldImpulse);\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { Vec3, Vec3Value } from \"./Vec3\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A 3-by-3 matrix. Stored in column-major order.\n */\nexport class Mat33 {\n ex: Vec3;\n ey: Vec3;\n ez: Vec3;\n\n constructor(a: Vec3Value, b: Vec3Value, c: Vec3Value);\n constructor();\n constructor(a?: Vec3Value, b?: Vec3Value, c?: Vec3Value) {\n if (typeof a === \"object\" && a !== null) {\n this.ex = Vec3.clone(a);\n this.ey = Vec3.clone(b);\n this.ez = Vec3.clone(c);\n } else {\n this.ex = Vec3.zero();\n this.ey = Vec3.zero();\n this.ez = Vec3.zero();\n }\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec3.isValid(obj.ex) && Vec3.isValid(obj.ey) && Vec3.isValid(obj.ez);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Mat33.isValid(o), \"Invalid Mat33!\", o);\n }\n\n /**\n * Set this matrix to all zeros.\n */\n setZero(): Mat33 {\n this.ex.setZero();\n this.ey.setZero();\n this.ez.setZero();\n return this;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases.\n */\n solve33(v: Vec3Value): Vec3 {\n // let det = matrix.dotVec3(this.ex, matrix.newCrossVec3(this.ey, this.ez));\n let cross_x = this.ey.y * this.ez.z - this.ey.z * this.ez.y;\n let cross_y = this.ey.z * this.ez.x - this.ey.x * this.ez.z;\n let cross_z = this.ey.x * this.ez.y - this.ey.y * this.ez.x;\n let det = this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const r = new Vec3();\n // r.x = det * matrix.dotVec3(v, matrix.newCrossVec3(this.ey, this.ez));\n cross_x = this.ey.y * this.ez.z - this.ey.z * this.ez.y;\n cross_y = this.ey.z * this.ez.x - this.ey.x * this.ez.z;\n cross_z = this.ey.x * this.ez.y - this.ey.y * this.ez.x;\n r.x = det * (v.x * cross_x + v.y * cross_y + v.z * cross_z);\n\n // r.y = det * matrix.dotVec3(this.ex, matrix.newCrossVec3(v, this.ez));\n cross_x = v.y * this.ez.z - v.z * this.ez.y;\n cross_y = v.z * this.ez.x - v.x * this.ez.z;\n cross_z = v.x * this.ez.y - v.y * this.ez.x;\n r.y = det * (this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z);\n\n // r.z = det * matrix.dotVec3(this.ex, matrix.newCrossVec3(this.ey, v));\n cross_x = this.ey.y * v.z - this.ey.z * v.y;\n cross_y = this.ey.z * v.x - this.ey.x * v.z;\n cross_z = this.ey.x * v.y - this.ey.y * v.x;\n r.z = det * (this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z);\n return r;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases. Solve only the upper 2-by-2 matrix\n * equation.\n */\n solve22(v: Vec2Value): Vec2 {\n const a11 = this.ex.x;\n const a12 = this.ey.x;\n const a21 = this.ex.y;\n const a22 = this.ey.y;\n let det = a11 * a22 - a12 * a21;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const r = Vec2.zero();\n r.x = det * (a22 * v.x - a12 * v.y);\n r.y = det * (a11 * v.y - a21 * v.x);\n return r;\n }\n\n /**\n * Get the inverse of this matrix as a 2-by-2. Returns the zero matrix if\n * singular.\n */\n getInverse22(M: Mat33): void {\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n M.ex.x = det * d;\n M.ey.x = -det * b;\n M.ex.z = 0.0;\n M.ex.y = -det * c;\n M.ey.y = det * a;\n M.ey.z = 0.0;\n M.ez.x = 0.0;\n M.ez.y = 0.0;\n M.ez.z = 0.0;\n }\n\n /**\n * Get the symmetric inverse of this matrix as a 3-by-3. Returns the zero matrix\n * if singular.\n */\n getSymInverse33(M: Mat33): void {\n let det = Vec3.dot(this.ex, Vec3.cross(this.ey, this.ez));\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const a11 = this.ex.x;\n const a12 = this.ey.x;\n const a13 = this.ez.x;\n const a22 = this.ey.y;\n const a23 = this.ez.y;\n const a33 = this.ez.z;\n\n M.ex.x = det * (a22 * a33 - a23 * a23);\n M.ex.y = det * (a13 * a23 - a12 * a33);\n M.ex.z = det * (a12 * a23 - a13 * a22);\n\n M.ey.x = M.ex.y;\n M.ey.y = det * (a11 * a33 - a13 * a13);\n M.ey.z = det * (a13 * a12 - a11 * a23);\n\n M.ez.x = M.ex.z;\n M.ez.y = M.ey.z;\n M.ez.z = det * (a11 * a22 - a12 * a12);\n }\n\n /**\n * Multiply a matrix times a vector.\n */\n static mul(a: Mat33, b: Vec2Value): Vec2;\n static mul(a: Mat33, b: Vec3Value): Vec3;\n static mul(a, b) {\n if (_ASSERT) Mat33.assert(a);\n if (b && \"z\" in b && \"y\" in b && \"x\" in b) {\n if (_ASSERT) Vec3.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y + a.ez.x * b.z;\n const y = a.ex.y * b.x + a.ey.y * b.y + a.ez.y * b.z;\n const z = a.ex.z * b.x + a.ey.z * b.y + a.ez.z * b.z;\n return new Vec3(x, y, z);\n\n } else if (b && \"y\" in b && \"x\" in b) {\n if (_ASSERT) Vec2.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y;\n const y = a.ex.y * b.x + a.ey.y * b.y;\n return Vec2.neo(x, y);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulVec3(a: Mat33, b: Vec3Value): Vec3 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Vec3.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y + a.ez.x * b.z;\n const y = a.ex.y * b.x + a.ey.y * b.y + a.ez.y * b.z;\n const z = a.ex.z * b.x + a.ey.z * b.y + a.ez.z * b.z;\n return new Vec3(x, y, z);\n }\n\n static mulVec2(a: Mat33, b: Vec2Value): Vec2 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y;\n const y = a.ex.y * b.x + a.ey.y * b.y;\n return Vec2.neo(x, y);\n }\n\n static add(a: Mat33, b: Mat33): Mat33 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Mat33.assert(b);\n return new Mat33(\n Vec3.add(a.ex, b.ex),\n Vec3.add(a.ey, b.ey),\n Vec3.add(a.ez, b.ez)\n );\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n\n\n// todo: use string?\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3,\n} \n\n/**\n * Revolute joint definition. This requires defining an anchor point where the\n * bodies are joined. The definition uses local anchor points so that the\n * initial configuration can violate the constraint slightly. You also need to\n * specify the initial relative angle for joint limits. This helps when saving\n * and loading a game.\n *\n * The local anchor points are measured from the body's origin rather than the\n * center of mass because: 1. you might not know where the center of mass will\n * be. 2. if you add/remove shapes from a body and recompute the mass, the\n * joints will be broken.\n */\nexport interface RevoluteJointOpt extends JointOpt {\n /**\n * The lower angle for the joint limit (radians).\n */\n lowerAngle?: number;\n /**\n * The upper angle for the joint limit (radians).\n */\n upperAngle?: number;\n /**\n * The maximum motor torque used to achieve the desired motor speed. Usually\n * in N-m.\n */\n maxMotorTorque?: number;\n /**\n * The desired motor speed. Usually in radians per second.\n */\n motorSpeed?: number;\n /**\n * A flag to enable joint limits.\n */\n enableLimit?: boolean;\n /**\n * A flag to enable the joint motor.\n */\n enableMotor?: boolean;\n}\n\n/**\n * Revolute joint definition. This requires defining an anchor point where the\n * bodies are joined. The definition uses local anchor points so that the\n * initial configuration can violate the constraint slightly. You also need to\n * specify the initial relative angle for joint limits. This helps when saving\n * and loading a game.\n *\n * The local anchor points are measured from the body's origin rather than the\n * center of mass because: 1. you might not know where the center of mass will\n * be. 2. if you add/remove shapes from a body and recompute the mass, the\n * joints will be broken.\n */\nexport interface RevoluteJointDef extends JointDef, RevoluteJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The bodyB angle minus bodyA angle in the reference state (radians).\n */\n referenceAngle?: number;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n lowerAngle : 0.0,\n upperAngle : 0.0,\n maxMotorTorque : 0.0,\n motorSpeed : 0.0,\n enableLimit : false,\n enableMotor : false\n};\n\ndeclare module \"./RevoluteJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RevoluteJoint(def: RevoluteJointDef): RevoluteJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RevoluteJoint(def: RevoluteJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): RevoluteJoint;\n}\n\n/**\n * A revolute joint constrains two bodies to share a common point while they are\n * free to rotate about the point. The relative rotation about the shared point\n * is the joint angle. You can limit the relative rotation with a joint limit\n * that specifies a lower and upper angle. You can use a motor to drive the\n * relative rotation about the shared point. A maximum motor torque is provided\n * so that infinite forces are not generated.\n */\n// @ts-expect-error\nexport class RevoluteJoint extends Joint {\n static TYPE = \"revolute-joint\" as const;\n\n /** @internal */ m_type: \"revolute-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngle: number;\n /** @internal */ m_impulse: Vec3;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_lowerAngle: number;\n /** @internal */ m_upperAngle: number;\n /** @internal */ m_maxMotorTorque: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableLimit: boolean;\n /** @internal */ m_enableMotor: boolean;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n // effective mass for point-to-point constraint.\n /** @internal */ m_mass: Mat33;\n // effective mass for motor/limit angular constraint.\n /** @internal */ m_motorMass: number;\n /** @internal */ m_limitState: number;\n\n constructor(def: RevoluteJointDef);\n constructor(def: RevoluteJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: RevoluteJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof RevoluteJoint)) {\n return new RevoluteJoint(def, bodyA, bodyB, anchor);\n }\n\n def = def ?? {} as RevoluteJointDef;\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_mass = new Mat33();\n this.m_limitState = LimitState.inactiveLimit;\n\n this.m_type = RevoluteJoint.TYPE;\n\n if (Vec2.isValid(anchor)) {\n this.m_localAnchorA = bodyA.getLocalPoint(anchor);\n } else if (Vec2.isValid(def.localAnchorA)) {\n this.m_localAnchorA = Vec2.clone(def.localAnchorA);\n } else {\n this.m_localAnchorA = Vec2.zero();\n }\n\n if (Vec2.isValid(anchor)) {\n this.m_localAnchorB = bodyB.getLocalPoint(anchor);\n } else if (Vec2.isValid(def.localAnchorB)) {\n this.m_localAnchorB = Vec2.clone(def.localAnchorB);\n } else {\n this.m_localAnchorB = Vec2.zero();\n }\n\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n } else {\n this.m_referenceAngle = bodyB.getAngle() - bodyA.getAngle();\n }\n\n this.m_impulse = new Vec3();\n this.m_motorImpulse = 0.0;\n\n this.m_lowerAngle = def.lowerAngle ?? DEFAULTS.lowerAngle;\n this.m_upperAngle = def.upperAngle ?? DEFAULTS.upperAngle;\n this.m_maxMotorTorque = def.maxMotorTorque ?? DEFAULTS.maxMotorTorque;\n this.m_motorSpeed = def.motorSpeed ?? DEFAULTS.motorSpeed;\n this.m_enableLimit = def.enableLimit ?? DEFAULTS.enableLimit;\n this.m_enableMotor = def.enableMotor ?? DEFAULTS.enableMotor;\n\n // Point-to-point constraint\n // C = p2 - p1\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Motor constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n lowerAngle: this.m_lowerAngle,\n upperAngle: this.m_upperAngle,\n maxMotorTorque: this.m_maxMotorTorque,\n motorSpeed: this.m_motorSpeed,\n enableLimit: this.m_enableLimit,\n enableMotor: this.m_enableMotor,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any):RevoluteJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new RevoluteJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n }\n if (def.enableLimit !== undefined) {\n this.m_enableLimit = def.enableLimit;\n }\n if (Number.isFinite(def.lowerAngle)) {\n this.m_lowerAngle = def.lowerAngle;\n }\n if (Number.isFinite(def.upperAngle)) {\n this.m_upperAngle = def.upperAngle;\n }\n if (Number.isFinite(def.maxMotorTorque)) {\n this.m_maxMotorTorque = def.maxMotorTorque;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n if (def.enableMotor !== undefined) {\n this.m_enableMotor = def.enableMotor;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Get the current joint angle in radians.\n */\n getJointAngle(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n return bB.m_sweep.a - bA.m_sweep.a - this.m_referenceAngle;\n }\n\n /**\n * Get the current joint angle speed in radians per second.\n */\n getJointSpeed(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n return bB.m_angularVelocity - bA.m_angularVelocity;\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Get the current motor torque given the inverse time step. Unit is N*m.\n */\n getMotorTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Set the motor speed in radians per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Get the motor speed in radians per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Set the maximum motor torque, usually in N-m.\n */\n setMaxMotorTorque(torque: number): void {\n if (torque == this.m_maxMotorTorque) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorTorque = torque;\n }\n\n getMaxMotorTorque(): number {\n return this.m_maxMotorTorque;\n }\n\n /**\n * Is the joint limit enabled?\n */\n isLimitEnabled(): boolean {\n return this.m_enableLimit;\n }\n\n /**\n * Enable/disable the joint limit.\n */\n enableLimit(flag: boolean): void {\n if (flag != this.m_enableLimit) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableLimit = flag;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Get the lower joint limit in radians.\n */\n getLowerLimit(): number {\n return this.m_lowerAngle;\n }\n\n /**\n * Get the upper joint limit in radians.\n */\n getUpperLimit(): number {\n return this.m_upperAngle;\n }\n\n /**\n * Set the joint limits in radians.\n */\n setLimits(lower: number, upper: number): void {\n if (_ASSERT) console.assert(lower <= upper);\n\n if (lower != this.m_lowerAngle || upper != this.m_upperAngle) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_impulse.z = 0.0;\n this.m_lowerAngle = lower;\n this.m_upperAngle = upper;\n }\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force given the inverse time step. Unit is N.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.neo(this.m_impulse.x, this.m_impulse.y).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque due to the joint limit given the inverse time step.\n * Unit is N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.z;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const fixedRotation = (iA + iB === 0.0);\n\n this.m_mass.ex.x = mA + mB + this.m_rA.y * this.m_rA.y * iA + this.m_rB.y * this.m_rB.y * iB;\n this.m_mass.ey.x = -this.m_rA.y * this.m_rA.x * iA - this.m_rB.y * this.m_rB.x * iB;\n this.m_mass.ez.x = -this.m_rA.y * iA - this.m_rB.y * iB;\n this.m_mass.ex.y = this.m_mass.ey.x;\n this.m_mass.ey.y = mA + mB + this.m_rA.x * this.m_rA.x * iA + this.m_rB.x * this.m_rB.x * iB;\n this.m_mass.ez.y = this.m_rA.x * iA + this.m_rB.x * iB;\n this.m_mass.ex.z = this.m_mass.ez.x;\n this.m_mass.ey.z = this.m_mass.ez.y;\n this.m_mass.ez.z = iA + iB;\n\n this.m_motorMass = iA + iB;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n\n if (this.m_enableMotor == false || fixedRotation) {\n this.m_motorImpulse = 0.0;\n }\n\n if (this.m_enableLimit && fixedRotation == false) {\n const jointAngle = aB - aA - this.m_referenceAngle;\n\n if (math_abs(this.m_upperAngle - this.m_lowerAngle) < 2.0 * Settings.angularSlop) {\n this.m_limitState = LimitState.equalLimits;\n\n } else if (jointAngle <= this.m_lowerAngle) {\n if (this.m_limitState != LimitState.atLowerLimit) {\n this.m_impulse.z = 0.0;\n }\n this.m_limitState = LimitState.atLowerLimit;\n\n } else if (jointAngle >= this.m_upperAngle) {\n if (this.m_limitState != LimitState.atUpperLimit) {\n this.m_impulse.z = 0.0;\n }\n this.m_limitState = LimitState.atUpperLimit;\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_impulse.mul(step.dtRatio);\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_impulse.x, this.m_impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_motorImpulse + this.m_impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_motorImpulse + this.m_impulse.z);\n\n } else {\n this.m_impulse.setZero();\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const fixedRotation = (iA + iB === 0.0);\n\n // Solve motor constraint.\n if (this.m_enableMotor && this.m_limitState != LimitState.equalLimits && fixedRotation == false) {\n const Cdot = wB - wA - this.m_motorSpeed;\n let impulse = -this.m_motorMass * Cdot;\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorTorque;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve limit constraint.\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit && fixedRotation == false) {\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const Cdot2 = wB - wA;\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const impulse = Vec3.neg(this.m_mass.solve33(Cdot));\n\n if (this.m_limitState == LimitState.equalLimits) {\n this.m_impulse.add(impulse);\n\n } else if (this.m_limitState == LimitState.atLowerLimit) {\n const newImpulse = this.m_impulse.z + impulse.z;\n\n if (newImpulse < 0.0) {\n const rhs = Vec2.combine(-1, Cdot1, this.m_impulse.z, Vec2.neo(this.m_mass.ez.x, this.m_mass.ez.y));\n const reduced = this.m_mass.solve22(rhs);\n impulse.x = reduced.x;\n impulse.y = reduced.y;\n impulse.z = -this.m_impulse.z;\n this.m_impulse.x += reduced.x;\n this.m_impulse.y += reduced.y;\n this.m_impulse.z = 0.0;\n\n } else {\n this.m_impulse.add(impulse);\n }\n\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n const newImpulse = this.m_impulse.z + impulse.z;\n\n if (newImpulse > 0.0) {\n const rhs = Vec2.combine(-1, Cdot1, this.m_impulse.z, Vec2.neo(this.m_mass.ez.x, this.m_mass.ez.y));\n const reduced = this.m_mass.solve22(rhs);\n impulse.x = reduced.x;\n impulse.y = reduced.y;\n impulse.z = -this.m_impulse.z;\n this.m_impulse.x += reduced.x;\n this.m_impulse.y += reduced.y;\n this.m_impulse.z = 0.0;\n\n } else {\n this.m_impulse.add(impulse);\n }\n }\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + impulse.z);\n\n } else {\n // Solve point-to-point constraint\n const Cdot = Vec2.zero();\n Cdot.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const impulse = this.m_mass.solve22(Vec2.neg(Cdot));\n\n this.m_impulse.x += impulse.x;\n this.m_impulse.y += impulse.y;\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n let angularError = 0.0;\n let positionError = 0.0;\n\n const fixedRotation = (this.m_invIA + this.m_invIB == 0.0);\n\n // Solve angular limit constraint.\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit && fixedRotation == false) {\n const angle = aB - aA - this.m_referenceAngle;\n let limitImpulse = 0.0;\n\n if (this.m_limitState == LimitState.equalLimits) {\n // Prevent large angular corrections\n const C = clamp(angle - this.m_lowerAngle, -Settings.maxAngularCorrection, Settings.maxAngularCorrection);\n limitImpulse = -this.m_motorMass * C;\n angularError = math_abs(C);\n\n } else if (this.m_limitState == LimitState.atLowerLimit) {\n let C = angle - this.m_lowerAngle;\n angularError = -C;\n\n // Prevent large angular corrections and allow some slop.\n C = clamp(C + Settings.angularSlop, -Settings.maxAngularCorrection, 0.0);\n limitImpulse = -this.m_motorMass * C;\n\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n let C = angle - this.m_upperAngle;\n angularError = C;\n\n // Prevent large angular corrections and allow some slop.\n C = clamp(C - Settings.angularSlop, 0.0, Settings.maxAngularCorrection);\n limitImpulse = -this.m_motorMass * C;\n }\n\n aA -= this.m_invIA * limitImpulse;\n aB += this.m_invIB * limitImpulse;\n }\n\n // Solve point-to-point constraint.\n {\n qA.setAngle(aA);\n qB.setAngle(aB);\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n const C = Vec2.zero();\n C.addCombine(1, cB, 1, rB);\n C.subCombine(1, cA, 1, rA);\n positionError = C.length();\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat22();\n K.ex.x = mA + mB + iA * rA.y * rA.y + iB * rB.y * rB.y;\n K.ex.y = -iA * rA.x * rA.y - iB * rB.x * rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * rA.x * rA.x + iB * rB.x * rB.x;\n\n const impulse = Vec2.neg(K.solve(C));\n\n cA.subMul(mA, impulse);\n aA -= iA * Vec2.crossVec2Vec2(rA, impulse);\n\n cB.addMul(mB, impulse);\n aB += iB * Vec2.crossVec2Vec2(rB, impulse);\n }\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return positionError <= Settings.linearSlop && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3, \n}\n\n/**\n * Prismatic joint definition. This requires defining a line of motion using an\n * axis and an anchor point. The definition uses local anchor points and a local\n * axis so that the initial configuration can violate the constraint slightly.\n * The joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface PrismaticJointOpt extends JointOpt {\n /**\n * Enable/disable the joint limit.\n */\n enableLimit?: boolean;\n /**\n * The lower translation limit, usually in meters.\n */\n lowerTranslation?: number;\n /**\n * The upper translation limit, usually in meters.\n */\n upperTranslation?: number;\n /**\n * Enable/disable the joint motor.\n */\n enableMotor?: boolean;\n /**\n * The maximum motor torque, usually in N-m.\n */\n maxMotorForce?: number;\n /**\n * The desired motor speed in radians per second.\n */\n motorSpeed?: number;\n}\n\n/**\n * Prismatic joint definition. This requires defining a line of motion using an\n * axis and an anchor point. The definition uses local anchor points and a local\n * axis so that the initial configuration can violate the constraint slightly.\n * The joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface PrismaticJointDef extends JointDef, PrismaticJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The local translation unit axis in bodyA.\n */\n localAxisA: Vec2Value;\n /**\n * referenceAngle The constrained angle between the bodies:\n * bodyB_angle - bodyA_angle.\n */\n referenceAngle?: number;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n enableLimit : false,\n lowerTranslation : 0.0,\n upperTranslation : 0.0,\n enableMotor : false,\n maxMotorForce : 0.0,\n motorSpeed : 0.0\n};\n\ndeclare module \"./PrismaticJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PrismaticJoint(def: PrismaticJointDef): PrismaticJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PrismaticJoint(def: PrismaticJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value, axis: Vec2Value): PrismaticJoint;\n}\n\n/**\n * A prismatic joint. This joint provides one degree of freedom: translation\n * along an axis fixed in bodyA. Relative rotation is prevented. You can use a\n * joint limit to restrict the range of motion and a joint motor to drive the\n * motion or to model joint friction.\n */\n// @ts-expect-error\nexport class PrismaticJoint extends Joint {\n static TYPE = \"prismatic-joint\" as const;\n\n /** @internal */ m_type: \"prismatic-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_localXAxisA: Vec2;\n /** @internal */ m_localYAxisA: Vec2;\n /** @internal */ m_referenceAngle: number;\n /** @internal */ m_impulse: Vec3;\n /** @internal */ m_motorMass: number;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_lowerTranslation: number;\n /** @internal */ m_upperTranslation: number;\n /** @internal */ m_maxMotorForce: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableLimit: boolean;\n /** @internal */ m_enableMotor: boolean;\n /** @internal */ m_limitState: number; // TODO enum\n /** @internal */ m_axis: Vec2;\n /** @internal */ m_perp: Vec2;\n // Solver temp\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_s1: number;\n /** @internal */ m_s2: number;\n /** @internal */ m_a1: number;\n /** @internal */ m_a2: number;\n /** @internal */ m_K: Mat33;\n\n constructor(def: PrismaticJointDef);\n constructor(def: PrismaticJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value, axis?: Vec2Value);\n constructor(def: PrismaticJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value, axis?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PrismaticJoint)) {\n return new PrismaticJoint(def, bodyA, bodyB, anchor, axis);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = PrismaticJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n this.m_localXAxisA = Vec2.clone(axis ? bodyA.getLocalVector(axis) : def.localAxisA || Vec2.neo(1.0, 0.0));\n this.m_localXAxisA.normalize();\n this.m_localYAxisA = Vec2.crossNumVec2(1.0, this.m_localXAxisA);\n this.m_referenceAngle = Number.isFinite(def.referenceAngle) ? def.referenceAngle : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_impulse = new Vec3();\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n\n this.m_lowerTranslation = def.lowerTranslation;\n this.m_upperTranslation = def.upperTranslation;\n this.m_maxMotorForce = def.maxMotorForce;\n this.m_motorSpeed = def.motorSpeed;\n this.m_enableLimit = def.enableLimit;\n this.m_enableMotor = def.enableMotor;\n this.m_limitState = LimitState.inactiveLimit;\n\n this.m_axis = Vec2.zero();\n this.m_perp = Vec2.zero();\n\n this.m_K = new Mat33();\n\n // Linear constraint (point-to-line)\n // d = p2 - p1 = x2 + r2 - x1 - r1\n // C = dot(perp, d)\n // Cdot = dot(d, cross(w1, perp)) + dot(perp, v2 + cross(w2, r2) - v1 -\n // cross(w1, r1))\n // = -dot(perp, v1) - dot(cross(d + r1, perp), w1) + dot(perp, v2) +\n // dot(cross(r2, perp), v2)\n // J = [-perp, -cross(d + r1, perp), perp, cross(r2,perp)]\n //\n // Angular constraint\n // C = a2 - a1 + a_initial\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n //\n // K = J * invM * JT\n //\n // J = [-a -s1 a s2]\n // [0 -1 0 1]\n // a = perp\n // s1 = cross(d + r1, a) = cross(p2 - x1, a)\n // s2 = cross(r2, a) = cross(p2 - x2, a)\n\n // Motor/Limit linear constraint\n // C = dot(ax1, d)\n // Cdot = = -dot(ax1, v1) - dot(cross(d + r1, ax1), w1) + dot(ax1, v2) +\n // dot(cross(r2, ax1), v2)\n // J = [-ax1 -cross(d+r1,ax1) ax1 cross(r2,ax1)]\n\n // Block Solver\n // We develop a block solver that includes the joint limit. This makes the\n // limit stiff (inelastic) even\n // when the mass has poor distribution (leading to large torques about the\n // joint anchor points).\n //\n // The Jacobian has 3 rows:\n // J = [-uT -s1 uT s2] // linear\n // [0 -1 0 1] // angular\n // [-vT -a1 vT a2] // limit\n //\n // u = perp\n // v = axis\n // s1 = cross(d + r1, u), s2 = cross(r2, u)\n // a1 = cross(d + r1, v), a2 = cross(r2, v)\n\n // M * (v2 - v1) = JT * df\n // J * v2 = bias\n //\n // v2 = v1 + invM * JT * df\n // J * (v1 + invM * JT * df) = bias\n // K * df = bias - J * v1 = -Cdot\n // K = J * invM * JT\n // Cdot = J * v1 - bias\n //\n // Now solve for f2.\n // df = f2 - f1\n // K * (f2 - f1) = -Cdot\n // f2 = invK * (-Cdot) + f1\n //\n // Clamp accumulated limit impulse.\n // lower: f2(3) = max(f2(3), 0)\n // upper: f2(3) = min(f2(3), 0)\n //\n // Solve for correct f2(1:2)\n // K(1:2, 1:2) * f2(1:2) = -Cdot(1:2) - K(1:2,3) * f2(3) + K(1:2,1:3) * f1\n // = -Cdot(1:2) - K(1:2,3) * f2(3) + K(1:2,1:2) * f1(1:2) + K(1:2,3) * f1(3)\n // K(1:2, 1:2) * f2(1:2) = -Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3)) +\n // K(1:2,1:2) * f1(1:2)\n // f2(1:2) = invK(1:2,1:2) * (-Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3))) +\n // f1(1:2)\n //\n // Now compute impulse to be applied:\n // df = f2 - f1\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n lowerTranslation: this.m_lowerTranslation,\n upperTranslation: this.m_upperTranslation,\n maxMotorForce: this.m_maxMotorForce,\n motorSpeed: this.m_motorSpeed,\n enableLimit: this.m_enableLimit,\n enableMotor: this.m_enableMotor,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n localAxisA: this.m_localXAxisA,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): PrismaticJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.localAxisA = Vec2.clone(data.localAxisA);\n const joint = new PrismaticJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (def.localAxisA) {\n this.m_localXAxisA.setVec2(def.localAxisA);\n this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1.0, def.localAxisA));\n }\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n }\n if (typeof def.enableLimit !== \"undefined\") {\n this.m_enableLimit = !!def.enableLimit;\n }\n if (Number.isFinite(def.lowerTranslation)) {\n this.m_lowerTranslation = def.lowerTranslation;\n }\n if (Number.isFinite(def.upperTranslation)) {\n this.m_upperTranslation = def.upperTranslation;\n }\n if (typeof def.enableMotor !== \"undefined\") {\n this.m_enableMotor = !!def.enableMotor;\n }\n if (Number.isFinite(def.maxMotorForce)) {\n this.m_maxMotorForce = def.maxMotorForce;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * The local joint axis relative to bodyA.\n */\n getLocalAxisA(): Vec2 {\n return this.m_localXAxisA;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Get the current joint translation, usually in meters.\n */\n getJointTranslation(): number {\n const pA = this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n const pB = this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n const d = Vec2.sub(pB, pA);\n const axis = this.m_bodyA.getWorldVector(this.m_localXAxisA);\n\n const translation = Vec2.dot(d, axis);\n return translation;\n }\n\n /**\n * Get the current joint translation speed, usually in meters per second.\n */\n getJointSpeed(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n\n const rA = Rot.mulVec2(bA.m_xf.q, Vec2.sub(this.m_localAnchorA, bA.m_sweep.localCenter));\n const rB = Rot.mulVec2(bB.m_xf.q, Vec2.sub(this.m_localAnchorB, bB.m_sweep.localCenter));\n const p1 = Vec2.add(bA.m_sweep.c, rA);\n const p2 = Vec2.add(bB.m_sweep.c, rB);\n const d = Vec2.sub(p2, p1);\n const axis = Rot.mulVec2(bA.m_xf.q, this.m_localXAxisA);\n\n const vA = bA.m_linearVelocity;\n const vB = bB.m_linearVelocity;\n const wA = bA.m_angularVelocity;\n const wB = bB.m_angularVelocity;\n\n const speed = Vec2.dot(d, Vec2.crossNumVec2(wA, axis)) + Vec2.dot(axis, Vec2.sub(Vec2.addCrossNumVec2(vB, wB, rB), Vec2.addCrossNumVec2(vA, wA, rA)));\n return speed;\n }\n\n /**\n * Is the joint limit enabled?\n */\n isLimitEnabled(): boolean {\n return this.m_enableLimit;\n }\n\n /**\n * Enable/disable the joint limit.\n */\n enableLimit(flag: boolean): void {\n if (flag != this.m_enableLimit) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableLimit = flag;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Get the lower joint limit, usually in meters.\n */\n getLowerLimit(): number {\n return this.m_lowerTranslation;\n }\n\n /**\n * Get the upper joint limit, usually in meters.\n */\n getUpperLimit(): number {\n return this.m_upperTranslation;\n }\n\n /**\n * Set the joint limits, usually in meters.\n */\n setLimits(lower: number, upper: number): void {\n if (_ASSERT) console.assert(lower <= upper);\n if (lower != this.m_lowerTranslation || upper != this.m_upperTranslation) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_lowerTranslation = lower;\n this.m_upperTranslation = upper;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Set the motor speed, usually in meters per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Set the maximum motor force, usually in N.\n */\n setMaxMotorForce(force: number): void {\n if (force == this.m_maxMotorForce) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorForce = force;\n }\n\n getMaxMotorForce(): number {\n return this.m_maxMotorForce;\n }\n\n /**\n * Get the motor speed, usually in meters per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Get the current motor force given the inverse time step, usually in N.\n */\n getMotorForce(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.combine(this.m_impulse.x, this.m_perp, this.m_motorImpulse + this.m_impulse.z, this.m_axis).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.y;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective masses.\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Compute motor Jacobian and effective mass.\n {\n this.m_axis = Rot.mulVec2(qA, this.m_localXAxisA);\n this.m_a1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_axis);\n this.m_a2 = Vec2.crossVec2Vec2(rB, this.m_axis);\n\n this.m_motorMass = mA + mB + iA * this.m_a1 * this.m_a1 + iB * this.m_a2\n * this.m_a2;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n }\n\n // Prismatic constraint.\n {\n this.m_perp = Rot.mulVec2(qA, this.m_localYAxisA);\n\n this.m_s1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_perp);\n this.m_s2 = Vec2.crossVec2Vec2(rB, this.m_perp);\n\n const s1test = Vec2.crossVec2Vec2(rA, this.m_perp);\n\n const k11 = mA + mB + iA * this.m_s1 * this.m_s1 + iB * this.m_s2 * this.m_s2;\n const k12 = iA * this.m_s1 + iB * this.m_s2;\n const k13 = iA * this.m_s1 * this.m_a1 + iB * this.m_s2 * this.m_a2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n // For bodies with fixed rotation.\n k22 = 1.0;\n }\n const k23 = iA * this.m_a1 + iB * this.m_a2;\n const k33 = mA + mB + iA * this.m_a1 * this.m_a1 + iB * this.m_a2 * this.m_a2;\n\n this.m_K.ex.set(k11, k12, k13);\n this.m_K.ey.set(k12, k22, k23);\n this.m_K.ez.set(k13, k23, k33);\n }\n\n // Compute motor and limit terms.\n if (this.m_enableLimit) {\n\n const jointTranslation = Vec2.dot(this.m_axis, d);\n if (math_abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * Settings.linearSlop) {\n this.m_limitState = LimitState.equalLimits;\n\n } else if (jointTranslation <= this.m_lowerTranslation) {\n if (this.m_limitState != LimitState.atLowerLimit) {\n this.m_limitState = LimitState.atLowerLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else if (jointTranslation >= this.m_upperTranslation) {\n if (this.m_limitState != LimitState.atUpperLimit) {\n this.m_limitState = LimitState.atUpperLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n if (this.m_enableMotor == false) {\n this.m_motorImpulse = 0.0;\n }\n\n if (step.warmStarting) {\n // Account for variable time step.\n this.m_impulse.mul(step.dtRatio);\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.combine(this.m_impulse.x, this.m_perp, this.m_motorImpulse\n + this.m_impulse.z, this.m_axis);\n const LA = this.m_impulse.x * this.m_s1 + this.m_impulse.y\n + (this.m_motorImpulse + this.m_impulse.z) * this.m_a1;\n const LB = this.m_impulse.x * this.m_s2 + this.m_impulse.y\n + (this.m_motorImpulse + this.m_impulse.z) * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n } else {\n this.m_impulse.setZero();\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Solve linear motor constraint.\n if (this.m_enableMotor && this.m_limitState != LimitState.equalLimits) {\n const Cdot = Vec2.dot(this.m_axis, Vec2.sub(vB, vA)) + this.m_a2 * wB\n - this.m_a1 * wA;\n let impulse = this.m_motorMass * (this.m_motorSpeed - Cdot);\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorForce;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse,\n -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_axis);\n const LA = impulse * this.m_a1;\n const LB = impulse * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n const Cdot1 = Vec2.zero();\n Cdot1.x += Vec2.dot(this.m_perp, vB) + this.m_s2 * wB;\n Cdot1.x -= Vec2.dot(this.m_perp, vA) + this.m_s1 * wA;\n Cdot1.y = wB - wA;\n\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit) {\n // Solve prismatic and limit constraint in block form.\n let Cdot2 = 0;\n Cdot2 += Vec2.dot(this.m_axis, vB) + this.m_a2 * wB;\n Cdot2 -= Vec2.dot(this.m_axis, vA) + this.m_a1 * wA;\n\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const f1 = Vec3.clone(this.m_impulse);\n let df = this.m_K.solve33(Vec3.neg(Cdot));\n this.m_impulse.add(df);\n\n if (this.m_limitState == LimitState.atLowerLimit) {\n this.m_impulse.z = math_max(this.m_impulse.z, 0.0);\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n this.m_impulse.z = math_min(this.m_impulse.z, 0.0);\n }\n\n // f2(1:2) = invK(1:2,1:2) * (-Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3))) +\n // f1(1:2)\n const b = Vec2.combine(-1, Cdot1, -(this.m_impulse.z - f1.z), Vec2.neo(this.m_K.ez.x, this.m_K.ez.y));\n const f2r = Vec2.add(this.m_K.solve22(b), Vec2.neo(f1.x, f1.y));\n this.m_impulse.x = f2r.x;\n this.m_impulse.y = f2r.y;\n\n df = Vec3.sub(this.m_impulse, f1);\n\n const P = Vec2.combine(df.x, this.m_perp, df.z, this.m_axis);\n const LA = df.x * this.m_s1 + df.y + df.z * this.m_a1;\n const LB = df.x * this.m_s2 + df.y + df.z * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n } else {\n // Limit is inactive, just solve the prismatic constraint in block form.\n const df = this.m_K.solve22(Vec2.neg(Cdot1));\n this.m_impulse.x += df.x;\n this.m_impulse.y += df.y;\n\n const P = Vec2.mulNumVec2(df.x, this.m_perp);\n const LA = df.x * this.m_s1 + df.y;\n const LB = df.x * this.m_s2 + df.y;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Compute fresh Jacobians\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.sub(Vec2.add(cB, rB), Vec2.add(cA, rA));\n\n const axis = Rot.mulVec2(qA, this.m_localXAxisA);\n const a1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), axis);\n const a2 = Vec2.crossVec2Vec2(rB, axis);\n const perp = Rot.mulVec2(qA, this.m_localYAxisA);\n\n const s1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), perp);\n const s2 = Vec2.crossVec2Vec2(rB, perp);\n\n let impulse = new Vec3();\n const C1 = Vec2.zero();\n C1.x = Vec2.dot(perp, d);\n C1.y = aB - aA - this.m_referenceAngle;\n\n let linearError = math_abs(C1.x);\n const angularError = math_abs(C1.y);\n\n const linearSlop = Settings.linearSlop;\n const maxLinearCorrection = Settings.maxLinearCorrection;\n\n let active = false; // bool\n let C2 = 0.0;\n if (this.m_enableLimit) {\n\n const translation = Vec2.dot(axis, d);\n if (math_abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * linearSlop) {\n // Prevent large angular corrections\n C2 = clamp(translation, -maxLinearCorrection, maxLinearCorrection);\n linearError = math_max(linearError, math_abs(translation));\n active = true;\n\n } else if (translation <= this.m_lowerTranslation) {\n // Prevent large linear corrections and allow some slop.\n C2 = clamp(translation - this.m_lowerTranslation + linearSlop,\n -maxLinearCorrection, 0.0);\n linearError = Math\n .max(linearError, this.m_lowerTranslation - translation);\n active = true;\n\n } else if (translation >= this.m_upperTranslation) {\n // Prevent large linear corrections and allow some slop.\n C2 = clamp(translation - this.m_upperTranslation - linearSlop, 0.0,\n maxLinearCorrection);\n linearError = Math\n .max(linearError, translation - this.m_upperTranslation);\n active = true;\n }\n }\n\n if (active) {\n const k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2;\n const k12 = iA * s1 + iB * s2;\n const k13 = iA * s1 * a1 + iB * s2 * a2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n // For fixed rotation\n k22 = 1.0;\n }\n const k23 = iA * a1 + iB * a2;\n const k33 = mA + mB + iA * a1 * a1 + iB * a2 * a2;\n\n const K = new Mat33();\n K.ex.set(k11, k12, k13);\n K.ey.set(k12, k22, k23);\n K.ez.set(k13, k23, k33);\n\n const C = new Vec3();\n C.x = C1.x;\n C.y = C1.y;\n C.z = C2;\n\n impulse = K.solve33(Vec3.neg(C));\n } else {\n const k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2;\n const k12 = iA * s1 + iB * s2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n k22 = 1.0;\n }\n\n const K = new Mat22();\n K.ex.setNum(k11, k12);\n K.ey.setNum(k12, k22);\n\n const impulse1 = K.solve(Vec2.neg(C1));\n impulse.x = impulse1.x;\n impulse.y = impulse1.y;\n impulse.z = 0.0;\n }\n\n const P = Vec2.combine(impulse.x, perp, impulse.z, axis);\n const LA = impulse.x * s1 + impulse.y + impulse.z * a1;\n const LB = impulse.x * s2 + impulse.y + impulse.z * a2;\n\n cA.subMul(mA, P);\n aA -= iA * LA;\n cB.addMul(mB, P);\n aB += iB * LB;\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return linearError <= Settings.linearSlop\n && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { } from \"../../common/Math\";\nimport { Vec2 } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { RevoluteJoint } from \"./RevoluteJoint\";\nimport { PrismaticJoint } from \"./PrismaticJoint\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Gear joint definition.\n */\nexport interface GearJointOpt extends JointOpt {\n /**\n * The gear ratio. See {@link GearJoint} for explanation.\n */\n ratio?: number;\n}\n\n/**\n * Gear joint definition.\n */\nexport interface GearJointDef extends JointDef, GearJointOpt {\n /**\n * The first revolute/prismatic joint attached to the gear joint.\n */\n joint1: RevoluteJoint | PrismaticJoint;\n /**\n * The second prismatic/revolute joint attached to the gear joint.\n */\n joint2: RevoluteJoint | PrismaticJoint;\n}\n\n/** @internal */ const DEFAULTS = {\n ratio : 1.0\n};\n\ndeclare module \"./GearJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function GearJoint(def: GearJointDef): GearJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function GearJoint(def: GearJointOpt, bodyA: Body, bodyB: Body, joint1: RevoluteJoint | PrismaticJoint, joint2: RevoluteJoint | PrismaticJoint, ratio?: number): GearJoint;\n}\n\n/**\n * A gear joint is used to connect two joints together. Either joint can be a\n * revolute or prismatic joint. You specify a gear ratio to bind the motions\n * together: coordinate1 + ratio * coordinate2 = constant\n *\n * The ratio can be negative or positive. If one joint is a revolute joint and\n * the other joint is a prismatic joint, then the ratio will have units of\n * length or units of 1/length. Warning: You have to manually destroy the gear\n * joint if joint1 or joint2 is destroyed.\n *\n * This definition requires two existing revolute or prismatic joints (any\n * combination will work).\n */\n// @ts-expect-error\nexport class GearJoint extends Joint {\n static TYPE = \"gear-joint\" as const;\n\n /** @internal */ m_type: \"gear-joint\";\n /** @internal */ m_joint1: RevoluteJoint | PrismaticJoint;\n /** @internal */ m_joint2: RevoluteJoint | PrismaticJoint;\n /** @internal */ m_type1: \"revolute-joint\" | \"prismatic-joint\";\n /** @internal */ m_type2: \"revolute-joint\" | \"prismatic-joint\";\n /** @internal */ m_bodyC: Body;\n /** @internal */ m_localAnchorC: Vec2;\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_referenceAngleA: number;\n /** @internal */ m_localAxisC: Vec2;\n /** @internal */ m_bodyD: Body;\n /** @internal */ m_localAnchorD: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngleB: number;\n /** @internal */ m_localAxisD: Vec2;\n /** @internal */ m_ratio: number;\n /** @internal */ m_constant: number;\n /** @internal */ m_impulse: number;\n\n // Solver temp\n /** @internal */ m_lcA: Vec2;\n /** @internal */ m_lcB: Vec2;\n /** @internal */ m_lcC: Vec2;\n /** @internal */ m_lcD: Vec2;\n /** @internal */ m_mA: number;\n /** @internal */ m_mB: number;\n /** @internal */ m_mC: number;\n /** @internal */ m_mD: number;\n /** @internal */ m_iA: number;\n /** @internal */ m_iB: number;\n /** @internal */ m_iC: number;\n /** @internal */ m_iD: number;\n /** @internal */ m_JvAC: Vec2;\n /** @internal */ m_JvBD: Vec2;\n /** @internal */ m_JwA: number;\n /** @internal */ m_JwB: number;\n /** @internal */ m_JwC: number;\n /** @internal */ m_JwD: number;\n /** @internal */ m_mass: number;\n\n constructor(def: GearJointDef);\n constructor(def: GearJointOpt, bodyA: Body, bodyB: Body, joint1: RevoluteJoint | PrismaticJoint, joint2: RevoluteJoint | PrismaticJoint, ratio?: number);\n constructor(def: GearJointDef, bodyA?: Body, bodyB?: Body, joint1?: RevoluteJoint | PrismaticJoint, joint2?: RevoluteJoint | PrismaticJoint, ratio?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof GearJoint)) {\n return new GearJoint(def, bodyA, bodyB, joint1, joint2, ratio);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = GearJoint.TYPE;\n\n if (_ASSERT) console.assert(joint1.m_type === RevoluteJoint.TYPE || joint1.m_type === PrismaticJoint.TYPE);\n if (_ASSERT) console.assert(joint2.m_type === RevoluteJoint.TYPE || joint2.m_type === PrismaticJoint.TYPE);\n\n this.m_joint1 = joint1 ? joint1 : def.joint1;\n this.m_joint2 = joint2 ? joint2 : def.joint2;\n this.m_ratio = Number.isFinite(ratio) ? ratio : def.ratio;\n\n this.m_type1 = this.m_joint1.getType() as \"revolute-joint\" | \"prismatic-joint\";\n this.m_type2 = this.m_joint2.getType() as \"revolute-joint\" | \"prismatic-joint\";\n\n // joint1 connects body A to body C\n // joint2 connects body B to body D\n\n let coordinateA: number;\n let coordinateB: number;\n\n // TODO_ERIN there might be some problem with the joint edges in Joint.\n\n this.m_bodyC = this.m_joint1.getBodyA();\n this.m_bodyA = this.m_joint1.getBodyB();\n\n // Get geometry of joint1\n const xfA = this.m_bodyA.m_xf;\n const aA = this.m_bodyA.m_sweep.a;\n const xfC = this.m_bodyC.m_xf;\n const aC = this.m_bodyC.m_sweep.a;\n\n if (this.m_type1 === RevoluteJoint.TYPE) {\n const revolute = this.m_joint1 as RevoluteJoint;\n this.m_localAnchorC = revolute.m_localAnchorA;\n this.m_localAnchorA = revolute.m_localAnchorB;\n this.m_referenceAngleA = revolute.m_referenceAngle;\n this.m_localAxisC = Vec2.zero();\n\n coordinateA = aA - aC - this.m_referenceAngleA;\n } else {\n const prismatic = this.m_joint1 as PrismaticJoint;\n this.m_localAnchorC = prismatic.m_localAnchorA;\n this.m_localAnchorA = prismatic.m_localAnchorB;\n this.m_referenceAngleA = prismatic.m_referenceAngle;\n this.m_localAxisC = prismatic.m_localXAxisA;\n\n const pC = this.m_localAnchorC;\n const pA = Rot.mulTVec2(xfC.q, Vec2.add(Rot.mulVec2(xfA.q, this.m_localAnchorA), Vec2.sub(xfA.p, xfC.p)));\n coordinateA = Vec2.dot(pA, this.m_localAxisC) - Vec2.dot(pC, this.m_localAxisC);\n }\n\n this.m_bodyD = this.m_joint2.getBodyA();\n this.m_bodyB = this.m_joint2.getBodyB();\n\n // Get geometry of joint2\n const xfB = this.m_bodyB.m_xf;\n const aB = this.m_bodyB.m_sweep.a;\n const xfD = this.m_bodyD.m_xf;\n const aD = this.m_bodyD.m_sweep.a;\n\n if (this.m_type2 === RevoluteJoint.TYPE) {\n const revolute = this.m_joint2 as RevoluteJoint;\n this.m_localAnchorD = revolute.m_localAnchorA;\n this.m_localAnchorB = revolute.m_localAnchorB;\n this.m_referenceAngleB = revolute.m_referenceAngle;\n this.m_localAxisD = Vec2.zero();\n\n coordinateB = aB - aD - this.m_referenceAngleB;\n } else {\n const prismatic = this.m_joint2 as PrismaticJoint;\n this.m_localAnchorD = prismatic.m_localAnchorA;\n this.m_localAnchorB = prismatic.m_localAnchorB;\n this.m_referenceAngleB = prismatic.m_referenceAngle;\n this.m_localAxisD = prismatic.m_localXAxisA;\n\n const pD = this.m_localAnchorD;\n const pB = Rot.mulTVec2(xfD.q, Vec2.add(Rot.mulVec2(xfB.q, this.m_localAnchorB), Vec2.sub(xfB.p, xfD.p)));\n coordinateB = Vec2.dot(pB, this.m_localAxisD) - Vec2.dot(pD, this.m_localAxisD);\n }\n\n this.m_constant = coordinateA + this.m_ratio * coordinateB;\n\n this.m_impulse = 0.0;\n\n // Gear Joint:\n // C0 = (coordinate1 + ratio * coordinate2)_initial\n // C = (coordinate1 + ratio * coordinate2) - C0 = 0\n // J = [J1 ratio * J2]\n // K = J * invM * JT\n // = J1 * invM1 * J1T + ratio * ratio * J2 * invM2 * J2T\n //\n // Revolute:\n // coordinate = rotation\n // Cdot = angularVelocity\n // J = [0 0 1]\n // K = J * invM * JT = invI\n //\n // Prismatic:\n // coordinate = dot(p - pg, ug)\n // Cdot = dot(v + cross(w, r), ug)\n // J = [ug cross(r, ug)]\n // K = J * invM * JT = invMass + invI * cross(r, ug)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n joint1: this.m_joint1,\n joint2: this.m_joint2,\n ratio: this.m_ratio,\n\n // _constant: this.m_constant,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): GearJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.joint1 = restore(Joint, data.joint1, world);\n data.joint2 = restore(Joint, data.joint2, world);\n const joint = new GearJoint(data);\n // if (data._constant) joint.m_constant = data._constant;\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n // todo: implement other fields\n if (Number.isFinite(def.ratio)) {\n this.m_ratio = def.ratio;\n }\n }\n\n /**\n * Get the first joint.\n */\n getJoint1(): Joint {\n return this.m_joint1;\n }\n\n /**\n * Get the second joint.\n */\n getJoint2(): Joint {\n return this.m_joint2;\n }\n\n /**\n * Set the gear ratio.\n */\n setRatio(ratio: number): void {\n if (_ASSERT) console.assert(Number.isFinite(ratio));\n this.m_ratio = ratio;\n }\n\n /**\n * Get the gear ratio.\n */\n getRatio(): number {\n return this.m_ratio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_JvAC).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n const L = this.m_impulse * this.m_JwA;\n return inv_dt * L;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_lcA = this.m_bodyA.m_sweep.localCenter;\n this.m_lcB = this.m_bodyB.m_sweep.localCenter;\n this.m_lcC = this.m_bodyC.m_sweep.localCenter;\n this.m_lcD = this.m_bodyD.m_sweep.localCenter;\n this.m_mA = this.m_bodyA.m_invMass;\n this.m_mB = this.m_bodyB.m_invMass;\n this.m_mC = this.m_bodyC.m_invMass;\n this.m_mD = this.m_bodyD.m_invMass;\n this.m_iA = this.m_bodyA.m_invI;\n this.m_iB = this.m_bodyB.m_invI;\n this.m_iC = this.m_bodyC.m_invI;\n this.m_iD = this.m_bodyD.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const aC = this.m_bodyC.c_position.a;\n const vC = this.m_bodyC.c_velocity.v;\n let wC = this.m_bodyC.c_velocity.w;\n\n const aD = this.m_bodyD.c_position.a;\n const vD = this.m_bodyD.c_velocity.v;\n let wD = this.m_bodyD.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n const qC = Rot.neo(aC);\n const qD = Rot.neo(aD);\n\n this.m_mass = 0.0;\n\n if (this.m_type1 == RevoluteJoint.TYPE) {\n this.m_JvAC = Vec2.zero();\n this.m_JwA = 1.0;\n this.m_JwC = 1.0;\n this.m_mass += this.m_iA + this.m_iC;\n } else {\n const u = Rot.mulVec2(qC, this.m_localAxisC);\n const rC = Rot.mulSub(qC, this.m_localAnchorC, this.m_lcC);\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_lcA);\n this.m_JvAC = u;\n this.m_JwC = Vec2.crossVec2Vec2(rC, u);\n this.m_JwA = Vec2.crossVec2Vec2(rA, u);\n this.m_mass += this.m_mC + this.m_mA + this.m_iC * this.m_JwC * this.m_JwC + this.m_iA * this.m_JwA * this.m_JwA;\n }\n\n if (this.m_type2 == RevoluteJoint.TYPE) {\n this.m_JvBD = Vec2.zero();\n this.m_JwB = this.m_ratio;\n this.m_JwD = this.m_ratio;\n this.m_mass += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD);\n } else {\n const u = Rot.mulVec2(qD, this.m_localAxisD);\n const rD = Rot.mulSub(qD, this.m_localAnchorD, this.m_lcD);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_lcB);\n this.m_JvBD = Vec2.mulNumVec2(this.m_ratio, u);\n this.m_JwD = this.m_ratio * Vec2.crossVec2Vec2(rD, u);\n this.m_JwB = this.m_ratio * Vec2.crossVec2Vec2(rB, u);\n this.m_mass += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * this.m_JwD * this.m_JwD + this.m_iB * this.m_JwB * this.m_JwB;\n }\n\n // Compute effective mass.\n this.m_mass = this.m_mass > 0.0 ? 1.0 / this.m_mass : 0.0;\n\n if (step.warmStarting) {\n vA.addMul(this.m_mA * this.m_impulse, this.m_JvAC);\n wA += this.m_iA * this.m_impulse * this.m_JwA;\n\n vB.addMul(this.m_mB * this.m_impulse, this.m_JvBD);\n wB += this.m_iB * this.m_impulse * this.m_JwB;\n\n vC.subMul(this.m_mC * this.m_impulse, this.m_JvAC);\n wC -= this.m_iC * this.m_impulse * this.m_JwC;\n\n vD.subMul(this.m_mD * this.m_impulse, this.m_JvBD);\n wD -= this.m_iD * this.m_impulse * this.m_JwD;\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n this.m_bodyC.c_velocity.v.setVec2(vC);\n this.m_bodyC.c_velocity.w = wC;\n this.m_bodyD.c_velocity.v.setVec2(vD);\n this.m_bodyD.c_velocity.w = wD;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n const vC = this.m_bodyC.c_velocity.v;\n let wC = this.m_bodyC.c_velocity.w;\n const vD = this.m_bodyD.c_velocity.v;\n let wD = this.m_bodyD.c_velocity.w;\n\n let Cdot = Vec2.dot(this.m_JvAC, vA) - Vec2.dot(this.m_JvAC, vC) + Vec2.dot(this.m_JvBD, vB) - Vec2.dot(this.m_JvBD, vD);\n Cdot += (this.m_JwA * wA - this.m_JwC * wC) + (this.m_JwB * wB - this.m_JwD * wD);\n\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n vA.addMul(this.m_mA * impulse, this.m_JvAC);\n wA += this.m_iA * impulse * this.m_JwA;\n vB.addMul(this.m_mB * impulse, this.m_JvBD);\n wB += this.m_iB * impulse * this.m_JwB;\n vC.subMul(this.m_mC * impulse, this.m_JvAC);\n wC -= this.m_iC * impulse * this.m_JwC;\n vD.subMul(this.m_mD * impulse, this.m_JvBD);\n wD -= this.m_iD * impulse * this.m_JwD;\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n this.m_bodyC.c_velocity.v.setVec2(vC);\n this.m_bodyC.c_velocity.w = wC;\n this.m_bodyD.c_velocity.v.setVec2(vD);\n this.m_bodyD.c_velocity.w = wD;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n const cC = this.m_bodyC.c_position.c;\n let aC = this.m_bodyC.c_position.a;\n const cD = this.m_bodyD.c_position.c;\n let aD = this.m_bodyD.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n const qC = Rot.neo(aC);\n const qD = Rot.neo(aD);\n\n const linearError = 0.0;\n\n let coordinateA: number;\n let coordinateB: number;\n\n let JvAC: Vec2;\n let JvBD: Vec2;\n let JwA: number;\n let JwB: number;\n let JwC: number;\n let JwD: number;\n let mass = 0.0;\n\n if (this.m_type1 == RevoluteJoint.TYPE) {\n JvAC = Vec2.zero();\n JwA = 1.0;\n JwC = 1.0;\n mass += this.m_iA + this.m_iC;\n\n coordinateA = aA - aC - this.m_referenceAngleA;\n } else {\n const u = Rot.mulVec2(qC, this.m_localAxisC);\n const rC = Rot.mulSub(qC, this.m_localAnchorC, this.m_lcC);\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_lcA);\n JvAC = u;\n JwC = Vec2.crossVec2Vec2(rC, u);\n JwA = Vec2.crossVec2Vec2(rA, u);\n mass += this.m_mC + this.m_mA + this.m_iC * JwC * JwC + this.m_iA * JwA * JwA;\n\n const pC = Vec2.sub(this.m_localAnchorC, this.m_lcC);\n const pA = Rot.mulTVec2(qC, Vec2.add(rA, Vec2.sub(cA, cC)));\n coordinateA = Vec2.dot(Vec2.sub(pA, pC), this.m_localAxisC);\n }\n\n if (this.m_type2 == RevoluteJoint.TYPE) {\n JvBD = Vec2.zero();\n JwB = this.m_ratio;\n JwD = this.m_ratio;\n mass += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD);\n\n coordinateB = aB - aD - this.m_referenceAngleB;\n } else {\n const u = Rot.mulVec2(qD, this.m_localAxisD);\n const rD = Rot.mulSub(qD, this.m_localAnchorD, this.m_lcD);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_lcB);\n JvBD = Vec2.mulNumVec2(this.m_ratio, u);\n JwD = this.m_ratio * Vec2.crossVec2Vec2(rD, u);\n JwB = this.m_ratio * Vec2.crossVec2Vec2(rB, u);\n mass += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * JwD * JwD + this.m_iB * JwB * JwB;\n\n const pD = Vec2.sub(this.m_localAnchorD, this.m_lcD);\n const pB = Rot.mulTVec2(qD, Vec2.add(rB, Vec2.sub(cB, cD)));\n coordinateB = Vec2.dot(pB, this.m_localAxisD) - Vec2.dot(pD, this.m_localAxisD);\n }\n\n const C = (coordinateA + this.m_ratio * coordinateB) - this.m_constant;\n\n let impulse = 0.0;\n if (mass > 0.0) {\n impulse = -C / mass;\n }\n\n cA.addMul(this.m_mA * impulse, JvAC);\n aA += this.m_iA * impulse * JwA;\n cB.addMul(this.m_mB * impulse, JvBD);\n aB += this.m_iB * impulse * JwB;\n cC.subMul(this.m_mC * impulse, JvAC);\n aC -= this.m_iC * impulse * JwC;\n cD.subMul(this.m_mD * impulse, JvBD);\n aD -= this.m_iD * impulse * JwD;\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n this.m_bodyC.c_position.c.setVec2(cC);\n this.m_bodyC.c_position.a = aC;\n this.m_bodyD.c_position.c.setVec2(cD);\n this.m_bodyD.c_position.a = aD;\n\n // TODO_ERIN not implemented\n return linearError < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Motor joint definition.\n */\nexport interface MotorJointOpt extends JointOpt {\n /**\n * The bodyB angle minus bodyA angle in radians.\n */\n angularOffset?: number;\n /**\n * The maximum motor force in N.\n */\n maxForce?: number;\n /**\n * The maximum motor torque in N-m.\n */\n maxTorque?: number;\n /**\n * Position correction factor in the range [0,1].\n */\n correctionFactor?: number;\n /**\n * Position of bodyB minus the position of bodyA, in bodyA's frame, in meters.\n */\n linearOffset?: Vec2Value;\n}\n\n/**\n * Motor joint definition.\n */\nexport interface MotorJointDef extends JointDef, MotorJointOpt {\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 1.0,\n maxTorque : 1.0,\n correctionFactor : 0.3\n};\n\ndeclare module \"./MotorJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MotorJoint(def: MotorJointDef): MotorJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MotorJoint(def: MotorJointOpt, bodyA: Body, bodyB: Body): MotorJoint;\n}\n\n/**\n * A motor joint is used to control the relative motion between two bodies. A\n * typical usage is to control the movement of a dynamic body with respect to\n * the ground.\n */\n// @ts-expect-error\nexport class MotorJoint extends Joint {\n static TYPE = \"motor-joint\" as const;\n\n /** @internal */ m_type: \"motor-joint\";\n /** @internal */ m_linearOffset: Vec2;\n /** @internal */ m_angularOffset: number;\n /** @internal */ m_linearImpulse: Vec2;\n /** @internal */ m_angularImpulse: number;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_maxTorque: number;\n /** @internal */ m_correctionFactor: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_linearError: Vec2;\n /** @internal */ m_angularError: number;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_linearMass: Mat22;\n /** @internal */ m_angularMass: number;\n\n constructor(def: MotorJointDef);\n constructor(def: MotorJointOpt, bodyA: Body, bodyB: Body);\n constructor(def: MotorJointDef | MotorJointOpt, bodyA?: Body, bodyB?: Body) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof MotorJoint)) {\n return new MotorJoint(def, bodyA, bodyB);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = MotorJoint.TYPE;\n\n this.m_linearOffset = Vec2.isValid(def.linearOffset) ? Vec2.clone(def.linearOffset) : bodyA.getLocalPoint(bodyB.getPosition());\n this.m_angularOffset = Number.isFinite(def.angularOffset) ? def.angularOffset : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_linearImpulse = Vec2.zero();\n this.m_angularImpulse = 0.0;\n\n this.m_maxForce = def.maxForce;\n this.m_maxTorque = def.maxTorque;\n this.m_correctionFactor = def.correctionFactor;\n\n // Point-to-point constraint\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n //\n // r1 = offset - c1\n // r2 = -c2\n\n // Angle constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n maxForce: this.m_maxForce,\n maxTorque: this.m_maxTorque,\n correctionFactor: this.m_correctionFactor,\n\n linearOffset: this.m_linearOffset,\n angularOffset: this.m_angularOffset,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): MotorJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new MotorJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.angularOffset)) {\n this.m_angularOffset = def.angularOffset;\n }\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.maxTorque)) {\n this.m_maxTorque = def.maxTorque;\n }\n if (Number.isFinite(def.correctionFactor)) {\n this.m_correctionFactor = def.correctionFactor;\n }\n if (Vec2.isValid(def.linearOffset)) {\n this.m_linearOffset.set(def.linearOffset); \n }\n }\n\n /**\n * Set the maximum friction force in N.\n */\n setMaxForce(force: number): void {\n if (_ASSERT) console.assert(Number.isFinite(force) && force >= 0.0);\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum friction force in N.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the maximum friction torque in N*m.\n */\n setMaxTorque(torque: number): void {\n if (_ASSERT) console.assert(Number.isFinite(torque) && torque >= 0.0);\n this.m_maxTorque = torque;\n }\n\n /**\n * Get the maximum friction torque in N*m.\n */\n getMaxTorque(): number {\n return this.m_maxTorque;\n }\n\n /**\n * Set the position correction factor in the range [0,1].\n */\n setCorrectionFactor(factor: number): void {\n if (_ASSERT) console.assert(Number.isFinite(factor) && 0.0 <= factor && factor <= 1.0);\n this.m_correctionFactor = factor;\n }\n\n /**\n * Get the position correction factor in the range [0,1].\n */\n getCorrectionFactor(): number {\n return this.m_correctionFactor;\n }\n\n /**\n * Set/get the target linear offset, in frame A, in meters.\n */\n setLinearOffset(linearOffset: Vec2Value): void {\n if (linearOffset.x != this.m_linearOffset.x || linearOffset.y != this.m_linearOffset.y) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_linearOffset.set(linearOffset);\n }\n }\n\n getLinearOffset(): Vec2 {\n return this.m_linearOffset;\n }\n\n /**\n * Set/get the target angular offset, in radians.\n */\n setAngularOffset(angularOffset: number): void {\n if (angularOffset != this.m_angularOffset) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_angularOffset = angularOffset;\n }\n }\n\n getAngularOffset(): number {\n return this.m_angularOffset;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getPosition();\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getPosition();\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_linearImpulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_angularImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective mass matrix.\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_linearOffset, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.neg(this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Upper 2 by 2 of K for point to point\n const K = new Mat22();\n K.ex.x = mA + mB + iA * this.m_rA.y * this.m_rA.y + iB * this.m_rB.y * this.m_rB.y;\n K.ex.y = -iA * this.m_rA.x * this.m_rA.y - iB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * this.m_rA.x * this.m_rA.x + iB * this.m_rB.x * this.m_rB.x;\n\n this.m_linearMass = K.getInverse();\n\n this.m_angularMass = iA + iB;\n if (this.m_angularMass > 0.0) {\n this.m_angularMass = 1.0 / this.m_angularMass;\n }\n\n this.m_linearError = Vec2.zero();\n this.m_linearError.addCombine(1, cB, 1, this.m_rB);\n this.m_linearError.subCombine(1, cA, 1, this.m_rA);\n\n this.m_angularError = aB - aA - this.m_angularOffset;\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_linearImpulse.mul(step.dtRatio);\n this.m_angularImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_linearImpulse.x, this.m_linearImpulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_angularImpulse);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_angularImpulse);\n\n } else {\n this.m_linearImpulse.setZero();\n this.m_angularImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const h = step.dt;\n const inv_h = step.inv_dt;\n\n // Solve angular friction\n {\n const Cdot = wB - wA + inv_h * this.m_correctionFactor * this.m_angularError;\n let impulse = -this.m_angularMass * Cdot;\n\n const oldImpulse = this.m_angularImpulse;\n const maxImpulse = h * this.m_maxTorque;\n this.m_angularImpulse = clamp(this.m_angularImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_angularImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve linear friction\n {\n const Cdot = Vec2.zero();\n Cdot.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n Cdot.addMul(inv_h * this.m_correctionFactor, this.m_linearError);\n\n let impulse = Vec2.neg(Mat22.mulVec2(this.m_linearMass, Cdot));\n const oldImpulse = Vec2.clone(this.m_linearImpulse);\n this.m_linearImpulse.add(impulse);\n\n const maxImpulse = h * this.m_maxForce;\n\n this.m_linearImpulse.clamp(maxImpulse);\n\n impulse = Vec2.sub(this.m_linearImpulse, oldImpulse);\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Transform } from \"../../common/Transform\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Mouse joint definition. This requires a world target point, tuning\n * parameters, and the time step.\n */\nexport interface MouseJointOpt extends JointOpt {\n /**\n * [maxForce = 0.0] The maximum constraint force that can be exerted to move\n * the candidate body. Usually you will express as some multiple of the\n * weight (multiplier * mass * gravity).\n */\n maxForce?: number;\n /**\n * [frequencyHz = 5.0] The response speed.\n */\n frequencyHz?: number;\n /**\n * [dampingRatio = 0.7] The damping ratio. 0 = no damping, 1 = critical\n * damping.\n */\n dampingRatio?: number;\n}\n\n/**\n * Mouse joint definition. This requires a world target point, tuning\n * parameters, and the time step.\n */\nexport interface MouseJointDef extends JointDef, MouseJointOpt {\n /**\n * The initial world target point. This is assumed to coincide with the body\n * anchor initially.\n */\n target: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 0.0,\n frequencyHz : 5.0,\n dampingRatio : 0.7\n};\n\ndeclare module \"./MouseJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MouseJoint(def: MouseJointDef): MouseJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MouseJoint(def: MouseJointOpt, bodyA: Body, bodyB: Body, target: Vec2Value): MouseJoint;\n}\n\n/**\n * A mouse joint is used to make a point on a body track a specified world\n * point. This a soft constraint with a maximum force. This allows the\n * constraint to stretch and without applying huge forces.\n *\n * You need to call setTarget(target) every time that mouse is \n * moved, to track the new location of the mouse.\n *\n * NOTE: this joint is not documented in the manual because it was developed to\n * be used in the testbed. If you want to learn how to use the mouse joint, look\n * at the testbed.\n */\n// @ts-expect-error\nexport class MouseJoint extends Joint {\n static TYPE = \"mouse-joint\" as const;\n\n /** @internal */ m_type: \"mouse-joint\";\n /** @internal */ m_targetA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_impulse: Vec2;\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n /** @internal */ m_beta: number;\n /** @internal */ m_gamma: number;\n // Solver temp\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: Mat22;\n /** @internal */ m_C: Vec2;\n\n constructor(def: MouseJointDef);\n constructor(def: MouseJointOpt, bodyA: Body, bodyB: Body, target?: Vec2Value);\n constructor(def: MouseJointDef, bodyA?: Body, bodyB?: Body, target?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof MouseJoint)) {\n return new MouseJoint(def, bodyA, bodyB, target);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = MouseJoint.TYPE;\n\n if (_ASSERT) console.assert(Number.isFinite(def.maxForce) && def.maxForce >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.frequencyHz) && def.frequencyHz >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.dampingRatio) && def.dampingRatio >= 0.0);\n\n if (Vec2.isValid(target)) {\n this.m_targetA = Vec2.clone(target);\n } else if (Vec2.isValid(def.target)) {\n this.m_targetA = Vec2.clone(def.target);\n } else {\n this.m_targetA = Vec2.zero();\n }\n\n this.m_localAnchorB = Transform.mulTVec2(bodyB.getTransform(), this.m_targetA);\n\n this.m_maxForce = def.maxForce;\n this.m_impulse = Vec2.zero();\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_beta = 0.0;\n this.m_gamma = 0.0;\n\n // Solver temp\n this.m_rB = Vec2.zero();\n this.m_localCenterB = Vec2.zero();\n this.m_invMassB = 0.0;\n this.m_invIB = 0.0;\n this.m_mass = new Mat22();\n this.m_C = Vec2.zero();\n\n // p = attached point, m = mouse point\n // C = p - m\n // Cdot = v\n // = v + cross(w, r)\n // J = [I r_skew]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n target: this.m_targetA,\n maxForce: this.m_maxForce,\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n _localAnchorB: this.m_localAnchorB,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): MouseJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.target = Vec2.clone(data.target);\n const joint = new MouseJoint(data);\n if (data._localAnchorB) {\n joint.m_localAnchorB = data._localAnchorB;\n }\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * Use this to update the target point.\n */\n setTarget(target: Vec2Value): void {\n if (Vec2.areEqual(target, this.m_targetA)) return;\n this.m_bodyB.setAwake(true);\n this.m_targetA.set(target);\n }\n\n getTarget(): Vec2 {\n return this.m_targetA;\n }\n\n /**\n * Set the maximum force in Newtons.\n */\n setMaxForce(force: number): void {\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum force in Newtons.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the frequency in Hertz.\n */\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n /**\n * Get the frequency in Hertz.\n */\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set the damping ratio (dimensionless).\n */\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n /**\n * Get the damping ratio (dimensionless).\n */\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return Vec2.clone(this.m_targetA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_impulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * 0.0;\n }\n\n /**\n * Shift the origin for any points stored in world coordinates.\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_targetA.sub(newOrigin);\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const position = this.m_bodyB.c_position;\n const velocity = this.m_bodyB.c_velocity;\n\n const cB = position.c;\n const aB = position.a;\n const vB = velocity.v;\n let wB = velocity.w;\n\n const qB = Rot.neo(aB);\n\n const mass = this.m_bodyB.getMass();\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * mass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = mass * (omega * omega);\n\n // magic formulas\n // gamma has units of inverse mass.\n // beta has units of inverse time.\n const h = step.dt;\n if (_ASSERT) console.assert(d + h * k > EPSILON);\n this.m_gamma = h * (d + h * k);\n if (this.m_gamma != 0.0) {\n this.m_gamma = 1.0 / this.m_gamma;\n }\n this.m_beta = h * k * this.m_gamma;\n\n // Compute the effective mass matrix.\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // K = [(1/m1 + 1/m2) * eye(2) - skew(r1) * invI1 * skew(r1) - skew(r2) *\n // invI2 * skew(r2)]\n // = [1/m1+1/m2 0 ] + invI1 * [r1.y*r1.y -r1.x*r1.y] + invI2 * [r1.y*r1.y\n // -r1.x*r1.y]\n // [ 0 1/m1+1/m2] [-r1.x*r1.y r1.x*r1.x] [-r1.x*r1.y r1.x*r1.x]\n const K = new Mat22();\n K.ex.x = this.m_invMassB + this.m_invIB * this.m_rB.y * this.m_rB.y\n + this.m_gamma;\n K.ex.y = -this.m_invIB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = this.m_invMassB + this.m_invIB * this.m_rB.x * this.m_rB.x\n + this.m_gamma;\n\n this.m_mass = K.getInverse();\n\n this.m_C.setVec2(cB);\n this.m_C.addCombine(1, this.m_rB, -1, this.m_targetA);\n this.m_C.mul(this.m_beta);\n\n // Cheat with some damping\n wB *= 0.98;\n\n if (step.warmStarting) {\n this.m_impulse.mul(step.dtRatio);\n vB.addMul(this.m_invMassB, this.m_impulse);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, this.m_impulse);\n\n } else {\n this.m_impulse.setZero();\n }\n\n velocity.v.setVec2(vB);\n velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const velocity = this.m_bodyB.c_velocity;\n const vB = Vec2.clone(velocity.v);\n let wB = velocity.w;\n\n // Cdot = v + cross(w, r)\n\n const Cdot = Vec2.crossNumVec2(wB, this.m_rB);\n Cdot.add(vB);\n\n Cdot.addCombine(1, this.m_C, this.m_gamma, this.m_impulse);\n Cdot.neg();\n\n let impulse = Mat22.mulVec2(this.m_mass, Cdot);\n\n const oldImpulse = Vec2.clone(this.m_impulse);\n this.m_impulse.add(impulse);\n const maxImpulse = step.dt * this.m_maxForce;\n this.m_impulse.clamp(maxImpulse);\n impulse = Vec2.sub(this.m_impulse, oldImpulse);\n\n vB.addMul(this.m_invMassB, impulse);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n\n velocity.v.setVec2(vB);\n velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n\n\n/**\n * Pulley joint definition. This requires two ground anchors, two dynamic body\n * anchor points, and a pulley ratio.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface PulleyJointOpt extends JointOpt {\n}\n\n/**\n * Pulley joint definition. This requires two ground anchors, two dynamic body\n * anchor points, and a pulley ratio.\n */\nexport interface PulleyJointDef extends JointDef, PulleyJointOpt {\n /**\n * The first ground anchor in world coordinates. This point never moves.\n */\n groundAnchorA: Vec2Value;\n /**\n * The second ground anchor in world coordinates. This point never moves.\n */\n groundAnchorB: Vec2Value;\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The reference length for the segment attached to bodyA.\n */\n lengthA: number;\n /**\n * The reference length for the segment attached to bodyB.\n */\n lengthB: number;\n /**\n * The pulley ratio, used to simulate a block-and-tackle.\n */\n ratio: number;\n\n /** @hidden */ anchorA?: Vec2Value;\n /** @hidden */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n collideConnected : true\n};\n\ndeclare module \"./PulleyJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PulleyJoint(def: PulleyJointDef): PulleyJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PulleyJoint(def: PulleyJointOpt, bodyA: Body, bodyB: Body, groundA: Vec2Value, groundB: Vec2Value, anchorA: Vec2Value, anchorB: Vec2Value, ratio: number): PulleyJoint;\n}\n\n/**\n * The pulley joint is connected to two bodies and two fixed ground points. The\n * pulley supports a ratio such that: length1 + ratio * length2 <= constant\n *\n * Yes, the force transmitted is scaled by the ratio.\n *\n * Warning: the pulley joint can get a bit squirrelly by itself. They often work\n * better when combined with prismatic joints. You should also cover the the\n * anchor points with static shapes to prevent one side from going to zero\n * length.\n */\n// @ts-expect-error\nexport class PulleyJoint extends Joint {\n static TYPE = \"pulley-joint\" as const;\n // static MIN_PULLEY_LENGTH: number = 2.0; // TODO where this is used?\n\n /** @internal */ m_type: \"pulley-joint\";\n /** @internal */ m_groundAnchorA: Vec2;\n /** @internal */ m_groundAnchorB: Vec2;\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_lengthA: number;\n /** @internal */ m_lengthB: number;\n /** @internal */ m_ratio: number;\n /** @internal */ m_constant: number;\n /** @internal */ m_impulse: number;\n\n // Solver temp\n /** @internal */ m_uA: Vec2;\n /** @internal */ m_uB: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: number;\n\n constructor(def: PulleyJointDef);\n constructor(def: PulleyJointOpt, bodyA: Body, bodyB: Body, groundA?: Vec2Value, groundB?: Vec2Value, anchorA?: Vec2Value, anchorB?: Vec2Value, ratio?: number);\n constructor(def: PulleyJointDef, bodyA?: Body, bodyB?: Body, groundA?: Vec2Value, groundB?: Vec2Value, anchorA?: Vec2Value, anchorB?: Vec2Value, ratio?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PulleyJoint)) {\n return new PulleyJoint(def, bodyA, bodyB, groundA, groundB, anchorA, anchorB, ratio);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = PulleyJoint.TYPE;\n this.m_groundAnchorA = Vec2.clone(groundA ? groundA : def.groundAnchorA || Vec2.neo(-1.0, 1.0));\n this.m_groundAnchorB = Vec2.clone(groundB ? groundB : def.groundAnchorB || Vec2.neo(1.0, 1.0));\n this.m_localAnchorA = Vec2.clone(anchorA ? bodyA.getLocalPoint(anchorA) : def.localAnchorA || Vec2.neo(-1.0, 0.0));\n this.m_localAnchorB = Vec2.clone(anchorB ? bodyB.getLocalPoint(anchorB) : def.localAnchorB || Vec2.neo(1.0, 0.0));\n this.m_lengthA = Number.isFinite(def.lengthA) ? def.lengthA : Vec2.distance(anchorA, groundA);\n this.m_lengthB = Number.isFinite(def.lengthB) ? def.lengthB : Vec2.distance(anchorB, groundB);\n this.m_ratio = Number.isFinite(ratio) ? ratio : def.ratio;\n\n if (_ASSERT) console.assert(ratio > EPSILON);\n\n this.m_constant = this.m_lengthA + this.m_ratio * this.m_lengthB;\n\n this.m_impulse = 0.0;\n\n // Pulley:\n // length1 = norm(p1 - s1)\n // length2 = norm(p2 - s2)\n // C0 = (length1 + ratio * length2)_initial\n // C = C0 - (length1 + ratio * length2)\n // u1 = (p1 - s1) / norm(p1 - s1)\n // u2 = (p2 - s2) / norm(p2 - s2)\n // Cdot = -dot(u1, v1 + cross(w1, r1)) - ratio * dot(u2, v2 + cross(w2, r2))\n // J = -[u1 cross(r1, u1) ratio * u2 ratio * cross(r2, u2)]\n // K = J * invM * JT\n // = invMass1 + invI1 * cross(r1, u1)^2 + ratio^2 * (invMass2 + invI2 *\n // cross(r2, u2)^2)\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n groundAnchorA: this.m_groundAnchorA,\n groundAnchorB: this.m_groundAnchorB,\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n lengthA: this.m_lengthA,\n lengthB: this.m_lengthB,\n ratio: this.m_ratio,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): PulleyJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new PulleyJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Vec2.isValid(def.groundAnchorA)) {\n this.m_groundAnchorA.set(def.groundAnchorA);\n }\n if (Vec2.isValid(def.groundAnchorB)) {\n this.m_groundAnchorB.set(def.groundAnchorB);\n }\n if (Vec2.isValid(def.localAnchorA)) {\n this.m_localAnchorA.set(def.localAnchorA);\n } else if (Vec2.isValid(def.anchorA)) {\n this.m_localAnchorA.set(this.m_bodyA.getLocalPoint(def.anchorA));\n }\n if (Vec2.isValid(def.localAnchorB)) {\n this.m_localAnchorB.set(def.localAnchorB);\n } else if (Vec2.isValid(def.anchorB)) {\n this.m_localAnchorB.set(this.m_bodyB.getLocalPoint(def.anchorB));\n }\n if (Number.isFinite(def.lengthA)) {\n this.m_lengthA = def.lengthA;\n }\n if (Number.isFinite(def.lengthB)) {\n this.m_lengthB = def.lengthB;\n }\n if (Number.isFinite(def.ratio)) {\n this.m_ratio = def.ratio;\n }\n }\n\n /**\n * Get the first ground anchor.\n */\n getGroundAnchorA(): Vec2 {\n return this.m_groundAnchorA;\n }\n\n /**\n * Get the second ground anchor.\n */\n getGroundAnchorB(): Vec2 {\n return this.m_groundAnchorB;\n }\n\n /**\n * Get the current length of the segment attached to bodyA.\n */\n getLengthA(): number {\n return this.m_lengthA;\n }\n\n /**\n * Get the current length of the segment attached to bodyB.\n */\n getLengthB(): number {\n return this.m_lengthB;\n }\n\n /**\n * Get the pulley ratio.\n */\n getRatio(): number {\n return this.m_ratio;\n }\n\n /**\n * Get the current length of the segment attached to bodyA.\n */\n getCurrentLengthA(): number {\n const p = this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n const s = this.m_groundAnchorA;\n return Vec2.distance(p, s);\n }\n\n /**\n * Get the current length of the segment attached to bodyB.\n */\n getCurrentLengthB(): number {\n const p = this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n const s = this.m_groundAnchorB;\n return Vec2.distance(p, s);\n }\n\n /**\n * Shift the origin for any points stored in world coordinates.\n *\n * @param newOrigin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_groundAnchorA.sub(newOrigin);\n this.m_groundAnchorB.sub(newOrigin);\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_uB).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // Get the pulley axes.\n this.m_uA = Vec2.sub(Vec2.add(cA, this.m_rA), this.m_groundAnchorA);\n this.m_uB = Vec2.sub(Vec2.add(cB, this.m_rB), this.m_groundAnchorB);\n\n const lengthA = this.m_uA.length();\n const lengthB = this.m_uB.length();\n\n if (lengthA > 10.0 * Settings.linearSlop) {\n this.m_uA.mul(1.0 / lengthA);\n } else {\n this.m_uA.setZero();\n }\n\n if (lengthB > 10.0 * Settings.linearSlop) {\n this.m_uB.mul(1.0 / lengthB);\n } else {\n this.m_uB.setZero();\n }\n\n // Compute effective mass.\n const ruA = Vec2.crossVec2Vec2(this.m_rA, this.m_uA);\n const ruB = Vec2.crossVec2Vec2(this.m_rB, this.m_uB);\n\n const mA = this.m_invMassA + this.m_invIA * ruA * ruA;\n const mB = this.m_invMassB + this.m_invIB * ruB * ruB;\n\n this.m_mass = mA + this.m_ratio * this.m_ratio * mB;\n\n if (this.m_mass > 0.0) {\n this.m_mass = 1.0 / this.m_mass;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support variable time steps.\n this.m_impulse *= step.dtRatio;\n\n // Warm starting.\n const PA = Vec2.mulNumVec2(-this.m_impulse, this.m_uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * this.m_impulse, this.m_uB);\n\n vA.addMul(this.m_invMassA, PA);\n wA += this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, PA);\n\n vB.addMul(this.m_invMassB, PB);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, PB);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const vpA = Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA));\n const vpB = Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB));\n\n const Cdot = -Vec2.dot(this.m_uA, vpA) - this.m_ratio * Vec2.dot(this.m_uB, vpB);\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n const PA = Vec2.mulNumVec2(-impulse, this.m_uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * impulse, this.m_uB);\n vA.addMul(this.m_invMassA, PA);\n wA += this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, PA);\n vB.addMul(this.m_invMassB, PB);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, PB);\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // Get the pulley axes.\n const uA = Vec2.sub(Vec2.add(cA, this.m_rA), this.m_groundAnchorA);\n const uB = Vec2.sub(Vec2.add(cB, this.m_rB), this.m_groundAnchorB);\n\n const lengthA = uA.length();\n const lengthB = uB.length();\n\n if (lengthA > 10.0 * Settings.linearSlop) {\n uA.mul(1.0 / lengthA);\n } else {\n uA.setZero();\n }\n\n if (lengthB > 10.0 * Settings.linearSlop) {\n uB.mul(1.0 / lengthB);\n } else {\n uB.setZero();\n }\n\n // Compute effective mass.\n const ruA = Vec2.crossVec2Vec2(rA, uA);\n const ruB = Vec2.crossVec2Vec2(rB, uB);\n\n const mA = this.m_invMassA + this.m_invIA * ruA * ruA;\n const mB = this.m_invMassB + this.m_invIB * ruB * ruB;\n\n let mass = mA + this.m_ratio * this.m_ratio * mB;\n\n if (mass > 0.0) {\n mass = 1.0 / mass;\n }\n\n const C = this.m_constant - lengthA - this.m_ratio * lengthB;\n const linearError = math_abs(C);\n\n const impulse = -mass * C;\n\n const PA = Vec2.mulNumVec2(-impulse, uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * impulse, uB);\n\n cA.addMul(this.m_invMassA, PA);\n aA += this.m_invIA * Vec2.crossVec2Vec2(rA, PA);\n cB.addMul(this.m_invMassB, PB);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, PB);\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return linearError < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_min = Math.min;\n\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3,\n}\n\n/**\n * Rope joint definition. This requires two body anchor points and a maximum\n * lengths. Note: by default the connected objects will not collide. see\n * collideConnected in JointDef.\n */\nexport interface RopeJointOpt extends JointOpt {\n /**\n * The maximum length of the rope.\n * Warning: this must be larger than linearSlop or the joint will have no effect.\n */\n maxLength?: number;\n}\n\n/**\n * Rope joint definition. This requires two body anchor points and a maximum\n * lengths. Note: by default the connected objects will not collide. see\n * collideConnected in JointDef.\n */\nexport interface RopeJointDef extends JointDef, RopeJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxLength : 0.0,\n};\n\ndeclare module \"./RopeJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RopeJoint(def: RopeJointDef): RopeJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RopeJoint(def: RopeJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): RopeJoint;\n}\n\n/**\n * A rope joint enforces a maximum distance between two points on two bodies. It\n * has no other effect.\n *\n * Warning: if you attempt to change the maximum length during the simulation\n * you will get some non-physical behavior.\n *\n * A model that would allow you to dynamically modify the length would have some\n * sponginess, so I chose not to implement it that way. See {@link DistanceJoint} if you\n * want to dynamically control length.\n */\n// @ts-expect-error\nexport class RopeJoint extends Joint {\n static TYPE = \"rope-joint\" as const;\n\n /** @internal */ m_type: \"rope-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n\n /** @internal */ m_maxLength: number;\n\n /** @internal */ m_mass: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_length: number;\n /** @internal */ m_state: number; // TODO enum\n\n // Solver temp\n /** @internal */ m_u: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n\n constructor(def: RopeJointDef);\n constructor(def: RopeJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: RopeJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof RopeJoint)) {\n return new RopeJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = RopeJoint.TYPE;\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.neo(-1.0, 0.0));\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.neo(1.0, 0.0));\n\n this.m_maxLength = def.maxLength;\n\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n this.m_length = 0.0;\n this.m_state = LimitState.inactiveLimit;\n\n // Limit:\n // C = norm(pB - pA) - L\n // u = (pB - pA) / norm(pB - pA)\n // Cdot = dot(u, vB + cross(wB, rB) - vA - cross(wA, rA))\n // J = [-u -cross(rA, u) u cross(rB, u)]\n // K = J * invM * JT\n // = invMassA + invIA * cross(rA, u)^2 + invMassB + invIB * cross(rB, u)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n maxLength: this.m_maxLength,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): RopeJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new RopeJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.maxLength)) {\n this.m_maxLength = def.maxLength;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the maximum length of the rope.\n */\n setMaxLength(length: number): void {\n this.m_maxLength = length;\n }\n\n /**\n * Get the maximum length of the rope.\n */\n getMaxLength(): number {\n return this.m_maxLength;\n }\n\n getLimitState(): number {\n // TODO LimitState\n return this.m_state;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_u).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n this.m_rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n this.m_u = Vec2.zero();\n this.m_u.addCombine(1, cB, 1, this.m_rB);\n this.m_u.subCombine(1, cA, 1, this.m_rA);\n\n this.m_length = this.m_u.length();\n\n const C = this.m_length - this.m_maxLength;\n if (C > 0.0) {\n this.m_state = LimitState.atUpperLimit;\n } else {\n this.m_state = LimitState.inactiveLimit;\n }\n\n if (this.m_length > Settings.linearSlop) {\n this.m_u.mul(1.0 / this.m_length);\n } else {\n this.m_u.setZero();\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n return;\n }\n\n // Compute effective mass.\n const crA = Vec2.crossVec2Vec2(this.m_rA, this.m_u);\n const crB = Vec2.crossVec2Vec2(this.m_rB, this.m_u);\n const invMass = this.m_invMassA + this.m_invIA * crA * crA + this.m_invMassB + this.m_invIB * crB * crB;\n\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n\n if (step.warmStarting) {\n // Scale the impulse to support a variable time step.\n this.m_impulse *= step.dtRatio;\n\n const P = Vec2.mulNumVec2(this.m_impulse, this.m_u);\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Cdot = dot(u, v + cross(w, r))\n const vpA = Vec2.addCrossNumVec2(vA, wA, this.m_rA);\n const vpB = Vec2.addCrossNumVec2(vB, wB, this.m_rB);\n const C = this.m_length - this.m_maxLength;\n let Cdot = Vec2.dot(this.m_u, Vec2.sub(vpB, vpA));\n\n // Predictive constraint.\n if (C < 0.0) {\n Cdot += step.inv_dt * C;\n }\n\n let impulse = -this.m_mass * Cdot;\n const oldImpulse = this.m_impulse;\n this.m_impulse = math_min(0.0, this.m_impulse + impulse);\n impulse = this.m_impulse - oldImpulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_u);\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n const u = Vec2.zero();\n u.addCombine(1, cB, 1, rB);\n u.subCombine(1, cA, 1, rA);\n\n const length = u.normalize();\n let C = length - this.m_maxLength;\n\n C = clamp(C, 0.0, Settings.maxLinearCorrection);\n\n const impulse = -this.m_mass * C;\n const P = Vec2.mulNumVec2(impulse, u);\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * Vec2.crossVec2Vec2(rA, P);\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, P);\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return length - this.m_maxLength < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Weld joint definition. You need to specify local anchor points where they are\n * attached and the relative body angle. The position of the anchor points is\n * important for computing the reaction torque.\n */\nexport interface WeldJointOpt extends JointOpt {\n /**\n * The mass-spring-damper frequency in Hertz. Rotation only. Disable softness\n * with a value of 0.\n */\n frequencyHz?: number;\n /**\n * The damping ratio. 0 = no damping, 1 = critical damping.\n */\n dampingRatio?: number;\n /**\n * The bodyB angle minus bodyA angle in the reference state (radians).\n */\n referenceAngle?: number;\n}\n\n/**\n * Weld joint definition. You need to specify local anchor points where they are\n * attached and the relative body angle. The position of the anchor points is\n * important for computing the reaction torque.\n */\nexport interface WeldJointDef extends JointDef, WeldJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n frequencyHz : 0.0,\n dampingRatio : 0.0,\n};\n\ndeclare module \"./WeldJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WeldJoint(def: WeldJointDef): WeldJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WeldJoint(def: WeldJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): WeldJoint;\n}\n\n/**\n * A weld joint essentially glues two bodies together. A weld joint may distort\n * somewhat because the island constraint solver is approximate.\n */\n// @ts-expect-error\nexport class WeldJoint extends Joint {\n static TYPE = \"weld-joint\" as const;\n\n /** @internal */ m_type: \"weld-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngle: number;\n\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n\n /** @internal */ m_impulse: Vec3;\n\n /** @internal */ m_bias: number;\n /** @internal */ m_gamma: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: Mat33;\n\n constructor(def: WeldJointDef);\n constructor(def: WeldJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: WeldJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof WeldJoint)) {\n return new WeldJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = WeldJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n this.m_referenceAngle = Number.isFinite(def.referenceAngle) ? def.referenceAngle : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_impulse = new Vec3();\n\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n\n // Solver temp\n // todo: do we need to initialize?\n // this.m_rA;\n // this.m_rB;\n // this.m_localCenterA;\n // this.m_localCenterB;\n // this.m_invMassA;\n // this.m_invMassB;\n // this.m_invIA;\n // this.m_invIB;\n this.m_mass = new Mat33();\n\n // Point-to-point constraint\n // C = p2 - p1\n // Cdot = v2 - v1\n // / = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Angle constraint\n // C = angle2 - angle1 - referenceAngle\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): WeldJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new WeldJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Set frequency in Hz.\n */\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n /**\n * Get frequency in Hz.\n */\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set damping ratio.\n */\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n /**\n * Get damping ratio.\n */\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.neo(this.m_impulse.x, this.m_impulse.y).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.z;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat33();\n K.ex.x = mA + mB + this.m_rA.y * this.m_rA.y * iA + this.m_rB.y * this.m_rB.y\n * iB;\n K.ey.x = -this.m_rA.y * this.m_rA.x * iA - this.m_rB.y * this.m_rB.x * iB;\n K.ez.x = -this.m_rA.y * iA - this.m_rB.y * iB;\n K.ex.y = K.ey.x;\n K.ey.y = mA + mB + this.m_rA.x * this.m_rA.x * iA + this.m_rB.x * this.m_rB.x\n * iB;\n K.ez.y = this.m_rA.x * iA + this.m_rB.x * iB;\n K.ex.z = K.ez.x;\n K.ey.z = K.ez.y;\n K.ez.z = iA + iB;\n\n if (this.m_frequencyHz > 0.0) {\n K.getInverse22(this.m_mass);\n\n let invM = iA + iB;\n const m = invM > 0.0 ? 1.0 / invM : 0.0;\n\n const C = aB - aA - this.m_referenceAngle;\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * m * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = m * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (d + h * k);\n this.m_gamma = this.m_gamma != 0.0 ? 1.0 / this.m_gamma : 0.0;\n this.m_bias = C * h * k * this.m_gamma;\n\n invM += this.m_gamma;\n this.m_mass.ez.z = invM != 0.0 ? 1.0 / invM : 0.0;\n } else if (K.ez.z == 0.0) {\n K.getInverse22(this.m_mass);\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n } else {\n K.getSymInverse33(this.m_mass);\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_impulse.mul(step.dtRatio);\n\n const P = Vec2.neo(this.m_impulse.x, this.m_impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_impulse.z);\n\n } else {\n this.m_impulse.setZero();\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n if (this.m_frequencyHz > 0.0) {\n const Cdot2 = wB - wA;\n\n const impulse2 = -this.m_mass.ez.z * (Cdot2 + this.m_bias + this.m_gamma * this.m_impulse.z);\n this.m_impulse.z += impulse2;\n\n wA -= iA * impulse2;\n wB += iB * impulse2;\n\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n\n const impulse1 = Vec2.neg(Mat33.mulVec2(this.m_mass, Cdot1));\n this.m_impulse.x += impulse1.x;\n this.m_impulse.y += impulse1.y;\n\n const P = Vec2.clone(impulse1);\n\n vA.subMul(mA, P);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(mB, P);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, P);\n } else {\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const Cdot2 = wB - wA;\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const impulse = Vec3.neg(Mat33.mulVec3(this.m_mass, Cdot));\n this.m_impulse.add(impulse);\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + impulse.z);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n let positionError: number;\n let angularError: number;\n\n const K = new Mat33();\n K.ex.x = mA + mB + rA.y * rA.y * iA + rB.y * rB.y * iB;\n K.ey.x = -rA.y * rA.x * iA - rB.y * rB.x * iB;\n K.ez.x = -rA.y * iA - rB.y * iB;\n K.ex.y = K.ey.x;\n K.ey.y = mA + mB + rA.x * rA.x * iA + rB.x * rB.x * iB;\n K.ez.y = rA.x * iA + rB.x * iB;\n K.ex.z = K.ez.x;\n K.ey.z = K.ez.y;\n K.ez.z = iA + iB;\n\n if (this.m_frequencyHz > 0.0) {\n const C1 = Vec2.zero();\n C1.addCombine(1, cB, 1, rB);\n C1.subCombine(1, cA, 1, rA);\n\n positionError = C1.length();\n angularError = 0.0;\n\n const P = Vec2.neg(K.solve22(C1));\n\n cA.subMul(mA, P);\n aA -= iA * Vec2.crossVec2Vec2(rA, P);\n\n cB.addMul(mB, P);\n aB += iB * Vec2.crossVec2Vec2(rB, P);\n } else {\n const C1 = Vec2.zero();\n C1.addCombine(1, cB, 1, rB);\n C1.subCombine(1, cA, 1, rA);\n\n const C2 = aB - aA - this.m_referenceAngle;\n\n positionError = C1.length();\n angularError = math_abs(C2);\n\n const C = new Vec3(C1.x, C1.y, C2);\n\n let impulse = new Vec3();\n if (K.ez.z > 0.0) {\n impulse = Vec3.neg(K.solve33(C));\n } else {\n const impulse2 = Vec2.neg(K.solve22(C1));\n impulse.set(impulse2.x, impulse2.y, 0.0);\n }\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n cA.subMul(mA, P);\n aA -= iA * (Vec2.crossVec2Vec2(rA, P) + impulse.z);\n\n cB.addMul(mB, P);\n aB += iB * (Vec2.crossVec2Vec2(rB, P) + impulse.z);\n }\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return positionError <= Settings.linearSlop && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Wheel joint definition. This requires defining a line of motion using an axis\n * and an anchor point. The definition uses local anchor points and a local axis\n * so that the initial configuration can violate the constraint slightly. The\n * joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface WheelJointOpt extends JointOpt {\n /**\n * Enable/disable the joint motor.\n */\n enableMotor?: boolean;\n /**\n * The maximum motor torque, usually in N-m.\n */\n maxMotorTorque?: number;\n /**\n * The desired motor speed in radians per second.\n */\n motorSpeed?: number;\n /**\n * Suspension frequency, zero indicates no suspension.\n */\n frequencyHz?: number;\n /**\n * Suspension damping ratio, one indicates critical damping.\n */\n dampingRatio?: number;\n}\n\n/**\n * Wheel joint definition. This requires defining a line of motion using an axis\n * and an anchor point. The definition uses local anchor points and a local axis\n * so that the initial configuration can violate the constraint slightly. The\n * joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface WheelJointDef extends JointDef, WheelJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The local translation axis in bodyA.\n */\n localAxisA: Vec2Value;\n\n /** @internal renamed to localAxisA */\n localAxis?: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n enableMotor : false,\n maxMotorTorque : 0.0,\n motorSpeed : 0.0,\n frequencyHz : 2.0,\n dampingRatio : 0.7,\n};\n\ndeclare module \"./WheelJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WheelJoint(def: WheelJointDef): WheelJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WheelJoint(def: WheelJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value, axis: Vec2Value): WheelJoint;\n}\n\n/**\n * A wheel joint. This joint provides two degrees of freedom: translation along\n * an axis fixed in bodyA and rotation in the plane. In other words, it is a\n * point to line constraint with a rotational motor and a linear spring/damper.\n * This joint is designed for vehicle suspensions.\n */\n// @ts-expect-error\nexport class WheelJoint extends Joint {\n static TYPE = \"wheel-joint\" as const;\n\n /** @internal */ m_type: \"wheel-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_localXAxisA: Vec2;\n /** @internal */ m_localYAxisA: Vec2;\n\n /** @internal */ m_mass: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_motorMass: number;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_springMass: number;\n /** @internal */ m_springImpulse: number;\n\n /** @internal */ m_maxMotorTorque: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableMotor: boolean;\n\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n\n /** @internal */ m_bias: number;\n /** @internal */ m_gamma: number;\n\n // Solver temp\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n\n /** @internal */ m_ax: Vec2;\n /** @internal */ m_ay: Vec2;\n /** @internal */ m_sAx: number;\n /** @internal */ m_sBx: number;\n /** @internal */ m_sAy: number;\n /** @internal */ m_sBy: number;\n\n constructor(def: WheelJointDef);\n constructor(def: WheelJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value, axis?: Vec2Value);\n constructor(def: WheelJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value, axis?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof WheelJoint)) {\n return new WheelJoint(def, bodyA, bodyB, anchor, axis);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_ax = Vec2.zero();\n this.m_ay = Vec2.zero();\n\n this.m_type = WheelJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n\n if (Vec2.isValid(axis)) {\n this.m_localXAxisA = bodyA.getLocalVector(axis);\n } else if (Vec2.isValid(def.localAxisA)) {\n this.m_localXAxisA = Vec2.clone(def.localAxisA);\n } else if (Vec2.isValid(def.localAxis)) {\n // localAxis is renamed to localAxisA, this is for backward compatibility\n this.m_localXAxisA = Vec2.clone(def.localAxis);\n } else {\n this.m_localXAxisA = Vec2.neo(1.0, 0.0);\n }\n\n this.m_localYAxisA = Vec2.crossNumVec2(1.0, this.m_localXAxisA);\n\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n this.m_springMass = 0.0;\n this.m_springImpulse = 0.0;\n\n this.m_maxMotorTorque = def.maxMotorTorque;\n this.m_motorSpeed = def.motorSpeed;\n this.m_enableMotor = def.enableMotor;\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n\n // Linear constraint (point-to-line)\n // d = pB - pA = xB + rB - xA - rA\n // C = dot(ay, d)\n // Cdot = dot(d, cross(wA, ay)) + dot(ay, vB + cross(wB, rB) - vA - cross(wA,\n // rA))\n // = -dot(ay, vA) - dot(cross(d + rA, ay), wA) + dot(ay, vB) + dot(cross(rB,\n // ay), vB)\n // J = [-ay, -cross(d + rA, ay), ay, cross(rB, ay)]\n\n // Spring linear constraint\n // C = dot(ax, d)\n // Cdot = = -dot(ax, vA) - dot(cross(d + rA, ax), wA) + dot(ax, vB) +\n // dot(cross(rB, ax), vB)\n // J = [-ax -cross(d+rA, ax) ax cross(rB, ax)]\n\n // Motor rotational constraint\n // Cdot = wB - wA\n // J = [0 0 -1 0 0 1]\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n enableMotor: this.m_enableMotor,\n maxMotorTorque: this.m_maxMotorTorque,\n motorSpeed: this.m_motorSpeed,\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n localAxisA: this.m_localXAxisA,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): WheelJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new WheelJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (def.localAxisA) {\n this.m_localXAxisA.setVec2(def.localAxisA);\n this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1.0, def.localAxisA));\n }\n if (def.enableMotor !== undefined) {\n this.m_enableMotor = def.enableMotor;\n }\n if (Number.isFinite(def.maxMotorTorque)) {\n this.m_maxMotorTorque = def.maxMotorTorque;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * The local joint axis relative to bodyA.\n */\n getLocalAxisA(): Vec2 {\n return this.m_localXAxisA;\n }\n\n /**\n * Get the current joint translation, usually in meters.\n */\n getJointTranslation(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n\n const pA = bA.getWorldPoint(this.m_localAnchorA);\n const pB = bB.getWorldPoint(this.m_localAnchorB);\n const d = Vec2.sub(pB, pA);\n const axis = bA.getWorldVector(this.m_localXAxisA);\n\n const translation = Vec2.dot(d, axis);\n return translation;\n }\n\n /**\n * Get the current joint translation speed, usually in meters per second.\n */\n getJointSpeed(): number {\n const wA = this.m_bodyA.m_angularVelocity;\n const wB = this.m_bodyB.m_angularVelocity;\n return wB - wA;\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Set the motor speed, usually in radians per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Get the motor speed, usually in radians per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Set/Get the maximum motor force, usually in N-m.\n */\n setMaxMotorTorque(torque: number): void {\n if (torque == this.m_maxMotorTorque) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorTorque = torque;\n }\n\n getMaxMotorTorque(): number {\n return this.m_maxMotorTorque;\n }\n\n /**\n * Get the current motor torque given the inverse time step, usually in N-m.\n */\n getMotorTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Set/Get the spring frequency in hertz. Setting the frequency to zero disables\n * the spring.\n */\n setSpringFrequencyHz(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n getSpringFrequencyHz(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set/Get the spring damping ratio\n */\n setSpringDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n getSpringDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.combine(this.m_impulse, this.m_ay, this.m_springImpulse, this.m_ax).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective masses.\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n // Point to line constraint\n {\n this.m_ay = Rot.mulVec2(qA, this.m_localYAxisA);\n this.m_sAy = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_ay);\n this.m_sBy = Vec2.crossVec2Vec2(rB, this.m_ay);\n\n this.m_mass = mA + mB + iA * this.m_sAy * this.m_sAy + iB * this.m_sBy\n * this.m_sBy;\n\n if (this.m_mass > 0.0) {\n this.m_mass = 1.0 / this.m_mass;\n }\n }\n\n // Spring constraint\n this.m_springMass = 0.0;\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n if (this.m_frequencyHz > 0.0) {\n this.m_ax = Rot.mulVec2(qA, this.m_localXAxisA);\n this.m_sAx = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_ax);\n this.m_sBx = Vec2.crossVec2Vec2(rB, this.m_ax);\n\n const invMass = mA + mB + iA * this.m_sAx * this.m_sAx + iB * this.m_sBx\n * this.m_sBx;\n\n if (invMass > 0.0) {\n this.m_springMass = 1.0 / invMass;\n\n const C = Vec2.dot(d, this.m_ax);\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const damp = 2.0 * this.m_springMass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = this.m_springMass * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (damp + h * k);\n if (this.m_gamma > 0.0) {\n this.m_gamma = 1.0 / this.m_gamma;\n }\n\n this.m_bias = C * h * k * this.m_gamma;\n\n this.m_springMass = invMass + this.m_gamma;\n if (this.m_springMass > 0.0) {\n this.m_springMass = 1.0 / this.m_springMass;\n }\n }\n } else {\n this.m_springImpulse = 0.0;\n }\n\n // Rotational motor\n if (this.m_enableMotor) {\n this.m_motorMass = iA + iB;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n } else {\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n }\n\n if (step.warmStarting) {\n // Account for variable time step.\n this.m_impulse *= step.dtRatio;\n this.m_springImpulse *= step.dtRatio;\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.combine(this.m_impulse, this.m_ay, this.m_springImpulse, this.m_ax);\n const LA = this.m_impulse * this.m_sAy + this.m_springImpulse * this.m_sAx + this.m_motorImpulse;\n const LB = this.m_impulse * this.m_sBy + this.m_springImpulse * this.m_sBx + this.m_motorImpulse;\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * LA;\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * LB;\n\n } else {\n this.m_impulse = 0.0;\n this.m_springImpulse = 0.0;\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Solve spring constraint\n {\n const Cdot = Vec2.dot(this.m_ax, vB) - Vec2.dot(this.m_ax, vA) + this.m_sBx * wB - this.m_sAx * wA;\n const impulse = -this.m_springMass * (Cdot + this.m_bias + this.m_gamma * this.m_springImpulse);\n this.m_springImpulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_ax);\n const LA = impulse * this.m_sAx;\n const LB = impulse * this.m_sBx;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n // Solve rotational motor constraint\n {\n const Cdot = wB - wA - this.m_motorSpeed;\n let impulse = -this.m_motorMass * Cdot;\n\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorTorque;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve point to line constraint\n {\n const Cdot = Vec2.dot(this.m_ay, vB) - Vec2.dot(this.m_ay, vA) + this.m_sBy * wB - this.m_sAy * wA;\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_ay);\n const LA = impulse * this.m_sAy;\n const LB = impulse * this.m_sBy;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n const ay = Rot.mulVec2(qA, this.m_localYAxisA);\n\n const sAy = Vec2.crossVec2Vec2(Vec2.add(d, rA), ay);\n const sBy = Vec2.crossVec2Vec2(rB, ay);\n\n const C = Vec2.dot(d, ay);\n\n const k = this.m_invMassA + this.m_invMassB + this.m_invIA * this.m_sAy * this.m_sAy + this.m_invIB * this.m_sBy * this.m_sBy;\n\n const impulse = k != 0.0 ? -C / k : 0.0;\n\n const P = Vec2.mulNumVec2(impulse, ay);\n const LA = impulse * sAy;\n const LB = impulse * sBy;\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * LA;\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * LB;\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return math_abs(C) <= Settings.linearSlop;\n }\n\n}\n","import { World } from \"../dynamics/World\";\nimport { Body } from \"../dynamics/Body\";\nimport { Joint } from \"../dynamics/Joint\";\nimport { Fixture } from \"../dynamics/Fixture\";\nimport { Shape } from \"../collision/Shape\";\nimport { Vec2 } from \"../common/Vec2\";\nimport { Vec3 } from \"../common/Vec3\";\nimport { ChainShape } from \"../collision/shape/ChainShape\";\n// import { BoxShape } from \"../collision/shape/BoxShape\";\nimport { EdgeShape } from \"../collision/shape/EdgeShape\";\nimport { PolygonShape } from \"../collision/shape/PolygonShape\";\nimport { CircleShape } from \"../collision/shape/CircleShape\";\nimport { DistanceJoint } from \"../dynamics/joint/DistanceJoint\";\nimport { FrictionJoint } from \"../dynamics/joint/FrictionJoint\";\nimport { GearJoint } from \"../dynamics/joint/GearJoint\";\nimport { MotorJoint } from \"../dynamics/joint/MotorJoint\";\nimport { MouseJoint } from \"../dynamics/joint/MouseJoint\";\nimport { PrismaticJoint } from \"../dynamics/joint/PrismaticJoint\";\nimport { PulleyJoint } from \"../dynamics/joint/PulleyJoint\";\nimport { RevoluteJoint } from \"../dynamics/joint/RevoluteJoint\";\nimport { RopeJoint } from \"../dynamics/joint/RopeJoint\";\nimport { WeldJoint } from \"../dynamics/joint/WeldJoint\";\nimport { WheelJoint } from \"../dynamics/joint/WheelJoint\";\n\nlet SID = 0;\n\n// Classes to be serialized as reference objects\nconst SERIALIZE_REF_TYPES = {\n \"World\": World,\n \"Body\": Body,\n \"Joint\": Joint,\n \"Fixture\": Fixture,\n \"Shape\": Shape,\n};\n\n// For deserializing reference objects by reference type\nconst DESERIALIZE_BY_REF_TYPE = {\n \"Vec2\": Vec2,\n \"Vec3\": Vec3,\n \"World\": World,\n \"Body\": Body,\n \"Joint\": Joint,\n \"Fixture\": Fixture,\n \"Shape\": Shape,\n};\n\n// For deserializing data objects by type field\nconst DESERIALIZE_BY_TYPE_FIELD = {\n [Body.STATIC]: Body,\n [Body.DYNAMIC]: Body,\n [Body.KINEMATIC]: Body,\n [ChainShape.TYPE]: ChainShape,\n // [BoxShape.TYPE]: BoxShape,\n [PolygonShape.TYPE]: PolygonShape,\n [EdgeShape.TYPE]: EdgeShape,\n [CircleShape.TYPE]: CircleShape,\n [DistanceJoint.TYPE]: DistanceJoint,\n [FrictionJoint.TYPE]: FrictionJoint,\n [GearJoint.TYPE]: GearJoint,\n [MotorJoint.TYPE]: MotorJoint,\n [MouseJoint.TYPE]: MouseJoint,\n [PrismaticJoint.TYPE]: PrismaticJoint,\n [PulleyJoint.TYPE]: PulleyJoint,\n [RevoluteJoint.TYPE]: RevoluteJoint,\n [RopeJoint.TYPE]: RopeJoint,\n [WeldJoint.TYPE]: WeldJoint,\n [WheelJoint.TYPE]: WheelJoint,\n};\n\n// dummy types\ntype DataType = any;\ntype ObjectType = any;\ntype ClassName = any;\n\ntype SerializedType = object[];\n\ntype RefType = {\n refIndex: number,\n refType: string,\n};\n\ntype SerializerOptions = {\n rootClass: ClassName,\n preSerialize?: (obj: ObjectType) => DataType,\n postSerialize?: (data: DataType, obj: any) => DataType,\n preDeserialize?: (data: DataType) => DataType,\n postDeserialize?: (obj: ObjectType, data: DataType) => ObjectType,\n};\n\nconst DEFAULT_OPTIONS: SerializerOptions = {\n rootClass: World,\n preSerialize: function(obj) { return obj; },\n postSerialize: function(data, obj) { return data; },\n preDeserialize: function(data: DataType) { return data; },\n postDeserialize: function(obj, data) { return obj; },\n};\n\ntype DeserializeChildCallback = (classHint: any, obj: any, context: any) => any;\ntype ClassDeserializerMethod = (data: any, context: any, deserialize: DeserializeChildCallback) => any;\n\nexport class Serializer {\n private options: SerializerOptions;\n constructor(options: SerializerOptions) {\n this.options = {\n ...DEFAULT_OPTIONS,\n ...options,\n };\n }\n\n toJson = (root: T): SerializedType => {\n const preSerialize = this.options.preSerialize;\n const postSerialize = this.options.postSerialize;\n const json = [];\n\n // Breadth-first ref serialization queue\n const refQueue = [root];\n\n const refMemoById: Record = {};\n\n function addToRefQueue(value: any, typeName: string) {\n value.__sid = value.__sid || ++SID;\n if (!refMemoById[value.__sid]) {\n refQueue.push(value);\n const index = json.length + refQueue.length;\n const ref = {\n refIndex: index,\n refType: typeName\n };\n refMemoById[value.__sid] = ref;\n }\n return refMemoById[value.__sid];\n }\n\n function serializeWithHooks(obj: ObjectType) {\n obj = preSerialize(obj);\n let data = obj._serialize();\n data = postSerialize(data, obj);\n return data;\n }\n\n // traverse the object graph\n // ref objects are pushed into the queue\n // other objects are serialize in-place \n function traverse(value: any, noRefType = false) {\n if (typeof value !== \"object\" || value === null) {\n return value;\n }\n // object with _serialize function\n if (typeof value._serialize === \"function\") {\n if (!noRefType) {\n for (const typeName in SERIALIZE_REF_TYPES) {\n if (value instanceof SERIALIZE_REF_TYPES[typeName]) {\n return addToRefQueue(value, typeName);\n }\n }\n }\n // object with _serialize function\n value = serializeWithHooks(value);\n }\n // recursive for arrays any objects\n if (Array.isArray(value)) {\n const newValue = [];\n for (let key = 0; key < value.length; key++) {\n newValue[key] = traverse(value[key]);\n }\n value = newValue;\n\n } else {\n const newValue = {};\n for (const key in value) {\n if (value.hasOwnProperty(key)) {\n newValue[key] = traverse(value[key]);\n }\n }\n value = newValue;\n }\n return value;\n }\n\n while (refQueue.length) {\n const obj = refQueue.shift();\n const str = traverse(obj, true);\n json.push(str);\n }\n\n return json;\n };\n\n fromJson = (json: SerializedType): T => {\n const preDeserialize = this.options.preDeserialize;\n const postDeserialize = this.options.postDeserialize;\n const rootClass = this.options.rootClass;\n\n const deserializedRefMemoByIndex: Record = {};\n\n function deserializeWithHooks(classHint: ClassName, data: DataType, context: any): ObjectType {\n if (!classHint || !classHint._deserialize) {\n classHint = DESERIALIZE_BY_TYPE_FIELD[data.type];\n }\n const deserializer = classHint && classHint._deserialize;\n if (!deserializer) {\n return;\n }\n data = preDeserialize(data);\n const classDeserializeFn = classHint._deserialize as ClassDeserializerMethod;\n let obj = classDeserializeFn(data, context, deserializeChild);\n obj = postDeserialize(obj, data);\n return obj;\n }\n\n /**\n * Recursive callback function to deserialize a child data object or reference object.\n * \n * @param classHint suggested class to deserialize obj to\n * @param dataOrRef data or reference object\n * @param context for example world when deserializing bodies and joints\n */\n function deserializeChild(classHint: ClassName, dataOrRef: DataType | RefType, context: any) {\n const isRefObject = dataOrRef.refIndex && dataOrRef.refType;\n if (!isRefObject) {\n return deserializeWithHooks(classHint, dataOrRef, context); \n }\n const ref = dataOrRef as RefType;\n if (DESERIALIZE_BY_REF_TYPE[ref.refType]) {\n classHint = DESERIALIZE_BY_REF_TYPE[ref.refType];\n }\n const refIndex = ref.refIndex;\n if (!deserializedRefMemoByIndex[refIndex]) {\n const data = json[refIndex];\n const obj = deserializeWithHooks(classHint, data, context);\n deserializedRefMemoByIndex[refIndex] = obj;\n }\n return deserializedRefMemoByIndex[refIndex];\n }\n\n const root = deserializeWithHooks(rootClass, json[0], null);\n\n return root;\n };\n\n static toJson: (root: World) => SerializedType;\n static fromJson: (json: SerializedType) => World;\n}\n\nconst worldSerializer = new Serializer({\n rootClass: World,\n});\n\nSerializer.fromJson = worldSerializer.fromJson;\nSerializer.toJson = worldSerializer.toJson;\n","import type { AABBValue } from \"../collision/AABB\";\nimport type { World } from \"../dynamics/World\";\nimport type { Joint } from \"../dynamics/Joint\";\nimport type { Fixture } from \"../dynamics/Fixture\";\nimport type { Body } from \"../dynamics/Body\";\n\nexport interface Style {\n stroke?: string;\n fill?: string;\n lineWidth?: number;\n}\n\ntype KEY = \"0\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" |\n \"8\" | \"9\" | \"A\" | \"B\" | \"C\" | \"D\" | \"E\" | \"F\" | \"G\" |\n \"H\" | \"I\" | \"J\" | \"K\" | \"L\" | \"M\" | \"N\" | \"O\" | \"P\" |\n \"Q\" | \"R\" | \"S\" | \"T\" | \"U\" | \"V\" | \"W\" | \"X\" | \"Y\" |\n \"Z\" | \"right\" | \"left\" | \"up\" | \"down\" | \"fire\";\n\nexport type ActiveKeys = { [key in KEY]?: boolean };\n\ntype TestbedMountOptions = { [key: string]: any };\n\nexport abstract class Testbed {\n /**\n * Mounts testbed. Call start with a world to start simulation and rendering.\n */\n static mount(options?: TestbedMountOptions): Testbed {\n throw new Error(\"Not implemented\");\n }\n\n /**\n * Mounts testbed if needed, then starts simulation and rendering.\n * \n * If you need to customize testbed before starting, first run `const testbed = Testbed.mount()` and then `testbed.start()`.\n */\n static start(world: World): Testbed {\n const testbed = Testbed.mount();\n testbed.start(world);\n return testbed;\n }\n\n /** World viewbox width. */\n width: number = 80;\n\n /** World viewbox height. */\n height: number = 60;\n\n /** World viewbox center vertical offset. */\n x: number = 0;\n\n /** World viewbox center horizontal offset. */\n y: number = -10;\n\n /** @hidden */\n scaleY: number = -1;\n\n /** World simulation step frequency */\n hz: number = 60;\n\n /** World simulation speed, default is 1 */\n speed: number = 1;\n\n background: string = \"#222222\";\n\n mouseForce?: number;\n activeKeys: ActiveKeys = {};\n\n /** callback, to be implemented by user */\n step = (dt: number, t: number): void => {\n return;\n };\n\n /** callback, to be implemented by user */\n keydown = (keyCode: number, label: string): void => {\n return;\n };\n\n /** callback, to be implemented by user */\n keyup = (keyCode: number, label: string): void => {\n return;\n };\n\n abstract status(name: string, value: any): void;\n abstract status(value: object | string): void;\n\n abstract info(text: string): void;\n\n color(r: number, g: number, b: number): string {\n r = r * 256 | 0;\n g = g * 256 | 0;\n b = b * 256 | 0;\n return \"rgb(\" + r + \", \" + g + \", \" + b + \")\";\n }\n\n abstract drawPoint(p: {x: number, y: number}, r: any, color: string): void;\n abstract drawCircle(p: {x: number, y: number}, r: number, color: string): void;\n abstract drawEdge(a: {x: number, y: number}, b: {x: number, y: number}, color: string): void;\n abstract drawSegment(a: {x: number, y: number}, b: {x: number, y: number}, color: string): void;\n abstract drawPolygon(points: Array<{x: number, y: number}>, color: string): void;\n abstract drawAABB(aabb: AABBValue, color: string): void;\n\n abstract start(world: World): void;\n\n abstract findOne(query: string): (Body | Joint | Fixture | null);\n abstract findAll(query: string): (Body | Joint | Fixture)[];\n}\n\ntype TestbedFactoryOptions = string | TestbedMountOptions;\n\n/** @deprecated */\ntype TestbedCallback = (testbed: Testbed) => (World | undefined);\n\n/** @deprecated */\nexport function testbed(callback: TestbedCallback): void;\n/** @deprecated */\nexport function testbed(options: TestbedFactoryOptions, callback: TestbedCallback): void;\n/** @internal */\nexport function testbed(a?: any, b?: any) {\n let callback: TestbedCallback | undefined;\n let options;\n if (typeof a === \"function\") {\n callback = a;\n options = b;\n } else if (typeof b === \"function\") {\n callback = b;\n options = a;\n } else {\n options = a ?? b;\n }\n const testbed = Testbed.mount(options);\n if (callback) {\n // this is for backwards compatibility\n const world = callback(testbed) || (testbed as any).world;\n testbed.start(world);\n } else {\n return testbed;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { Vec2Value } from \"../../common/Vec2\";\nimport { PolygonShape } from \"./PolygonShape\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\ndeclare module \"./BoxShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function BoxShape(halfWidth: number, halfHeight: number, center?: Vec2Value, angle?: number): BoxShape;\n}\n\n/**\n * A rectangle polygon which extend PolygonShape.\n */\n// @ts-expect-error\nexport class BoxShape extends PolygonShape {\n // note that box is serialized/deserialized as polygon\n static TYPE = \"polygon\" as const;\n\n /**\n * \n * @param halfWidth \n * @param halfHeight \n * @param center coordinate of the center of the box relative to the body\n * @param angle angle of the box relative to the body\n */\n constructor(halfWidth: number, halfHeight: number, center?: Vec2Value, angle?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof BoxShape)) {\n return new BoxShape(halfWidth, halfHeight, center, angle);\n }\n\n super();\n\n this._setAsBox(halfWidth, halfHeight, center, angle);\n }\n}\n\nexport const Box = BoxShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { CircleShape } from \"./CircleShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(CircleShape.TYPE, CircleShape.TYPE, CircleCircleContact);\n\n/** @internal */ function CircleCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == CircleShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n CollideCircles(manifold, fixtureA.getShape() as CircleShape, xfA, fixtureB.getShape() as CircleShape, xfB);\n}\n\n/** @internal */ const pA = matrix.vec2(0, 0);\n/** @internal */ const pB = matrix.vec2(0, 0);\n\nexport const CollideCircles = function (manifold: Manifold, circleA: CircleShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n matrix.transformVec2(pA, xfA, circleA.m_p);\n matrix.transformVec2(pB, xfB, circleB.m_p);\n\n const distSqr = matrix.distSqrVec2(pB, pA);\n const rA = circleA.m_radius;\n const rB = circleB.m_radius;\n const radius = rA + rB;\n if (distSqr > radius * radius) {\n return;\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.copyVec2(manifold.localPoint, circleA.m_p);\n matrix.zeroVec2(manifold.localNormal);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { TransformValue } from \"../../common/Transform\";\nimport * as matrix from \"../../common/Matrix\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { EdgeShape } from \"./EdgeShape\";\nimport { ChainShape } from \"./ChainShape\";\nimport { CircleShape } from \"./CircleShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(EdgeShape.TYPE, CircleShape.TYPE, EdgeCircleContact);\nContact.addType(ChainShape.TYPE, CircleShape.TYPE, ChainCircleContact);\n\n/** @internal */ function EdgeCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == EdgeShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n\n const shapeA = fixtureA.getShape() as EdgeShape;\n const shapeB = fixtureB.getShape() as CircleShape;\n\n CollideEdgeCircle(manifold, shapeA, xfA, shapeB, xfB);\n}\n\nfunction ChainCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == ChainShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n\n const chain = fixtureA.getShape() as ChainShape;\n const edge = new EdgeShape();\n chain.getChildEdge(edge, indexA);\n\n const shapeA = edge;\n const shapeB = fixtureB.getShape() as CircleShape;\n\n CollideEdgeCircle(manifold, shapeA, xfA, shapeB, xfB);\n}\n\n/** @internal */ const e = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const e1 = matrix.vec2(0, 0);\n/** @internal */ const e2 = matrix.vec2(0, 0);\n/** @internal */ const Q = matrix.vec2(0, 0);\n/** @internal */ const P = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n\n// Compute contact points for edge versus circle.\n// This accounts for edge connectivity.\nexport const CollideEdgeCircle = function (manifold: Manifold, edgeA: EdgeShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n // Compute circle in frame of edge\n matrix.retransformVec2(Q, xfB, xfA, circleB.m_p);\n\n const A = edgeA.m_vertex1;\n const B = edgeA.m_vertex2;\n matrix.subVec2(e, B, A);\n\n // Barycentric coordinates\n const u = matrix.dotVec2(e, B) - matrix.dotVec2(e, Q);\n const v = matrix.dotVec2(e, Q) - matrix.dotVec2(e, A);\n\n const radius = edgeA.m_radius + circleB.m_radius;\n\n // Region A\n if (v <= 0.0) {\n matrix.copyVec2(P, A);\n const dd = matrix.distSqrVec2(Q, A);\n if (dd > radius * radius) {\n return;\n }\n\n // Is there an edge connected to A?\n if (edgeA.m_hasVertex0) {\n const A1 = edgeA.m_vertex0;\n const B1 = A;\n matrix.subVec2(e1, B1, A1);\n const u1 = matrix.dotVec2(e1, B1) - matrix.dotVec2(e1, Q);\n\n // Is the circle in Region AB of the previous edge?\n if (u1 > 0.0) {\n return;\n }\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.zeroVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, P);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n return;\n }\n\n // Region B\n if (u <= 0.0) {\n matrix.copyVec2(P, B);\n const dd = matrix.distSqrVec2(Q, P);\n if (dd > radius * radius) {\n return;\n }\n\n // Is there an edge connected to B?\n if (edgeA.m_hasVertex3) {\n const B2 = edgeA.m_vertex3;\n const A2 = B;\n matrix.subVec2(e2, B2, A2);\n const v2 = matrix.dotVec2(e2, Q) - matrix.dotVec2(e2, A2);\n\n // Is the circle in Region AB of the next edge?\n if (v2 > 0.0) {\n return;\n }\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.zeroVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, P);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(1, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n\n return;\n }\n\n // Region AB\n const den = matrix.lengthSqrVec2(e);\n if (_ASSERT) console.assert(den > 0.0);\n matrix.combine2Vec2(P, u / den, A, v / den, B);\n const dd = matrix.distSqrVec2(Q, P);\n if (dd > radius * radius) {\n return;\n }\n\n matrix.crossNumVec2(n, 1, e);\n if (matrix.dotVec2(n, Q) - matrix.dotVec2(n, A) < 0.0) {\n matrix.negVec2(n);\n }\n matrix.normalizeVec2(n);\n\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, n);\n matrix.copyVec2(manifold.localPoint, A);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_face, 0, ContactFeatureType.e_vertex);\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { TransformValue } from \"../../common/Transform\";\nimport * as matrix from \"../../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Manifold, clipSegmentToLine, ClipVertex, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/** @internal */ const incidentEdge = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints1 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints2 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipSegmentToLineNormal = matrix.vec2(0, 0);\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const v11 = matrix.vec2(0, 0);\n/** @internal */ const v12 = matrix.vec2(0, 0);\n/** @internal */ const localTangent = matrix.vec2(0, 0);\n/** @internal */ const localNormal = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const tangent = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const normal1 = matrix.vec2(0, 0);\n\n\nContact.addType(PolygonShape.TYPE, PolygonShape.TYPE, PolygonContact);\n\n/** @internal */ function PolygonContact(\n manifold: Manifold,\n xfA: TransformValue,\n fixtureA: Fixture,\n indexA: number,\n xfB: TransformValue,\n fixtureB: Fixture,\n indexB: number,\n): void {\n if (_ASSERT) console.assert(fixtureA.getType() == PolygonShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == PolygonShape.TYPE);\n CollidePolygons(manifold, fixtureA.getShape() as PolygonShape, xfA, fixtureB.getShape() as PolygonShape, xfB);\n}\n\n/** @internal */ interface MaxSeparation {\n maxSeparation: number;\n bestIndex: number;\n}\n\n/**\n * Find the max separation between poly1 and poly2 using edge normals from\n * poly1.\n */\n/** @internal */ function findMaxSeparation(\n poly1: PolygonShape,\n xf1: TransformValue,\n poly2: PolygonShape,\n xf2: TransformValue,\n output: MaxSeparation,\n): void {\n const count1 = poly1.m_count;\n const count2 = poly2.m_count;\n const n1s = poly1.m_normals;\n const v1s = poly1.m_vertices;\n const v2s = poly2.m_vertices;\n\n matrix.detransformTransform(xf, xf2, xf1);\n\n let bestIndex = 0;\n let maxSeparation = -Infinity;\n for (let i = 0; i < count1; ++i) {\n // Get poly1 normal in frame2.\n matrix.rotVec2(n, xf.q, n1s[i]);\n matrix.transformVec2(v1, xf, v1s[i]);\n\n // Find deepest point for normal i.\n let si = Infinity;\n for (let j = 0; j < count2; ++j) {\n const sij = matrix.dotVec2(n, v2s[j]) - matrix.dotVec2(n, v1);\n if (sij < si) {\n si = sij;\n }\n }\n\n if (si > maxSeparation) {\n maxSeparation = si;\n bestIndex = i;\n }\n }\n\n // used to keep last FindMaxSeparation call values\n output.maxSeparation = maxSeparation;\n output.bestIndex = bestIndex;\n}\n\n/** @internal */ function findIncidentEdge(\n clipVertex: ClipVertex[],\n poly1: PolygonShape,\n xf1: TransformValue,\n edge1: number,\n poly2: PolygonShape,\n xf2: TransformValue,\n): void {\n const normals1 = poly1.m_normals;\n\n const count2 = poly2.m_count;\n const vertices2 = poly2.m_vertices;\n const normals2 = poly2.m_normals;\n\n if (_ASSERT) console.assert(0 <= edge1 && edge1 < poly1.m_count);\n\n // Get the normal of the reference edge in poly2's frame.\n matrix.rerotVec2(normal1, xf2.q, xf1.q, normals1[edge1]);\n\n // Find the incident edge on poly2.\n let index = 0;\n let minDot = Infinity;\n for (let i = 0; i < count2; ++i) {\n const dot = matrix.dotVec2(normal1, normals2[i]);\n if (dot < minDot) {\n minDot = dot;\n index = i;\n }\n }\n\n // Build the clip vertices for the incident edge.\n const i1 = index;\n const i2 = i1 + 1 < count2 ? i1 + 1 : 0;\n\n matrix.transformVec2(clipVertex[0].v, xf2, vertices2[i1]);\n clipVertex[0].id.setFeatures(edge1, ContactFeatureType.e_face, i1, ContactFeatureType.e_vertex);\n\n matrix.transformVec2(clipVertex[1].v, xf2, vertices2[i2]);\n clipVertex[1].id.setFeatures(edge1, ContactFeatureType.e_face, i2, ContactFeatureType.e_vertex);\n}\n\n/** @internal */ const maxSeparation = {\n maxSeparation: 0,\n bestIndex: 0,\n};\n\n/**\n *\n * Find edge normal of max separation on A - return if separating axis is found
\n * Find edge normal of max separation on B - return if separation axis is found
\n * Choose reference edge as min(minA, minB)
\n * Find incident edge
\n * Clip\n *\n * The normal points from 1 to 2\n */\nexport const CollidePolygons = function (\n manifold: Manifold,\n polyA: PolygonShape,\n xfA: TransformValue,\n polyB: PolygonShape,\n xfB: TransformValue,\n): void {\n manifold.pointCount = 0;\n const totalRadius = polyA.m_radius + polyB.m_radius;\n\n findMaxSeparation(polyA, xfA, polyB, xfB, maxSeparation);\n const edgeA = maxSeparation.bestIndex;\n const separationA = maxSeparation.maxSeparation;\n if (separationA > totalRadius)\n return;\n\n findMaxSeparation(polyB, xfB, polyA, xfA, maxSeparation);\n const edgeB = maxSeparation.bestIndex;\n const separationB = maxSeparation.maxSeparation;\n if (separationB > totalRadius)\n return;\n\n let poly1: PolygonShape; // reference polygon\n let poly2: PolygonShape; // incident polygon\n let xf1: TransformValue;\n let xf2: TransformValue;\n let edge1: number; // reference edge\n let flip: boolean;\n const k_tol = 0.1 * Settings.linearSlop;\n\n if (separationB > separationA + k_tol) {\n poly1 = polyB;\n poly2 = polyA;\n xf1 = xfB;\n xf2 = xfA;\n edge1 = edgeB;\n manifold.type = ManifoldType.e_faceB;\n flip = true;\n } else {\n poly1 = polyA;\n poly2 = polyB;\n xf1 = xfA;\n xf2 = xfB;\n edge1 = edgeA;\n manifold.type = ManifoldType.e_faceA;\n flip = false;\n }\n\n incidentEdge[0].recycle();\n incidentEdge[1].recycle();\n findIncidentEdge(incidentEdge, poly1, xf1, edge1, poly2, xf2);\n\n const count1 = poly1.m_count;\n const vertices1 = poly1.m_vertices;\n\n const iv1 = edge1;\n const iv2 = edge1 + 1 < count1 ? edge1 + 1 : 0;\n\n matrix.copyVec2(v11, vertices1[iv1]);\n matrix.copyVec2(v12, vertices1[iv2]);\n\n matrix.subVec2(localTangent, v12, v11);\n matrix.normalizeVec2(localTangent);\n\n matrix.crossVec2Num(localNormal, localTangent, 1.0);\n matrix.combine2Vec2(planePoint, 0.5, v11, 0.5, v12);\n\n matrix.rotVec2(tangent, xf1.q, localTangent);\n matrix.crossVec2Num(normal, tangent, 1.0);\n\n matrix.transformVec2(v11, xf1, v11);\n matrix.transformVec2(v12, xf1, v12);\n\n // Face offset.\n const frontOffset = matrix.dotVec2(normal, v11);\n\n // Side offsets, extended by polytope skin thickness.\n const sideOffset1 = -matrix.dotVec2(tangent, v11) + totalRadius;\n const sideOffset2 = matrix.dotVec2(tangent, v12) + totalRadius;\n\n // Clip incident edge against extruded edge1 side edges.\n clipPoints1[0].recycle();\n clipPoints1[1].recycle();\n clipPoints2[0].recycle();\n clipPoints2[1].recycle();\n\n // Clip to box side 1\n matrix.setVec2(clipSegmentToLineNormal, -tangent.x, -tangent.y);\n const np1 = clipSegmentToLine(clipPoints1, incidentEdge, clipSegmentToLineNormal, sideOffset1, iv1);\n\n if (np1 < 2) {\n return;\n }\n\n // Clip to negative box side 1\n matrix.setVec2(clipSegmentToLineNormal, tangent.x, tangent.y);\n const np2 = clipSegmentToLine(clipPoints2, clipPoints1, clipSegmentToLineNormal, sideOffset2, iv2);\n\n if (np2 < 2) {\n return;\n }\n\n // Now clipPoints2 contains the clipped points.\n matrix.copyVec2(manifold.localNormal, localNormal);\n matrix.copyVec2(manifold.localPoint, planePoint);\n\n let pointCount = 0;\n for (let i = 0; i < clipPoints2.length/* maxManifoldPoints */; ++i) {\n const separation = matrix.dotVec2(normal, clipPoints2[i].v) - frontOffset;\n\n if (separation <= totalRadius) {\n const cp = manifold.points[pointCount];\n matrix.detransformVec2(cp.localPoint, xf2, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n if (flip) {\n // Swap features\n cp.id.swapFeatures();\n }\n ++pointCount;\n }\n }\n\n manifold.pointCount = pointCount;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { EPSILON } from \"../../common/Math\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { CircleShape } from \"./CircleShape\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(PolygonShape.TYPE, CircleShape.TYPE, PolygonCircleContact);\n\n/** @internal */ function PolygonCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == PolygonShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n CollidePolygonCircle(manifold, fixtureA.getShape() as PolygonShape, xfA, fixtureB.getShape() as CircleShape, xfB);\n}\n\n/** @internal */ const cLocal = matrix.vec2(0, 0);\n/** @internal */ const faceCenter = matrix.vec2(0, 0);\n\nexport const CollidePolygonCircle = function (manifold: Manifold, polygonA: PolygonShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n // Compute circle position in the frame of the polygon.\n matrix.retransformVec2(cLocal, xfB, xfA, circleB.m_p);\n\n // Find the min separating edge.\n let normalIndex = 0;\n let separation = -Infinity;\n const radius = polygonA.m_radius + circleB.m_radius;\n const vertexCount = polygonA.m_count;\n const vertices = polygonA.m_vertices;\n const normals = polygonA.m_normals;\n\n for (let i = 0; i < vertexCount; ++i) {\n const s = matrix.dotVec2(normals[i], cLocal) - matrix.dotVec2(normals[i], vertices[i]);\n\n if (s > radius) {\n // Early out.\n return;\n }\n\n if (s > separation) {\n separation = s;\n normalIndex = i;\n }\n }\n\n // Vertices that subtend the incident face.\n const vertIndex1 = normalIndex;\n const vertIndex2 = vertIndex1 + 1 < vertexCount ? vertIndex1 + 1 : 0;\n const v1 = vertices[vertIndex1];\n const v2 = vertices[vertIndex2];\n\n // If the center is inside the polygon ...\n if (separation < EPSILON) {\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, normals[normalIndex]);\n matrix.combine2Vec2(manifold.localPoint, 0.5, v1, 0.5, v2);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n return;\n }\n\n // Compute barycentric coordinates\n // u1 = (cLocal - v1) dot (v2 - v1))\n const u1 = matrix.dotVec2(cLocal, v2) - matrix.dotVec2(cLocal, v1) - matrix.dotVec2(v1, v2) + matrix.dotVec2(v1, v1);\n // u2 = (cLocal - v2) dot (v1 - v2)\n const u2 = matrix.dotVec2(cLocal, v1) - matrix.dotVec2(cLocal, v2) - matrix.dotVec2(v2, v1) + matrix.dotVec2(v2, v2);\n if (u1 <= 0.0) {\n if (matrix.distSqrVec2(cLocal, v1) > radius * radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.subVec2(manifold.localNormal, cLocal, v1);\n matrix.normalizeVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, v1);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n } else if (u2 <= 0.0) {\n if (matrix.distSqrVec2(cLocal, v2) > radius * radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.subVec2(manifold.localNormal, cLocal, v2);\n matrix.normalizeVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, v2);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n } else {\n matrix.combine2Vec2(faceCenter, 0.5, v1, 0.5, v2);\n const separation = matrix.dotVec2(cLocal, normals[vertIndex1]) - matrix.dotVec2(faceCenter, normals[vertIndex1]);\n if (separation > radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, normals[vertIndex1]);\n matrix.copyVec2(manifold.localPoint, faceCenter);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n }\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { Manifold, clipSegmentToLine, ClipVertex, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { EdgeShape } from \"./EdgeShape\";\nimport { ChainShape } from \"./ChainShape\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_min = Math.min;\n\nContact.addType(EdgeShape.TYPE, PolygonShape.TYPE, EdgePolygonContact);\nContact.addType(ChainShape.TYPE, PolygonShape.TYPE, ChainPolygonContact);\n\n/** @internal */ function EdgePolygonContact(manifold: Manifold, xfA: TransformValue, fA: Fixture, indexA: number, xfB: TransformValue, fB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fA.getType() == EdgeShape.TYPE);\n if (_ASSERT) console.assert(fB.getType() == PolygonShape.TYPE);\n\n CollideEdgePolygon(manifold, fA.getShape() as EdgeShape, xfA, fB.getShape() as PolygonShape, xfB);\n}\n\n// reused\n/** @internal */ const edge_reuse = new EdgeShape();\n\n/** @internal */ function ChainPolygonContact(manifold: Manifold, xfA: TransformValue, fA: Fixture, indexA: number, xfB: TransformValue, fB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fA.getType() == ChainShape.TYPE);\n if (_ASSERT) console.assert(fB.getType() == PolygonShape.TYPE);\n\n const chain = fA.getShape() as ChainShape;\n chain.getChildEdge(edge_reuse, indexA);\n\n CollideEdgePolygon(manifold, edge_reuse, xfA, fB.getShape() as PolygonShape, xfB);\n}\n\n/** @internal */ enum EPAxisType {\n e_unknown = -1,\n e_edgeA = 1,\n e_edgeB = 2,\n}\n\n// unused?\n/** @internal */ enum VertexType {\n e_isolated = 0,\n e_concave = 1,\n e_convex = 2,\n}\n\n/**\n * This structure is used to keep track of the best separating axis.\n */\n/** @internal */ class EPAxis {\n type: EPAxisType;\n index: number;\n separation: number;\n}\n\n/**\n * This holds polygon B expressed in frame A.\n */\n/** @internal */ class TempPolygon {\n vertices: Vec2Value[] = []; // [Settings.maxPolygonVertices]\n normals: Vec2Value[] = []; // [Settings.maxPolygonVertices];\n count: number = 0;\n constructor() {\n for (let i = 0; i < Settings.maxPolygonVertices; i++) {\n this.vertices.push(matrix.vec2(0, 0));\n this.normals.push(matrix.vec2(0, 0));\n }\n }\n}\n\n/**\n * Reference face used for clipping\n */\n/** @internal */ class ReferenceFace {\n i1: number;\n i2: number;\n readonly v1 = matrix.vec2(0 ,0);\n readonly v2 = matrix.vec2(0 ,0);\n readonly normal = matrix.vec2(0 ,0);\n readonly sideNormal1 = matrix.vec2(0 ,0);\n sideOffset1: number;\n readonly sideNormal2 = matrix.vec2(0 ,0);\n sideOffset2: number;\n recycle() {\n matrix.zeroVec2(this.v1);\n matrix.zeroVec2(this.v2);\n matrix.zeroVec2(this.normal);\n matrix.zeroVec2(this.sideNormal1);\n matrix.zeroVec2(this.sideNormal2);\n }\n}\n\n// reused\n/** @internal */ const clipPoints1 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints2 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const ie = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const edgeAxis = new EPAxis();\n/** @internal */ const polygonAxis = new EPAxis();\n/** @internal */ const polygonBA = new TempPolygon();\n/** @internal */ const rf = new ReferenceFace();\n/** @internal */ const centroidB = matrix.vec2(0, 0);\n/** @internal */ const edge0 = matrix.vec2(0, 0);\n/** @internal */ const edge1 = matrix.vec2(0, 0);\n/** @internal */ const edge2 = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const normal0 = matrix.vec2(0, 0);\n/** @internal */ const normal1 = matrix.vec2(0, 0);\n/** @internal */ const normal2 = matrix.vec2(0, 0);\n/** @internal */ const lowerLimit = matrix.vec2(0, 0);\n/** @internal */ const upperLimit = matrix.vec2(0, 0);\n/** @internal */ const perp = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n\n/**\n * This function collides and edge and a polygon, taking into account edge\n * adjacency.\n */\nexport const CollideEdgePolygon = function (manifold: Manifold, edgeA: EdgeShape, xfA: TransformValue, polygonB: PolygonShape, xfB: TransformValue): void {\n // Algorithm:\n // 1. Classify v1 and v2\n // 2. Classify polygon centroid as front or back\n // 3. Flip normal if necessary\n // 4. Initialize normal range to [-pi, pi] about face normal\n // 5. Adjust normal range according to adjacent edges\n // 6. Visit each separating axes, only accept axes within the range\n // 7. Return if _any_ axis indicates separation\n // 8. Clip\n\n // let m_type1: VertexType;\n // let m_type2: VertexType;\n\n matrix.detransformTransform(xf, xfA, xfB);\n matrix.transformVec2(centroidB, xf, polygonB.m_centroid);\n\n const v0 = edgeA.m_vertex0;\n const v1 = edgeA.m_vertex1;\n const v2 = edgeA.m_vertex2;\n const v3 = edgeA.m_vertex3;\n\n const hasVertex0 = edgeA.m_hasVertex0;\n const hasVertex3 = edgeA.m_hasVertex3;\n\n matrix.subVec2(edge1, v2, v1);\n matrix.normalizeVec2(edge1);\n matrix.setVec2(normal1, edge1.y, -edge1.x);\n const offset1 = matrix.dotVec2(normal1, centroidB) - matrix.dotVec2(normal1, v1);\n let offset0 = 0.0;\n let offset2 = 0.0;\n let convex1 = false;\n let convex2 = false;\n\n matrix.zeroVec2(normal0);\n matrix.zeroVec2(normal2);\n\n // Is there a preceding edge?\n if (hasVertex0) {\n matrix.subVec2(edge0, v1, v0);\n matrix.normalizeVec2(edge0);\n matrix.setVec2(normal0, edge0.y, -edge0.x);\n convex1 = matrix.crossVec2Vec2(edge0, edge1) >= 0.0;\n offset0 = Vec2.dot(normal0, centroidB) - Vec2.dot(normal0, v0);\n }\n\n // Is there a following edge?\n if (hasVertex3) {\n matrix.subVec2(edge2, v3, v2);\n matrix.normalizeVec2(edge2);\n matrix.setVec2(normal2, edge2.y, -edge2.x);\n convex2 = Vec2.crossVec2Vec2(edge1, edge2) > 0.0;\n offset2 = Vec2.dot(normal2, centroidB) - Vec2.dot(normal2, v2);\n }\n\n let front: boolean;\n matrix.zeroVec2(normal);\n matrix.zeroVec2(lowerLimit);\n matrix.zeroVec2(upperLimit);\n\n // Determine front or back collision. Determine collision normal limits.\n if (hasVertex0 && hasVertex3) {\n if (convex1 && convex2) {\n front = offset0 >= 0.0 || offset1 >= 0.0 || offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else if (convex1) {\n front = offset0 >= 0.0 || (offset1 >= 0.0 && offset2 >= 0.0);\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else if (convex2) {\n front = offset2 >= 0.0 || (offset0 >= 0.0 && offset1 >= 0.0);\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n } else {\n front = offset0 >= 0.0 && offset1 >= 0.0 && offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n }\n } else if (hasVertex0) {\n if (convex1) {\n front = offset0 >= 0.0 || offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else {\n front = offset0 >= 0.0 && offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n }\n } else if (hasVertex3) {\n if (convex2) {\n front = offset1 >= 0.0 || offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal1);\n }\n } else {\n front = offset1 >= 0.0 && offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.copyVec2(upperLimit, normal1);\n }\n }\n } else {\n front = offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal1);\n }\n }\n\n // Get polygonB in frameA\n polygonBA.count = polygonB.m_count;\n for (let i = 0; i < polygonB.m_count; ++i) {\n matrix.transformVec2(polygonBA.vertices[i], xf, polygonB.m_vertices[i]);\n matrix.rotVec2(polygonBA.normals[i], xf.q, polygonB.m_normals[i]);\n }\n\n const radius = polygonB.m_radius + edgeA.m_radius;\n\n manifold.pointCount = 0;\n\n { // ComputeEdgeSeparation\n edgeAxis.type = EPAxisType.e_edgeA;\n edgeAxis.index = front ? 0 : 1;\n edgeAxis.separation = Infinity;\n\n for (let i = 0; i < polygonBA.count; ++i) {\n const v = polygonBA.vertices[i];\n const s = matrix.dotVec2(normal, v) - matrix.dotVec2(normal, v1);\n if (s < edgeAxis.separation) {\n edgeAxis.separation = s;\n }\n }\n }\n\n // If no valid normal can be found than this edge should not collide.\n // @ts-ignore todo: why we need this if here?\n if (edgeAxis.type == EPAxisType.e_unknown) {\n return;\n }\n\n if (edgeAxis.separation > radius) {\n return;\n }\n\n { // ComputePolygonSeparation\n polygonAxis.type = EPAxisType.e_unknown;\n polygonAxis.index = -1;\n polygonAxis.separation = -Infinity;\n\n matrix.setVec2(perp, -normal.y, normal.x);\n\n for (let i = 0; i < polygonBA.count; ++i) {\n matrix.scaleVec2(n, -1, polygonBA.normals[i]);\n\n const s1 = matrix.dotVec2(n, polygonBA.vertices[i]) - matrix.dotVec2(n, v1);\n const s2 = matrix.dotVec2(n, polygonBA.vertices[i]) - matrix.dotVec2(n, v2);\n const s = math_min(s1, s2);\n\n if (s > radius) {\n // No collision\n polygonAxis.type = EPAxisType.e_edgeB;\n polygonAxis.index = i;\n polygonAxis.separation = s;\n break;\n }\n\n // Adjacency\n if (matrix.dotVec2(n, perp) >= 0.0) {\n if (matrix.dotVec2(n, normal) - matrix.dotVec2(upperLimit, normal) < -Settings.angularSlop) {\n continue;\n }\n } else {\n if (matrix.dotVec2(n, normal) - matrix.dotVec2(lowerLimit, normal) < -Settings.angularSlop) {\n continue;\n }\n }\n\n if (s > polygonAxis.separation) {\n polygonAxis.type = EPAxisType.e_edgeB;\n polygonAxis.index = i;\n polygonAxis.separation = s;\n }\n }\n }\n\n if (polygonAxis.type != EPAxisType.e_unknown && polygonAxis.separation > radius) {\n return;\n }\n\n // Use hysteresis for jitter reduction.\n const k_relativeTol = 0.98;\n const k_absoluteTol = 0.001;\n\n let primaryAxis: EPAxis;\n if (polygonAxis.type == EPAxisType.e_unknown) {\n primaryAxis = edgeAxis;\n } else if (polygonAxis.separation > k_relativeTol * edgeAxis.separation + k_absoluteTol) {\n primaryAxis = polygonAxis;\n } else {\n primaryAxis = edgeAxis;\n }\n\n ie[0].recycle();\n ie[1].recycle();\n\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n manifold.type = ManifoldType.e_faceA;\n\n // Search for the polygon normal that is most anti-parallel to the edge\n // normal.\n let bestIndex = 0;\n let bestValue = matrix.dotVec2(normal, polygonBA.normals[0]);\n for (let i = 1; i < polygonBA.count; ++i) {\n const value = matrix.dotVec2(normal, polygonBA.normals[i]);\n if (value < bestValue) {\n bestValue = value;\n bestIndex = i;\n }\n }\n\n const i1 = bestIndex;\n const i2 = i1 + 1 < polygonBA.count ? i1 + 1 : 0;\n\n matrix.copyVec2(ie[0].v, polygonBA.vertices[i1]);\n ie[0].id.setFeatures(0, ContactFeatureType.e_face, i1, ContactFeatureType.e_vertex);\n\n matrix.copyVec2(ie[1].v, polygonBA.vertices[i2]);\n ie[1].id.setFeatures(0, ContactFeatureType.e_face, i2, ContactFeatureType.e_vertex);\n\n if (front) {\n rf.i1 = 0;\n rf.i2 = 1;\n matrix.copyVec2(rf.v1, v1);\n matrix.copyVec2(rf.v2, v2);\n matrix.copyVec2(rf.normal, normal1);\n } else {\n rf.i1 = 1;\n rf.i2 = 0;\n matrix.copyVec2(rf.v1, v2);\n matrix.copyVec2(rf.v2, v1);\n matrix.scaleVec2(rf.normal, -1, normal1);\n }\n } else {\n manifold.type = ManifoldType.e_faceB;\n\n matrix.copyVec2(ie[0].v, v1);\n ie[0].id.setFeatures(0, ContactFeatureType.e_vertex, primaryAxis.index, ContactFeatureType.e_face);\n\n matrix.copyVec2(ie[1].v, v2);\n ie[1].id.setFeatures(0, ContactFeatureType.e_vertex, primaryAxis.index, ContactFeatureType.e_face);\n\n rf.i1 = primaryAxis.index;\n rf.i2 = rf.i1 + 1 < polygonBA.count ? rf.i1 + 1 : 0;\n matrix.copyVec2(rf.v1, polygonBA.vertices[rf.i1]);\n matrix.copyVec2(rf.v2, polygonBA.vertices[rf.i2]);\n matrix.copyVec2(rf.normal, polygonBA.normals[rf.i1]);\n }\n\n matrix.setVec2(rf.sideNormal1, rf.normal.y, -rf.normal.x);\n matrix.setVec2(rf.sideNormal2, -rf.sideNormal1.x, -rf.sideNormal1.y);\n rf.sideOffset1 = matrix.dotVec2(rf.sideNormal1, rf.v1);\n rf.sideOffset2 = matrix.dotVec2(rf.sideNormal2, rf.v2);\n\n // Clip incident edge against extruded edge1 side edges.\n clipPoints1[0].recycle();\n clipPoints1[1].recycle();\n clipPoints2[0].recycle();\n clipPoints2[1].recycle();\n\n // Clip to box side 1\n const np1 = clipSegmentToLine(clipPoints1, ie, rf.sideNormal1, rf.sideOffset1, rf.i1);\n\n if (np1 < Settings.maxManifoldPoints) {\n return;\n }\n\n // Clip to negative box side 1\n const np2 = clipSegmentToLine(clipPoints2, clipPoints1, rf.sideNormal2, rf.sideOffset2, rf.i2);\n\n if (np2 < Settings.maxManifoldPoints) {\n return;\n }\n\n // Now clipPoints2 contains the clipped points.\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n matrix.copyVec2(manifold.localNormal, rf.normal);\n matrix.copyVec2(manifold.localPoint, rf.v1);\n } else {\n matrix.copyVec2(manifold.localNormal, polygonB.m_normals[rf.i1]);\n matrix.copyVec2(manifold.localPoint, polygonB.m_vertices[rf.i1]);\n }\n\n let pointCount = 0;\n for (let i = 0; i < Settings.maxManifoldPoints; ++i) {\n const separation = matrix.dotVec2(rf.normal, clipPoints2[i].v) - matrix.dotVec2(rf.normal, rf.v1);\n\n if (separation <= radius) {\n const cp = manifold.points[pointCount]; // ManifoldPoint\n\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n matrix.detransformVec2(cp.localPoint, xf, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n } else {\n matrix.copyVec2(cp.localPoint, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n cp.id.swapFeatures();\n }\n\n ++pointCount;\n }\n }\n\n manifold.pointCount = pointCount;\n};\n","import { CollidePolygons } from \"./collision/shape/CollidePolygon\";\nimport { Settings } from \"./Settings\";\nimport { Sweep } from \"./common/Sweep\";\nimport { DynamicTree } from \"./collision/DynamicTree\";\nimport { Manifold } from \"./collision/Manifold\";\nimport { Distance } from \"./collision/Distance\";\nimport { TimeOfImpact } from \"./collision/TimeOfImpact\";\nimport { stats } from \"./util/stats\";\n\n/** @hidden @deprecated Merged with main namespace */\nexport const internal = {\n CollidePolygons,\n Settings,\n Sweep,\n Manifold,\n Distance,\n TimeOfImpact,\n DynamicTree,\n stats\n};\n","/**\n * Stage.js 1.0.0-alpha.5\n *\n * @copyright Copyright (c) 2024 Ali Shakiba\n * @license The MIT License (MIT)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\nvar math_random = Math.random;\nvar math_sqrt = Math.sqrt;\nfunction random(min, max) {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n return min == max ? min : math_random() * (max - min) + min;\n}\nfunction wrap(num, min, max) {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n if (max > min) {\n num = (num - min) % (max - min);\n return num + (num < 0 ? max : min);\n } else {\n num = (num - max) % (min - max);\n return num + (num <= 0 ? min : max);\n }\n}\nfunction clamp(num, min, max) {\n if (num < min) {\n return min;\n } else if (num > max) {\n return max;\n } else {\n return num;\n }\n}\nfunction length(x, y) {\n return math_sqrt(x * x + y * y);\n}\nvar math = Object.create(Math);\nmath.random = random;\nmath.wrap = wrap;\nmath.clamp = clamp;\nmath.length = length;\nmath.rotate = wrap;\nmath.limit = clamp;\nvar Matrix = (\n /** @class */\n function() {\n function Matrix2(a, b, c, d, e, f) {\n this.a = 1;\n this.b = 0;\n this.c = 0;\n this.d = 1;\n this.e = 0;\n this.f = 0;\n if (typeof a === \"object\") {\n this.reset(a);\n } else {\n this.reset(a, b, c, d, e, f);\n }\n }\n Matrix2.prototype.toString = function() {\n return \"[\" + this.a + \", \" + this.b + \", \" + this.c + \", \" + this.d + \", \" + this.e + \", \" + this.f + \"]\";\n };\n Matrix2.prototype.clone = function() {\n return new Matrix2(this.a, this.b, this.c, this.d, this.e, this.f);\n };\n Matrix2.prototype.reset = function(a, b, c, d, e, f) {\n this._dirty = true;\n if (typeof a === \"object\") {\n this.a = a.a;\n this.d = a.d;\n this.b = a.b;\n this.c = a.c;\n this.e = a.e;\n this.f = a.f;\n } else {\n this.a = typeof a === \"number\" ? a : 1;\n this.b = typeof b === \"number\" ? b : 0;\n this.c = typeof c === \"number\" ? c : 0;\n this.d = typeof d === \"number\" ? d : 1;\n this.e = typeof e === \"number\" ? e : 0;\n this.f = typeof f === \"number\" ? f : 0;\n }\n return this;\n };\n Matrix2.prototype.identity = function() {\n this._dirty = true;\n this.a = 1;\n this.b = 0;\n this.c = 0;\n this.d = 1;\n this.e = 0;\n this.f = 0;\n return this;\n };\n Matrix2.prototype.rotate = function(angle) {\n if (!angle) {\n return this;\n }\n this._dirty = true;\n var u = angle ? Math.cos(angle) : 1;\n var v = angle ? Math.sin(angle) : 0;\n var a = u * this.a - v * this.b;\n var b = u * this.b + v * this.a;\n var c = u * this.c - v * this.d;\n var d = u * this.d + v * this.c;\n var e = u * this.e - v * this.f;\n var f = u * this.f + v * this.e;\n this.a = a;\n this.b = b;\n this.c = c;\n this.d = d;\n this.e = e;\n this.f = f;\n return this;\n };\n Matrix2.prototype.translate = function(x, y) {\n if (!x && !y) {\n return this;\n }\n this._dirty = true;\n this.e += x;\n this.f += y;\n return this;\n };\n Matrix2.prototype.scale = function(x, y) {\n if (!(x - 1) && !(y - 1)) {\n return this;\n }\n this._dirty = true;\n this.a *= x;\n this.b *= y;\n this.c *= x;\n this.d *= y;\n this.e *= x;\n this.f *= y;\n return this;\n };\n Matrix2.prototype.skew = function(x, y) {\n if (!x && !y) {\n return this;\n }\n this._dirty = true;\n var a = this.a + this.b * x;\n var b = this.b + this.a * y;\n var c = this.c + this.d * x;\n var d = this.d + this.c * y;\n var e = this.e + this.f * x;\n var f = this.f + this.e * y;\n this.a = a;\n this.b = b;\n this.c = c;\n this.d = d;\n this.e = e;\n this.f = f;\n return this;\n };\n Matrix2.prototype.concat = function(m) {\n this._dirty = true;\n var a = this.a * m.a + this.b * m.c;\n var b = this.b * m.d + this.a * m.b;\n var c = this.c * m.a + this.d * m.c;\n var d = this.d * m.d + this.c * m.b;\n var e = this.e * m.a + m.e + this.f * m.c;\n var f = this.f * m.d + m.f + this.e * m.b;\n this.a = a;\n this.b = b;\n this.c = c;\n this.d = d;\n this.e = e;\n this.f = f;\n return this;\n };\n Matrix2.prototype.inverse = function() {\n if (this._dirty) {\n this._dirty = false;\n if (!this.inverted) {\n this.inverted = new Matrix2();\n }\n var z = this.a * this.d - this.b * this.c;\n this.inverted.a = this.d / z;\n this.inverted.b = -this.b / z;\n this.inverted.c = -this.c / z;\n this.inverted.d = this.a / z;\n this.inverted.e = (this.c * this.f - this.e * this.d) / z;\n this.inverted.f = (this.e * this.b - this.a * this.f) / z;\n }\n return this.inverted;\n };\n Matrix2.prototype.map = function(p, q) {\n q = q || { x: 0, y: 0 };\n q.x = this.a * p.x + this.c * p.y + this.e;\n q.y = this.b * p.x + this.d * p.y + this.f;\n return q;\n };\n Matrix2.prototype.mapX = function(x, y) {\n if (typeof x === \"object\") {\n y = x.y;\n x = x.x;\n }\n return this.a * x + this.c * y + this.e;\n };\n Matrix2.prototype.mapY = function(x, y) {\n if (typeof x === \"object\") {\n y = x.y;\n x = x.x;\n }\n return this.b * x + this.d * y + this.f;\n };\n return Matrix2;\n }()\n);\nvar objectToString = Object.prototype.toString;\nfunction isFn(value) {\n var str = objectToString.call(value);\n return str === \"[object Function]\" || str === \"[object GeneratorFunction]\" || str === \"[object AsyncFunction]\";\n}\nfunction isHash(value) {\n return objectToString.call(value) === \"[object Object]\" && value.constructor === Object;\n}\nconst stats = {\n create: 0,\n tick: 0,\n node: 0,\n draw: 0,\n fps: 0\n};\nvar uid = function() {\n return Date.now().toString(36) + Math.random().toString(36).slice(2);\n};\nvar Texture = (\n /** @class */\n function() {\n function Texture2() {\n this.uid = \"texture:\" + uid();\n this.sx = 0;\n this.sy = 0;\n this.dx = 0;\n this.dy = 0;\n }\n Texture2.prototype.setSourceCoordinate = function(x, y) {\n this.sx = x;\n this.sy = y;\n };\n Texture2.prototype.setSourceDimension = function(w, h) {\n this.sw = w;\n this.sh = h;\n };\n Texture2.prototype.setDestinationCoordinate = function(x, y) {\n this.dx = x;\n this.dy = y;\n };\n Texture2.prototype.setDestinationDimension = function(w, h) {\n this.dw = w;\n this.dh = h;\n };\n Texture2.prototype.draw = function(context, x1, y1, w1, h1, x2, y2, w2, h2) {\n var sx = this.sx;\n var sy = this.sy;\n var sw = this.sw;\n var sh = this.sh;\n var dx = this.dx;\n var dy = this.dy;\n var dw = this.dw;\n var dh = this.dh;\n if (typeof x1 === \"number\" || typeof y1 === \"number\" || typeof w1 === \"number\" || typeof h1 === \"number\" || typeof x2 === \"number\" || typeof y2 === \"number\" || typeof w2 === \"number\" || typeof h2 === \"number\") {\n if (typeof x2 === \"number\" || typeof y2 === \"number\" || typeof w2 === \"number\" || typeof h2 === \"number\") {\n sx += x1;\n sy += y1;\n sw = w1 !== null && w1 !== void 0 ? w1 : sw;\n sh = h1 !== null && h1 !== void 0 ? h1 : sh;\n dx += x2;\n dy += y2;\n dw = w2 !== null && w2 !== void 0 ? w2 : dw;\n dh = h2 !== null && h2 !== void 0 ? h2 : dh;\n } else {\n dx += x1;\n dy += y1;\n dw = w1;\n dh = h1;\n }\n }\n this.drawWithNormalizedArgs(context, sx, sy, sw, sh, dx, dy, dw, dh);\n };\n return Texture2;\n }()\n);\nvar __extends$9 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar ImageTexture = (\n /** @class */\n function(_super) {\n __extends$9(ImageTexture2, _super);\n function ImageTexture2(source, pixelRatio) {\n var _this = _super.call(this) || this;\n _this._pixelRatio = 1;\n if (typeof source === \"object\") {\n _this.setSourceImage(source, pixelRatio);\n }\n return _this;\n }\n ImageTexture2.prototype.setSourceImage = function(image2, pixelRatio) {\n if (pixelRatio === void 0) {\n pixelRatio = 1;\n }\n this._source = image2;\n this._pixelRatio = pixelRatio;\n };\n ImageTexture2.prototype.getWidth = function() {\n return this._source.width / this._pixelRatio;\n };\n ImageTexture2.prototype.getHeight = function() {\n return this._source.height / this._pixelRatio;\n };\n ImageTexture2.prototype.prerender = function(context) {\n return false;\n };\n ImageTexture2.prototype.drawWithNormalizedArgs = function(context, sx, sy, sw, sh, dx, dy, dw, dh) {\n var image2 = this._source;\n if (image2 === null || typeof image2 !== \"object\") {\n return;\n }\n sw = sw !== null && sw !== void 0 ? sw : this.getWidth();\n sh = sh !== null && sh !== void 0 ? sh : this.getHeight();\n dw = dw !== null && dw !== void 0 ? dw : sw;\n dh = dh !== null && dh !== void 0 ? dh : sh;\n sx *= this._pixelRatio;\n sy *= this._pixelRatio;\n sw *= this._pixelRatio;\n sh *= this._pixelRatio;\n try {\n stats.draw++;\n context.drawImage(image2, sx, sy, sw, sh, dx, dy, dw, dh);\n } catch (ex) {\n if (!this._draw_failed) {\n console.log(\"Unable to draw: \", image2);\n console.log(ex);\n this._draw_failed = true;\n }\n }\n };\n return ImageTexture2;\n }(Texture)\n);\nvar __extends$8 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar PipeTexture = (\n /** @class */\n function(_super) {\n __extends$8(PipeTexture2, _super);\n function PipeTexture2(source) {\n var _this = _super.call(this) || this;\n _this._source = source;\n return _this;\n }\n PipeTexture2.prototype.setSourceTexture = function(texture2) {\n this._source = texture2;\n };\n PipeTexture2.prototype.getWidth = function() {\n var _a, _b;\n return (_b = (_a = this.dw) !== null && _a !== void 0 ? _a : this.sw) !== null && _b !== void 0 ? _b : this._source.getWidth();\n };\n PipeTexture2.prototype.getHeight = function() {\n var _a, _b;\n return (_b = (_a = this.dh) !== null && _a !== void 0 ? _a : this.sh) !== null && _b !== void 0 ? _b : this._source.getHeight();\n };\n PipeTexture2.prototype.prerender = function(context) {\n return this._source.prerender(context);\n };\n PipeTexture2.prototype.drawWithNormalizedArgs = function(context, sx, sy, sw, sh, dx, dy, dw, dh) {\n var texture2 = this._source;\n if (texture2 === null || typeof texture2 !== \"object\") {\n return;\n }\n texture2.draw(context, sx, sy, sw, sh, dx, dy, dw, dh);\n };\n return PipeTexture2;\n }(Texture)\n);\nvar __extends$7 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar __awaiter$1 = function(thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function(resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function(resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator$1 = function(thisArg, body) {\n var _ = { label: 0, sent: function() {\n if (t[0] & 1)\n throw t[1];\n return t[1];\n }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() {\n return this;\n }), g;\n function verb(n) {\n return function(v) {\n return step([n, v]);\n };\n }\n function step(op) {\n if (f)\n throw new TypeError(\"Generator is already executing.\");\n while (_)\n try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)\n return t;\n if (y = 0, t)\n op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0:\n case 1:\n t = op;\n break;\n case 4:\n _.label++;\n return { value: op[1], done: false };\n case 5:\n _.label++;\n y = op[1];\n op = [0];\n continue;\n case 7:\n op = _.ops.pop();\n _.trys.pop();\n continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {\n _ = 0;\n continue;\n }\n if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {\n _.label = op[1];\n break;\n }\n if (op[0] === 6 && _.label < t[1]) {\n _.label = t[1];\n t = op;\n break;\n }\n if (t && _.label < t[2]) {\n _.label = t[2];\n _.ops.push(op);\n break;\n }\n if (t[2])\n _.ops.pop();\n _.trys.pop();\n continue;\n }\n op = body.call(thisArg, _);\n } catch (e) {\n op = [6, e];\n y = 0;\n } finally {\n f = t = 0;\n }\n if (op[0] & 5)\n throw op[1];\n return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar Atlas = (\n /** @class */\n function(_super) {\n __extends$7(Atlas2, _super);\n function Atlas2(def) {\n if (def === void 0) {\n def = {};\n }\n var _this = _super.call(this) || this;\n _this.pipeSpriteTexture = function(def2) {\n var map = _this._map;\n var ppu = _this._ppu;\n var trim = _this._trim;\n if (!def2) {\n return void 0;\n }\n def2 = Object.assign({}, def2);\n if (isFn(map)) {\n def2 = map(def2);\n }\n if (ppu != 1) {\n def2.x *= ppu;\n def2.y *= ppu;\n def2.width *= ppu;\n def2.height *= ppu;\n def2.top *= ppu;\n def2.bottom *= ppu;\n def2.left *= ppu;\n def2.right *= ppu;\n }\n if (trim != 0) {\n def2.x += trim;\n def2.y += trim;\n def2.width -= 2 * trim;\n def2.height -= 2 * trim;\n def2.top -= trim;\n def2.bottom -= trim;\n def2.left -= trim;\n def2.right -= trim;\n }\n var texture2 = new PipeTexture(_this);\n texture2.top = def2.top;\n texture2.bottom = def2.bottom;\n texture2.left = def2.left;\n texture2.right = def2.right;\n texture2.setSourceCoordinate(def2.x, def2.y);\n texture2.setSourceDimension(def2.width, def2.height);\n return texture2;\n };\n _this.findSpriteDefinition = function(query) {\n var textures = _this._textures;\n if (textures) {\n if (isFn(textures)) {\n return textures(query);\n } else if (isHash(textures)) {\n return textures[query];\n }\n }\n };\n _this.select = function(query) {\n if (!query) {\n return new TextureSelection(new PipeTexture(_this));\n }\n var textureDefinition = _this.findSpriteDefinition(query);\n if (textureDefinition) {\n return new TextureSelection(textureDefinition, _this);\n }\n };\n _this.name = def.name;\n _this._ppu = def.ppu || def.ratio || 1;\n _this._trim = def.trim || 0;\n _this._map = def.map || def.filter;\n _this._textures = def.textures;\n if (typeof def.image === \"object\" && isHash(def.image)) {\n _this._imageSrc = def.image.src || def.image.url;\n if (typeof def.image.ratio === \"number\") {\n _this._pixelRatio = def.image.ratio;\n }\n } else {\n if (typeof def.imagePath === \"string\") {\n _this._imageSrc = def.imagePath;\n } else if (typeof def.image === \"string\") {\n _this._imageSrc = def.image;\n }\n if (typeof def.imageRatio === \"number\") {\n _this._pixelRatio = def.imageRatio;\n }\n }\n deprecatedWarning(def);\n return _this;\n }\n Atlas2.prototype.load = function() {\n return __awaiter$1(this, void 0, void 0, function() {\n var image2;\n return __generator$1(this, function(_a) {\n switch (_a.label) {\n case 0:\n if (!this._imageSrc)\n return [3, 2];\n return [4, asyncLoadImage(this._imageSrc)];\n case 1:\n image2 = _a.sent();\n this.setSourceImage(image2, this._pixelRatio);\n _a.label = 2;\n case 2:\n return [\n 2\n /*return*/\n ];\n }\n });\n });\n };\n return Atlas2;\n }(ImageTexture)\n);\nfunction asyncLoadImage(src) {\n return new Promise(function(resolve, reject) {\n var img = new Image();\n img.onload = function() {\n resolve(img);\n };\n img.onerror = function(error) {\n console.error(\"Loading failed: \" + src);\n reject(error);\n };\n img.src = src;\n });\n}\nfunction deprecatedWarning(def) {\n if (\"filter\" in def)\n console.warn(\"'filter' field of atlas definition is deprecated\");\n if (\"cutouts\" in def)\n console.warn(\"'cutouts' field of atlas definition is deprecated\");\n if (\"sprites\" in def)\n console.warn(\"'sprites' field of atlas definition is deprecated\");\n if (\"factory\" in def)\n console.warn(\"'factory' field of atlas definition is deprecated\");\n if (\"ratio\" in def)\n console.warn(\"'ratio' field of atlas definition is deprecated\");\n if (\"imagePath\" in def)\n console.warn(\"'imagePath' field of atlas definition is deprecated\");\n if (\"imageRatio\" in def)\n console.warn(\"'imageRatio' field of atlas definition is deprecated\");\n if (typeof def.image === \"object\" && \"url\" in def.image)\n console.warn(\"'image.url' field of atlas definition is deprecated\");\n}\nvar __extends$6 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar __awaiter = function(thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function(resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function(resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = function(thisArg, body) {\n var _ = { label: 0, sent: function() {\n if (t[0] & 1)\n throw t[1];\n return t[1];\n }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() {\n return this;\n }), g;\n function verb(n) {\n return function(v) {\n return step([n, v]);\n };\n }\n function step(op) {\n if (f)\n throw new TypeError(\"Generator is already executing.\");\n while (_)\n try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)\n return t;\n if (y = 0, t)\n op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0:\n case 1:\n t = op;\n break;\n case 4:\n _.label++;\n return { value: op[1], done: false };\n case 5:\n _.label++;\n y = op[1];\n op = [0];\n continue;\n case 7:\n op = _.ops.pop();\n _.trys.pop();\n continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {\n _ = 0;\n continue;\n }\n if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {\n _.label = op[1];\n break;\n }\n if (op[0] === 6 && _.label < t[1]) {\n _.label = t[1];\n t = op;\n break;\n }\n if (t && _.label < t[2]) {\n _.label = t[2];\n _.ops.push(op);\n break;\n }\n if (t[2])\n _.ops.pop();\n _.trys.pop();\n continue;\n }\n op = body.call(thisArg, _);\n } catch (e) {\n op = [6, e];\n y = 0;\n } finally {\n f = t = 0;\n }\n if (op[0] & 5)\n throw op[1];\n return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nfunction isAtlasSpriteDefinition(selection) {\n return typeof selection === \"object\" && isHash(selection) && \"number\" === typeof selection.width && \"number\" === typeof selection.height;\n}\nvar TextureSelection = (\n /** @class */\n function() {\n function TextureSelection2(selection, atlas2) {\n this.selection = selection;\n this.atlas = atlas2;\n }\n TextureSelection2.prototype.resolve = function(selection, subquery) {\n if (!selection) {\n return NO_TEXTURE;\n } else if (Array.isArray(selection)) {\n return this.resolve(selection[0]);\n } else if (selection instanceof Texture) {\n return selection;\n } else if (isAtlasSpriteDefinition(selection)) {\n if (!this.atlas) {\n return NO_TEXTURE;\n }\n return this.atlas.pipeSpriteTexture(selection);\n } else if (typeof selection === \"object\" && isHash(selection) && typeof subquery !== \"undefined\") {\n return this.resolve(selection[subquery]);\n } else if (typeof selection === \"function\" && isFn(selection)) {\n return this.resolve(selection(subquery));\n } else if (typeof selection === \"string\") {\n if (!this.atlas) {\n return NO_TEXTURE;\n }\n return this.resolve(this.atlas.findSpriteDefinition(selection));\n }\n };\n TextureSelection2.prototype.one = function(subquery) {\n return this.resolve(this.selection, subquery);\n };\n TextureSelection2.prototype.array = function(arr) {\n var array = Array.isArray(arr) ? arr : [];\n if (Array.isArray(this.selection)) {\n for (var i = 0; i < this.selection.length; i++) {\n array[i] = this.resolve(this.selection[i]);\n }\n } else {\n array[0] = this.resolve(this.selection);\n }\n return array;\n };\n return TextureSelection2;\n }()\n);\nvar NO_TEXTURE = new /** @class */\n(function(_super) {\n __extends$6(class_1, _super);\n function class_1() {\n var _this = _super.call(this) || this;\n _this.setSourceDimension(0, 0);\n return _this;\n }\n class_1.prototype.getWidth = function() {\n return 0;\n };\n class_1.prototype.getHeight = function() {\n return 0;\n };\n class_1.prototype.prerender = function(context) {\n return false;\n };\n class_1.prototype.drawWithNormalizedArgs = function(context, sx, sy, sw, sh, dx, dy, dw, dh) {\n };\n class_1.prototype.setSourceCoordinate = function(x, y) {\n };\n class_1.prototype.setSourceDimension = function(w, h) {\n };\n class_1.prototype.setDestinationCoordinate = function(x, y) {\n };\n class_1.prototype.setDestinationDimension = function(w, h) {\n };\n class_1.prototype.draw = function() {\n };\n return class_1;\n}(Texture))();\nvar NO_SELECTION = new TextureSelection(NO_TEXTURE);\nvar ATLAS_MEMO_BY_NAME = {};\nvar ATLAS_ARRAY = [];\nfunction atlas(def) {\n return __awaiter(this, void 0, Promise, function() {\n var atlas2;\n return __generator(this, function(_a) {\n switch (_a.label) {\n case 0:\n if (def instanceof Atlas) {\n atlas2 = def;\n } else {\n atlas2 = new Atlas(def);\n }\n if (atlas2.name) {\n ATLAS_MEMO_BY_NAME[atlas2.name] = atlas2;\n }\n ATLAS_ARRAY.push(atlas2);\n return [4, atlas2.load()];\n case 1:\n _a.sent();\n return [2, atlas2];\n }\n });\n });\n}\nfunction texture(query) {\n if (\"string\" !== typeof query) {\n return new TextureSelection(query);\n }\n var result = null;\n var colonIndex = query.indexOf(\":\");\n if (colonIndex > 0 && query.length > colonIndex + 1) {\n var atlas_1 = ATLAS_MEMO_BY_NAME[query.slice(0, colonIndex)];\n result = atlas_1 && atlas_1.select(query.slice(colonIndex + 1));\n }\n if (!result) {\n var atlas_2 = ATLAS_MEMO_BY_NAME[query];\n result = atlas_2 && atlas_2.select();\n }\n if (!result) {\n for (var i = 0; i < ATLAS_ARRAY.length; i++) {\n result = ATLAS_ARRAY[i].select(query);\n if (result) {\n break;\n }\n }\n }\n if (!result) {\n console.error(\"Texture not found: \" + query);\n result = NO_SELECTION;\n }\n return result;\n}\nvar __extends$5 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar ResizableTexture = (\n /** @class */\n function(_super) {\n __extends$5(ResizableTexture2, _super);\n function ResizableTexture2(source, mode) {\n var _this = _super.call(this) || this;\n _this._source = source;\n _this._resizeMode = mode;\n return _this;\n }\n ResizableTexture2.prototype.getWidth = function() {\n var _a;\n return (_a = this.dw) !== null && _a !== void 0 ? _a : this._source.getWidth();\n };\n ResizableTexture2.prototype.getHeight = function() {\n var _a;\n return (_a = this.dh) !== null && _a !== void 0 ? _a : this._source.getHeight();\n };\n ResizableTexture2.prototype.prerender = function(context) {\n return false;\n };\n ResizableTexture2.prototype.drawWithNormalizedArgs = function(context, sx, sy, sw, sh, dx, dy, dw, dh) {\n var texture2 = this._source;\n if (texture2 === null || typeof texture2 !== \"object\") {\n return;\n }\n var outWidth = dw;\n var outHeight = dh;\n var left = Number.isFinite(texture2.left) ? texture2.left : 0;\n var right = Number.isFinite(texture2.right) ? texture2.right : 0;\n var top = Number.isFinite(texture2.top) ? texture2.top : 0;\n var bottom = Number.isFinite(texture2.bottom) ? texture2.bottom : 0;\n var width = texture2.getWidth() - left - right;\n var height = texture2.getHeight() - top - bottom;\n if (!this._innerSize) {\n outWidth = Math.max(outWidth - left - right, 0);\n outHeight = Math.max(outHeight - top - bottom, 0);\n }\n if (top > 0 && left > 0) {\n texture2.draw(context, 0, 0, left, top, 0, 0, left, top);\n }\n if (bottom > 0 && left > 0) {\n texture2.draw(context, 0, height + top, left, bottom, 0, outHeight + top, left, bottom);\n }\n if (top > 0 && right > 0) {\n texture2.draw(context, width + left, 0, right, top, outWidth + left, 0, right, top);\n }\n if (bottom > 0 && right > 0) {\n texture2.draw(context, width + left, height + top, right, bottom, outWidth + left, outHeight + top, right, bottom);\n }\n if (this._resizeMode === \"stretch\") {\n if (top > 0) {\n texture2.draw(context, left, 0, width, top, left, 0, outWidth, top);\n }\n if (bottom > 0) {\n texture2.draw(context, left, height + top, width, bottom, left, outHeight + top, outWidth, bottom);\n }\n if (left > 0) {\n texture2.draw(context, 0, top, left, height, 0, top, left, outHeight);\n }\n if (right > 0) {\n texture2.draw(context, width + left, top, right, height, outWidth + left, top, right, outHeight);\n }\n texture2.draw(context, left, top, width, height, left, top, outWidth, outHeight);\n } else if (this._resizeMode === \"tile\") {\n var l = left;\n var r = outWidth;\n var w = void 0;\n while (r > 0) {\n w = Math.min(width, r);\n r -= width;\n var t = top;\n var b = outHeight;\n var h = void 0;\n while (b > 0) {\n h = Math.min(height, b);\n b -= height;\n texture2.draw(context, left, top, w, h, l, t, w, h);\n if (r <= 0) {\n if (left) {\n texture2.draw(context, 0, top, left, h, 0, t, left, h);\n }\n if (right) {\n texture2.draw(context, width + left, top, right, h, l + w, t, right, h);\n }\n }\n t += h;\n }\n if (top) {\n texture2.draw(context, left, 0, w, top, l, 0, w, top);\n }\n if (bottom) {\n texture2.draw(context, left, height + top, w, bottom, l, t, w, bottom);\n }\n l += w;\n }\n }\n };\n return ResizableTexture2;\n }(Texture)\n);\nfunction getPixelRatio() {\n return typeof window !== \"undefined\" ? window.devicePixelRatio || 1 : 1;\n}\nfunction isValidFitMode(value) {\n return value && (value === \"cover\" || value === \"contain\" || value === \"fill\" || value === \"in\" || value === \"in-pad\" || value === \"out\" || value === \"out-crop\");\n}\nvar iid$1 = 0;\nvar Pin = (\n /** @class */\n function() {\n function Pin2(owner) {\n this.uid = \"pin:\" + uid();\n this._owner = owner;\n this._parent = null;\n this._relativeMatrix = new Matrix();\n this._absoluteMatrix = new Matrix();\n this.reset();\n }\n Pin2.prototype.reset = function() {\n this._textureAlpha = 1;\n this._alpha = 1;\n this._width = 0;\n this._height = 0;\n this._scaleX = 1;\n this._scaleY = 1;\n this._skewX = 0;\n this._skewY = 0;\n this._rotation = 0;\n this._pivoted = false;\n this._pivotX = 0;\n this._pivotY = 0;\n this._handled = false;\n this._handleX = 0;\n this._handleY = 0;\n this._aligned = false;\n this._alignX = 0;\n this._alignY = 0;\n this._offsetX = 0;\n this._offsetY = 0;\n this._boxX = 0;\n this._boxY = 0;\n this._boxWidth = this._width;\n this._boxHeight = this._height;\n this._ts_translate = ++iid$1;\n this._ts_transform = ++iid$1;\n this._ts_matrix = ++iid$1;\n };\n Pin2.prototype._update = function() {\n this._parent = this._owner._parent && this._owner._parent._pin;\n if (this._handled && this._mo_handle != this._ts_transform) {\n this._mo_handle = this._ts_transform;\n this._ts_translate = ++iid$1;\n }\n if (this._aligned && this._parent && this._mo_align != this._parent._ts_transform) {\n this._mo_align = this._parent._ts_transform;\n this._ts_translate = ++iid$1;\n }\n return this;\n };\n Pin2.prototype.toString = function() {\n return this._owner + \" (\" + (this._parent ? this._parent._owner : null) + \")\";\n };\n Pin2.prototype.absoluteMatrix = function() {\n this._update();\n var ts = Math.max(this._ts_transform, this._ts_translate, this._parent ? this._parent._ts_matrix : 0);\n if (this._mo_abs == ts) {\n return this._absoluteMatrix;\n }\n this._mo_abs = ts;\n var abs = this._absoluteMatrix;\n abs.reset(this.relativeMatrix());\n this._parent && abs.concat(this._parent._absoluteMatrix);\n this._ts_matrix = ++iid$1;\n return abs;\n };\n Pin2.prototype.relativeMatrix = function() {\n this._update();\n var ts = Math.max(this._ts_transform, this._ts_translate, this._parent ? this._parent._ts_transform : 0);\n if (this._mo_rel == ts) {\n return this._relativeMatrix;\n }\n this._mo_rel = ts;\n var rel = this._relativeMatrix;\n rel.identity();\n if (this._pivoted) {\n rel.translate(-this._pivotX * this._width, -this._pivotY * this._height);\n }\n rel.scale(this._scaleX, this._scaleY);\n rel.skew(this._skewX, this._skewY);\n rel.rotate(this._rotation);\n if (this._pivoted) {\n rel.translate(this._pivotX * this._width, this._pivotY * this._height);\n }\n if (this._pivoted) {\n this._boxX = 0;\n this._boxY = 0;\n this._boxWidth = this._width;\n this._boxHeight = this._height;\n } else {\n var p = void 0;\n var q = void 0;\n if (rel.a > 0 && rel.c > 0 || rel.a < 0 && rel.c < 0) {\n p = 0;\n q = rel.a * this._width + rel.c * this._height;\n } else {\n p = rel.a * this._width;\n q = rel.c * this._height;\n }\n if (p > q) {\n this._boxX = q;\n this._boxWidth = p - q;\n } else {\n this._boxX = p;\n this._boxWidth = q - p;\n }\n if (rel.b > 0 && rel.d > 0 || rel.b < 0 && rel.d < 0) {\n p = 0;\n q = rel.b * this._width + rel.d * this._height;\n } else {\n p = rel.b * this._width;\n q = rel.d * this._height;\n }\n if (p > q) {\n this._boxY = q;\n this._boxHeight = p - q;\n } else {\n this._boxY = p;\n this._boxHeight = q - p;\n }\n }\n this._x = this._offsetX;\n this._y = this._offsetY;\n this._x -= this._boxX + this._handleX * this._boxWidth;\n this._y -= this._boxY + this._handleY * this._boxHeight;\n if (this._aligned && this._parent) {\n this._parent.relativeMatrix();\n this._x += this._alignX * this._parent._width;\n this._y += this._alignY * this._parent._height;\n }\n rel.translate(this._x, this._y);\n return this._relativeMatrix;\n };\n Pin2.prototype.get = function(key) {\n if (typeof getters[key] === \"function\") {\n return getters[key](this);\n }\n };\n Pin2.prototype.set = function(a, b) {\n if (typeof a === \"string\") {\n if (typeof setters[a] === \"function\" && typeof b !== \"undefined\") {\n setters[a](this, b);\n }\n } else if (typeof a === \"object\") {\n for (b in a) {\n if (typeof setters[b] === \"function\" && typeof a[b] !== \"undefined\") {\n setters[b](this, a[b], a);\n }\n }\n }\n if (this._owner) {\n this._owner._ts_pin = ++iid$1;\n this._owner.touch();\n }\n return this;\n };\n Pin2.prototype.fit = function(width, height, mode) {\n this._ts_transform = ++iid$1;\n if (mode === \"contain\") {\n mode = \"in-pad\";\n }\n if (mode === \"cover\") {\n mode = \"out-crop\";\n }\n if (typeof width === \"number\") {\n this._scaleX = width / this._unscaled_width;\n this._width = this._unscaled_width;\n }\n if (typeof height === \"number\") {\n this._scaleY = height / this._unscaled_height;\n this._height = this._unscaled_height;\n }\n if (typeof width === \"number\" && typeof height === \"number\" && typeof mode === \"string\") {\n if (mode === \"fill\")\n ;\n else if (mode === \"out\" || mode === \"out-crop\") {\n this._scaleX = this._scaleY = Math.max(this._scaleX, this._scaleY);\n } else if (mode === \"in\" || mode === \"in-pad\") {\n this._scaleX = this._scaleY = Math.min(this._scaleX, this._scaleY);\n }\n if (mode === \"out-crop\" || mode === \"in-pad\") {\n this._width = width / this._scaleX;\n this._height = height / this._scaleY;\n }\n }\n };\n return Pin2;\n }()\n);\nvar getters = {\n alpha: function(pin) {\n return pin._alpha;\n },\n textureAlpha: function(pin) {\n return pin._textureAlpha;\n },\n width: function(pin) {\n return pin._width;\n },\n height: function(pin) {\n return pin._height;\n },\n boxWidth: function(pin) {\n return pin._boxWidth;\n },\n boxHeight: function(pin) {\n return pin._boxHeight;\n },\n // scale : function(pin: Pin) {\n // },\n scaleX: function(pin) {\n return pin._scaleX;\n },\n scaleY: function(pin) {\n return pin._scaleY;\n },\n // skew : function(pin: Pin) {\n // },\n skewX: function(pin) {\n return pin._skewX;\n },\n skewY: function(pin) {\n return pin._skewY;\n },\n rotation: function(pin) {\n return pin._rotation;\n },\n // pivot : function(pin: Pin) {\n // },\n pivotX: function(pin) {\n return pin._pivotX;\n },\n pivotY: function(pin) {\n return pin._pivotY;\n },\n // offset : function(pin: Pin) {\n // },\n offsetX: function(pin) {\n return pin._offsetX;\n },\n offsetY: function(pin) {\n return pin._offsetY;\n },\n // align : function(pin: Pin) {\n // },\n alignX: function(pin) {\n return pin._alignX;\n },\n alignY: function(pin) {\n return pin._alignY;\n },\n // handle : function(pin: Pin) {\n // },\n handleX: function(pin) {\n return pin._handleX;\n },\n handleY: function(pin) {\n return pin._handleY;\n }\n};\nvar setters = {\n alpha: function(pin, value) {\n pin._alpha = value;\n },\n textureAlpha: function(pin, value) {\n pin._textureAlpha = value;\n },\n width: function(pin, value) {\n pin._unscaled_width = value;\n pin._width = value;\n pin._ts_transform = ++iid$1;\n },\n height: function(pin, value) {\n pin._unscaled_height = value;\n pin._height = value;\n pin._ts_transform = ++iid$1;\n },\n scale: function(pin, value) {\n pin._scaleX = value;\n pin._scaleY = value;\n pin._ts_transform = ++iid$1;\n },\n scaleX: function(pin, value) {\n pin._scaleX = value;\n pin._ts_transform = ++iid$1;\n },\n scaleY: function(pin, value) {\n pin._scaleY = value;\n pin._ts_transform = ++iid$1;\n },\n skew: function(pin, value) {\n pin._skewX = value;\n pin._skewY = value;\n pin._ts_transform = ++iid$1;\n },\n skewX: function(pin, value) {\n pin._skewX = value;\n pin._ts_transform = ++iid$1;\n },\n skewY: function(pin, value) {\n pin._skewY = value;\n pin._ts_transform = ++iid$1;\n },\n rotation: function(pin, value) {\n pin._rotation = value;\n pin._ts_transform = ++iid$1;\n },\n pivot: function(pin, value) {\n pin._pivotX = value;\n pin._pivotY = value;\n pin._pivoted = true;\n pin._ts_transform = ++iid$1;\n },\n pivotX: function(pin, value) {\n pin._pivotX = value;\n pin._pivoted = true;\n pin._ts_transform = ++iid$1;\n },\n pivotY: function(pin, value) {\n pin._pivotY = value;\n pin._pivoted = true;\n pin._ts_transform = ++iid$1;\n },\n offset: function(pin, value) {\n pin._offsetX = value;\n pin._offsetY = value;\n pin._ts_translate = ++iid$1;\n },\n offsetX: function(pin, value) {\n pin._offsetX = value;\n pin._ts_translate = ++iid$1;\n },\n offsetY: function(pin, value) {\n pin._offsetY = value;\n pin._ts_translate = ++iid$1;\n },\n align: function(pin, value) {\n this.alignX(pin, value);\n this.alignY(pin, value);\n },\n alignX: function(pin, value) {\n pin._alignX = value;\n pin._aligned = true;\n pin._ts_translate = ++iid$1;\n this.handleX(pin, value);\n },\n alignY: function(pin, value) {\n pin._alignY = value;\n pin._aligned = true;\n pin._ts_translate = ++iid$1;\n this.handleY(pin, value);\n },\n handle: function(pin, value) {\n this.handleX(pin, value);\n this.handleY(pin, value);\n },\n handleX: function(pin, value) {\n pin._handleX = value;\n pin._handled = true;\n pin._ts_translate = ++iid$1;\n },\n handleY: function(pin, value) {\n pin._handleY = value;\n pin._handled = true;\n pin._ts_translate = ++iid$1;\n },\n resizeMode: function(pin, value, all) {\n if (all) {\n if (value == \"in\") {\n value = \"in-pad\";\n } else if (value == \"out\") {\n value = \"out-crop\";\n }\n pin.fit(all.resizeWidth, all.resizeHeight, value);\n }\n },\n resizeWidth: function(pin, value, all) {\n if (!all || !all.resizeMode) {\n pin.fit(value, null);\n }\n },\n resizeHeight: function(pin, value, all) {\n if (!all || !all.resizeMode) {\n pin.fit(null, value);\n }\n },\n scaleMode: function(pin, value, all) {\n if (all) {\n pin.fit(all.scaleWidth, all.scaleHeight, value);\n }\n },\n scaleWidth: function(pin, value, all) {\n if (!all || !all.scaleMode) {\n pin.fit(value, null);\n }\n },\n scaleHeight: function(pin, value, all) {\n if (!all || !all.scaleMode) {\n pin.fit(null, value);\n }\n },\n matrix: function(pin, value) {\n this.scaleX(pin, value.a);\n this.skewX(pin, value.c / value.d);\n this.skewY(pin, value.b / value.a);\n this.scaleY(pin, value.d);\n this.offsetX(pin, value.e);\n this.offsetY(pin, value.f);\n this.rotation(pin, 0);\n }\n};\nfunction IDENTITY(x) {\n return x;\n}\nvar LOOKUP_CACHE = {};\nvar MODE_BY_NAME = {};\nvar EASE_BY_NAME = {};\nvar Easing = (\n /** @class */\n function() {\n function Easing2() {\n }\n Easing2.get = function(token, fallback) {\n fallback = fallback || IDENTITY;\n if (typeof token === \"function\") {\n return token;\n }\n if (typeof token !== \"string\") {\n return fallback;\n }\n var easeFn = LOOKUP_CACHE[token];\n if (easeFn) {\n return easeFn;\n }\n var tokens = /^(\\w+)(-(in|out|in-out|out-in))?(\\((.*)\\))?$/i.exec(token);\n if (!tokens || !tokens.length) {\n return fallback;\n }\n var easeName = tokens[1];\n var easing = EASE_BY_NAME[easeName];\n var modeName = tokens[3];\n var modeFn = MODE_BY_NAME[modeName];\n var params = tokens[5];\n if (!easing) {\n easeFn = fallback;\n } else if (\"fn\" in easing && typeof easing.fn === \"function\") {\n easeFn = easing.fn;\n } else if (\"fc\" in easing && typeof easing.fc === \"function\") {\n var args = params ? params.replace(/\\s+/, \"\").split(\",\") : void 0;\n easeFn = easing.fc.apply(easing.fc, args);\n } else {\n easeFn = fallback;\n }\n if (modeFn) {\n easeFn = modeFn(easeFn);\n }\n LOOKUP_CACHE[token] = easeFn;\n return easeFn;\n };\n return Easing2;\n }()\n);\nfunction addMode(name, fn) {\n MODE_BY_NAME[name] = fn;\n}\nfunction addEaseFn(data) {\n var names = data.name.split(/\\s+/);\n for (var i = 0; i < names.length; i++) {\n var key = names[i];\n if (key) {\n EASE_BY_NAME[key] = data;\n }\n }\n}\naddMode(\"in\", function(f) {\n return f;\n});\naddMode(\"out\", function(f) {\n return function(t) {\n return 1 - f(1 - t);\n };\n});\naddMode(\"in-out\", function(f) {\n return function(t) {\n return t < 0.5 ? f(2 * t) / 2 : 1 - f(2 * (1 - t)) / 2;\n };\n});\naddMode(\"out-in\", function(f) {\n return function(t) {\n return t < 0.5 ? 1 - f(2 * (1 - t)) / 2 : f(2 * t) / 2;\n };\n});\naddEaseFn({\n name: \"linear\",\n fn: function(t) {\n return t;\n }\n});\naddEaseFn({\n name: \"quad\",\n fn: function(t) {\n return t * t;\n }\n});\naddEaseFn({\n name: \"cubic\",\n fn: function(t) {\n return t * t * t;\n }\n});\naddEaseFn({\n name: \"quart\",\n fn: function(t) {\n return t * t * t * t;\n }\n});\naddEaseFn({\n name: \"quint\",\n fn: function(t) {\n return t * t * t * t * t;\n }\n});\naddEaseFn({\n name: \"sin sine\",\n fn: function(t) {\n return 1 - Math.cos(t * Math.PI / 2);\n }\n});\naddEaseFn({\n name: \"exp expo\",\n fn: function(t) {\n return t == 0 ? 0 : Math.pow(2, 10 * (t - 1));\n }\n});\naddEaseFn({\n name: \"circle circ\",\n fn: function(t) {\n return 1 - Math.sqrt(1 - t * t);\n }\n});\naddEaseFn({\n name: \"bounce\",\n fn: function(t) {\n return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + 0.75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + 0.9375 : 7.5625 * (t -= 2.625 / 2.75) * t + 0.984375;\n }\n});\naddEaseFn({\n name: \"poly\",\n fc: function(e) {\n return function(t) {\n return Math.pow(t, e);\n };\n }\n});\naddEaseFn({\n name: \"elastic\",\n fc: function(a, p) {\n p = p || 0.45;\n a = a || 1;\n var s = p / (2 * Math.PI) * Math.asin(1 / a);\n return function(t) {\n return 1 + a * Math.pow(2, -10 * t) * Math.sin((t - s) * (2 * Math.PI) / p);\n };\n }\n});\naddEaseFn({\n name: \"back\",\n fc: function(s) {\n s = typeof s !== \"undefined\" ? s : 1.70158;\n return function(t) {\n return t * t * ((s + 1) * t - s);\n };\n }\n});\nvar Transition = (\n /** @class */\n function() {\n function Transition2(owner, options) {\n if (options === void 0) {\n options = {};\n }\n this.uid = \"transition:\" + uid();\n this._ending = [];\n this._end = {};\n this._duration = options.duration || 400;\n this._delay = options.delay || 0;\n this._owner = owner;\n this._time = 0;\n }\n Transition2.prototype.tick = function(node, elapsed, now, last) {\n this._time += elapsed;\n if (this._time < this._delay) {\n return;\n }\n var time = this._time - this._delay;\n if (!this._start) {\n this._start = {};\n for (var key in this._end) {\n this._start[key] = this._owner.pin(key);\n }\n }\n var p = Math.min(time / this._duration, 1);\n var ended = p >= 1;\n if (typeof this._easing == \"function\") {\n p = this._easing(p);\n }\n var q = 1 - p;\n for (var key in this._end) {\n this._owner.pin(key, this._start[key] * q + this._end[key] * p);\n }\n return ended;\n };\n Transition2.prototype.finish = function() {\n var _this = this;\n this._ending.forEach(function(callback) {\n try {\n callback.call(_this._owner);\n } catch (e) {\n console.error(e);\n }\n });\n return this._next;\n };\n Transition2.prototype.tween = function(a, b) {\n var options;\n if (typeof a === \"object\" && a !== null) {\n options = a;\n } else {\n options = {};\n if (typeof a === \"number\") {\n options.duration = a;\n if (typeof b === \"number\") {\n options.delay = b;\n }\n }\n }\n return this._next = new Transition2(this._owner, options);\n };\n Transition2.prototype.duration = function(duration) {\n this._duration = duration;\n return this;\n };\n Transition2.prototype.delay = function(delay) {\n this._delay = delay;\n return this;\n };\n Transition2.prototype.ease = function(easing) {\n this._easing = Easing.get(easing);\n return this;\n };\n Transition2.prototype.done = function(fn) {\n this._ending.push(fn);\n return this;\n };\n Transition2.prototype.hide = function() {\n this._ending.push(function() {\n this.hide();\n });\n this._hide = true;\n return this;\n };\n Transition2.prototype.remove = function() {\n this._ending.push(function() {\n this.remove();\n });\n this._remove = true;\n return this;\n };\n Transition2.prototype.pin = function(a, b) {\n if (typeof a === \"object\") {\n for (var attr in a) {\n pinning(this._owner, this._end, attr, a[attr]);\n }\n } else if (typeof b !== \"undefined\") {\n pinning(this._owner, this._end, a, b);\n }\n return this;\n };\n Transition2.prototype.then = function(fn) {\n this.done(fn);\n return this;\n };\n Transition2.prototype.clear = function(forward) {\n return this;\n };\n Transition2.prototype.size = function(w, h) {\n this.pin(\"width\", w);\n this.pin(\"height\", h);\n return this;\n };\n Transition2.prototype.width = function(w) {\n if (typeof w === \"undefined\") {\n return this.pin(\"width\");\n }\n this.pin(\"width\", w);\n return this;\n };\n Transition2.prototype.height = function(h) {\n if (typeof h === \"undefined\") {\n return this.pin(\"height\");\n }\n this.pin(\"height\", h);\n return this;\n };\n Transition2.prototype.offset = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n }\n this.pin(\"offsetX\", a);\n this.pin(\"offsetY\", b);\n return this;\n };\n Transition2.prototype.rotate = function(a) {\n this.pin(\"rotation\", a);\n return this;\n };\n Transition2.prototype.skew = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n } else if (typeof b === \"undefined\") {\n b = a;\n }\n this.pin(\"skewX\", a);\n this.pin(\"skewY\", b);\n return this;\n };\n Transition2.prototype.scale = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n } else if (typeof b === \"undefined\") {\n b = a;\n }\n this.pin(\"scaleX\", a);\n this.pin(\"scaleY\", b);\n return this;\n };\n Transition2.prototype.alpha = function(a, ta) {\n this.pin(\"alpha\", a);\n if (typeof ta !== \"undefined\") {\n this.pin(\"textureAlpha\", ta);\n }\n return this;\n };\n return Transition2;\n }()\n);\nfunction pinning(node, map, key, value) {\n if (typeof node.pin(key) === \"number\") {\n map[key] = value;\n } else if (typeof node.pin(key + \"X\") === \"number\" && typeof node.pin(key + \"Y\") === \"number\") {\n map[key + \"X\"] = value;\n map[key + \"Y\"] = value;\n }\n}\nvar iid = 0;\nstats.create = 0;\nfunction assertType(obj) {\n if (obj && obj instanceof Node) {\n return obj;\n }\n throw \"Invalid node: \" + obj;\n}\nfunction create() {\n return layout();\n}\nfunction layer() {\n return maximize();\n}\nfunction box() {\n return minimize();\n}\nfunction layout() {\n return new Node();\n}\nfunction row(align) {\n return layout().row(align).label(\"Row\");\n}\nfunction column(align) {\n return layout().column(align).label(\"Column\");\n}\nfunction minimize() {\n return layout().minimize().label(\"Minimize\");\n}\nfunction maximize() {\n return layout().maximize().label(\"Maximize\");\n}\nvar Node = (\n /** @class */\n function() {\n function Node2() {\n var _this = this;\n this.uid = \"node:\" + uid();\n this._label = \"\";\n this._parent = null;\n this._next = null;\n this._prev = null;\n this._first = null;\n this._last = null;\n this._visible = true;\n this._alpha = 1;\n this._padding = 0;\n this._spacing = 0;\n this._pin = new Pin(this);\n this._listeners = {};\n this._attrs = {};\n this._flags = {};\n this._transitions = [];\n this._tickBefore = [];\n this._tickAfter = [];\n this.MAX_ELAPSE = Infinity;\n this._transitionTickInitied = false;\n this._transitionTickLastTime = 0;\n this._transitionTick = function(elapsed, now, last) {\n if (!_this._transitions.length) {\n return false;\n }\n var ignore = _this._transitionTickLastTime !== last;\n _this._transitionTickLastTime = now;\n if (ignore) {\n return true;\n }\n var head = _this._transitions[0];\n var ended = head.tick(_this, elapsed, now, last);\n if (ended) {\n if (head === _this._transitions[0]) {\n _this._transitions.shift();\n }\n var next = head.finish();\n if (next) {\n _this._transitions.unshift(next);\n }\n }\n return true;\n };\n stats.create++;\n }\n Node2.prototype.matrix = function(relative) {\n if (relative === void 0) {\n relative = false;\n }\n if (relative === true) {\n return this._pin.relativeMatrix();\n }\n return this._pin.absoluteMatrix();\n };\n Node2.prototype.getPixelRatio = function() {\n var _a;\n var m = (_a = this._parent) === null || _a === void 0 ? void 0 : _a.matrix();\n var pixelRatio = !m ? 1 : Math.max(Math.abs(m.a), Math.abs(m.b)) / getPixelRatio();\n return pixelRatio;\n };\n Node2.prototype.pin = function(a, b) {\n if (typeof a === \"object\") {\n this._pin.set(a);\n return this;\n } else if (typeof a === \"string\") {\n if (typeof b === \"undefined\") {\n return this._pin.get(a);\n } else {\n this._pin.set(a, b);\n return this;\n }\n } else if (typeof a === \"undefined\") {\n return this._pin;\n }\n };\n Node2.prototype.fit = function(a, b, c) {\n if (typeof a === \"object\") {\n c = b;\n b = a.y;\n a = a.x;\n }\n this._pin.fit(a, b, c);\n return this;\n };\n Node2.prototype.scaleTo = function(a, b, c) {\n return this.fit(a, b, c);\n };\n Node2.prototype.toString = function() {\n return \"[\" + this._label + \"]\";\n };\n Node2.prototype.id = function(id) {\n return this.label(id);\n };\n Node2.prototype.label = function(label) {\n if (typeof label === \"undefined\") {\n return this._label;\n }\n this._label = label;\n return this;\n };\n Node2.prototype.attr = function(name, value) {\n if (typeof value === \"undefined\") {\n return this._attrs !== null ? this._attrs[name] : void 0;\n }\n (this._attrs !== null ? this._attrs : this._attrs = {})[name] = value;\n return this;\n };\n Node2.prototype.visible = function(visible) {\n if (typeof visible === \"undefined\") {\n return this._visible;\n }\n this._visible = visible;\n this._parent && (this._parent._ts_children = ++iid);\n this._ts_pin = ++iid;\n this.touch();\n return this;\n };\n Node2.prototype.hide = function() {\n this.visible(false);\n return this;\n };\n Node2.prototype.show = function() {\n this.visible(true);\n return this;\n };\n Node2.prototype.parent = function() {\n return this._parent;\n };\n Node2.prototype.next = function(visible) {\n var next = this._next;\n while (next && visible && !next._visible) {\n next = next._next;\n }\n return next;\n };\n Node2.prototype.prev = function(visible) {\n var prev = this._prev;\n while (prev && visible && !prev._visible) {\n prev = prev._prev;\n }\n return prev;\n };\n Node2.prototype.first = function(visible) {\n var next = this._first;\n while (next && visible && !next._visible) {\n next = next._next;\n }\n return next;\n };\n Node2.prototype.last = function(visible) {\n var prev = this._last;\n while (prev && visible && !prev._visible) {\n prev = prev._prev;\n }\n return prev;\n };\n Node2.prototype.visit = function(visitor, payload) {\n var reverse = visitor.reverse;\n var visible = visitor.visible;\n if (visitor.start && visitor.start(this, payload)) {\n return;\n }\n var child;\n var next = reverse ? this.last(visible) : this.first(visible);\n while (child = next) {\n next = reverse ? child.prev(visible) : child.next(visible);\n if (child.visit(visitor, payload)) {\n return true;\n }\n }\n return visitor.end && visitor.end(this, payload);\n };\n Node2.prototype.append = function(child, more) {\n if (Array.isArray(child)) {\n for (var i = 0; i < child.length; i++) {\n Node2.append(this, child[i]);\n }\n } else if (typeof more !== \"undefined\") {\n for (var i = 0; i < arguments.length; i++) {\n Node2.append(this, arguments[i]);\n }\n } else if (typeof child !== \"undefined\")\n Node2.append(this, child);\n return this;\n };\n Node2.prototype.prepend = function(child, more) {\n if (Array.isArray(child)) {\n for (var i = child.length - 1; i >= 0; i--) {\n Node2.prepend(this, child[i]);\n }\n } else if (typeof more !== \"undefined\") {\n for (var i = arguments.length - 1; i >= 0; i--) {\n Node2.prepend(this, arguments[i]);\n }\n } else if (typeof child !== \"undefined\")\n Node2.prepend(this, child);\n return this;\n };\n Node2.prototype.appendTo = function(parent) {\n Node2.append(parent, this);\n return this;\n };\n Node2.prototype.prependTo = function(parent) {\n Node2.prepend(parent, this);\n return this;\n };\n Node2.prototype.insertNext = function(sibling, more) {\n if (Array.isArray(sibling)) {\n for (var i = 0; i < sibling.length; i++) {\n Node2.insertAfter(sibling[i], this);\n }\n } else if (typeof more !== \"undefined\") {\n for (var i = 0; i < arguments.length; i++) {\n Node2.insertAfter(arguments[i], this);\n }\n } else if (typeof sibling !== \"undefined\") {\n Node2.insertAfter(sibling, this);\n }\n return this;\n };\n Node2.prototype.insertPrev = function(sibling, more) {\n if (Array.isArray(sibling)) {\n for (var i = sibling.length - 1; i >= 0; i--) {\n Node2.insertBefore(sibling[i], this);\n }\n } else if (typeof more !== \"undefined\") {\n for (var i = arguments.length - 1; i >= 0; i--) {\n Node2.insertBefore(arguments[i], this);\n }\n } else if (typeof sibling !== \"undefined\") {\n Node2.insertBefore(sibling, this);\n }\n return this;\n };\n Node2.prototype.insertAfter = function(prev) {\n Node2.insertAfter(this, prev);\n return this;\n };\n Node2.prototype.insertBefore = function(next) {\n Node2.insertBefore(this, next);\n return this;\n };\n Node2.append = function(parent, child) {\n assertType(child);\n assertType(parent);\n child.remove();\n if (parent._last) {\n parent._last._next = child;\n child._prev = parent._last;\n }\n child._parent = parent;\n parent._last = child;\n if (!parent._first) {\n parent._first = child;\n }\n child._parent._flag(child, true);\n child._ts_parent = ++iid;\n parent._ts_children = ++iid;\n parent.touch();\n };\n Node2.prepend = function(parent, child) {\n assertType(child);\n assertType(parent);\n child.remove();\n if (parent._first) {\n parent._first._prev = child;\n child._next = parent._first;\n }\n child._parent = parent;\n parent._first = child;\n if (!parent._last) {\n parent._last = child;\n }\n child._parent._flag(child, true);\n child._ts_parent = ++iid;\n parent._ts_children = ++iid;\n parent.touch();\n };\n Node2.insertBefore = function(self, next) {\n assertType(self);\n assertType(next);\n self.remove();\n var parent = next._parent;\n var prev = next._prev;\n if (!parent) {\n return;\n }\n next._prev = self;\n prev && (prev._next = self) || parent && (parent._first = self);\n self._parent = parent;\n self._prev = prev;\n self._next = next;\n self._parent._flag(self, true);\n self._ts_parent = ++iid;\n self.touch();\n };\n Node2.insertAfter = function(self, prev) {\n assertType(self);\n assertType(prev);\n self.remove();\n var parent = prev._parent;\n var next = prev._next;\n if (!parent) {\n return;\n }\n prev._next = self;\n next && (next._prev = self) || parent && (parent._last = self);\n self._parent = parent;\n self._prev = prev;\n self._next = next;\n self._parent._flag(self, true);\n self._ts_parent = ++iid;\n self.touch();\n };\n Node2.prototype.remove = function(child, more) {\n if (typeof child !== \"undefined\") {\n if (Array.isArray(child)) {\n for (var i = 0; i < child.length; i++) {\n assertType(child[i]).remove();\n }\n } else if (typeof more !== \"undefined\") {\n for (var i = 0; i < arguments.length; i++) {\n assertType(arguments[i]).remove();\n }\n } else {\n assertType(child).remove();\n }\n return this;\n }\n if (this._prev) {\n this._prev._next = this._next;\n }\n if (this._next) {\n this._next._prev = this._prev;\n }\n if (this._parent) {\n if (this._parent._first === this) {\n this._parent._first = this._next;\n }\n if (this._parent._last === this) {\n this._parent._last = this._prev;\n }\n this._parent._flag(this, false);\n this._parent._ts_children = ++iid;\n this._parent.touch();\n }\n this._prev = this._next = this._parent = null;\n this._ts_parent = ++iid;\n return this;\n };\n Node2.prototype.empty = function() {\n var child = null;\n var next = this._first;\n while (child = next) {\n next = child._next;\n child._prev = child._next = child._parent = null;\n this._flag(child, false);\n }\n this._first = this._last = null;\n this._ts_children = ++iid;\n this.touch();\n return this;\n };\n Node2.prototype.touch = function() {\n this._ts_touch = ++iid;\n this._parent && this._parent.touch();\n return this;\n };\n Node2.prototype._flag = function(key, value) {\n if (typeof value === \"undefined\") {\n return this._flags !== null && this._flags[key] || 0;\n }\n if (typeof key === \"string\") {\n if (value) {\n this._flags = this._flags || {};\n if (!this._flags[key] && this._parent) {\n this._parent._flag(key, true);\n }\n this._flags[key] = (this._flags[key] || 0) + 1;\n } else if (this._flags && this._flags[key] > 0) {\n if (this._flags[key] == 1 && this._parent) {\n this._parent._flag(key, false);\n }\n this._flags[key] = this._flags[key] - 1;\n }\n }\n if (typeof key === \"object\") {\n if (key._flags) {\n for (var type in key._flags) {\n if (key._flags[type] > 0) {\n this._flag(type, value);\n }\n }\n }\n }\n return this;\n };\n Node2.prototype.hitTest = function(hit) {\n var width = this._pin._width;\n var height = this._pin._height;\n return hit.x >= 0 && hit.x <= width && hit.y >= 0 && hit.y <= height;\n };\n Node2.prototype.prerender = function() {\n if (!this._visible) {\n return;\n }\n var child;\n var next = this._first;\n while (child = next) {\n next = child._next;\n child.prerender();\n }\n };\n Node2.prototype.render = function(context) {\n if (!this._visible) {\n return;\n }\n stats.node++;\n var m = this.matrix();\n context.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);\n this._alpha = this._pin._alpha * (this._parent ? this._parent._alpha : 1);\n var alpha = this._pin._textureAlpha * this._alpha;\n if (context.globalAlpha != alpha) {\n context.globalAlpha = alpha;\n }\n if (this._textures) {\n for (var i = 0, n = this._textures.length; i < n; i++) {\n this._textures[i].draw(context);\n }\n }\n if (context.globalAlpha != this._alpha) {\n context.globalAlpha = this._alpha;\n }\n var child;\n var next = this._first;\n while (child = next) {\n next = child._next;\n child.render(context);\n }\n };\n Node2.prototype._tick = function(elapsed, now, last) {\n if (!this._visible) {\n return;\n }\n if (elapsed > this.MAX_ELAPSE) {\n elapsed = this.MAX_ELAPSE;\n }\n var ticked = false;\n if (this._tickBefore !== null) {\n for (var i = 0; i < this._tickBefore.length; i++) {\n stats.tick++;\n var tickFn = this._tickBefore[i];\n ticked = tickFn.call(this, elapsed, now, last) === true || ticked;\n }\n }\n var child;\n var next = this._first;\n while (child = next) {\n next = child._next;\n if (child._flag(\"_tick\")) {\n ticked = child._tick(elapsed, now, last) === true ? true : ticked;\n }\n }\n if (this._tickAfter !== null) {\n for (var i = 0; i < this._tickAfter.length; i++) {\n stats.tick++;\n var tickFn = this._tickAfter[i];\n ticked = tickFn.call(this, elapsed, now, last) === true || ticked;\n }\n }\n return ticked;\n };\n Node2.prototype.tick = function(callback, before) {\n var _a, _b;\n if (before === void 0) {\n before = false;\n }\n if (typeof callback !== \"function\") {\n return;\n }\n if (before) {\n if (this._tickBefore === null) {\n this._tickBefore = [];\n }\n this._tickBefore.push(callback);\n } else {\n if (this._tickAfter === null) {\n this._tickAfter = [];\n }\n this._tickAfter.push(callback);\n }\n var hasTickListener = ((_a = this._tickAfter) === null || _a === void 0 ? void 0 : _a.length) > 0 || ((_b = this._tickBefore) === null || _b === void 0 ? void 0 : _b.length) > 0;\n this._flag(\"_tick\", hasTickListener);\n };\n Node2.prototype.untick = function(callback) {\n if (typeof callback !== \"function\") {\n return;\n }\n var i;\n if (this._tickBefore !== null && (i = this._tickBefore.indexOf(callback)) >= 0) {\n this._tickBefore.splice(i, 1);\n }\n if (this._tickAfter !== null && (i = this._tickAfter.indexOf(callback)) >= 0) {\n this._tickAfter.splice(i, 1);\n }\n };\n Node2.prototype.timeout = function(callback, time) {\n this.setTimeout(callback, time);\n };\n Node2.prototype.setTimeout = function(callback, time) {\n function timer(t) {\n if ((time -= t) < 0) {\n this.untick(timer);\n callback.call(this);\n } else {\n return true;\n }\n }\n this.tick(timer);\n return timer;\n };\n Node2.prototype.clearTimeout = function(timer) {\n this.untick(timer);\n };\n Node2.prototype.on = function(type, listener) {\n if (!type || !type.length || typeof listener !== \"function\") {\n return this;\n }\n if (typeof type !== \"string\" && typeof type.join === \"function\") {\n for (var i = 0; i < type.length; i++) {\n this.on(type[i], listener);\n }\n } else if (typeof type === \"string\" && type.indexOf(\" \") > -1) {\n type = type.match(/\\S+/g);\n for (var i = 0; i < type.length; i++) {\n this._on(type[i], listener);\n }\n } else if (typeof type === \"string\") {\n this._on(type, listener);\n } else\n ;\n return this;\n };\n Node2.prototype._on = function(type, listener) {\n if (typeof type !== \"string\" && typeof listener !== \"function\") {\n return;\n }\n this._listeners[type] = this._listeners[type] || [];\n this._listeners[type].push(listener);\n this._flag(type, true);\n };\n Node2.prototype.off = function(type, listener) {\n if (!type || !type.length || typeof listener !== \"function\") {\n return this;\n }\n if (typeof type !== \"string\" && typeof type.join === \"function\") {\n for (var i = 0; i < type.length; i++) {\n this.off(type[i], listener);\n }\n } else if (typeof type === \"string\" && type.indexOf(\" \") > -1) {\n type = type.match(/\\S+/g);\n for (var i = 0; i < type.length; i++) {\n this._off(type[i], listener);\n }\n } else if (typeof type === \"string\") {\n this._off(type, listener);\n } else\n ;\n return this;\n };\n Node2.prototype._off = function(type, listener) {\n if (typeof type !== \"string\" && typeof listener !== \"function\") {\n return;\n }\n var listeners = this._listeners[type];\n if (!listeners || !listeners.length) {\n return;\n }\n var index = listeners.indexOf(listener);\n if (index >= 0) {\n listeners.splice(index, 1);\n this._flag(type, false);\n }\n };\n Node2.prototype.listeners = function(type) {\n return this._listeners[type];\n };\n Node2.prototype.publish = function(name, args) {\n var listeners = this.listeners(name);\n if (!listeners || !listeners.length) {\n return 0;\n }\n for (var l = 0; l < listeners.length; l++) {\n listeners[l].apply(this, args);\n }\n return listeners.length;\n };\n Node2.prototype.trigger = function(name, args) {\n this.publish(name, args);\n return this;\n };\n Node2.prototype.size = function(w, h) {\n this.pin(\"width\", w);\n this.pin(\"height\", h);\n return this;\n };\n Node2.prototype.width = function(w) {\n if (typeof w === \"undefined\") {\n return this.pin(\"width\");\n }\n this.pin(\"width\", w);\n return this;\n };\n Node2.prototype.height = function(h) {\n if (typeof h === \"undefined\") {\n return this.pin(\"height\");\n }\n this.pin(\"height\", h);\n return this;\n };\n Node2.prototype.offset = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n }\n this.pin(\"offsetX\", a);\n this.pin(\"offsetY\", b);\n return this;\n };\n Node2.prototype.rotate = function(a) {\n this.pin(\"rotation\", a);\n return this;\n };\n Node2.prototype.skew = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n } else if (typeof b === \"undefined\")\n b = a;\n this.pin(\"skewX\", a);\n this.pin(\"skewY\", b);\n return this;\n };\n Node2.prototype.scale = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n } else if (typeof b === \"undefined\")\n b = a;\n this.pin(\"scaleX\", a);\n this.pin(\"scaleY\", b);\n return this;\n };\n Node2.prototype.alpha = function(a, ta) {\n this.pin(\"alpha\", a);\n if (typeof ta !== \"undefined\") {\n this.pin(\"textureAlpha\", ta);\n }\n return this;\n };\n Node2.prototype.tween = function(a, b, c) {\n var options;\n if (typeof a === \"object\" && a !== null) {\n options = a;\n } else {\n options = {};\n if (typeof a === \"number\") {\n options.duration = a;\n if (typeof b === \"number\") {\n options.delay = b;\n if (typeof c === \"boolean\") {\n options.append = c;\n }\n } else if (typeof b === \"boolean\") {\n options.append = b;\n }\n } else if (typeof a === \"boolean\") {\n options.append = a;\n }\n }\n if (!this._transitionTickInitied) {\n this.tick(this._transitionTick, true);\n this._transitionTickInitied = true;\n }\n this.touch();\n if (!options.append) {\n this._transitions.length = 0;\n }\n var transition = new Transition(this, options);\n this._transitions.push(transition);\n return transition;\n };\n Node2.prototype.row = function(align) {\n this.align(\"row\", align);\n return this;\n };\n Node2.prototype.column = function(align) {\n this.align(\"column\", align);\n return this;\n };\n Node2.prototype.align = function(type, align) {\n var _this = this;\n this._padding = this._padding;\n this._spacing = this._spacing;\n this._layoutTicker && this.untick(this._layoutTicker);\n this.tick(this._layoutTicker = function() {\n if (_this._mo_seq == _this._ts_touch) {\n return;\n }\n _this._mo_seq = _this._ts_touch;\n var alignChildren = _this._mo_seqAlign != _this._ts_children;\n _this._mo_seqAlign = _this._ts_children;\n var width = 0;\n var height = 0;\n var child;\n var next = _this.first(true);\n var first = true;\n while (child = next) {\n next = child.next(true);\n child.matrix(true);\n var w = child.pin(\"boxWidth\");\n var h = child.pin(\"boxHeight\");\n if (type == \"column\") {\n !first && (height += _this._spacing);\n child.pin(\"offsetY\") != height && child.pin(\"offsetY\", height);\n width = Math.max(width, w);\n height = height + h;\n alignChildren && child.pin(\"alignX\", align);\n } else if (type == \"row\") {\n !first && (width += _this._spacing);\n child.pin(\"offsetX\") != width && child.pin(\"offsetX\", width);\n width = width + w;\n height = Math.max(height, h);\n alignChildren && child.pin(\"alignY\", align);\n }\n first = false;\n }\n width += 2 * _this._padding;\n height += 2 * _this._padding;\n _this.pin(\"width\") != width && _this.pin(\"width\", width);\n _this.pin(\"height\") != height && _this.pin(\"height\", height);\n });\n return this;\n };\n Node2.prototype.box = function() {\n return this.minimize();\n };\n Node2.prototype.layer = function() {\n return this.maximize();\n };\n Node2.prototype.minimize = function() {\n var _this = this;\n this._padding = this._padding;\n this._layoutTicker && this.untick(this._layoutTicker);\n this.tick(this._layoutTicker = function() {\n if (_this._mo_box == _this._ts_touch) {\n return;\n }\n _this._mo_box = _this._ts_touch;\n var width = 0;\n var height = 0;\n var child;\n var next = _this.first(true);\n while (child = next) {\n next = child.next(true);\n child.matrix(true);\n var w = child.pin(\"boxWidth\");\n var h = child.pin(\"boxHeight\");\n width = Math.max(width, w);\n height = Math.max(height, h);\n }\n width += 2 * _this._padding;\n height += 2 * _this._padding;\n _this.pin(\"width\") != width && _this.pin(\"width\", width);\n _this.pin(\"height\") != height && _this.pin(\"height\", height);\n });\n return this;\n };\n Node2.prototype.maximize = function() {\n var _this = this;\n this._layoutTicker && this.untick(this._layoutTicker);\n this.tick(this._layoutTicker = function() {\n var parent = _this.parent();\n if (parent) {\n var width = parent.pin(\"width\");\n if (_this.pin(\"width\") != width) {\n _this.pin(\"width\", width);\n }\n var height = parent.pin(\"height\");\n if (_this.pin(\"height\") != height) {\n _this.pin(\"height\", height);\n }\n }\n }, true);\n return this;\n };\n Node2.prototype.padding = function(pad) {\n this._padding = pad;\n return this;\n };\n Node2.prototype.spacing = function(space) {\n this._spacing = space;\n return this;\n };\n return Node2;\n }()\n);\nvar __extends$4 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nfunction sprite(frame) {\n var sprite2 = new Sprite();\n frame && sprite2.texture(frame);\n return sprite2;\n}\nvar Sprite = (\n /** @class */\n function(_super) {\n __extends$4(Sprite2, _super);\n function Sprite2() {\n var _this = _super.call(this) || this;\n _this._tiled = false;\n _this._stretched = false;\n _this.prerenderContext = {};\n _this.label(\"Sprite\");\n _this._textures = [];\n _this._image = null;\n return _this;\n }\n Sprite2.prototype.texture = function(frame) {\n this._image = texture(frame).one();\n if (this._image) {\n this.pin(\"width\", this._image.getWidth());\n this.pin(\"height\", this._image.getHeight());\n if (this._tiled) {\n this._textures[0] = new ResizableTexture(this._image, \"tile\");\n } else if (this._stretched) {\n this._textures[0] = new ResizableTexture(this._image, \"stretch\");\n } else {\n this._textures[0] = new PipeTexture(this._image);\n }\n this._textures.length = 1;\n } else {\n this.pin(\"width\", 0);\n this.pin(\"height\", 0);\n this._textures.length = 0;\n }\n return this;\n };\n Sprite2.prototype.image = function(frame) {\n return this.texture(frame);\n };\n Sprite2.prototype.tile = function(inner) {\n this._tiled = true;\n var texture2 = new ResizableTexture(this._image, \"tile\");\n this._textures[0] = texture2;\n return this;\n };\n Sprite2.prototype.stretch = function(inner) {\n this._stretched = true;\n var texture2 = new ResizableTexture(this._image, \"stretch\");\n this._textures[0] = texture2;\n return this;\n };\n Sprite2.prototype.prerender = function() {\n if (!this._visible) {\n return;\n }\n if (this._image) {\n var pixelRatio = this.getPixelRatio();\n this.prerenderContext.pixelRatio = pixelRatio;\n var updated = this._image.prerender(this.prerenderContext);\n if (updated === true) {\n var w = this._image.getWidth();\n var h = this._image.getHeight();\n this.size(w, h);\n }\n }\n _super.prototype.prerender.call(this);\n };\n Sprite2.prototype.render = function(context) {\n var texture2 = this._textures[0];\n if (texture2 === null || texture2 === void 0 ? void 0 : texture2[\"_resizeMode\"]) {\n texture2.dw = this.pin(\"width\");\n texture2.dh = this.pin(\"height\");\n }\n _super.prototype.render.call(this, context);\n };\n return Sprite2;\n }(Node)\n);\nvar image = sprite;\nvar Image$1 = Sprite;\nvar __extends$3 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar CanvasTexture = (\n /** @class */\n function(_super) {\n __extends$3(CanvasTexture2, _super);\n function CanvasTexture2() {\n var _this = _super.call(this, document.createElement(\"canvas\")) || this;\n _this._lastPixelRatio = 0;\n return _this;\n }\n CanvasTexture2.prototype.setSize = function(textureWidth, textureHeight, pixelRatio) {\n if (pixelRatio === void 0) {\n pixelRatio = 1;\n }\n this._source.width = textureWidth * pixelRatio;\n this._source.height = textureHeight * pixelRatio;\n this._pixelRatio = pixelRatio;\n };\n CanvasTexture2.prototype.getContext = function(type, attributes) {\n if (type === void 0) {\n type = \"2d\";\n }\n return this._source.getContext(type, attributes);\n };\n CanvasTexture2.prototype.getOptimalPixelRatio = function() {\n return Math.ceil(this._lastPixelRatio);\n };\n CanvasTexture2.prototype.setMemoizer = function(memoizer) {\n this._memoizer = memoizer;\n };\n CanvasTexture2.prototype.setDrawer = function(drawer) {\n this._drawer = drawer;\n };\n CanvasTexture2.prototype.prerender = function(context) {\n var newPixelRatio = context.pixelRatio;\n var lastPixelRatio = this._lastPixelRatio;\n var pixelRationChange = lastPixelRatio / newPixelRatio;\n var pixelRatioChanged = lastPixelRatio === 0 || pixelRationChange > 1.25 || pixelRationChange < 0.8;\n if (pixelRatioChanged) {\n this._lastPixelRatio = newPixelRatio;\n }\n var newMemoKey = this._memoizer ? this._memoizer.call(this) : null;\n var memoKeyChanged = this._lastMemoKey !== newMemoKey;\n if (pixelRatioChanged || memoKeyChanged) {\n this._lastMemoKey = newMemoKey;\n this._lastPixelRatio = newPixelRatio;\n if (typeof this._drawer === \"function\") {\n this._drawer.call(this);\n }\n return true;\n }\n };\n CanvasTexture2.prototype.size = function(width, height, pixelRatio) {\n this.setSize(width, height, pixelRatio);\n return this;\n };\n CanvasTexture2.prototype.context = function(type, attributes) {\n if (type === void 0) {\n type = \"2d\";\n }\n return this.getContext(type, attributes);\n };\n CanvasTexture2.prototype.canvas = function(legacyTextureDrawer) {\n if (typeof legacyTextureDrawer === \"function\") {\n legacyTextureDrawer.call(this, this.getContext());\n } else if (typeof legacyTextureDrawer === \"undefined\") {\n if (typeof this._drawer === \"function\") {\n this._drawer.call(this);\n }\n }\n return this;\n };\n return CanvasTexture2;\n }(ImageTexture)\n);\nfunction canvas(type, attributes, legacyTextureDrawer) {\n if (typeof type === \"function\") {\n var texture_1 = new CanvasTexture();\n legacyTextureDrawer = type;\n texture_1.setDrawer(function() {\n legacyTextureDrawer.call(texture_1, texture_1.getContext());\n });\n return texture_1;\n } else if (typeof attributes === \"function\") {\n var texture_2 = new CanvasTexture();\n legacyTextureDrawer = attributes;\n texture_2.setDrawer(function() {\n legacyTextureDrawer.call(texture_2, texture_2.getContext(type));\n });\n return texture_2;\n } else if (typeof legacyTextureDrawer === \"function\") {\n var texture_3 = new CanvasTexture();\n texture_3.setDrawer(function() {\n legacyTextureDrawer.call(texture_3, texture_3.getContext(type, attributes));\n });\n return texture_3;\n } else {\n var texture2 = new CanvasTexture();\n return texture2;\n }\n}\nfunction memoizeDraw(legacySpriteDrawer, legacySpriteMemoizer) {\n if (legacySpriteMemoizer === void 0) {\n legacySpriteMemoizer = function() {\n return null;\n };\n }\n var sprite2 = new Sprite();\n var texture2 = new CanvasTexture();\n sprite2.texture(texture2);\n texture2.setDrawer(function() {\n legacySpriteDrawer(2.5 * texture2._lastPixelRatio, texture2, sprite2);\n });\n texture2.setMemoizer(legacySpriteMemoizer);\n return sprite2;\n}\nvar POINTER_CLICK = \"click\";\nvar POINTER_START = \"touchstart mousedown\";\nvar POINTER_MOVE = \"touchmove mousemove\";\nvar POINTER_END = \"touchend mouseup\";\nvar POINTER_CANCEL = \"touchcancel mousecancel\";\nvar EventPoint = (\n /** @class */\n function() {\n function EventPoint2() {\n }\n EventPoint2.prototype.clone = function(obj) {\n if (obj) {\n obj.x = this.x;\n obj.y = this.y;\n } else {\n obj = {\n x: this.x,\n y: this.y\n };\n }\n return obj;\n };\n EventPoint2.prototype.toString = function() {\n return (this.x | 0) + \"x\" + (this.y | 0);\n };\n return EventPoint2;\n }()\n);\nvar PointerSyntheticEvent = (\n /** @class */\n function() {\n function PointerSyntheticEvent2() {\n this.abs = new EventPoint();\n }\n PointerSyntheticEvent2.prototype.clone = function(obj) {\n if (obj) {\n obj.x = this.x;\n obj.y = this.y;\n } else {\n obj = {\n x: this.x,\n y: this.y\n };\n }\n return obj;\n };\n PointerSyntheticEvent2.prototype.toString = function() {\n return this.type + \": \" + (this.x | 0) + \"x\" + (this.y | 0);\n };\n return PointerSyntheticEvent2;\n }()\n);\nvar VisitPayload = (\n /** @class */\n function() {\n function VisitPayload2() {\n this.type = \"\";\n this.x = 0;\n this.y = 0;\n this.timeStamp = -1;\n this.event = null;\n this.root = null;\n this.collected = null;\n }\n VisitPayload2.prototype.toString = function() {\n return this.type + \": \" + (this.x | 0) + \"x\" + (this.y | 0);\n };\n return VisitPayload2;\n }()\n);\nvar syntheticEvent = new PointerSyntheticEvent();\nvar PAYLOAD = new VisitPayload();\nvar Pointer = (\n /** @class */\n function() {\n function Pointer2() {\n var _this = this;\n this.ratio = 1;\n this.clickList = [];\n this.cancelList = [];\n this.handleStart = function(event) {\n event.preventDefault();\n _this.localPoint(event);\n _this.dispatchEvent(event.type, event);\n _this.findTargets(\"click\", _this.clickList);\n _this.findTargets(\"mousecancel\", _this.cancelList);\n };\n this.handleMove = function(event) {\n event.preventDefault();\n _this.localPoint(event);\n _this.dispatchEvent(event.type, event);\n };\n this.handleEnd = function(event) {\n event.preventDefault();\n _this.dispatchEvent(event.type, event);\n if (_this.clickList.length) {\n _this.dispatchEvent(\"click\", event, _this.clickList);\n }\n _this.cancelList.length = 0;\n };\n this.handleCancel = function(event) {\n if (_this.cancelList.length) {\n _this.dispatchEvent(\"mousecancel\", event, _this.cancelList);\n }\n _this.clickList.length = 0;\n };\n this.visitStart = function(node, payload) {\n return !node._flag(payload.type);\n };\n this.visitEnd = function(node, payload) {\n syntheticEvent.raw = payload.event;\n syntheticEvent.type = payload.type;\n syntheticEvent.timeStamp = payload.timeStamp;\n syntheticEvent.abs.x = payload.x;\n syntheticEvent.abs.y = payload.y;\n var listeners = node.listeners(payload.type);\n if (!listeners) {\n return;\n }\n node.matrix().inverse().map(payload, syntheticEvent);\n var isEventTarget = node === payload.root || node.attr(\"spy\") || node.hitTest(syntheticEvent);\n if (!isEventTarget) {\n return;\n }\n if (payload.collected) {\n payload.collected.push(node);\n }\n if (payload.event) {\n var cancel = false;\n for (var l = 0; l < listeners.length; l++) {\n cancel = listeners[l].call(node, syntheticEvent) ? true : cancel;\n }\n return cancel;\n }\n };\n }\n Pointer2.prototype.mount = function(stage, elem) {\n var _this = this;\n this.stage = stage;\n this.elem = elem;\n this.ratio = stage.viewport().ratio || 1;\n stage.on(\"viewport\", function(viewport) {\n var _a;\n _this.ratio = (_a = viewport.ratio) !== null && _a !== void 0 ? _a : _this.ratio;\n });\n elem.addEventListener(\"touchstart\", this.handleStart);\n elem.addEventListener(\"touchend\", this.handleEnd);\n elem.addEventListener(\"touchmove\", this.handleMove);\n elem.addEventListener(\"touchcancel\", this.handleCancel);\n elem.addEventListener(\"mousedown\", this.handleStart);\n elem.addEventListener(\"mouseup\", this.handleEnd);\n elem.addEventListener(\"mousemove\", this.handleMove);\n document.addEventListener(\"mouseup\", this.handleCancel);\n window.addEventListener(\"blur\", this.handleCancel);\n return this;\n };\n Pointer2.prototype.unmount = function() {\n var elem = this.elem;\n elem.removeEventListener(\"touchstart\", this.handleStart);\n elem.removeEventListener(\"touchend\", this.handleEnd);\n elem.removeEventListener(\"touchmove\", this.handleMove);\n elem.removeEventListener(\"touchcancel\", this.handleCancel);\n elem.removeEventListener(\"mousedown\", this.handleStart);\n elem.removeEventListener(\"mouseup\", this.handleEnd);\n elem.removeEventListener(\"mousemove\", this.handleMove);\n document.removeEventListener(\"mouseup\", this.handleCancel);\n window.removeEventListener(\"blur\", this.handleCancel);\n return this;\n };\n Pointer2.prototype.localPoint = function(event) {\n var _a;\n var elem = this.elem;\n var x;\n var y;\n if ((_a = event.touches) === null || _a === void 0 ? void 0 : _a.length) {\n x = event.touches[0].clientX;\n y = event.touches[0].clientY;\n } else {\n x = event.clientX;\n y = event.clientY;\n }\n var rect = elem.getBoundingClientRect();\n x -= rect.left;\n y -= rect.top;\n x -= elem.clientLeft | 0;\n y -= elem.clientTop | 0;\n PAYLOAD.x = x * this.ratio;\n PAYLOAD.y = y * this.ratio;\n };\n Pointer2.prototype.findTargets = function(type, result) {\n var payload = PAYLOAD;\n payload.type = type;\n payload.root = this.stage;\n payload.event = null;\n payload.collected = result;\n payload.collected.length = 0;\n this.stage.visit({\n reverse: true,\n visible: true,\n start: this.visitStart,\n end: this.visitEnd\n }, payload);\n };\n Pointer2.prototype.dispatchEvent = function(type, event, targets) {\n var payload = PAYLOAD;\n payload.type = type;\n payload.root = this.stage;\n payload.event = event;\n payload.timeStamp = Date.now();\n payload.collected = null;\n if (targets) {\n while (targets.length) {\n var node = targets.shift();\n if (this.visitEnd(node, payload)) {\n break;\n }\n }\n targets.length = 0;\n } else {\n this.stage.visit({\n reverse: true,\n visible: true,\n start: this.visitStart,\n end: this.visitEnd\n }, payload);\n }\n };\n return Pointer2;\n }()\n);\nvar Mouse = {\n CLICK: \"click\",\n START: \"touchstart mousedown\",\n MOVE: \"touchmove mousemove\",\n END: \"touchend mouseup\",\n CANCEL: \"touchcancel mousecancel\"\n};\nvar __extends$2 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar __assign = function() {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s)\n if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar ROOTS = [];\nfunction pause() {\n for (var i = ROOTS.length - 1; i >= 0; i--) {\n ROOTS[i].pause();\n }\n}\nfunction resume() {\n for (var i = ROOTS.length - 1; i >= 0; i--) {\n ROOTS[i].resume();\n }\n}\nfunction mount(configs) {\n if (configs === void 0) {\n configs = {};\n }\n var root = new Root();\n root.mount(configs);\n root.pointer = new Pointer().mount(root, root.dom);\n return root;\n}\nvar Root = (\n /** @class */\n function(_super) {\n __extends$2(Root2, _super);\n function Root2() {\n var _this = _super.call(this) || this;\n _this.canvas = null;\n _this.dom = null;\n _this.context = null;\n _this.pixelWidth = -1;\n _this.pixelHeight = -1;\n _this.pixelRatio = 1;\n _this.drawingWidth = 0;\n _this.drawingHeight = 0;\n _this.mounted = false;\n _this.paused = false;\n _this.sleep = false;\n _this.mount = function(configs) {\n if (configs === void 0) {\n configs = {};\n }\n if (typeof configs.canvas === \"string\") {\n _this.canvas = document.getElementById(configs.canvas);\n if (!_this.canvas) {\n console.error(\"Canvas element not found: \", configs.canvas);\n }\n } else if (configs.canvas instanceof HTMLCanvasElement) {\n _this.canvas = configs.canvas;\n } else if (configs.canvas) {\n console.error(\"Unknown value for canvas:\", configs.canvas);\n }\n if (!_this.canvas) {\n _this.canvas = document.getElementById(\"cutjs\") || document.getElementById(\"stage\");\n }\n if (!_this.canvas) {\n _this.canvas = document.createElement(\"canvas\");\n Object.assign(_this.canvas.style, {\n position: \"absolute\",\n display: \"block\",\n top: \"0\",\n left: \"0\",\n bottom: \"0\",\n right: \"0\",\n width: \"100%\",\n height: \"100%\"\n });\n var body = document.body;\n body.insertBefore(_this.canvas, body.firstChild);\n }\n _this.dom = _this.canvas;\n _this.context = _this.canvas.getContext(\"2d\");\n var devicePixelRatio = window.devicePixelRatio || 1;\n var backingStorePixelRatio = (\n // @ts-ignore\n _this.context.webkitBackingStorePixelRatio || // @ts-ignore\n _this.context.mozBackingStorePixelRatio || // @ts-ignore\n _this.context.msBackingStorePixelRatio || // @ts-ignore\n _this.context.oBackingStorePixelRatio || // @ts-ignore\n _this.context.backingStorePixelRatio || 1\n );\n _this.devicePixelRatio = devicePixelRatio;\n _this.backingStoreRatio = backingStorePixelRatio;\n _this.pixelRatio = _this.devicePixelRatio / _this.backingStoreRatio;\n _this.mounted = true;\n ROOTS.push(_this);\n _this.requestFrame();\n };\n _this.frameRequested = false;\n _this.requestFrame = function() {\n if (!_this.frameRequested) {\n _this.frameRequested = true;\n requestAnimationFrame(_this.onFrame);\n }\n };\n _this._lastFrameTime = 0;\n _this._mo_touch = null;\n _this.onFrame = function(now) {\n _this.frameRequested = false;\n if (!_this.mounted || !_this.canvas || !_this.context) {\n return;\n }\n _this.requestFrame();\n var newPixelWidth = _this.canvas.clientWidth;\n var newPixelHeight = _this.canvas.clientHeight;\n if (_this.pixelWidth !== newPixelWidth || _this.pixelHeight !== newPixelHeight) {\n _this.pixelWidth = newPixelWidth;\n _this.pixelHeight = newPixelHeight;\n _this.drawingWidth = newPixelWidth * _this.pixelRatio;\n _this.drawingHeight = newPixelHeight * _this.pixelRatio;\n if (_this.canvas.width !== _this.drawingWidth || _this.canvas.height !== _this.drawingHeight) {\n _this.canvas.width = _this.drawingWidth;\n _this.canvas.height = _this.drawingHeight;\n _this.viewport({\n width: _this.drawingWidth,\n height: _this.drawingHeight,\n ratio: _this.pixelRatio\n });\n }\n }\n var last = _this._lastFrameTime || now;\n var elapsed = now - last;\n if (!_this.mounted || _this.paused || _this.sleep) {\n return;\n }\n _this._lastFrameTime = now;\n _this.prerender();\n var tickRequest = _this._tick(elapsed, now, last);\n if (_this._mo_touch != _this._ts_touch) {\n _this._mo_touch = _this._ts_touch;\n _this.sleep = false;\n if (_this.drawingWidth > 0 && _this.drawingHeight > 0) {\n _this.context.setTransform(1, 0, 0, 1, 0, 0);\n _this.context.clearRect(0, 0, _this.drawingWidth, _this.drawingHeight);\n _this.render(_this.context);\n }\n } else if (tickRequest) {\n _this.sleep = false;\n } else {\n _this.sleep = true;\n }\n stats.fps = elapsed ? 1e3 / elapsed : 0;\n };\n _this.label(\"Root\");\n return _this;\n }\n Root2.prototype.resume = function() {\n if (this.sleep || this.paused) {\n this.requestFrame();\n }\n this.paused = false;\n this.sleep = false;\n this.publish(\"resume\");\n return this;\n };\n Root2.prototype.pause = function() {\n if (!this.paused) {\n this.publish(\"pause\");\n }\n this.paused = true;\n return this;\n };\n Root2.prototype.touch = function() {\n if (this.sleep || this.paused) {\n this.requestFrame();\n }\n this.sleep = false;\n return _super.prototype.touch.call(this);\n };\n Root2.prototype.unmount = function() {\n var _a;\n this.mounted = false;\n var index = ROOTS.indexOf(this);\n if (index >= 0) {\n ROOTS.splice(index, 1);\n }\n (_a = this.pointer) === null || _a === void 0 ? void 0 : _a.unmount();\n return this;\n };\n Root2.prototype.background = function(color) {\n if (this.dom) {\n this.dom.style.backgroundColor = color;\n }\n return this;\n };\n Root2.prototype.viewport = function(width, height, ratio) {\n if (typeof width === \"undefined\") {\n return Object.assign({}, this._viewport);\n }\n if (typeof width === \"object\") {\n var options = width;\n width = options.width;\n height = options.height;\n ratio = options.ratio;\n }\n if (typeof width === \"number\" && typeof height === \"number\") {\n this._viewport = {\n width,\n height,\n ratio: typeof ratio === \"number\" ? ratio : 1\n };\n this.viewbox();\n var data_1 = Object.assign({}, this._viewport);\n this.visit({\n start: function(node) {\n if (!node._flag(\"viewport\")) {\n return true;\n }\n node.publish(\"viewport\", [data_1]);\n }\n });\n }\n return this;\n };\n Root2.prototype.viewbox = function(width, height, mode) {\n if (typeof width === \"number\" && typeof height === \"number\") {\n this._viewbox = {\n width,\n height,\n mode\n };\n } else if (typeof width === \"object\" && width !== null) {\n this._viewbox = __assign({}, width);\n }\n this.rescale();\n return this;\n };\n Root2.prototype.camera = function(matrix) {\n this._camera = matrix;\n this.rescale();\n return this;\n };\n Root2.prototype.rescale = function() {\n var viewbox = this._viewbox;\n var viewport = this._viewport;\n var camera = this._camera;\n if (viewport && viewbox) {\n var viewportWidth = viewport.width;\n var viewportHeight = viewport.height;\n var viewboxMode = isValidFitMode(viewbox.mode) ? viewbox.mode : \"in-pad\";\n var viewboxWidth = viewbox.width;\n var viewboxHeight = viewbox.height;\n this.pin({\n width: viewboxWidth,\n height: viewboxHeight\n });\n this.scaleTo(viewportWidth, viewportHeight, viewboxMode);\n var viewboxX = viewbox.x || 0;\n var viewboxY = viewbox.y || 0;\n var cameraZoom = (camera === null || camera === void 0 ? void 0 : camera.a) || 1;\n var cameraX = (camera === null || camera === void 0 ? void 0 : camera.e) || 0;\n var cameraY = (camera === null || camera === void 0 ? void 0 : camera.f) || 0;\n var scaleX = this.pin(\"scaleX\");\n var scaleY = this.pin(\"scaleY\");\n this.pin(\"scaleX\", scaleX * cameraZoom);\n this.pin(\"scaleY\", scaleY * cameraZoom);\n this.pin(\"offsetX\", cameraX - viewboxX * scaleX * cameraZoom);\n this.pin(\"offsetY\", cameraY - viewboxY * scaleY * cameraZoom);\n } else if (viewport) {\n this.pin({\n width: viewport.width,\n height: viewport.height\n });\n }\n return this;\n };\n return Root2;\n }(Node)\n);\nvar __extends$1 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nfunction anim(frames, fps) {\n var anim2 = new Anim();\n anim2.frames(frames).gotoFrame(0);\n fps && anim2.fps(fps);\n return anim2;\n}\nvar FPS = 15;\nvar Anim = (\n /** @class */\n function(_super) {\n __extends$1(Anim2, _super);\n function Anim2() {\n var _this = _super.call(this) || this;\n _this.label(\"Anim\");\n _this._textures = [];\n _this._fps = FPS;\n _this._ft = 1e3 / _this._fps;\n _this._time = -1;\n _this._repeat = 0;\n _this._index = 0;\n _this._frames = [];\n var lastTime = 0;\n _this.tick(function(t, now, last) {\n if (this._time < 0 || this._frames.length <= 1) {\n return;\n }\n var ignore = lastTime != last;\n lastTime = now;\n if (ignore) {\n return true;\n }\n this._time += t;\n if (this._time < this._ft) {\n return true;\n }\n var n = this._time / this._ft | 0;\n this._time -= n * this._ft;\n this.moveFrame(n);\n if (this._repeat > 0 && (this._repeat -= n) <= 0) {\n this.stop();\n this._callback && this._callback();\n return false;\n }\n return true;\n }, false);\n return _this;\n }\n Anim2.prototype.fps = function(fps) {\n if (typeof fps === \"undefined\") {\n return this._fps;\n }\n this._fps = fps > 0 ? fps : FPS;\n this._ft = 1e3 / this._fps;\n return this;\n };\n Anim2.prototype.setFrames = function(frames) {\n return this.frames(frames);\n };\n Anim2.prototype.frames = function(frames) {\n this._index = 0;\n this._frames = texture(frames).array();\n this.touch();\n return this;\n };\n Anim2.prototype.length = function() {\n return this._frames ? this._frames.length : 0;\n };\n Anim2.prototype.gotoFrame = function(frame, resize) {\n if (resize === void 0) {\n resize = false;\n }\n this._index = math.wrap(frame, this._frames.length) | 0;\n resize = resize || !this._textures[0];\n this._textures[0] = this._frames[this._index];\n if (resize) {\n this.pin(\"width\", this._textures[0].getWidth());\n this.pin(\"height\", this._textures[0].getHeight());\n }\n this.touch();\n return this;\n };\n Anim2.prototype.moveFrame = function(move) {\n return this.gotoFrame(this._index + move);\n };\n Anim2.prototype.repeat = function(repeat, callback) {\n this._repeat = repeat * this._frames.length - 1;\n this._callback = callback;\n this.play();\n return this;\n };\n Anim2.prototype.play = function(frame) {\n if (typeof frame !== \"undefined\") {\n this.gotoFrame(frame);\n this._time = 0;\n } else if (this._time < 0) {\n this._time = 0;\n }\n this.touch();\n return this;\n };\n Anim2.prototype.stop = function(frame) {\n this._time = -1;\n if (typeof frame !== \"undefined\") {\n this.gotoFrame(frame);\n }\n return this;\n };\n return Anim2;\n }(Node)\n);\nvar __extends = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nfunction monotype(chars) {\n return new Monotype().frames(chars);\n}\nvar Monotype = (\n /** @class */\n function(_super) {\n __extends(Monotype2, _super);\n function Monotype2() {\n var _this = _super.call(this) || this;\n _this.label(\"String\");\n _this._textures = [];\n return _this;\n }\n Monotype2.prototype.setFont = function(frames) {\n return this.frames(frames);\n };\n Monotype2.prototype.frames = function(frames) {\n this._textures = [];\n if (typeof frames == \"string\") {\n var selection_1 = texture(frames);\n this._font = function(value) {\n return selection_1.one(value);\n };\n } else if (typeof frames === \"object\") {\n this._font = function(value) {\n return frames[value];\n };\n } else if (typeof frames === \"function\") {\n this._font = frames;\n }\n return this;\n };\n Monotype2.prototype.setValue = function(value) {\n return this.value(value);\n };\n Monotype2.prototype.value = function(value) {\n if (typeof value === \"undefined\") {\n return this._value;\n }\n if (this._value === value) {\n return this;\n }\n this._value = value;\n if (value === null) {\n value = \"\";\n } else if (typeof value !== \"string\" && !Array.isArray(value)) {\n value = value.toString();\n }\n this._spacing = this._spacing || 0;\n var width = 0;\n var height = 0;\n for (var i = 0; i < value.length; i++) {\n var v = value[i];\n var texture_1 = this._textures[i] = this._font(typeof v === \"string\" ? v : v + \"\");\n width += i > 0 ? this._spacing : 0;\n texture_1.setDestinationCoordinate(width, 0);\n width = width + texture_1.getWidth();\n height = Math.max(height, texture_1.getHeight());\n }\n this.pin(\"width\", width);\n this.pin(\"height\", height);\n this._textures.length = value.length;\n return this;\n };\n return Monotype2;\n }(Node)\n);\nvar string = monotype;\nvar Str = Monotype;\nconst Stage = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({\n __proto__: null,\n Anim,\n Atlas,\n CanvasTexture,\n Image: Image$1,\n ImageTexture,\n Math: math,\n Matrix,\n Monotype,\n Mouse,\n Node,\n POINTER_CANCEL,\n POINTER_CLICK,\n POINTER_END,\n POINTER_MOVE,\n POINTER_START,\n Pin,\n PipeTexture,\n Pointer,\n ResizableTexture,\n Root,\n Sprite,\n Str,\n Texture,\n TextureSelection,\n Transition,\n anim,\n atlas,\n box,\n canvas,\n clamp,\n column,\n create,\n image,\n isValidFitMode,\n layer,\n layout,\n length,\n math,\n maximize,\n memoizeDraw,\n minimize,\n monotype,\n mount,\n pause,\n random,\n resume,\n row,\n sprite,\n string,\n texture,\n wrap\n}, Symbol.toStringTag, { value: \"Module\" }));\nexport {\n Anim,\n Atlas,\n CanvasTexture,\n Image$1 as Image,\n ImageTexture,\n math as Math,\n Matrix,\n Monotype,\n Mouse,\n Node,\n POINTER_CANCEL,\n POINTER_CLICK,\n POINTER_END,\n POINTER_MOVE,\n POINTER_START,\n Pin,\n PipeTexture,\n Pointer,\n ResizableTexture,\n Root,\n Sprite,\n Str,\n Texture,\n TextureSelection,\n Transition,\n anim,\n atlas,\n box,\n canvas,\n clamp,\n column,\n create,\n Stage as default,\n image,\n isValidFitMode,\n layer,\n layout,\n length,\n math,\n maximize,\n memoizeDraw,\n minimize,\n monotype,\n mount,\n pause,\n random,\n resume,\n row,\n sprite,\n string,\n texture,\n wrap\n};\n","import * as Stage from \"stage-js\";\n\nimport type { Vec2Value } from \"../src/common/Vec2\";\nimport type { World } from \"../src/dynamics/World\";\nimport type { Joint } from \"../src/dynamics/Joint\";\nimport type { Fixture } from \"../src/dynamics/Fixture\";\nimport type { Body } from \"../src/dynamics/Body\";\nimport type { AABBValue } from \"../src/collision/AABB\";\nimport type { Shape } from \"../src/collision/Shape\";\nimport type { Style } from \"../src/util/Testbed\";\nimport { Testbed } from \"../src/util/Testbed\";\nimport type { EdgeShape } from \"../src/collision/shape/EdgeShape\";\nimport type { PolygonShape } from \"../src/collision/shape/PolygonShape\";\nimport type { ChainShape } from \"../src/collision/shape/ChainShape\";\nimport type { CircleShape } from \"../src/collision/shape/CircleShape\";\nimport type { PulleyJoint } from \"../src/dynamics/joint/PulleyJoint\";\nimport { MouseJoint } from \"../src/dynamics/joint/MouseJoint\";\n\nconst math_atan2 = Math.atan2;\nconst math_abs = Math.abs;\nconst math_sqrt = Math.sqrt;\nconst math_PI = Math.PI;\nconst math_max = Math.max;\nconst math_min = Math.min;\n\ninterface DrawOptions {\n scaleY: number;\n lineWidth: number;\n stroke: string;\n fill: string;\n}\n\nlet mounted: StageTestbed | null = null;\n\n/** @internal */\nfunction memo() {\n const memory: any = [];\n function recall(...rest: any[]) {\n let equal = memory.length === rest.length;\n for (let i = 0; equal && i < rest.length; i++) {\n equal = equal && memory[i] === rest[i];\n memory[i] = rest[i];\n }\n memory.length = rest.length;\n return equal;\n }\n function reset() {\n memory.length = 0;\n // void 0;\n }\n return {\n recall,\n reset,\n };\n}\n\nTestbed.mount = () => {\n if (mounted) {\n return mounted;\n }\n\n mounted = new StageTestbed();\n\n // todo: merge rest of this into StageTestbed\n\n // todo: should we create these elements if not exists?\n const playButton = document.getElementById(\"testbed-play\");\n const statusElement = document.getElementById(\"testbed-status\");\n const infoElement = document.getElementById(\"testbed-info\");\n\n if (playButton) {\n playButton.addEventListener(\"click\", () => {\n if (mounted.isPaused() ) {\n mounted.resume();\n } else {\n mounted.pause();\n }\n });\n\n mounted._pause = () => {\n playButton.classList.add(\"pause\");\n playButton.classList.remove(\"play\");\n };\n\n mounted._resume = () => {\n playButton.classList.add(\"play\");\n playButton.classList.remove(\"pause\");\n };\n } else {\n console.log(\"Please create a button with id='testbed-play'\");\n }\n\n let lastStatus = \"\";\n if (statusElement) {\n statusElement.innerText = lastStatus;\n }\n mounted._status = (text: string) => {\n if (lastStatus === text) {\n return;\n }\n lastStatus = text;\n if (statusElement) {\n statusElement.innerText = text;\n }\n };\n\n let lastInfo = \"\";\n if (infoElement) {\n infoElement.innerText = lastInfo;\n }\n mounted._info = (text: string) => {\n if (lastInfo === text) {\n return;\n }\n lastInfo = text;\n if (infoElement) {\n infoElement.innerText = text;\n }\n };\n\n return mounted;\n};\n\nfunction getStyle(obj: Body | Fixture | Joint | Shape): Style {\n if (typeof obj[\"render\"] === \"object\" && (\"stroke\" in obj[\"render\"] || \"fill\" in obj[\"render\"])) {\n // this was used in planck before v1\n return obj[\"render\"];\n } else if (typeof obj[\"style\"] === \"object\") {\n return obj[\"style\"];\n }\n}\n\nfunction findBody(world: World, point: Vec2Value) {\n let body: Body | null = null;\n const aabb = {\n lowerBound: point,\n upperBound: point,\n };\n world.queryAABB(aabb, (fixture: Fixture) => {\n if (!fixture.getBody().isDynamic() || !fixture.testPoint(point)) {\n return true;\n }\n body = fixture.getBody();\n return false;\n });\n return body;\n}\n\n/** @internal */\nexport class StageTestbed extends Testbed {\n private canvas: HTMLCanvasElement;\n private stage: Stage.Root;\n private paused: boolean = false;\n private lastDrawHash = \"\";\n private newDrawHash = \"\";\n private buffer: ((context: CanvasRenderingContext2D, ratio: number)=> void)[] = [];\n\n start(world: World) {\n const stage = this.stage = Stage.mount();\n const canvas = this.canvas = stage.dom as HTMLCanvasElement;\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const testbed = this;\n this.canvas = canvas;\n\n stage.on(Stage.POINTER_START, () => {\n window.focus();\n // @ts-ignore\n document.activeElement?.blur();\n canvas.focus();\n });\n\n stage.MAX_ELAPSE = 1000 / 30;\n\n stage.on(\"resume\", () => {\n this.paused = false;\n this._resume();\n });\n stage.on(\"pause\", () => {\n this.paused = true;\n this._pause();\n });\n\n const drawingTexture = new Stage.CanvasTexture();\n drawingTexture.draw = (ctx: CanvasRenderingContext2D) => {\n const pixelRatio = 2 * drawingTexture.getOptimalPixelRatio();\n ctx.save();\n ctx.transform(1, 0, 0, this.scaleY, -this.x, -this.y);\n ctx.lineWidth = 3 / pixelRatio;\n ctx.lineCap = \"round\";\n for (let drawing = this.buffer.shift(); drawing; drawing = this.buffer.shift()) {\n drawing(ctx, pixelRatio);\n }\n ctx.restore();\n };\n\n const drawingElement = Stage.sprite(drawingTexture);\n stage.append(drawingElement);\n stage.tick(() => {\n this.buffer.length = 0;\n }, true);\n\n\n stage.background(this.background);\n stage.viewbox(this.width, this.height);\n stage.pin(\"alignX\", -0.5);\n stage.pin(\"alignY\", -0.5);\n\n const worldNode = new WorldStageNode(world, this);\n\n // stage.empty();\n stage.prepend(worldNode);\n\n let lastX = 0;\n let lastY = 0;\n stage.tick((dt: number, t: number) => {\n // update camera position\n if (lastX !== this.x || lastY !== this.y) {\n worldNode.offset(-this.x, -this.y);\n lastX = this.x;\n lastY = this.y;\n }\n });\n\n worldNode.tick((dt: number, t: number) => {\n this.step(dt, t);\n\n if (targetBody) {\n this.drawSegment(targetBody.getPosition(), mouseMove, \"rgba(255,255,255,0.2)\");\n }\n\n if (this.lastDrawHash !== this.newDrawHash) {\n this.lastDrawHash = this.newDrawHash;\n stage.touch();\n }\n this.newDrawHash = \"\";\n\n return true;\n });\n\n const mouseGround = world.createBody();\n let mouseJoint: MouseJoint | null = null;\n let targetBody: Body | null = null;\n const mouseMove = {x: 0, y: 0};\n\n worldNode.attr(\"spy\", true);\n\n worldNode.on(Stage.POINTER_START, (point: Vec2Value) => {\n point = { x: point.x, y: testbed.scaleY * point.y };\n if (targetBody) {\n return;\n }\n\n const body = findBody(world, point);\n if (!body) {\n return;\n }\n\n if (this.mouseForce) {\n targetBody = body;\n\n } else {\n mouseJoint = new MouseJoint({maxForce: 1000}, mouseGround, body, { x: point.x, y: point.y });\n world.createJoint(mouseJoint);\n }\n });\n\n worldNode.on(Stage.POINTER_MOVE, (point: Vec2Value) => {\n point = { x: point.x, y: testbed.scaleY * point.y };\n if (mouseJoint) {\n mouseJoint.setTarget(point);\n }\n\n mouseMove.x = point.x;\n mouseMove.y = point.y;\n });\n\n worldNode.on(Stage.POINTER_END, (point: Vec2Value) => {\n point = { x: point.x, y: testbed.scaleY * point.y };\n if (mouseJoint) {\n world.destroyJoint(mouseJoint);\n mouseJoint = null;\n }\n if (targetBody && this.mouseForce) {\n const target = targetBody.getPosition();\n const force = {\n x: (point.x - target.x) * this.mouseForce,\n y: (point.y - target.y) * this.mouseForce,\n };\n targetBody.applyForceToCenter(force, true);\n targetBody = null;\n }\n });\n\n worldNode.on(Stage.POINTER_CANCEL, (point: Vec2Value) => {\n point = { x: point.x, y: testbed.scaleY * point.y };\n if (mouseJoint) {\n world.destroyJoint(mouseJoint);\n mouseJoint = null;\n }\n if (targetBody) {\n targetBody = null;\n }\n });\n\n const activeKeys = testbed.activeKeys;\n const downKeys: Record = {};\n function updateActiveKeys(keyCode: number, down: boolean) {\n const char = String.fromCharCode(keyCode);\n if (/\\w/.test(char)) {\n activeKeys[char] = down;\n }\n activeKeys.right = downKeys[39] || activeKeys[\"D\"];\n activeKeys.left = downKeys[37] || activeKeys[\"A\"];\n activeKeys.up = downKeys[38] || activeKeys[\"W\"];\n activeKeys.down = downKeys[40] || activeKeys[\"S\"];\n activeKeys.fire = downKeys[32] || downKeys[13] ;\n }\n\n window.addEventListener(\"keydown\", function(e) {\n const keyCode = e.keyCode;\n downKeys[keyCode] = true;\n updateActiveKeys(keyCode, true);\n testbed.keydown?.(keyCode, String.fromCharCode(keyCode));\n });\n window.addEventListener(\"keyup\", function(e) {\n const keyCode = e.keyCode;\n downKeys[keyCode] = false;\n updateActiveKeys(keyCode, false);\n testbed.keyup?.(keyCode, String.fromCharCode(keyCode));\n });\n\n this.resume();\n }\n\n /** @private @internal */\n focus() {\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n document.activeElement && document.activeElement.blur();\n this.canvas.focus();\n }\n\n /** @internal */\n _pause() {\n }\n\n /** @internal */\n _resume() {\n }\n\n private statusText = \"\";\n private statusMap: Record = {};\n\n status(name: string, value: any): void;\n status(value: object | string): void;\n status(a: any, b?: any) {\n if (typeof b !== \"undefined\") {\n const key = a;\n const value = b;\n if (typeof value !== \"function\" && typeof value !== \"object\") {\n this.statusMap[key] = value;\n }\n } else if (a && typeof a === \"object\") {\n // tslint:disable-next-line:no-for-in\n for (const key in a) {\n const value = a[key];\n if (typeof value !== \"function\" && typeof value !== \"object\") {\n this.statusMap[key] = value;\n }\n }\n } else if (typeof a === \"string\") {\n this.statusText = a;\n }\n\n var newline = \"\\n\";\n var text = this.statusText || \"\";\n for (var key in this.statusMap) {\n var value = this.statusMap[key];\n if (typeof value === \"function\") continue;\n text += (text && newline) + key + \": \" + value;\n }\n\n this._status(text);\n }\n\n info(text: string): void {\n this._info(text);\n }\n\n /** @internal */\n _status(string: string) {\n }\n\n /** @internal */ \n _info(text: string) {\n }\n\n /** @internal */\n isPaused() {\n return this.paused;\n }\n\n /** @internal */\n togglePause() {\n if (this.paused) {\n this.resume();\n } else {\n this.pause();\n }\n }\n\n /** @internal */\n pause() {\n this.stage.pause();\n }\n\n /** @internal */\n resume() {\n this.stage.resume();\n this.focus();\n }\n\n drawPoint(p: {x: number, y: number}, r: number, color: string): void {\n this.buffer.push(function(ctx, ratio) {\n ctx.beginPath();\n ctx.arc(p.x, p.y, 5 / ratio, 0, 2 * math_PI);\n ctx.strokeStyle = color;\n ctx.stroke();\n });\n this.newDrawHash += \"point\" + p.x + \",\" + p.y + \",\" + r + \",\" + color;\n }\n\n drawCircle(p: {x: number, y: number}, r: number, color: string): void {\n this.buffer.push(function(ctx) {\n ctx.beginPath();\n ctx.arc(p.x, p.y, r, 0, 2 * math_PI);\n ctx.strokeStyle = color;\n ctx.stroke();\n });\n this.newDrawHash += \"circle\" + p.x + \",\" + p.y + \",\" + r + \",\" + color;\n }\n\n drawEdge(a: {x: number, y: number}, b: {x: number, y: number}, color: string): void {\n this.buffer.push(function(ctx) {\n ctx.beginPath();\n ctx.moveTo(a.x, a.y);\n ctx.lineTo(b.x, b.y);\n ctx.strokeStyle = color;\n ctx.stroke();\n });\n this.newDrawHash += \"segment\" + a.x + \",\" + a.y + \",\" + b.x + \",\" + b.y + \",\" + color;\n }\n\n drawSegment = this.drawEdge;\n\n drawPolygon(points: Array<{x: number, y: number}>, color: string): void {\n if (!points || !points.length) {\n return;\n }\n this.buffer.push(function(ctx) {\n ctx.beginPath();\n ctx.moveTo(points[0].x, points[0].y);\n for (let i = 1; i < points.length; i++) {\n ctx.lineTo(points[i].x, points[i].y);\n }\n ctx.strokeStyle = color;\n ctx.closePath();\n ctx.stroke();\n });\n this.newDrawHash += \"segment\";\n for (let i = 1; i < points.length; i++) {\n this.newDrawHash += points[i].x + \",\" + points[i].y + \",\";\n }\n this.newDrawHash += color;\n }\n\n drawAABB(aabb: AABBValue, color: string): void {\n this.buffer.push(function(ctx) {\n ctx.beginPath();\n ctx.moveTo(aabb.lowerBound.x, aabb.lowerBound.y);\n ctx.lineTo(aabb.upperBound.x, aabb.lowerBound.y);\n ctx.lineTo(aabb.upperBound.x, aabb.upperBound.y);\n ctx.lineTo(aabb.lowerBound.x, aabb.upperBound.y);\n ctx.strokeStyle = color;\n ctx.closePath();\n ctx.stroke();\n });\n this.newDrawHash += \"aabb\";\n this.newDrawHash += aabb.lowerBound.x + \",\" + aabb.lowerBound.y + \",\";\n this.newDrawHash += aabb.upperBound.x + \",\" + aabb.upperBound.y + \",\";\n this.newDrawHash += color;\n }\n\n findOne(query: string): (Body | Joint | Fixture | null) {\n throw new Error(\"Not implemented\");\n }\n\n findAll(query: string): (Body | Joint | Fixture)[] {\n throw new Error(\"Not implemented\");\n }\n}\n\ninterface WorldStageOptions {\n speed: number;\n hz: number;\n scaleY: number;\n lineWidth: number;\n stroke: string | undefined;\n fill: string | undefined;\n}\n\nclass WorldStageNode extends Stage.Node {\n private nodes = new WeakMap();\n\n private options: WorldStageOptions = {\n speed: 1,\n hz: 60,\n scaleY: -1,\n lineWidth: 3,\n stroke: undefined,\n fill: undefined\n };\n\n private world: World;\n private testbed: Testbed;\n\n constructor(world: World, opts: Partial = {}) {\n super();\n this.label(\"Planck\");\n\n this.options = { ...this.options, ...opts };\n\n if (math_abs(this.options.hz) < 1) {\n this.options.hz = 1 / this.options.hz;\n }\n\n this.world = world;\n this.testbed = opts as Testbed;\n\n const timeStep = 1 / this.options.hz;\n let elapsedTime = 0;\n let errored = false;\n this.tick((dt: number) => {\n if (errored) {\n return false;\n }\n try {\n dt = dt * 0.001 * this.options.speed;\n elapsedTime += dt;\n while (elapsedTime > timeStep) {\n world.step(timeStep);\n elapsedTime -= timeStep;\n }\n this.renderWorld();\n return true; \n } catch (error) {\n errored = true;\n console.error(error);\n return false;\n }\n }, true);\n\n world.on(\"remove-fixture\", (obj: Fixture) => {\n this.nodes.get(obj)?.remove();\n });\n\n world.on(\"remove-joint\", (obj: Joint) => {\n this.nodes.get(obj)?.remove();\n });\n }\n\n renderWorld() {\n const world = this.world;\n const options = this.options;\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const viewer = this;\n\n for (let b = world.getBodyList(); b; b = b.getNext()) {\n for (let f = b.getFixtureList(); f; f = f.getNext()) {\n\n let node = this.nodes.get(f);\n if (!node) {\n const type = f.getType();\n const shape = f.getShape();\n\n const opts: DrawOptions = Object.assign({\n stroke: options.stroke,\n fill: options.fill,\n scaleY: options.scaleY,\n lineWidth: options.lineWidth,\n }, getStyle(b), getStyle(f), getStyle(shape));\n\n if (opts.stroke) {\n // good\n } else if (b.isDynamic()) {\n opts.stroke = \"rgba(255,255,255,0.9)\";\n } else if (b.isKinematic()) {\n opts.stroke = \"rgba(255,255,255,0.7)\";\n } else if (b.isStatic()) {\n opts.stroke = \"rgba(255,255,255,0.5)\";\n }\n\n if (type == \"circle\") {\n node = viewer.drawCircle(shape as CircleShape, opts);\n }\n if (type == \"edge\") {\n node = viewer.drawEdge(shape as EdgeShape, opts);\n }\n if (type == \"polygon\") {\n node = viewer.drawPolygon(shape as PolygonShape, opts);\n }\n if (type == \"chain\") {\n node = viewer.drawChain(shape as ChainShape, opts);\n }\n\n if (node) {\n node.appendTo(viewer);\n this.nodes.set(f, node);\n }\n }\n\n if (node) {\n const p = b.getPosition();\n const r = b.getAngle();\n // @ts-ignore\n const isChanged = node.__lastX !== p.x || node.__lastY !== p.y || node.__lastR !== r;\n if (isChanged) {\n // @ts-ignore\n node.__lastX = p.x;\n // @ts-ignore\n node.__lastY = p.y;\n // @ts-ignore\n node.__lastR = r;\n node.offset(p.x, options.scaleY * p.y);\n node.rotate(options.scaleY * r);\n }\n }\n\n }\n }\n\n for (let j = world.getJointList(); j; j = j.getNext()) {\n const type = j.getType();\n if (type == \"pulley-joint\") {\n this.testbed.drawSegment(j.getAnchorA(), (j as PulleyJoint).getGroundAnchorA(), \"rgba(255,255,255,0.5)\");\n this.testbed.drawSegment(j.getAnchorB(), (j as PulleyJoint).getGroundAnchorB(), \"rgba(255,255,255,0.5)\");\n this.testbed.drawSegment((j as PulleyJoint).getGroundAnchorB(), (j as PulleyJoint).getGroundAnchorA(), \"rgba(255,255,255,0.5)\");\n } else {\n this.testbed.drawSegment(j.getAnchorA(), j.getAnchorB(), \"rgba(255,255,255,0.5)\");\n }\n }\n }\n\n drawCircle(shape: CircleShape, options: DrawOptions) {\n let offsetX = 0;\n let offsetY = 0;\n const offsetMemo = memo();\n\n const texture = Stage.canvas();\n texture.setDrawer(function () {\n const ctx = this.getContext();\n const ratio = 2 * this.getOptimalPixelRatio();\n const lw = options.lineWidth / ratio;\n\n const r = shape.m_radius;\n const cx = r + lw;\n const cy = r + lw;\n const w = r * 2 + lw * 2;\n const h = r * 2 + lw * 2;\n\n offsetX = shape.m_p.x - cx;\n offsetY = options.scaleY * shape.m_p.y - cy;\n\n this.setSize(w, h, ratio);\n\n ctx.scale(ratio, ratio);\n ctx.arc(cx, cy, r, 0, 2 * math_PI);\n if (options.fill) {\n ctx.fillStyle = options.fill;\n ctx.fill();\n }\n ctx.lineTo(cx, cy);\n ctx.lineWidth = options.lineWidth / ratio;\n ctx.strokeStyle = options.stroke ?? \"\";\n ctx.stroke();\n });\n\n const sprite = Stage.sprite(texture);\n sprite.tick(() => {\n if (!offsetMemo.recall(offsetX, offsetY)) {\n sprite.offset(offsetX, offsetY);\n }\n });\n\n const node = Stage.layout().append(sprite);\n return node;\n }\n\n drawEdge(edge: EdgeShape, options: DrawOptions) {\n let offsetX = 0;\n let offsetY = 0;\n let offsetA = 0;\n const offsetMemo = memo();\n\n const texture = Stage.canvas();\n texture.setDrawer(function () {\n const ctx = this.getContext();\n const ratio = 2 * this.getOptimalPixelRatio();\n const lw = options.lineWidth / ratio;\n\n const v1 = edge.m_vertex1;\n const v2 = edge.m_vertex2;\n\n const dx = v2.x - v1.x;\n const dy = v2.y - v1.y;\n\n const length = math_sqrt(dx * dx + dy * dy);\n\n this.setSize(length + 2 * lw, 2 * lw, ratio);\n\n const minX = math_min(v1.x, v2.x);\n const minY = math_min(options.scaleY * v1.y, options.scaleY * v2.y);\n \n offsetX = minX - lw;\n offsetY = minY - lw;\n offsetA = options.scaleY * math_atan2(dy, dx);\n\n ctx.scale(ratio, ratio);\n ctx.beginPath();\n ctx.moveTo(lw, lw);\n ctx.lineTo(lw + length, lw);\n\n ctx.lineCap = \"round\";\n ctx.lineWidth = options.lineWidth / ratio;\n ctx.strokeStyle = options.stroke ?? \"\";\n ctx.stroke();\n });\n\n const sprite = Stage.sprite(texture);\n sprite.tick(() => {\n if(!offsetMemo.recall(offsetX, offsetY, offsetA)) {\n sprite.offset(offsetX, offsetY);\n sprite.rotate(offsetA);\n }\n });\n const node = Stage.layout().append(sprite);\n return node;\n }\n\n drawPolygon(shape: PolygonShape, options: DrawOptions) {\n let offsetX = 0;\n let offsetY = 0;\n const offsetMemo = memo();\n\n const texture = Stage.canvas();\n texture.setDrawer(function () {\n const ctx = this.getContext();\n const ratio = 2 * this.getOptimalPixelRatio();\n const lw = options.lineWidth / ratio;\n\n const vertices = shape.m_vertices;\n\n if (!vertices.length) {\n return;\n }\n \n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (let i = 0; i < vertices.length; ++i) {\n const v = vertices[i];\n minX = math_min(minX, v.x);\n maxX = math_max(maxX, v.x);\n minY = math_min(minY, options.scaleY * v.y);\n maxY = math_max(maxY, options.scaleY * v.y);\n }\n \n const width = maxX - minX;\n const height = maxY - minY;\n\n offsetX = minX;\n offsetY = minY;\n\n this.setSize(width + 2 * lw, height + 2 * lw, ratio);\n\n ctx.scale(ratio, ratio);\n ctx.beginPath();\n for (let i = 0; i < vertices.length; ++i) {\n const v = vertices[i];\n const x = v.x - minX + lw;\n const y = options.scaleY * v.y - minY + lw;\n if (i == 0)\n ctx.moveTo(x, y);\n\n else\n ctx.lineTo(x, y);\n }\n\n if (vertices.length > 2) {\n ctx.closePath();\n }\n\n if (options.fill) {\n ctx.fillStyle = options.fill;\n ctx.fill();\n ctx.closePath();\n }\n\n ctx.lineCap = \"round\";\n ctx.lineWidth = options.lineWidth / ratio;\n ctx.strokeStyle = options.stroke ?? \"\";\n ctx.stroke();\n });\n\n const sprite = Stage.sprite(texture);\n sprite.tick(() => {\n if(!offsetMemo.recall(offsetX, offsetY)) {\n sprite.offset(offsetX, offsetY);\n }\n });\n\n const node = Stage.layout().append(sprite);\n return node;\n }\n\n drawChain(shape: ChainShape, options: DrawOptions) {\n let offsetX = 0;\n let offsetY = 0;\n const offsetMemo = memo();\n\n const texture = Stage.canvas();\n texture.setDrawer(function () {\n const ctx = this.getContext();\n const ratio = 2 * this.getOptimalPixelRatio();\n const lw = options.lineWidth / ratio;\n\n const vertices = shape.m_vertices;\n\n if (!vertices.length) {\n return;\n }\n \n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (let i = 0; i < vertices.length; ++i) {\n const v = vertices[i];\n minX = math_min(minX, v.x);\n maxX = math_max(maxX, v.x);\n minY = math_min(minY, options.scaleY * v.y);\n maxY = math_max(maxY, options.scaleY * v.y);\n }\n \n const width = maxX - minX;\n const height = maxY - minY;\n\n offsetX = minX;\n offsetY = minY;\n\n this.setSize(width + 2 * lw, height + 2 * lw, ratio);\n\n ctx.scale(ratio, ratio);\n ctx.beginPath();\n for (let i = 0; i < vertices.length; ++i) {\n const v = vertices[i];\n const x = v.x - minX + lw;\n const y = options.scaleY * v.y - minY + lw;\n if (i == 0)\n ctx.moveTo(x, y);\n\n else\n ctx.lineTo(x, y);\n }\n\n // TODO: if loop\n if (vertices.length > 2) {\n // ctx.closePath();\n }\n\n if (options.fill) {\n ctx.fillStyle = options.fill;\n ctx.fill();\n ctx.closePath();\n }\n\n ctx.lineCap = \"round\";\n ctx.lineWidth = options.lineWidth / ratio;\n ctx.strokeStyle = options.stroke ?? \"\";\n ctx.stroke();\n });\n\n const sprite = Stage.sprite(texture);\n sprite.tick(() => {\n if(!offsetMemo.recall(offsetX, offsetY)) {\n sprite.offset(offsetX, offsetY);\n }\n });\n\n const node = Stage.layout().append(sprite);\n return node;\n }\n}\n"],"names":["d","b","__extends","__assign","s","n","input","output","math_random","x","clamp","random","math","math_abs","math_sqrt","math_max","math_min","Vec2","v","a","length","AABB","normal","temp","math_PI","Settings","SettingsInternal","Pool","TreeNode","DynamicTree","c","Iterator","BroadPhase","displacement","math_sin","math_cos","transform","xf","math_atan2","Rot","matrix.vec2","Sweep","matrix.zeroVec2","matrix.transformVec2","matrix.copyVec2","localCenter","matrix.setRotAngle","matrix.combine2Vec2","matrix.minusVec2","matrix.rotVec2","Transform","rotation","Velocity","Position","Shape","FixtureProxy","Fixture","matrix.subVec2","matrix.transform","Body","matrix.plusScaleVec2","matrix.scaleVec2","matrix.dotVec2","matrix.crossNumVec2","matrix.plusVec2","point","JointEdge","Joint","stats","DistanceInput","DistanceOutput","SimplexCache","cache","xfA","xfB","matrix.lengthSqrVec2","matrix.derotVec2","matrix.distVec2","rA","rB","matrix.normalizeVec2","matrix.minusScaleVec2","DistanceProxy","SimplexVertex","Simplex","v1","v2","matrix.setVec2","matrix.crossVec2Vec2","pA","pB","matrix.combine3Vec2","matrix.copyTransform","ShapeCastInput","ShapeCastOutput","simplex","pointA","pointB","TOIInput","TOIOutputState","TOIOutput","SeparationFunctionType","SeparationFunction","matrix.normalizeVec2Length","matrix.crossVec2Num","matrix.negVec2","TimeStep","ContactImpulse","Solver","matrix.mulVec2","Mat22","cA","cB","planePoint","clipPoint","ManifoldType","ContactFeatureType","PointState","ClipVertex","Manifold","ManifoldPoint","ContactID","WorldManifold","ContactEdge","VelocityConstraintPoint","tangent","P","Contact","_a","worldManifold","DEFAULTS","World","oldManifold","Vec3","EdgeShape","e","ChainShape","e1","e2","PolygonShape","ie","center","matrix.detransformVec2","matrix.addVec2","CircleShape","matrix.distSqrVec2","DistanceJoint","vA","vB","FrictionJoint","Mat33","LimitState","RevoluteJoint","PrismaticJoint","translation","perp","GearJoint","MotorJoint","MouseJoint","PulleyJoint","RopeJoint","WeldJoint","WheelJoint","Serializer","options","obj","Testbed","testbed","BoxShape","matrix.retransformVec2","clipPoints1","clipPoints2","normal1","matrix.detransformTransform","maxSeparation","edge1","matrix.rerotVec2","EPAxisType","VertexType","EPAxis","TempPolygon","ReferenceFace","s2","extendStatics","d2","b2","now","self","StageTestbed","Stage.mount","canvas","Stage.POINTER_START","Stage.CanvasTexture","Stage.sprite","Stage.POINTER_MOVE","Stage.POINTER_END","Stage.POINTER_CANCEL","i","WorldStageNode","texture","Stage.canvas","sprite","Stage.layout","Stage.Node"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,MAAI,gBAAgB,SAASA,IAAGC,IAAG;AAC/B,oBAAgB,OAAO,kBAClB,EAAE,WAAW,CAAA,eAAgB,SAAS,SAAUD,IAAGC,IAAG;AAAE,MAAAD,GAAE,YAAYC;AAAA,IAAE,KACzE,SAAUD,IAAGC,IAAG;AAAE,eAAS,KAAKA,GAAG,KAAI,OAAO,UAAU,eAAe,KAAKA,IAAG,CAAC,EAAG,CAAAD,GAAE,CAAC,IAAIC,GAAE,CAAC;AAAA;AACjG,WAAO,cAAcD,IAAGC,EAAC;AAAA,EAC7B;AAEO,WAASC,YAAUF,IAAGC,IAAG;AAC5B,QAAI,OAAOA,OAAM,cAAcA,OAAM;AACjC,YAAM,IAAI,UAAU,yBAAyB,OAAOA,EAAC,IAAI,+BAA+B;AAC5F,kBAAcD,IAAGC,EAAC;AAClB,aAAS,KAAK;AAAE,WAAK,cAAcD;AAAA,IAAI;AACvC,IAAAA,GAAE,YAAYC,OAAM,OAAO,OAAO,OAAOA,EAAC,KAAK,GAAG,YAAYA,GAAE,WAAW,IAAI,GAAI;AAAA,EACvF;AAEO,MAAIE,aAAW,WAAW;AAC7BA,iBAAW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testbed.min.js index cdc0dae2..55ee13cb 100644 --- a/dist/planck-with-testbed.min.js +++ b/dist/planck-with-testbed.min.js @@ -1,6 +1,6 @@ (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports):typeof define==="function"&&define.amd?define(["exports"],factory):(global=typeof globalThis!=="undefined"?globalThis:global||self,factory(global.planck={}))})(this,(function(exports2){"use strict"; /** - * Planck.js v1.1.6 + * Planck.js v1.2.0 * @license The MIT license * @copyright Copyright (c) 2024 Erin Catto, Ali Shakiba * @@ -35,7 +35,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ***************************************************************************** */var extendStatics=function(d2,b2){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d3,b3){d3.__proto__=b3}||function(d3,b3){for(var p in b3)if(Object.prototype.hasOwnProperty.call(b3,p))d3[p]=b3[p]};return extendStatics(d2,b2)};function __extends$a(d2,b2){if(typeof b2!=="function"&&b2!==null)throw new TypeError("Class extends value "+String(b2)+" is not a constructor or null");extendStatics(d2,b2);function __(){this.constructor=d2}d2.prototype=b2===null?Object.create(b2):(__.prototype=b2.prototype,new __)}var __assign$1=function(){__assign$1=Object.assign||function __assign2(t){for(var s2,i=1,n2=arguments.length;i>1;x2|=x2>>2;x2|=x2>>4;x2|=x2>>8;x2|=x2>>16;return x2+1}function isPowerOfTwo(x2){return x2>0&&(x2&x2-1)===0}function mod(num,min,max){if(typeof min==="undefined"){max=1;min=0}else if(typeof max==="undefined"){max=min;min=0}if(max>min){num=(num-min)%(max-min);return num+(num<0?max:min)}else{num=(num-max)%(min-max);return num+(num<=0?min:max)}}function clamp$1(num,min,max){if(nummax){return max}else{return num}}function random$1(min,max){if(typeof min==="undefined"){max=1;min=0}else if(typeof max==="undefined"){max=min;min=0}return min===max?min:math_random$1()*(max-min)+min}var math$1=Object.create(Math);math$1.EPSILON=EPSILON;math$1.isFinite=isFinite;math$1.nextPowerOfTwo=nextPowerOfTwo;math$1.isPowerOfTwo=isPowerOfTwo;math$1.mod=mod;math$1.clamp=clamp$1;math$1.random=random$1;var math_abs$a=Math.abs;var math_sqrt$7=Math.sqrt;var math_max$9=Math.max;var math_min$9=Math.min;var Vec2=function(){function Vec22(x2,y){if(!(this instanceof Vec22)){return new Vec22(x2,y)}if(typeof x2==="undefined"){this.x=0;this.y=0}else if(typeof x2==="object"){this.x=x2.x;this.y=x2.y}else{this.x=x2;this.y=y}}Vec22.prototype._serialize=function(){return{x:this.x,y:this.y}};Vec22._deserialize=function(data){var obj=Object.create(Vec22.prototype);obj.x=data.x;obj.y=data.y;return obj};Vec22.zero=function(){var obj=Object.create(Vec22.prototype);obj.x=0;obj.y=0;return obj};Vec22.neo=function(x2,y){var obj=Object.create(Vec22.prototype);obj.x=x2;obj.y=y;return obj};Vec22.clone=function(v3){return Vec22.neo(v3.x,v3.y)};Vec22.prototype.toString=function(){return JSON.stringify(this)};Vec22.isValid=function(obj){if(obj===null||typeof obj==="undefined"){return false}return Number.isFinite(obj.x)&&Number.isFinite(obj.y)};Vec22.assert=function(o){};Vec22.prototype.clone=function(){return Vec22.clone(this)};Vec22.prototype.setZero=function(){this.x=0;this.y=0;return this};Vec22.prototype.set=function(x2,y){if(typeof x2==="object"){this.x=x2.x;this.y=x2.y}else{this.x=x2;this.y=y}return this};Vec22.prototype.setNum=function(x2,y){this.x=x2;this.y=y;return this};Vec22.prototype.setVec2=function(value){this.x=value.x;this.y=value.y;return this};Vec22.prototype.wSet=function(a2,v3,b2,w){if(typeof b2!=="undefined"||typeof w!=="undefined"){return this.setCombine(a2,v3,b2,w)}else{return this.setMul(a2,v3)}};Vec22.prototype.setCombine=function(a2,v3,b2,w){var x2=a2*v3.x+b2*w.x;var y=a2*v3.y+b2*w.y;this.x=x2;this.y=y;return this};Vec22.prototype.setMul=function(a2,v3){var x2=a2*v3.x;var y=a2*v3.y;this.x=x2;this.y=y;return this};Vec22.prototype.add=function(w){this.x+=w.x;this.y+=w.y;return this};Vec22.prototype.wAdd=function(a2,v3,b2,w){if(typeof b2!=="undefined"||typeof w!=="undefined"){return this.addCombine(a2,v3,b2,w)}else{return this.addMul(a2,v3)}};Vec22.prototype.addCombine=function(a2,v3,b2,w){var x2=a2*v3.x+b2*w.x;var y=a2*v3.y+b2*w.y;this.x+=x2;this.y+=y;return this};Vec22.prototype.addMul=function(a2,v3){var x2=a2*v3.x;var y=a2*v3.y;this.x+=x2;this.y+=y;return this};Vec22.prototype.wSub=function(a2,v3,b2,w){if(typeof b2!=="undefined"||typeof w!=="undefined"){return this.subCombine(a2,v3,b2,w)}else{return this.subMul(a2,v3)}};Vec22.prototype.subCombine=function(a2,v3,b2,w){var x2=a2*v3.x+b2*w.x;var y=a2*v3.y+b2*w.y;this.x-=x2;this.y-=y;return this};Vec22.prototype.subMul=function(a2,v3){var x2=a2*v3.x;var y=a2*v3.y;this.x-=x2;this.y-=y;return this};Vec22.prototype.sub=function(w){this.x-=w.x;this.y-=w.y;return this};Vec22.prototype.mul=function(m){this.x*=m;this.y*=m;return this};Vec22.prototype.length=function(){return Vec22.lengthOf(this)};Vec22.prototype.lengthSquared=function(){return Vec22.lengthSquared(this)};Vec22.prototype.normalize=function(){var length2=this.length();if(length2max*max){var scale=max/math_sqrt$7(lengthSqr);this.x*=scale;this.y*=scale}return this};Vec22.clamp=function(v3,max){var r=Vec22.neo(v3.x,v3.y);r.clamp(max);return r};Vec22.clampVec2=function(v3,min,max){return{x:clamp$1(v3.x,min===null||min===void 0?void 0:min.x,max===null||max===void 0?void 0:max.x),y:clamp$1(v3.y,min===null||min===void 0?void 0:min.y,max===null||max===void 0?void 0:max.y)}};Vec22.scaleFn=function(x2,y){return function(v3){return Vec22.neo(v3.x*x2,v3.y*y)}};Vec22.translateFn=function(x2,y){return function(v3){return Vec22.neo(v3.x+x2,v3.y+y)}};return Vec22}();var math_max$8=Math.max;var math_min$8=Math.min;var AABB=function(){function AABB2(lower,upper){if(!(this instanceof AABB2)){return new AABB2(lower,upper)}this.lowerBound=Vec2.zero();this.upperBound=Vec2.zero();if(typeof lower==="object"){this.lowerBound.setVec2(lower)}if(typeof upper==="object"){this.upperBound.setVec2(upper)}else if(typeof lower==="object"){this.upperBound.setVec2(lower)}}AABB2.prototype.isValid=function(){return AABB2.isValid(this)};AABB2.isValid=function(obj){if(obj===null||typeof obj==="undefined"){return false}return Vec2.isValid(obj.lowerBound)&&Vec2.isValid(obj.upperBound)&&Vec2.sub(obj.upperBound,obj.lowerBound).lengthSquared()>=0};AABB2.assert=function(o){};AABB2.prototype.getCenter=function(){return Vec2.neo((this.lowerBound.x+this.upperBound.x)*.5,(this.lowerBound.y+this.upperBound.y)*.5)};AABB2.prototype.getExtents=function(){return Vec2.neo((this.upperBound.x-this.lowerBound.x)*.5,(this.upperBound.y-this.lowerBound.y)*.5)};AABB2.prototype.getPerimeter=function(){return 2*(this.upperBound.x-this.lowerBound.x+this.upperBound.y-this.lowerBound.y)};AABB2.prototype.combine=function(a2,b2){b2=b2||this;var lowerA=a2.lowerBound;var upperA=a2.upperBound;var lowerB=b2.lowerBound;var upperB=b2.upperBound;var lowerX=math_min$8(lowerA.x,lowerB.x);var lowerY=math_min$8(lowerA.y,lowerB.y);var upperX=math_max$8(upperB.x,upperA.x);var upperY=math_max$8(upperB.y,upperA.y);this.lowerBound.setNum(lowerX,lowerY);this.upperBound.setNum(upperX,upperY)};AABB2.prototype.combinePoints=function(a2,b2){this.lowerBound.setNum(math_min$8(a2.x,b2.x),math_min$8(a2.y,b2.y));this.upperBound.setNum(math_max$8(a2.x,b2.x),math_max$8(a2.y,b2.y))};AABB2.prototype.set=function(aabb){this.lowerBound.setNum(aabb.lowerBound.x,aabb.lowerBound.y);this.upperBound.setNum(aabb.upperBound.x,aabb.upperBound.y)};AABB2.prototype.contains=function(aabb){var result=true;result=result&&this.lowerBound.x<=aabb.lowerBound.x;result=result&&this.lowerBound.y<=aabb.lowerBound.y;result=result&&aabb.upperBound.x<=this.upperBound.x;result=result&&aabb.upperBound.y<=this.upperBound.y;return result};AABB2.prototype.extend=function(value){AABB2.extend(this,value);return this};AABB2.extend=function(out,value){out.lowerBound.x-=value;out.lowerBound.y-=value;out.upperBound.x+=value;out.upperBound.y+=value;return out};AABB2.testOverlap=function(a2,b2){var d1x=b2.lowerBound.x-a2.upperBound.x;var d2x=a2.lowerBound.x-b2.upperBound.x;var d1y=b2.lowerBound.y-a2.upperBound.y;var d2y=a2.lowerBound.y-b2.upperBound.y;if(d1x>0||d1y>0||d2x>0||d2y>0){return false}return true};AABB2.areEqual=function(a2,b2){return Vec2.areEqual(a2.lowerBound,b2.lowerBound)&&Vec2.areEqual(a2.upperBound,b2.upperBound)};AABB2.diff=function(a2,b2){var wD=math_max$8(0,math_min$8(a2.upperBound.x,b2.upperBound.x)-math_max$8(b2.lowerBound.x,a2.lowerBound.x));var hD=math_max$8(0,math_min$8(a2.upperBound.y,b2.upperBound.y)-math_max$8(b2.lowerBound.y,a2.lowerBound.y));var wA=a2.upperBound.x-a2.lowerBound.x;var hA=a2.upperBound.y-a2.lowerBound.y;var wB=b2.upperBound.x-b2.lowerBound.x;var hB=b2.upperBound.y-b2.lowerBound.y;return wA*hA+wB*hB-wD*hD};AABB2.prototype.rayCast=function(output2,input2){var tmin=-Infinity;var tmax=Infinity;var p=input2.p1;var d2=Vec2.sub(input2.p2,input2.p1);var absD=Vec2.abs(d2);var normal3=Vec2.zero();for(var f="x";f!==null;f=f==="x"?"y":null){if(absD.xt2){var temp3=t1;t1=t2;t2=temp3;s2=1}if(t1>tmin){normal3.setZero();normal3[f]=s2;tmin=t1}tmax=math_min$8(tmax,t2);if(tmin>tmax){return false}}}if(tmin<0||input2.maxFraction0){item=this._list.shift()}else{this._createCount++;if(this._hasCreateFn){item=this._createFn()}else{item={}}}this._allocateCount++;if(this._hasAllocateFn){this._allocateFn(item)}return item};Pool2.prototype.release=function(item){if(this._list.length"+this._allocateCount+" <"+this._releaseCount+" -"+this._disposeCount+" ="+this._list.length+"/"+this._max};return Pool2}();var math_abs$9=Math.abs;var math_max$7=Math.max;var TreeNode=function(){function TreeNode2(id){this.aabb=new AABB;this.userData=null;this.parent=null;this.child1=null;this.child2=null;this.height=-1;this.id=id}TreeNode2.prototype.toString=function(){return this.id+": "+this.userData};TreeNode2.prototype.isLeaf=function(){return this.child1==null};return TreeNode2}();var poolTreeNode=new Pool({create:function(){return new TreeNode},release:function(node){node.userData=null;node.parent=null;node.child1=null;node.child2=null;node.height=-1;node.id=void 0}});var DynamicTree=function(){function DynamicTree2(){this.inputPool=new Pool({create:function(){return{}},release:function(stack){}});this.stackPool=new Pool({create:function(){return[]},release:function(stack){stack.length=0}});this.iteratorPool=new Pool({create:function(){return new Iterator},release:function(iterator){iterator.close()}});this.m_root=null;this.m_nodes={};this.m_lastProxyId=0}DynamicTree2.prototype.getUserData=function(id){var node=this.m_nodes[id];return node.userData};DynamicTree2.prototype.getFatAABB=function(id){var node=this.m_nodes[id];return node.aabb};DynamicTree2.prototype.allocateNode=function(){var node=poolTreeNode.allocate();node.id=++this.m_lastProxyId;this.m_nodes[node.id]=node;return node};DynamicTree2.prototype.freeNode=function(node){delete this.m_nodes[node.id];poolTreeNode.release(node)};DynamicTree2.prototype.createProxy=function(aabb,userData){var node=this.allocateNode();node.aabb.set(aabb);AABB.extend(node.aabb,SettingsInternal.aabbExtension);node.userData=userData;node.height=0;this.insertLeaf(node);return node.id};DynamicTree2.prototype.destroyProxy=function(id){var node=this.m_nodes[id];this.removeLeaf(node);this.freeNode(node)};DynamicTree2.prototype.moveProxy=function(id,aabb,d2){var node=this.m_nodes[id];if(node.aabb.contains(aabb)){return false}this.removeLeaf(node);node.aabb.set(aabb);aabb=node.aabb;AABB.extend(aabb,SettingsInternal.aabbExtension);if(d2.x<0){aabb.lowerBound.x+=d2.x*SettingsInternal.aabbMultiplier}else{aabb.upperBound.x+=d2.x*SettingsInternal.aabbMultiplier}if(d2.y<0){aabb.lowerBound.y+=d2.y*SettingsInternal.aabbMultiplier}else{aabb.upperBound.y+=d2.y*SettingsInternal.aabbMultiplier}this.insertLeaf(node);return true};DynamicTree2.prototype.insertLeaf=function(leaf){if(this.m_root==null){this.m_root=leaf;this.m_root.parent=null;return}var leafAABB=leaf.aabb;var index=this.m_root;while(!index.isLeaf()){var child1=index.child1;var child2=index.child2;var area=index.aabb.getPerimeter();var combinedArea=AABB.combinedPerimeter(index.aabb,leafAABB);var cost=2*combinedArea;var inheritanceCost=2*(combinedArea-area);var newArea1=AABB.combinedPerimeter(leafAABB,child1.aabb);var cost1=newArea1+inheritanceCost;if(!child1.isLeaf()){var oldArea=child1.aabb.getPerimeter();cost1-=oldArea}var newArea2=AABB.combinedPerimeter(leafAABB,child2.aabb);var cost2=newArea2+inheritanceCost;if(!child2.isLeaf()){var oldArea=child2.aabb.getPerimeter();cost2-=oldArea}if(cost1){var F=C.child1;var G=C.child2;C.child1=A;C.parent=A.parent;A.parent=C;if(C.parent!=null){if(C.parent.child1===iA){C.parent.child1=C}else{C.parent.child2=C}}else{this.m_root=C}if(F.height>G.height){C.child2=F;A.child2=G;G.parent=A;A.aabb.combine(B.aabb,G.aabb);C.aabb.combine(A.aabb,F.aabb);A.height=1+math_max$7(B.height,G.height);C.height=1+math_max$7(A.height,F.height)}else{C.child2=G;A.child2=F;F.parent=A;A.aabb.combine(B.aabb,F.aabb);C.aabb.combine(A.aabb,G.aabb);A.height=1+math_max$7(B.height,F.height);C.height=1+math_max$7(A.height,G.height)}return C}if(balance<-1){var D=B.child1;var E=B.child2;B.child1=A;B.parent=A.parent;A.parent=B;if(B.parent!=null){if(B.parent.child1===A){B.parent.child1=B}else{B.parent.child2=B}}else{this.m_root=B}if(D.height>E.height){B.child2=D;A.child1=E;E.parent=A;A.aabb.combine(C.aabb,E.aabb);B.aabb.combine(A.aabb,D.aabb);A.height=1+math_max$7(C.height,E.height);B.height=1+math_max$7(A.height,D.height)}else{B.child2=E;A.child1=D;D.parent=A;A.aabb.combine(C.aabb,D.aabb);B.aabb.combine(A.aabb,E.aabb);A.height=1+math_max$7(C.height,D.height);B.height=1+math_max$7(A.height,E.height)}return B}return A};DynamicTree2.prototype.getHeight=function(){if(this.m_root==null){return 0}return this.m_root.height};DynamicTree2.prototype.getAreaRatio=function(){if(this.m_root==null){return 0}var root=this.m_root;var rootArea=root.aabb.getPerimeter();var totalArea=0;var node;var it=this.iteratorPool.allocate().preorder(this.m_root);while(node=it.next()){if(node.height<0){continue}totalArea+=node.aabb.getPerimeter()}this.iteratorPool.release(it);return totalArea/rootArea};DynamicTree2.prototype.computeHeight=function(id){var node;if(typeof id!=="undefined"){node=this.m_nodes[id]}else{node=this.m_root}if(node.isLeaf()){return 0}var height1=this.computeHeight(node.child1.id);var height2=this.computeHeight(node.child2.id);return 1+math_max$7(height1,height2)};DynamicTree2.prototype.validateStructure=function(node){if(node==null){return}if(node===this.m_root);var child1=node.child1;var child2=node.child2;if(node.isLeaf()){return}this.validateStructure(child1);this.validateStructure(child2)};DynamicTree2.prototype.validateMetrics=function(node){if(node==null){return}var child1=node.child1;var child2=node.child2;if(node.isLeaf()){return}child1.height;child2.height;var aabb=new AABB;aabb.combine(child1.aabb,child2.aabb);this.validateMetrics(child1);this.validateMetrics(child2)};DynamicTree2.prototype.validate=function(){return};DynamicTree2.prototype.getMaxBalance=function(){var maxBalance=0;var node;var it=this.iteratorPool.allocate().preorder(this.m_root);while(node=it.next()){if(node.height<=1){continue}var balance=math_abs$9(node.child2.height-node.child1.height);maxBalance=math_max$7(maxBalance,balance)}this.iteratorPool.release(it);return maxBalance};DynamicTree2.prototype.rebuildBottomUp=function(){var nodes=[];var count=0;var node;var it=this.iteratorPool.allocate().preorder(this.m_root);while(node=it.next()){if(node.height<0){continue}if(node.isLeaf()){node.parent=null;nodes[count]=node;++count}else{this.freeNode(node)}}this.iteratorPool.release(it);while(count>1){var minCost=Infinity;var iMin=-1;var jMin=-1;for(var i=0;i0){var node=stack.pop();if(node==null){continue}if(AABB.testOverlap(node.aabb,aabb)){if(node.isLeaf()){var proceed=queryCallback(node.id);if(proceed===false){return}}else{stack.push(node.child1);stack.push(node.child2)}}}this.stackPool.release(stack)};DynamicTree2.prototype.rayCast=function(input2,rayCastCallback){var p1=input2.p1;var p2=input2.p2;var r=Vec2.sub(p2,p1);r.normalize();var v3=Vec2.crossNumVec2(1,r);var abs_v=Vec2.abs(v3);var maxFraction=input2.maxFraction;var segmentAABB=new AABB;var t=Vec2.combine(1-maxFraction,p1,maxFraction,p2);segmentAABB.combinePoints(p1,t);var stack=this.stackPool.allocate();var subInput=this.inputPool.allocate();stack.push(this.m_root);while(stack.length>0){var node=stack.pop();if(node==null){continue}if(AABB.testOverlap(node.aabb,segmentAABB)===false){continue}var c2=node.aabb.getCenter();var h=node.aabb.getExtents();var separation=math_abs$9(Vec2.dot(v3,Vec2.sub(p1,c2)))-Vec2.dot(abs_v,h);if(separation>0){continue}if(node.isLeaf()){subInput.p1=Vec2.clone(input2.p1);subInput.p2=Vec2.clone(input2.p2);subInput.maxFraction=maxFraction;var value=rayCastCallback(subInput,node.id);if(value===0){break}else if(value>0){maxFraction=value;t=Vec2.combine(1-maxFraction,p1,maxFraction,p2);segmentAABB.combinePoints(p1,t)}}else{stack.push(node.child1);stack.push(node.child2)}}this.stackPool.release(stack);this.inputPool.release(subInput)};return DynamicTree2}();var Iterator=function(){function Iterator2(){this.parents=[];this.states=[]}Iterator2.prototype.preorder=function(root){this.parents.length=0;this.parents.push(root);this.states.length=0;this.states.push(0);return this};Iterator2.prototype.next=function(){while(this.parents.length>0){var i=this.parents.length-1;var node=this.parents[i];if(this.states[i]===0){this.states[i]=1;return node}if(this.states[i]===1){this.states[i]=2;if(node.child1){this.parents.push(node.child1);this.states.push(1);return node.child1}}if(this.states[i]===2){this.states[i]=3;if(node.child2){this.parents.push(node.child2);this.states.push(1);return node.child2}}this.parents.pop();this.states.pop()}};Iterator2.prototype.close=function(){this.parents.length=0};return Iterator2}();var math_max$6=Math.max;var math_min$7=Math.min;var BroadPhase=function(){function BroadPhase2(){var _this=this;this.m_tree=new DynamicTree;this.m_moveBuffer=[];this.query=function(aabb,queryCallback){_this.m_tree.query(aabb,queryCallback)};this.queryCallback=function(proxyId){if(proxyId===_this.m_queryProxyId){return true}var proxyIdA=math_min$7(proxyId,_this.m_queryProxyId);var proxyIdB=math_max$6(proxyId,_this.m_queryProxyId);var userDataA=_this.m_tree.getUserData(proxyIdA);var userDataB=_this.m_tree.getUserData(proxyIdB);_this.m_callback(userDataA,userDataB);return true}}BroadPhase2.prototype.getUserData=function(proxyId){return this.m_tree.getUserData(proxyId)};BroadPhase2.prototype.testOverlap=function(proxyIdA,proxyIdB){var aabbA=this.m_tree.getFatAABB(proxyIdA);var aabbB=this.m_tree.getFatAABB(proxyIdB);return AABB.testOverlap(aabbA,aabbB)};BroadPhase2.prototype.getFatAABB=function(proxyId){return this.m_tree.getFatAABB(proxyId)};BroadPhase2.prototype.getProxyCount=function(){return this.m_moveBuffer.length};BroadPhase2.prototype.getTreeHeight=function(){return this.m_tree.getHeight()};BroadPhase2.prototype.getTreeBalance=function(){return this.m_tree.getMaxBalance()};BroadPhase2.prototype.getTreeQuality=function(){return this.m_tree.getAreaRatio()};BroadPhase2.prototype.rayCast=function(input2,rayCastCallback){this.m_tree.rayCast(input2,rayCastCallback)};BroadPhase2.prototype.shiftOrigin=function(newOrigin){this.m_tree.shiftOrigin(newOrigin)};BroadPhase2.prototype.createProxy=function(aabb,userData){var proxyId=this.m_tree.createProxy(aabb,userData);this.bufferMove(proxyId);return proxyId};BroadPhase2.prototype.destroyProxy=function(proxyId){this.unbufferMove(proxyId);this.m_tree.destroyProxy(proxyId)};BroadPhase2.prototype.moveProxy=function(proxyId,aabb,displacement2){var changed=this.m_tree.moveProxy(proxyId,aabb,displacement2);if(changed){this.bufferMove(proxyId)}};BroadPhase2.prototype.touchProxy=function(proxyId){this.bufferMove(proxyId)};BroadPhase2.prototype.bufferMove=function(proxyId){this.m_moveBuffer.push(proxyId)};BroadPhase2.prototype.unbufferMove=function(proxyId){for(var i=0;i0){this.m_queryProxyId=this.m_moveBuffer.pop();if(this.m_queryProxyId===null){continue}var fatAABB=this.m_tree.getFatAABB(this.m_queryProxyId);this.m_tree.query(fatAABB,this.queryCallback)}};return BroadPhase2}();var math_sin$2=Math.sin;var math_cos$2=Math.cos;var math_sqrt$6=Math.sqrt;function vec2(x2,y){return{x:x2,y:y}}function rotation(angle){return{s:math_sin$2(angle),c:math_cos$2(angle)}}function setVec2(out,x2,y){out.x=x2;out.y=y;return out}function copyVec2(out,w){out.x=w.x;out.y=w.y;return out}function zeroVec2(out){out.x=0;out.y=0;return out}function negVec2(out){out.x=-out.x;out.y=-out.y;return out}function plusVec2(out,w){out.x+=w.x;out.y+=w.y;return out}function addVec2(out,v3,w){out.x=v3.x+w.x;out.y=v3.x+w.y;return out}function minusVec2(out,w){out.x-=w.x;out.y-=w.y;return out}function subVec2(out,v3,w){out.x=v3.x-w.x;out.y=v3.y-w.y;return out}function mulVec2(out,m){out.x*=m;out.y*=m;return out}function scaleVec2(out,m,w){out.x=m*w.x;out.y=m*w.y;return out}function plusScaleVec2(out,m,w){out.x+=m*w.x;out.y+=m*w.y;return out}function minusScaleVec2(out,m,w){out.x-=m*w.x;out.y-=m*w.y;return out}function combine2Vec2(out,am,a2,bm,b2){out.x=am*a2.x+bm*b2.x;out.y=am*a2.y+bm*b2.y;return out}function combine3Vec2(out,am,a2,bm,b2,cm,c2){out.x=am*a2.x+bm*b2.x+cm*c2.x;out.y=am*a2.y+bm*b2.y+cm*c2.y;return out}function normalizeVec2Length(out){var length2=math_sqrt$6(out.x*out.x+out.y*out.y);if(length2!==0){var invLength=1/length2;out.x*=invLength;out.y*=invLength}return length2}function normalizeVec2(out){var length2=math_sqrt$6(out.x*out.x+out.y*out.y);if(length2>0){var invLength=1/length2;out.x*=invLength;out.y*=invLength}return out}function crossVec2Num(out,v3,w){var x2=w*v3.y;var y=-w*v3.x;out.x=x2;out.y=y;return out}function crossNumVec2(out,w,v3){var x2=-w*v3.y;var y=w*v3.x;out.x=x2;out.y=y;return out}function crossVec2Vec2(a2,b2){return a2.x*b2.y-a2.y*b2.x}function dotVec2(a2,b2){return a2.x*b2.x+a2.y*b2.y}function lengthSqrVec2(a2){return a2.x*a2.x+a2.y*a2.y}function distVec2(a2,b2){var dx=a2.x-b2.x;var dy=a2.y-b2.y;return math_sqrt$6(dx*dx+dy*dy)}function distSqrVec2(a2,b2){var dx=a2.x-b2.x;var dy=a2.y-b2.y;return dx*dx+dy*dy}function setRotAngle(out,a2){out.c=math_cos$2(a2);out.s=math_sin$2(a2);return out}function rotVec2(out,q,v3){out.x=q.c*v3.x-q.s*v3.y;out.y=q.s*v3.x+q.c*v3.y;return out}function derotVec2(out,q,v3){var x2=q.c*v3.x+q.s*v3.y;var y=-q.s*v3.x+q.c*v3.y;out.x=x2;out.y=y;return out}function rerotVec2(out,before,after,v3){var x0=before.c*v3.x+before.s*v3.y;var y0=-before.s*v3.x+before.c*v3.y;var x2=after.c*x0-after.s*y0;var y=after.s*x0+after.c*y0;out.x=x2;out.y=y;return out}function transform(x2,y,a2){return{p:vec2(x2,y),q:rotation(a2)}}function copyTransform(out,transform2){out.p.x=transform2.p.x;out.p.y=transform2.p.y;out.q.s=transform2.q.s;out.q.c=transform2.q.c;return out}function transformVec2(out,xf2,v3){var x2=xf2.q.c*v3.x-xf2.q.s*v3.y+xf2.p.x;var y=xf2.q.s*v3.x+xf2.q.c*v3.y+xf2.p.y;out.x=x2;out.y=y;return out}function detransformVec2(out,xf2,v3){var px=v3.x-xf2.p.x;var py=v3.y-xf2.p.y;var x2=xf2.q.c*px+xf2.q.s*py;var y=-xf2.q.s*px+xf2.q.c*py;out.x=x2;out.y=y;return out}function retransformVec2(out,from,to,v3){var x0=from.q.c*v3.x-from.q.s*v3.y+from.p.x;var y0=from.q.s*v3.x+from.q.c*v3.y+from.p.y;var px=x0-to.p.x;var py=y0-to.p.y;var x2=to.q.c*px+to.q.s*py;var y=-to.q.s*px+to.q.c*py;out.x=x2;out.y=y;return out}function detransformTransform(out,a2,b2){var c2=a2.q.c*b2.q.c+a2.q.s*b2.q.s;var s2=a2.q.c*b2.q.s-a2.q.s*b2.q.c;var x2=a2.q.c*(b2.p.x-a2.p.x)+a2.q.s*(b2.p.y-a2.p.y);var y=-a2.q.s*(b2.p.x-a2.p.x)+a2.q.c*(b2.p.y-a2.p.y);out.q.c=c2;out.q.s=s2;out.p.x=x2;out.p.y=y;return out}var math_sin$1=Math.sin;var math_cos$1=Math.cos;var math_atan2$2=Math.atan2;var Rot=function(){function Rot2(angle){if(!(this instanceof Rot2)){return new Rot2(angle)}if(typeof angle==="number"){this.setAngle(angle)}else if(typeof angle==="object"){this.setRot(angle)}else{this.setIdentity()}}Rot2.neo=function(angle){var obj=Object.create(Rot2.prototype);obj.setAngle(angle);return obj};Rot2.clone=function(rot){var obj=Object.create(Rot2.prototype);obj.s=rot.s;obj.c=rot.c;return obj};Rot2.identity=function(){var obj=Object.create(Rot2.prototype);obj.s=0;obj.c=1;return obj};Rot2.isValid=function(obj){if(obj===null||typeof obj==="undefined"){return false}return Number.isFinite(obj.s)&&Number.isFinite(obj.c)};Rot2.assert=function(o){};Rot2.prototype.setIdentity=function(){this.s=0;this.c=1};Rot2.prototype.set=function(angle){if(typeof angle==="object"){this.s=angle.s;this.c=angle.c}else{this.s=math_sin$1(angle);this.c=math_cos$1(angle)}};Rot2.prototype.setRot=function(angle){this.s=angle.s;this.c=angle.c};Rot2.prototype.setAngle=function(angle){this.s=math_sin$1(angle);this.c=math_cos$1(angle)};Rot2.prototype.getAngle=function(){return math_atan2$2(this.s,this.c)};Rot2.prototype.getXAxis=function(){return Vec2.neo(this.c,this.s)};Rot2.prototype.getYAxis=function(){return Vec2.neo(-this.s,this.c)};Rot2.mul=function(rot,m){if("c"in m&&"s"in m){var qr=Rot2.identity();qr.s=rot.s*m.c+rot.c*m.s;qr.c=rot.c*m.c-rot.s*m.s;return qr}else if("x"in m&&"y"in m){return Vec2.neo(rot.c*m.x-rot.s*m.y,rot.s*m.x+rot.c*m.y)}};Rot2.mulRot=function(rot,m){var qr=Rot2.identity();qr.s=rot.s*m.c+rot.c*m.s;qr.c=rot.c*m.c-rot.s*m.s;return qr};Rot2.mulVec2=function(rot,m){return Vec2.neo(rot.c*m.x-rot.s*m.y,rot.s*m.x+rot.c*m.y)};Rot2.mulSub=function(rot,v3,w){var x2=rot.c*(v3.x-w.x)-rot.s*(v3.y-w.y);var y=rot.s*(v3.x-w.x)+rot.c*(v3.y-w.y);return Vec2.neo(x2,y)};Rot2.mulT=function(rot,m){if("c"in m&&"s"in m){var qr=Rot2.identity();qr.s=rot.c*m.s-rot.s*m.c;qr.c=rot.c*m.c+rot.s*m.s;return qr}else if("x"in m&&"y"in m){return Vec2.neo(rot.c*m.x+rot.s*m.y,-rot.s*m.x+rot.c*m.y)}};Rot2.mulTRot=function(rot,m){var qr=Rot2.identity();qr.s=rot.c*m.s-rot.s*m.c;qr.c=rot.c*m.c+rot.s*m.s;return qr};Rot2.mulTVec2=function(rot,m){return Vec2.neo(rot.c*m.x+rot.s*m.y,-rot.s*m.x+rot.c*m.y)};return Rot2}();var math_atan2$1=Math.atan2;var math_PI$6=Math.PI;var temp$7=vec2(0,0);var Sweep=function(){function Sweep2(){this.localCenter=Vec2.zero();this.c=Vec2.zero();this.a=0;this.alpha0=0;this.c0=Vec2.zero();this.a0=0}Sweep2.prototype.recycle=function(){zeroVec2(this.localCenter);zeroVec2(this.c);this.a=0;this.alpha0=0;zeroVec2(this.c0);this.a0=0};Sweep2.prototype.setTransform=function(xf2){transformVec2(temp$7,xf2,this.localCenter);copyVec2(this.c,temp$7);copyVec2(this.c0,temp$7);this.a=this.a0=math_atan2$1(xf2.q.s,xf2.q.c)};Sweep2.prototype.setLocalCenter=function(localCenter2,xf2){copyVec2(this.localCenter,localCenter2);transformVec2(temp$7,xf2,this.localCenter);copyVec2(this.c,temp$7);copyVec2(this.c0,temp$7)};Sweep2.prototype.getTransform=function(xf2,beta){if(beta===void 0){beta=0}setRotAngle(xf2.q,(1-beta)*this.a0+beta*this.a);combine2Vec2(xf2.p,1-beta,this.c0,beta,this.c);minusVec2(xf2.p,rotVec2(temp$7,xf2.q,this.localCenter))};Sweep2.prototype.advance=function(alpha){var beta=(alpha-this.alpha0)/(1-this.alpha0);combine2Vec2(this.c0,beta,this.c,1-beta,this.c0);this.a0=beta*this.a+(1-beta)*this.a0;this.alpha0=alpha};Sweep2.prototype.forward=function(){this.a0=this.a;copyVec2(this.c0,this.c)};Sweep2.prototype.normalize=function(){var a0=mod(this.a0,-math_PI$6,+math_PI$6);this.a-=this.a0-a0;this.a0=a0};Sweep2.prototype.set=function(that){copyVec2(this.localCenter,that.localCenter);copyVec2(this.c,that.c);this.a=that.a;this.alpha0=that.alpha0;copyVec2(this.c0,that.c0);this.a0=that.a0};return Sweep2}();var Transform=function(){function Transform2(position,rotation2){if(!(this instanceof Transform2)){return new Transform2(position,rotation2)}this.p=Vec2.zero();this.q=Rot.identity();if(typeof position!=="undefined"){this.p.setVec2(position)}if(typeof rotation2!=="undefined"){this.q.setAngle(rotation2)}}Transform2.clone=function(xf2){var obj=Object.create(Transform2.prototype);obj.p=Vec2.clone(xf2.p);obj.q=Rot.clone(xf2.q);return obj};Transform2.neo=function(position,rotation2){var obj=Object.create(Transform2.prototype);obj.p=Vec2.clone(position);obj.q=Rot.clone(rotation2);return obj};Transform2.identity=function(){var obj=Object.create(Transform2.prototype);obj.p=Vec2.zero();obj.q=Rot.identity();return obj};Transform2.prototype.setIdentity=function(){this.p.setZero();this.q.setIdentity()};Transform2.prototype.set=function(a2,b2){if(typeof b2==="undefined"){this.p.set(a2.p);this.q.set(a2.q)}else{this.p.set(a2);this.q.set(b2)}};Transform2.prototype.setNum=function(position,rotation2){this.p.setVec2(position);this.q.setAngle(rotation2)};Transform2.prototype.setTransform=function(xf2){this.p.setVec2(xf2.p);this.q.setRot(xf2.q)};Transform2.isValid=function(obj){if(obj===null||typeof obj==="undefined"){return false}return Vec2.isValid(obj.p)&&Rot.isValid(obj.q)};Transform2.assert=function(o){};Transform2.mul=function(a2,b2){if(Array.isArray(b2)){var arr=[];for(var i=0;i0}var collideA=(that.m_filterMaskBits&this.m_filterCategoryBits)!==0;var collideB=(that.m_filterCategoryBits&this.m_filterMaskBits)!==0;var collide=collideA&&collideB;return collide};return Fixture2}();var STATIC="static";var KINEMATIC="kinematic";var DYNAMIC="dynamic";var oldCenter=vec2(0,0);var localCenter=vec2(0,0);var shift=vec2(0,0);var temp$6=vec2(0,0);var xf$2=transform(0,0,0);var BodyDefDefault={type:STATIC,position:Vec2.zero(),angle:0,linearVelocity:Vec2.zero(),angularVelocity:0,linearDamping:0,angularDamping:0,fixedRotation:false,bullet:false,gravityScale:1,allowSleep:true,awake:true,active:true,userData:null};var Body=function(){function Body2(world,def){this.style={};this.appData={};def=options(def,BodyDefDefault);this.m_world=world;this.m_awakeFlag=def.awake;this.m_autoSleepFlag=def.allowSleep;this.m_bulletFlag=def.bullet;this.m_fixedRotationFlag=def.fixedRotation;this.m_activeFlag=def.active;this.m_islandFlag=false;this.m_toiFlag=false;this.m_userData=def.userData;this.m_type=def.type;if(this.m_type==DYNAMIC){this.m_mass=1;this.m_invMass=1}else{this.m_mass=0;this.m_invMass=0}this.m_I=0;this.m_invI=0;this.m_xf=Transform.identity();this.m_xf.p.setVec2(def.position);this.m_xf.q.setAngle(def.angle);this.m_sweep=new Sweep;this.m_sweep.setTransform(this.m_xf);this.c_velocity=new Velocity;this.c_position=new Position;this.m_force=Vec2.zero();this.m_torque=0;this.m_linearVelocity=Vec2.clone(def.linearVelocity);this.m_angularVelocity=def.angularVelocity;this.m_linearDamping=def.linearDamping;this.m_angularDamping=def.angularDamping;this.m_gravityScale=def.gravityScale;this.m_sleepTime=0;this.m_jointList=null;this.m_contactList=null;this.m_fixtureList=null;this.m_prev=null;this.m_next=null;this.m_destroyed=false;if(typeof def.style==="object"&&def.style!==null){this.style=def.style}}Body2.prototype._serialize=function(){var fixtures=[];for(var f=this.m_fixtureList;f;f=f.m_next){fixtures.push(f)}return{type:this.m_type,bullet:this.m_bulletFlag,position:this.m_xf.p,angle:this.m_xf.q.getAngle(),linearVelocity:this.m_linearVelocity,angularVelocity:this.m_angularVelocity,fixtures:fixtures}};Body2._deserialize=function(data,world,restore){var body=new Body2(world,data);if(data.fixtures){for(var i=data.fixtures.length-1;i>=0;i--){var fixture=restore(Fixture,data.fixtures[i],body);body._addFixture(fixture)}}return body};Body2.prototype.isWorldLocked=function(){return this.m_world&&this.m_world.isLocked()?true:false};Body2.prototype.getWorld=function(){return this.m_world};Body2.prototype.getNext=function(){return this.m_next};Body2.prototype.setUserData=function(data){this.m_userData=data};Body2.prototype.getUserData=function(){return this.m_userData};Body2.prototype.getFixtureList=function(){return this.m_fixtureList};Body2.prototype.getJointList=function(){return this.m_jointList};Body2.prototype.getContactList=function(){return this.m_contactList};Body2.prototype.isStatic=function(){return this.m_type==STATIC};Body2.prototype.isDynamic=function(){return this.m_type==DYNAMIC};Body2.prototype.isKinematic=function(){return this.m_type==KINEMATIC};Body2.prototype.setStatic=function(){this.setType(STATIC);return this};Body2.prototype.setDynamic=function(){this.setType(DYNAMIC);return this};Body2.prototype.setKinematic=function(){this.setType(KINEMATIC);return this};Body2.prototype.getType=function(){return this.m_type};Body2.prototype.setType=function(type){if(this.isWorldLocked()==true){return}if(this.m_type==type){return}this.m_type=type;this.resetMassData();if(this.m_type==STATIC){this.m_linearVelocity.setZero();this.m_angularVelocity=0;this.m_sweep.forward();this.synchronizeFixtures()}this.setAwake(true);this.m_force.setZero();this.m_torque=0;var ce=this.m_contactList;while(ce){var ce0=ce;ce=ce.next;this.m_world.destroyContact(ce0.contact)}this.m_contactList=null;var broadPhase=this.m_world.m_broadPhase;for(var f=this.m_fixtureList;f;f=f.m_next){for(var i=0;i0){this.setAwake(true)}this.m_linearVelocity.setVec2(v3)};Body2.prototype.getAngularVelocity=function(){return this.m_angularVelocity};Body2.prototype.setAngularVelocity=function(w){if(this.m_type==STATIC){return}if(w*w>0){this.setAwake(true)}this.m_angularVelocity=w};Body2.prototype.getLinearDamping=function(){return this.m_linearDamping};Body2.prototype.setLinearDamping=function(linearDamping){this.m_linearDamping=linearDamping};Body2.prototype.getAngularDamping=function(){return this.m_angularDamping};Body2.prototype.setAngularDamping=function(angularDamping){this.m_angularDamping=angularDamping};Body2.prototype.getGravityScale=function(){return this.m_gravityScale};Body2.prototype.setGravityScale=function(scale){this.m_gravityScale=scale};Body2.prototype.getMass=function(){return this.m_mass};Body2.prototype.getInertia=function(){return this.m_I+this.m_mass*Vec2.dot(this.m_sweep.localCenter,this.m_sweep.localCenter)};Body2.prototype.getMassData=function(data){data.mass=this.m_mass;data.I=this.getInertia();copyVec2(data.center,this.m_sweep.localCenter)};Body2.prototype.resetMassData=function(){this.m_mass=0;this.m_invMass=0;this.m_I=0;this.m_invI=0;zeroVec2(this.m_sweep.localCenter);if(this.isStatic()||this.isKinematic()){copyVec2(this.m_sweep.c0,this.m_xf.p);copyVec2(this.m_sweep.c,this.m_xf.p);this.m_sweep.a0=this.m_sweep.a;return}zeroVec2(localCenter);for(var f=this.m_fixtureList;f;f=f.m_next){if(f.m_density==0){continue}var massData={mass:0,center:vec2(0,0),I:0};f.getMassData(massData);this.m_mass+=massData.mass;plusScaleVec2(localCenter,massData.mass,massData.center);this.m_I+=massData.I}if(this.m_mass>0){this.m_invMass=1/this.m_mass;scaleVec2(localCenter,this.m_invMass,localCenter)}else{this.m_mass=1;this.m_invMass=1}if(this.m_I>0&&this.m_fixedRotationFlag==false){this.m_I-=this.m_mass*dotVec2(localCenter,localCenter);this.m_invI=1/this.m_I}else{this.m_I=0;this.m_invI=0}copyVec2(oldCenter,this.m_sweep.c);this.m_sweep.setLocalCenter(localCenter,this.m_xf);subVec2(shift,this.m_sweep.c,oldCenter);crossNumVec2(temp$6,this.m_angularVelocity,shift);plusVec2(this.m_linearVelocity,temp$6)};Body2.prototype.setMassData=function(massData){if(this.isWorldLocked()==true){return}if(this.m_type!=DYNAMIC){return}this.m_invMass=0;this.m_I=0;this.m_invI=0;this.m_mass=massData.mass;if(this.m_mass<=0){this.m_mass=1}this.m_invMass=1/this.m_mass;if(massData.I>0&&this.m_fixedRotationFlag==false){this.m_I=massData.I-this.m_mass*dotVec2(massData.center,massData.center);this.m_invI=1/this.m_I}copyVec2(oldCenter,this.m_sweep.c);this.m_sweep.setLocalCenter(massData.center,this.m_xf);subVec2(shift,this.m_sweep.c,oldCenter);crossNumVec2(temp$6,this.m_angularVelocity,shift);plusVec2(this.m_linearVelocity,temp$6)};Body2.prototype.applyForce=function(force,point2,wake){if(wake===void 0){wake=true}if(this.m_type!=DYNAMIC){return}if(wake&&this.m_awakeFlag==false){this.setAwake(true)}if(this.m_awakeFlag){this.m_force.add(force);this.m_torque+=Vec2.crossVec2Vec2(Vec2.sub(point2,this.m_sweep.c),force)}};Body2.prototype.applyForceToCenter=function(force,wake){if(wake===void 0){wake=true}if(this.m_type!=DYNAMIC){return}if(wake&&this.m_awakeFlag==false){this.setAwake(true)}if(this.m_awakeFlag){this.m_force.add(force)}};Body2.prototype.applyTorque=function(torque,wake){if(wake===void 0){wake=true}if(this.m_type!=DYNAMIC){return}if(wake&&this.m_awakeFlag==false){this.setAwake(true)}if(this.m_awakeFlag){this.m_torque+=torque}};Body2.prototype.applyLinearImpulse=function(impulse,point2,wake){if(wake===void 0){wake=true}if(this.m_type!=DYNAMIC){return}if(wake&&this.m_awakeFlag==false){this.setAwake(true)}if(this.m_awakeFlag){this.m_linearVelocity.addMul(this.m_invMass,impulse);this.m_angularVelocity+=this.m_invI*Vec2.crossVec2Vec2(Vec2.sub(point2,this.m_sweep.c),impulse)}};Body2.prototype.applyAngularImpulse=function(impulse,wake){if(wake===void 0){wake=true}if(this.m_type!=DYNAMIC){return}if(wake&&this.m_awakeFlag==false){this.setAwake(true)}if(this.m_awakeFlag){this.m_angularVelocity+=this.m_invI*impulse}};Body2.prototype.shouldCollide=function(that){if(this.m_type!=DYNAMIC&&that.m_type!=DYNAMIC){return false}for(var jn=this.m_jointList;jn;jn=jn.next){if(jn.other==that){if(jn.joint.m_collideConnected==false){return false}}}return true};Body2.prototype._addFixture=function(fixture){if(this.isWorldLocked()==true){return null}if(this.m_activeFlag){var broadPhase=this.m_world.m_broadPhase;fixture.createProxies(broadPhase,this.m_xf)}fixture.m_next=this.m_fixtureList;this.m_fixtureList=fixture;if(fixture.m_density>0){this.resetMassData()}this.m_world.m_newFixture=true;return fixture};Body2.prototype.createFixture=function(shape,fixdef){if(this.isWorldLocked()==true){return null}var fixture=new Fixture(this,shape,fixdef);this._addFixture(fixture);return fixture};Body2.prototype.destroyFixture=function(fixture){if(this.isWorldLocked()==true){return}if(this.m_fixtureList===fixture){this.m_fixtureList=fixture.m_next}else{var node=this.m_fixtureList;while(node!=null){if(node.m_next===fixture){node.m_next=fixture.m_next;break}node=node.m_next}}var edge=this.m_contactList;while(edge){var c2=edge.contact;edge=edge.next;var fixtureA=c2.getFixtureA();var fixtureB=c2.getFixtureB();if(fixture==fixtureA||fixture==fixtureB){this.m_world.destroyContact(c2)}}if(this.m_activeFlag){var broadPhase=this.m_world.m_broadPhase;fixture.destroyProxies(broadPhase)}fixture.m_body=null;fixture.m_next=null;this.m_world.publish("remove-fixture",fixture);this.resetMassData()};Body2.prototype.getWorldPoint=function(localPoint){return Transform.mulVec2(this.m_xf,localPoint)};Body2.prototype.getWorldVector=function(localVector){return Rot.mulVec2(this.m_xf.q,localVector)};Body2.prototype.getLocalPoint=function(worldPoint){return Transform.mulTVec2(this.m_xf,worldPoint)};Body2.prototype.getLocalVector=function(worldVector){return Rot.mulTVec2(this.m_xf.q,worldVector)};Body2.STATIC="static";Body2.KINEMATIC="kinematic";Body2.DYNAMIC="dynamic";return Body2}();var JointEdge=function(){function JointEdge2(){this.other=null;this.joint=null;this.prev=null;this.next=null}return JointEdge2}();var Joint=function(){function Joint2(def,bodyA,bodyB){this.m_type="unknown-joint";this.m_prev=null;this.m_next=null;this.m_edgeA=new JointEdge;this.m_edgeB=new JointEdge;this.m_islandFlag=false;this.style={};this.appData={};bodyA="bodyA"in def?def.bodyA:bodyA;bodyB="bodyB"in def?def.bodyB:bodyB;this.m_bodyA=bodyA;this.m_bodyB=bodyB;this.m_collideConnected=!!def.collideConnected;this.m_userData=def.userData;if(typeof def.style==="object"&&def.style!==null){this.style=def.style}}Joint2.prototype.isActive=function(){return this.m_bodyA.isActive()&&this.m_bodyB.isActive()};Joint2.prototype.getType=function(){return this.m_type};Joint2.prototype.getBodyA=function(){return this.m_bodyA};Joint2.prototype.getBodyB=function(){return this.m_bodyB};Joint2.prototype.getNext=function(){return this.m_next};Joint2.prototype.getUserData=function(){return this.m_userData};Joint2.prototype.setUserData=function(data){this.m_userData=data};Joint2.prototype.getCollideConnected=function(){return this.m_collideConnected};Joint2.prototype.shiftOrigin=function(newOrigin){};Joint2.prototype._resetAnchors=function(def){return this._reset(def)};return Joint2}();var stats$1={gjkCalls:0,gjkIters:0,gjkMaxIters:0,toiTime:0,toiMaxTime:0,toiCalls:0,toiIters:0,toiMaxIters:0,toiRootIters:0,toiMaxRootIters:0,toString:function(newline){newline=typeof newline==="string"?newline:"\n";var string="";for(var name_1 in this){if(typeof this[name_1]!=="function"&&typeof this[name_1]!=="object"){string+=name_1+": "+this[name_1]+newline}}return string}};var now=function(){return Date.now()};var diff=function(time){return Date.now()-time};const Timer={now:now,diff:diff};var math_max$5=Math.max;var temp$5=vec2(0,0);var normal$4=vec2(0,0);var e12=vec2(0,0);var e13=vec2(0,0);var e23=vec2(0,0);var temp1=vec2(0,0);var temp2=vec2(0,0);stats$1.gjkCalls=0;stats$1.gjkIters=0;stats$1.gjkMaxIters=0;var DistanceInput=function(){function DistanceInput2(){this.proxyA=new DistanceProxy;this.proxyB=new DistanceProxy;this.transformA=Transform.identity();this.transformB=Transform.identity();this.useRadii=false}DistanceInput2.prototype.recycle=function(){this.proxyA.recycle();this.proxyB.recycle();this.transformA.setIdentity();this.transformB.setIdentity();this.useRadii=false};return DistanceInput2}();var DistanceOutput=function(){function DistanceOutput2(){this.pointA=vec2(0,0);this.pointB=vec2(0,0);this.distance=0;this.iterations=0}DistanceOutput2.prototype.recycle=function(){zeroVec2(this.pointA);zeroVec2(this.pointB);this.distance=0;this.iterations=0};return DistanceOutput2}();var SimplexCache=function(){function SimplexCache2(){this.metric=0;this.indexA=[];this.indexB=[];this.count=0}SimplexCache2.prototype.recycle=function(){this.metric=0;this.indexA.length=0;this.indexB.length=0;this.count=0};return SimplexCache2}();var Distance=function(output2,cache2,input2){++stats$1.gjkCalls;var proxyA=input2.proxyA;var proxyB=input2.proxyB;var xfA2=input2.transformA;var xfB2=input2.transformB;simplex.recycle();simplex.readCache(cache2,proxyA,xfA2,proxyB,xfB2);var vertices=simplex.m_v;var k_maxIters=SettingsInternal.maxDistanceIterations;var saveA=[];var saveB=[];var saveCount=0;var iter=0;while(iterrA2+rB2&&output2.distance>EPSILON){output2.distance-=rA2+rB2;subVec2(normal$4,output2.pointB,output2.pointA);normalizeVec2(normal$4);plusScaleVec2(output2.pointA,rA2,normal$4);minusScaleVec2(output2.pointB,rB2,normal$4)}else{var p=subVec2(temp$5,output2.pointA,output2.pointB);copyVec2(output2.pointA,p);copyVec2(output2.pointB,p);output2.distance=0}}};var DistanceProxy=function(){function DistanceProxy2(){this.m_vertices=[];this.m_count=0;this.m_radius=0}DistanceProxy2.prototype.recycle=function(){this.m_vertices.length=0;this.m_count=0;this.m_radius=0};DistanceProxy2.prototype.getVertexCount=function(){return this.m_count};DistanceProxy2.prototype.getVertex=function(index){return this.m_vertices[index]};DistanceProxy2.prototype.getSupport=function(d2){var bestIndex=-1;var bestValue=-Infinity;for(var i=0;ibestValue){bestIndex=i;bestValue=value}}return bestIndex};DistanceProxy2.prototype.getSupportVertex=function(d2){return this.m_vertices[this.getSupport(d2)]};DistanceProxy2.prototype.set=function(shape,index){shape.computeDistanceProxy(this,index)};DistanceProxy2.prototype.setVertices=function(vertices,count,radius){this.m_vertices=vertices;this.m_count=count;this.m_radius=radius};return DistanceProxy2}();var SimplexVertex=function(){function SimplexVertex2(){this.wA=vec2(0,0);this.indexA=0;this.wB=vec2(0,0);this.indexB=0;this.w=vec2(0,0);this.a=0}SimplexVertex2.prototype.recycle=function(){this.indexA=0;this.indexB=0;zeroVec2(this.wA);zeroVec2(this.wB);zeroVec2(this.w);this.a=0};SimplexVertex2.prototype.set=function(v3){this.indexA=v3.indexA;this.indexB=v3.indexB;copyVec2(this.wA,v3.wA);copyVec2(this.wB,v3.wB);copyVec2(this.w,v3.w);this.a=v3.a};return SimplexVertex2}();var searchDirection_reuse=vec2(0,0);var closestPoint_reuse=vec2(0,0);var Simplex=function(){function Simplex2(){this.m_v1=new SimplexVertex;this.m_v2=new SimplexVertex;this.m_v3=new SimplexVertex;this.m_v=[this.m_v1,this.m_v2,this.m_v3]}Simplex2.prototype.recycle=function(){this.m_v1.recycle();this.m_v2.recycle();this.m_v3.recycle();this.m_count=0};Simplex2.prototype.toString=function(){if(this.m_count===3){return["+"+this.m_count,this.m_v1.a,this.m_v1.wA.x,this.m_v1.wA.y,this.m_v1.wB.x,this.m_v1.wB.y,this.m_v2.a,this.m_v2.wA.x,this.m_v2.wA.y,this.m_v2.wB.x,this.m_v2.wB.y,this.m_v3.a,this.m_v3.wA.x,this.m_v3.wA.y,this.m_v3.wB.x,this.m_v3.wB.y].toString()}else if(this.m_count===2){return["+"+this.m_count,this.m_v1.a,this.m_v1.wA.x,this.m_v1.wA.y,this.m_v1.wB.x,this.m_v1.wB.y,this.m_v2.a,this.m_v2.wA.x,this.m_v2.wA.y,this.m_v2.wB.x,this.m_v2.wB.y].toString()}else if(this.m_count===1){return["+"+this.m_count,this.m_v1.a,this.m_v1.wA.x,this.m_v1.wA.y,this.m_v1.wB.x,this.m_v1.wB.y].toString()}else{return"+"+this.m_count}};Simplex2.prototype.readCache=function(cache2,proxyA,transformA,proxyB,transformB){this.m_count=cache2.count;for(var i=0;i1){var metric1=cache2.metric;var metric2=this.getMetric();if(metric2<.5*metric1||2*metric10){return setVec2(searchDirection_reuse,-e12.y,e12.x)}else{return setVec2(searchDirection_reuse,e12.y,-e12.x)}}default:return zeroVec2(searchDirection_reuse)}};Simplex2.prototype.getClosestPoint=function(){var v13=this.m_v1;var v22=this.m_v2;this.m_v3;switch(this.m_count){case 0:return zeroVec2(closestPoint_reuse);case 1:return copyVec2(closestPoint_reuse,v13.w);case 2:return combine2Vec2(closestPoint_reuse,v13.a,v13.w,v22.a,v22.w);case 3:return zeroVec2(closestPoint_reuse);default:return zeroVec2(closestPoint_reuse)}};Simplex2.prototype.getWitnessPoints=function(pA2,pB2){var v13=this.m_v1;var v22=this.m_v2;var v3=this.m_v3;switch(this.m_count){case 0:break;case 1:copyVec2(pA2,v13.wA);copyVec2(pB2,v13.wB);break;case 2:combine2Vec2(pA2,v13.a,v13.wA,v22.a,v22.wA);combine2Vec2(pB2,v13.a,v13.wB,v22.a,v22.wB);break;case 3:combine3Vec2(pA2,v13.a,v13.wA,v22.a,v22.wA,v3.a,v3.wA);copyVec2(pB2,pA2);break}};Simplex2.prototype.getMetric=function(){switch(this.m_count){case 0:return 0;case 1:return 0;case 2:return distVec2(this.m_v1.w,this.m_v2.w);case 3:return crossVec2Vec2(subVec2(temp1,this.m_v2.w,this.m_v1.w),subVec2(temp2,this.m_v3.w,this.m_v1.w));default:return 0}};Simplex2.prototype.solve=function(){switch(this.m_count){case 1:break;case 2:this.solve2();break;case 3:this.solve3();break}};Simplex2.prototype.solve2=function(){var w1=this.m_v1.w;var w2=this.m_v2.w;subVec2(e12,w2,w1);var d12_2=-dotVec2(w1,e12);if(d12_2<=0){this.m_v1.a=1;this.m_count=1;return}var d12_1=dotVec2(w2,e12);if(d12_1<=0){this.m_v2.a=1;this.m_count=1;this.m_v1.set(this.m_v2);return}var inv_d12=1/(d12_1+d12_2);this.m_v1.a=d12_1*inv_d12;this.m_v2.a=d12_2*inv_d12;this.m_count=2};Simplex2.prototype.solve3=function(){var w1=this.m_v1.w;var w2=this.m_v2.w;var w3=this.m_v3.w;subVec2(e12,w2,w1);var w1e12=dotVec2(w1,e12);var w2e12=dotVec2(w2,e12);var d12_1=w2e12;var d12_2=-w1e12;subVec2(e13,w3,w1);var w1e13=dotVec2(w1,e13);var w3e13=dotVec2(w3,e13);var d13_1=w3e13;var d13_2=-w1e13;subVec2(e23,w3,w2);var w2e23=dotVec2(w2,e23);var w3e23=dotVec2(w3,e23);var d23_1=w3e23;var d23_2=-w2e23;var n123=crossVec2Vec2(e12,e13);var d123_1=n123*crossVec2Vec2(w2,w3);var d123_2=n123*crossVec2Vec2(w3,w1);var d123_3=n123*crossVec2Vec2(w1,w2);if(d12_2<=0&&d13_2<=0){this.m_v1.a=1;this.m_count=1;return}if(d12_1>0&&d12_2>0&&d123_3<=0){var inv_d12=1/(d12_1+d12_2);this.m_v1.a=d12_1*inv_d12;this.m_v2.a=d12_2*inv_d12;this.m_count=2;return}if(d13_1>0&&d13_2>0&&d123_2<=0){var inv_d13=1/(d13_1+d13_2);this.m_v1.a=d13_1*inv_d13;this.m_v3.a=d13_2*inv_d13;this.m_count=2;this.m_v2.set(this.m_v3);return}if(d12_1<=0&&d23_2<=0){this.m_v2.a=1;this.m_count=1;this.m_v1.set(this.m_v2);return}if(d13_1<=0&&d23_1<=0){this.m_v3.a=1;this.m_count=1;this.m_v1.set(this.m_v3);return}if(d23_1>0&&d23_2>0&&d123_1<=0){var inv_d23=1/(d23_1+d23_2);this.m_v2.a=d23_1*inv_d23;this.m_v3.a=d23_2*inv_d23;this.m_count=2;this.m_v1.set(this.m_v3);return}var inv_d123=1/(d123_1+d123_2+d123_3);this.m_v1.a=d123_1*inv_d123;this.m_v2.a=d123_2*inv_d123;this.m_v3.a=d123_3*inv_d123;this.m_count=3};return Simplex2}();var simplex=new Simplex;var input$1=new DistanceInput;var cache$1=new SimplexCache;var output$1=new DistanceOutput;var testOverlap=function(shapeA,indexA,shapeB,indexB,xfA2,xfB2){input$1.recycle();input$1.proxyA.set(shapeA,indexA);input$1.proxyB.set(shapeB,indexB);copyTransform(input$1.transformA,xfA2);copyTransform(input$1.transformB,xfB2);input$1.useRadii=true;output$1.recycle();cache$1.recycle();Distance(output$1,cache$1,input$1);return output$1.distance<10*EPSILON};Distance.testOverlap=testOverlap;Distance.Input=DistanceInput;Distance.Output=DistanceOutput;Distance.Proxy=DistanceProxy;Distance.Cache=SimplexCache;var ShapeCastInput=function(){function ShapeCastInput2(){this.proxyA=new DistanceProxy;this.proxyB=new DistanceProxy;this.transformA=Transform.identity();this.transformB=Transform.identity();this.translationB=Vec2.zero()}ShapeCastInput2.prototype.recycle=function(){this.proxyA.recycle();this.proxyB.recycle();this.transformA.setIdentity();this.transformB.setIdentity();zeroVec2(this.translationB)};return ShapeCastInput2}();var ShapeCastOutput=function(){function ShapeCastOutput2(){this.point=Vec2.zero();this.normal=Vec2.zero();this.lambda=1;this.iterations=0}return ShapeCastOutput2}();var ShapeCast=function(output2,input2){output2.iterations=0;output2.lambda=1;output2.normal.setZero();output2.point.setZero();var proxyA=input2.proxyA;var proxyB=input2.proxyB;var radiusA=math_max$5(proxyA.m_radius,SettingsInternal.polygonRadius);var radiusB=math_max$5(proxyB.m_radius,SettingsInternal.polygonRadius);var radius=radiusA+radiusB;var xfA2=input2.transformA;var xfB2=input2.transformB;var r=input2.translationB;var n2=Vec2.zero();var lambda=0;var simplex2=new Simplex;simplex2.m_count=0;var vertices=simplex2.m_v;var indexA=proxyA.getSupport(Rot.mulTVec2(xfA2.q,Vec2.neg(r)));var wA=Transform.mulVec2(xfA2,proxyA.getVertex(indexA));var indexB=proxyB.getSupport(Rot.mulTVec2(xfB2.q,r));var wB=Transform.mulVec2(xfB2,proxyB.getVertex(indexB));var v3=Vec2.sub(wA,wB);var sigma=math_max$5(SettingsInternal.polygonRadius,radius-SettingsInternal.polygonRadius);var tolerance=.5*SettingsInternal.linearSlop;var k_maxIters=20;var iter=0;while(itertolerance){output2.iterations+=1;indexA=proxyA.getSupport(Rot.mulTVec2(xfA2.q,Vec2.neg(v3)));wA=Transform.mulVec2(xfA2,proxyA.getVertex(indexA));indexB=proxyB.getSupport(Rot.mulTVec2(xfB2.q,v3));wB=Transform.mulVec2(xfB2,proxyB.getVertex(indexB));var p=Vec2.sub(wA,wB);v3.normalize();var vp=Vec2.dot(v3,p);var vr=Vec2.dot(v3,r);if(vp-sigma>lambda*vr){if(vr<=0){return false}lambda=(vp-sigma)/vr;if(lambda>1){return false}n2.setMul(-1,v3);simplex2.m_count=0}var vertex=vertices[simplex2.m_count];vertex.indexA=indexB;vertex.wA=Vec2.combine(1,wB,lambda,r);vertex.indexB=indexA;vertex.wB=wA;vertex.w=Vec2.sub(vertex.wB,vertex.wA);vertex.a=1;simplex2.m_count+=1;switch(simplex2.m_count){case 1:break;case 2:simplex2.solve2();break;case 3:simplex2.solve3();break}if(simplex2.m_count==3){return false}v3.setVec2(simplex2.getClosestPoint());++iter}if(iter==0){return false}var pointA2=Vec2.zero();var pointB2=Vec2.zero();simplex2.getWitnessPoints(pointB2,pointA2);if(v3.lengthSquared()>0){n2.setMul(-1,v3);n2.normalize()}output2.point=Vec2.combine(1,pointA2,radiusA,n2);output2.normal=n2;output2.lambda=lambda;output2.iterations=iter;return true};var math_abs$8=Math.abs;var math_max$4=Math.max;var TOIInput=function(){function TOIInput2(){this.proxyA=new DistanceProxy;this.proxyB=new DistanceProxy;this.sweepA=new Sweep;this.sweepB=new Sweep}TOIInput2.prototype.recycle=function(){this.proxyA.recycle();this.proxyB.recycle();this.sweepA.recycle();this.sweepB.recycle();this.tMax=-1};return TOIInput2}();exports2.TOIOutputState=void 0;(function(TOIOutputState2){TOIOutputState2[TOIOutputState2["e_unset"]=-1]="e_unset";TOIOutputState2[TOIOutputState2["e_unknown"]=0]="e_unknown";TOIOutputState2[TOIOutputState2["e_failed"]=1]="e_failed";TOIOutputState2[TOIOutputState2["e_overlapped"]=2]="e_overlapped";TOIOutputState2[TOIOutputState2["e_touching"]=3]="e_touching";TOIOutputState2[TOIOutputState2["e_separated"]=4]="e_separated"})(exports2.TOIOutputState||(exports2.TOIOutputState={}));var TOIOutput=function(){function TOIOutput2(){this.state=exports2.TOIOutputState.e_unset;this.t=-1}TOIOutput2.prototype.recycle=function(){this.state=exports2.TOIOutputState.e_unset;this.t=-1};return TOIOutput2}();stats$1.toiTime=0;stats$1.toiMaxTime=0;stats$1.toiCalls=0;stats$1.toiIters=0;stats$1.toiMaxIters=0;stats$1.toiRootIters=0;stats$1.toiMaxRootIters=0;var distanceInput=new DistanceInput;var distanceOutput=new DistanceOutput;var cache=new SimplexCache;var xfA$1=transform(0,0,0);var xfB$1=transform(0,0,0);var temp$4=vec2(0,0);var pointA$2=vec2(0,0);var pointB$2=vec2(0,0);var normal$3=vec2(0,0);var axisA=vec2(0,0);var axisB=vec2(0,0);var localPointA=vec2(0,0);var localPointB=vec2(0,0);var TimeOfImpact=function(output2,input2){var timer=Timer.now();++stats$1.toiCalls;output2.state=exports2.TOIOutputState.e_unknown;output2.t=input2.tMax;var proxyA=input2.proxyA;var proxyB=input2.proxyB;var sweepA=input2.sweepA;var sweepB=input2.sweepB;sweepA.normalize();sweepB.normalize();var tMax=input2.tMax;var totalRadius=proxyA.m_radius+proxyB.m_radius;var target=math_max$4(SettingsInternal.linearSlop,totalRadius-3*SettingsInternal.linearSlop);var tolerance=.25*SettingsInternal.linearSlop;var t1=0;var k_maxIterations=SettingsInternal.maxTOIIterations;var iter=0;cache.recycle();distanceInput.proxyA.setVertices(proxyA.m_vertices,proxyA.m_count,proxyA.m_radius);distanceInput.proxyB.setVertices(proxyB.m_vertices,proxyB.m_count,proxyB.m_radius);distanceInput.useRadii=false;while(true){sweepA.getTransform(xfA$1,t1);sweepB.getTransform(xfB$1,t1);copyTransform(distanceInput.transformA,xfA$1);copyTransform(distanceInput.transformB,xfB$1);Distance(distanceOutput,cache,distanceInput);if(distanceOutput.distance<=0){output2.state=exports2.TOIOutputState.e_overlapped;output2.t=0;break}if(distanceOutput.distancetarget+tolerance){output2.state=exports2.TOIOutputState.e_separated;output2.t=tMax;done=true;break}if(s2>target-tolerance){t1=t2;break}var s1=separationFunction.evaluate(t1);if(s1target){a1=t;s1=s3}else{a2=t;s2=s3}if(rootIterCount===50){break}}stats$1.toiMaxRootIters=math_max$4(stats$1.toiMaxRootIters,rootIterCount);++pushBackIter;if(pushBackIter===SettingsInternal.maxPolygonVertices){break}}++iter;++stats$1.toiIters;if(done){break}if(iter===k_maxIterations){output2.state=exports2.TOIOutputState.e_failed;output2.t=t1;break}}stats$1.toiMaxIters=math_max$4(stats$1.toiMaxIters,iter);var time=Timer.diff(timer);stats$1.toiMaxTime=math_max$4(stats$1.toiMaxTime,time);stats$1.toiTime+=time;separationFunction.recycle()};var SeparationFunctionType;(function(SeparationFunctionType2){SeparationFunctionType2[SeparationFunctionType2["e_unset"]=-1]="e_unset";SeparationFunctionType2[SeparationFunctionType2["e_points"]=1]="e_points";SeparationFunctionType2[SeparationFunctionType2["e_faceA"]=2]="e_faceA";SeparationFunctionType2[SeparationFunctionType2["e_faceB"]=3]="e_faceB"})(SeparationFunctionType||(SeparationFunctionType={}));var SeparationFunction=function(){function SeparationFunction2(){this.m_proxyA=null;this.m_proxyB=null;this.m_sweepA=null;this.m_sweepB=null;this.m_type=SeparationFunctionType.e_unset;this.m_localPoint=vec2(0,0);this.m_axis=vec2(0,0);this.indexA=-1;this.indexB=-1}SeparationFunction2.prototype.recycle=function(){this.m_proxyA=null;this.m_proxyB=null;this.m_sweepA=null;this.m_sweepB=null;this.m_type=SeparationFunctionType.e_unset;zeroVec2(this.m_localPoint);zeroVec2(this.m_axis);this.indexA=-1;this.indexB=-1};SeparationFunction2.prototype.initialize=function(cache2,proxyA,sweepA,proxyB,sweepB,t1){var count=cache2.count;this.m_proxyA=proxyA;this.m_proxyB=proxyB;this.m_sweepA=sweepA;this.m_sweepB=sweepB;this.m_sweepA.getTransform(xfA$1,t1);this.m_sweepB.getTransform(xfB$1,t1);if(count===1){this.m_type=SeparationFunctionType.e_points;var localPointA_1=this.m_proxyA.getVertex(cache2.indexA[0]);var localPointB_1=this.m_proxyB.getVertex(cache2.indexB[0]);transformVec2(pointA$2,xfA$1,localPointA_1);transformVec2(pointB$2,xfB$1,localPointB_1);subVec2(this.m_axis,pointB$2,pointA$2);var s2=normalizeVec2Length(this.m_axis);return s2}else if(cache2.indexA[0]===cache2.indexA[1]){this.m_type=SeparationFunctionType.e_faceB;var localPointB1=proxyB.getVertex(cache2.indexB[0]);var localPointB2=proxyB.getVertex(cache2.indexB[1]);crossVec2Num(this.m_axis,subVec2(temp$4,localPointB2,localPointB1),1);normalizeVec2(this.m_axis);rotVec2(normal$3,xfB$1.q,this.m_axis);combine2Vec2(this.m_localPoint,.5,localPointB1,.5,localPointB2);transformVec2(pointB$2,xfB$1,this.m_localPoint);var localPointA_2=proxyA.getVertex(cache2.indexA[0]);var pointA_1=Transform.mulVec2(xfA$1,localPointA_2);var s2=dotVec2(pointA_1,normal$3)-dotVec2(pointB$2,normal$3);if(s2<0){negVec2(this.m_axis);s2=-s2}return s2}else{this.m_type=SeparationFunctionType.e_faceA;var localPointA1=this.m_proxyA.getVertex(cache2.indexA[0]);var localPointA2=this.m_proxyA.getVertex(cache2.indexA[1]);crossVec2Num(this.m_axis,subVec2(temp$4,localPointA2,localPointA1),1);normalizeVec2(this.m_axis);rotVec2(normal$3,xfA$1.q,this.m_axis);combine2Vec2(this.m_localPoint,.5,localPointA1,.5,localPointA2);transformVec2(pointA$2,xfA$1,this.m_localPoint);var localPointB_2=this.m_proxyB.getVertex(cache2.indexB[0]);transformVec2(pointB$2,xfB$1,localPointB_2);var s2=dotVec2(pointB$2,normal$3)-dotVec2(pointA$2,normal$3);if(s2<0){negVec2(this.m_axis);s2=-s2}return s2}};SeparationFunction2.prototype.compute=function(find,t){this.m_sweepA.getTransform(xfA$1,t);this.m_sweepB.getTransform(xfB$1,t);switch(this.m_type){case SeparationFunctionType.e_points:{if(find){derotVec2(axisA,xfA$1.q,this.m_axis);derotVec2(axisB,xfB$1.q,scaleVec2(temp$4,-1,this.m_axis));this.indexA=this.m_proxyA.getSupport(axisA);this.indexB=this.m_proxyB.getSupport(axisB)}copyVec2(localPointA,this.m_proxyA.getVertex(this.indexA));copyVec2(localPointB,this.m_proxyB.getVertex(this.indexB));transformVec2(pointA$2,xfA$1,localPointA);transformVec2(pointB$2,xfB$1,localPointB);var sep=dotVec2(pointB$2,this.m_axis)-dotVec2(pointA$2,this.m_axis);return sep}case SeparationFunctionType.e_faceA:{rotVec2(normal$3,xfA$1.q,this.m_axis);transformVec2(pointA$2,xfA$1,this.m_localPoint);if(find){derotVec2(axisB,xfB$1.q,scaleVec2(temp$4,-1,normal$3));this.indexA=-1;this.indexB=this.m_proxyB.getSupport(axisB)}copyVec2(localPointB,this.m_proxyB.getVertex(this.indexB));transformVec2(pointB$2,xfB$1,localPointB);var sep=dotVec2(pointB$2,normal$3)-dotVec2(pointA$2,normal$3);return sep}case SeparationFunctionType.e_faceB:{rotVec2(normal$3,xfB$1.q,this.m_axis);transformVec2(pointB$2,xfB$1,this.m_localPoint);if(find){derotVec2(axisA,xfA$1.q,scaleVec2(temp$4,-1,normal$3));this.indexB=-1;this.indexA=this.m_proxyA.getSupport(axisA)}copyVec2(localPointA,this.m_proxyA.getVertex(this.indexA));transformVec2(pointA$2,xfA$1,localPointA);var sep=dotVec2(pointA$2,normal$3)-dotVec2(pointB$2,normal$3);return sep}default:if(find){this.indexA=-1;this.indexB=-1}return 0}};SeparationFunction2.prototype.findMinSeparation=function(t){return this.compute(true,t)};SeparationFunction2.prototype.evaluate=function(t){return this.compute(false,t)};return SeparationFunction2}();var separationFunction=new SeparationFunction;TimeOfImpact.Input=TOIInput;TimeOfImpact.Output=TOIOutput;var math_abs$7=Math.abs;var math_sqrt$5=Math.sqrt;var math_min$6=Math.min;var TimeStep=function(){function TimeStep2(){this.dt=0;this.inv_dt=0;this.velocityIterations=0;this.positionIterations=0;this.warmStarting=false;this.blockSolve=true;this.inv_dt0=0;this.dtRatio=1}TimeStep2.prototype.reset=function(dt){if(this.dt>0){this.inv_dt0=this.inv_dt}this.dt=dt;this.inv_dt=dt==0?0:1/dt;this.dtRatio=dt*this.inv_dt0};return TimeStep2}();var s_subStep=new TimeStep;var c=vec2(0,0);var v=vec2(0,0);var translation=vec2(0,0);var input=new TOIInput;var output=new TOIOutput;var backup=new Sweep;var backup1=new Sweep;var backup2=new Sweep;var ContactImpulse=function(){function ContactImpulse2(contact){this.contact=contact;this.normals=[];this.tangents=[]}ContactImpulse2.prototype.recycle=function(){this.normals.length=0;this.tangents.length=0};Object.defineProperty(ContactImpulse2.prototype,"normalImpulses",{get:function(){var contact=this.contact;var normals=this.normals;normals.length=0;for(var p=0;p0){var b2=stack.pop();this.addBody(b2);b2.m_awakeFlag=true;if(b2.isStatic()){continue}for(var ce=b2.m_contactList;ce;ce=ce.next){var contact=ce.contact;if(contact.m_islandFlag){continue}if(contact.isEnabled()==false||contact.isTouching()==false){continue}var sensorA=contact.m_fixtureA.m_isSensor;var sensorB=contact.m_fixtureB.m_isSensor;if(sensorA||sensorB){continue}this.addContact(contact);contact.m_islandFlag=true;var other=ce.other;if(other.m_islandFlag){continue}stack.push(other);other.m_islandFlag=true}for(var je=b2.m_jointList;je;je=je.next){if(je.joint.m_islandFlag==true){continue}var other=je.other;if(other.isActive()==false){continue}this.addJoint(je.joint);je.joint.m_islandFlag=true;if(other.m_islandFlag){continue}stack.push(other);other.m_islandFlag=true}}this.solveIsland(step);for(var i=0;iSettingsInternal.maxTranslationSquared){var ratio=SettingsInternal.maxTranslation/math_sqrt$5(translationLengthSqr);mulVec2(v,ratio)}var rotation2=h*w;if(rotation2*rotation2>SettingsInternal.maxRotationSquared){var ratio=SettingsInternal.maxRotation/math_abs$7(rotation2);w*=ratio}plusScaleVec2(c,h,v);a2+=h*w;copyVec2(body.c_position.c,c);body.c_position.a=a2;copyVec2(body.c_velocity.v,v);body.c_velocity.w=w}var positionSolved=false;for(var i=0;i=-3*SettingsInternal.linearSlop;var jointsOkay=true;for(var j=0;jangTolSqr||lengthSqrVec2(body.m_linearVelocity)>linTolSqr){body.m_sleepTime=0;minSleepTime=0}else{body.m_sleepTime+=h;minSleepTime=math_min$6(minSleepTime,body.m_sleepTime)}}if(minSleepTime>=SettingsInternal.timeToSleep&&positionSolved){for(var i=0;iSettingsInternal.maxSubSteps){continue}var alpha=1;if(c_3.m_toiFlag){alpha=c_3.m_toi}else{var fA_1=c_3.getFixtureA();var fB_1=c_3.getFixtureB();if(fA_1.isSensor()||fB_1.isSensor()){continue}var bA_1=fA_1.getBody();var bB_1=fB_1.getBody();var activeA=bA_1.isAwake()&&!bA_1.isStatic();var activeB=bB_1.isAwake()&&!bB_1.isStatic();if(activeA==false&&activeB==false){continue}var collideA=bA_1.isBullet()||!bA_1.isDynamic();var collideB=bB_1.isBullet()||!bB_1.isDynamic();if(collideA==false&&collideB==false){continue}var alpha0=bA_1.m_sweep.alpha0;if(bA_1.m_sweep.alpha0=-1.5*SettingsInternal.linearSlop;if(contactsOkay){break}}var i;copyVec2(toiA.m_sweep.c0,toiA.c_position.c);toiA.m_sweep.a0=toiA.c_position.a;copyVec2(toiB.m_sweep.c0,toiB.c_position.c);toiB.m_sweep.a0=toiB.c_position.a;for(var i=0;iSettingsInternal.maxTranslationSquared){var ratio=SettingsInternal.maxTranslation/math_sqrt$5(translationLengthSqr);mulVec2(v,ratio)}var rotation2=h*w;if(rotation2*rotation2>SettingsInternal.maxRotationSquared){var ratio=SettingsInternal.maxRotation/math_abs$7(rotation2);w*=ratio}plusScaleVec2(c,h,v);a2+=h*w;copyVec2(body.c_position.c,c);body.c_position.a=a2;copyVec2(body.c_velocity.v,v);body.c_velocity.w=w;copyVec2(body.m_sweep.c,c);body.m_sweep.a=a2;copyVec2(body.m_linearVelocity,v);body.m_angularVelocity=w;body.synchronizeTransform()}this.postSolveIsland()};Solver2.prototype.postSolveIsland=function(){for(var c_5=0;c_5EPSILON*EPSILON){var length_1=math_sqrt$4(lengthSqr);scaleVec2(normal3,1/length_1,dist)}combine2Vec2(cA$1,1,pointA$1,radiusA,normal3);combine2Vec2(cB$1,1,pointB$1,-radiusB,normal3);combine2Vec2(points[0],.5,cA$1,.5,cB$1);separations[0]=dotVec2(subVec2(temp$3,cB$1,cA$1),normal3);break}case exports2.ManifoldType.e_faceA:{rotVec2(normal3,xfA2.q,this.localNormal);transformVec2(planePoint$2,xfA2,this.localPoint);for(var i=0;irestitution2?restitution1:restitution2}var s_registers=[];var VelocityConstraintPoint=function(){function VelocityConstraintPoint2(){this.rA=vec2(0,0);this.rB=vec2(0,0);this.normalImpulse=0;this.tangentImpulse=0;this.normalMass=0;this.tangentMass=0;this.velocityBias=0}VelocityConstraintPoint2.prototype.recycle=function(){zeroVec2(this.rA);zeroVec2(this.rB);this.normalImpulse=0;this.tangentImpulse=0;this.normalMass=0;this.tangentMass=0;this.velocityBias=0};return VelocityConstraintPoint2}();var cA=vec2(0,0);var vA=vec2(0,0);var cB=vec2(0,0);var vB=vec2(0,0);var tangent$1=vec2(0,0);var xfA=transform(0,0,0);var xfB=transform(0,0,0);var pointA=vec2(0,0);var pointB=vec2(0,0);var clipPoint=vec2(0,0);var planePoint$1=vec2(0,0);var rA=vec2(0,0);var rB=vec2(0,0);var P$1=vec2(0,0);var normal$2=vec2(0,0);var point=vec2(0,0);var dv=vec2(0,0);var dv1=vec2(0,0);var dv2=vec2(0,0);var b=vec2(0,0);var a=vec2(0,0);var x=vec2(0,0);var d=vec2(0,0);var P1=vec2(0,0);var P2=vec2(0,0);var temp$2=vec2(0,0);var Contact=function(){function Contact2(){this.m_nodeA=new ContactEdge(this);this.m_nodeB=new ContactEdge(this);this.m_fixtureA=null;this.m_fixtureB=null;this.m_indexA=-1;this.m_indexB=-1;this.m_evaluateFcn=null;this.m_manifold=new Manifold;this.m_prev=null;this.m_next=null;this.m_toi=1;this.m_toiCount=0;this.m_toiFlag=false;this.m_friction=0;this.m_restitution=0;this.m_tangentSpeed=0;this.m_enabledFlag=true;this.m_islandFlag=false;this.m_touchingFlag=false;this.m_filterFlag=false;this.m_bulletHitFlag=false;this.m_impulse=new ContactImpulse(this);this.v_points=[new VelocityConstraintPoint,new VelocityConstraintPoint];this.v_normal=vec2(0,0);this.v_normalMass=new Mat22;this.v_K=new Mat22;this.v_pointCount=0;this.v_tangentSpeed=0;this.v_friction=0;this.v_restitution=0;this.v_invMassA=0;this.v_invMassB=0;this.v_invIA=0;this.v_invIB=0;this.p_localPoints=[vec2(0,0),vec2(0,0)];this.p_localNormal=vec2(0,0);this.p_localPoint=vec2(0,0);this.p_localCenterA=vec2(0,0);this.p_localCenterB=vec2(0,0);this.p_type=exports2.ManifoldType.e_unset;this.p_radiusA=0;this.p_radiusB=0;this.p_pointCount=0;this.p_invMassA=0;this.p_invMassB=0;this.p_invIA=0;this.p_invIB=0}Contact2.prototype.initialize=function(fA,indexA,fB,indexB,evaluateFcn){this.m_fixtureA=fA;this.m_fixtureB=fB;this.m_indexA=indexA;this.m_indexB=indexB;this.m_evaluateFcn=evaluateFcn;this.m_friction=mixFriction(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction);this.m_restitution=mixRestitution(this.m_fixtureA.m_restitution,this.m_fixtureB.m_restitution)};Contact2.prototype.recycle=function(){this.m_nodeA.recycle();this.m_nodeB.recycle();this.m_fixtureA=null;this.m_fixtureB=null;this.m_indexA=-1;this.m_indexB=-1;this.m_evaluateFcn=null;this.m_manifold.recycle();this.m_prev=null;this.m_next=null;this.m_toi=1;this.m_toiCount=0;this.m_toiFlag=false;this.m_friction=0;this.m_restitution=0;this.m_tangentSpeed=0;this.m_enabledFlag=true;this.m_islandFlag=false;this.m_touchingFlag=false;this.m_filterFlag=false;this.m_bulletHitFlag=false;this.m_impulse.recycle();for(var _i=0,_a2=this.v_points;_i<_a2.length;_i++){var point_1=_a2[_i];point_1.recycle()}zeroVec2(this.v_normal);this.v_normalMass.setZero();this.v_K.setZero();this.v_pointCount=0;this.v_tangentSpeed=0;this.v_friction=0;this.v_restitution=0;this.v_invMassA=0;this.v_invMassB=0;this.v_invIA=0;this.v_invIB=0;for(var _b=0,_c=this.p_localPoints;_b<_c.length;_b++){var point_2=_c[_b];zeroVec2(point_2)}zeroVec2(this.p_localNormal);zeroVec2(this.p_localPoint);zeroVec2(this.p_localCenterA);zeroVec2(this.p_localCenterB);this.p_type=exports2.ManifoldType.e_unset;this.p_radiusA=0;this.p_radiusB=0;this.p_pointCount=0;this.p_invMassA=0;this.p_invMassB=0;this.p_invIA=0;this.p_invIB=0};Contact2.prototype.initConstraint=function(step){var fixtureA=this.m_fixtureA;var fixtureB=this.m_fixtureB;if(fixtureA===null||fixtureB===null)return;var bodyA=fixtureA.m_body;var bodyB=fixtureB.m_body;if(bodyA===null||bodyB===null)return;var shapeA=fixtureA.m_shape;var shapeB=fixtureB.m_shape;if(shapeA===null||shapeB===null)return;var manifold=this.m_manifold;var pointCount=manifold.pointCount;this.v_invMassA=bodyA.m_invMass;this.v_invMassB=bodyB.m_invMass;this.v_invIA=bodyA.m_invI;this.v_invIB=bodyB.m_invI;this.v_friction=this.m_friction;this.v_restitution=this.m_restitution;this.v_tangentSpeed=this.m_tangentSpeed;this.v_pointCount=pointCount;this.v_K.setZero();this.v_normalMass.setZero();this.p_invMassA=bodyA.m_invMass;this.p_invMassB=bodyB.m_invMass;this.p_invIA=bodyA.m_invI;this.p_invIB=bodyB.m_invI;copyVec2(this.p_localCenterA,bodyA.m_sweep.localCenter);copyVec2(this.p_localCenterB,bodyB.m_sweep.localCenter);this.p_radiusA=shapeA.m_radius;this.p_radiusB=shapeB.m_radius;this.p_type=manifold.type;copyVec2(this.p_localNormal,manifold.localNormal);copyVec2(this.p_localPoint,manifold.localPoint);this.p_pointCount=pointCount;for(var j=0;j0;for(var i=0;i0?-C/K:0;scaleVec2(P$1,impulse,normal$2);minusScaleVec2(cA,mA,P$1);aA-=iA*crossVec2Vec2(rA,P$1);plusScaleVec2(cB,mB,P$1);aB+=iB*crossVec2Vec2(rB,P$1)}copyVec2(positionA.c,cA);positionA.a=aA;copyVec2(positionB.c,cB);positionB.a=aB;return minSeparation};Contact2.prototype.initVelocityConstraint=function(step){var fixtureA=this.m_fixtureA;var fixtureB=this.m_fixtureB;if(fixtureA===null||fixtureB===null)return;var bodyA=fixtureA.m_body;var bodyB=fixtureB.m_body;if(bodyA===null||bodyB===null)return;var velocityA=bodyA.c_velocity;var velocityB=bodyB.c_velocity;var positionA=bodyA.c_position;var positionB=bodyB.c_position;var radiusA=this.p_radiusA;var radiusB=this.p_radiusB;var manifold=this.m_manifold;var mA=this.v_invMassA;var mB=this.v_invMassB;var iA=this.v_invIA;var iB=this.v_invIB;var localCenterA=this.p_localCenterA;var localCenterB=this.p_localCenterB;copyVec2(cA,positionA.c);var aA=positionA.a;copyVec2(vA,velocityA.v);var wA=velocityA.w;copyVec2(cB,positionB.c);var aB=positionB.a;copyVec2(vB,velocityB.v);var wB=velocityB.w;getTransform(xfA,localCenterA,cA,aA);getTransform(xfB,localCenterB,cB,aB);worldManifold.recycle();manifold.getWorldManifold(worldManifold,xfA,radiusA,xfB,radiusB);copyVec2(this.v_normal,worldManifold.normal);for(var j=0;j0?1/kNormal:0;crossVec2Num(tangent$1,this.v_normal,1);var rtA=crossVec2Vec2(vcp.rA,tangent$1);var rtB=crossVec2Vec2(vcp.rB,tangent$1);var kTangent=mA+mB+iA*rtA*rtA+iB*rtB*rtB;vcp.tangentMass=kTangent>0?1/kTangent:0;vcp.velocityBias=0;var vRel=0;vRel+=dotVec2(this.v_normal,vB);vRel+=dotVec2(this.v_normal,crossNumVec2(temp$2,wB,vcp.rB));vRel-=dotVec2(this.v_normal,vA);vRel-=dotVec2(this.v_normal,crossNumVec2(temp$2,wA,vcp.rA));if(vRel<-SettingsInternal.velocityThreshold){vcp.velocityBias=-this.v_restitution*vRel}}if(this.v_pointCount==2&&step.blockSolve){var vcp1=this.v_points[0];var vcp2=this.v_points[1];var rn1A=crossVec2Vec2(vcp1.rA,this.v_normal);var rn1B=crossVec2Vec2(vcp1.rB,this.v_normal);var rn2A=crossVec2Vec2(vcp2.rA,this.v_normal);var rn2B=crossVec2Vec2(vcp2.rB,this.v_normal);var k11=mA+mB+iA*rn1A*rn1A+iB*rn1B*rn1B;var k22=mA+mB+iA*rn2A*rn2A+iB*rn2B*rn2B;var k12=mA+mB+iA*rn1A*rn2A+iB*rn1B*rn2B;var k_maxConditionNumber=1e3;if(k11*k11=0&&x.y>=0){subVec2(d,x,a);scaleVec2(P1,d.x,normal$2);scaleVec2(P2,d.y,normal$2);combine3Vec2(vA,-mA,P1,-mA,P2,1,vA);wA-=iA*(crossVec2Vec2(vcp1.rA,P1)+crossVec2Vec2(vcp2.rA,P2));combine3Vec2(vB,mB,P1,mB,P2,1,vB);wB+=iB*(crossVec2Vec2(vcp1.rB,P1)+crossVec2Vec2(vcp2.rB,P2));vcp1.normalImpulse=x.x;vcp2.normalImpulse=x.y;break}x.x=-vcp1.normalMass*b.x;x.y=0;vn1=0;vn2=this.v_K.ex.y*x.x+b.y;if(x.x>=0&&vn2>=0){subVec2(d,x,a);scaleVec2(P1,d.x,normal$2);scaleVec2(P2,d.y,normal$2);combine3Vec2(vA,-mA,P1,-mA,P2,1,vA);wA-=iA*(crossVec2Vec2(vcp1.rA,P1)+crossVec2Vec2(vcp2.rA,P2));combine3Vec2(vB,mB,P1,mB,P2,1,vB);wB+=iB*(crossVec2Vec2(vcp1.rB,P1)+crossVec2Vec2(vcp2.rB,P2));vcp1.normalImpulse=x.x;vcp2.normalImpulse=x.y;break}x.x=0;x.y=-vcp2.normalMass*b.y;vn1=this.v_K.ey.x*x.y+b.x;vn2=0;if(x.y>=0&&vn1>=0){subVec2(d,x,a);scaleVec2(P1,d.x,normal$2);scaleVec2(P2,d.y,normal$2);combine3Vec2(vA,-mA,P1,-mA,P2,1,vA);wA-=iA*(crossVec2Vec2(vcp1.rA,P1)+crossVec2Vec2(vcp2.rA,P2));combine3Vec2(vB,mB,P1,mB,P2,1,vB);wB+=iB*(crossVec2Vec2(vcp1.rB,P1)+crossVec2Vec2(vcp2.rB,P2));vcp1.normalImpulse=x.x;vcp2.normalImpulse=x.y;break}x.x=0;x.y=0;vn1=b.x;vn2=b.y;if(vn1>=0&&vn2>=0){subVec2(d,x,a);scaleVec2(P1,d.x,normal$2);scaleVec2(P2,d.y,normal$2);combine3Vec2(vA,-mA,P1,-mA,P2,1,vA);wA-=iA*(crossVec2Vec2(vcp1.rA,P1)+crossVec2Vec2(vcp2.rA,P2));combine3Vec2(vB,mB,P1,mB,P2,1,vB);wB+=iB*(crossVec2Vec2(vcp1.rB,P1)+crossVec2Vec2(vcp2.rB,P2));vcp1.normalImpulse=x.x;vcp2.normalImpulse=x.y;break}break}}copyVec2(velocityA.v,vA);velocityA.w=wA;copyVec2(velocityB.v,vB);velocityB.w=wB};Contact2.addType=function(type1,type2,callback){s_registers[type1]=s_registers[type1]||{};s_registers[type1][type2]=callback};Contact2.create=function(fixtureA,indexA,fixtureB,indexB){var typeA=fixtureA.m_shape.m_type;var typeB=fixtureB.m_shape.m_type;var contact=contactPool.allocate();var evaluateFcn;if(evaluateFcn=s_registers[typeA]&&s_registers[typeA][typeB]){contact.initialize(fixtureA,indexA,fixtureB,indexB,evaluateFcn)}else if(evaluateFcn=s_registers[typeB]&&s_registers[typeB][typeA]){contact.initialize(fixtureB,indexB,fixtureA,indexA,evaluateFcn)}else{return null}fixtureA=contact.m_fixtureA;fixtureB=contact.m_fixtureB;indexA=contact.getChildIndexA();indexB=contact.getChildIndexB();var bodyA=fixtureA.m_body;var bodyB=fixtureB.m_body;contact.m_nodeA.contact=contact;contact.m_nodeA.other=bodyB;contact.m_nodeA.prev=null;contact.m_nodeA.next=bodyA.m_contactList;if(bodyA.m_contactList!=null){bodyA.m_contactList.prev=contact.m_nodeA}bodyA.m_contactList=contact.m_nodeA;contact.m_nodeB.contact=contact;contact.m_nodeB.other=bodyA;contact.m_nodeB.prev=null;contact.m_nodeB.next=bodyB.m_contactList;if(bodyB.m_contactList!=null){bodyB.m_contactList.prev=contact.m_nodeB}bodyB.m_contactList=contact.m_nodeB;if(fixtureA.isSensor()==false&&fixtureB.isSensor()==false){bodyA.setAwake(true);bodyB.setAwake(true)}return contact};Contact2.destroy=function(contact,listener){var fixtureA=contact.m_fixtureA;var fixtureB=contact.m_fixtureB;if(fixtureA===null||fixtureB===null)return;var bodyA=fixtureA.m_body;var bodyB=fixtureB.m_body;if(bodyA===null||bodyB===null)return;if(contact.isTouching()){listener.endContact(contact)}if(contact.m_nodeA.prev){contact.m_nodeA.prev.next=contact.m_nodeA.next}if(contact.m_nodeA.next){contact.m_nodeA.next.prev=contact.m_nodeA.prev}if(contact.m_nodeA==bodyA.m_contactList){bodyA.m_contactList=contact.m_nodeA.next}if(contact.m_nodeB.prev){contact.m_nodeB.prev.next=contact.m_nodeB.next}if(contact.m_nodeB.next){contact.m_nodeB.next.prev=contact.m_nodeB.prev}if(contact.m_nodeB==bodyB.m_contactList){bodyB.m_contactList=contact.m_nodeB.next}if(contact.m_manifold.pointCount>0&&!fixtureA.m_isSensor&&!fixtureB.m_isSensor){bodyA.setAwake(true);bodyB.setAwake(true)}contactPool.release(contact)};return Contact2}();var DEFAULTS$b={gravity:Vec2.zero(),allowSleep:true,warmStarting:true,continuousPhysics:true,subStepping:false,blockSolve:true,velocityIterations:8,positionIterations:3};var World=function(){function World2(def){if(!(this instanceof World2)){return new World2(def)}this.s_step=new TimeStep;if(!def){def={}}else if(Vec2.isValid(def)){def={gravity:def}}def=options(def,DEFAULTS$b);this.m_solver=new Solver(this);this.m_broadPhase=new BroadPhase;this.m_contactList=null;this.m_contactCount=0;this.m_bodyList=null;this.m_bodyCount=0;this.m_jointList=null;this.m_jointCount=0;this.m_stepComplete=true;this.m_allowSleep=def.allowSleep;this.m_gravity=Vec2.clone(def.gravity);this.m_clearForces=true;this.m_newFixture=false;this.m_locked=false;this.m_warmStarting=def.warmStarting;this.m_continuousPhysics=def.continuousPhysics;this.m_subStepping=def.subStepping;this.m_blockSolve=def.blockSolve;this.m_velocityIterations=def.velocityIterations;this.m_positionIterations=def.positionIterations;this.m_t=0}World2.prototype._serialize=function(){var bodies=[];var joints=[];for(var b2=this.getBodyList();b2;b2=b2.getNext()){bodies.push(b2)}for(var j=this.getJointList();j;j=j.getNext()){if(typeof j._serialize==="function"){joints.push(j)}}return{gravity:this.m_gravity,bodies:bodies,joints:joints}};World2._deserialize=function(data,context,restore){if(!data){return new World2}var world=new World2(data.gravity);if(data.bodies){for(var i=data.bodies.length-1;i>=0;i-=1){world._addBody(restore(Body,data.bodies[i],world))}}if(data.joints){for(var i=data.joints.length-1;i>=0;i--){world.createJoint(restore(Joint,data.joints[i],world))}}return world};World2.prototype.getBodyList=function(){return this.m_bodyList};World2.prototype.getJointList=function(){return this.m_jointList};World2.prototype.getContactList=function(){return this.m_contactList};World2.prototype.getBodyCount=function(){return this.m_bodyCount};World2.prototype.getJointCount=function(){return this.m_jointCount};World2.prototype.getContactCount=function(){return this.m_contactCount};World2.prototype.setGravity=function(gravity){this.m_gravity.set(gravity)};World2.prototype.getGravity=function(){return this.m_gravity};World2.prototype.isLocked=function(){return this.m_locked};World2.prototype.setAllowSleeping=function(flag){if(flag==this.m_allowSleep){return}this.m_allowSleep=flag;if(this.m_allowSleep==false){for(var b2=this.m_bodyList;b2;b2=b2.m_next){b2.setAwake(true)}}};World2.prototype.getAllowSleeping=function(){return this.m_allowSleep};World2.prototype.setWarmStarting=function(flag){this.m_warmStarting=flag};World2.prototype.getWarmStarting=function(){return this.m_warmStarting};World2.prototype.setContinuousPhysics=function(flag){this.m_continuousPhysics=flag};World2.prototype.getContinuousPhysics=function(){return this.m_continuousPhysics};World2.prototype.setSubStepping=function(flag){this.m_subStepping=flag};World2.prototype.getSubStepping=function(){return this.m_subStepping};World2.prototype.setAutoClearForces=function(flag){this.m_clearForces=flag};World2.prototype.getAutoClearForces=function(){return this.m_clearForces};World2.prototype.clearForces=function(){for(var body=this.m_bodyList;body;body=body.getNext()){body.m_force.setZero();body.m_torque=0}};World2.prototype.queryAABB=function(aabb,callback){var broadPhase=this.m_broadPhase;this.m_broadPhase.query(aabb,(function(proxyId){var proxy=broadPhase.getUserData(proxyId);return callback(proxy.fixture)}))};World2.prototype.rayCast=function(point1,point2,callback){var broadPhase=this.m_broadPhase;this.m_broadPhase.rayCast({maxFraction:1,p1:point1,p2:point2},(function(input2,proxyId){var proxy=broadPhase.getUserData(proxyId);var fixture=proxy.fixture;var index=proxy.childIndex;var output2={};var hit=fixture.rayCast(output2,input2,index);if(hit){var fraction=output2.fraction;var point3=Vec2.add(Vec2.mulNumVec2(1-fraction,input2.p1),Vec2.mulNumVec2(fraction,input2.p2));return callback(fixture,point3,output2.normal,fraction)}return input2.maxFraction}))};World2.prototype.getProxyCount=function(){return this.m_broadPhase.getProxyCount()};World2.prototype.getTreeHeight=function(){return this.m_broadPhase.getTreeHeight()};World2.prototype.getTreeBalance=function(){return this.m_broadPhase.getTreeBalance()};World2.prototype.getTreeQuality=function(){return this.m_broadPhase.getTreeQuality()};World2.prototype.shiftOrigin=function(newOrigin){if(this.m_locked){return}for(var b2=this.m_bodyList;b2;b2=b2.m_next){b2.m_xf.p.sub(newOrigin);b2.m_sweep.c0.sub(newOrigin);b2.m_sweep.c.sub(newOrigin)}for(var j=this.m_jointList;j;j=j.m_next){j.shiftOrigin(newOrigin)}this.m_broadPhase.shiftOrigin(newOrigin)};World2.prototype._addBody=function(body){if(this.isLocked()){return}body.m_prev=null;body.m_next=this.m_bodyList;if(this.m_bodyList){this.m_bodyList.m_prev=body}this.m_bodyList=body;++this.m_bodyCount};World2.prototype.createBody=function(arg1,arg2){if(this.isLocked()){return null}var def={};if(!arg1);else if(Vec2.isValid(arg1)){def={position:arg1,angle:arg2}}else if(typeof arg1==="object"){def=arg1}var body=new Body(this,def);this._addBody(body);return body};World2.prototype.createDynamicBody=function(arg1,arg2){var def={};if(!arg1);else if(Vec2.isValid(arg1)){def={position:arg1,angle:arg2}}else if(typeof arg1==="object"){def=arg1}def.type="dynamic";return this.createBody(def)};World2.prototype.createKinematicBody=function(arg1,arg2){var def={};if(!arg1);else if(Vec2.isValid(arg1)){def={position:arg1,angle:arg2}}else if(typeof arg1==="object"){def=arg1}def.type="kinematic";return this.createBody(def)};World2.prototype.destroyBody=function(b2){if(this.isLocked()){return}if(b2.m_destroyed){return false}var je=b2.m_jointList;while(je){var je0=je;je=je.next;this.publish("remove-joint",je0.joint);this.destroyJoint(je0.joint);b2.m_jointList=je}b2.m_jointList=null;var ce=b2.m_contactList;while(ce){var ce0=ce;ce=ce.next;this.destroyContact(ce0.contact);b2.m_contactList=ce}b2.m_contactList=null;var f=b2.m_fixtureList;while(f){var f0=f;f=f.m_next;this.publish("remove-fixture",f0);f0.destroyProxies(this.m_broadPhase);b2.m_fixtureList=f}b2.m_fixtureList=null;if(b2.m_prev){b2.m_prev.m_next=b2.m_next}if(b2.m_next){b2.m_next.m_prev=b2.m_prev}if(b2==this.m_bodyList){this.m_bodyList=b2.m_next}b2.m_destroyed=true;--this.m_bodyCount;this.publish("remove-body",b2);return true};World2.prototype.createJoint=function(joint){if(this.isLocked()){return null}joint.m_prev=null;joint.m_next=this.m_jointList;if(this.m_jointList){this.m_jointList.m_prev=joint}this.m_jointList=joint;++this.m_jointCount;joint.m_edgeA.joint=joint;joint.m_edgeA.other=joint.m_bodyB;joint.m_edgeA.prev=null;joint.m_edgeA.next=joint.m_bodyA.m_jointList;if(joint.m_bodyA.m_jointList)joint.m_bodyA.m_jointList.prev=joint.m_edgeA;joint.m_bodyA.m_jointList=joint.m_edgeA;joint.m_edgeB.joint=joint;joint.m_edgeB.other=joint.m_bodyA;joint.m_edgeB.prev=null;joint.m_edgeB.next=joint.m_bodyB.m_jointList;if(joint.m_bodyB.m_jointList)joint.m_bodyB.m_jointList.prev=joint.m_edgeB;joint.m_bodyB.m_jointList=joint.m_edgeB;if(joint.m_collideConnected==false){for(var edge=joint.m_bodyB.getContactList();edge;edge=edge.next){if(edge.other==joint.m_bodyA){edge.contact.flagForFiltering()}}}return joint};World2.prototype.destroyJoint=function(joint){if(this.isLocked()){return}if(joint.m_prev){joint.m_prev.m_next=joint.m_next}if(joint.m_next){joint.m_next.m_prev=joint.m_prev}if(joint==this.m_jointList){this.m_jointList=joint.m_next}var bodyA=joint.m_bodyA;var bodyB=joint.m_bodyB;bodyA.setAwake(true);bodyB.setAwake(true);if(joint.m_edgeA.prev){joint.m_edgeA.prev.next=joint.m_edgeA.next}if(joint.m_edgeA.next){joint.m_edgeA.next.prev=joint.m_edgeA.prev}if(joint.m_edgeA==bodyA.m_jointList){bodyA.m_jointList=joint.m_edgeA.next}joint.m_edgeA.prev=null;joint.m_edgeA.next=null;if(joint.m_edgeB.prev){joint.m_edgeB.prev.next=joint.m_edgeB.next}if(joint.m_edgeB.next){joint.m_edgeB.next.prev=joint.m_edgeB.prev}if(joint.m_edgeB==bodyB.m_jointList){bodyB.m_jointList=joint.m_edgeB.next}joint.m_edgeB.prev=null;joint.m_edgeB.next=null;--this.m_jointCount;if(joint.m_collideConnected==false){var edge=bodyB.getContactList();while(edge){if(edge.other==bodyA){edge.contact.flagForFiltering()}edge=edge.next}}this.publish("remove-joint",joint)};World2.prototype.step=function(timeStep,velocityIterations,positionIterations){this.publish("pre-step",timeStep);if((velocityIterations|0)!==velocityIterations){velocityIterations=0}velocityIterations=velocityIterations||this.m_velocityIterations;positionIterations=positionIterations||this.m_positionIterations;if(this.m_newFixture){this.findNewContacts();this.m_newFixture=false}this.m_locked=true;this.s_step.reset(timeStep);this.s_step.velocityIterations=velocityIterations;this.s_step.positionIterations=positionIterations;this.s_step.warmStarting=this.m_warmStarting;this.s_step.blockSolve=this.m_blockSolve;this.updateContacts();if(this.m_stepComplete&&timeStep>0){this.m_solver.solveWorld(this.s_step);for(var b2=this.m_bodyList;b2;b2=b2.getNext()){if(b2.m_islandFlag==false){continue}if(b2.isStatic()){continue}b2.synchronizeFixtures()}this.findNewContacts()}if(this.m_continuousPhysics&&timeStep>0){this.m_solver.solveWorldTOI(this.s_step)}if(this.m_clearForces){this.clearForces()}this.m_locked=false;this.publish("post-step",timeStep)};World2.prototype.findNewContacts=function(){var _this=this;this.m_broadPhase.updatePairs((function(proxyA,proxyB){return _this.createContact(proxyA,proxyB)}))};World2.prototype.createContact=function(proxyA,proxyB){var fixtureA=proxyA.fixture;var fixtureB=proxyB.fixture;var indexA=proxyA.childIndex;var indexB=proxyB.childIndex;var bodyA=fixtureA.getBody();var bodyB=fixtureB.getBody();if(bodyA==bodyB){return}var edge=bodyB.getContactList();while(edge){if(edge.other==bodyA){var fA=edge.contact.getFixtureA();var fB=edge.contact.getFixtureB();var iA=edge.contact.getChildIndexA();var iB=edge.contact.getChildIndexB();if(fA==fixtureA&&fB==fixtureB&&iA==indexA&&iB==indexB){return}if(fA==fixtureB&&fB==fixtureA&&iA==indexB&&iB==indexA){return}}edge=edge.next}if(bodyB.shouldCollide(bodyA)==false){return}if(fixtureB.shouldCollide(fixtureA)==false){return}var contact=Contact.create(fixtureA,indexA,fixtureB,indexB);if(contact==null){return}contact.m_prev=null;if(this.m_contactList!=null){contact.m_next=this.m_contactList;this.m_contactList.m_prev=contact}this.m_contactList=contact;++this.m_contactCount};World2.prototype.updateContacts=function(){var c2;var next_c=this.m_contactList;while(c2=next_c){next_c=c2.getNext();var fixtureA=c2.getFixtureA();var fixtureB=c2.getFixtureB();var indexA=c2.getChildIndexA();var indexB=c2.getChildIndexB();var bodyA=fixtureA.getBody();var bodyB=fixtureB.getBody();if(c2.m_filterFlag){if(bodyB.shouldCollide(bodyA)==false){this.destroyContact(c2);continue}if(fixtureB.shouldCollide(fixtureA)==false){this.destroyContact(c2);continue}c2.m_filterFlag=false}var activeA=bodyA.isAwake()&&!bodyA.isStatic();var activeB=bodyB.isAwake()&&!bodyB.isStatic();if(activeA==false&&activeB==false){continue}var proxyIdA=fixtureA.m_proxies[indexA].proxyId;var proxyIdB=fixtureB.m_proxies[indexB].proxyId;var overlap=this.m_broadPhase.testOverlap(proxyIdA,proxyIdB);if(overlap==false){this.destroyContact(c2);continue}c2.update(this)}};World2.prototype.destroyContact=function(contact){if(contact.m_prev){contact.m_prev.m_next=contact.m_next}if(contact.m_next){contact.m_next.m_prev=contact.m_prev}if(contact==this.m_contactList){this.m_contactList=contact.m_next}Contact.destroy(contact,this);--this.m_contactCount};World2.prototype.on=function(name,listener){if(typeof name!=="string"||typeof listener!=="function"){return this}if(!this._listeners){this._listeners={}}if(!this._listeners[name]){this._listeners[name]=[]}this._listeners[name].push(listener);return this};World2.prototype.off=function(name,listener){if(typeof name!=="string"||typeof listener!=="function"){return this}var listeners=this._listeners&&this._listeners[name];if(!listeners||!listeners.length){return this}var index=listeners.indexOf(listener);if(index>=0){listeners.splice(index,1)}return this};World2.prototype.publish=function(name,arg1,arg2,arg3){var listeners=this._listeners&&this._listeners[name];if(!listeners||!listeners.length){return 0}for(var l=0;l0){output2.normal=Rot.mulVec2(xf2.q,normal3).neg()}else{output2.normal=Rot.mulVec2(xf2.q,normal3)}return true};EdgeShape2.prototype.computeAABB=function(aabb,xf2,childIndex){transformVec2(v1$2,xf2,this.m_vertex1);transformVec2(v2$1,xf2,this.m_vertex2);AABB.combinePoints(aabb,v1$2,v2$1);AABB.extend(aabb,this.m_radius)};EdgeShape2.prototype.computeMass=function(massData,density){massData.mass=0;combine2Vec2(massData.center,.5,this.m_vertex1,.5,this.m_vertex2);massData.I=0};EdgeShape2.prototype.computeDistanceProxy=function(proxy){proxy.m_vertices[0]=this.m_vertex1;proxy.m_vertices[1]=this.m_vertex2;proxy.m_vertices.length=2;proxy.m_count=2;proxy.m_radius=this.m_radius};EdgeShape2.TYPE="edge";return EdgeShape2}(Shape);var Edge=EdgeShape;var v1$1=vec2(0,0);var v2=vec2(0,0);var ChainShape=function(_super){__extends$a(ChainShape2,_super);function ChainShape2(vertices,loop){var _this=this;if(!(_this instanceof ChainShape2)){return new ChainShape2(vertices,loop)}_this=_super.call(this)||this;_this.m_type=ChainShape2.TYPE;_this.m_radius=SettingsInternal.polygonRadius;_this.m_vertices=[];_this.m_count=0;_this.m_prevVertex=null;_this.m_nextVertex=null;_this.m_hasPrevVertex=false;_this.m_hasNextVertex=false;_this.m_isLoop=!!loop;if(vertices&&vertices.length){if(loop){_this._createLoop(vertices)}else{_this._createChain(vertices)}}return _this}ChainShape2.prototype._serialize=function(){var data={type:this.m_type,vertices:this.m_isLoop?this.m_vertices.slice(0,this.m_vertices.length-1):this.m_vertices,isLoop:this.m_isLoop,hasPrevVertex:this.m_hasPrevVertex,hasNextVertex:this.m_hasNextVertex,prevVertex:null,nextVertex:null};if(this.m_prevVertex){data.prevVertex=this.m_prevVertex}if(this.m_nextVertex){data.nextVertex=this.m_nextVertex}return data};ChainShape2._deserialize=function(data,fixture,restore){var vertices=[];if(data.vertices){for(var i=0;i0){edge.m_vertex0=this.m_vertices[childIndex-1];edge.m_hasVertex0=true}else{edge.m_vertex0=this.m_prevVertex;edge.m_hasVertex0=this.m_hasPrevVertex}if(childIndexx0||x2===x0&&ps[i].yr.lengthSquared()){ie2=j}}++m;ih=ie2;if(ie2===i0){break}}if(m<3){this._setAsBox(1,1);return}this.m_count=m;this.m_vertices=[];for(var i=0;i0){return false}}return true};PolygonShape2.prototype.rayCast=function(output2,input2,xf2,childIndex){var p1=Rot.mulTVec2(xf2.q,Vec2.sub(input2.p1,xf2.p));var p2=Rot.mulTVec2(xf2.q,Vec2.sub(input2.p2,xf2.p));var d2=Vec2.sub(p2,p1);var lower=0;var upper=input2.maxFraction;var index=-1;for(var i=0;i0&&numerator=0){output2.fraction=lower;output2.normal=Rot.mulVec2(xf2.q,this.m_normals[index]);return true}return false};PolygonShape2.prototype.computeAABB=function(aabb,xf2,childIndex){var minX=Infinity;var minY=Infinity;var maxX=-Infinity;var maxY=-Infinity;for(var i=0;i0){this.m_length=+def.length}else if(def.length<0);else if(def.anchorA||def.anchorA||def.anchorA||def.anchorA){this.m_length=Vec2.distance(this.m_bodyA.getWorldPoint(this.m_localAnchorA),this.m_bodyB.getWorldPoint(this.m_localAnchorB))}if(Number.isFinite(def.frequencyHz)){this.m_frequencyHz=def.frequencyHz}if(Number.isFinite(def.dampingRatio)){this.m_dampingRatio=def.dampingRatio}};DistanceJoint2.prototype.getLocalAnchorA=function(){return this.m_localAnchorA};DistanceJoint2.prototype.getLocalAnchorB=function(){return this.m_localAnchorB};DistanceJoint2.prototype.setLength=function(length2){this.m_length=length2};DistanceJoint2.prototype.getLength=function(){return this.m_length};DistanceJoint2.prototype.setFrequency=function(hz){this.m_frequencyHz=hz};DistanceJoint2.prototype.getFrequency=function(){return this.m_frequencyHz};DistanceJoint2.prototype.setDampingRatio=function(ratio){this.m_dampingRatio=ratio};DistanceJoint2.prototype.getDampingRatio=function(){return this.m_dampingRatio};DistanceJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};DistanceJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};DistanceJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.mulNumVec2(this.m_impulse,this.m_u).mul(inv_dt)};DistanceJoint2.prototype.getReactionTorque=function(inv_dt){return 0};DistanceJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter;this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);this.m_rA=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));this.m_rB=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));this.m_u=Vec2.sub(Vec2.add(cB2,this.m_rB),Vec2.add(cA2,this.m_rA));var length2=this.m_u.length();if(length2>SettingsInternal.linearSlop){this.m_u.mul(1/length2)}else{this.m_u.setNum(0,0)}var crAu=Vec2.crossVec2Vec2(this.m_rA,this.m_u);var crBu=Vec2.crossVec2Vec2(this.m_rB,this.m_u);var invMass=this.m_invMassA+this.m_invIA*crAu*crAu+this.m_invMassB+this.m_invIB*crBu*crBu;this.m_mass=invMass!=0?1/invMass:0;if(this.m_frequencyHz>0){var C=length2-this.m_length;var omega=2*math_PI$4*this.m_frequencyHz;var d2=2*this.m_mass*this.m_dampingRatio*omega;var k=this.m_mass*omega*omega;var h=step.dt;this.m_gamma=h*(d2+h*k);this.m_gamma=this.m_gamma!=0?1/this.m_gamma:0;this.m_bias=C*h*k*this.m_gamma;invMass+=this.m_gamma;this.m_mass=invMass!=0?1/invMass:0}else{this.m_gamma=0;this.m_bias=0}if(step.warmStarting){this.m_impulse*=step.dtRatio;var P3=Vec2.mulNumVec2(this.m_impulse,this.m_u);vA2.subMul(this.m_invMassA,P3);wA-=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,P3);vB2.addMul(this.m_invMassB,P3);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,P3)}else{this.m_impulse=0}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};DistanceJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var vpA=Vec2.add(vA2,Vec2.crossNumVec2(wA,this.m_rA));var vpB=Vec2.add(vB2,Vec2.crossNumVec2(wB,this.m_rB));var Cdot=Vec2.dot(this.m_u,vpB)-Vec2.dot(this.m_u,vpA);var impulse=-this.m_mass*(Cdot+this.m_bias+this.m_gamma*this.m_impulse);this.m_impulse+=impulse;var P3=Vec2.mulNumVec2(impulse,this.m_u);vA2.subMul(this.m_invMassA,P3);wA-=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,P3);vB2.addMul(this.m_invMassB,P3);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,P3);this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};DistanceJoint2.prototype.solvePositionConstraints=function(step){if(this.m_frequencyHz>0){return true}var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulSub(qA,this.m_localAnchorA,this.m_localCenterA);var rB2=Rot.mulSub(qB,this.m_localAnchorB,this.m_localCenterB);var u=Vec2.sub(Vec2.add(cB2,rB2),Vec2.add(cA2,rA2));var length2=u.normalize();var C=clamp$1(length2-this.m_length,-SettingsInternal.maxLinearCorrection,SettingsInternal.maxLinearCorrection);var impulse=-this.m_mass*C;var P3=Vec2.mulNumVec2(impulse,u);cA2.subMul(this.m_invMassA,P3);aA-=this.m_invIA*Vec2.crossVec2Vec2(rA2,P3);cB2.addMul(this.m_invMassB,P3);aB+=this.m_invIB*Vec2.crossVec2Vec2(rB2,P3);this.m_bodyA.c_position.c.setVec2(cA2);this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c.setVec2(cB2);this.m_bodyB.c_position.a=aB;return math_abs$6(C)0){this.m_angularMass=1/this.m_angularMass}if(step.warmStarting){this.m_linearImpulse.mul(step.dtRatio);this.m_angularImpulse*=step.dtRatio;var P3=Vec2.neo(this.m_linearImpulse.x,this.m_linearImpulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+this.m_angularImpulse);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+this.m_angularImpulse)}else{this.m_linearImpulse.setZero();this.m_angularImpulse=0}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};FrictionJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var h=step.dt;{var Cdot=wB-wA;var impulse=-this.m_angularMass*Cdot;var oldImpulse=this.m_angularImpulse;var maxImpulse=h*this.m_maxTorque;this.m_angularImpulse=clamp$1(this.m_angularImpulse+impulse,-maxImpulse,maxImpulse);impulse=this.m_angularImpulse-oldImpulse;wA-=iA*impulse;wB+=iB*impulse}{var Cdot=Vec2.sub(Vec2.add(vB2,Vec2.crossNumVec2(wB,this.m_rB)),Vec2.add(vA2,Vec2.crossNumVec2(wA,this.m_rA)));var impulse=Vec2.neg(Mat22.mulVec2(this.m_linearMass,Cdot));var oldImpulse=this.m_linearImpulse;this.m_linearImpulse.add(impulse);var maxImpulse=h*this.m_maxForce;if(this.m_linearImpulse.lengthSquared()>maxImpulse*maxImpulse){this.m_linearImpulse.normalize();this.m_linearImpulse.mul(maxImpulse)}impulse=Vec2.sub(this.m_linearImpulse,oldImpulse);vA2.subMul(mA,impulse);wA-=iA*Vec2.crossVec2Vec2(this.m_rA,impulse);vB2.addMul(mB,impulse);wB+=iB*Vec2.crossVec2Vec2(this.m_rB,impulse)}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};FrictionJoint2.prototype.solvePositionConstraints=function(step){return true};FrictionJoint2.TYPE="friction-joint";return FrictionJoint2}(Joint);var Mat33=function(){function Mat332(a2,b2,c2){if(typeof a2==="object"&&a2!==null){this.ex=Vec3.clone(a2);this.ey=Vec3.clone(b2);this.ez=Vec3.clone(c2)}else{this.ex=Vec3.zero();this.ey=Vec3.zero();this.ez=Vec3.zero()}}Mat332.prototype.toString=function(){return JSON.stringify(this)};Mat332.isValid=function(obj){if(obj===null||typeof obj==="undefined"){return false}return Vec3.isValid(obj.ex)&&Vec3.isValid(obj.ey)&&Vec3.isValid(obj.ez)};Mat332.assert=function(o){};Mat332.prototype.setZero=function(){this.ex.setZero();this.ey.setZero();this.ez.setZero();return this};Mat332.prototype.solve33=function(v3){var cross_x=this.ey.y*this.ez.z-this.ey.z*this.ez.y;var cross_y=this.ey.z*this.ez.x-this.ey.x*this.ez.z;var cross_z=this.ey.x*this.ez.y-this.ey.y*this.ez.x;var det=this.ex.x*cross_x+this.ex.y*cross_y+this.ex.z*cross_z;if(det!==0){det=1/det}var r=new Vec3;cross_x=this.ey.y*this.ez.z-this.ey.z*this.ez.y;cross_y=this.ey.z*this.ez.x-this.ey.x*this.ez.z;cross_z=this.ey.x*this.ez.y-this.ey.y*this.ez.x;r.x=det*(v3.x*cross_x+v3.y*cross_y+v3.z*cross_z);cross_x=v3.y*this.ez.z-v3.z*this.ez.y;cross_y=v3.z*this.ez.x-v3.x*this.ez.z;cross_z=v3.x*this.ez.y-v3.y*this.ez.x;r.y=det*(this.ex.x*cross_x+this.ex.y*cross_y+this.ex.z*cross_z);cross_x=this.ey.y*v3.z-this.ey.z*v3.y;cross_y=this.ey.z*v3.x-this.ey.x*v3.z;cross_z=this.ey.x*v3.y-this.ey.y*v3.x;r.z=det*(this.ex.x*cross_x+this.ex.y*cross_y+this.ex.z*cross_z);return r};Mat332.prototype.solve22=function(v3){var a11=this.ex.x;var a12=this.ey.x;var a21=this.ex.y;var a22=this.ey.y;var det=a11*a22-a12*a21;if(det!==0){det=1/det}var r=Vec2.zero();r.x=det*(a22*v3.x-a12*v3.y);r.y=det*(a11*v3.y-a21*v3.x);return r};Mat332.prototype.getInverse22=function(M){var a2=this.ex.x;var b2=this.ey.x;var c2=this.ex.y;var d2=this.ey.y;var det=a2*d2-b2*c2;if(det!==0){det=1/det}M.ex.x=det*d2;M.ey.x=-det*b2;M.ex.z=0;M.ex.y=-det*c2;M.ey.y=det*a2;M.ey.z=0;M.ez.x=0;M.ez.y=0;M.ez.z=0};Mat332.prototype.getSymInverse33=function(M){var det=Vec3.dot(this.ex,Vec3.cross(this.ey,this.ez));if(det!==0){det=1/det}var a11=this.ex.x;var a12=this.ey.x;var a13=this.ez.x;var a22=this.ey.y;var a23=this.ez.y;var a33=this.ez.z;M.ex.x=det*(a22*a33-a23*a23);M.ex.y=det*(a13*a23-a12*a33);M.ex.z=det*(a12*a23-a13*a22);M.ey.x=M.ex.y;M.ey.y=det*(a11*a33-a13*a13);M.ey.z=det*(a13*a12-a11*a23);M.ez.x=M.ex.z;M.ez.y=M.ey.z;M.ez.z=det*(a11*a22-a12*a12)};Mat332.mul=function(a2,b2){if(b2&&"z"in b2&&"y"in b2&&"x"in b2){var x2=a2.ex.x*b2.x+a2.ey.x*b2.y+a2.ez.x*b2.z;var y=a2.ex.y*b2.x+a2.ey.y*b2.y+a2.ez.y*b2.z;var z=a2.ex.z*b2.x+a2.ey.z*b2.y+a2.ez.z*b2.z;return new Vec3(x2,y,z)}else if(b2&&"y"in b2&&"x"in b2){var x2=a2.ex.x*b2.x+a2.ey.x*b2.y;var y=a2.ex.y*b2.x+a2.ey.y*b2.y;return Vec2.neo(x2,y)}};Mat332.mulVec3=function(a2,b2){var x2=a2.ex.x*b2.x+a2.ey.x*b2.y+a2.ez.x*b2.z;var y=a2.ex.y*b2.x+a2.ey.y*b2.y+a2.ez.y*b2.z;var z=a2.ex.z*b2.x+a2.ey.z*b2.y+a2.ez.z*b2.z;return new Vec3(x2,y,z)};Mat332.mulVec2=function(a2,b2){var x2=a2.ex.x*b2.x+a2.ey.x*b2.y;var y=a2.ex.y*b2.x+a2.ey.y*b2.y;return Vec2.neo(x2,y)};Mat332.add=function(a2,b2){return new Mat332(Vec3.add(a2.ex,b2.ex),Vec3.add(a2.ey,b2.ey),Vec3.add(a2.ez,b2.ez))};return Mat332}();var math_abs$5=Math.abs;var LimitState$2;(function(LimitState2){LimitState2[LimitState2["inactiveLimit"]=0]="inactiveLimit";LimitState2[LimitState2["atLowerLimit"]=1]="atLowerLimit";LimitState2[LimitState2["atUpperLimit"]=2]="atUpperLimit";LimitState2[LimitState2["equalLimits"]=3]="equalLimits"})(LimitState$2||(LimitState$2={}));var DEFAULTS$8={lowerAngle:0,upperAngle:0,maxMotorTorque:0,motorSpeed:0,enableLimit:false,enableMotor:false};var RevoluteJoint=function(_super){__extends$a(RevoluteJoint2,_super);function RevoluteJoint2(def,bodyA,bodyB,anchor){var _this=this;var _a2,_b,_c,_d,_e,_f;if(!(_this instanceof RevoluteJoint2)){return new RevoluteJoint2(def,bodyA,bodyB,anchor)}def=def!==null&&def!==void 0?def:{};_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_mass=new Mat33;_this.m_limitState=LimitState$2.inactiveLimit;_this.m_type=RevoluteJoint2.TYPE;if(Vec2.isValid(anchor)){_this.m_localAnchorA=bodyA.getLocalPoint(anchor)}else if(Vec2.isValid(def.localAnchorA)){_this.m_localAnchorA=Vec2.clone(def.localAnchorA)}else{_this.m_localAnchorA=Vec2.zero()}if(Vec2.isValid(anchor)){_this.m_localAnchorB=bodyB.getLocalPoint(anchor)}else if(Vec2.isValid(def.localAnchorB)){_this.m_localAnchorB=Vec2.clone(def.localAnchorB)}else{_this.m_localAnchorB=Vec2.zero()}if(Number.isFinite(def.referenceAngle)){_this.m_referenceAngle=def.referenceAngle}else{_this.m_referenceAngle=bodyB.getAngle()-bodyA.getAngle()}_this.m_impulse=new Vec3;_this.m_motorImpulse=0;_this.m_lowerAngle=(_a2=def.lowerAngle)!==null&&_a2!==void 0?_a2:DEFAULTS$8.lowerAngle;_this.m_upperAngle=(_b=def.upperAngle)!==null&&_b!==void 0?_b:DEFAULTS$8.upperAngle;_this.m_maxMotorTorque=(_c=def.maxMotorTorque)!==null&&_c!==void 0?_c:DEFAULTS$8.maxMotorTorque;_this.m_motorSpeed=(_d=def.motorSpeed)!==null&&_d!==void 0?_d:DEFAULTS$8.motorSpeed;_this.m_enableLimit=(_e=def.enableLimit)!==null&&_e!==void 0?_e:DEFAULTS$8.enableLimit;_this.m_enableMotor=(_f=def.enableMotor)!==null&&_f!==void 0?_f:DEFAULTS$8.enableMotor;return _this}RevoluteJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,lowerAngle:this.m_lowerAngle,upperAngle:this.m_upperAngle,maxMotorTorque:this.m_maxMotorTorque,motorSpeed:this.m_motorSpeed,enableLimit:this.m_enableLimit,enableMotor:this.m_enableMotor,localAnchorA:this.m_localAnchorA,localAnchorB:this.m_localAnchorB,referenceAngle:this.m_referenceAngle}};RevoluteJoint2._deserialize=function(data,world,restore){data=__assign$1({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);var joint=new RevoluteJoint2(data);return joint};RevoluteJoint2.prototype._reset=function(def){if(def.anchorA){this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA))}else if(def.localAnchorA){this.m_localAnchorA.setVec2(def.localAnchorA)}if(def.anchorB){this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB))}else if(def.localAnchorB){this.m_localAnchorB.setVec2(def.localAnchorB)}if(Number.isFinite(def.referenceAngle)){this.m_referenceAngle=def.referenceAngle}if(def.enableLimit!==void 0){this.m_enableLimit=def.enableLimit}if(Number.isFinite(def.lowerAngle)){this.m_lowerAngle=def.lowerAngle}if(Number.isFinite(def.upperAngle)){this.m_upperAngle=def.upperAngle}if(Number.isFinite(def.maxMotorTorque)){this.m_maxMotorTorque=def.maxMotorTorque}if(Number.isFinite(def.motorSpeed)){this.m_motorSpeed=def.motorSpeed}if(def.enableMotor!==void 0){this.m_enableMotor=def.enableMotor}};RevoluteJoint2.prototype.getLocalAnchorA=function(){return this.m_localAnchorA};RevoluteJoint2.prototype.getLocalAnchorB=function(){return this.m_localAnchorB};RevoluteJoint2.prototype.getReferenceAngle=function(){return this.m_referenceAngle};RevoluteJoint2.prototype.getJointAngle=function(){var bA=this.m_bodyA;var bB=this.m_bodyB;return bB.m_sweep.a-bA.m_sweep.a-this.m_referenceAngle};RevoluteJoint2.prototype.getJointSpeed=function(){var bA=this.m_bodyA;var bB=this.m_bodyB;return bB.m_angularVelocity-bA.m_angularVelocity};RevoluteJoint2.prototype.isMotorEnabled=function(){return this.m_enableMotor};RevoluteJoint2.prototype.enableMotor=function(flag){if(flag==this.m_enableMotor)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_enableMotor=flag};RevoluteJoint2.prototype.getMotorTorque=function(inv_dt){return inv_dt*this.m_motorImpulse};RevoluteJoint2.prototype.setMotorSpeed=function(speed){if(speed==this.m_motorSpeed)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_motorSpeed=speed};RevoluteJoint2.prototype.getMotorSpeed=function(){return this.m_motorSpeed};RevoluteJoint2.prototype.setMaxMotorTorque=function(torque){if(torque==this.m_maxMotorTorque)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_maxMotorTorque=torque};RevoluteJoint2.prototype.getMaxMotorTorque=function(){return this.m_maxMotorTorque};RevoluteJoint2.prototype.isLimitEnabled=function(){return this.m_enableLimit};RevoluteJoint2.prototype.enableLimit=function(flag){if(flag!=this.m_enableLimit){this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_enableLimit=flag;this.m_impulse.z=0}};RevoluteJoint2.prototype.getLowerLimit=function(){return this.m_lowerAngle};RevoluteJoint2.prototype.getUpperLimit=function(){return this.m_upperAngle};RevoluteJoint2.prototype.setLimits=function(lower,upper){if(lower!=this.m_lowerAngle||upper!=this.m_upperAngle){this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_impulse.z=0;this.m_lowerAngle=lower;this.m_upperAngle=upper}};RevoluteJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};RevoluteJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};RevoluteJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.neo(this.m_impulse.x,this.m_impulse.y).mul(inv_dt)};RevoluteJoint2.prototype.getReactionTorque=function(inv_dt){return inv_dt*this.m_impulse.z};RevoluteJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter;this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);this.m_rA=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));this.m_rB=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var fixedRotation=iA+iB===0;this.m_mass.ex.x=mA+mB+this.m_rA.y*this.m_rA.y*iA+this.m_rB.y*this.m_rB.y*iB;this.m_mass.ey.x=-this.m_rA.y*this.m_rA.x*iA-this.m_rB.y*this.m_rB.x*iB;this.m_mass.ez.x=-this.m_rA.y*iA-this.m_rB.y*iB;this.m_mass.ex.y=this.m_mass.ey.x;this.m_mass.ey.y=mA+mB+this.m_rA.x*this.m_rA.x*iA+this.m_rB.x*this.m_rB.x*iB;this.m_mass.ez.y=this.m_rA.x*iA+this.m_rB.x*iB;this.m_mass.ex.z=this.m_mass.ez.x;this.m_mass.ey.z=this.m_mass.ez.y;this.m_mass.ez.z=iA+iB;this.m_motorMass=iA+iB;if(this.m_motorMass>0){this.m_motorMass=1/this.m_motorMass}if(this.m_enableMotor==false||fixedRotation){this.m_motorImpulse=0}if(this.m_enableLimit&&fixedRotation==false){var jointAngle=aB-aA-this.m_referenceAngle;if(math_abs$5(this.m_upperAngle-this.m_lowerAngle)<2*SettingsInternal.angularSlop){this.m_limitState=LimitState$2.equalLimits}else if(jointAngle<=this.m_lowerAngle){if(this.m_limitState!=LimitState$2.atLowerLimit){this.m_impulse.z=0}this.m_limitState=LimitState$2.atLowerLimit}else if(jointAngle>=this.m_upperAngle){if(this.m_limitState!=LimitState$2.atUpperLimit){this.m_impulse.z=0}this.m_limitState=LimitState$2.atUpperLimit}else{this.m_limitState=LimitState$2.inactiveLimit;this.m_impulse.z=0}}else{this.m_limitState=LimitState$2.inactiveLimit}if(step.warmStarting){this.m_impulse.mul(step.dtRatio);this.m_motorImpulse*=step.dtRatio;var P3=Vec2.neo(this.m_impulse.x,this.m_impulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+this.m_motorImpulse+this.m_impulse.z);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+this.m_motorImpulse+this.m_impulse.z)}else{this.m_impulse.setZero();this.m_motorImpulse=0}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};RevoluteJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var fixedRotation=iA+iB===0;if(this.m_enableMotor&&this.m_limitState!=LimitState$2.equalLimits&&fixedRotation==false){var Cdot=wB-wA-this.m_motorSpeed;var impulse=-this.m_motorMass*Cdot;var oldImpulse=this.m_motorImpulse;var maxImpulse=step.dt*this.m_maxMotorTorque;this.m_motorImpulse=clamp$1(this.m_motorImpulse+impulse,-maxImpulse,maxImpulse);impulse=this.m_motorImpulse-oldImpulse;wA-=iA*impulse;wB+=iB*impulse}if(this.m_enableLimit&&this.m_limitState!=LimitState$2.inactiveLimit&&fixedRotation==false){var Cdot1=Vec2.zero();Cdot1.addCombine(1,vB2,1,Vec2.crossNumVec2(wB,this.m_rB));Cdot1.subCombine(1,vA2,1,Vec2.crossNumVec2(wA,this.m_rA));var Cdot2=wB-wA;var Cdot=new Vec3(Cdot1.x,Cdot1.y,Cdot2);var impulse=Vec3.neg(this.m_mass.solve33(Cdot));if(this.m_limitState==LimitState$2.equalLimits){this.m_impulse.add(impulse)}else if(this.m_limitState==LimitState$2.atLowerLimit){var newImpulse=this.m_impulse.z+impulse.z;if(newImpulse<0){var rhs=Vec2.combine(-1,Cdot1,this.m_impulse.z,Vec2.neo(this.m_mass.ez.x,this.m_mass.ez.y));var reduced=this.m_mass.solve22(rhs);impulse.x=reduced.x;impulse.y=reduced.y;impulse.z=-this.m_impulse.z;this.m_impulse.x+=reduced.x;this.m_impulse.y+=reduced.y;this.m_impulse.z=0}else{this.m_impulse.add(impulse)}}else if(this.m_limitState==LimitState$2.atUpperLimit){var newImpulse=this.m_impulse.z+impulse.z;if(newImpulse>0){var rhs=Vec2.combine(-1,Cdot1,this.m_impulse.z,Vec2.neo(this.m_mass.ez.x,this.m_mass.ez.y));var reduced=this.m_mass.solve22(rhs);impulse.x=reduced.x;impulse.y=reduced.y;impulse.z=-this.m_impulse.z;this.m_impulse.x+=reduced.x;this.m_impulse.y+=reduced.y;this.m_impulse.z=0}else{this.m_impulse.add(impulse)}}var P3=Vec2.neo(impulse.x,impulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+impulse.z);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+impulse.z)}else{var Cdot=Vec2.zero();Cdot.addCombine(1,vB2,1,Vec2.crossNumVec2(wB,this.m_rB));Cdot.subCombine(1,vA2,1,Vec2.crossNumVec2(wA,this.m_rA));var impulse=this.m_mass.solve22(Vec2.neg(Cdot));this.m_impulse.x+=impulse.x;this.m_impulse.y+=impulse.y;vA2.subMul(mA,impulse);wA-=iA*Vec2.crossVec2Vec2(this.m_rA,impulse);vB2.addMul(mB,impulse);wB+=iB*Vec2.crossVec2Vec2(this.m_rB,impulse)}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};RevoluteJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var angularError=0;var positionError=0;var fixedRotation=this.m_invIA+this.m_invIB==0;if(this.m_enableLimit&&this.m_limitState!=LimitState$2.inactiveLimit&&fixedRotation==false){var angle=aB-aA-this.m_referenceAngle;var limitImpulse=0;if(this.m_limitState==LimitState$2.equalLimits){var C=clamp$1(angle-this.m_lowerAngle,-SettingsInternal.maxAngularCorrection,SettingsInternal.maxAngularCorrection);limitImpulse=-this.m_motorMass*C;angularError=math_abs$5(C)}else if(this.m_limitState==LimitState$2.atLowerLimit){var C=angle-this.m_lowerAngle;angularError=-C;C=clamp$1(C+SettingsInternal.angularSlop,-SettingsInternal.maxAngularCorrection,0);limitImpulse=-this.m_motorMass*C}else if(this.m_limitState==LimitState$2.atUpperLimit){var C=angle-this.m_upperAngle;angularError=C;C=clamp$1(C-SettingsInternal.angularSlop,0,SettingsInternal.maxAngularCorrection);limitImpulse=-this.m_motorMass*C}aA-=this.m_invIA*limitImpulse;aB+=this.m_invIB*limitImpulse}{qA.setAngle(aA);qB.setAngle(aB);var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var C=Vec2.zero();C.addCombine(1,cB2,1,rB2);C.subCombine(1,cA2,1,rA2);positionError=C.length();var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var K=new Mat22;K.ex.x=mA+mB+iA*rA2.y*rA2.y+iB*rB2.y*rB2.y;K.ex.y=-iA*rA2.x*rA2.y-iB*rB2.x*rB2.y;K.ey.x=K.ex.y;K.ey.y=mA+mB+iA*rA2.x*rA2.x+iB*rB2.x*rB2.x;var impulse=Vec2.neg(K.solve(C));cA2.subMul(mA,impulse);aA-=iA*Vec2.crossVec2Vec2(rA2,impulse);cB2.addMul(mB,impulse);aB+=iB*Vec2.crossVec2Vec2(rB2,impulse)}this.m_bodyA.c_position.c.setVec2(cA2);this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c.setVec2(cB2);this.m_bodyB.c_position.a=aB;return positionError<=SettingsInternal.linearSlop&&angularError<=SettingsInternal.angularSlop};RevoluteJoint2.TYPE="revolute-joint";return RevoluteJoint2}(Joint);var math_abs$4=Math.abs;var math_max$1=Math.max;var math_min$3=Math.min;var LimitState$1;(function(LimitState2){LimitState2[LimitState2["inactiveLimit"]=0]="inactiveLimit";LimitState2[LimitState2["atLowerLimit"]=1]="atLowerLimit";LimitState2[LimitState2["atUpperLimit"]=2]="atUpperLimit";LimitState2[LimitState2["equalLimits"]=3]="equalLimits"})(LimitState$1||(LimitState$1={}));var DEFAULTS$7={enableLimit:false,lowerTranslation:0,upperTranslation:0,enableMotor:false,maxMotorForce:0,motorSpeed:0};var PrismaticJoint=function(_super){__extends$a(PrismaticJoint2,_super);function PrismaticJoint2(def,bodyA,bodyB,anchor,axis){var _this=this;if(!(_this instanceof PrismaticJoint2)){return new PrismaticJoint2(def,bodyA,bodyB,anchor,axis)}def=options(def,DEFAULTS$7);_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_type=PrismaticJoint2.TYPE;_this.m_localAnchorA=Vec2.clone(anchor?bodyA.getLocalPoint(anchor):def.localAnchorA||Vec2.zero());_this.m_localAnchorB=Vec2.clone(anchor?bodyB.getLocalPoint(anchor):def.localAnchorB||Vec2.zero());_this.m_localXAxisA=Vec2.clone(axis?bodyA.getLocalVector(axis):def.localAxisA||Vec2.neo(1,0));_this.m_localXAxisA.normalize();_this.m_localYAxisA=Vec2.crossNumVec2(1,_this.m_localXAxisA);_this.m_referenceAngle=Number.isFinite(def.referenceAngle)?def.referenceAngle:bodyB.getAngle()-bodyA.getAngle();_this.m_impulse=new Vec3;_this.m_motorMass=0;_this.m_motorImpulse=0;_this.m_lowerTranslation=def.lowerTranslation;_this.m_upperTranslation=def.upperTranslation;_this.m_maxMotorForce=def.maxMotorForce;_this.m_motorSpeed=def.motorSpeed;_this.m_enableLimit=def.enableLimit;_this.m_enableMotor=def.enableMotor;_this.m_limitState=LimitState$1.inactiveLimit;_this.m_axis=Vec2.zero();_this.m_perp=Vec2.zero();_this.m_K=new Mat33;return _this}PrismaticJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,lowerTranslation:this.m_lowerTranslation,upperTranslation:this.m_upperTranslation,maxMotorForce:this.m_maxMotorForce,motorSpeed:this.m_motorSpeed,enableLimit:this.m_enableLimit,enableMotor:this.m_enableMotor,localAnchorA:this.m_localAnchorA,localAnchorB:this.m_localAnchorB,localAxisA:this.m_localXAxisA,referenceAngle:this.m_referenceAngle}};PrismaticJoint2._deserialize=function(data,world,restore){data=__assign$1({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);data.localAxisA=Vec2.clone(data.localAxisA);var joint=new PrismaticJoint2(data);return joint};PrismaticJoint2.prototype._reset=function(def){if(def.anchorA){this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA))}else if(def.localAnchorA){this.m_localAnchorA.setVec2(def.localAnchorA)}if(def.anchorB){this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB))}else if(def.localAnchorB){this.m_localAnchorB.setVec2(def.localAnchorB)}if(def.localAxisA){this.m_localXAxisA.setVec2(def.localAxisA);this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1,def.localAxisA))}if(Number.isFinite(def.referenceAngle)){this.m_referenceAngle=def.referenceAngle}if(typeof def.enableLimit!=="undefined"){this.m_enableLimit=!!def.enableLimit}if(Number.isFinite(def.lowerTranslation)){this.m_lowerTranslation=def.lowerTranslation}if(Number.isFinite(def.upperTranslation)){this.m_upperTranslation=def.upperTranslation}if(typeof def.enableMotor!=="undefined"){this.m_enableMotor=!!def.enableMotor}if(Number.isFinite(def.maxMotorForce)){this.m_maxMotorForce=def.maxMotorForce}if(Number.isFinite(def.motorSpeed)){this.m_motorSpeed=def.motorSpeed}};PrismaticJoint2.prototype.getLocalAnchorA=function(){return this.m_localAnchorA};PrismaticJoint2.prototype.getLocalAnchorB=function(){return this.m_localAnchorB};PrismaticJoint2.prototype.getLocalAxisA=function(){return this.m_localXAxisA};PrismaticJoint2.prototype.getReferenceAngle=function(){return this.m_referenceAngle};PrismaticJoint2.prototype.getJointTranslation=function(){var pA2=this.m_bodyA.getWorldPoint(this.m_localAnchorA);var pB2=this.m_bodyB.getWorldPoint(this.m_localAnchorB);var d2=Vec2.sub(pB2,pA2);var axis=this.m_bodyA.getWorldVector(this.m_localXAxisA);var translation2=Vec2.dot(d2,axis);return translation2};PrismaticJoint2.prototype.getJointSpeed=function(){var bA=this.m_bodyA;var bB=this.m_bodyB;var rA2=Rot.mulVec2(bA.m_xf.q,Vec2.sub(this.m_localAnchorA,bA.m_sweep.localCenter));var rB2=Rot.mulVec2(bB.m_xf.q,Vec2.sub(this.m_localAnchorB,bB.m_sweep.localCenter));var p1=Vec2.add(bA.m_sweep.c,rA2);var p2=Vec2.add(bB.m_sweep.c,rB2);var d2=Vec2.sub(p2,p1);var axis=Rot.mulVec2(bA.m_xf.q,this.m_localXAxisA);var vA2=bA.m_linearVelocity;var vB2=bB.m_linearVelocity;var wA=bA.m_angularVelocity;var wB=bB.m_angularVelocity;var speed=Vec2.dot(d2,Vec2.crossNumVec2(wA,axis))+Vec2.dot(axis,Vec2.sub(Vec2.addCrossNumVec2(vB2,wB,rB2),Vec2.addCrossNumVec2(vA2,wA,rA2)));return speed};PrismaticJoint2.prototype.isLimitEnabled=function(){return this.m_enableLimit};PrismaticJoint2.prototype.enableLimit=function(flag){if(flag!=this.m_enableLimit){this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_enableLimit=flag;this.m_impulse.z=0}};PrismaticJoint2.prototype.getLowerLimit=function(){return this.m_lowerTranslation};PrismaticJoint2.prototype.getUpperLimit=function(){return this.m_upperTranslation};PrismaticJoint2.prototype.setLimits=function(lower,upper){if(lower!=this.m_lowerTranslation||upper!=this.m_upperTranslation){this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_lowerTranslation=lower;this.m_upperTranslation=upper;this.m_impulse.z=0}};PrismaticJoint2.prototype.isMotorEnabled=function(){return this.m_enableMotor};PrismaticJoint2.prototype.enableMotor=function(flag){if(flag==this.m_enableMotor)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_enableMotor=flag};PrismaticJoint2.prototype.setMotorSpeed=function(speed){if(speed==this.m_motorSpeed)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_motorSpeed=speed};PrismaticJoint2.prototype.setMaxMotorForce=function(force){if(force==this.m_maxMotorForce)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_maxMotorForce=force};PrismaticJoint2.prototype.getMaxMotorForce=function(){return this.m_maxMotorForce};PrismaticJoint2.prototype.getMotorSpeed=function(){return this.m_motorSpeed};PrismaticJoint2.prototype.getMotorForce=function(inv_dt){return inv_dt*this.m_motorImpulse};PrismaticJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};PrismaticJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};PrismaticJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.combine(this.m_impulse.x,this.m_perp,this.m_motorImpulse+this.m_impulse.z,this.m_axis).mul(inv_dt)};PrismaticJoint2.prototype.getReactionTorque=function(inv_dt){return inv_dt*this.m_impulse.y};PrismaticJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter;this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var d2=Vec2.zero();d2.addCombine(1,cB2,1,rB2);d2.subCombine(1,cA2,1,rA2);var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;{this.m_axis=Rot.mulVec2(qA,this.m_localXAxisA);this.m_a1=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),this.m_axis);this.m_a2=Vec2.crossVec2Vec2(rB2,this.m_axis);this.m_motorMass=mA+mB+iA*this.m_a1*this.m_a1+iB*this.m_a2*this.m_a2;if(this.m_motorMass>0){this.m_motorMass=1/this.m_motorMass}}{this.m_perp=Rot.mulVec2(qA,this.m_localYAxisA);this.m_s1=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),this.m_perp);this.m_s2=Vec2.crossVec2Vec2(rB2,this.m_perp);Vec2.crossVec2Vec2(rA2,this.m_perp);var k11=mA+mB+iA*this.m_s1*this.m_s1+iB*this.m_s2*this.m_s2;var k12=iA*this.m_s1+iB*this.m_s2;var k13=iA*this.m_s1*this.m_a1+iB*this.m_s2*this.m_a2;var k22=iA+iB;if(k22==0){k22=1}var k23=iA*this.m_a1+iB*this.m_a2;var k33=mA+mB+iA*this.m_a1*this.m_a1+iB*this.m_a2*this.m_a2;this.m_K.ex.set(k11,k12,k13);this.m_K.ey.set(k12,k22,k23);this.m_K.ez.set(k13,k23,k33)}if(this.m_enableLimit){var jointTranslation=Vec2.dot(this.m_axis,d2);if(math_abs$4(this.m_upperTranslation-this.m_lowerTranslation)<2*SettingsInternal.linearSlop){this.m_limitState=LimitState$1.equalLimits}else if(jointTranslation<=this.m_lowerTranslation){if(this.m_limitState!=LimitState$1.atLowerLimit){this.m_limitState=LimitState$1.atLowerLimit;this.m_impulse.z=0}}else if(jointTranslation>=this.m_upperTranslation){if(this.m_limitState!=LimitState$1.atUpperLimit){this.m_limitState=LimitState$1.atUpperLimit;this.m_impulse.z=0}}else{this.m_limitState=LimitState$1.inactiveLimit;this.m_impulse.z=0}}else{this.m_limitState=LimitState$1.inactiveLimit;this.m_impulse.z=0}if(this.m_enableMotor==false){this.m_motorImpulse=0}if(step.warmStarting){this.m_impulse.mul(step.dtRatio);this.m_motorImpulse*=step.dtRatio;var P3=Vec2.combine(this.m_impulse.x,this.m_perp,this.m_motorImpulse+this.m_impulse.z,this.m_axis);var LA=this.m_impulse.x*this.m_s1+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a1;var LB=this.m_impulse.x*this.m_s2+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a2;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}else{this.m_impulse.setZero();this.m_motorImpulse=0}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};PrismaticJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;if(this.m_enableMotor&&this.m_limitState!=LimitState$1.equalLimits){var Cdot=Vec2.dot(this.m_axis,Vec2.sub(vB2,vA2))+this.m_a2*wB-this.m_a1*wA;var impulse=this.m_motorMass*(this.m_motorSpeed-Cdot);var oldImpulse=this.m_motorImpulse;var maxImpulse=step.dt*this.m_maxMotorForce;this.m_motorImpulse=clamp$1(this.m_motorImpulse+impulse,-maxImpulse,maxImpulse);impulse=this.m_motorImpulse-oldImpulse;var P3=Vec2.mulNumVec2(impulse,this.m_axis);var LA=impulse*this.m_a1;var LB=impulse*this.m_a2;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}var Cdot1=Vec2.zero();Cdot1.x+=Vec2.dot(this.m_perp,vB2)+this.m_s2*wB;Cdot1.x-=Vec2.dot(this.m_perp,vA2)+this.m_s1*wA;Cdot1.y=wB-wA;if(this.m_enableLimit&&this.m_limitState!=LimitState$1.inactiveLimit){var Cdot2=0;Cdot2+=Vec2.dot(this.m_axis,vB2)+this.m_a2*wB;Cdot2-=Vec2.dot(this.m_axis,vA2)+this.m_a1*wA;var Cdot=new Vec3(Cdot1.x,Cdot1.y,Cdot2);var f1=Vec3.clone(this.m_impulse);var df=this.m_K.solve33(Vec3.neg(Cdot));this.m_impulse.add(df);if(this.m_limitState==LimitState$1.atLowerLimit){this.m_impulse.z=math_max$1(this.m_impulse.z,0)}else if(this.m_limitState==LimitState$1.atUpperLimit){this.m_impulse.z=math_min$3(this.m_impulse.z,0)}var b2=Vec2.combine(-1,Cdot1,-(this.m_impulse.z-f1.z),Vec2.neo(this.m_K.ez.x,this.m_K.ez.y));var f2r=Vec2.add(this.m_K.solve22(b2),Vec2.neo(f1.x,f1.y));this.m_impulse.x=f2r.x;this.m_impulse.y=f2r.y;df=Vec3.sub(this.m_impulse,f1);var P3=Vec2.combine(df.x,this.m_perp,df.z,this.m_axis);var LA=df.x*this.m_s1+df.y+df.z*this.m_a1;var LB=df.x*this.m_s2+df.y+df.z*this.m_a2;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}else{var df=this.m_K.solve22(Vec2.neg(Cdot1));this.m_impulse.x+=df.x;this.m_impulse.y+=df.y;var P3=Vec2.mulNumVec2(df.x,this.m_perp);var LA=df.x*this.m_s1+df.y;var LB=df.x*this.m_s2+df.y;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};PrismaticJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var d2=Vec2.sub(Vec2.add(cB2,rB2),Vec2.add(cA2,rA2));var axis=Rot.mulVec2(qA,this.m_localXAxisA);var a1=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),axis);var a2=Vec2.crossVec2Vec2(rB2,axis);var perp2=Rot.mulVec2(qA,this.m_localYAxisA);var s1=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),perp2);var s2=Vec2.crossVec2Vec2(rB2,perp2);var impulse=new Vec3;var C1=Vec2.zero();C1.x=Vec2.dot(perp2,d2);C1.y=aB-aA-this.m_referenceAngle;var linearError=math_abs$4(C1.x);var angularError=math_abs$4(C1.y);var linearSlop=SettingsInternal.linearSlop;var maxLinearCorrection=SettingsInternal.maxLinearCorrection;var active=false;var C2=0;if(this.m_enableLimit){var translation2=Vec2.dot(axis,d2);if(math_abs$4(this.m_upperTranslation-this.m_lowerTranslation)<2*linearSlop){C2=clamp$1(translation2,-maxLinearCorrection,maxLinearCorrection);linearError=math_max$1(linearError,math_abs$4(translation2));active=true}else if(translation2<=this.m_lowerTranslation){C2=clamp$1(translation2-this.m_lowerTranslation+linearSlop,-maxLinearCorrection,0);linearError=Math.max(linearError,this.m_lowerTranslation-translation2);active=true}else if(translation2>=this.m_upperTranslation){C2=clamp$1(translation2-this.m_upperTranslation-linearSlop,0,maxLinearCorrection);linearError=Math.max(linearError,translation2-this.m_upperTranslation);active=true}}if(active){var k11=mA+mB+iA*s1*s1+iB*s2*s2;var k12=iA*s1+iB*s2;var k13=iA*s1*a1+iB*s2*a2;var k22=iA+iB;if(k22==0){k22=1}var k23=iA*a1+iB*a2;var k33=mA+mB+iA*a1*a1+iB*a2*a2;var K=new Mat33;K.ex.set(k11,k12,k13);K.ey.set(k12,k22,k23);K.ez.set(k13,k23,k33);var C=new Vec3;C.x=C1.x;C.y=C1.y;C.z=C2;impulse=K.solve33(Vec3.neg(C))}else{var k11=mA+mB+iA*s1*s1+iB*s2*s2;var k12=iA*s1+iB*s2;var k22=iA+iB;if(k22==0){k22=1}var K=new Mat22;K.ex.setNum(k11,k12);K.ey.setNum(k12,k22);var impulse1=K.solve(Vec2.neg(C1));impulse.x=impulse1.x;impulse.y=impulse1.y;impulse.z=0}var P3=Vec2.combine(impulse.x,perp2,impulse.z,axis);var LA=impulse.x*s1+impulse.y+impulse.z*a1;var LB=impulse.x*s2+impulse.y+impulse.z*a2;cA2.subMul(mA,P3);aA-=iA*LA;cB2.addMul(mB,P3);aB+=iB*LB;this.m_bodyA.c_position.c=cA2;this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c=cB2;this.m_bodyB.c_position.a=aB;return linearError<=SettingsInternal.linearSlop&&angularError<=SettingsInternal.angularSlop};PrismaticJoint2.TYPE="prismatic-joint";return PrismaticJoint2}(Joint);var DEFAULTS$6={ratio:1};var GearJoint=function(_super){__extends$a(GearJoint2,_super);function GearJoint2(def,bodyA,bodyB,joint1,joint2,ratio){var _this=this;if(!(_this instanceof GearJoint2)){return new GearJoint2(def,bodyA,bodyB,joint1,joint2,ratio)}def=options(def,DEFAULTS$6);_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_type=GearJoint2.TYPE;_this.m_joint1=joint1?joint1:def.joint1;_this.m_joint2=joint2?joint2:def.joint2;_this.m_ratio=Number.isFinite(ratio)?ratio:def.ratio;_this.m_type1=_this.m_joint1.getType();_this.m_type2=_this.m_joint2.getType();var coordinateA;var coordinateB;_this.m_bodyC=_this.m_joint1.getBodyA();_this.m_bodyA=_this.m_joint1.getBodyB();var xfA2=_this.m_bodyA.m_xf;var aA=_this.m_bodyA.m_sweep.a;var xfC=_this.m_bodyC.m_xf;var aC=_this.m_bodyC.m_sweep.a;if(_this.m_type1===RevoluteJoint.TYPE){var revolute=_this.m_joint1;_this.m_localAnchorC=revolute.m_localAnchorA;_this.m_localAnchorA=revolute.m_localAnchorB;_this.m_referenceAngleA=revolute.m_referenceAngle;_this.m_localAxisC=Vec2.zero();coordinateA=aA-aC-_this.m_referenceAngleA}else{var prismatic=_this.m_joint1;_this.m_localAnchorC=prismatic.m_localAnchorA;_this.m_localAnchorA=prismatic.m_localAnchorB;_this.m_referenceAngleA=prismatic.m_referenceAngle;_this.m_localAxisC=prismatic.m_localXAxisA;var pC=_this.m_localAnchorC;var pA2=Rot.mulTVec2(xfC.q,Vec2.add(Rot.mulVec2(xfA2.q,_this.m_localAnchorA),Vec2.sub(xfA2.p,xfC.p)));coordinateA=Vec2.dot(pA2,_this.m_localAxisC)-Vec2.dot(pC,_this.m_localAxisC)}_this.m_bodyD=_this.m_joint2.getBodyA();_this.m_bodyB=_this.m_joint2.getBodyB();var xfB2=_this.m_bodyB.m_xf;var aB=_this.m_bodyB.m_sweep.a;var xfD=_this.m_bodyD.m_xf;var aD=_this.m_bodyD.m_sweep.a;if(_this.m_type2===RevoluteJoint.TYPE){var revolute=_this.m_joint2;_this.m_localAnchorD=revolute.m_localAnchorA;_this.m_localAnchorB=revolute.m_localAnchorB;_this.m_referenceAngleB=revolute.m_referenceAngle;_this.m_localAxisD=Vec2.zero();coordinateB=aB-aD-_this.m_referenceAngleB}else{var prismatic=_this.m_joint2;_this.m_localAnchorD=prismatic.m_localAnchorA;_this.m_localAnchorB=prismatic.m_localAnchorB;_this.m_referenceAngleB=prismatic.m_referenceAngle;_this.m_localAxisD=prismatic.m_localXAxisA;var pD=_this.m_localAnchorD;var pB2=Rot.mulTVec2(xfD.q,Vec2.add(Rot.mulVec2(xfB2.q,_this.m_localAnchorB),Vec2.sub(xfB2.p,xfD.p)));coordinateB=Vec2.dot(pB2,_this.m_localAxisD)-Vec2.dot(pD,_this.m_localAxisD)}_this.m_constant=coordinateA+_this.m_ratio*coordinateB;_this.m_impulse=0;return _this}GearJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,joint1:this.m_joint1,joint2:this.m_joint2,ratio:this.m_ratio}};GearJoint2._deserialize=function(data,world,restore){data=__assign$1({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);data.joint1=restore(Joint,data.joint1,world);data.joint2=restore(Joint,data.joint2,world);var joint=new GearJoint2(data);return joint};GearJoint2.prototype._reset=function(def){if(Number.isFinite(def.ratio)){this.m_ratio=def.ratio}};GearJoint2.prototype.getJoint1=function(){return this.m_joint1};GearJoint2.prototype.getJoint2=function(){return this.m_joint2};GearJoint2.prototype.setRatio=function(ratio){this.m_ratio=ratio};GearJoint2.prototype.getRatio=function(){return this.m_ratio};GearJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};GearJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};GearJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.mulNumVec2(this.m_impulse,this.m_JvAC).mul(inv_dt)};GearJoint2.prototype.getReactionTorque=function(inv_dt){var L=this.m_impulse*this.m_JwA;return inv_dt*L};GearJoint2.prototype.initVelocityConstraints=function(step){this.m_lcA=this.m_bodyA.m_sweep.localCenter;this.m_lcB=this.m_bodyB.m_sweep.localCenter;this.m_lcC=this.m_bodyC.m_sweep.localCenter;this.m_lcD=this.m_bodyD.m_sweep.localCenter;this.m_mA=this.m_bodyA.m_invMass;this.m_mB=this.m_bodyB.m_invMass;this.m_mC=this.m_bodyC.m_invMass;this.m_mD=this.m_bodyD.m_invMass;this.m_iA=this.m_bodyA.m_invI;this.m_iB=this.m_bodyB.m_invI;this.m_iC=this.m_bodyC.m_invI;this.m_iD=this.m_bodyD.m_invI;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var aC=this.m_bodyC.c_position.a;var vC=this.m_bodyC.c_velocity.v;var wC=this.m_bodyC.c_velocity.w;var aD=this.m_bodyD.c_position.a;var vD=this.m_bodyD.c_velocity.v;var wD=this.m_bodyD.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var qC=Rot.neo(aC);var qD=Rot.neo(aD);this.m_mass=0;if(this.m_type1==RevoluteJoint.TYPE){this.m_JvAC=Vec2.zero();this.m_JwA=1;this.m_JwC=1;this.m_mass+=this.m_iA+this.m_iC}else{var u=Rot.mulVec2(qC,this.m_localAxisC);var rC=Rot.mulSub(qC,this.m_localAnchorC,this.m_lcC);var rA2=Rot.mulSub(qA,this.m_localAnchorA,this.m_lcA);this.m_JvAC=u;this.m_JwC=Vec2.crossVec2Vec2(rC,u);this.m_JwA=Vec2.crossVec2Vec2(rA2,u);this.m_mass+=this.m_mC+this.m_mA+this.m_iC*this.m_JwC*this.m_JwC+this.m_iA*this.m_JwA*this.m_JwA}if(this.m_type2==RevoluteJoint.TYPE){this.m_JvBD=Vec2.zero();this.m_JwB=this.m_ratio;this.m_JwD=this.m_ratio;this.m_mass+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD)}else{var u=Rot.mulVec2(qD,this.m_localAxisD);var rD=Rot.mulSub(qD,this.m_localAnchorD,this.m_lcD);var rB2=Rot.mulSub(qB,this.m_localAnchorB,this.m_lcB);this.m_JvBD=Vec2.mulNumVec2(this.m_ratio,u);this.m_JwD=this.m_ratio*Vec2.crossVec2Vec2(rD,u);this.m_JwB=this.m_ratio*Vec2.crossVec2Vec2(rB2,u);this.m_mass+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*this.m_JwD*this.m_JwD+this.m_iB*this.m_JwB*this.m_JwB}this.m_mass=this.m_mass>0?1/this.m_mass:0;if(step.warmStarting){vA2.addMul(this.m_mA*this.m_impulse,this.m_JvAC);wA+=this.m_iA*this.m_impulse*this.m_JwA;vB2.addMul(this.m_mB*this.m_impulse,this.m_JvBD);wB+=this.m_iB*this.m_impulse*this.m_JwB;vC.subMul(this.m_mC*this.m_impulse,this.m_JvAC);wC-=this.m_iC*this.m_impulse*this.m_JwC;vD.subMul(this.m_mD*this.m_impulse,this.m_JvBD);wD-=this.m_iD*this.m_impulse*this.m_JwD}else{this.m_impulse=0}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB;this.m_bodyC.c_velocity.v.setVec2(vC);this.m_bodyC.c_velocity.w=wC;this.m_bodyD.c_velocity.v.setVec2(vD);this.m_bodyD.c_velocity.w=wD};GearJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var vC=this.m_bodyC.c_velocity.v;var wC=this.m_bodyC.c_velocity.w;var vD=this.m_bodyD.c_velocity.v;var wD=this.m_bodyD.c_velocity.w;var Cdot=Vec2.dot(this.m_JvAC,vA2)-Vec2.dot(this.m_JvAC,vC)+Vec2.dot(this.m_JvBD,vB2)-Vec2.dot(this.m_JvBD,vD);Cdot+=this.m_JwA*wA-this.m_JwC*wC+(this.m_JwB*wB-this.m_JwD*wD);var impulse=-this.m_mass*Cdot;this.m_impulse+=impulse;vA2.addMul(this.m_mA*impulse,this.m_JvAC);wA+=this.m_iA*impulse*this.m_JwA;vB2.addMul(this.m_mB*impulse,this.m_JvBD);wB+=this.m_iB*impulse*this.m_JwB;vC.subMul(this.m_mC*impulse,this.m_JvAC);wC-=this.m_iC*impulse*this.m_JwC;vD.subMul(this.m_mD*impulse,this.m_JvBD);wD-=this.m_iD*impulse*this.m_JwD;this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB;this.m_bodyC.c_velocity.v.setVec2(vC);this.m_bodyC.c_velocity.w=wC;this.m_bodyD.c_velocity.v.setVec2(vD);this.m_bodyD.c_velocity.w=wD};GearJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var cC=this.m_bodyC.c_position.c;var aC=this.m_bodyC.c_position.a;var cD=this.m_bodyD.c_position.c;var aD=this.m_bodyD.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var qC=Rot.neo(aC);var qD=Rot.neo(aD);var linearError=0;var coordinateA;var coordinateB;var JvAC;var JvBD;var JwA;var JwB;var JwC;var JwD;var mass=0;if(this.m_type1==RevoluteJoint.TYPE){JvAC=Vec2.zero();JwA=1;JwC=1;mass+=this.m_iA+this.m_iC;coordinateA=aA-aC-this.m_referenceAngleA}else{var u=Rot.mulVec2(qC,this.m_localAxisC);var rC=Rot.mulSub(qC,this.m_localAnchorC,this.m_lcC);var rA2=Rot.mulSub(qA,this.m_localAnchorA,this.m_lcA);JvAC=u;JwC=Vec2.crossVec2Vec2(rC,u);JwA=Vec2.crossVec2Vec2(rA2,u);mass+=this.m_mC+this.m_mA+this.m_iC*JwC*JwC+this.m_iA*JwA*JwA;var pC=Vec2.sub(this.m_localAnchorC,this.m_lcC);var pA2=Rot.mulTVec2(qC,Vec2.add(rA2,Vec2.sub(cA2,cC)));coordinateA=Vec2.dot(Vec2.sub(pA2,pC),this.m_localAxisC)}if(this.m_type2==RevoluteJoint.TYPE){JvBD=Vec2.zero();JwB=this.m_ratio;JwD=this.m_ratio;mass+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD);coordinateB=aB-aD-this.m_referenceAngleB}else{var u=Rot.mulVec2(qD,this.m_localAxisD);var rD=Rot.mulSub(qD,this.m_localAnchorD,this.m_lcD);var rB2=Rot.mulSub(qB,this.m_localAnchorB,this.m_lcB);JvBD=Vec2.mulNumVec2(this.m_ratio,u);JwD=this.m_ratio*Vec2.crossVec2Vec2(rD,u);JwB=this.m_ratio*Vec2.crossVec2Vec2(rB2,u);mass+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*JwD*JwD+this.m_iB*JwB*JwB;var pD=Vec2.sub(this.m_localAnchorD,this.m_lcD);var pB2=Rot.mulTVec2(qD,Vec2.add(rB2,Vec2.sub(cB2,cD)));coordinateB=Vec2.dot(pB2,this.m_localAxisD)-Vec2.dot(pD,this.m_localAxisD)}var C=coordinateA+this.m_ratio*coordinateB-this.m_constant;var impulse=0;if(mass>0){impulse=-C/mass}cA2.addMul(this.m_mA*impulse,JvAC);aA+=this.m_iA*impulse*JwA;cB2.addMul(this.m_mB*impulse,JvBD);aB+=this.m_iB*impulse*JwB;cC.subMul(this.m_mC*impulse,JvAC);aC-=this.m_iC*impulse*JwC;cD.subMul(this.m_mD*impulse,JvBD);aD-=this.m_iD*impulse*JwD;this.m_bodyA.c_position.c.setVec2(cA2);this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c.setVec2(cB2);this.m_bodyB.c_position.a=aB;this.m_bodyC.c_position.c.setVec2(cC);this.m_bodyC.c_position.a=aC;this.m_bodyD.c_position.c.setVec2(cD);this.m_bodyD.c_position.a=aD;return linearError0){this.m_angularMass=1/this.m_angularMass}this.m_linearError=Vec2.zero();this.m_linearError.addCombine(1,cB2,1,this.m_rB);this.m_linearError.subCombine(1,cA2,1,this.m_rA);this.m_angularError=aB-aA-this.m_angularOffset;if(step.warmStarting){this.m_linearImpulse.mul(step.dtRatio);this.m_angularImpulse*=step.dtRatio;var P3=Vec2.neo(this.m_linearImpulse.x,this.m_linearImpulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+this.m_angularImpulse);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+this.m_angularImpulse)}else{this.m_linearImpulse.setZero();this.m_angularImpulse=0}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};MotorJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var h=step.dt;var inv_h=step.inv_dt;{var Cdot=wB-wA+inv_h*this.m_correctionFactor*this.m_angularError;var impulse=-this.m_angularMass*Cdot;var oldImpulse=this.m_angularImpulse;var maxImpulse=h*this.m_maxTorque;this.m_angularImpulse=clamp$1(this.m_angularImpulse+impulse,-maxImpulse,maxImpulse);impulse=this.m_angularImpulse-oldImpulse;wA-=iA*impulse;wB+=iB*impulse}{var Cdot=Vec2.zero();Cdot.addCombine(1,vB2,1,Vec2.crossNumVec2(wB,this.m_rB));Cdot.subCombine(1,vA2,1,Vec2.crossNumVec2(wA,this.m_rA));Cdot.addMul(inv_h*this.m_correctionFactor,this.m_linearError);var impulse=Vec2.neg(Mat22.mulVec2(this.m_linearMass,Cdot));var oldImpulse=Vec2.clone(this.m_linearImpulse);this.m_linearImpulse.add(impulse);var maxImpulse=h*this.m_maxForce;this.m_linearImpulse.clamp(maxImpulse);impulse=Vec2.sub(this.m_linearImpulse,oldImpulse);vA2.subMul(mA,impulse);wA-=iA*Vec2.crossVec2Vec2(this.m_rA,impulse);vB2.addMul(mB,impulse);wB+=iB*Vec2.crossVec2Vec2(this.m_rB,impulse)}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};MotorJoint2.prototype.solvePositionConstraints=function(step){return true};MotorJoint2.TYPE="motor-joint";return MotorJoint2}(Joint);var math_PI$3=Math.PI;var DEFAULTS$4={maxForce:0,frequencyHz:5,dampingRatio:.7};var MouseJoint=function(_super){__extends$a(MouseJoint2,_super);function MouseJoint2(def,bodyA,bodyB,target){var _this=this;if(!(_this instanceof MouseJoint2)){return new MouseJoint2(def,bodyA,bodyB,target)}def=options(def,DEFAULTS$4);_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_type=MouseJoint2.TYPE;if(Vec2.isValid(target)){_this.m_targetA=Vec2.clone(target)}else if(Vec2.isValid(def.target)){_this.m_targetA=Vec2.clone(def.target)}else{_this.m_targetA=Vec2.zero()}_this.m_localAnchorB=Transform.mulTVec2(bodyB.getTransform(),_this.m_targetA);_this.m_maxForce=def.maxForce;_this.m_impulse=Vec2.zero();_this.m_frequencyHz=def.frequencyHz;_this.m_dampingRatio=def.dampingRatio;_this.m_beta=0;_this.m_gamma=0;_this.m_rB=Vec2.zero();_this.m_localCenterB=Vec2.zero();_this.m_invMassB=0;_this.m_invIB=0;_this.m_mass=new Mat22;_this.m_C=Vec2.zero();return _this}MouseJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,target:this.m_targetA,maxForce:this.m_maxForce,frequencyHz:this.m_frequencyHz,dampingRatio:this.m_dampingRatio,_localAnchorB:this.m_localAnchorB}};MouseJoint2._deserialize=function(data,world,restore){data=__assign$1({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);data.target=Vec2.clone(data.target);var joint=new MouseJoint2(data);if(data._localAnchorB){joint.m_localAnchorB=data._localAnchorB}return joint};MouseJoint2.prototype._reset=function(def){if(Number.isFinite(def.maxForce)){this.m_maxForce=def.maxForce}if(Number.isFinite(def.frequencyHz)){this.m_frequencyHz=def.frequencyHz}if(Number.isFinite(def.dampingRatio)){this.m_dampingRatio=def.dampingRatio}};MouseJoint2.prototype.setTarget=function(target){if(Vec2.areEqual(target,this.m_targetA))return;this.m_bodyB.setAwake(true);this.m_targetA.set(target)};MouseJoint2.prototype.getTarget=function(){return this.m_targetA};MouseJoint2.prototype.setMaxForce=function(force){this.m_maxForce=force};MouseJoint2.prototype.getMaxForce=function(){return this.m_maxForce};MouseJoint2.prototype.setFrequency=function(hz){this.m_frequencyHz=hz};MouseJoint2.prototype.getFrequency=function(){return this.m_frequencyHz};MouseJoint2.prototype.setDampingRatio=function(ratio){this.m_dampingRatio=ratio};MouseJoint2.prototype.getDampingRatio=function(){return this.m_dampingRatio};MouseJoint2.prototype.getAnchorA=function(){return Vec2.clone(this.m_targetA)};MouseJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};MouseJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.mulNumVec2(inv_dt,this.m_impulse)};MouseJoint2.prototype.getReactionTorque=function(inv_dt){return inv_dt*0};MouseJoint2.prototype.shiftOrigin=function(newOrigin){this.m_targetA.sub(newOrigin)};MouseJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIB=this.m_bodyB.m_invI;var position=this.m_bodyB.c_position;var velocity=this.m_bodyB.c_velocity;var cB2=position.c;var aB=position.a;var vB2=velocity.v;var wB=velocity.w;var qB=Rot.neo(aB);var mass=this.m_bodyB.getMass();var omega=2*math_PI$3*this.m_frequencyHz;var d2=2*mass*this.m_dampingRatio*omega;var k=mass*(omega*omega);var h=step.dt;this.m_gamma=h*(d2+h*k);if(this.m_gamma!=0){this.m_gamma=1/this.m_gamma}this.m_beta=h*k*this.m_gamma;this.m_rB=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var K=new Mat22;K.ex.x=this.m_invMassB+this.m_invIB*this.m_rB.y*this.m_rB.y+this.m_gamma;K.ex.y=-this.m_invIB*this.m_rB.x*this.m_rB.y;K.ey.x=K.ex.y;K.ey.y=this.m_invMassB+this.m_invIB*this.m_rB.x*this.m_rB.x+this.m_gamma;this.m_mass=K.getInverse();this.m_C.setVec2(cB2);this.m_C.addCombine(1,this.m_rB,-1,this.m_targetA);this.m_C.mul(this.m_beta);wB*=.98;if(step.warmStarting){this.m_impulse.mul(step.dtRatio);vB2.addMul(this.m_invMassB,this.m_impulse);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,this.m_impulse)}else{this.m_impulse.setZero()}velocity.v.setVec2(vB2);velocity.w=wB};MouseJoint2.prototype.solveVelocityConstraints=function(step){var velocity=this.m_bodyB.c_velocity;var vB2=Vec2.clone(velocity.v);var wB=velocity.w;var Cdot=Vec2.crossNumVec2(wB,this.m_rB);Cdot.add(vB2);Cdot.addCombine(1,this.m_C,this.m_gamma,this.m_impulse);Cdot.neg();var impulse=Mat22.mulVec2(this.m_mass,Cdot);var oldImpulse=Vec2.clone(this.m_impulse);this.m_impulse.add(impulse);var maxImpulse=step.dt*this.m_maxForce;this.m_impulse.clamp(maxImpulse);impulse=Vec2.sub(this.m_impulse,oldImpulse);vB2.addMul(this.m_invMassB,impulse);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,impulse);velocity.v.setVec2(vB2);velocity.w=wB};MouseJoint2.prototype.solvePositionConstraints=function(step){return true};MouseJoint2.TYPE="mouse-joint";return MouseJoint2}(Joint);var math_abs$3=Math.abs;var DEFAULTS$3={collideConnected:true};var PulleyJoint=function(_super){__extends$a(PulleyJoint2,_super);function PulleyJoint2(def,bodyA,bodyB,groundA,groundB,anchorA,anchorB,ratio){var _this=this;if(!(_this instanceof PulleyJoint2)){return new PulleyJoint2(def,bodyA,bodyB,groundA,groundB,anchorA,anchorB,ratio)}def=options(def,DEFAULTS$3);_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_type=PulleyJoint2.TYPE;_this.m_groundAnchorA=Vec2.clone(groundA?groundA:def.groundAnchorA||Vec2.neo(-1,1));_this.m_groundAnchorB=Vec2.clone(groundB?groundB:def.groundAnchorB||Vec2.neo(1,1));_this.m_localAnchorA=Vec2.clone(anchorA?bodyA.getLocalPoint(anchorA):def.localAnchorA||Vec2.neo(-1,0));_this.m_localAnchorB=Vec2.clone(anchorB?bodyB.getLocalPoint(anchorB):def.localAnchorB||Vec2.neo(1,0));_this.m_lengthA=Number.isFinite(def.lengthA)?def.lengthA:Vec2.distance(anchorA,groundA);_this.m_lengthB=Number.isFinite(def.lengthB)?def.lengthB:Vec2.distance(anchorB,groundB);_this.m_ratio=Number.isFinite(ratio)?ratio:def.ratio;_this.m_constant=_this.m_lengthA+_this.m_ratio*_this.m_lengthB;_this.m_impulse=0;return _this}PulleyJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,groundAnchorA:this.m_groundAnchorA,groundAnchorB:this.m_groundAnchorB,localAnchorA:this.m_localAnchorA,localAnchorB:this.m_localAnchorB,lengthA:this.m_lengthA,lengthB:this.m_lengthB,ratio:this.m_ratio}};PulleyJoint2._deserialize=function(data,world,restore){data=__assign$1({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);var joint=new PulleyJoint2(data);return joint};PulleyJoint2.prototype._reset=function(def){if(Vec2.isValid(def.groundAnchorA)){this.m_groundAnchorA.set(def.groundAnchorA)}if(Vec2.isValid(def.groundAnchorB)){this.m_groundAnchorB.set(def.groundAnchorB)}if(Vec2.isValid(def.localAnchorA)){this.m_localAnchorA.set(def.localAnchorA)}else if(Vec2.isValid(def.anchorA)){this.m_localAnchorA.set(this.m_bodyA.getLocalPoint(def.anchorA))}if(Vec2.isValid(def.localAnchorB)){this.m_localAnchorB.set(def.localAnchorB)}else if(Vec2.isValid(def.anchorB)){this.m_localAnchorB.set(this.m_bodyB.getLocalPoint(def.anchorB))}if(Number.isFinite(def.lengthA)){this.m_lengthA=def.lengthA}if(Number.isFinite(def.lengthB)){this.m_lengthB=def.lengthB}if(Number.isFinite(def.ratio)){this.m_ratio=def.ratio}};PulleyJoint2.prototype.getGroundAnchorA=function(){return this.m_groundAnchorA};PulleyJoint2.prototype.getGroundAnchorB=function(){return this.m_groundAnchorB};PulleyJoint2.prototype.getLengthA=function(){return this.m_lengthA};PulleyJoint2.prototype.getLengthB=function(){return this.m_lengthB};PulleyJoint2.prototype.getRatio=function(){return this.m_ratio};PulleyJoint2.prototype.getCurrentLengthA=function(){var p=this.m_bodyA.getWorldPoint(this.m_localAnchorA);var s2=this.m_groundAnchorA;return Vec2.distance(p,s2)};PulleyJoint2.prototype.getCurrentLengthB=function(){var p=this.m_bodyB.getWorldPoint(this.m_localAnchorB);var s2=this.m_groundAnchorB;return Vec2.distance(p,s2)};PulleyJoint2.prototype.shiftOrigin=function(newOrigin){this.m_groundAnchorA.sub(newOrigin);this.m_groundAnchorB.sub(newOrigin)};PulleyJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};PulleyJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};PulleyJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.mulNumVec2(this.m_impulse,this.m_uB).mul(inv_dt)};PulleyJoint2.prototype.getReactionTorque=function(inv_dt){return 0};PulleyJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter;this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);this.m_rA=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));this.m_rB=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));this.m_uA=Vec2.sub(Vec2.add(cA2,this.m_rA),this.m_groundAnchorA);this.m_uB=Vec2.sub(Vec2.add(cB2,this.m_rB),this.m_groundAnchorB);var lengthA=this.m_uA.length();var lengthB=this.m_uB.length();if(lengthA>10*SettingsInternal.linearSlop){this.m_uA.mul(1/lengthA)}else{this.m_uA.setZero()}if(lengthB>10*SettingsInternal.linearSlop){this.m_uB.mul(1/lengthB)}else{this.m_uB.setZero()}var ruA=Vec2.crossVec2Vec2(this.m_rA,this.m_uA);var ruB=Vec2.crossVec2Vec2(this.m_rB,this.m_uB);var mA=this.m_invMassA+this.m_invIA*ruA*ruA;var mB=this.m_invMassB+this.m_invIB*ruB*ruB;this.m_mass=mA+this.m_ratio*this.m_ratio*mB;if(this.m_mass>0){this.m_mass=1/this.m_mass}if(step.warmStarting){this.m_impulse*=step.dtRatio;var PA=Vec2.mulNumVec2(-this.m_impulse,this.m_uA);var PB=Vec2.mulNumVec2(-this.m_ratio*this.m_impulse,this.m_uB);vA2.addMul(this.m_invMassA,PA);wA+=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,PA);vB2.addMul(this.m_invMassB,PB);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,PB)}else{this.m_impulse=0}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};PulleyJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var vpA=Vec2.add(vA2,Vec2.crossNumVec2(wA,this.m_rA));var vpB=Vec2.add(vB2,Vec2.crossNumVec2(wB,this.m_rB));var Cdot=-Vec2.dot(this.m_uA,vpA)-this.m_ratio*Vec2.dot(this.m_uB,vpB);var impulse=-this.m_mass*Cdot;this.m_impulse+=impulse;var PA=Vec2.mulNumVec2(-impulse,this.m_uA);var PB=Vec2.mulNumVec2(-this.m_ratio*impulse,this.m_uB);vA2.addMul(this.m_invMassA,PA);wA+=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,PA);vB2.addMul(this.m_invMassB,PB);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,PB);this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};PulleyJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var uA=Vec2.sub(Vec2.add(cA2,this.m_rA),this.m_groundAnchorA);var uB=Vec2.sub(Vec2.add(cB2,this.m_rB),this.m_groundAnchorB);var lengthA=uA.length();var lengthB=uB.length();if(lengthA>10*SettingsInternal.linearSlop){uA.mul(1/lengthA)}else{uA.setZero()}if(lengthB>10*SettingsInternal.linearSlop){uB.mul(1/lengthB)}else{uB.setZero()}var ruA=Vec2.crossVec2Vec2(rA2,uA);var ruB=Vec2.crossVec2Vec2(rB2,uB);var mA=this.m_invMassA+this.m_invIA*ruA*ruA;var mB=this.m_invMassB+this.m_invIB*ruB*ruB;var mass=mA+this.m_ratio*this.m_ratio*mB;if(mass>0){mass=1/mass}var C=this.m_constant-lengthA-this.m_ratio*lengthB;var linearError=math_abs$3(C);var impulse=-mass*C;var PA=Vec2.mulNumVec2(-impulse,uA);var PB=Vec2.mulNumVec2(-this.m_ratio*impulse,uB);cA2.addMul(this.m_invMassA,PA);aA+=this.m_invIA*Vec2.crossVec2Vec2(rA2,PA);cB2.addMul(this.m_invMassB,PB);aB+=this.m_invIB*Vec2.crossVec2Vec2(rB2,PB);this.m_bodyA.c_position.c=cA2;this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c=cB2;this.m_bodyB.c_position.a=aB;return linearError0){this.m_state=LimitState.atUpperLimit}else{this.m_state=LimitState.inactiveLimit}if(this.m_length>SettingsInternal.linearSlop){this.m_u.mul(1/this.m_length)}else{this.m_u.setZero();this.m_mass=0;this.m_impulse=0;return}var crA=Vec2.crossVec2Vec2(this.m_rA,this.m_u);var crB=Vec2.crossVec2Vec2(this.m_rB,this.m_u);var invMass=this.m_invMassA+this.m_invIA*crA*crA+this.m_invMassB+this.m_invIB*crB*crB;this.m_mass=invMass!=0?1/invMass:0;if(step.warmStarting){this.m_impulse*=step.dtRatio;var P3=Vec2.mulNumVec2(this.m_impulse,this.m_u);vA2.subMul(this.m_invMassA,P3);wA-=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,P3);vB2.addMul(this.m_invMassB,P3);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,P3)}else{this.m_impulse=0}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};RopeJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var vpA=Vec2.addCrossNumVec2(vA2,wA,this.m_rA);var vpB=Vec2.addCrossNumVec2(vB2,wB,this.m_rB);var C=this.m_length-this.m_maxLength;var Cdot=Vec2.dot(this.m_u,Vec2.sub(vpB,vpA));if(C<0){Cdot+=step.inv_dt*C}var impulse=-this.m_mass*Cdot;var oldImpulse=this.m_impulse;this.m_impulse=math_min$2(0,this.m_impulse+impulse);impulse=this.m_impulse-oldImpulse;var P3=Vec2.mulNumVec2(impulse,this.m_u);vA2.subMul(this.m_invMassA,P3);wA-=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,P3);vB2.addMul(this.m_invMassB,P3);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,P3);this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};RopeJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulSub(qA,this.m_localAnchorA,this.m_localCenterA);var rB2=Rot.mulSub(qB,this.m_localAnchorB,this.m_localCenterB);var u=Vec2.zero();u.addCombine(1,cB2,1,rB2);u.subCombine(1,cA2,1,rA2);var length2=u.normalize();var C=length2-this.m_maxLength;C=clamp$1(C,0,SettingsInternal.maxLinearCorrection);var impulse=-this.m_mass*C;var P3=Vec2.mulNumVec2(impulse,u);cA2.subMul(this.m_invMassA,P3);aA-=this.m_invIA*Vec2.crossVec2Vec2(rA2,P3);cB2.addMul(this.m_invMassB,P3);aB+=this.m_invIB*Vec2.crossVec2Vec2(rB2,P3);this.m_bodyA.c_position.c.setVec2(cA2);this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c.setVec2(cB2);this.m_bodyB.c_position.a=aB;return length2-this.m_maxLength0){K.getInverse22(this.m_mass);var invM=iA+iB;var m=invM>0?1/invM:0;var C=aB-aA-this.m_referenceAngle;var omega=2*math_PI$2*this.m_frequencyHz;var d2=2*m*this.m_dampingRatio*omega;var k=m*omega*omega;var h=step.dt;this.m_gamma=h*(d2+h*k);this.m_gamma=this.m_gamma!=0?1/this.m_gamma:0;this.m_bias=C*h*k*this.m_gamma;invM+=this.m_gamma;this.m_mass.ez.z=invM!=0?1/invM:0}else if(K.ez.z==0){K.getInverse22(this.m_mass);this.m_gamma=0;this.m_bias=0}else{K.getSymInverse33(this.m_mass);this.m_gamma=0;this.m_bias=0}if(step.warmStarting){this.m_impulse.mul(step.dtRatio);var P3=Vec2.neo(this.m_impulse.x,this.m_impulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+this.m_impulse.z);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+this.m_impulse.z)}else{this.m_impulse.setZero()}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};WeldJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;if(this.m_frequencyHz>0){var Cdot2=wB-wA;var impulse2=-this.m_mass.ez.z*(Cdot2+this.m_bias+this.m_gamma*this.m_impulse.z);this.m_impulse.z+=impulse2;wA-=iA*impulse2;wB+=iB*impulse2;var Cdot1=Vec2.zero();Cdot1.addCombine(1,vB2,1,Vec2.crossNumVec2(wB,this.m_rB));Cdot1.subCombine(1,vA2,1,Vec2.crossNumVec2(wA,this.m_rA));var impulse1=Vec2.neg(Mat33.mulVec2(this.m_mass,Cdot1));this.m_impulse.x+=impulse1.x;this.m_impulse.y+=impulse1.y;var P3=Vec2.clone(impulse1);vA2.subMul(mA,P3);wA-=iA*Vec2.crossVec2Vec2(this.m_rA,P3);vB2.addMul(mB,P3);wB+=iB*Vec2.crossVec2Vec2(this.m_rB,P3)}else{var Cdot1=Vec2.zero();Cdot1.addCombine(1,vB2,1,Vec2.crossNumVec2(wB,this.m_rB));Cdot1.subCombine(1,vA2,1,Vec2.crossNumVec2(wA,this.m_rA));var Cdot2=wB-wA;var Cdot=new Vec3(Cdot1.x,Cdot1.y,Cdot2);var impulse=Vec3.neg(Mat33.mulVec3(this.m_mass,Cdot));this.m_impulse.add(impulse);var P3=Vec2.neo(impulse.x,impulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+impulse.z);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+impulse.z)}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};WeldJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var positionError;var angularError;var K=new Mat33;K.ex.x=mA+mB+rA2.y*rA2.y*iA+rB2.y*rB2.y*iB;K.ey.x=-rA2.y*rA2.x*iA-rB2.y*rB2.x*iB;K.ez.x=-rA2.y*iA-rB2.y*iB;K.ex.y=K.ey.x;K.ey.y=mA+mB+rA2.x*rA2.x*iA+rB2.x*rB2.x*iB;K.ez.y=rA2.x*iA+rB2.x*iB;K.ex.z=K.ez.x;K.ey.z=K.ez.y;K.ez.z=iA+iB;if(this.m_frequencyHz>0){var C1=Vec2.zero();C1.addCombine(1,cB2,1,rB2);C1.subCombine(1,cA2,1,rA2);positionError=C1.length();angularError=0;var P3=Vec2.neg(K.solve22(C1));cA2.subMul(mA,P3);aA-=iA*Vec2.crossVec2Vec2(rA2,P3);cB2.addMul(mB,P3);aB+=iB*Vec2.crossVec2Vec2(rB2,P3)}else{var C1=Vec2.zero();C1.addCombine(1,cB2,1,rB2);C1.subCombine(1,cA2,1,rA2);var C2=aB-aA-this.m_referenceAngle;positionError=C1.length();angularError=math_abs$2(C2);var C=new Vec3(C1.x,C1.y,C2);var impulse=new Vec3;if(K.ez.z>0){impulse=Vec3.neg(K.solve33(C))}else{var impulse2=Vec2.neg(K.solve22(C1));impulse.set(impulse2.x,impulse2.y,0)}var P3=Vec2.neo(impulse.x,impulse.y);cA2.subMul(mA,P3);aA-=iA*(Vec2.crossVec2Vec2(rA2,P3)+impulse.z);cB2.addMul(mB,P3);aB+=iB*(Vec2.crossVec2Vec2(rB2,P3)+impulse.z)}this.m_bodyA.c_position.c=cA2;this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c=cB2;this.m_bodyB.c_position.a=aB;return positionError<=SettingsInternal.linearSlop&&angularError<=SettingsInternal.angularSlop};WeldJoint2.TYPE="weld-joint";return WeldJoint2}(Joint);var math_abs$1=Math.abs;var math_PI$1=Math.PI;var DEFAULTS={enableMotor:false,maxMotorTorque:0,motorSpeed:0,frequencyHz:2,dampingRatio:.7};var WheelJoint=function(_super){__extends$a(WheelJoint2,_super);function WheelJoint2(def,bodyA,bodyB,anchor,axis){var _this=this;if(!(_this instanceof WheelJoint2)){return new WheelJoint2(def,bodyA,bodyB,anchor,axis)}def=options(def,DEFAULTS);_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_ax=Vec2.zero();_this.m_ay=Vec2.zero();_this.m_type=WheelJoint2.TYPE;_this.m_localAnchorA=Vec2.clone(anchor?bodyA.getLocalPoint(anchor):def.localAnchorA||Vec2.zero());_this.m_localAnchorB=Vec2.clone(anchor?bodyB.getLocalPoint(anchor):def.localAnchorB||Vec2.zero());if(Vec2.isValid(axis)){_this.m_localXAxisA=bodyA.getLocalVector(axis)}else if(Vec2.isValid(def.localAxisA)){_this.m_localXAxisA=Vec2.clone(def.localAxisA)}else if(Vec2.isValid(def.localAxis)){_this.m_localXAxisA=Vec2.clone(def.localAxis)}else{_this.m_localXAxisA=Vec2.neo(1,0)}_this.m_localYAxisA=Vec2.crossNumVec2(1,_this.m_localXAxisA);_this.m_mass=0;_this.m_impulse=0;_this.m_motorMass=0;_this.m_motorImpulse=0;_this.m_springMass=0;_this.m_springImpulse=0;_this.m_maxMotorTorque=def.maxMotorTorque;_this.m_motorSpeed=def.motorSpeed;_this.m_enableMotor=def.enableMotor;_this.m_frequencyHz=def.frequencyHz;_this.m_dampingRatio=def.dampingRatio;_this.m_bias=0;_this.m_gamma=0;return _this}WheelJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,enableMotor:this.m_enableMotor,maxMotorTorque:this.m_maxMotorTorque,motorSpeed:this.m_motorSpeed,frequencyHz:this.m_frequencyHz,dampingRatio:this.m_dampingRatio,localAnchorA:this.m_localAnchorA,localAnchorB:this.m_localAnchorB,localAxisA:this.m_localXAxisA}};WheelJoint2._deserialize=function(data,world,restore){data=__assign$1({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);var joint=new WheelJoint2(data);return joint};WheelJoint2.prototype._reset=function(def){if(def.anchorA){this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA))}else if(def.localAnchorA){this.m_localAnchorA.setVec2(def.localAnchorA)}if(def.anchorB){this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB))}else if(def.localAnchorB){this.m_localAnchorB.setVec2(def.localAnchorB)}if(def.localAxisA){this.m_localXAxisA.setVec2(def.localAxisA);this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1,def.localAxisA))}if(def.enableMotor!==void 0){this.m_enableMotor=def.enableMotor}if(Number.isFinite(def.maxMotorTorque)){this.m_maxMotorTorque=def.maxMotorTorque}if(Number.isFinite(def.motorSpeed)){this.m_motorSpeed=def.motorSpeed}if(Number.isFinite(def.frequencyHz)){this.m_frequencyHz=def.frequencyHz}if(Number.isFinite(def.dampingRatio)){this.m_dampingRatio=def.dampingRatio}};WheelJoint2.prototype.getLocalAnchorA=function(){return this.m_localAnchorA};WheelJoint2.prototype.getLocalAnchorB=function(){return this.m_localAnchorB};WheelJoint2.prototype.getLocalAxisA=function(){return this.m_localXAxisA};WheelJoint2.prototype.getJointTranslation=function(){var bA=this.m_bodyA;var bB=this.m_bodyB;var pA2=bA.getWorldPoint(this.m_localAnchorA);var pB2=bB.getWorldPoint(this.m_localAnchorB);var d2=Vec2.sub(pB2,pA2);var axis=bA.getWorldVector(this.m_localXAxisA);var translation2=Vec2.dot(d2,axis);return translation2};WheelJoint2.prototype.getJointSpeed=function(){var wA=this.m_bodyA.m_angularVelocity;var wB=this.m_bodyB.m_angularVelocity;return wB-wA};WheelJoint2.prototype.isMotorEnabled=function(){return this.m_enableMotor};WheelJoint2.prototype.enableMotor=function(flag){if(flag==this.m_enableMotor)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_enableMotor=flag};WheelJoint2.prototype.setMotorSpeed=function(speed){if(speed==this.m_motorSpeed)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_motorSpeed=speed};WheelJoint2.prototype.getMotorSpeed=function(){return this.m_motorSpeed};WheelJoint2.prototype.setMaxMotorTorque=function(torque){if(torque==this.m_maxMotorTorque)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_maxMotorTorque=torque};WheelJoint2.prototype.getMaxMotorTorque=function(){return this.m_maxMotorTorque};WheelJoint2.prototype.getMotorTorque=function(inv_dt){return inv_dt*this.m_motorImpulse};WheelJoint2.prototype.setSpringFrequencyHz=function(hz){this.m_frequencyHz=hz};WheelJoint2.prototype.getSpringFrequencyHz=function(){return this.m_frequencyHz};WheelJoint2.prototype.setSpringDampingRatio=function(ratio){this.m_dampingRatio=ratio};WheelJoint2.prototype.getSpringDampingRatio=function(){return this.m_dampingRatio};WheelJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};WheelJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};WheelJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.combine(this.m_impulse,this.m_ay,this.m_springImpulse,this.m_ax).mul(inv_dt)};WheelJoint2.prototype.getReactionTorque=function(inv_dt){return inv_dt*this.m_motorImpulse};WheelJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter;this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var d2=Vec2.zero();d2.addCombine(1,cB2,1,rB2);d2.subCombine(1,cA2,1,rA2);{this.m_ay=Rot.mulVec2(qA,this.m_localYAxisA);this.m_sAy=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),this.m_ay);this.m_sBy=Vec2.crossVec2Vec2(rB2,this.m_ay);this.m_mass=mA+mB+iA*this.m_sAy*this.m_sAy+iB*this.m_sBy*this.m_sBy;if(this.m_mass>0){this.m_mass=1/this.m_mass}}this.m_springMass=0;this.m_bias=0;this.m_gamma=0;if(this.m_frequencyHz>0){this.m_ax=Rot.mulVec2(qA,this.m_localXAxisA);this.m_sAx=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),this.m_ax);this.m_sBx=Vec2.crossVec2Vec2(rB2,this.m_ax);var invMass=mA+mB+iA*this.m_sAx*this.m_sAx+iB*this.m_sBx*this.m_sBx;if(invMass>0){this.m_springMass=1/invMass;var C=Vec2.dot(d2,this.m_ax);var omega=2*math_PI$1*this.m_frequencyHz;var damp=2*this.m_springMass*this.m_dampingRatio*omega;var k=this.m_springMass*omega*omega;var h=step.dt;this.m_gamma=h*(damp+h*k);if(this.m_gamma>0){this.m_gamma=1/this.m_gamma}this.m_bias=C*h*k*this.m_gamma;this.m_springMass=invMass+this.m_gamma;if(this.m_springMass>0){this.m_springMass=1/this.m_springMass}}}else{this.m_springImpulse=0}if(this.m_enableMotor){this.m_motorMass=iA+iB;if(this.m_motorMass>0){this.m_motorMass=1/this.m_motorMass}}else{this.m_motorMass=0;this.m_motorImpulse=0}if(step.warmStarting){this.m_impulse*=step.dtRatio;this.m_springImpulse*=step.dtRatio;this.m_motorImpulse*=step.dtRatio;var P3=Vec2.combine(this.m_impulse,this.m_ay,this.m_springImpulse,this.m_ax);var LA=this.m_impulse*this.m_sAy+this.m_springImpulse*this.m_sAx+this.m_motorImpulse;var LB=this.m_impulse*this.m_sBy+this.m_springImpulse*this.m_sBx+this.m_motorImpulse;vA2.subMul(this.m_invMassA,P3);wA-=this.m_invIA*LA;vB2.addMul(this.m_invMassB,P3);wB+=this.m_invIB*LB}else{this.m_impulse=0;this.m_springImpulse=0;this.m_motorImpulse=0}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};WheelJoint2.prototype.solveVelocityConstraints=function(step){var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;{var Cdot=Vec2.dot(this.m_ax,vB2)-Vec2.dot(this.m_ax,vA2)+this.m_sBx*wB-this.m_sAx*wA;var impulse=-this.m_springMass*(Cdot+this.m_bias+this.m_gamma*this.m_springImpulse);this.m_springImpulse+=impulse;var P3=Vec2.mulNumVec2(impulse,this.m_ax);var LA=impulse*this.m_sAx;var LB=impulse*this.m_sBx;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}{var Cdot=wB-wA-this.m_motorSpeed;var impulse=-this.m_motorMass*Cdot;var oldImpulse=this.m_motorImpulse;var maxImpulse=step.dt*this.m_maxMotorTorque;this.m_motorImpulse=clamp$1(this.m_motorImpulse+impulse,-maxImpulse,maxImpulse);impulse=this.m_motorImpulse-oldImpulse;wA-=iA*impulse;wB+=iB*impulse}{var Cdot=Vec2.dot(this.m_ay,vB2)-Vec2.dot(this.m_ay,vA2)+this.m_sBy*wB-this.m_sAy*wA;var impulse=-this.m_mass*Cdot;this.m_impulse+=impulse;var P3=Vec2.mulNumVec2(impulse,this.m_ay);var LA=impulse*this.m_sAy;var LB=impulse*this.m_sBy;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};WheelJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var d2=Vec2.zero();d2.addCombine(1,cB2,1,rB2);d2.subCombine(1,cA2,1,rA2);var ay=Rot.mulVec2(qA,this.m_localYAxisA);var sAy=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),ay);var sBy=Vec2.crossVec2Vec2(rB2,ay);var C=Vec2.dot(d2,ay);var k=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_sAy*this.m_sAy+this.m_invIB*this.m_sBy*this.m_sBy;var impulse=k!=0?-C/k:0;var P3=Vec2.mulNumVec2(impulse,ay);var LA=impulse*sAy;var LB=impulse*sBy;cA2.subMul(this.m_invMassA,P3);aA-=this.m_invIA*LA;cB2.addMul(this.m_invMassB,P3);aB+=this.m_invIB*LB;this.m_bodyA.c_position.c.setVec2(cA2);this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c.setVec2(cB2);this.m_bodyB.c_position.a=aB;return math_abs$1(C)<=SettingsInternal.linearSlop};WheelJoint2.TYPE="wheel-joint";return WheelJoint2}(Joint);var _a;var SID=0;var SERIALIZE_REF_TYPES={World:World,Body:Body,Joint:Joint,Fixture:Fixture,Shape:Shape};var DESERIALIZE_BY_REF_TYPE={Vec2:Vec2,Vec3:Vec3,World:World,Body:Body,Joint:Joint,Fixture:Fixture,Shape:Shape};var DESERIALIZE_BY_TYPE_FIELD=(_a={},_a[Body.STATIC]=Body,_a[Body.DYNAMIC]=Body,_a[Body.KINEMATIC]=Body,_a[ChainShape.TYPE]=ChainShape,_a[PolygonShape.TYPE]=PolygonShape,_a[EdgeShape.TYPE]=EdgeShape,_a[CircleShape.TYPE]=CircleShape,_a[DistanceJoint.TYPE]=DistanceJoint,_a[FrictionJoint.TYPE]=FrictionJoint,_a[GearJoint.TYPE]=GearJoint,_a[MotorJoint.TYPE]=MotorJoint,_a[MouseJoint.TYPE]=MouseJoint,_a[PrismaticJoint.TYPE]=PrismaticJoint,_a[PulleyJoint.TYPE]=PulleyJoint,_a[RevoluteJoint.TYPE]=RevoluteJoint,_a[RopeJoint.TYPE]=RopeJoint,_a[WeldJoint.TYPE]=WeldJoint,_a[WheelJoint.TYPE]=WheelJoint,_a);var DEFAULT_OPTIONS={rootClass:World,preSerialize:function(obj){return obj},postSerialize:function(data,obj){return data},preDeserialize:function(data){return data},postDeserialize:function(obj,data){return obj}};var Serializer=function(){function Serializer2(options2){var _this=this;this.toJson=function(root){var preSerialize=_this.options.preSerialize;var postSerialize=_this.options.postSerialize;var json=[];var refQueue=[root];var refMemoById={};function addToRefQueue(value,typeName){value.__sid=value.__sid||++SID;if(!refMemoById[value.__sid]){refQueue.push(value);var index=json.length+refQueue.length;var ref={refIndex:index,refType:typeName};refMemoById[value.__sid]=ref}return refMemoById[value.__sid]}function serializeWithHooks(obj2){obj2=preSerialize(obj2);var data=obj2._serialize();data=postSerialize(data,obj2);return data}function traverse(value,noRefType){if(noRefType===void 0){noRefType=false}if(typeof value!=="object"||value===null){return value}if(typeof value._serialize==="function"){if(!noRefType){for(var typeName in SERIALIZE_REF_TYPES){if(value instanceof SERIALIZE_REF_TYPES[typeName]){return addToRefQueue(value,typeName)}}}value=serializeWithHooks(value)}if(Array.isArray(value)){var newValue=[];for(var key=0;keyradius*radius){return}manifold.type=exports2.ManifoldType.e_circles;copyVec2(manifold.localPoint,circleA.m_p);zeroVec2(manifold.localNormal);manifold.pointCount=1;copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex)};Contact.addType(EdgeShape.TYPE,CircleShape.TYPE,EdgeCircleContact);Contact.addType(ChainShape.TYPE,CircleShape.TYPE,ChainCircleContact);function EdgeCircleContact(manifold,xfA2,fixtureA,indexA,xfB2,fixtureB,indexB){var shapeA=fixtureA.getShape();var shapeB=fixtureB.getShape();CollideEdgeCircle(manifold,shapeA,xfA2,shapeB,xfB2)}function ChainCircleContact(manifold,xfA2,fixtureA,indexA,xfB2,fixtureB,indexB){var chain=fixtureA.getShape();var edge=new EdgeShape;chain.getChildEdge(edge,indexA);var shapeA=edge;var shapeB=fixtureB.getShape();CollideEdgeCircle(manifold,shapeA,xfA2,shapeB,xfB2)}var e=vec2(0,0);var e1=vec2(0,0);var e2=vec2(0,0);var Q=vec2(0,0);var P=vec2(0,0);var n$2=vec2(0,0);var CollideEdgeCircle=function(manifold,edgeA,xfA2,circleB,xfB2){manifold.pointCount=0;retransformVec2(Q,xfB2,xfA2,circleB.m_p);var A=edgeA.m_vertex1;var B=edgeA.m_vertex2;subVec2(e,B,A);var u=dotVec2(e,B)-dotVec2(e,Q);var v3=dotVec2(e,Q)-dotVec2(e,A);var radius=edgeA.m_radius+circleB.m_radius;if(v3<=0){copyVec2(P,A);var dd_1=distSqrVec2(Q,A);if(dd_1>radius*radius){return}if(edgeA.m_hasVertex0){var A1=edgeA.m_vertex0;var B1=A;subVec2(e1,B1,A1);var u1=dotVec2(e1,B1)-dotVec2(e1,Q);if(u1>0){return}}manifold.type=exports2.ManifoldType.e_circles;zeroVec2(manifold.localNormal);copyVec2(manifold.localPoint,P);manifold.pointCount=1;copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex);return}if(u<=0){copyVec2(P,B);var dd_2=distSqrVec2(Q,P);if(dd_2>radius*radius){return}if(edgeA.m_hasVertex3){var B2=edgeA.m_vertex3;var A2=B;subVec2(e2,B2,A2);var v22=dotVec2(e2,Q)-dotVec2(e2,A2);if(v22>0){return}}manifold.type=exports2.ManifoldType.e_circles;zeroVec2(manifold.localNormal);copyVec2(manifold.localPoint,P);manifold.pointCount=1;copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(1,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex);return}var den=lengthSqrVec2(e);combine2Vec2(P,u/den,A,v3/den,B);var dd=distSqrVec2(Q,P);if(dd>radius*radius){return}crossNumVec2(n$2,1,e);if(dotVec2(n$2,Q)-dotVec2(n$2,A)<0){negVec2(n$2)}normalizeVec2(n$2);manifold.type=exports2.ManifoldType.e_faceA;copyVec2(manifold.localNormal,n$2);copyVec2(manifold.localPoint,A);manifold.pointCount=1;copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_face,0,exports2.ContactFeatureType.e_vertex)};var incidentEdge=[new ClipVertex,new ClipVertex];var clipPoints1$1=[new ClipVertex,new ClipVertex];var clipPoints2$1=[new ClipVertex,new ClipVertex];var clipSegmentToLineNormal=vec2(0,0);var v1=vec2(0,0);var n$1=vec2(0,0);var xf$1=transform(0,0,0);var v11=vec2(0,0);var v12=vec2(0,0);var localTangent=vec2(0,0);var localNormal=vec2(0,0);var planePoint=vec2(0,0);var tangent=vec2(0,0);var normal$1=vec2(0,0);var normal1$1=vec2(0,0);Contact.addType(PolygonShape.TYPE,PolygonShape.TYPE,PolygonContact);function PolygonContact(manifold,xfA2,fixtureA,indexA,xfB2,fixtureB,indexB){CollidePolygons(manifold,fixtureA.getShape(),xfA2,fixtureB.getShape(),xfB2)}function findMaxSeparation(poly1,xf1,poly2,xf2,output2){var count1=poly1.m_count;var count2=poly2.m_count;var n1s=poly1.m_normals;var v1s=poly1.m_vertices;var v2s=poly2.m_vertices;detransformTransform(xf$1,xf2,xf1);var bestIndex=0;var maxSeparation2=-Infinity;for(var i=0;imaxSeparation2){maxSeparation2=si;bestIndex=i}}output2.maxSeparation=maxSeparation2;output2.bestIndex=bestIndex}function findIncidentEdge(clipVertex,poly1,xf1,edge12,poly2,xf2){var normals1=poly1.m_normals;var count2=poly2.m_count;var vertices2=poly2.m_vertices;var normals2=poly2.m_normals;rerotVec2(normal1$1,xf2.q,xf1.q,normals1[edge12]);var index=0;var minDot=Infinity;for(var i=0;itotalRadius)return;findMaxSeparation(polyB,xfB2,polyA,xfA2,maxSeparation);var edgeB=maxSeparation.bestIndex;var separationB=maxSeparation.maxSeparation;if(separationB>totalRadius)return;var poly1;var poly2;var xf1;var xf2;var edge12;var flip;var k_tol=.1*SettingsInternal.linearSlop;if(separationB>separationA+k_tol){poly1=polyB;poly2=polyA;xf1=xfB2;xf2=xfA2;edge12=edgeB;manifold.type=exports2.ManifoldType.e_faceB;flip=true}else{poly1=polyA;poly2=polyB;xf1=xfA2;xf2=xfB2;edge12=edgeA;manifold.type=exports2.ManifoldType.e_faceA;flip=false}incidentEdge[0].recycle();incidentEdge[1].recycle();findIncidentEdge(incidentEdge,poly1,xf1,edge12,poly2,xf2);var count1=poly1.m_count;var vertices1=poly1.m_vertices;var iv1=edge12;var iv2=edge12+1radius){return}if(s2>separation){separation=s2;normalIndex=i}}var vertIndex1=normalIndex;var vertIndex2=vertIndex1+1radius*radius){return}manifold.pointCount=1;manifold.type=exports2.ManifoldType.e_faceA;subVec2(manifold.localNormal,cLocal,v13);normalizeVec2(manifold.localNormal);copyVec2(manifold.localPoint,v13);copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex)}else if(u2<=0){if(distSqrVec2(cLocal,v22)>radius*radius){return}manifold.pointCount=1;manifold.type=exports2.ManifoldType.e_faceA;subVec2(manifold.localNormal,cLocal,v22);normalizeVec2(manifold.localNormal);copyVec2(manifold.localPoint,v22);copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex)}else{combine2Vec2(faceCenter,.5,v13,.5,v22);var separation_1=dotVec2(cLocal,normals[vertIndex1])-dotVec2(faceCenter,normals[vertIndex1]);if(separation_1>radius){return}manifold.pointCount=1;manifold.type=exports2.ManifoldType.e_faceA;copyVec2(manifold.localNormal,normals[vertIndex1]);copyVec2(manifold.localPoint,faceCenter);copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex)}};var math_min$1=Math.min;Contact.addType(EdgeShape.TYPE,PolygonShape.TYPE,EdgePolygonContact);Contact.addType(ChainShape.TYPE,PolygonShape.TYPE,ChainPolygonContact);function EdgePolygonContact(manifold,xfA2,fA,indexA,xfB2,fB,indexB){CollideEdgePolygon(manifold,fA.getShape(),xfA2,fB.getShape(),xfB2)}var edge_reuse=new EdgeShape;function ChainPolygonContact(manifold,xfA2,fA,indexA,xfB2,fB,indexB){var chain=fA.getShape();chain.getChildEdge(edge_reuse,indexA);CollideEdgePolygon(manifold,edge_reuse,xfA2,fB.getShape(),xfB2)}var EPAxisType;(function(EPAxisType2){EPAxisType2[EPAxisType2["e_unknown"]=-1]="e_unknown";EPAxisType2[EPAxisType2["e_edgeA"]=1]="e_edgeA";EPAxisType2[EPAxisType2["e_edgeB"]=2]="e_edgeB"})(EPAxisType||(EPAxisType={}));var VertexType;(function(VertexType2){VertexType2[VertexType2["e_isolated"]=0]="e_isolated";VertexType2[VertexType2["e_concave"]=1]="e_concave";VertexType2[VertexType2["e_convex"]=2]="e_convex"})(VertexType||(VertexType={}));var EPAxis=function(){function EPAxis2(){}return EPAxis2}();var TempPolygon=function(){function TempPolygon2(){this.vertices=[];this.normals=[];this.count=0;for(var i=0;i=0;offset0=Vec2.dot(normal0,centroidB)-Vec2.dot(normal0,v0)}if(hasVertex3){subVec2(edge2,v3,v22);normalizeVec2(edge2);setVec2(normal2,edge2.y,-edge2.x);convex2=Vec2.crossVec2Vec2(edge1,edge2)>0;offset2=Vec2.dot(normal2,centroidB)-Vec2.dot(normal2,v22)}var front;zeroVec2(normal);zeroVec2(lowerLimit);zeroVec2(upperLimit);if(hasVertex0&&hasVertex3){if(convex1&&convex2){front=offset0>=0||offset1>=0||offset2>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal0);copyVec2(upperLimit,normal2)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal1);scaleVec2(upperLimit,-1,normal1)}}else if(convex1){front=offset0>=0||offset1>=0&&offset2>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal0);copyVec2(upperLimit,normal1)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal2);scaleVec2(upperLimit,-1,normal1)}}else if(convex2){front=offset2>=0||offset0>=0&&offset1>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal1);copyVec2(upperLimit,normal2)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal1);scaleVec2(upperLimit,-1,normal0)}}else{front=offset0>=0&&offset1>=0&&offset2>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal1);copyVec2(upperLimit,normal1)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal2);scaleVec2(upperLimit,-1,normal0)}}}else if(hasVertex0){if(convex1){front=offset0>=0||offset1>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal0);scaleVec2(upperLimit,-1,normal1)}else{scaleVec2(normal,-1,normal1);copyVec2(lowerLimit,normal1);scaleVec2(upperLimit,-1,normal1)}}else{front=offset0>=0&&offset1>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal1);scaleVec2(upperLimit,-1,normal1)}else{scaleVec2(normal,-1,normal1);copyVec2(lowerLimit,normal1);scaleVec2(upperLimit,-1,normal0)}}}else if(hasVertex3){if(convex2){front=offset1>=0||offset2>=0;if(front){copyVec2(normal,normal1);scaleVec2(lowerLimit,-1,normal1);copyVec2(upperLimit,normal2)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal1);copyVec2(upperLimit,normal1)}}else{front=offset1>=0&&offset2>=0;if(front){copyVec2(normal,normal1);scaleVec2(lowerLimit,-1,normal1);copyVec2(upperLimit,normal1)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal2);copyVec2(upperLimit,normal1)}}}else{front=offset1>=0;if(front){copyVec2(normal,normal1);scaleVec2(lowerLimit,-1,normal1);scaleVec2(upperLimit,-1,normal1)}else{scaleVec2(normal,-1,normal1);copyVec2(lowerLimit,normal1);copyVec2(upperLimit,normal1)}}polygonBA.count=polygonB.m_count;for(var i=0;iradius){return}{polygonAxis.type=EPAxisType.e_unknown;polygonAxis.index=-1;polygonAxis.separation=-Infinity;setVec2(perp,-normal.y,normal.x);for(var i=0;iradius){polygonAxis.type=EPAxisType.e_edgeB;polygonAxis.index=i;polygonAxis.separation=s2;break}if(dotVec2(n,perp)>=0){if(dotVec2(n,normal)-dotVec2(upperLimit,normal)<-SettingsInternal.angularSlop){continue}}else{if(dotVec2(n,normal)-dotVec2(lowerLimit,normal)<-SettingsInternal.angularSlop){continue}}if(s2>polygonAxis.separation){polygonAxis.type=EPAxisType.e_edgeB;polygonAxis.index=i;polygonAxis.separation=s2}}}if(polygonAxis.type!=EPAxisType.e_unknown&&polygonAxis.separation>radius){return}var k_relativeTol=.98;var k_absoluteTol=.001;var primaryAxis;if(polygonAxis.type==EPAxisType.e_unknown){primaryAxis=edgeAxis}else if(polygonAxis.separation>k_relativeTol*edgeAxis.separation+k_absoluteTol){primaryAxis=polygonAxis}else{primaryAxis=edgeAxis}ie[0].recycle();ie[1].recycle();if(primaryAxis.type==EPAxisType.e_edgeA){manifold.type=exports2.ManifoldType.e_faceA;var bestIndex=0;var bestValue=dotVec2(normal,polygonBA.normals[0]);for(var i=1;i>1;x2|=x2>>2;x2|=x2>>4;x2|=x2>>8;x2|=x2>>16;return x2+1}function isPowerOfTwo(x2){return x2>0&&(x2&x2-1)===0}function mod(num,min,max){if(typeof min==="undefined"){max=1;min=0}else if(typeof max==="undefined"){max=min;min=0}if(max>min){num=(num-min)%(max-min);return num+(num<0?max:min)}else{num=(num-max)%(min-max);return num+(num<=0?min:max)}}function clamp$1(num,min,max){if(nummax){return max}else{return num}}function random$1(min,max){if(typeof min==="undefined"){max=1;min=0}else if(typeof max==="undefined"){max=min;min=0}return min===max?min:math_random$1()*(max-min)+min}var math$1=Object.create(Math);math$1.EPSILON=EPSILON;math$1.isFinite=isFinite;math$1.nextPowerOfTwo=nextPowerOfTwo;math$1.isPowerOfTwo=isPowerOfTwo;math$1.mod=mod;math$1.clamp=clamp$1;math$1.random=random$1;var math_abs$a=Math.abs;var math_sqrt$7=Math.sqrt;var math_max$9=Math.max;var math_min$9=Math.min;var Vec2=function(){function Vec22(x2,y){if(!(this instanceof Vec22)){return new Vec22(x2,y)}if(typeof x2==="undefined"){this.x=0;this.y=0}else if(typeof x2==="object"){this.x=x2.x;this.y=x2.y}else{this.x=x2;this.y=y}}Vec22.prototype._serialize=function(){return{x:this.x,y:this.y}};Vec22._deserialize=function(data){var obj=Object.create(Vec22.prototype);obj.x=data.x;obj.y=data.y;return obj};Vec22.zero=function(){var obj=Object.create(Vec22.prototype);obj.x=0;obj.y=0;return obj};Vec22.neo=function(x2,y){var obj=Object.create(Vec22.prototype);obj.x=x2;obj.y=y;return obj};Vec22.clone=function(v3){return Vec22.neo(v3.x,v3.y)};Vec22.prototype.toString=function(){return JSON.stringify(this)};Vec22.isValid=function(obj){if(obj===null||typeof obj==="undefined"){return false}return Number.isFinite(obj.x)&&Number.isFinite(obj.y)};Vec22.assert=function(o){};Vec22.prototype.clone=function(){return Vec22.clone(this)};Vec22.prototype.setZero=function(){this.x=0;this.y=0;return this};Vec22.prototype.set=function(x2,y){if(typeof x2==="object"){this.x=x2.x;this.y=x2.y}else{this.x=x2;this.y=y}return this};Vec22.prototype.setNum=function(x2,y){this.x=x2;this.y=y;return this};Vec22.prototype.setVec2=function(value){this.x=value.x;this.y=value.y;return this};Vec22.prototype.wSet=function(a2,v3,b2,w){if(typeof b2!=="undefined"||typeof w!=="undefined"){return this.setCombine(a2,v3,b2,w)}else{return this.setMul(a2,v3)}};Vec22.prototype.setCombine=function(a2,v3,b2,w){var x2=a2*v3.x+b2*w.x;var y=a2*v3.y+b2*w.y;this.x=x2;this.y=y;return this};Vec22.prototype.setMul=function(a2,v3){var x2=a2*v3.x;var y=a2*v3.y;this.x=x2;this.y=y;return this};Vec22.prototype.add=function(w){this.x+=w.x;this.y+=w.y;return this};Vec22.prototype.wAdd=function(a2,v3,b2,w){if(typeof b2!=="undefined"||typeof w!=="undefined"){return this.addCombine(a2,v3,b2,w)}else{return this.addMul(a2,v3)}};Vec22.prototype.addCombine=function(a2,v3,b2,w){var x2=a2*v3.x+b2*w.x;var y=a2*v3.y+b2*w.y;this.x+=x2;this.y+=y;return this};Vec22.prototype.addMul=function(a2,v3){var x2=a2*v3.x;var y=a2*v3.y;this.x+=x2;this.y+=y;return this};Vec22.prototype.wSub=function(a2,v3,b2,w){if(typeof b2!=="undefined"||typeof w!=="undefined"){return this.subCombine(a2,v3,b2,w)}else{return this.subMul(a2,v3)}};Vec22.prototype.subCombine=function(a2,v3,b2,w){var x2=a2*v3.x+b2*w.x;var y=a2*v3.y+b2*w.y;this.x-=x2;this.y-=y;return this};Vec22.prototype.subMul=function(a2,v3){var x2=a2*v3.x;var y=a2*v3.y;this.x-=x2;this.y-=y;return this};Vec22.prototype.sub=function(w){this.x-=w.x;this.y-=w.y;return this};Vec22.prototype.mul=function(m){this.x*=m;this.y*=m;return this};Vec22.prototype.length=function(){return Vec22.lengthOf(this)};Vec22.prototype.lengthSquared=function(){return Vec22.lengthSquared(this)};Vec22.prototype.normalize=function(){var length2=this.length();if(length2max*max){var scale=max/math_sqrt$7(lengthSqr);this.x*=scale;this.y*=scale}return this};Vec22.clamp=function(v3,max){var r=Vec22.neo(v3.x,v3.y);r.clamp(max);return r};Vec22.clampVec2=function(v3,min,max){return{x:clamp$1(v3.x,min===null||min===void 0?void 0:min.x,max===null||max===void 0?void 0:max.x),y:clamp$1(v3.y,min===null||min===void 0?void 0:min.y,max===null||max===void 0?void 0:max.y)}};Vec22.scaleFn=function(x2,y){return function(v3){return Vec22.neo(v3.x*x2,v3.y*y)}};Vec22.translateFn=function(x2,y){return function(v3){return Vec22.neo(v3.x+x2,v3.y+y)}};return Vec22}();var math_max$8=Math.max;var math_min$8=Math.min;var AABB=function(){function AABB2(lower,upper){if(!(this instanceof AABB2)){return new AABB2(lower,upper)}this.lowerBound=Vec2.zero();this.upperBound=Vec2.zero();if(typeof lower==="object"){this.lowerBound.setVec2(lower)}if(typeof upper==="object"){this.upperBound.setVec2(upper)}else if(typeof lower==="object"){this.upperBound.setVec2(lower)}}AABB2.prototype.isValid=function(){return AABB2.isValid(this)};AABB2.isValid=function(obj){if(obj===null||typeof obj==="undefined"){return false}return Vec2.isValid(obj.lowerBound)&&Vec2.isValid(obj.upperBound)&&Vec2.sub(obj.upperBound,obj.lowerBound).lengthSquared()>=0};AABB2.assert=function(o){};AABB2.prototype.getCenter=function(){return Vec2.neo((this.lowerBound.x+this.upperBound.x)*.5,(this.lowerBound.y+this.upperBound.y)*.5)};AABB2.prototype.getExtents=function(){return Vec2.neo((this.upperBound.x-this.lowerBound.x)*.5,(this.upperBound.y-this.lowerBound.y)*.5)};AABB2.prototype.getPerimeter=function(){return 2*(this.upperBound.x-this.lowerBound.x+this.upperBound.y-this.lowerBound.y)};AABB2.prototype.combine=function(a2,b2){b2=b2||this;var lowerA=a2.lowerBound;var upperA=a2.upperBound;var lowerB=b2.lowerBound;var upperB=b2.upperBound;var lowerX=math_min$8(lowerA.x,lowerB.x);var lowerY=math_min$8(lowerA.y,lowerB.y);var upperX=math_max$8(upperB.x,upperA.x);var upperY=math_max$8(upperB.y,upperA.y);this.lowerBound.setNum(lowerX,lowerY);this.upperBound.setNum(upperX,upperY)};AABB2.prototype.combinePoints=function(a2,b2){this.lowerBound.setNum(math_min$8(a2.x,b2.x),math_min$8(a2.y,b2.y));this.upperBound.setNum(math_max$8(a2.x,b2.x),math_max$8(a2.y,b2.y))};AABB2.prototype.set=function(aabb){this.lowerBound.setNum(aabb.lowerBound.x,aabb.lowerBound.y);this.upperBound.setNum(aabb.upperBound.x,aabb.upperBound.y)};AABB2.prototype.contains=function(aabb){var result=true;result=result&&this.lowerBound.x<=aabb.lowerBound.x;result=result&&this.lowerBound.y<=aabb.lowerBound.y;result=result&&aabb.upperBound.x<=this.upperBound.x;result=result&&aabb.upperBound.y<=this.upperBound.y;return result};AABB2.prototype.extend=function(value){AABB2.extend(this,value);return this};AABB2.extend=function(out,value){out.lowerBound.x-=value;out.lowerBound.y-=value;out.upperBound.x+=value;out.upperBound.y+=value;return out};AABB2.testOverlap=function(a2,b2){var d1x=b2.lowerBound.x-a2.upperBound.x;var d2x=a2.lowerBound.x-b2.upperBound.x;var d1y=b2.lowerBound.y-a2.upperBound.y;var d2y=a2.lowerBound.y-b2.upperBound.y;if(d1x>0||d1y>0||d2x>0||d2y>0){return false}return true};AABB2.areEqual=function(a2,b2){return Vec2.areEqual(a2.lowerBound,b2.lowerBound)&&Vec2.areEqual(a2.upperBound,b2.upperBound)};AABB2.diff=function(a2,b2){var wD=math_max$8(0,math_min$8(a2.upperBound.x,b2.upperBound.x)-math_max$8(b2.lowerBound.x,a2.lowerBound.x));var hD=math_max$8(0,math_min$8(a2.upperBound.y,b2.upperBound.y)-math_max$8(b2.lowerBound.y,a2.lowerBound.y));var wA=a2.upperBound.x-a2.lowerBound.x;var hA=a2.upperBound.y-a2.lowerBound.y;var wB=b2.upperBound.x-b2.lowerBound.x;var hB=b2.upperBound.y-b2.lowerBound.y;return wA*hA+wB*hB-wD*hD};AABB2.prototype.rayCast=function(output2,input2){var tmin=-Infinity;var tmax=Infinity;var p=input2.p1;var d2=Vec2.sub(input2.p2,input2.p1);var absD=Vec2.abs(d2);var normal3=Vec2.zero();for(var f="x";f!==null;f=f==="x"?"y":null){if(absD.xt2){var temp3=t1;t1=t2;t2=temp3;s2=1}if(t1>tmin){normal3.setZero();normal3[f]=s2;tmin=t1}tmax=math_min$8(tmax,t2);if(tmin>tmax){return false}}}if(tmin<0||input2.maxFraction0){item=this._list.shift()}else{this._createCount++;if(this._hasCreateFn){item=this._createFn()}else{item={}}}this._allocateCount++;if(this._hasAllocateFn){this._allocateFn(item)}return item};Pool2.prototype.release=function(item){if(this._list.length"+this._allocateCount+" <"+this._releaseCount+" -"+this._disposeCount+" ="+this._list.length+"/"+this._max};return Pool2}();var math_abs$9=Math.abs;var math_max$7=Math.max;var TreeNode=function(){function TreeNode2(id){this.aabb=new AABB;this.userData=null;this.parent=null;this.child1=null;this.child2=null;this.height=-1;this.id=id}TreeNode2.prototype.toString=function(){return this.id+": "+this.userData};TreeNode2.prototype.isLeaf=function(){return this.child1==null};return TreeNode2}();var poolTreeNode=new Pool({create:function(){return new TreeNode},release:function(node){node.userData=null;node.parent=null;node.child1=null;node.child2=null;node.height=-1;node.id=void 0}});var DynamicTree=function(){function DynamicTree2(){this.inputPool=new Pool({create:function(){return{}},release:function(stack){}});this.stackPool=new Pool({create:function(){return[]},release:function(stack){stack.length=0}});this.iteratorPool=new Pool({create:function(){return new Iterator},release:function(iterator){iterator.close()}});this.m_root=null;this.m_nodes={};this.m_lastProxyId=0}DynamicTree2.prototype.getUserData=function(id){var node=this.m_nodes[id];return node.userData};DynamicTree2.prototype.getFatAABB=function(id){var node=this.m_nodes[id];return node.aabb};DynamicTree2.prototype.allocateNode=function(){var node=poolTreeNode.allocate();node.id=++this.m_lastProxyId;this.m_nodes[node.id]=node;return node};DynamicTree2.prototype.freeNode=function(node){delete this.m_nodes[node.id];poolTreeNode.release(node)};DynamicTree2.prototype.createProxy=function(aabb,userData){var node=this.allocateNode();node.aabb.set(aabb);AABB.extend(node.aabb,SettingsInternal.aabbExtension);node.userData=userData;node.height=0;this.insertLeaf(node);return node.id};DynamicTree2.prototype.destroyProxy=function(id){var node=this.m_nodes[id];this.removeLeaf(node);this.freeNode(node)};DynamicTree2.prototype.moveProxy=function(id,aabb,d2){var node=this.m_nodes[id];if(node.aabb.contains(aabb)){return false}this.removeLeaf(node);node.aabb.set(aabb);aabb=node.aabb;AABB.extend(aabb,SettingsInternal.aabbExtension);if(d2.x<0){aabb.lowerBound.x+=d2.x*SettingsInternal.aabbMultiplier}else{aabb.upperBound.x+=d2.x*SettingsInternal.aabbMultiplier}if(d2.y<0){aabb.lowerBound.y+=d2.y*SettingsInternal.aabbMultiplier}else{aabb.upperBound.y+=d2.y*SettingsInternal.aabbMultiplier}this.insertLeaf(node);return true};DynamicTree2.prototype.insertLeaf=function(leaf){if(this.m_root==null){this.m_root=leaf;this.m_root.parent=null;return}var leafAABB=leaf.aabb;var index=this.m_root;while(!index.isLeaf()){var child1=index.child1;var child2=index.child2;var area=index.aabb.getPerimeter();var combinedArea=AABB.combinedPerimeter(index.aabb,leafAABB);var cost=2*combinedArea;var inheritanceCost=2*(combinedArea-area);var newArea1=AABB.combinedPerimeter(leafAABB,child1.aabb);var cost1=newArea1+inheritanceCost;if(!child1.isLeaf()){var oldArea=child1.aabb.getPerimeter();cost1-=oldArea}var newArea2=AABB.combinedPerimeter(leafAABB,child2.aabb);var cost2=newArea2+inheritanceCost;if(!child2.isLeaf()){var oldArea=child2.aabb.getPerimeter();cost2-=oldArea}if(cost1){var F=C.child1;var G=C.child2;C.child1=A;C.parent=A.parent;A.parent=C;if(C.parent!=null){if(C.parent.child1===iA){C.parent.child1=C}else{C.parent.child2=C}}else{this.m_root=C}if(F.height>G.height){C.child2=F;A.child2=G;G.parent=A;A.aabb.combine(B.aabb,G.aabb);C.aabb.combine(A.aabb,F.aabb);A.height=1+math_max$7(B.height,G.height);C.height=1+math_max$7(A.height,F.height)}else{C.child2=G;A.child2=F;F.parent=A;A.aabb.combine(B.aabb,F.aabb);C.aabb.combine(A.aabb,G.aabb);A.height=1+math_max$7(B.height,F.height);C.height=1+math_max$7(A.height,G.height)}return C}if(balance<-1){var D=B.child1;var E=B.child2;B.child1=A;B.parent=A.parent;A.parent=B;if(B.parent!=null){if(B.parent.child1===A){B.parent.child1=B}else{B.parent.child2=B}}else{this.m_root=B}if(D.height>E.height){B.child2=D;A.child1=E;E.parent=A;A.aabb.combine(C.aabb,E.aabb);B.aabb.combine(A.aabb,D.aabb);A.height=1+math_max$7(C.height,E.height);B.height=1+math_max$7(A.height,D.height)}else{B.child2=E;A.child1=D;D.parent=A;A.aabb.combine(C.aabb,D.aabb);B.aabb.combine(A.aabb,E.aabb);A.height=1+math_max$7(C.height,D.height);B.height=1+math_max$7(A.height,E.height)}return B}return A};DynamicTree2.prototype.getHeight=function(){if(this.m_root==null){return 0}return this.m_root.height};DynamicTree2.prototype.getAreaRatio=function(){if(this.m_root==null){return 0}var root=this.m_root;var rootArea=root.aabb.getPerimeter();var totalArea=0;var node;var it=this.iteratorPool.allocate().preorder(this.m_root);while(node=it.next()){if(node.height<0){continue}totalArea+=node.aabb.getPerimeter()}this.iteratorPool.release(it);return totalArea/rootArea};DynamicTree2.prototype.computeHeight=function(id){var node;if(typeof id!=="undefined"){node=this.m_nodes[id]}else{node=this.m_root}if(node.isLeaf()){return 0}var height1=this.computeHeight(node.child1.id);var height2=this.computeHeight(node.child2.id);return 1+math_max$7(height1,height2)};DynamicTree2.prototype.validateStructure=function(node){if(node==null){return}if(node===this.m_root);var child1=node.child1;var child2=node.child2;if(node.isLeaf()){return}this.validateStructure(child1);this.validateStructure(child2)};DynamicTree2.prototype.validateMetrics=function(node){if(node==null){return}var child1=node.child1;var child2=node.child2;if(node.isLeaf()){return}child1.height;child2.height;var aabb=new AABB;aabb.combine(child1.aabb,child2.aabb);this.validateMetrics(child1);this.validateMetrics(child2)};DynamicTree2.prototype.validate=function(){return};DynamicTree2.prototype.getMaxBalance=function(){var maxBalance=0;var node;var it=this.iteratorPool.allocate().preorder(this.m_root);while(node=it.next()){if(node.height<=1){continue}var balance=math_abs$9(node.child2.height-node.child1.height);maxBalance=math_max$7(maxBalance,balance)}this.iteratorPool.release(it);return maxBalance};DynamicTree2.prototype.rebuildBottomUp=function(){var nodes=[];var count=0;var node;var it=this.iteratorPool.allocate().preorder(this.m_root);while(node=it.next()){if(node.height<0){continue}if(node.isLeaf()){node.parent=null;nodes[count]=node;++count}else{this.freeNode(node)}}this.iteratorPool.release(it);while(count>1){var minCost=Infinity;var iMin=-1;var jMin=-1;for(var i=0;i0){var node=stack.pop();if(node==null){continue}if(AABB.testOverlap(node.aabb,aabb)){if(node.isLeaf()){var proceed=queryCallback(node.id);if(proceed===false){return}}else{stack.push(node.child1);stack.push(node.child2)}}}this.stackPool.release(stack)};DynamicTree2.prototype.rayCast=function(input2,rayCastCallback){var p1=input2.p1;var p2=input2.p2;var r=Vec2.sub(p2,p1);r.normalize();var v3=Vec2.crossNumVec2(1,r);var abs_v=Vec2.abs(v3);var maxFraction=input2.maxFraction;var segmentAABB=new AABB;var t=Vec2.combine(1-maxFraction,p1,maxFraction,p2);segmentAABB.combinePoints(p1,t);var stack=this.stackPool.allocate();var subInput=this.inputPool.allocate();stack.push(this.m_root);while(stack.length>0){var node=stack.pop();if(node==null){continue}if(AABB.testOverlap(node.aabb,segmentAABB)===false){continue}var c2=node.aabb.getCenter();var h=node.aabb.getExtents();var separation=math_abs$9(Vec2.dot(v3,Vec2.sub(p1,c2)))-Vec2.dot(abs_v,h);if(separation>0){continue}if(node.isLeaf()){subInput.p1=Vec2.clone(input2.p1);subInput.p2=Vec2.clone(input2.p2);subInput.maxFraction=maxFraction;var value=rayCastCallback(subInput,node.id);if(value===0){break}else if(value>0){maxFraction=value;t=Vec2.combine(1-maxFraction,p1,maxFraction,p2);segmentAABB.combinePoints(p1,t)}}else{stack.push(node.child1);stack.push(node.child2)}}this.stackPool.release(stack);this.inputPool.release(subInput)};return DynamicTree2}();var Iterator=function(){function Iterator2(){this.parents=[];this.states=[]}Iterator2.prototype.preorder=function(root){this.parents.length=0;this.parents.push(root);this.states.length=0;this.states.push(0);return this};Iterator2.prototype.next=function(){while(this.parents.length>0){var i=this.parents.length-1;var node=this.parents[i];if(this.states[i]===0){this.states[i]=1;return node}if(this.states[i]===1){this.states[i]=2;if(node.child1){this.parents.push(node.child1);this.states.push(1);return node.child1}}if(this.states[i]===2){this.states[i]=3;if(node.child2){this.parents.push(node.child2);this.states.push(1);return node.child2}}this.parents.pop();this.states.pop()}};Iterator2.prototype.close=function(){this.parents.length=0};return Iterator2}();var math_max$6=Math.max;var math_min$7=Math.min;var BroadPhase=function(){function BroadPhase2(){var _this=this;this.m_tree=new DynamicTree;this.m_moveBuffer=[];this.query=function(aabb,queryCallback){_this.m_tree.query(aabb,queryCallback)};this.queryCallback=function(proxyId){if(proxyId===_this.m_queryProxyId){return true}var proxyIdA=math_min$7(proxyId,_this.m_queryProxyId);var proxyIdB=math_max$6(proxyId,_this.m_queryProxyId);var userDataA=_this.m_tree.getUserData(proxyIdA);var userDataB=_this.m_tree.getUserData(proxyIdB);_this.m_callback(userDataA,userDataB);return true}}BroadPhase2.prototype.getUserData=function(proxyId){return this.m_tree.getUserData(proxyId)};BroadPhase2.prototype.testOverlap=function(proxyIdA,proxyIdB){var aabbA=this.m_tree.getFatAABB(proxyIdA);var aabbB=this.m_tree.getFatAABB(proxyIdB);return AABB.testOverlap(aabbA,aabbB)};BroadPhase2.prototype.getFatAABB=function(proxyId){return this.m_tree.getFatAABB(proxyId)};BroadPhase2.prototype.getProxyCount=function(){return this.m_moveBuffer.length};BroadPhase2.prototype.getTreeHeight=function(){return this.m_tree.getHeight()};BroadPhase2.prototype.getTreeBalance=function(){return this.m_tree.getMaxBalance()};BroadPhase2.prototype.getTreeQuality=function(){return this.m_tree.getAreaRatio()};BroadPhase2.prototype.rayCast=function(input2,rayCastCallback){this.m_tree.rayCast(input2,rayCastCallback)};BroadPhase2.prototype.shiftOrigin=function(newOrigin){this.m_tree.shiftOrigin(newOrigin)};BroadPhase2.prototype.createProxy=function(aabb,userData){var proxyId=this.m_tree.createProxy(aabb,userData);this.bufferMove(proxyId);return proxyId};BroadPhase2.prototype.destroyProxy=function(proxyId){this.unbufferMove(proxyId);this.m_tree.destroyProxy(proxyId)};BroadPhase2.prototype.moveProxy=function(proxyId,aabb,displacement2){var changed=this.m_tree.moveProxy(proxyId,aabb,displacement2);if(changed){this.bufferMove(proxyId)}};BroadPhase2.prototype.touchProxy=function(proxyId){this.bufferMove(proxyId)};BroadPhase2.prototype.bufferMove=function(proxyId){this.m_moveBuffer.push(proxyId)};BroadPhase2.prototype.unbufferMove=function(proxyId){for(var i=0;i0){this.m_queryProxyId=this.m_moveBuffer.pop();if(this.m_queryProxyId===null){continue}var fatAABB=this.m_tree.getFatAABB(this.m_queryProxyId);this.m_tree.query(fatAABB,this.queryCallback)}};return BroadPhase2}();var math_sin$2=Math.sin;var math_cos$2=Math.cos;var math_sqrt$6=Math.sqrt;function vec2(x2,y){return{x:x2,y:y}}function rotation(angle){return{s:math_sin$2(angle),c:math_cos$2(angle)}}function setVec2(out,x2,y){out.x=x2;out.y=y;return out}function copyVec2(out,w){out.x=w.x;out.y=w.y;return out}function zeroVec2(out){out.x=0;out.y=0;return out}function negVec2(out){out.x=-out.x;out.y=-out.y;return out}function plusVec2(out,w){out.x+=w.x;out.y+=w.y;return out}function addVec2(out,v3,w){out.x=v3.x+w.x;out.y=v3.x+w.y;return out}function minusVec2(out,w){out.x-=w.x;out.y-=w.y;return out}function subVec2(out,v3,w){out.x=v3.x-w.x;out.y=v3.y-w.y;return out}function mulVec2(out,m){out.x*=m;out.y*=m;return out}function scaleVec2(out,m,w){out.x=m*w.x;out.y=m*w.y;return out}function plusScaleVec2(out,m,w){out.x+=m*w.x;out.y+=m*w.y;return out}function minusScaleVec2(out,m,w){out.x-=m*w.x;out.y-=m*w.y;return out}function combine2Vec2(out,am,a2,bm,b2){out.x=am*a2.x+bm*b2.x;out.y=am*a2.y+bm*b2.y;return out}function combine3Vec2(out,am,a2,bm,b2,cm,c2){out.x=am*a2.x+bm*b2.x+cm*c2.x;out.y=am*a2.y+bm*b2.y+cm*c2.y;return out}function normalizeVec2Length(out){var length2=math_sqrt$6(out.x*out.x+out.y*out.y);if(length2!==0){var invLength=1/length2;out.x*=invLength;out.y*=invLength}return length2}function normalizeVec2(out){var length2=math_sqrt$6(out.x*out.x+out.y*out.y);if(length2>0){var invLength=1/length2;out.x*=invLength;out.y*=invLength}return out}function crossVec2Num(out,v3,w){var x2=w*v3.y;var y=-w*v3.x;out.x=x2;out.y=y;return out}function crossNumVec2(out,w,v3){var x2=-w*v3.y;var y=w*v3.x;out.x=x2;out.y=y;return out}function crossVec2Vec2(a2,b2){return a2.x*b2.y-a2.y*b2.x}function dotVec2(a2,b2){return a2.x*b2.x+a2.y*b2.y}function lengthSqrVec2(a2){return a2.x*a2.x+a2.y*a2.y}function distVec2(a2,b2){var dx=a2.x-b2.x;var dy=a2.y-b2.y;return math_sqrt$6(dx*dx+dy*dy)}function distSqrVec2(a2,b2){var dx=a2.x-b2.x;var dy=a2.y-b2.y;return dx*dx+dy*dy}function setRotAngle(out,a2){out.c=math_cos$2(a2);out.s=math_sin$2(a2);return out}function rotVec2(out,q,v3){out.x=q.c*v3.x-q.s*v3.y;out.y=q.s*v3.x+q.c*v3.y;return out}function derotVec2(out,q,v3){var x2=q.c*v3.x+q.s*v3.y;var y=-q.s*v3.x+q.c*v3.y;out.x=x2;out.y=y;return out}function rerotVec2(out,before,after,v3){var x0=before.c*v3.x+before.s*v3.y;var y0=-before.s*v3.x+before.c*v3.y;var x2=after.c*x0-after.s*y0;var y=after.s*x0+after.c*y0;out.x=x2;out.y=y;return out}function transform(x2,y,a2){return{p:vec2(x2,y),q:rotation(a2)}}function copyTransform(out,transform2){out.p.x=transform2.p.x;out.p.y=transform2.p.y;out.q.s=transform2.q.s;out.q.c=transform2.q.c;return out}function transformVec2(out,xf2,v3){var x2=xf2.q.c*v3.x-xf2.q.s*v3.y+xf2.p.x;var y=xf2.q.s*v3.x+xf2.q.c*v3.y+xf2.p.y;out.x=x2;out.y=y;return out}function detransformVec2(out,xf2,v3){var px=v3.x-xf2.p.x;var py=v3.y-xf2.p.y;var x2=xf2.q.c*px+xf2.q.s*py;var y=-xf2.q.s*px+xf2.q.c*py;out.x=x2;out.y=y;return out}function retransformVec2(out,from,to,v3){var x0=from.q.c*v3.x-from.q.s*v3.y+from.p.x;var y0=from.q.s*v3.x+from.q.c*v3.y+from.p.y;var px=x0-to.p.x;var py=y0-to.p.y;var x2=to.q.c*px+to.q.s*py;var y=-to.q.s*px+to.q.c*py;out.x=x2;out.y=y;return out}function detransformTransform(out,a2,b2){var c2=a2.q.c*b2.q.c+a2.q.s*b2.q.s;var s2=a2.q.c*b2.q.s-a2.q.s*b2.q.c;var x2=a2.q.c*(b2.p.x-a2.p.x)+a2.q.s*(b2.p.y-a2.p.y);var y=-a2.q.s*(b2.p.x-a2.p.x)+a2.q.c*(b2.p.y-a2.p.y);out.q.c=c2;out.q.s=s2;out.p.x=x2;out.p.y=y;return out}var math_sin$1=Math.sin;var math_cos$1=Math.cos;var math_atan2$2=Math.atan2;var Rot=function(){function Rot2(angle){if(!(this instanceof Rot2)){return new Rot2(angle)}if(typeof angle==="number"){this.setAngle(angle)}else if(typeof angle==="object"){this.setRot(angle)}else{this.setIdentity()}}Rot2.neo=function(angle){var obj=Object.create(Rot2.prototype);obj.setAngle(angle);return obj};Rot2.clone=function(rot){var obj=Object.create(Rot2.prototype);obj.s=rot.s;obj.c=rot.c;return obj};Rot2.identity=function(){var obj=Object.create(Rot2.prototype);obj.s=0;obj.c=1;return obj};Rot2.isValid=function(obj){if(obj===null||typeof obj==="undefined"){return false}return Number.isFinite(obj.s)&&Number.isFinite(obj.c)};Rot2.assert=function(o){};Rot2.prototype.setIdentity=function(){this.s=0;this.c=1};Rot2.prototype.set=function(angle){if(typeof angle==="object"){this.s=angle.s;this.c=angle.c}else{this.s=math_sin$1(angle);this.c=math_cos$1(angle)}};Rot2.prototype.setRot=function(angle){this.s=angle.s;this.c=angle.c};Rot2.prototype.setAngle=function(angle){this.s=math_sin$1(angle);this.c=math_cos$1(angle)};Rot2.prototype.getAngle=function(){return math_atan2$2(this.s,this.c)};Rot2.prototype.getXAxis=function(){return Vec2.neo(this.c,this.s)};Rot2.prototype.getYAxis=function(){return Vec2.neo(-this.s,this.c)};Rot2.mul=function(rot,m){if("c"in m&&"s"in m){var qr=Rot2.identity();qr.s=rot.s*m.c+rot.c*m.s;qr.c=rot.c*m.c-rot.s*m.s;return qr}else if("x"in m&&"y"in m){return Vec2.neo(rot.c*m.x-rot.s*m.y,rot.s*m.x+rot.c*m.y)}};Rot2.mulRot=function(rot,m){var qr=Rot2.identity();qr.s=rot.s*m.c+rot.c*m.s;qr.c=rot.c*m.c-rot.s*m.s;return qr};Rot2.mulVec2=function(rot,m){return Vec2.neo(rot.c*m.x-rot.s*m.y,rot.s*m.x+rot.c*m.y)};Rot2.mulSub=function(rot,v3,w){var x2=rot.c*(v3.x-w.x)-rot.s*(v3.y-w.y);var y=rot.s*(v3.x-w.x)+rot.c*(v3.y-w.y);return Vec2.neo(x2,y)};Rot2.mulT=function(rot,m){if("c"in m&&"s"in m){var qr=Rot2.identity();qr.s=rot.c*m.s-rot.s*m.c;qr.c=rot.c*m.c+rot.s*m.s;return qr}else if("x"in m&&"y"in m){return Vec2.neo(rot.c*m.x+rot.s*m.y,-rot.s*m.x+rot.c*m.y)}};Rot2.mulTRot=function(rot,m){var qr=Rot2.identity();qr.s=rot.c*m.s-rot.s*m.c;qr.c=rot.c*m.c+rot.s*m.s;return qr};Rot2.mulTVec2=function(rot,m){return Vec2.neo(rot.c*m.x+rot.s*m.y,-rot.s*m.x+rot.c*m.y)};return Rot2}();var math_atan2$1=Math.atan2;var math_PI$6=Math.PI;var temp$7=vec2(0,0);var Sweep=function(){function Sweep2(){this.localCenter=Vec2.zero();this.c=Vec2.zero();this.a=0;this.alpha0=0;this.c0=Vec2.zero();this.a0=0}Sweep2.prototype.recycle=function(){zeroVec2(this.localCenter);zeroVec2(this.c);this.a=0;this.alpha0=0;zeroVec2(this.c0);this.a0=0};Sweep2.prototype.setTransform=function(xf2){transformVec2(temp$7,xf2,this.localCenter);copyVec2(this.c,temp$7);copyVec2(this.c0,temp$7);this.a=this.a0=math_atan2$1(xf2.q.s,xf2.q.c)};Sweep2.prototype.setLocalCenter=function(localCenter2,xf2){copyVec2(this.localCenter,localCenter2);transformVec2(temp$7,xf2,this.localCenter);copyVec2(this.c,temp$7);copyVec2(this.c0,temp$7)};Sweep2.prototype.getTransform=function(xf2,beta){if(beta===void 0){beta=0}setRotAngle(xf2.q,(1-beta)*this.a0+beta*this.a);combine2Vec2(xf2.p,1-beta,this.c0,beta,this.c);minusVec2(xf2.p,rotVec2(temp$7,xf2.q,this.localCenter))};Sweep2.prototype.advance=function(alpha){var beta=(alpha-this.alpha0)/(1-this.alpha0);combine2Vec2(this.c0,beta,this.c,1-beta,this.c0);this.a0=beta*this.a+(1-beta)*this.a0;this.alpha0=alpha};Sweep2.prototype.forward=function(){this.a0=this.a;copyVec2(this.c0,this.c)};Sweep2.prototype.normalize=function(){var a0=mod(this.a0,-math_PI$6,+math_PI$6);this.a-=this.a0-a0;this.a0=a0};Sweep2.prototype.set=function(that){copyVec2(this.localCenter,that.localCenter);copyVec2(this.c,that.c);this.a=that.a;this.alpha0=that.alpha0;copyVec2(this.c0,that.c0);this.a0=that.a0};return Sweep2}();var Transform=function(){function Transform2(position,rotation2){if(!(this instanceof Transform2)){return new Transform2(position,rotation2)}this.p=Vec2.zero();this.q=Rot.identity();if(typeof position!=="undefined"){this.p.setVec2(position)}if(typeof rotation2!=="undefined"){this.q.setAngle(rotation2)}}Transform2.clone=function(xf2){var obj=Object.create(Transform2.prototype);obj.p=Vec2.clone(xf2.p);obj.q=Rot.clone(xf2.q);return obj};Transform2.neo=function(position,rotation2){var obj=Object.create(Transform2.prototype);obj.p=Vec2.clone(position);obj.q=Rot.clone(rotation2);return obj};Transform2.identity=function(){var obj=Object.create(Transform2.prototype);obj.p=Vec2.zero();obj.q=Rot.identity();return obj};Transform2.prototype.setIdentity=function(){this.p.setZero();this.q.setIdentity()};Transform2.prototype.set=function(a2,b2){if(typeof b2==="undefined"){this.p.set(a2.p);this.q.set(a2.q)}else{this.p.set(a2);this.q.set(b2)}};Transform2.prototype.setNum=function(position,rotation2){this.p.setVec2(position);this.q.setAngle(rotation2)};Transform2.prototype.setTransform=function(xf2){this.p.setVec2(xf2.p);this.q.setRot(xf2.q)};Transform2.isValid=function(obj){if(obj===null||typeof obj==="undefined"){return false}return Vec2.isValid(obj.p)&&Rot.isValid(obj.q)};Transform2.assert=function(o){};Transform2.mul=function(a2,b2){if(Array.isArray(b2)){var arr=[];for(var i=0;i0}var collideA=(that.m_filterMaskBits&this.m_filterCategoryBits)!==0;var collideB=(that.m_filterCategoryBits&this.m_filterMaskBits)!==0;var collide=collideA&&collideB;return collide};return Fixture2}();var STATIC="static";var KINEMATIC="kinematic";var DYNAMIC="dynamic";var oldCenter=vec2(0,0);var localCenter=vec2(0,0);var shift=vec2(0,0);var temp$6=vec2(0,0);var xf$2=transform(0,0,0);var BodyDefDefault={type:STATIC,position:Vec2.zero(),angle:0,linearVelocity:Vec2.zero(),angularVelocity:0,linearDamping:0,angularDamping:0,fixedRotation:false,bullet:false,gravityScale:1,allowSleep:true,awake:true,active:true,userData:null};var Body=function(){function Body2(world,def){this.style={};this.appData={};def=options(def,BodyDefDefault);this.m_world=world;this.m_awakeFlag=def.awake;this.m_autoSleepFlag=def.allowSleep;this.m_bulletFlag=def.bullet;this.m_fixedRotationFlag=def.fixedRotation;this.m_activeFlag=def.active;this.m_islandFlag=false;this.m_toiFlag=false;this.m_userData=def.userData;this.m_type=def.type;if(this.m_type==DYNAMIC){this.m_mass=1;this.m_invMass=1}else{this.m_mass=0;this.m_invMass=0}this.m_I=0;this.m_invI=0;this.m_xf=Transform.identity();this.m_xf.p.setVec2(def.position);this.m_xf.q.setAngle(def.angle);this.m_sweep=new Sweep;this.m_sweep.setTransform(this.m_xf);this.c_velocity=new Velocity;this.c_position=new Position;this.m_force=Vec2.zero();this.m_torque=0;this.m_linearVelocity=Vec2.clone(def.linearVelocity);this.m_angularVelocity=def.angularVelocity;this.m_linearDamping=def.linearDamping;this.m_angularDamping=def.angularDamping;this.m_gravityScale=def.gravityScale;this.m_sleepTime=0;this.m_jointList=null;this.m_contactList=null;this.m_fixtureList=null;this.m_prev=null;this.m_next=null;this.m_destroyed=false;if(typeof def.style==="object"&&def.style!==null){this.style=def.style}}Body2.prototype._serialize=function(){var fixtures=[];for(var f=this.m_fixtureList;f;f=f.m_next){fixtures.push(f)}return{type:this.m_type,bullet:this.m_bulletFlag,position:this.m_xf.p,angle:this.m_xf.q.getAngle(),linearVelocity:this.m_linearVelocity,angularVelocity:this.m_angularVelocity,fixtures:fixtures}};Body2._deserialize=function(data,world,restore){var body=new Body2(world,data);if(data.fixtures){for(var i=data.fixtures.length-1;i>=0;i--){var fixture=restore(Fixture,data.fixtures[i],body);body._addFixture(fixture)}}return body};Body2.prototype.isWorldLocked=function(){return this.m_world&&this.m_world.isLocked()?true:false};Body2.prototype.getWorld=function(){return this.m_world};Body2.prototype.getNext=function(){return this.m_next};Body2.prototype.setUserData=function(data){this.m_userData=data};Body2.prototype.getUserData=function(){return this.m_userData};Body2.prototype.getFixtureList=function(){return this.m_fixtureList};Body2.prototype.getJointList=function(){return this.m_jointList};Body2.prototype.getContactList=function(){return this.m_contactList};Body2.prototype.isStatic=function(){return this.m_type==STATIC};Body2.prototype.isDynamic=function(){return this.m_type==DYNAMIC};Body2.prototype.isKinematic=function(){return this.m_type==KINEMATIC};Body2.prototype.setStatic=function(){this.setType(STATIC);return this};Body2.prototype.setDynamic=function(){this.setType(DYNAMIC);return this};Body2.prototype.setKinematic=function(){this.setType(KINEMATIC);return this};Body2.prototype.getType=function(){return this.m_type};Body2.prototype.setType=function(type){if(this.isWorldLocked()==true){return}if(this.m_type==type){return}this.m_type=type;this.resetMassData();if(this.m_type==STATIC){this.m_linearVelocity.setZero();this.m_angularVelocity=0;this.m_sweep.forward();this.synchronizeFixtures()}this.setAwake(true);this.m_force.setZero();this.m_torque=0;var ce=this.m_contactList;while(ce){var ce0=ce;ce=ce.next;this.m_world.destroyContact(ce0.contact)}this.m_contactList=null;var broadPhase=this.m_world.m_broadPhase;for(var f=this.m_fixtureList;f;f=f.m_next){for(var i=0;i0){this.setAwake(true)}this.m_linearVelocity.setVec2(v3)};Body2.prototype.getAngularVelocity=function(){return this.m_angularVelocity};Body2.prototype.setAngularVelocity=function(w){if(this.m_type==STATIC){return}if(w*w>0){this.setAwake(true)}this.m_angularVelocity=w};Body2.prototype.getLinearDamping=function(){return this.m_linearDamping};Body2.prototype.setLinearDamping=function(linearDamping){this.m_linearDamping=linearDamping};Body2.prototype.getAngularDamping=function(){return this.m_angularDamping};Body2.prototype.setAngularDamping=function(angularDamping){this.m_angularDamping=angularDamping};Body2.prototype.getGravityScale=function(){return this.m_gravityScale};Body2.prototype.setGravityScale=function(scale){this.m_gravityScale=scale};Body2.prototype.getMass=function(){return this.m_mass};Body2.prototype.getInertia=function(){return this.m_I+this.m_mass*Vec2.dot(this.m_sweep.localCenter,this.m_sweep.localCenter)};Body2.prototype.getMassData=function(data){data.mass=this.m_mass;data.I=this.getInertia();copyVec2(data.center,this.m_sweep.localCenter)};Body2.prototype.resetMassData=function(){this.m_mass=0;this.m_invMass=0;this.m_I=0;this.m_invI=0;zeroVec2(this.m_sweep.localCenter);if(this.isStatic()||this.isKinematic()){copyVec2(this.m_sweep.c0,this.m_xf.p);copyVec2(this.m_sweep.c,this.m_xf.p);this.m_sweep.a0=this.m_sweep.a;return}zeroVec2(localCenter);for(var f=this.m_fixtureList;f;f=f.m_next){if(f.m_density==0){continue}var massData={mass:0,center:vec2(0,0),I:0};f.getMassData(massData);this.m_mass+=massData.mass;plusScaleVec2(localCenter,massData.mass,massData.center);this.m_I+=massData.I}if(this.m_mass>0){this.m_invMass=1/this.m_mass;scaleVec2(localCenter,this.m_invMass,localCenter)}else{this.m_mass=1;this.m_invMass=1}if(this.m_I>0&&this.m_fixedRotationFlag==false){this.m_I-=this.m_mass*dotVec2(localCenter,localCenter);this.m_invI=1/this.m_I}else{this.m_I=0;this.m_invI=0}copyVec2(oldCenter,this.m_sweep.c);this.m_sweep.setLocalCenter(localCenter,this.m_xf);subVec2(shift,this.m_sweep.c,oldCenter);crossNumVec2(temp$6,this.m_angularVelocity,shift);plusVec2(this.m_linearVelocity,temp$6)};Body2.prototype.setMassData=function(massData){if(this.isWorldLocked()==true){return}if(this.m_type!=DYNAMIC){return}this.m_invMass=0;this.m_I=0;this.m_invI=0;this.m_mass=massData.mass;if(this.m_mass<=0){this.m_mass=1}this.m_invMass=1/this.m_mass;if(massData.I>0&&this.m_fixedRotationFlag==false){this.m_I=massData.I-this.m_mass*dotVec2(massData.center,massData.center);this.m_invI=1/this.m_I}copyVec2(oldCenter,this.m_sweep.c);this.m_sweep.setLocalCenter(massData.center,this.m_xf);subVec2(shift,this.m_sweep.c,oldCenter);crossNumVec2(temp$6,this.m_angularVelocity,shift);plusVec2(this.m_linearVelocity,temp$6)};Body2.prototype.applyForce=function(force,point2,wake){if(wake===void 0){wake=true}if(this.m_type!=DYNAMIC){return}if(wake&&this.m_awakeFlag==false){this.setAwake(true)}if(this.m_awakeFlag){this.m_force.add(force);this.m_torque+=Vec2.crossVec2Vec2(Vec2.sub(point2,this.m_sweep.c),force)}};Body2.prototype.applyForceToCenter=function(force,wake){if(wake===void 0){wake=true}if(this.m_type!=DYNAMIC){return}if(wake&&this.m_awakeFlag==false){this.setAwake(true)}if(this.m_awakeFlag){this.m_force.add(force)}};Body2.prototype.applyTorque=function(torque,wake){if(wake===void 0){wake=true}if(this.m_type!=DYNAMIC){return}if(wake&&this.m_awakeFlag==false){this.setAwake(true)}if(this.m_awakeFlag){this.m_torque+=torque}};Body2.prototype.applyLinearImpulse=function(impulse,point2,wake){if(wake===void 0){wake=true}if(this.m_type!=DYNAMIC){return}if(wake&&this.m_awakeFlag==false){this.setAwake(true)}if(this.m_awakeFlag){this.m_linearVelocity.addMul(this.m_invMass,impulse);this.m_angularVelocity+=this.m_invI*Vec2.crossVec2Vec2(Vec2.sub(point2,this.m_sweep.c),impulse)}};Body2.prototype.applyAngularImpulse=function(impulse,wake){if(wake===void 0){wake=true}if(this.m_type!=DYNAMIC){return}if(wake&&this.m_awakeFlag==false){this.setAwake(true)}if(this.m_awakeFlag){this.m_angularVelocity+=this.m_invI*impulse}};Body2.prototype.shouldCollide=function(that){if(this.m_type!=DYNAMIC&&that.m_type!=DYNAMIC){return false}for(var jn=this.m_jointList;jn;jn=jn.next){if(jn.other==that){if(jn.joint.m_collideConnected==false){return false}}}return true};Body2.prototype._addFixture=function(fixture){if(this.isWorldLocked()==true){return null}if(this.m_activeFlag){var broadPhase=this.m_world.m_broadPhase;fixture.createProxies(broadPhase,this.m_xf)}fixture.m_next=this.m_fixtureList;this.m_fixtureList=fixture;if(fixture.m_density>0){this.resetMassData()}this.m_world.m_newFixture=true;return fixture};Body2.prototype.createFixture=function(shape,fixdef){if(this.isWorldLocked()==true){return null}var fixture=new Fixture(this,shape,fixdef);this._addFixture(fixture);return fixture};Body2.prototype.destroyFixture=function(fixture){if(this.isWorldLocked()==true){return}if(this.m_fixtureList===fixture){this.m_fixtureList=fixture.m_next}else{var node=this.m_fixtureList;while(node!=null){if(node.m_next===fixture){node.m_next=fixture.m_next;break}node=node.m_next}}var edge=this.m_contactList;while(edge){var c2=edge.contact;edge=edge.next;var fixtureA=c2.getFixtureA();var fixtureB=c2.getFixtureB();if(fixture==fixtureA||fixture==fixtureB){this.m_world.destroyContact(c2)}}if(this.m_activeFlag){var broadPhase=this.m_world.m_broadPhase;fixture.destroyProxies(broadPhase)}fixture.m_body=null;fixture.m_next=null;this.m_world.publish("remove-fixture",fixture);this.resetMassData()};Body2.prototype.getWorldPoint=function(localPoint){return Transform.mulVec2(this.m_xf,localPoint)};Body2.prototype.getWorldVector=function(localVector){return Rot.mulVec2(this.m_xf.q,localVector)};Body2.prototype.getLocalPoint=function(worldPoint){return Transform.mulTVec2(this.m_xf,worldPoint)};Body2.prototype.getLocalVector=function(worldVector){return Rot.mulTVec2(this.m_xf.q,worldVector)};Body2.STATIC="static";Body2.KINEMATIC="kinematic";Body2.DYNAMIC="dynamic";return Body2}();var JointEdge=function(){function JointEdge2(){this.other=null;this.joint=null;this.prev=null;this.next=null}return JointEdge2}();var Joint=function(){function Joint2(def,bodyA,bodyB){this.m_type="unknown-joint";this.m_prev=null;this.m_next=null;this.m_edgeA=new JointEdge;this.m_edgeB=new JointEdge;this.m_islandFlag=false;this.style={};this.appData={};bodyA="bodyA"in def?def.bodyA:bodyA;bodyB="bodyB"in def?def.bodyB:bodyB;this.m_bodyA=bodyA;this.m_bodyB=bodyB;this.m_collideConnected=!!def.collideConnected;this.m_userData=def.userData;if(typeof def.style==="object"&&def.style!==null){this.style=def.style}}Joint2.prototype.isActive=function(){return this.m_bodyA.isActive()&&this.m_bodyB.isActive()};Joint2.prototype.getType=function(){return this.m_type};Joint2.prototype.getBodyA=function(){return this.m_bodyA};Joint2.prototype.getBodyB=function(){return this.m_bodyB};Joint2.prototype.getNext=function(){return this.m_next};Joint2.prototype.getUserData=function(){return this.m_userData};Joint2.prototype.setUserData=function(data){this.m_userData=data};Joint2.prototype.getCollideConnected=function(){return this.m_collideConnected};Joint2.prototype.shiftOrigin=function(newOrigin){};Joint2.prototype._resetAnchors=function(def){return this._reset(def)};return Joint2}();var stats$1={gjkCalls:0,gjkIters:0,gjkMaxIters:0,toiTime:0,toiMaxTime:0,toiCalls:0,toiIters:0,toiMaxIters:0,toiRootIters:0,toiMaxRootIters:0,toString:function(newline){newline=typeof newline==="string"?newline:"\n";var string="";for(var name_1 in this){if(typeof this[name_1]!=="function"&&typeof this[name_1]!=="object"){string+=name_1+": "+this[name_1]+newline}}return string}};var now=function(){return Date.now()};var diff=function(time){return Date.now()-time};const Timer={now:now,diff:diff};var math_max$5=Math.max;var temp$5=vec2(0,0);var normal$4=vec2(0,0);var e12=vec2(0,0);var e13=vec2(0,0);var e23=vec2(0,0);var temp1=vec2(0,0);var temp2=vec2(0,0);stats$1.gjkCalls=0;stats$1.gjkIters=0;stats$1.gjkMaxIters=0;var DistanceInput=function(){function DistanceInput2(){this.proxyA=new DistanceProxy;this.proxyB=new DistanceProxy;this.transformA=Transform.identity();this.transformB=Transform.identity();this.useRadii=false}DistanceInput2.prototype.recycle=function(){this.proxyA.recycle();this.proxyB.recycle();this.transformA.setIdentity();this.transformB.setIdentity();this.useRadii=false};return DistanceInput2}();var DistanceOutput=function(){function DistanceOutput2(){this.pointA=vec2(0,0);this.pointB=vec2(0,0);this.distance=0;this.iterations=0}DistanceOutput2.prototype.recycle=function(){zeroVec2(this.pointA);zeroVec2(this.pointB);this.distance=0;this.iterations=0};return DistanceOutput2}();var SimplexCache=function(){function SimplexCache2(){this.metric=0;this.indexA=[];this.indexB=[];this.count=0}SimplexCache2.prototype.recycle=function(){this.metric=0;this.indexA.length=0;this.indexB.length=0;this.count=0};return SimplexCache2}();var Distance=function(output2,cache2,input2){++stats$1.gjkCalls;var proxyA=input2.proxyA;var proxyB=input2.proxyB;var xfA2=input2.transformA;var xfB2=input2.transformB;simplex.recycle();simplex.readCache(cache2,proxyA,xfA2,proxyB,xfB2);var vertices=simplex.m_v;var k_maxIters=SettingsInternal.maxDistanceIterations;var saveA=[];var saveB=[];var saveCount=0;var iter=0;while(iterrA2+rB2&&output2.distance>EPSILON){output2.distance-=rA2+rB2;subVec2(normal$4,output2.pointB,output2.pointA);normalizeVec2(normal$4);plusScaleVec2(output2.pointA,rA2,normal$4);minusScaleVec2(output2.pointB,rB2,normal$4)}else{var p=subVec2(temp$5,output2.pointA,output2.pointB);copyVec2(output2.pointA,p);copyVec2(output2.pointB,p);output2.distance=0}}};var DistanceProxy=function(){function DistanceProxy2(){this.m_vertices=[];this.m_count=0;this.m_radius=0}DistanceProxy2.prototype.recycle=function(){this.m_vertices.length=0;this.m_count=0;this.m_radius=0};DistanceProxy2.prototype.getVertexCount=function(){return this.m_count};DistanceProxy2.prototype.getVertex=function(index){return this.m_vertices[index]};DistanceProxy2.prototype.getSupport=function(d2){var bestIndex=-1;var bestValue=-Infinity;for(var i=0;ibestValue){bestIndex=i;bestValue=value}}return bestIndex};DistanceProxy2.prototype.getSupportVertex=function(d2){return this.m_vertices[this.getSupport(d2)]};DistanceProxy2.prototype.set=function(shape,index){shape.computeDistanceProxy(this,index)};DistanceProxy2.prototype.setVertices=function(vertices,count,radius){this.m_vertices=vertices;this.m_count=count;this.m_radius=radius};return DistanceProxy2}();var SimplexVertex=function(){function SimplexVertex2(){this.wA=vec2(0,0);this.indexA=0;this.wB=vec2(0,0);this.indexB=0;this.w=vec2(0,0);this.a=0}SimplexVertex2.prototype.recycle=function(){this.indexA=0;this.indexB=0;zeroVec2(this.wA);zeroVec2(this.wB);zeroVec2(this.w);this.a=0};SimplexVertex2.prototype.set=function(v3){this.indexA=v3.indexA;this.indexB=v3.indexB;copyVec2(this.wA,v3.wA);copyVec2(this.wB,v3.wB);copyVec2(this.w,v3.w);this.a=v3.a};return SimplexVertex2}();var searchDirection_reuse=vec2(0,0);var closestPoint_reuse=vec2(0,0);var Simplex=function(){function Simplex2(){this.m_v1=new SimplexVertex;this.m_v2=new SimplexVertex;this.m_v3=new SimplexVertex;this.m_v=[this.m_v1,this.m_v2,this.m_v3]}Simplex2.prototype.recycle=function(){this.m_v1.recycle();this.m_v2.recycle();this.m_v3.recycle();this.m_count=0};Simplex2.prototype.toString=function(){if(this.m_count===3){return["+"+this.m_count,this.m_v1.a,this.m_v1.wA.x,this.m_v1.wA.y,this.m_v1.wB.x,this.m_v1.wB.y,this.m_v2.a,this.m_v2.wA.x,this.m_v2.wA.y,this.m_v2.wB.x,this.m_v2.wB.y,this.m_v3.a,this.m_v3.wA.x,this.m_v3.wA.y,this.m_v3.wB.x,this.m_v3.wB.y].toString()}else if(this.m_count===2){return["+"+this.m_count,this.m_v1.a,this.m_v1.wA.x,this.m_v1.wA.y,this.m_v1.wB.x,this.m_v1.wB.y,this.m_v2.a,this.m_v2.wA.x,this.m_v2.wA.y,this.m_v2.wB.x,this.m_v2.wB.y].toString()}else if(this.m_count===1){return["+"+this.m_count,this.m_v1.a,this.m_v1.wA.x,this.m_v1.wA.y,this.m_v1.wB.x,this.m_v1.wB.y].toString()}else{return"+"+this.m_count}};Simplex2.prototype.readCache=function(cache2,proxyA,transformA,proxyB,transformB){this.m_count=cache2.count;for(var i=0;i1){var metric1=cache2.metric;var metric2=this.getMetric();if(metric2<.5*metric1||2*metric10){return setVec2(searchDirection_reuse,-e12.y,e12.x)}else{return setVec2(searchDirection_reuse,e12.y,-e12.x)}}default:return zeroVec2(searchDirection_reuse)}};Simplex2.prototype.getClosestPoint=function(){var v13=this.m_v1;var v22=this.m_v2;this.m_v3;switch(this.m_count){case 0:return zeroVec2(closestPoint_reuse);case 1:return copyVec2(closestPoint_reuse,v13.w);case 2:return combine2Vec2(closestPoint_reuse,v13.a,v13.w,v22.a,v22.w);case 3:return zeroVec2(closestPoint_reuse);default:return zeroVec2(closestPoint_reuse)}};Simplex2.prototype.getWitnessPoints=function(pA2,pB2){var v13=this.m_v1;var v22=this.m_v2;var v3=this.m_v3;switch(this.m_count){case 0:break;case 1:copyVec2(pA2,v13.wA);copyVec2(pB2,v13.wB);break;case 2:combine2Vec2(pA2,v13.a,v13.wA,v22.a,v22.wA);combine2Vec2(pB2,v13.a,v13.wB,v22.a,v22.wB);break;case 3:combine3Vec2(pA2,v13.a,v13.wA,v22.a,v22.wA,v3.a,v3.wA);copyVec2(pB2,pA2);break}};Simplex2.prototype.getMetric=function(){switch(this.m_count){case 0:return 0;case 1:return 0;case 2:return distVec2(this.m_v1.w,this.m_v2.w);case 3:return crossVec2Vec2(subVec2(temp1,this.m_v2.w,this.m_v1.w),subVec2(temp2,this.m_v3.w,this.m_v1.w));default:return 0}};Simplex2.prototype.solve=function(){switch(this.m_count){case 1:break;case 2:this.solve2();break;case 3:this.solve3();break}};Simplex2.prototype.solve2=function(){var w1=this.m_v1.w;var w2=this.m_v2.w;subVec2(e12,w2,w1);var d12_2=-dotVec2(w1,e12);if(d12_2<=0){this.m_v1.a=1;this.m_count=1;return}var d12_1=dotVec2(w2,e12);if(d12_1<=0){this.m_v2.a=1;this.m_count=1;this.m_v1.set(this.m_v2);return}var inv_d12=1/(d12_1+d12_2);this.m_v1.a=d12_1*inv_d12;this.m_v2.a=d12_2*inv_d12;this.m_count=2};Simplex2.prototype.solve3=function(){var w1=this.m_v1.w;var w2=this.m_v2.w;var w3=this.m_v3.w;subVec2(e12,w2,w1);var w1e12=dotVec2(w1,e12);var w2e12=dotVec2(w2,e12);var d12_1=w2e12;var d12_2=-w1e12;subVec2(e13,w3,w1);var w1e13=dotVec2(w1,e13);var w3e13=dotVec2(w3,e13);var d13_1=w3e13;var d13_2=-w1e13;subVec2(e23,w3,w2);var w2e23=dotVec2(w2,e23);var w3e23=dotVec2(w3,e23);var d23_1=w3e23;var d23_2=-w2e23;var n123=crossVec2Vec2(e12,e13);var d123_1=n123*crossVec2Vec2(w2,w3);var d123_2=n123*crossVec2Vec2(w3,w1);var d123_3=n123*crossVec2Vec2(w1,w2);if(d12_2<=0&&d13_2<=0){this.m_v1.a=1;this.m_count=1;return}if(d12_1>0&&d12_2>0&&d123_3<=0){var inv_d12=1/(d12_1+d12_2);this.m_v1.a=d12_1*inv_d12;this.m_v2.a=d12_2*inv_d12;this.m_count=2;return}if(d13_1>0&&d13_2>0&&d123_2<=0){var inv_d13=1/(d13_1+d13_2);this.m_v1.a=d13_1*inv_d13;this.m_v3.a=d13_2*inv_d13;this.m_count=2;this.m_v2.set(this.m_v3);return}if(d12_1<=0&&d23_2<=0){this.m_v2.a=1;this.m_count=1;this.m_v1.set(this.m_v2);return}if(d13_1<=0&&d23_1<=0){this.m_v3.a=1;this.m_count=1;this.m_v1.set(this.m_v3);return}if(d23_1>0&&d23_2>0&&d123_1<=0){var inv_d23=1/(d23_1+d23_2);this.m_v2.a=d23_1*inv_d23;this.m_v3.a=d23_2*inv_d23;this.m_count=2;this.m_v1.set(this.m_v3);return}var inv_d123=1/(d123_1+d123_2+d123_3);this.m_v1.a=d123_1*inv_d123;this.m_v2.a=d123_2*inv_d123;this.m_v3.a=d123_3*inv_d123;this.m_count=3};return Simplex2}();var simplex=new Simplex;var input$1=new DistanceInput;var cache$1=new SimplexCache;var output$1=new DistanceOutput;var testOverlap=function(shapeA,indexA,shapeB,indexB,xfA2,xfB2){input$1.recycle();input$1.proxyA.set(shapeA,indexA);input$1.proxyB.set(shapeB,indexB);copyTransform(input$1.transformA,xfA2);copyTransform(input$1.transformB,xfB2);input$1.useRadii=true;output$1.recycle();cache$1.recycle();Distance(output$1,cache$1,input$1);return output$1.distance<10*EPSILON};Distance.testOverlap=testOverlap;Distance.Input=DistanceInput;Distance.Output=DistanceOutput;Distance.Proxy=DistanceProxy;Distance.Cache=SimplexCache;var ShapeCastInput=function(){function ShapeCastInput2(){this.proxyA=new DistanceProxy;this.proxyB=new DistanceProxy;this.transformA=Transform.identity();this.transformB=Transform.identity();this.translationB=Vec2.zero()}ShapeCastInput2.prototype.recycle=function(){this.proxyA.recycle();this.proxyB.recycle();this.transformA.setIdentity();this.transformB.setIdentity();zeroVec2(this.translationB)};return ShapeCastInput2}();var ShapeCastOutput=function(){function ShapeCastOutput2(){this.point=Vec2.zero();this.normal=Vec2.zero();this.lambda=1;this.iterations=0}return ShapeCastOutput2}();var ShapeCast=function(output2,input2){output2.iterations=0;output2.lambda=1;output2.normal.setZero();output2.point.setZero();var proxyA=input2.proxyA;var proxyB=input2.proxyB;var radiusA=math_max$5(proxyA.m_radius,SettingsInternal.polygonRadius);var radiusB=math_max$5(proxyB.m_radius,SettingsInternal.polygonRadius);var radius=radiusA+radiusB;var xfA2=input2.transformA;var xfB2=input2.transformB;var r=input2.translationB;var n2=Vec2.zero();var lambda=0;var simplex2=new Simplex;simplex2.m_count=0;var vertices=simplex2.m_v;var indexA=proxyA.getSupport(Rot.mulTVec2(xfA2.q,Vec2.neg(r)));var wA=Transform.mulVec2(xfA2,proxyA.getVertex(indexA));var indexB=proxyB.getSupport(Rot.mulTVec2(xfB2.q,r));var wB=Transform.mulVec2(xfB2,proxyB.getVertex(indexB));var v3=Vec2.sub(wA,wB);var sigma=math_max$5(SettingsInternal.polygonRadius,radius-SettingsInternal.polygonRadius);var tolerance=.5*SettingsInternal.linearSlop;var k_maxIters=20;var iter=0;while(itertolerance){output2.iterations+=1;indexA=proxyA.getSupport(Rot.mulTVec2(xfA2.q,Vec2.neg(v3)));wA=Transform.mulVec2(xfA2,proxyA.getVertex(indexA));indexB=proxyB.getSupport(Rot.mulTVec2(xfB2.q,v3));wB=Transform.mulVec2(xfB2,proxyB.getVertex(indexB));var p=Vec2.sub(wA,wB);v3.normalize();var vp=Vec2.dot(v3,p);var vr=Vec2.dot(v3,r);if(vp-sigma>lambda*vr){if(vr<=0){return false}lambda=(vp-sigma)/vr;if(lambda>1){return false}n2.setMul(-1,v3);simplex2.m_count=0}var vertex=vertices[simplex2.m_count];vertex.indexA=indexB;vertex.wA=Vec2.combine(1,wB,lambda,r);vertex.indexB=indexA;vertex.wB=wA;vertex.w=Vec2.sub(vertex.wB,vertex.wA);vertex.a=1;simplex2.m_count+=1;switch(simplex2.m_count){case 1:break;case 2:simplex2.solve2();break;case 3:simplex2.solve3();break}if(simplex2.m_count==3){return false}v3.setVec2(simplex2.getClosestPoint());++iter}if(iter==0){return false}var pointA2=Vec2.zero();var pointB2=Vec2.zero();simplex2.getWitnessPoints(pointB2,pointA2);if(v3.lengthSquared()>0){n2.setMul(-1,v3);n2.normalize()}output2.point=Vec2.combine(1,pointA2,radiusA,n2);output2.normal=n2;output2.lambda=lambda;output2.iterations=iter;return true};var math_abs$8=Math.abs;var math_max$4=Math.max;var TOIInput=function(){function TOIInput2(){this.proxyA=new DistanceProxy;this.proxyB=new DistanceProxy;this.sweepA=new Sweep;this.sweepB=new Sweep}TOIInput2.prototype.recycle=function(){this.proxyA.recycle();this.proxyB.recycle();this.sweepA.recycle();this.sweepB.recycle();this.tMax=-1};return TOIInput2}();exports2.TOIOutputState=void 0;(function(TOIOutputState2){TOIOutputState2[TOIOutputState2["e_unset"]=-1]="e_unset";TOIOutputState2[TOIOutputState2["e_unknown"]=0]="e_unknown";TOIOutputState2[TOIOutputState2["e_failed"]=1]="e_failed";TOIOutputState2[TOIOutputState2["e_overlapped"]=2]="e_overlapped";TOIOutputState2[TOIOutputState2["e_touching"]=3]="e_touching";TOIOutputState2[TOIOutputState2["e_separated"]=4]="e_separated"})(exports2.TOIOutputState||(exports2.TOIOutputState={}));var TOIOutput=function(){function TOIOutput2(){this.state=exports2.TOIOutputState.e_unset;this.t=-1}TOIOutput2.prototype.recycle=function(){this.state=exports2.TOIOutputState.e_unset;this.t=-1};return TOIOutput2}();stats$1.toiTime=0;stats$1.toiMaxTime=0;stats$1.toiCalls=0;stats$1.toiIters=0;stats$1.toiMaxIters=0;stats$1.toiRootIters=0;stats$1.toiMaxRootIters=0;var distanceInput=new DistanceInput;var distanceOutput=new DistanceOutput;var cache=new SimplexCache;var xfA$1=transform(0,0,0);var xfB$1=transform(0,0,0);var temp$4=vec2(0,0);var pointA$2=vec2(0,0);var pointB$2=vec2(0,0);var normal$3=vec2(0,0);var axisA=vec2(0,0);var axisB=vec2(0,0);var localPointA=vec2(0,0);var localPointB=vec2(0,0);var TimeOfImpact=function(output2,input2){var timer=Timer.now();++stats$1.toiCalls;output2.state=exports2.TOIOutputState.e_unknown;output2.t=input2.tMax;var proxyA=input2.proxyA;var proxyB=input2.proxyB;var sweepA=input2.sweepA;var sweepB=input2.sweepB;sweepA.normalize();sweepB.normalize();var tMax=input2.tMax;var totalRadius=proxyA.m_radius+proxyB.m_radius;var target=math_max$4(SettingsInternal.linearSlop,totalRadius-3*SettingsInternal.linearSlop);var tolerance=.25*SettingsInternal.linearSlop;var t1=0;var k_maxIterations=SettingsInternal.maxTOIIterations;var iter=0;cache.recycle();distanceInput.proxyA.setVertices(proxyA.m_vertices,proxyA.m_count,proxyA.m_radius);distanceInput.proxyB.setVertices(proxyB.m_vertices,proxyB.m_count,proxyB.m_radius);distanceInput.useRadii=false;while(true){sweepA.getTransform(xfA$1,t1);sweepB.getTransform(xfB$1,t1);copyTransform(distanceInput.transformA,xfA$1);copyTransform(distanceInput.transformB,xfB$1);Distance(distanceOutput,cache,distanceInput);if(distanceOutput.distance<=0){output2.state=exports2.TOIOutputState.e_overlapped;output2.t=0;break}if(distanceOutput.distancetarget+tolerance){output2.state=exports2.TOIOutputState.e_separated;output2.t=tMax;done=true;break}if(s2>target-tolerance){t1=t2;break}var s1=separationFunction.evaluate(t1);if(s1target){a1=t;s1=s3}else{a2=t;s2=s3}if(rootIterCount===50){break}}stats$1.toiMaxRootIters=math_max$4(stats$1.toiMaxRootIters,rootIterCount);++pushBackIter;if(pushBackIter===SettingsInternal.maxPolygonVertices){break}}++iter;++stats$1.toiIters;if(done){break}if(iter===k_maxIterations){output2.state=exports2.TOIOutputState.e_failed;output2.t=t1;break}}stats$1.toiMaxIters=math_max$4(stats$1.toiMaxIters,iter);var time=Timer.diff(timer);stats$1.toiMaxTime=math_max$4(stats$1.toiMaxTime,time);stats$1.toiTime+=time;separationFunction.recycle()};var SeparationFunctionType;(function(SeparationFunctionType2){SeparationFunctionType2[SeparationFunctionType2["e_unset"]=-1]="e_unset";SeparationFunctionType2[SeparationFunctionType2["e_points"]=1]="e_points";SeparationFunctionType2[SeparationFunctionType2["e_faceA"]=2]="e_faceA";SeparationFunctionType2[SeparationFunctionType2["e_faceB"]=3]="e_faceB"})(SeparationFunctionType||(SeparationFunctionType={}));var SeparationFunction=function(){function SeparationFunction2(){this.m_proxyA=null;this.m_proxyB=null;this.m_sweepA=null;this.m_sweepB=null;this.m_type=SeparationFunctionType.e_unset;this.m_localPoint=vec2(0,0);this.m_axis=vec2(0,0);this.indexA=-1;this.indexB=-1}SeparationFunction2.prototype.recycle=function(){this.m_proxyA=null;this.m_proxyB=null;this.m_sweepA=null;this.m_sweepB=null;this.m_type=SeparationFunctionType.e_unset;zeroVec2(this.m_localPoint);zeroVec2(this.m_axis);this.indexA=-1;this.indexB=-1};SeparationFunction2.prototype.initialize=function(cache2,proxyA,sweepA,proxyB,sweepB,t1){var count=cache2.count;this.m_proxyA=proxyA;this.m_proxyB=proxyB;this.m_sweepA=sweepA;this.m_sweepB=sweepB;this.m_sweepA.getTransform(xfA$1,t1);this.m_sweepB.getTransform(xfB$1,t1);if(count===1){this.m_type=SeparationFunctionType.e_points;var localPointA_1=this.m_proxyA.getVertex(cache2.indexA[0]);var localPointB_1=this.m_proxyB.getVertex(cache2.indexB[0]);transformVec2(pointA$2,xfA$1,localPointA_1);transformVec2(pointB$2,xfB$1,localPointB_1);subVec2(this.m_axis,pointB$2,pointA$2);var s2=normalizeVec2Length(this.m_axis);return s2}else if(cache2.indexA[0]===cache2.indexA[1]){this.m_type=SeparationFunctionType.e_faceB;var localPointB1=proxyB.getVertex(cache2.indexB[0]);var localPointB2=proxyB.getVertex(cache2.indexB[1]);crossVec2Num(this.m_axis,subVec2(temp$4,localPointB2,localPointB1),1);normalizeVec2(this.m_axis);rotVec2(normal$3,xfB$1.q,this.m_axis);combine2Vec2(this.m_localPoint,.5,localPointB1,.5,localPointB2);transformVec2(pointB$2,xfB$1,this.m_localPoint);var localPointA_2=proxyA.getVertex(cache2.indexA[0]);var pointA_1=Transform.mulVec2(xfA$1,localPointA_2);var s2=dotVec2(pointA_1,normal$3)-dotVec2(pointB$2,normal$3);if(s2<0){negVec2(this.m_axis);s2=-s2}return s2}else{this.m_type=SeparationFunctionType.e_faceA;var localPointA1=this.m_proxyA.getVertex(cache2.indexA[0]);var localPointA2=this.m_proxyA.getVertex(cache2.indexA[1]);crossVec2Num(this.m_axis,subVec2(temp$4,localPointA2,localPointA1),1);normalizeVec2(this.m_axis);rotVec2(normal$3,xfA$1.q,this.m_axis);combine2Vec2(this.m_localPoint,.5,localPointA1,.5,localPointA2);transformVec2(pointA$2,xfA$1,this.m_localPoint);var localPointB_2=this.m_proxyB.getVertex(cache2.indexB[0]);transformVec2(pointB$2,xfB$1,localPointB_2);var s2=dotVec2(pointB$2,normal$3)-dotVec2(pointA$2,normal$3);if(s2<0){negVec2(this.m_axis);s2=-s2}return s2}};SeparationFunction2.prototype.compute=function(find,t){this.m_sweepA.getTransform(xfA$1,t);this.m_sweepB.getTransform(xfB$1,t);switch(this.m_type){case SeparationFunctionType.e_points:{if(find){derotVec2(axisA,xfA$1.q,this.m_axis);derotVec2(axisB,xfB$1.q,scaleVec2(temp$4,-1,this.m_axis));this.indexA=this.m_proxyA.getSupport(axisA);this.indexB=this.m_proxyB.getSupport(axisB)}copyVec2(localPointA,this.m_proxyA.getVertex(this.indexA));copyVec2(localPointB,this.m_proxyB.getVertex(this.indexB));transformVec2(pointA$2,xfA$1,localPointA);transformVec2(pointB$2,xfB$1,localPointB);var sep=dotVec2(pointB$2,this.m_axis)-dotVec2(pointA$2,this.m_axis);return sep}case SeparationFunctionType.e_faceA:{rotVec2(normal$3,xfA$1.q,this.m_axis);transformVec2(pointA$2,xfA$1,this.m_localPoint);if(find){derotVec2(axisB,xfB$1.q,scaleVec2(temp$4,-1,normal$3));this.indexA=-1;this.indexB=this.m_proxyB.getSupport(axisB)}copyVec2(localPointB,this.m_proxyB.getVertex(this.indexB));transformVec2(pointB$2,xfB$1,localPointB);var sep=dotVec2(pointB$2,normal$3)-dotVec2(pointA$2,normal$3);return sep}case SeparationFunctionType.e_faceB:{rotVec2(normal$3,xfB$1.q,this.m_axis);transformVec2(pointB$2,xfB$1,this.m_localPoint);if(find){derotVec2(axisA,xfA$1.q,scaleVec2(temp$4,-1,normal$3));this.indexB=-1;this.indexA=this.m_proxyA.getSupport(axisA)}copyVec2(localPointA,this.m_proxyA.getVertex(this.indexA));transformVec2(pointA$2,xfA$1,localPointA);var sep=dotVec2(pointA$2,normal$3)-dotVec2(pointB$2,normal$3);return sep}default:if(find){this.indexA=-1;this.indexB=-1}return 0}};SeparationFunction2.prototype.findMinSeparation=function(t){return this.compute(true,t)};SeparationFunction2.prototype.evaluate=function(t){return this.compute(false,t)};return SeparationFunction2}();var separationFunction=new SeparationFunction;TimeOfImpact.Input=TOIInput;TimeOfImpact.Output=TOIOutput;var math_abs$7=Math.abs;var math_sqrt$5=Math.sqrt;var math_min$6=Math.min;var TimeStep=function(){function TimeStep2(){this.dt=0;this.inv_dt=0;this.velocityIterations=0;this.positionIterations=0;this.warmStarting=false;this.blockSolve=true;this.inv_dt0=0;this.dtRatio=1}TimeStep2.prototype.reset=function(dt){if(this.dt>0){this.inv_dt0=this.inv_dt}this.dt=dt;this.inv_dt=dt==0?0:1/dt;this.dtRatio=dt*this.inv_dt0};return TimeStep2}();var s_subStep=new TimeStep;var c=vec2(0,0);var v=vec2(0,0);var translation=vec2(0,0);var input=new TOIInput;var output=new TOIOutput;var backup=new Sweep;var backup1=new Sweep;var backup2=new Sweep;var ContactImpulse=function(){function ContactImpulse2(contact){this.contact=contact;this.normals=[];this.tangents=[]}ContactImpulse2.prototype.recycle=function(){this.normals.length=0;this.tangents.length=0};Object.defineProperty(ContactImpulse2.prototype,"normalImpulses",{get:function(){var contact=this.contact;var normals=this.normals;normals.length=0;for(var p=0;p0){var b2=stack.pop();this.addBody(b2);b2.m_awakeFlag=true;if(b2.isStatic()){continue}for(var ce=b2.m_contactList;ce;ce=ce.next){var contact=ce.contact;if(contact.m_islandFlag){continue}if(contact.isEnabled()==false||contact.isTouching()==false){continue}var sensorA=contact.m_fixtureA.m_isSensor;var sensorB=contact.m_fixtureB.m_isSensor;if(sensorA||sensorB){continue}this.addContact(contact);contact.m_islandFlag=true;var other=ce.other;if(other.m_islandFlag){continue}stack.push(other);other.m_islandFlag=true}for(var je=b2.m_jointList;je;je=je.next){if(je.joint.m_islandFlag==true){continue}var other=je.other;if(other.isActive()==false){continue}this.addJoint(je.joint);je.joint.m_islandFlag=true;if(other.m_islandFlag){continue}stack.push(other);other.m_islandFlag=true}}this.solveIsland(step);for(var i=0;iSettingsInternal.maxTranslationSquared){var ratio=SettingsInternal.maxTranslation/math_sqrt$5(translationLengthSqr);mulVec2(v,ratio)}var rotation2=h*w;if(rotation2*rotation2>SettingsInternal.maxRotationSquared){var ratio=SettingsInternal.maxRotation/math_abs$7(rotation2);w*=ratio}plusScaleVec2(c,h,v);a2+=h*w;copyVec2(body.c_position.c,c);body.c_position.a=a2;copyVec2(body.c_velocity.v,v);body.c_velocity.w=w}var positionSolved=false;for(var i=0;i=-3*SettingsInternal.linearSlop;var jointsOkay=true;for(var j=0;jangTolSqr||lengthSqrVec2(body.m_linearVelocity)>linTolSqr){body.m_sleepTime=0;minSleepTime=0}else{body.m_sleepTime+=h;minSleepTime=math_min$6(minSleepTime,body.m_sleepTime)}}if(minSleepTime>=SettingsInternal.timeToSleep&&positionSolved){for(var i=0;iSettingsInternal.maxSubSteps){continue}var alpha=1;if(c_3.m_toiFlag){alpha=c_3.m_toi}else{var fA_1=c_3.getFixtureA();var fB_1=c_3.getFixtureB();if(fA_1.isSensor()||fB_1.isSensor()){continue}var bA_1=fA_1.getBody();var bB_1=fB_1.getBody();var activeA=bA_1.isAwake()&&!bA_1.isStatic();var activeB=bB_1.isAwake()&&!bB_1.isStatic();if(activeA==false&&activeB==false){continue}var collideA=bA_1.isBullet()||!bA_1.isDynamic();var collideB=bB_1.isBullet()||!bB_1.isDynamic();if(collideA==false&&collideB==false){continue}var alpha0=bA_1.m_sweep.alpha0;if(bA_1.m_sweep.alpha0=-1.5*SettingsInternal.linearSlop;if(contactsOkay){break}}var i;copyVec2(toiA.m_sweep.c0,toiA.c_position.c);toiA.m_sweep.a0=toiA.c_position.a;copyVec2(toiB.m_sweep.c0,toiB.c_position.c);toiB.m_sweep.a0=toiB.c_position.a;for(var i=0;iSettingsInternal.maxTranslationSquared){var ratio=SettingsInternal.maxTranslation/math_sqrt$5(translationLengthSqr);mulVec2(v,ratio)}var rotation2=h*w;if(rotation2*rotation2>SettingsInternal.maxRotationSquared){var ratio=SettingsInternal.maxRotation/math_abs$7(rotation2);w*=ratio}plusScaleVec2(c,h,v);a2+=h*w;copyVec2(body.c_position.c,c);body.c_position.a=a2;copyVec2(body.c_velocity.v,v);body.c_velocity.w=w;copyVec2(body.m_sweep.c,c);body.m_sweep.a=a2;copyVec2(body.m_linearVelocity,v);body.m_angularVelocity=w;body.synchronizeTransform()}this.postSolveIsland()};Solver2.prototype.postSolveIsland=function(){for(var c_5=0;c_5EPSILON*EPSILON){var length_1=math_sqrt$4(lengthSqr);scaleVec2(normal3,1/length_1,dist)}combine2Vec2(cA$1,1,pointA$1,radiusA,normal3);combine2Vec2(cB$1,1,pointB$1,-radiusB,normal3);combine2Vec2(points[0],.5,cA$1,.5,cB$1);separations[0]=dotVec2(subVec2(temp$3,cB$1,cA$1),normal3);break}case exports2.ManifoldType.e_faceA:{rotVec2(normal3,xfA2.q,this.localNormal);transformVec2(planePoint$2,xfA2,this.localPoint);for(var i=0;irestitution2?restitution1:restitution2}var s_registers=[];var VelocityConstraintPoint=function(){function VelocityConstraintPoint2(){this.rA=vec2(0,0);this.rB=vec2(0,0);this.normalImpulse=0;this.tangentImpulse=0;this.normalMass=0;this.tangentMass=0;this.velocityBias=0}VelocityConstraintPoint2.prototype.recycle=function(){zeroVec2(this.rA);zeroVec2(this.rB);this.normalImpulse=0;this.tangentImpulse=0;this.normalMass=0;this.tangentMass=0;this.velocityBias=0};return VelocityConstraintPoint2}();var cA=vec2(0,0);var vA=vec2(0,0);var cB=vec2(0,0);var vB=vec2(0,0);var tangent$1=vec2(0,0);var xfA=transform(0,0,0);var xfB=transform(0,0,0);var pointA=vec2(0,0);var pointB=vec2(0,0);var clipPoint=vec2(0,0);var planePoint$1=vec2(0,0);var rA=vec2(0,0);var rB=vec2(0,0);var P$1=vec2(0,0);var normal$2=vec2(0,0);var point=vec2(0,0);var dv=vec2(0,0);var dv1=vec2(0,0);var dv2=vec2(0,0);var b=vec2(0,0);var a=vec2(0,0);var x=vec2(0,0);var d=vec2(0,0);var P1=vec2(0,0);var P2=vec2(0,0);var temp$2=vec2(0,0);var Contact=function(){function Contact2(){this.m_nodeA=new ContactEdge(this);this.m_nodeB=new ContactEdge(this);this.m_fixtureA=null;this.m_fixtureB=null;this.m_indexA=-1;this.m_indexB=-1;this.m_evaluateFcn=null;this.m_manifold=new Manifold;this.m_prev=null;this.m_next=null;this.m_toi=1;this.m_toiCount=0;this.m_toiFlag=false;this.m_friction=0;this.m_restitution=0;this.m_tangentSpeed=0;this.m_enabledFlag=true;this.m_islandFlag=false;this.m_touchingFlag=false;this.m_filterFlag=false;this.m_bulletHitFlag=false;this.m_impulse=new ContactImpulse(this);this.v_points=[new VelocityConstraintPoint,new VelocityConstraintPoint];this.v_normal=vec2(0,0);this.v_normalMass=new Mat22;this.v_K=new Mat22;this.v_pointCount=0;this.v_tangentSpeed=0;this.v_friction=0;this.v_restitution=0;this.v_invMassA=0;this.v_invMassB=0;this.v_invIA=0;this.v_invIB=0;this.p_localPoints=[vec2(0,0),vec2(0,0)];this.p_localNormal=vec2(0,0);this.p_localPoint=vec2(0,0);this.p_localCenterA=vec2(0,0);this.p_localCenterB=vec2(0,0);this.p_type=exports2.ManifoldType.e_unset;this.p_radiusA=0;this.p_radiusB=0;this.p_pointCount=0;this.p_invMassA=0;this.p_invMassB=0;this.p_invIA=0;this.p_invIB=0}Contact2.prototype.initialize=function(fA,indexA,fB,indexB,evaluateFcn){this.m_fixtureA=fA;this.m_fixtureB=fB;this.m_indexA=indexA;this.m_indexB=indexB;this.m_evaluateFcn=evaluateFcn;this.m_friction=mixFriction(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction);this.m_restitution=mixRestitution(this.m_fixtureA.m_restitution,this.m_fixtureB.m_restitution)};Contact2.prototype.recycle=function(){this.m_nodeA.recycle();this.m_nodeB.recycle();this.m_fixtureA=null;this.m_fixtureB=null;this.m_indexA=-1;this.m_indexB=-1;this.m_evaluateFcn=null;this.m_manifold.recycle();this.m_prev=null;this.m_next=null;this.m_toi=1;this.m_toiCount=0;this.m_toiFlag=false;this.m_friction=0;this.m_restitution=0;this.m_tangentSpeed=0;this.m_enabledFlag=true;this.m_islandFlag=false;this.m_touchingFlag=false;this.m_filterFlag=false;this.m_bulletHitFlag=false;this.m_impulse.recycle();for(var _i=0,_a2=this.v_points;_i<_a2.length;_i++){var point_1=_a2[_i];point_1.recycle()}zeroVec2(this.v_normal);this.v_normalMass.setZero();this.v_K.setZero();this.v_pointCount=0;this.v_tangentSpeed=0;this.v_friction=0;this.v_restitution=0;this.v_invMassA=0;this.v_invMassB=0;this.v_invIA=0;this.v_invIB=0;for(var _b=0,_c=this.p_localPoints;_b<_c.length;_b++){var point_2=_c[_b];zeroVec2(point_2)}zeroVec2(this.p_localNormal);zeroVec2(this.p_localPoint);zeroVec2(this.p_localCenterA);zeroVec2(this.p_localCenterB);this.p_type=exports2.ManifoldType.e_unset;this.p_radiusA=0;this.p_radiusB=0;this.p_pointCount=0;this.p_invMassA=0;this.p_invMassB=0;this.p_invIA=0;this.p_invIB=0};Contact2.prototype.initConstraint=function(step){var fixtureA=this.m_fixtureA;var fixtureB=this.m_fixtureB;if(fixtureA===null||fixtureB===null)return;var bodyA=fixtureA.m_body;var bodyB=fixtureB.m_body;if(bodyA===null||bodyB===null)return;var shapeA=fixtureA.m_shape;var shapeB=fixtureB.m_shape;if(shapeA===null||shapeB===null)return;var manifold=this.m_manifold;var pointCount=manifold.pointCount;this.v_invMassA=bodyA.m_invMass;this.v_invMassB=bodyB.m_invMass;this.v_invIA=bodyA.m_invI;this.v_invIB=bodyB.m_invI;this.v_friction=this.m_friction;this.v_restitution=this.m_restitution;this.v_tangentSpeed=this.m_tangentSpeed;this.v_pointCount=pointCount;this.v_K.setZero();this.v_normalMass.setZero();this.p_invMassA=bodyA.m_invMass;this.p_invMassB=bodyB.m_invMass;this.p_invIA=bodyA.m_invI;this.p_invIB=bodyB.m_invI;copyVec2(this.p_localCenterA,bodyA.m_sweep.localCenter);copyVec2(this.p_localCenterB,bodyB.m_sweep.localCenter);this.p_radiusA=shapeA.m_radius;this.p_radiusB=shapeB.m_radius;this.p_type=manifold.type;copyVec2(this.p_localNormal,manifold.localNormal);copyVec2(this.p_localPoint,manifold.localPoint);this.p_pointCount=pointCount;for(var j=0;j0;for(var i=0;i0?-C/K:0;scaleVec2(P$1,impulse,normal$2);minusScaleVec2(cA,mA,P$1);aA-=iA*crossVec2Vec2(rA,P$1);plusScaleVec2(cB,mB,P$1);aB+=iB*crossVec2Vec2(rB,P$1)}copyVec2(positionA.c,cA);positionA.a=aA;copyVec2(positionB.c,cB);positionB.a=aB;return minSeparation};Contact2.prototype.initVelocityConstraint=function(step){var fixtureA=this.m_fixtureA;var fixtureB=this.m_fixtureB;if(fixtureA===null||fixtureB===null)return;var bodyA=fixtureA.m_body;var bodyB=fixtureB.m_body;if(bodyA===null||bodyB===null)return;var velocityA=bodyA.c_velocity;var velocityB=bodyB.c_velocity;var positionA=bodyA.c_position;var positionB=bodyB.c_position;var radiusA=this.p_radiusA;var radiusB=this.p_radiusB;var manifold=this.m_manifold;var mA=this.v_invMassA;var mB=this.v_invMassB;var iA=this.v_invIA;var iB=this.v_invIB;var localCenterA=this.p_localCenterA;var localCenterB=this.p_localCenterB;copyVec2(cA,positionA.c);var aA=positionA.a;copyVec2(vA,velocityA.v);var wA=velocityA.w;copyVec2(cB,positionB.c);var aB=positionB.a;copyVec2(vB,velocityB.v);var wB=velocityB.w;getTransform(xfA,localCenterA,cA,aA);getTransform(xfB,localCenterB,cB,aB);worldManifold.recycle();manifold.getWorldManifold(worldManifold,xfA,radiusA,xfB,radiusB);copyVec2(this.v_normal,worldManifold.normal);for(var j=0;j0?1/kNormal:0;crossVec2Num(tangent$1,this.v_normal,1);var rtA=crossVec2Vec2(vcp.rA,tangent$1);var rtB=crossVec2Vec2(vcp.rB,tangent$1);var kTangent=mA+mB+iA*rtA*rtA+iB*rtB*rtB;vcp.tangentMass=kTangent>0?1/kTangent:0;vcp.velocityBias=0;var vRel=0;vRel+=dotVec2(this.v_normal,vB);vRel+=dotVec2(this.v_normal,crossNumVec2(temp$2,wB,vcp.rB));vRel-=dotVec2(this.v_normal,vA);vRel-=dotVec2(this.v_normal,crossNumVec2(temp$2,wA,vcp.rA));if(vRel<-SettingsInternal.velocityThreshold){vcp.velocityBias=-this.v_restitution*vRel}}if(this.v_pointCount==2&&step.blockSolve){var vcp1=this.v_points[0];var vcp2=this.v_points[1];var rn1A=crossVec2Vec2(vcp1.rA,this.v_normal);var rn1B=crossVec2Vec2(vcp1.rB,this.v_normal);var rn2A=crossVec2Vec2(vcp2.rA,this.v_normal);var rn2B=crossVec2Vec2(vcp2.rB,this.v_normal);var k11=mA+mB+iA*rn1A*rn1A+iB*rn1B*rn1B;var k22=mA+mB+iA*rn2A*rn2A+iB*rn2B*rn2B;var k12=mA+mB+iA*rn1A*rn2A+iB*rn1B*rn2B;var k_maxConditionNumber=1e3;if(k11*k11=0&&x.y>=0){subVec2(d,x,a);scaleVec2(P1,d.x,normal$2);scaleVec2(P2,d.y,normal$2);combine3Vec2(vA,-mA,P1,-mA,P2,1,vA);wA-=iA*(crossVec2Vec2(vcp1.rA,P1)+crossVec2Vec2(vcp2.rA,P2));combine3Vec2(vB,mB,P1,mB,P2,1,vB);wB+=iB*(crossVec2Vec2(vcp1.rB,P1)+crossVec2Vec2(vcp2.rB,P2));vcp1.normalImpulse=x.x;vcp2.normalImpulse=x.y;break}x.x=-vcp1.normalMass*b.x;x.y=0;vn1=0;vn2=this.v_K.ex.y*x.x+b.y;if(x.x>=0&&vn2>=0){subVec2(d,x,a);scaleVec2(P1,d.x,normal$2);scaleVec2(P2,d.y,normal$2);combine3Vec2(vA,-mA,P1,-mA,P2,1,vA);wA-=iA*(crossVec2Vec2(vcp1.rA,P1)+crossVec2Vec2(vcp2.rA,P2));combine3Vec2(vB,mB,P1,mB,P2,1,vB);wB+=iB*(crossVec2Vec2(vcp1.rB,P1)+crossVec2Vec2(vcp2.rB,P2));vcp1.normalImpulse=x.x;vcp2.normalImpulse=x.y;break}x.x=0;x.y=-vcp2.normalMass*b.y;vn1=this.v_K.ey.x*x.y+b.x;vn2=0;if(x.y>=0&&vn1>=0){subVec2(d,x,a);scaleVec2(P1,d.x,normal$2);scaleVec2(P2,d.y,normal$2);combine3Vec2(vA,-mA,P1,-mA,P2,1,vA);wA-=iA*(crossVec2Vec2(vcp1.rA,P1)+crossVec2Vec2(vcp2.rA,P2));combine3Vec2(vB,mB,P1,mB,P2,1,vB);wB+=iB*(crossVec2Vec2(vcp1.rB,P1)+crossVec2Vec2(vcp2.rB,P2));vcp1.normalImpulse=x.x;vcp2.normalImpulse=x.y;break}x.x=0;x.y=0;vn1=b.x;vn2=b.y;if(vn1>=0&&vn2>=0){subVec2(d,x,a);scaleVec2(P1,d.x,normal$2);scaleVec2(P2,d.y,normal$2);combine3Vec2(vA,-mA,P1,-mA,P2,1,vA);wA-=iA*(crossVec2Vec2(vcp1.rA,P1)+crossVec2Vec2(vcp2.rA,P2));combine3Vec2(vB,mB,P1,mB,P2,1,vB);wB+=iB*(crossVec2Vec2(vcp1.rB,P1)+crossVec2Vec2(vcp2.rB,P2));vcp1.normalImpulse=x.x;vcp2.normalImpulse=x.y;break}break}}copyVec2(velocityA.v,vA);velocityA.w=wA;copyVec2(velocityB.v,vB);velocityB.w=wB};Contact2.addType=function(type1,type2,callback){s_registers[type1]=s_registers[type1]||{};s_registers[type1][type2]=callback};Contact2.create=function(fixtureA,indexA,fixtureB,indexB){var typeA=fixtureA.m_shape.m_type;var typeB=fixtureB.m_shape.m_type;var contact=contactPool.allocate();var evaluateFcn;if(evaluateFcn=s_registers[typeA]&&s_registers[typeA][typeB]){contact.initialize(fixtureA,indexA,fixtureB,indexB,evaluateFcn)}else if(evaluateFcn=s_registers[typeB]&&s_registers[typeB][typeA]){contact.initialize(fixtureB,indexB,fixtureA,indexA,evaluateFcn)}else{return null}fixtureA=contact.m_fixtureA;fixtureB=contact.m_fixtureB;indexA=contact.getChildIndexA();indexB=contact.getChildIndexB();var bodyA=fixtureA.m_body;var bodyB=fixtureB.m_body;contact.m_nodeA.contact=contact;contact.m_nodeA.other=bodyB;contact.m_nodeA.prev=null;contact.m_nodeA.next=bodyA.m_contactList;if(bodyA.m_contactList!=null){bodyA.m_contactList.prev=contact.m_nodeA}bodyA.m_contactList=contact.m_nodeA;contact.m_nodeB.contact=contact;contact.m_nodeB.other=bodyA;contact.m_nodeB.prev=null;contact.m_nodeB.next=bodyB.m_contactList;if(bodyB.m_contactList!=null){bodyB.m_contactList.prev=contact.m_nodeB}bodyB.m_contactList=contact.m_nodeB;if(fixtureA.isSensor()==false&&fixtureB.isSensor()==false){bodyA.setAwake(true);bodyB.setAwake(true)}return contact};Contact2.destroy=function(contact,listener){var fixtureA=contact.m_fixtureA;var fixtureB=contact.m_fixtureB;if(fixtureA===null||fixtureB===null)return;var bodyA=fixtureA.m_body;var bodyB=fixtureB.m_body;if(bodyA===null||bodyB===null)return;if(contact.isTouching()){listener.endContact(contact)}if(contact.m_nodeA.prev){contact.m_nodeA.prev.next=contact.m_nodeA.next}if(contact.m_nodeA.next){contact.m_nodeA.next.prev=contact.m_nodeA.prev}if(contact.m_nodeA==bodyA.m_contactList){bodyA.m_contactList=contact.m_nodeA.next}if(contact.m_nodeB.prev){contact.m_nodeB.prev.next=contact.m_nodeB.next}if(contact.m_nodeB.next){contact.m_nodeB.next.prev=contact.m_nodeB.prev}if(contact.m_nodeB==bodyB.m_contactList){bodyB.m_contactList=contact.m_nodeB.next}if(contact.m_manifold.pointCount>0&&!fixtureA.m_isSensor&&!fixtureB.m_isSensor){bodyA.setAwake(true);bodyB.setAwake(true)}contactPool.release(contact)};return Contact2}();var DEFAULTS$b={gravity:Vec2.zero(),allowSleep:true,warmStarting:true,continuousPhysics:true,subStepping:false,blockSolve:true,velocityIterations:8,positionIterations:3};var World=function(){function World2(def){if(!(this instanceof World2)){return new World2(def)}this.s_step=new TimeStep;if(!def){def={}}else if(Vec2.isValid(def)){def={gravity:def}}def=options(def,DEFAULTS$b);this.m_solver=new Solver(this);this.m_broadPhase=new BroadPhase;this.m_contactList=null;this.m_contactCount=0;this.m_bodyList=null;this.m_bodyCount=0;this.m_jointList=null;this.m_jointCount=0;this.m_stepComplete=true;this.m_allowSleep=def.allowSleep;this.m_gravity=Vec2.clone(def.gravity);this.m_clearForces=true;this.m_newFixture=false;this.m_locked=false;this.m_warmStarting=def.warmStarting;this.m_continuousPhysics=def.continuousPhysics;this.m_subStepping=def.subStepping;this.m_blockSolve=def.blockSolve;this.m_velocityIterations=def.velocityIterations;this.m_positionIterations=def.positionIterations;this.m_t=0;this.m_step_callback=[]}World2.prototype._serialize=function(){var bodies=[];var joints=[];for(var b2=this.getBodyList();b2;b2=b2.getNext()){bodies.push(b2)}for(var j=this.getJointList();j;j=j.getNext()){if(typeof j._serialize==="function"){joints.push(j)}}return{gravity:this.m_gravity,bodies:bodies,joints:joints}};World2._deserialize=function(data,context,restore){if(!data){return new World2}var world=new World2(data.gravity);if(data.bodies){for(var i=data.bodies.length-1;i>=0;i-=1){world._addBody(restore(Body,data.bodies[i],world))}}if(data.joints){for(var i=data.joints.length-1;i>=0;i--){world.createJoint(restore(Joint,data.joints[i],world))}}return world};World2.prototype.getBodyList=function(){return this.m_bodyList};World2.prototype.getJointList=function(){return this.m_jointList};World2.prototype.getContactList=function(){return this.m_contactList};World2.prototype.getBodyCount=function(){return this.m_bodyCount};World2.prototype.getJointCount=function(){return this.m_jointCount};World2.prototype.getContactCount=function(){return this.m_contactCount};World2.prototype.setGravity=function(gravity){this.m_gravity.set(gravity)};World2.prototype.getGravity=function(){return this.m_gravity};World2.prototype.isLocked=function(){return this.m_locked};World2.prototype.setAllowSleeping=function(flag){if(flag==this.m_allowSleep){return}this.m_allowSleep=flag;if(this.m_allowSleep==false){for(var b2=this.m_bodyList;b2;b2=b2.m_next){b2.setAwake(true)}}};World2.prototype.getAllowSleeping=function(){return this.m_allowSleep};World2.prototype.setWarmStarting=function(flag){this.m_warmStarting=flag};World2.prototype.getWarmStarting=function(){return this.m_warmStarting};World2.prototype.setContinuousPhysics=function(flag){this.m_continuousPhysics=flag};World2.prototype.getContinuousPhysics=function(){return this.m_continuousPhysics};World2.prototype.setSubStepping=function(flag){this.m_subStepping=flag};World2.prototype.getSubStepping=function(){return this.m_subStepping};World2.prototype.setAutoClearForces=function(flag){this.m_clearForces=flag};World2.prototype.getAutoClearForces=function(){return this.m_clearForces};World2.prototype.clearForces=function(){for(var body=this.m_bodyList;body;body=body.getNext()){body.m_force.setZero();body.m_torque=0}};World2.prototype.queryAABB=function(aabb,callback){var broadPhase=this.m_broadPhase;this.m_broadPhase.query(aabb,(function(proxyId){var proxy=broadPhase.getUserData(proxyId);return callback(proxy.fixture)}))};World2.prototype.rayCast=function(point1,point2,callback){var broadPhase=this.m_broadPhase;this.m_broadPhase.rayCast({maxFraction:1,p1:point1,p2:point2},(function(input2,proxyId){var proxy=broadPhase.getUserData(proxyId);var fixture=proxy.fixture;var index=proxy.childIndex;var output2={};var hit=fixture.rayCast(output2,input2,index);if(hit){var fraction=output2.fraction;var point3=Vec2.add(Vec2.mulNumVec2(1-fraction,input2.p1),Vec2.mulNumVec2(fraction,input2.p2));return callback(fixture,point3,output2.normal,fraction)}return input2.maxFraction}))};World2.prototype.getProxyCount=function(){return this.m_broadPhase.getProxyCount()};World2.prototype.getTreeHeight=function(){return this.m_broadPhase.getTreeHeight()};World2.prototype.getTreeBalance=function(){return this.m_broadPhase.getTreeBalance()};World2.prototype.getTreeQuality=function(){return this.m_broadPhase.getTreeQuality()};World2.prototype.shiftOrigin=function(newOrigin){if(this.isLocked()){return}for(var b2=this.m_bodyList;b2;b2=b2.m_next){b2.m_xf.p.sub(newOrigin);b2.m_sweep.c0.sub(newOrigin);b2.m_sweep.c.sub(newOrigin)}for(var j=this.m_jointList;j;j=j.m_next){j.shiftOrigin(newOrigin)}this.m_broadPhase.shiftOrigin(newOrigin)};World2.prototype._addBody=function(body){if(this.isLocked()){return}body.m_prev=null;body.m_next=this.m_bodyList;if(this.m_bodyList){this.m_bodyList.m_prev=body}this.m_bodyList=body;++this.m_bodyCount};World2.prototype.createBody=function(arg1,arg2){if(this.isLocked()){return null}var def={};if(!arg1);else if(Vec2.isValid(arg1)){def={position:arg1,angle:arg2}}else if(typeof arg1==="object"){def=arg1}var body=new Body(this,def);this._addBody(body);return body};World2.prototype.createDynamicBody=function(arg1,arg2){var def={};if(!arg1);else if(Vec2.isValid(arg1)){def={position:arg1,angle:arg2}}else if(typeof arg1==="object"){def=arg1}def.type="dynamic";return this.createBody(def)};World2.prototype.createKinematicBody=function(arg1,arg2){var def={};if(!arg1);else if(Vec2.isValid(arg1)){def={position:arg1,angle:arg2}}else if(typeof arg1==="object"){def=arg1}def.type="kinematic";return this.createBody(def)};World2.prototype.destroyBody=function(b2){if(this.isLocked()){return}if(b2.m_destroyed){return false}var je=b2.m_jointList;while(je){var je0=je;je=je.next;this.publish("remove-joint",je0.joint);this.destroyJoint(je0.joint);b2.m_jointList=je}b2.m_jointList=null;var ce=b2.m_contactList;while(ce){var ce0=ce;ce=ce.next;this.destroyContact(ce0.contact);b2.m_contactList=ce}b2.m_contactList=null;var f=b2.m_fixtureList;while(f){var f0=f;f=f.m_next;this.publish("remove-fixture",f0);f0.destroyProxies(this.m_broadPhase);b2.m_fixtureList=f}b2.m_fixtureList=null;if(b2.m_prev){b2.m_prev.m_next=b2.m_next}if(b2.m_next){b2.m_next.m_prev=b2.m_prev}if(b2==this.m_bodyList){this.m_bodyList=b2.m_next}b2.m_destroyed=true;--this.m_bodyCount;this.publish("remove-body",b2);return true};World2.prototype.createJoint=function(joint){if(this.isLocked()){return null}joint.m_prev=null;joint.m_next=this.m_jointList;if(this.m_jointList){this.m_jointList.m_prev=joint}this.m_jointList=joint;++this.m_jointCount;joint.m_edgeA.joint=joint;joint.m_edgeA.other=joint.m_bodyB;joint.m_edgeA.prev=null;joint.m_edgeA.next=joint.m_bodyA.m_jointList;if(joint.m_bodyA.m_jointList)joint.m_bodyA.m_jointList.prev=joint.m_edgeA;joint.m_bodyA.m_jointList=joint.m_edgeA;joint.m_edgeB.joint=joint;joint.m_edgeB.other=joint.m_bodyA;joint.m_edgeB.prev=null;joint.m_edgeB.next=joint.m_bodyB.m_jointList;if(joint.m_bodyB.m_jointList)joint.m_bodyB.m_jointList.prev=joint.m_edgeB;joint.m_bodyB.m_jointList=joint.m_edgeB;if(joint.m_collideConnected==false){for(var edge=joint.m_bodyB.getContactList();edge;edge=edge.next){if(edge.other==joint.m_bodyA){edge.contact.flagForFiltering()}}}return joint};World2.prototype.destroyJoint=function(joint){if(this.isLocked()){return}if(joint.m_prev){joint.m_prev.m_next=joint.m_next}if(joint.m_next){joint.m_next.m_prev=joint.m_prev}if(joint==this.m_jointList){this.m_jointList=joint.m_next}var bodyA=joint.m_bodyA;var bodyB=joint.m_bodyB;bodyA.setAwake(true);bodyB.setAwake(true);if(joint.m_edgeA.prev){joint.m_edgeA.prev.next=joint.m_edgeA.next}if(joint.m_edgeA.next){joint.m_edgeA.next.prev=joint.m_edgeA.prev}if(joint.m_edgeA==bodyA.m_jointList){bodyA.m_jointList=joint.m_edgeA.next}joint.m_edgeA.prev=null;joint.m_edgeA.next=null;if(joint.m_edgeB.prev){joint.m_edgeB.prev.next=joint.m_edgeB.next}if(joint.m_edgeB.next){joint.m_edgeB.next.prev=joint.m_edgeB.prev}if(joint.m_edgeB==bodyB.m_jointList){bodyB.m_jointList=joint.m_edgeB.next}joint.m_edgeB.prev=null;joint.m_edgeB.next=null;--this.m_jointCount;if(joint.m_collideConnected==false){var edge=bodyB.getContactList();while(edge){if(edge.other==bodyA){edge.contact.flagForFiltering()}edge=edge.next}}this.publish("remove-joint",joint)};World2.prototype.step=function(timeStep,velocityIterations,positionIterations){this.publish("pre-step",timeStep);if((velocityIterations|0)!==velocityIterations){velocityIterations=0}velocityIterations=velocityIterations||this.m_velocityIterations;positionIterations=positionIterations||this.m_positionIterations;if(this.m_newFixture){this.findNewContacts();this.m_newFixture=false}this.m_locked=true;this.s_step.reset(timeStep);this.s_step.velocityIterations=velocityIterations;this.s_step.positionIterations=positionIterations;this.s_step.warmStarting=this.m_warmStarting;this.s_step.blockSolve=this.m_blockSolve;this.updateContacts();if(this.m_stepComplete&&timeStep>0){this.m_solver.solveWorld(this.s_step);for(var b2=this.m_bodyList;b2;b2=b2.getNext()){if(b2.m_islandFlag==false){continue}if(b2.isStatic()){continue}b2.synchronizeFixtures()}this.findNewContacts()}if(this.m_continuousPhysics&&timeStep>0){this.m_solver.solveWorldTOI(this.s_step)}if(this.m_clearForces){this.clearForces()}this.m_locked=false;var callback;while(callback=this.m_step_callback.shift()){callback(this)}this.publish("post-step",timeStep)};World2.prototype.queueUpdate=function(callback){if(!this.isLocked()){callback(this)}else{this.m_step_callback.push(callback)}};World2.prototype.findNewContacts=function(){var _this=this;this.m_broadPhase.updatePairs((function(proxyA,proxyB){return _this.createContact(proxyA,proxyB)}))};World2.prototype.createContact=function(proxyA,proxyB){var fixtureA=proxyA.fixture;var fixtureB=proxyB.fixture;var indexA=proxyA.childIndex;var indexB=proxyB.childIndex;var bodyA=fixtureA.getBody();var bodyB=fixtureB.getBody();if(bodyA==bodyB){return}var edge=bodyB.getContactList();while(edge){if(edge.other==bodyA){var fA=edge.contact.getFixtureA();var fB=edge.contact.getFixtureB();var iA=edge.contact.getChildIndexA();var iB=edge.contact.getChildIndexB();if(fA==fixtureA&&fB==fixtureB&&iA==indexA&&iB==indexB){return}if(fA==fixtureB&&fB==fixtureA&&iA==indexB&&iB==indexA){return}}edge=edge.next}if(bodyB.shouldCollide(bodyA)==false){return}if(fixtureB.shouldCollide(fixtureA)==false){return}var contact=Contact.create(fixtureA,indexA,fixtureB,indexB);if(contact==null){return}contact.m_prev=null;if(this.m_contactList!=null){contact.m_next=this.m_contactList;this.m_contactList.m_prev=contact}this.m_contactList=contact;++this.m_contactCount};World2.prototype.updateContacts=function(){var c2;var next_c=this.m_contactList;while(c2=next_c){next_c=c2.getNext();var fixtureA=c2.getFixtureA();var fixtureB=c2.getFixtureB();var indexA=c2.getChildIndexA();var indexB=c2.getChildIndexB();var bodyA=fixtureA.getBody();var bodyB=fixtureB.getBody();if(c2.m_filterFlag){if(bodyB.shouldCollide(bodyA)==false){this.destroyContact(c2);continue}if(fixtureB.shouldCollide(fixtureA)==false){this.destroyContact(c2);continue}c2.m_filterFlag=false}var activeA=bodyA.isAwake()&&!bodyA.isStatic();var activeB=bodyB.isAwake()&&!bodyB.isStatic();if(activeA==false&&activeB==false){continue}var proxyIdA=fixtureA.m_proxies[indexA].proxyId;var proxyIdB=fixtureB.m_proxies[indexB].proxyId;var overlap=this.m_broadPhase.testOverlap(proxyIdA,proxyIdB);if(overlap==false){this.destroyContact(c2);continue}c2.update(this)}};World2.prototype.destroyContact=function(contact){if(contact.m_prev){contact.m_prev.m_next=contact.m_next}if(contact.m_next){contact.m_next.m_prev=contact.m_prev}if(contact==this.m_contactList){this.m_contactList=contact.m_next}Contact.destroy(contact,this);--this.m_contactCount};World2.prototype.on=function(name,listener){if(typeof name!=="string"||typeof listener!=="function"){return this}if(!this._listeners){this._listeners={}}if(!this._listeners[name]){this._listeners[name]=[]}this._listeners[name].push(listener);return this};World2.prototype.off=function(name,listener){if(typeof name!=="string"||typeof listener!=="function"){return this}var listeners=this._listeners&&this._listeners[name];if(!listeners||!listeners.length){return this}var index=listeners.indexOf(listener);if(index>=0){listeners.splice(index,1)}return this};World2.prototype.publish=function(name,arg1,arg2,arg3){var listeners=this._listeners&&this._listeners[name];if(!listeners||!listeners.length){return 0}for(var l=0;l0){output2.normal=Rot.mulVec2(xf2.q,normal3).neg()}else{output2.normal=Rot.mulVec2(xf2.q,normal3)}return true};EdgeShape2.prototype.computeAABB=function(aabb,xf2,childIndex){transformVec2(v1$2,xf2,this.m_vertex1);transformVec2(v2$1,xf2,this.m_vertex2);AABB.combinePoints(aabb,v1$2,v2$1);AABB.extend(aabb,this.m_radius)};EdgeShape2.prototype.computeMass=function(massData,density){massData.mass=0;combine2Vec2(massData.center,.5,this.m_vertex1,.5,this.m_vertex2);massData.I=0};EdgeShape2.prototype.computeDistanceProxy=function(proxy){proxy.m_vertices[0]=this.m_vertex1;proxy.m_vertices[1]=this.m_vertex2;proxy.m_vertices.length=2;proxy.m_count=2;proxy.m_radius=this.m_radius};EdgeShape2.TYPE="edge";return EdgeShape2}(Shape);var Edge=EdgeShape;var v1$1=vec2(0,0);var v2=vec2(0,0);var ChainShape=function(_super){__extends$a(ChainShape2,_super);function ChainShape2(vertices,loop){var _this=this;if(!(_this instanceof ChainShape2)){return new ChainShape2(vertices,loop)}_this=_super.call(this)||this;_this.m_type=ChainShape2.TYPE;_this.m_radius=SettingsInternal.polygonRadius;_this.m_vertices=[];_this.m_count=0;_this.m_prevVertex=null;_this.m_nextVertex=null;_this.m_hasPrevVertex=false;_this.m_hasNextVertex=false;_this.m_isLoop=!!loop;if(vertices&&vertices.length){if(loop){_this._createLoop(vertices)}else{_this._createChain(vertices)}}return _this}ChainShape2.prototype._serialize=function(){var data={type:this.m_type,vertices:this.m_isLoop?this.m_vertices.slice(0,this.m_vertices.length-1):this.m_vertices,isLoop:this.m_isLoop,hasPrevVertex:this.m_hasPrevVertex,hasNextVertex:this.m_hasNextVertex,prevVertex:null,nextVertex:null};if(this.m_prevVertex){data.prevVertex=this.m_prevVertex}if(this.m_nextVertex){data.nextVertex=this.m_nextVertex}return data};ChainShape2._deserialize=function(data,fixture,restore){var vertices=[];if(data.vertices){for(var i=0;i0){edge.m_vertex0=this.m_vertices[childIndex-1];edge.m_hasVertex0=true}else{edge.m_vertex0=this.m_prevVertex;edge.m_hasVertex0=this.m_hasPrevVertex}if(childIndexx0||x2===x0&&ps[i].yr.lengthSquared()){ie2=j}}++m;ih=ie2;if(ie2===i0){break}}if(m<3){this._setAsBox(1,1);return}this.m_count=m;this.m_vertices=[];for(var i=0;i0){return false}}return true};PolygonShape2.prototype.rayCast=function(output2,input2,xf2,childIndex){var p1=Rot.mulTVec2(xf2.q,Vec2.sub(input2.p1,xf2.p));var p2=Rot.mulTVec2(xf2.q,Vec2.sub(input2.p2,xf2.p));var d2=Vec2.sub(p2,p1);var lower=0;var upper=input2.maxFraction;var index=-1;for(var i=0;i0&&numerator=0){output2.fraction=lower;output2.normal=Rot.mulVec2(xf2.q,this.m_normals[index]);return true}return false};PolygonShape2.prototype.computeAABB=function(aabb,xf2,childIndex){var minX=Infinity;var minY=Infinity;var maxX=-Infinity;var maxY=-Infinity;for(var i=0;i0){this.m_length=+def.length}else if(def.length<0);else if(def.anchorA||def.anchorA||def.anchorA||def.anchorA){this.m_length=Vec2.distance(this.m_bodyA.getWorldPoint(this.m_localAnchorA),this.m_bodyB.getWorldPoint(this.m_localAnchorB))}if(Number.isFinite(def.frequencyHz)){this.m_frequencyHz=def.frequencyHz}if(Number.isFinite(def.dampingRatio)){this.m_dampingRatio=def.dampingRatio}};DistanceJoint2.prototype.getLocalAnchorA=function(){return this.m_localAnchorA};DistanceJoint2.prototype.getLocalAnchorB=function(){return this.m_localAnchorB};DistanceJoint2.prototype.setLength=function(length2){this.m_length=length2};DistanceJoint2.prototype.getLength=function(){return this.m_length};DistanceJoint2.prototype.setFrequency=function(hz){this.m_frequencyHz=hz};DistanceJoint2.prototype.getFrequency=function(){return this.m_frequencyHz};DistanceJoint2.prototype.setDampingRatio=function(ratio){this.m_dampingRatio=ratio};DistanceJoint2.prototype.getDampingRatio=function(){return this.m_dampingRatio};DistanceJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};DistanceJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};DistanceJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.mulNumVec2(this.m_impulse,this.m_u).mul(inv_dt)};DistanceJoint2.prototype.getReactionTorque=function(inv_dt){return 0};DistanceJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter;this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);this.m_rA=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));this.m_rB=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));this.m_u=Vec2.sub(Vec2.add(cB2,this.m_rB),Vec2.add(cA2,this.m_rA));var length2=this.m_u.length();if(length2>SettingsInternal.linearSlop){this.m_u.mul(1/length2)}else{this.m_u.setNum(0,0)}var crAu=Vec2.crossVec2Vec2(this.m_rA,this.m_u);var crBu=Vec2.crossVec2Vec2(this.m_rB,this.m_u);var invMass=this.m_invMassA+this.m_invIA*crAu*crAu+this.m_invMassB+this.m_invIB*crBu*crBu;this.m_mass=invMass!=0?1/invMass:0;if(this.m_frequencyHz>0){var C=length2-this.m_length;var omega=2*math_PI$4*this.m_frequencyHz;var d2=2*this.m_mass*this.m_dampingRatio*omega;var k=this.m_mass*omega*omega;var h=step.dt;this.m_gamma=h*(d2+h*k);this.m_gamma=this.m_gamma!=0?1/this.m_gamma:0;this.m_bias=C*h*k*this.m_gamma;invMass+=this.m_gamma;this.m_mass=invMass!=0?1/invMass:0}else{this.m_gamma=0;this.m_bias=0}if(step.warmStarting){this.m_impulse*=step.dtRatio;var P3=Vec2.mulNumVec2(this.m_impulse,this.m_u);vA2.subMul(this.m_invMassA,P3);wA-=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,P3);vB2.addMul(this.m_invMassB,P3);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,P3)}else{this.m_impulse=0}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};DistanceJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var vpA=Vec2.add(vA2,Vec2.crossNumVec2(wA,this.m_rA));var vpB=Vec2.add(vB2,Vec2.crossNumVec2(wB,this.m_rB));var Cdot=Vec2.dot(this.m_u,vpB)-Vec2.dot(this.m_u,vpA);var impulse=-this.m_mass*(Cdot+this.m_bias+this.m_gamma*this.m_impulse);this.m_impulse+=impulse;var P3=Vec2.mulNumVec2(impulse,this.m_u);vA2.subMul(this.m_invMassA,P3);wA-=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,P3);vB2.addMul(this.m_invMassB,P3);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,P3);this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};DistanceJoint2.prototype.solvePositionConstraints=function(step){if(this.m_frequencyHz>0){return true}var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulSub(qA,this.m_localAnchorA,this.m_localCenterA);var rB2=Rot.mulSub(qB,this.m_localAnchorB,this.m_localCenterB);var u=Vec2.sub(Vec2.add(cB2,rB2),Vec2.add(cA2,rA2));var length2=u.normalize();var C=clamp$1(length2-this.m_length,-SettingsInternal.maxLinearCorrection,SettingsInternal.maxLinearCorrection);var impulse=-this.m_mass*C;var P3=Vec2.mulNumVec2(impulse,u);cA2.subMul(this.m_invMassA,P3);aA-=this.m_invIA*Vec2.crossVec2Vec2(rA2,P3);cB2.addMul(this.m_invMassB,P3);aB+=this.m_invIB*Vec2.crossVec2Vec2(rB2,P3);this.m_bodyA.c_position.c.setVec2(cA2);this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c.setVec2(cB2);this.m_bodyB.c_position.a=aB;return math_abs$6(C)0){this.m_angularMass=1/this.m_angularMass}if(step.warmStarting){this.m_linearImpulse.mul(step.dtRatio);this.m_angularImpulse*=step.dtRatio;var P3=Vec2.neo(this.m_linearImpulse.x,this.m_linearImpulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+this.m_angularImpulse);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+this.m_angularImpulse)}else{this.m_linearImpulse.setZero();this.m_angularImpulse=0}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};FrictionJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var h=step.dt;{var Cdot=wB-wA;var impulse=-this.m_angularMass*Cdot;var oldImpulse=this.m_angularImpulse;var maxImpulse=h*this.m_maxTorque;this.m_angularImpulse=clamp$1(this.m_angularImpulse+impulse,-maxImpulse,maxImpulse);impulse=this.m_angularImpulse-oldImpulse;wA-=iA*impulse;wB+=iB*impulse}{var Cdot=Vec2.sub(Vec2.add(vB2,Vec2.crossNumVec2(wB,this.m_rB)),Vec2.add(vA2,Vec2.crossNumVec2(wA,this.m_rA)));var impulse=Vec2.neg(Mat22.mulVec2(this.m_linearMass,Cdot));var oldImpulse=this.m_linearImpulse;this.m_linearImpulse.add(impulse);var maxImpulse=h*this.m_maxForce;if(this.m_linearImpulse.lengthSquared()>maxImpulse*maxImpulse){this.m_linearImpulse.normalize();this.m_linearImpulse.mul(maxImpulse)}impulse=Vec2.sub(this.m_linearImpulse,oldImpulse);vA2.subMul(mA,impulse);wA-=iA*Vec2.crossVec2Vec2(this.m_rA,impulse);vB2.addMul(mB,impulse);wB+=iB*Vec2.crossVec2Vec2(this.m_rB,impulse)}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};FrictionJoint2.prototype.solvePositionConstraints=function(step){return true};FrictionJoint2.TYPE="friction-joint";return FrictionJoint2}(Joint);var Mat33=function(){function Mat332(a2,b2,c2){if(typeof a2==="object"&&a2!==null){this.ex=Vec3.clone(a2);this.ey=Vec3.clone(b2);this.ez=Vec3.clone(c2)}else{this.ex=Vec3.zero();this.ey=Vec3.zero();this.ez=Vec3.zero()}}Mat332.prototype.toString=function(){return JSON.stringify(this)};Mat332.isValid=function(obj){if(obj===null||typeof obj==="undefined"){return false}return Vec3.isValid(obj.ex)&&Vec3.isValid(obj.ey)&&Vec3.isValid(obj.ez)};Mat332.assert=function(o){};Mat332.prototype.setZero=function(){this.ex.setZero();this.ey.setZero();this.ez.setZero();return this};Mat332.prototype.solve33=function(v3){var cross_x=this.ey.y*this.ez.z-this.ey.z*this.ez.y;var cross_y=this.ey.z*this.ez.x-this.ey.x*this.ez.z;var cross_z=this.ey.x*this.ez.y-this.ey.y*this.ez.x;var det=this.ex.x*cross_x+this.ex.y*cross_y+this.ex.z*cross_z;if(det!==0){det=1/det}var r=new Vec3;cross_x=this.ey.y*this.ez.z-this.ey.z*this.ez.y;cross_y=this.ey.z*this.ez.x-this.ey.x*this.ez.z;cross_z=this.ey.x*this.ez.y-this.ey.y*this.ez.x;r.x=det*(v3.x*cross_x+v3.y*cross_y+v3.z*cross_z);cross_x=v3.y*this.ez.z-v3.z*this.ez.y;cross_y=v3.z*this.ez.x-v3.x*this.ez.z;cross_z=v3.x*this.ez.y-v3.y*this.ez.x;r.y=det*(this.ex.x*cross_x+this.ex.y*cross_y+this.ex.z*cross_z);cross_x=this.ey.y*v3.z-this.ey.z*v3.y;cross_y=this.ey.z*v3.x-this.ey.x*v3.z;cross_z=this.ey.x*v3.y-this.ey.y*v3.x;r.z=det*(this.ex.x*cross_x+this.ex.y*cross_y+this.ex.z*cross_z);return r};Mat332.prototype.solve22=function(v3){var a11=this.ex.x;var a12=this.ey.x;var a21=this.ex.y;var a22=this.ey.y;var det=a11*a22-a12*a21;if(det!==0){det=1/det}var r=Vec2.zero();r.x=det*(a22*v3.x-a12*v3.y);r.y=det*(a11*v3.y-a21*v3.x);return r};Mat332.prototype.getInverse22=function(M){var a2=this.ex.x;var b2=this.ey.x;var c2=this.ex.y;var d2=this.ey.y;var det=a2*d2-b2*c2;if(det!==0){det=1/det}M.ex.x=det*d2;M.ey.x=-det*b2;M.ex.z=0;M.ex.y=-det*c2;M.ey.y=det*a2;M.ey.z=0;M.ez.x=0;M.ez.y=0;M.ez.z=0};Mat332.prototype.getSymInverse33=function(M){var det=Vec3.dot(this.ex,Vec3.cross(this.ey,this.ez));if(det!==0){det=1/det}var a11=this.ex.x;var a12=this.ey.x;var a13=this.ez.x;var a22=this.ey.y;var a23=this.ez.y;var a33=this.ez.z;M.ex.x=det*(a22*a33-a23*a23);M.ex.y=det*(a13*a23-a12*a33);M.ex.z=det*(a12*a23-a13*a22);M.ey.x=M.ex.y;M.ey.y=det*(a11*a33-a13*a13);M.ey.z=det*(a13*a12-a11*a23);M.ez.x=M.ex.z;M.ez.y=M.ey.z;M.ez.z=det*(a11*a22-a12*a12)};Mat332.mul=function(a2,b2){if(b2&&"z"in b2&&"y"in b2&&"x"in b2){var x2=a2.ex.x*b2.x+a2.ey.x*b2.y+a2.ez.x*b2.z;var y=a2.ex.y*b2.x+a2.ey.y*b2.y+a2.ez.y*b2.z;var z=a2.ex.z*b2.x+a2.ey.z*b2.y+a2.ez.z*b2.z;return new Vec3(x2,y,z)}else if(b2&&"y"in b2&&"x"in b2){var x2=a2.ex.x*b2.x+a2.ey.x*b2.y;var y=a2.ex.y*b2.x+a2.ey.y*b2.y;return Vec2.neo(x2,y)}};Mat332.mulVec3=function(a2,b2){var x2=a2.ex.x*b2.x+a2.ey.x*b2.y+a2.ez.x*b2.z;var y=a2.ex.y*b2.x+a2.ey.y*b2.y+a2.ez.y*b2.z;var z=a2.ex.z*b2.x+a2.ey.z*b2.y+a2.ez.z*b2.z;return new Vec3(x2,y,z)};Mat332.mulVec2=function(a2,b2){var x2=a2.ex.x*b2.x+a2.ey.x*b2.y;var y=a2.ex.y*b2.x+a2.ey.y*b2.y;return Vec2.neo(x2,y)};Mat332.add=function(a2,b2){return new Mat332(Vec3.add(a2.ex,b2.ex),Vec3.add(a2.ey,b2.ey),Vec3.add(a2.ez,b2.ez))};return Mat332}();var math_abs$5=Math.abs;var LimitState$2;(function(LimitState2){LimitState2[LimitState2["inactiveLimit"]=0]="inactiveLimit";LimitState2[LimitState2["atLowerLimit"]=1]="atLowerLimit";LimitState2[LimitState2["atUpperLimit"]=2]="atUpperLimit";LimitState2[LimitState2["equalLimits"]=3]="equalLimits"})(LimitState$2||(LimitState$2={}));var DEFAULTS$8={lowerAngle:0,upperAngle:0,maxMotorTorque:0,motorSpeed:0,enableLimit:false,enableMotor:false};var RevoluteJoint=function(_super){__extends$a(RevoluteJoint2,_super);function RevoluteJoint2(def,bodyA,bodyB,anchor){var _this=this;var _a2,_b,_c,_d,_e,_f;if(!(_this instanceof RevoluteJoint2)){return new RevoluteJoint2(def,bodyA,bodyB,anchor)}def=def!==null&&def!==void 0?def:{};_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_mass=new Mat33;_this.m_limitState=LimitState$2.inactiveLimit;_this.m_type=RevoluteJoint2.TYPE;if(Vec2.isValid(anchor)){_this.m_localAnchorA=bodyA.getLocalPoint(anchor)}else if(Vec2.isValid(def.localAnchorA)){_this.m_localAnchorA=Vec2.clone(def.localAnchorA)}else{_this.m_localAnchorA=Vec2.zero()}if(Vec2.isValid(anchor)){_this.m_localAnchorB=bodyB.getLocalPoint(anchor)}else if(Vec2.isValid(def.localAnchorB)){_this.m_localAnchorB=Vec2.clone(def.localAnchorB)}else{_this.m_localAnchorB=Vec2.zero()}if(Number.isFinite(def.referenceAngle)){_this.m_referenceAngle=def.referenceAngle}else{_this.m_referenceAngle=bodyB.getAngle()-bodyA.getAngle()}_this.m_impulse=new Vec3;_this.m_motorImpulse=0;_this.m_lowerAngle=(_a2=def.lowerAngle)!==null&&_a2!==void 0?_a2:DEFAULTS$8.lowerAngle;_this.m_upperAngle=(_b=def.upperAngle)!==null&&_b!==void 0?_b:DEFAULTS$8.upperAngle;_this.m_maxMotorTorque=(_c=def.maxMotorTorque)!==null&&_c!==void 0?_c:DEFAULTS$8.maxMotorTorque;_this.m_motorSpeed=(_d=def.motorSpeed)!==null&&_d!==void 0?_d:DEFAULTS$8.motorSpeed;_this.m_enableLimit=(_e=def.enableLimit)!==null&&_e!==void 0?_e:DEFAULTS$8.enableLimit;_this.m_enableMotor=(_f=def.enableMotor)!==null&&_f!==void 0?_f:DEFAULTS$8.enableMotor;return _this}RevoluteJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,lowerAngle:this.m_lowerAngle,upperAngle:this.m_upperAngle,maxMotorTorque:this.m_maxMotorTorque,motorSpeed:this.m_motorSpeed,enableLimit:this.m_enableLimit,enableMotor:this.m_enableMotor,localAnchorA:this.m_localAnchorA,localAnchorB:this.m_localAnchorB,referenceAngle:this.m_referenceAngle}};RevoluteJoint2._deserialize=function(data,world,restore){data=__assign$1({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);var joint=new RevoluteJoint2(data);return joint};RevoluteJoint2.prototype._reset=function(def){if(def.anchorA){this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA))}else if(def.localAnchorA){this.m_localAnchorA.setVec2(def.localAnchorA)}if(def.anchorB){this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB))}else if(def.localAnchorB){this.m_localAnchorB.setVec2(def.localAnchorB)}if(Number.isFinite(def.referenceAngle)){this.m_referenceAngle=def.referenceAngle}if(def.enableLimit!==void 0){this.m_enableLimit=def.enableLimit}if(Number.isFinite(def.lowerAngle)){this.m_lowerAngle=def.lowerAngle}if(Number.isFinite(def.upperAngle)){this.m_upperAngle=def.upperAngle}if(Number.isFinite(def.maxMotorTorque)){this.m_maxMotorTorque=def.maxMotorTorque}if(Number.isFinite(def.motorSpeed)){this.m_motorSpeed=def.motorSpeed}if(def.enableMotor!==void 0){this.m_enableMotor=def.enableMotor}};RevoluteJoint2.prototype.getLocalAnchorA=function(){return this.m_localAnchorA};RevoluteJoint2.prototype.getLocalAnchorB=function(){return this.m_localAnchorB};RevoluteJoint2.prototype.getReferenceAngle=function(){return this.m_referenceAngle};RevoluteJoint2.prototype.getJointAngle=function(){var bA=this.m_bodyA;var bB=this.m_bodyB;return bB.m_sweep.a-bA.m_sweep.a-this.m_referenceAngle};RevoluteJoint2.prototype.getJointSpeed=function(){var bA=this.m_bodyA;var bB=this.m_bodyB;return bB.m_angularVelocity-bA.m_angularVelocity};RevoluteJoint2.prototype.isMotorEnabled=function(){return this.m_enableMotor};RevoluteJoint2.prototype.enableMotor=function(flag){if(flag==this.m_enableMotor)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_enableMotor=flag};RevoluteJoint2.prototype.getMotorTorque=function(inv_dt){return inv_dt*this.m_motorImpulse};RevoluteJoint2.prototype.setMotorSpeed=function(speed){if(speed==this.m_motorSpeed)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_motorSpeed=speed};RevoluteJoint2.prototype.getMotorSpeed=function(){return this.m_motorSpeed};RevoluteJoint2.prototype.setMaxMotorTorque=function(torque){if(torque==this.m_maxMotorTorque)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_maxMotorTorque=torque};RevoluteJoint2.prototype.getMaxMotorTorque=function(){return this.m_maxMotorTorque};RevoluteJoint2.prototype.isLimitEnabled=function(){return this.m_enableLimit};RevoluteJoint2.prototype.enableLimit=function(flag){if(flag!=this.m_enableLimit){this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_enableLimit=flag;this.m_impulse.z=0}};RevoluteJoint2.prototype.getLowerLimit=function(){return this.m_lowerAngle};RevoluteJoint2.prototype.getUpperLimit=function(){return this.m_upperAngle};RevoluteJoint2.prototype.setLimits=function(lower,upper){if(lower!=this.m_lowerAngle||upper!=this.m_upperAngle){this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_impulse.z=0;this.m_lowerAngle=lower;this.m_upperAngle=upper}};RevoluteJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};RevoluteJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};RevoluteJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.neo(this.m_impulse.x,this.m_impulse.y).mul(inv_dt)};RevoluteJoint2.prototype.getReactionTorque=function(inv_dt){return inv_dt*this.m_impulse.z};RevoluteJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter;this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);this.m_rA=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));this.m_rB=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var fixedRotation=iA+iB===0;this.m_mass.ex.x=mA+mB+this.m_rA.y*this.m_rA.y*iA+this.m_rB.y*this.m_rB.y*iB;this.m_mass.ey.x=-this.m_rA.y*this.m_rA.x*iA-this.m_rB.y*this.m_rB.x*iB;this.m_mass.ez.x=-this.m_rA.y*iA-this.m_rB.y*iB;this.m_mass.ex.y=this.m_mass.ey.x;this.m_mass.ey.y=mA+mB+this.m_rA.x*this.m_rA.x*iA+this.m_rB.x*this.m_rB.x*iB;this.m_mass.ez.y=this.m_rA.x*iA+this.m_rB.x*iB;this.m_mass.ex.z=this.m_mass.ez.x;this.m_mass.ey.z=this.m_mass.ez.y;this.m_mass.ez.z=iA+iB;this.m_motorMass=iA+iB;if(this.m_motorMass>0){this.m_motorMass=1/this.m_motorMass}if(this.m_enableMotor==false||fixedRotation){this.m_motorImpulse=0}if(this.m_enableLimit&&fixedRotation==false){var jointAngle=aB-aA-this.m_referenceAngle;if(math_abs$5(this.m_upperAngle-this.m_lowerAngle)<2*SettingsInternal.angularSlop){this.m_limitState=LimitState$2.equalLimits}else if(jointAngle<=this.m_lowerAngle){if(this.m_limitState!=LimitState$2.atLowerLimit){this.m_impulse.z=0}this.m_limitState=LimitState$2.atLowerLimit}else if(jointAngle>=this.m_upperAngle){if(this.m_limitState!=LimitState$2.atUpperLimit){this.m_impulse.z=0}this.m_limitState=LimitState$2.atUpperLimit}else{this.m_limitState=LimitState$2.inactiveLimit;this.m_impulse.z=0}}else{this.m_limitState=LimitState$2.inactiveLimit}if(step.warmStarting){this.m_impulse.mul(step.dtRatio);this.m_motorImpulse*=step.dtRatio;var P3=Vec2.neo(this.m_impulse.x,this.m_impulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+this.m_motorImpulse+this.m_impulse.z);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+this.m_motorImpulse+this.m_impulse.z)}else{this.m_impulse.setZero();this.m_motorImpulse=0}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};RevoluteJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var fixedRotation=iA+iB===0;if(this.m_enableMotor&&this.m_limitState!=LimitState$2.equalLimits&&fixedRotation==false){var Cdot=wB-wA-this.m_motorSpeed;var impulse=-this.m_motorMass*Cdot;var oldImpulse=this.m_motorImpulse;var maxImpulse=step.dt*this.m_maxMotorTorque;this.m_motorImpulse=clamp$1(this.m_motorImpulse+impulse,-maxImpulse,maxImpulse);impulse=this.m_motorImpulse-oldImpulse;wA-=iA*impulse;wB+=iB*impulse}if(this.m_enableLimit&&this.m_limitState!=LimitState$2.inactiveLimit&&fixedRotation==false){var Cdot1=Vec2.zero();Cdot1.addCombine(1,vB2,1,Vec2.crossNumVec2(wB,this.m_rB));Cdot1.subCombine(1,vA2,1,Vec2.crossNumVec2(wA,this.m_rA));var Cdot2=wB-wA;var Cdot=new Vec3(Cdot1.x,Cdot1.y,Cdot2);var impulse=Vec3.neg(this.m_mass.solve33(Cdot));if(this.m_limitState==LimitState$2.equalLimits){this.m_impulse.add(impulse)}else if(this.m_limitState==LimitState$2.atLowerLimit){var newImpulse=this.m_impulse.z+impulse.z;if(newImpulse<0){var rhs=Vec2.combine(-1,Cdot1,this.m_impulse.z,Vec2.neo(this.m_mass.ez.x,this.m_mass.ez.y));var reduced=this.m_mass.solve22(rhs);impulse.x=reduced.x;impulse.y=reduced.y;impulse.z=-this.m_impulse.z;this.m_impulse.x+=reduced.x;this.m_impulse.y+=reduced.y;this.m_impulse.z=0}else{this.m_impulse.add(impulse)}}else if(this.m_limitState==LimitState$2.atUpperLimit){var newImpulse=this.m_impulse.z+impulse.z;if(newImpulse>0){var rhs=Vec2.combine(-1,Cdot1,this.m_impulse.z,Vec2.neo(this.m_mass.ez.x,this.m_mass.ez.y));var reduced=this.m_mass.solve22(rhs);impulse.x=reduced.x;impulse.y=reduced.y;impulse.z=-this.m_impulse.z;this.m_impulse.x+=reduced.x;this.m_impulse.y+=reduced.y;this.m_impulse.z=0}else{this.m_impulse.add(impulse)}}var P3=Vec2.neo(impulse.x,impulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+impulse.z);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+impulse.z)}else{var Cdot=Vec2.zero();Cdot.addCombine(1,vB2,1,Vec2.crossNumVec2(wB,this.m_rB));Cdot.subCombine(1,vA2,1,Vec2.crossNumVec2(wA,this.m_rA));var impulse=this.m_mass.solve22(Vec2.neg(Cdot));this.m_impulse.x+=impulse.x;this.m_impulse.y+=impulse.y;vA2.subMul(mA,impulse);wA-=iA*Vec2.crossVec2Vec2(this.m_rA,impulse);vB2.addMul(mB,impulse);wB+=iB*Vec2.crossVec2Vec2(this.m_rB,impulse)}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};RevoluteJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var angularError=0;var positionError=0;var fixedRotation=this.m_invIA+this.m_invIB==0;if(this.m_enableLimit&&this.m_limitState!=LimitState$2.inactiveLimit&&fixedRotation==false){var angle=aB-aA-this.m_referenceAngle;var limitImpulse=0;if(this.m_limitState==LimitState$2.equalLimits){var C=clamp$1(angle-this.m_lowerAngle,-SettingsInternal.maxAngularCorrection,SettingsInternal.maxAngularCorrection);limitImpulse=-this.m_motorMass*C;angularError=math_abs$5(C)}else if(this.m_limitState==LimitState$2.atLowerLimit){var C=angle-this.m_lowerAngle;angularError=-C;C=clamp$1(C+SettingsInternal.angularSlop,-SettingsInternal.maxAngularCorrection,0);limitImpulse=-this.m_motorMass*C}else if(this.m_limitState==LimitState$2.atUpperLimit){var C=angle-this.m_upperAngle;angularError=C;C=clamp$1(C-SettingsInternal.angularSlop,0,SettingsInternal.maxAngularCorrection);limitImpulse=-this.m_motorMass*C}aA-=this.m_invIA*limitImpulse;aB+=this.m_invIB*limitImpulse}{qA.setAngle(aA);qB.setAngle(aB);var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var C=Vec2.zero();C.addCombine(1,cB2,1,rB2);C.subCombine(1,cA2,1,rA2);positionError=C.length();var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var K=new Mat22;K.ex.x=mA+mB+iA*rA2.y*rA2.y+iB*rB2.y*rB2.y;K.ex.y=-iA*rA2.x*rA2.y-iB*rB2.x*rB2.y;K.ey.x=K.ex.y;K.ey.y=mA+mB+iA*rA2.x*rA2.x+iB*rB2.x*rB2.x;var impulse=Vec2.neg(K.solve(C));cA2.subMul(mA,impulse);aA-=iA*Vec2.crossVec2Vec2(rA2,impulse);cB2.addMul(mB,impulse);aB+=iB*Vec2.crossVec2Vec2(rB2,impulse)}this.m_bodyA.c_position.c.setVec2(cA2);this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c.setVec2(cB2);this.m_bodyB.c_position.a=aB;return positionError<=SettingsInternal.linearSlop&&angularError<=SettingsInternal.angularSlop};RevoluteJoint2.TYPE="revolute-joint";return RevoluteJoint2}(Joint);var math_abs$4=Math.abs;var math_max$1=Math.max;var math_min$3=Math.min;var LimitState$1;(function(LimitState2){LimitState2[LimitState2["inactiveLimit"]=0]="inactiveLimit";LimitState2[LimitState2["atLowerLimit"]=1]="atLowerLimit";LimitState2[LimitState2["atUpperLimit"]=2]="atUpperLimit";LimitState2[LimitState2["equalLimits"]=3]="equalLimits"})(LimitState$1||(LimitState$1={}));var DEFAULTS$7={enableLimit:false,lowerTranslation:0,upperTranslation:0,enableMotor:false,maxMotorForce:0,motorSpeed:0};var PrismaticJoint=function(_super){__extends$a(PrismaticJoint2,_super);function PrismaticJoint2(def,bodyA,bodyB,anchor,axis){var _this=this;if(!(_this instanceof PrismaticJoint2)){return new PrismaticJoint2(def,bodyA,bodyB,anchor,axis)}def=options(def,DEFAULTS$7);_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_type=PrismaticJoint2.TYPE;_this.m_localAnchorA=Vec2.clone(anchor?bodyA.getLocalPoint(anchor):def.localAnchorA||Vec2.zero());_this.m_localAnchorB=Vec2.clone(anchor?bodyB.getLocalPoint(anchor):def.localAnchorB||Vec2.zero());_this.m_localXAxisA=Vec2.clone(axis?bodyA.getLocalVector(axis):def.localAxisA||Vec2.neo(1,0));_this.m_localXAxisA.normalize();_this.m_localYAxisA=Vec2.crossNumVec2(1,_this.m_localXAxisA);_this.m_referenceAngle=Number.isFinite(def.referenceAngle)?def.referenceAngle:bodyB.getAngle()-bodyA.getAngle();_this.m_impulse=new Vec3;_this.m_motorMass=0;_this.m_motorImpulse=0;_this.m_lowerTranslation=def.lowerTranslation;_this.m_upperTranslation=def.upperTranslation;_this.m_maxMotorForce=def.maxMotorForce;_this.m_motorSpeed=def.motorSpeed;_this.m_enableLimit=def.enableLimit;_this.m_enableMotor=def.enableMotor;_this.m_limitState=LimitState$1.inactiveLimit;_this.m_axis=Vec2.zero();_this.m_perp=Vec2.zero();_this.m_K=new Mat33;return _this}PrismaticJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,lowerTranslation:this.m_lowerTranslation,upperTranslation:this.m_upperTranslation,maxMotorForce:this.m_maxMotorForce,motorSpeed:this.m_motorSpeed,enableLimit:this.m_enableLimit,enableMotor:this.m_enableMotor,localAnchorA:this.m_localAnchorA,localAnchorB:this.m_localAnchorB,localAxisA:this.m_localXAxisA,referenceAngle:this.m_referenceAngle}};PrismaticJoint2._deserialize=function(data,world,restore){data=__assign$1({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);data.localAxisA=Vec2.clone(data.localAxisA);var joint=new PrismaticJoint2(data);return joint};PrismaticJoint2.prototype._reset=function(def){if(def.anchorA){this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA))}else if(def.localAnchorA){this.m_localAnchorA.setVec2(def.localAnchorA)}if(def.anchorB){this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB))}else if(def.localAnchorB){this.m_localAnchorB.setVec2(def.localAnchorB)}if(def.localAxisA){this.m_localXAxisA.setVec2(def.localAxisA);this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1,def.localAxisA))}if(Number.isFinite(def.referenceAngle)){this.m_referenceAngle=def.referenceAngle}if(typeof def.enableLimit!=="undefined"){this.m_enableLimit=!!def.enableLimit}if(Number.isFinite(def.lowerTranslation)){this.m_lowerTranslation=def.lowerTranslation}if(Number.isFinite(def.upperTranslation)){this.m_upperTranslation=def.upperTranslation}if(typeof def.enableMotor!=="undefined"){this.m_enableMotor=!!def.enableMotor}if(Number.isFinite(def.maxMotorForce)){this.m_maxMotorForce=def.maxMotorForce}if(Number.isFinite(def.motorSpeed)){this.m_motorSpeed=def.motorSpeed}};PrismaticJoint2.prototype.getLocalAnchorA=function(){return this.m_localAnchorA};PrismaticJoint2.prototype.getLocalAnchorB=function(){return this.m_localAnchorB};PrismaticJoint2.prototype.getLocalAxisA=function(){return this.m_localXAxisA};PrismaticJoint2.prototype.getReferenceAngle=function(){return this.m_referenceAngle};PrismaticJoint2.prototype.getJointTranslation=function(){var pA2=this.m_bodyA.getWorldPoint(this.m_localAnchorA);var pB2=this.m_bodyB.getWorldPoint(this.m_localAnchorB);var d2=Vec2.sub(pB2,pA2);var axis=this.m_bodyA.getWorldVector(this.m_localXAxisA);var translation2=Vec2.dot(d2,axis);return translation2};PrismaticJoint2.prototype.getJointSpeed=function(){var bA=this.m_bodyA;var bB=this.m_bodyB;var rA2=Rot.mulVec2(bA.m_xf.q,Vec2.sub(this.m_localAnchorA,bA.m_sweep.localCenter));var rB2=Rot.mulVec2(bB.m_xf.q,Vec2.sub(this.m_localAnchorB,bB.m_sweep.localCenter));var p1=Vec2.add(bA.m_sweep.c,rA2);var p2=Vec2.add(bB.m_sweep.c,rB2);var d2=Vec2.sub(p2,p1);var axis=Rot.mulVec2(bA.m_xf.q,this.m_localXAxisA);var vA2=bA.m_linearVelocity;var vB2=bB.m_linearVelocity;var wA=bA.m_angularVelocity;var wB=bB.m_angularVelocity;var speed=Vec2.dot(d2,Vec2.crossNumVec2(wA,axis))+Vec2.dot(axis,Vec2.sub(Vec2.addCrossNumVec2(vB2,wB,rB2),Vec2.addCrossNumVec2(vA2,wA,rA2)));return speed};PrismaticJoint2.prototype.isLimitEnabled=function(){return this.m_enableLimit};PrismaticJoint2.prototype.enableLimit=function(flag){if(flag!=this.m_enableLimit){this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_enableLimit=flag;this.m_impulse.z=0}};PrismaticJoint2.prototype.getLowerLimit=function(){return this.m_lowerTranslation};PrismaticJoint2.prototype.getUpperLimit=function(){return this.m_upperTranslation};PrismaticJoint2.prototype.setLimits=function(lower,upper){if(lower!=this.m_lowerTranslation||upper!=this.m_upperTranslation){this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_lowerTranslation=lower;this.m_upperTranslation=upper;this.m_impulse.z=0}};PrismaticJoint2.prototype.isMotorEnabled=function(){return this.m_enableMotor};PrismaticJoint2.prototype.enableMotor=function(flag){if(flag==this.m_enableMotor)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_enableMotor=flag};PrismaticJoint2.prototype.setMotorSpeed=function(speed){if(speed==this.m_motorSpeed)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_motorSpeed=speed};PrismaticJoint2.prototype.setMaxMotorForce=function(force){if(force==this.m_maxMotorForce)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_maxMotorForce=force};PrismaticJoint2.prototype.getMaxMotorForce=function(){return this.m_maxMotorForce};PrismaticJoint2.prototype.getMotorSpeed=function(){return this.m_motorSpeed};PrismaticJoint2.prototype.getMotorForce=function(inv_dt){return inv_dt*this.m_motorImpulse};PrismaticJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};PrismaticJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};PrismaticJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.combine(this.m_impulse.x,this.m_perp,this.m_motorImpulse+this.m_impulse.z,this.m_axis).mul(inv_dt)};PrismaticJoint2.prototype.getReactionTorque=function(inv_dt){return inv_dt*this.m_impulse.y};PrismaticJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter;this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var d2=Vec2.zero();d2.addCombine(1,cB2,1,rB2);d2.subCombine(1,cA2,1,rA2);var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;{this.m_axis=Rot.mulVec2(qA,this.m_localXAxisA);this.m_a1=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),this.m_axis);this.m_a2=Vec2.crossVec2Vec2(rB2,this.m_axis);this.m_motorMass=mA+mB+iA*this.m_a1*this.m_a1+iB*this.m_a2*this.m_a2;if(this.m_motorMass>0){this.m_motorMass=1/this.m_motorMass}}{this.m_perp=Rot.mulVec2(qA,this.m_localYAxisA);this.m_s1=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),this.m_perp);this.m_s2=Vec2.crossVec2Vec2(rB2,this.m_perp);Vec2.crossVec2Vec2(rA2,this.m_perp);var k11=mA+mB+iA*this.m_s1*this.m_s1+iB*this.m_s2*this.m_s2;var k12=iA*this.m_s1+iB*this.m_s2;var k13=iA*this.m_s1*this.m_a1+iB*this.m_s2*this.m_a2;var k22=iA+iB;if(k22==0){k22=1}var k23=iA*this.m_a1+iB*this.m_a2;var k33=mA+mB+iA*this.m_a1*this.m_a1+iB*this.m_a2*this.m_a2;this.m_K.ex.set(k11,k12,k13);this.m_K.ey.set(k12,k22,k23);this.m_K.ez.set(k13,k23,k33)}if(this.m_enableLimit){var jointTranslation=Vec2.dot(this.m_axis,d2);if(math_abs$4(this.m_upperTranslation-this.m_lowerTranslation)<2*SettingsInternal.linearSlop){this.m_limitState=LimitState$1.equalLimits}else if(jointTranslation<=this.m_lowerTranslation){if(this.m_limitState!=LimitState$1.atLowerLimit){this.m_limitState=LimitState$1.atLowerLimit;this.m_impulse.z=0}}else if(jointTranslation>=this.m_upperTranslation){if(this.m_limitState!=LimitState$1.atUpperLimit){this.m_limitState=LimitState$1.atUpperLimit;this.m_impulse.z=0}}else{this.m_limitState=LimitState$1.inactiveLimit;this.m_impulse.z=0}}else{this.m_limitState=LimitState$1.inactiveLimit;this.m_impulse.z=0}if(this.m_enableMotor==false){this.m_motorImpulse=0}if(step.warmStarting){this.m_impulse.mul(step.dtRatio);this.m_motorImpulse*=step.dtRatio;var P3=Vec2.combine(this.m_impulse.x,this.m_perp,this.m_motorImpulse+this.m_impulse.z,this.m_axis);var LA=this.m_impulse.x*this.m_s1+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a1;var LB=this.m_impulse.x*this.m_s2+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a2;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}else{this.m_impulse.setZero();this.m_motorImpulse=0}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};PrismaticJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;if(this.m_enableMotor&&this.m_limitState!=LimitState$1.equalLimits){var Cdot=Vec2.dot(this.m_axis,Vec2.sub(vB2,vA2))+this.m_a2*wB-this.m_a1*wA;var impulse=this.m_motorMass*(this.m_motorSpeed-Cdot);var oldImpulse=this.m_motorImpulse;var maxImpulse=step.dt*this.m_maxMotorForce;this.m_motorImpulse=clamp$1(this.m_motorImpulse+impulse,-maxImpulse,maxImpulse);impulse=this.m_motorImpulse-oldImpulse;var P3=Vec2.mulNumVec2(impulse,this.m_axis);var LA=impulse*this.m_a1;var LB=impulse*this.m_a2;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}var Cdot1=Vec2.zero();Cdot1.x+=Vec2.dot(this.m_perp,vB2)+this.m_s2*wB;Cdot1.x-=Vec2.dot(this.m_perp,vA2)+this.m_s1*wA;Cdot1.y=wB-wA;if(this.m_enableLimit&&this.m_limitState!=LimitState$1.inactiveLimit){var Cdot2=0;Cdot2+=Vec2.dot(this.m_axis,vB2)+this.m_a2*wB;Cdot2-=Vec2.dot(this.m_axis,vA2)+this.m_a1*wA;var Cdot=new Vec3(Cdot1.x,Cdot1.y,Cdot2);var f1=Vec3.clone(this.m_impulse);var df=this.m_K.solve33(Vec3.neg(Cdot));this.m_impulse.add(df);if(this.m_limitState==LimitState$1.atLowerLimit){this.m_impulse.z=math_max$1(this.m_impulse.z,0)}else if(this.m_limitState==LimitState$1.atUpperLimit){this.m_impulse.z=math_min$3(this.m_impulse.z,0)}var b2=Vec2.combine(-1,Cdot1,-(this.m_impulse.z-f1.z),Vec2.neo(this.m_K.ez.x,this.m_K.ez.y));var f2r=Vec2.add(this.m_K.solve22(b2),Vec2.neo(f1.x,f1.y));this.m_impulse.x=f2r.x;this.m_impulse.y=f2r.y;df=Vec3.sub(this.m_impulse,f1);var P3=Vec2.combine(df.x,this.m_perp,df.z,this.m_axis);var LA=df.x*this.m_s1+df.y+df.z*this.m_a1;var LB=df.x*this.m_s2+df.y+df.z*this.m_a2;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}else{var df=this.m_K.solve22(Vec2.neg(Cdot1));this.m_impulse.x+=df.x;this.m_impulse.y+=df.y;var P3=Vec2.mulNumVec2(df.x,this.m_perp);var LA=df.x*this.m_s1+df.y;var LB=df.x*this.m_s2+df.y;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};PrismaticJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var d2=Vec2.sub(Vec2.add(cB2,rB2),Vec2.add(cA2,rA2));var axis=Rot.mulVec2(qA,this.m_localXAxisA);var a1=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),axis);var a2=Vec2.crossVec2Vec2(rB2,axis);var perp2=Rot.mulVec2(qA,this.m_localYAxisA);var s1=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),perp2);var s2=Vec2.crossVec2Vec2(rB2,perp2);var impulse=new Vec3;var C1=Vec2.zero();C1.x=Vec2.dot(perp2,d2);C1.y=aB-aA-this.m_referenceAngle;var linearError=math_abs$4(C1.x);var angularError=math_abs$4(C1.y);var linearSlop=SettingsInternal.linearSlop;var maxLinearCorrection=SettingsInternal.maxLinearCorrection;var active=false;var C2=0;if(this.m_enableLimit){var translation2=Vec2.dot(axis,d2);if(math_abs$4(this.m_upperTranslation-this.m_lowerTranslation)<2*linearSlop){C2=clamp$1(translation2,-maxLinearCorrection,maxLinearCorrection);linearError=math_max$1(linearError,math_abs$4(translation2));active=true}else if(translation2<=this.m_lowerTranslation){C2=clamp$1(translation2-this.m_lowerTranslation+linearSlop,-maxLinearCorrection,0);linearError=Math.max(linearError,this.m_lowerTranslation-translation2);active=true}else if(translation2>=this.m_upperTranslation){C2=clamp$1(translation2-this.m_upperTranslation-linearSlop,0,maxLinearCorrection);linearError=Math.max(linearError,translation2-this.m_upperTranslation);active=true}}if(active){var k11=mA+mB+iA*s1*s1+iB*s2*s2;var k12=iA*s1+iB*s2;var k13=iA*s1*a1+iB*s2*a2;var k22=iA+iB;if(k22==0){k22=1}var k23=iA*a1+iB*a2;var k33=mA+mB+iA*a1*a1+iB*a2*a2;var K=new Mat33;K.ex.set(k11,k12,k13);K.ey.set(k12,k22,k23);K.ez.set(k13,k23,k33);var C=new Vec3;C.x=C1.x;C.y=C1.y;C.z=C2;impulse=K.solve33(Vec3.neg(C))}else{var k11=mA+mB+iA*s1*s1+iB*s2*s2;var k12=iA*s1+iB*s2;var k22=iA+iB;if(k22==0){k22=1}var K=new Mat22;K.ex.setNum(k11,k12);K.ey.setNum(k12,k22);var impulse1=K.solve(Vec2.neg(C1));impulse.x=impulse1.x;impulse.y=impulse1.y;impulse.z=0}var P3=Vec2.combine(impulse.x,perp2,impulse.z,axis);var LA=impulse.x*s1+impulse.y+impulse.z*a1;var LB=impulse.x*s2+impulse.y+impulse.z*a2;cA2.subMul(mA,P3);aA-=iA*LA;cB2.addMul(mB,P3);aB+=iB*LB;this.m_bodyA.c_position.c=cA2;this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c=cB2;this.m_bodyB.c_position.a=aB;return linearError<=SettingsInternal.linearSlop&&angularError<=SettingsInternal.angularSlop};PrismaticJoint2.TYPE="prismatic-joint";return PrismaticJoint2}(Joint);var DEFAULTS$6={ratio:1};var GearJoint=function(_super){__extends$a(GearJoint2,_super);function GearJoint2(def,bodyA,bodyB,joint1,joint2,ratio){var _this=this;if(!(_this instanceof GearJoint2)){return new GearJoint2(def,bodyA,bodyB,joint1,joint2,ratio)}def=options(def,DEFAULTS$6);_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_type=GearJoint2.TYPE;_this.m_joint1=joint1?joint1:def.joint1;_this.m_joint2=joint2?joint2:def.joint2;_this.m_ratio=Number.isFinite(ratio)?ratio:def.ratio;_this.m_type1=_this.m_joint1.getType();_this.m_type2=_this.m_joint2.getType();var coordinateA;var coordinateB;_this.m_bodyC=_this.m_joint1.getBodyA();_this.m_bodyA=_this.m_joint1.getBodyB();var xfA2=_this.m_bodyA.m_xf;var aA=_this.m_bodyA.m_sweep.a;var xfC=_this.m_bodyC.m_xf;var aC=_this.m_bodyC.m_sweep.a;if(_this.m_type1===RevoluteJoint.TYPE){var revolute=_this.m_joint1;_this.m_localAnchorC=revolute.m_localAnchorA;_this.m_localAnchorA=revolute.m_localAnchorB;_this.m_referenceAngleA=revolute.m_referenceAngle;_this.m_localAxisC=Vec2.zero();coordinateA=aA-aC-_this.m_referenceAngleA}else{var prismatic=_this.m_joint1;_this.m_localAnchorC=prismatic.m_localAnchorA;_this.m_localAnchorA=prismatic.m_localAnchorB;_this.m_referenceAngleA=prismatic.m_referenceAngle;_this.m_localAxisC=prismatic.m_localXAxisA;var pC=_this.m_localAnchorC;var pA2=Rot.mulTVec2(xfC.q,Vec2.add(Rot.mulVec2(xfA2.q,_this.m_localAnchorA),Vec2.sub(xfA2.p,xfC.p)));coordinateA=Vec2.dot(pA2,_this.m_localAxisC)-Vec2.dot(pC,_this.m_localAxisC)}_this.m_bodyD=_this.m_joint2.getBodyA();_this.m_bodyB=_this.m_joint2.getBodyB();var xfB2=_this.m_bodyB.m_xf;var aB=_this.m_bodyB.m_sweep.a;var xfD=_this.m_bodyD.m_xf;var aD=_this.m_bodyD.m_sweep.a;if(_this.m_type2===RevoluteJoint.TYPE){var revolute=_this.m_joint2;_this.m_localAnchorD=revolute.m_localAnchorA;_this.m_localAnchorB=revolute.m_localAnchorB;_this.m_referenceAngleB=revolute.m_referenceAngle;_this.m_localAxisD=Vec2.zero();coordinateB=aB-aD-_this.m_referenceAngleB}else{var prismatic=_this.m_joint2;_this.m_localAnchorD=prismatic.m_localAnchorA;_this.m_localAnchorB=prismatic.m_localAnchorB;_this.m_referenceAngleB=prismatic.m_referenceAngle;_this.m_localAxisD=prismatic.m_localXAxisA;var pD=_this.m_localAnchorD;var pB2=Rot.mulTVec2(xfD.q,Vec2.add(Rot.mulVec2(xfB2.q,_this.m_localAnchorB),Vec2.sub(xfB2.p,xfD.p)));coordinateB=Vec2.dot(pB2,_this.m_localAxisD)-Vec2.dot(pD,_this.m_localAxisD)}_this.m_constant=coordinateA+_this.m_ratio*coordinateB;_this.m_impulse=0;return _this}GearJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,joint1:this.m_joint1,joint2:this.m_joint2,ratio:this.m_ratio}};GearJoint2._deserialize=function(data,world,restore){data=__assign$1({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);data.joint1=restore(Joint,data.joint1,world);data.joint2=restore(Joint,data.joint2,world);var joint=new GearJoint2(data);return joint};GearJoint2.prototype._reset=function(def){if(Number.isFinite(def.ratio)){this.m_ratio=def.ratio}};GearJoint2.prototype.getJoint1=function(){return this.m_joint1};GearJoint2.prototype.getJoint2=function(){return this.m_joint2};GearJoint2.prototype.setRatio=function(ratio){this.m_ratio=ratio};GearJoint2.prototype.getRatio=function(){return this.m_ratio};GearJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};GearJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};GearJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.mulNumVec2(this.m_impulse,this.m_JvAC).mul(inv_dt)};GearJoint2.prototype.getReactionTorque=function(inv_dt){var L=this.m_impulse*this.m_JwA;return inv_dt*L};GearJoint2.prototype.initVelocityConstraints=function(step){this.m_lcA=this.m_bodyA.m_sweep.localCenter;this.m_lcB=this.m_bodyB.m_sweep.localCenter;this.m_lcC=this.m_bodyC.m_sweep.localCenter;this.m_lcD=this.m_bodyD.m_sweep.localCenter;this.m_mA=this.m_bodyA.m_invMass;this.m_mB=this.m_bodyB.m_invMass;this.m_mC=this.m_bodyC.m_invMass;this.m_mD=this.m_bodyD.m_invMass;this.m_iA=this.m_bodyA.m_invI;this.m_iB=this.m_bodyB.m_invI;this.m_iC=this.m_bodyC.m_invI;this.m_iD=this.m_bodyD.m_invI;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var aC=this.m_bodyC.c_position.a;var vC=this.m_bodyC.c_velocity.v;var wC=this.m_bodyC.c_velocity.w;var aD=this.m_bodyD.c_position.a;var vD=this.m_bodyD.c_velocity.v;var wD=this.m_bodyD.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var qC=Rot.neo(aC);var qD=Rot.neo(aD);this.m_mass=0;if(this.m_type1==RevoluteJoint.TYPE){this.m_JvAC=Vec2.zero();this.m_JwA=1;this.m_JwC=1;this.m_mass+=this.m_iA+this.m_iC}else{var u=Rot.mulVec2(qC,this.m_localAxisC);var rC=Rot.mulSub(qC,this.m_localAnchorC,this.m_lcC);var rA2=Rot.mulSub(qA,this.m_localAnchorA,this.m_lcA);this.m_JvAC=u;this.m_JwC=Vec2.crossVec2Vec2(rC,u);this.m_JwA=Vec2.crossVec2Vec2(rA2,u);this.m_mass+=this.m_mC+this.m_mA+this.m_iC*this.m_JwC*this.m_JwC+this.m_iA*this.m_JwA*this.m_JwA}if(this.m_type2==RevoluteJoint.TYPE){this.m_JvBD=Vec2.zero();this.m_JwB=this.m_ratio;this.m_JwD=this.m_ratio;this.m_mass+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD)}else{var u=Rot.mulVec2(qD,this.m_localAxisD);var rD=Rot.mulSub(qD,this.m_localAnchorD,this.m_lcD);var rB2=Rot.mulSub(qB,this.m_localAnchorB,this.m_lcB);this.m_JvBD=Vec2.mulNumVec2(this.m_ratio,u);this.m_JwD=this.m_ratio*Vec2.crossVec2Vec2(rD,u);this.m_JwB=this.m_ratio*Vec2.crossVec2Vec2(rB2,u);this.m_mass+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*this.m_JwD*this.m_JwD+this.m_iB*this.m_JwB*this.m_JwB}this.m_mass=this.m_mass>0?1/this.m_mass:0;if(step.warmStarting){vA2.addMul(this.m_mA*this.m_impulse,this.m_JvAC);wA+=this.m_iA*this.m_impulse*this.m_JwA;vB2.addMul(this.m_mB*this.m_impulse,this.m_JvBD);wB+=this.m_iB*this.m_impulse*this.m_JwB;vC.subMul(this.m_mC*this.m_impulse,this.m_JvAC);wC-=this.m_iC*this.m_impulse*this.m_JwC;vD.subMul(this.m_mD*this.m_impulse,this.m_JvBD);wD-=this.m_iD*this.m_impulse*this.m_JwD}else{this.m_impulse=0}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB;this.m_bodyC.c_velocity.v.setVec2(vC);this.m_bodyC.c_velocity.w=wC;this.m_bodyD.c_velocity.v.setVec2(vD);this.m_bodyD.c_velocity.w=wD};GearJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var vC=this.m_bodyC.c_velocity.v;var wC=this.m_bodyC.c_velocity.w;var vD=this.m_bodyD.c_velocity.v;var wD=this.m_bodyD.c_velocity.w;var Cdot=Vec2.dot(this.m_JvAC,vA2)-Vec2.dot(this.m_JvAC,vC)+Vec2.dot(this.m_JvBD,vB2)-Vec2.dot(this.m_JvBD,vD);Cdot+=this.m_JwA*wA-this.m_JwC*wC+(this.m_JwB*wB-this.m_JwD*wD);var impulse=-this.m_mass*Cdot;this.m_impulse+=impulse;vA2.addMul(this.m_mA*impulse,this.m_JvAC);wA+=this.m_iA*impulse*this.m_JwA;vB2.addMul(this.m_mB*impulse,this.m_JvBD);wB+=this.m_iB*impulse*this.m_JwB;vC.subMul(this.m_mC*impulse,this.m_JvAC);wC-=this.m_iC*impulse*this.m_JwC;vD.subMul(this.m_mD*impulse,this.m_JvBD);wD-=this.m_iD*impulse*this.m_JwD;this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB;this.m_bodyC.c_velocity.v.setVec2(vC);this.m_bodyC.c_velocity.w=wC;this.m_bodyD.c_velocity.v.setVec2(vD);this.m_bodyD.c_velocity.w=wD};GearJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var cC=this.m_bodyC.c_position.c;var aC=this.m_bodyC.c_position.a;var cD=this.m_bodyD.c_position.c;var aD=this.m_bodyD.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var qC=Rot.neo(aC);var qD=Rot.neo(aD);var linearError=0;var coordinateA;var coordinateB;var JvAC;var JvBD;var JwA;var JwB;var JwC;var JwD;var mass=0;if(this.m_type1==RevoluteJoint.TYPE){JvAC=Vec2.zero();JwA=1;JwC=1;mass+=this.m_iA+this.m_iC;coordinateA=aA-aC-this.m_referenceAngleA}else{var u=Rot.mulVec2(qC,this.m_localAxisC);var rC=Rot.mulSub(qC,this.m_localAnchorC,this.m_lcC);var rA2=Rot.mulSub(qA,this.m_localAnchorA,this.m_lcA);JvAC=u;JwC=Vec2.crossVec2Vec2(rC,u);JwA=Vec2.crossVec2Vec2(rA2,u);mass+=this.m_mC+this.m_mA+this.m_iC*JwC*JwC+this.m_iA*JwA*JwA;var pC=Vec2.sub(this.m_localAnchorC,this.m_lcC);var pA2=Rot.mulTVec2(qC,Vec2.add(rA2,Vec2.sub(cA2,cC)));coordinateA=Vec2.dot(Vec2.sub(pA2,pC),this.m_localAxisC)}if(this.m_type2==RevoluteJoint.TYPE){JvBD=Vec2.zero();JwB=this.m_ratio;JwD=this.m_ratio;mass+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD);coordinateB=aB-aD-this.m_referenceAngleB}else{var u=Rot.mulVec2(qD,this.m_localAxisD);var rD=Rot.mulSub(qD,this.m_localAnchorD,this.m_lcD);var rB2=Rot.mulSub(qB,this.m_localAnchorB,this.m_lcB);JvBD=Vec2.mulNumVec2(this.m_ratio,u);JwD=this.m_ratio*Vec2.crossVec2Vec2(rD,u);JwB=this.m_ratio*Vec2.crossVec2Vec2(rB2,u);mass+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*JwD*JwD+this.m_iB*JwB*JwB;var pD=Vec2.sub(this.m_localAnchorD,this.m_lcD);var pB2=Rot.mulTVec2(qD,Vec2.add(rB2,Vec2.sub(cB2,cD)));coordinateB=Vec2.dot(pB2,this.m_localAxisD)-Vec2.dot(pD,this.m_localAxisD)}var C=coordinateA+this.m_ratio*coordinateB-this.m_constant;var impulse=0;if(mass>0){impulse=-C/mass}cA2.addMul(this.m_mA*impulse,JvAC);aA+=this.m_iA*impulse*JwA;cB2.addMul(this.m_mB*impulse,JvBD);aB+=this.m_iB*impulse*JwB;cC.subMul(this.m_mC*impulse,JvAC);aC-=this.m_iC*impulse*JwC;cD.subMul(this.m_mD*impulse,JvBD);aD-=this.m_iD*impulse*JwD;this.m_bodyA.c_position.c.setVec2(cA2);this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c.setVec2(cB2);this.m_bodyB.c_position.a=aB;this.m_bodyC.c_position.c.setVec2(cC);this.m_bodyC.c_position.a=aC;this.m_bodyD.c_position.c.setVec2(cD);this.m_bodyD.c_position.a=aD;return linearError0){this.m_angularMass=1/this.m_angularMass}this.m_linearError=Vec2.zero();this.m_linearError.addCombine(1,cB2,1,this.m_rB);this.m_linearError.subCombine(1,cA2,1,this.m_rA);this.m_angularError=aB-aA-this.m_angularOffset;if(step.warmStarting){this.m_linearImpulse.mul(step.dtRatio);this.m_angularImpulse*=step.dtRatio;var P3=Vec2.neo(this.m_linearImpulse.x,this.m_linearImpulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+this.m_angularImpulse);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+this.m_angularImpulse)}else{this.m_linearImpulse.setZero();this.m_angularImpulse=0}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};MotorJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var h=step.dt;var inv_h=step.inv_dt;{var Cdot=wB-wA+inv_h*this.m_correctionFactor*this.m_angularError;var impulse=-this.m_angularMass*Cdot;var oldImpulse=this.m_angularImpulse;var maxImpulse=h*this.m_maxTorque;this.m_angularImpulse=clamp$1(this.m_angularImpulse+impulse,-maxImpulse,maxImpulse);impulse=this.m_angularImpulse-oldImpulse;wA-=iA*impulse;wB+=iB*impulse}{var Cdot=Vec2.zero();Cdot.addCombine(1,vB2,1,Vec2.crossNumVec2(wB,this.m_rB));Cdot.subCombine(1,vA2,1,Vec2.crossNumVec2(wA,this.m_rA));Cdot.addMul(inv_h*this.m_correctionFactor,this.m_linearError);var impulse=Vec2.neg(Mat22.mulVec2(this.m_linearMass,Cdot));var oldImpulse=Vec2.clone(this.m_linearImpulse);this.m_linearImpulse.add(impulse);var maxImpulse=h*this.m_maxForce;this.m_linearImpulse.clamp(maxImpulse);impulse=Vec2.sub(this.m_linearImpulse,oldImpulse);vA2.subMul(mA,impulse);wA-=iA*Vec2.crossVec2Vec2(this.m_rA,impulse);vB2.addMul(mB,impulse);wB+=iB*Vec2.crossVec2Vec2(this.m_rB,impulse)}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};MotorJoint2.prototype.solvePositionConstraints=function(step){return true};MotorJoint2.TYPE="motor-joint";return MotorJoint2}(Joint);var math_PI$3=Math.PI;var DEFAULTS$4={maxForce:0,frequencyHz:5,dampingRatio:.7};var MouseJoint=function(_super){__extends$a(MouseJoint2,_super);function MouseJoint2(def,bodyA,bodyB,target){var _this=this;if(!(_this instanceof MouseJoint2)){return new MouseJoint2(def,bodyA,bodyB,target)}def=options(def,DEFAULTS$4);_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_type=MouseJoint2.TYPE;if(Vec2.isValid(target)){_this.m_targetA=Vec2.clone(target)}else if(Vec2.isValid(def.target)){_this.m_targetA=Vec2.clone(def.target)}else{_this.m_targetA=Vec2.zero()}_this.m_localAnchorB=Transform.mulTVec2(bodyB.getTransform(),_this.m_targetA);_this.m_maxForce=def.maxForce;_this.m_impulse=Vec2.zero();_this.m_frequencyHz=def.frequencyHz;_this.m_dampingRatio=def.dampingRatio;_this.m_beta=0;_this.m_gamma=0;_this.m_rB=Vec2.zero();_this.m_localCenterB=Vec2.zero();_this.m_invMassB=0;_this.m_invIB=0;_this.m_mass=new Mat22;_this.m_C=Vec2.zero();return _this}MouseJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,target:this.m_targetA,maxForce:this.m_maxForce,frequencyHz:this.m_frequencyHz,dampingRatio:this.m_dampingRatio,_localAnchorB:this.m_localAnchorB}};MouseJoint2._deserialize=function(data,world,restore){data=__assign$1({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);data.target=Vec2.clone(data.target);var joint=new MouseJoint2(data);if(data._localAnchorB){joint.m_localAnchorB=data._localAnchorB}return joint};MouseJoint2.prototype._reset=function(def){if(Number.isFinite(def.maxForce)){this.m_maxForce=def.maxForce}if(Number.isFinite(def.frequencyHz)){this.m_frequencyHz=def.frequencyHz}if(Number.isFinite(def.dampingRatio)){this.m_dampingRatio=def.dampingRatio}};MouseJoint2.prototype.setTarget=function(target){if(Vec2.areEqual(target,this.m_targetA))return;this.m_bodyB.setAwake(true);this.m_targetA.set(target)};MouseJoint2.prototype.getTarget=function(){return this.m_targetA};MouseJoint2.prototype.setMaxForce=function(force){this.m_maxForce=force};MouseJoint2.prototype.getMaxForce=function(){return this.m_maxForce};MouseJoint2.prototype.setFrequency=function(hz){this.m_frequencyHz=hz};MouseJoint2.prototype.getFrequency=function(){return this.m_frequencyHz};MouseJoint2.prototype.setDampingRatio=function(ratio){this.m_dampingRatio=ratio};MouseJoint2.prototype.getDampingRatio=function(){return this.m_dampingRatio};MouseJoint2.prototype.getAnchorA=function(){return Vec2.clone(this.m_targetA)};MouseJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};MouseJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.mulNumVec2(inv_dt,this.m_impulse)};MouseJoint2.prototype.getReactionTorque=function(inv_dt){return inv_dt*0};MouseJoint2.prototype.shiftOrigin=function(newOrigin){this.m_targetA.sub(newOrigin)};MouseJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIB=this.m_bodyB.m_invI;var position=this.m_bodyB.c_position;var velocity=this.m_bodyB.c_velocity;var cB2=position.c;var aB=position.a;var vB2=velocity.v;var wB=velocity.w;var qB=Rot.neo(aB);var mass=this.m_bodyB.getMass();var omega=2*math_PI$3*this.m_frequencyHz;var d2=2*mass*this.m_dampingRatio*omega;var k=mass*(omega*omega);var h=step.dt;this.m_gamma=h*(d2+h*k);if(this.m_gamma!=0){this.m_gamma=1/this.m_gamma}this.m_beta=h*k*this.m_gamma;this.m_rB=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var K=new Mat22;K.ex.x=this.m_invMassB+this.m_invIB*this.m_rB.y*this.m_rB.y+this.m_gamma;K.ex.y=-this.m_invIB*this.m_rB.x*this.m_rB.y;K.ey.x=K.ex.y;K.ey.y=this.m_invMassB+this.m_invIB*this.m_rB.x*this.m_rB.x+this.m_gamma;this.m_mass=K.getInverse();this.m_C.setVec2(cB2);this.m_C.addCombine(1,this.m_rB,-1,this.m_targetA);this.m_C.mul(this.m_beta);wB*=.98;if(step.warmStarting){this.m_impulse.mul(step.dtRatio);vB2.addMul(this.m_invMassB,this.m_impulse);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,this.m_impulse)}else{this.m_impulse.setZero()}velocity.v.setVec2(vB2);velocity.w=wB};MouseJoint2.prototype.solveVelocityConstraints=function(step){var velocity=this.m_bodyB.c_velocity;var vB2=Vec2.clone(velocity.v);var wB=velocity.w;var Cdot=Vec2.crossNumVec2(wB,this.m_rB);Cdot.add(vB2);Cdot.addCombine(1,this.m_C,this.m_gamma,this.m_impulse);Cdot.neg();var impulse=Mat22.mulVec2(this.m_mass,Cdot);var oldImpulse=Vec2.clone(this.m_impulse);this.m_impulse.add(impulse);var maxImpulse=step.dt*this.m_maxForce;this.m_impulse.clamp(maxImpulse);impulse=Vec2.sub(this.m_impulse,oldImpulse);vB2.addMul(this.m_invMassB,impulse);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,impulse);velocity.v.setVec2(vB2);velocity.w=wB};MouseJoint2.prototype.solvePositionConstraints=function(step){return true};MouseJoint2.TYPE="mouse-joint";return MouseJoint2}(Joint);var math_abs$3=Math.abs;var DEFAULTS$3={collideConnected:true};var PulleyJoint=function(_super){__extends$a(PulleyJoint2,_super);function PulleyJoint2(def,bodyA,bodyB,groundA,groundB,anchorA,anchorB,ratio){var _this=this;if(!(_this instanceof PulleyJoint2)){return new PulleyJoint2(def,bodyA,bodyB,groundA,groundB,anchorA,anchorB,ratio)}def=options(def,DEFAULTS$3);_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_type=PulleyJoint2.TYPE;_this.m_groundAnchorA=Vec2.clone(groundA?groundA:def.groundAnchorA||Vec2.neo(-1,1));_this.m_groundAnchorB=Vec2.clone(groundB?groundB:def.groundAnchorB||Vec2.neo(1,1));_this.m_localAnchorA=Vec2.clone(anchorA?bodyA.getLocalPoint(anchorA):def.localAnchorA||Vec2.neo(-1,0));_this.m_localAnchorB=Vec2.clone(anchorB?bodyB.getLocalPoint(anchorB):def.localAnchorB||Vec2.neo(1,0));_this.m_lengthA=Number.isFinite(def.lengthA)?def.lengthA:Vec2.distance(anchorA,groundA);_this.m_lengthB=Number.isFinite(def.lengthB)?def.lengthB:Vec2.distance(anchorB,groundB);_this.m_ratio=Number.isFinite(ratio)?ratio:def.ratio;_this.m_constant=_this.m_lengthA+_this.m_ratio*_this.m_lengthB;_this.m_impulse=0;return _this}PulleyJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,groundAnchorA:this.m_groundAnchorA,groundAnchorB:this.m_groundAnchorB,localAnchorA:this.m_localAnchorA,localAnchorB:this.m_localAnchorB,lengthA:this.m_lengthA,lengthB:this.m_lengthB,ratio:this.m_ratio}};PulleyJoint2._deserialize=function(data,world,restore){data=__assign$1({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);var joint=new PulleyJoint2(data);return joint};PulleyJoint2.prototype._reset=function(def){if(Vec2.isValid(def.groundAnchorA)){this.m_groundAnchorA.set(def.groundAnchorA)}if(Vec2.isValid(def.groundAnchorB)){this.m_groundAnchorB.set(def.groundAnchorB)}if(Vec2.isValid(def.localAnchorA)){this.m_localAnchorA.set(def.localAnchorA)}else if(Vec2.isValid(def.anchorA)){this.m_localAnchorA.set(this.m_bodyA.getLocalPoint(def.anchorA))}if(Vec2.isValid(def.localAnchorB)){this.m_localAnchorB.set(def.localAnchorB)}else if(Vec2.isValid(def.anchorB)){this.m_localAnchorB.set(this.m_bodyB.getLocalPoint(def.anchorB))}if(Number.isFinite(def.lengthA)){this.m_lengthA=def.lengthA}if(Number.isFinite(def.lengthB)){this.m_lengthB=def.lengthB}if(Number.isFinite(def.ratio)){this.m_ratio=def.ratio}};PulleyJoint2.prototype.getGroundAnchorA=function(){return this.m_groundAnchorA};PulleyJoint2.prototype.getGroundAnchorB=function(){return this.m_groundAnchorB};PulleyJoint2.prototype.getLengthA=function(){return this.m_lengthA};PulleyJoint2.prototype.getLengthB=function(){return this.m_lengthB};PulleyJoint2.prototype.getRatio=function(){return this.m_ratio};PulleyJoint2.prototype.getCurrentLengthA=function(){var p=this.m_bodyA.getWorldPoint(this.m_localAnchorA);var s2=this.m_groundAnchorA;return Vec2.distance(p,s2)};PulleyJoint2.prototype.getCurrentLengthB=function(){var p=this.m_bodyB.getWorldPoint(this.m_localAnchorB);var s2=this.m_groundAnchorB;return Vec2.distance(p,s2)};PulleyJoint2.prototype.shiftOrigin=function(newOrigin){this.m_groundAnchorA.sub(newOrigin);this.m_groundAnchorB.sub(newOrigin)};PulleyJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};PulleyJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};PulleyJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.mulNumVec2(this.m_impulse,this.m_uB).mul(inv_dt)};PulleyJoint2.prototype.getReactionTorque=function(inv_dt){return 0};PulleyJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter;this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);this.m_rA=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));this.m_rB=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));this.m_uA=Vec2.sub(Vec2.add(cA2,this.m_rA),this.m_groundAnchorA);this.m_uB=Vec2.sub(Vec2.add(cB2,this.m_rB),this.m_groundAnchorB);var lengthA=this.m_uA.length();var lengthB=this.m_uB.length();if(lengthA>10*SettingsInternal.linearSlop){this.m_uA.mul(1/lengthA)}else{this.m_uA.setZero()}if(lengthB>10*SettingsInternal.linearSlop){this.m_uB.mul(1/lengthB)}else{this.m_uB.setZero()}var ruA=Vec2.crossVec2Vec2(this.m_rA,this.m_uA);var ruB=Vec2.crossVec2Vec2(this.m_rB,this.m_uB);var mA=this.m_invMassA+this.m_invIA*ruA*ruA;var mB=this.m_invMassB+this.m_invIB*ruB*ruB;this.m_mass=mA+this.m_ratio*this.m_ratio*mB;if(this.m_mass>0){this.m_mass=1/this.m_mass}if(step.warmStarting){this.m_impulse*=step.dtRatio;var PA=Vec2.mulNumVec2(-this.m_impulse,this.m_uA);var PB=Vec2.mulNumVec2(-this.m_ratio*this.m_impulse,this.m_uB);vA2.addMul(this.m_invMassA,PA);wA+=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,PA);vB2.addMul(this.m_invMassB,PB);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,PB)}else{this.m_impulse=0}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};PulleyJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var vpA=Vec2.add(vA2,Vec2.crossNumVec2(wA,this.m_rA));var vpB=Vec2.add(vB2,Vec2.crossNumVec2(wB,this.m_rB));var Cdot=-Vec2.dot(this.m_uA,vpA)-this.m_ratio*Vec2.dot(this.m_uB,vpB);var impulse=-this.m_mass*Cdot;this.m_impulse+=impulse;var PA=Vec2.mulNumVec2(-impulse,this.m_uA);var PB=Vec2.mulNumVec2(-this.m_ratio*impulse,this.m_uB);vA2.addMul(this.m_invMassA,PA);wA+=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,PA);vB2.addMul(this.m_invMassB,PB);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,PB);this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};PulleyJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var uA=Vec2.sub(Vec2.add(cA2,this.m_rA),this.m_groundAnchorA);var uB=Vec2.sub(Vec2.add(cB2,this.m_rB),this.m_groundAnchorB);var lengthA=uA.length();var lengthB=uB.length();if(lengthA>10*SettingsInternal.linearSlop){uA.mul(1/lengthA)}else{uA.setZero()}if(lengthB>10*SettingsInternal.linearSlop){uB.mul(1/lengthB)}else{uB.setZero()}var ruA=Vec2.crossVec2Vec2(rA2,uA);var ruB=Vec2.crossVec2Vec2(rB2,uB);var mA=this.m_invMassA+this.m_invIA*ruA*ruA;var mB=this.m_invMassB+this.m_invIB*ruB*ruB;var mass=mA+this.m_ratio*this.m_ratio*mB;if(mass>0){mass=1/mass}var C=this.m_constant-lengthA-this.m_ratio*lengthB;var linearError=math_abs$3(C);var impulse=-mass*C;var PA=Vec2.mulNumVec2(-impulse,uA);var PB=Vec2.mulNumVec2(-this.m_ratio*impulse,uB);cA2.addMul(this.m_invMassA,PA);aA+=this.m_invIA*Vec2.crossVec2Vec2(rA2,PA);cB2.addMul(this.m_invMassB,PB);aB+=this.m_invIB*Vec2.crossVec2Vec2(rB2,PB);this.m_bodyA.c_position.c=cA2;this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c=cB2;this.m_bodyB.c_position.a=aB;return linearError0){this.m_state=LimitState.atUpperLimit}else{this.m_state=LimitState.inactiveLimit}if(this.m_length>SettingsInternal.linearSlop){this.m_u.mul(1/this.m_length)}else{this.m_u.setZero();this.m_mass=0;this.m_impulse=0;return}var crA=Vec2.crossVec2Vec2(this.m_rA,this.m_u);var crB=Vec2.crossVec2Vec2(this.m_rB,this.m_u);var invMass=this.m_invMassA+this.m_invIA*crA*crA+this.m_invMassB+this.m_invIB*crB*crB;this.m_mass=invMass!=0?1/invMass:0;if(step.warmStarting){this.m_impulse*=step.dtRatio;var P3=Vec2.mulNumVec2(this.m_impulse,this.m_u);vA2.subMul(this.m_invMassA,P3);wA-=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,P3);vB2.addMul(this.m_invMassB,P3);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,P3)}else{this.m_impulse=0}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};RopeJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var vpA=Vec2.addCrossNumVec2(vA2,wA,this.m_rA);var vpB=Vec2.addCrossNumVec2(vB2,wB,this.m_rB);var C=this.m_length-this.m_maxLength;var Cdot=Vec2.dot(this.m_u,Vec2.sub(vpB,vpA));if(C<0){Cdot+=step.inv_dt*C}var impulse=-this.m_mass*Cdot;var oldImpulse=this.m_impulse;this.m_impulse=math_min$2(0,this.m_impulse+impulse);impulse=this.m_impulse-oldImpulse;var P3=Vec2.mulNumVec2(impulse,this.m_u);vA2.subMul(this.m_invMassA,P3);wA-=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,P3);vB2.addMul(this.m_invMassB,P3);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,P3);this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};RopeJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulSub(qA,this.m_localAnchorA,this.m_localCenterA);var rB2=Rot.mulSub(qB,this.m_localAnchorB,this.m_localCenterB);var u=Vec2.zero();u.addCombine(1,cB2,1,rB2);u.subCombine(1,cA2,1,rA2);var length2=u.normalize();var C=length2-this.m_maxLength;C=clamp$1(C,0,SettingsInternal.maxLinearCorrection);var impulse=-this.m_mass*C;var P3=Vec2.mulNumVec2(impulse,u);cA2.subMul(this.m_invMassA,P3);aA-=this.m_invIA*Vec2.crossVec2Vec2(rA2,P3);cB2.addMul(this.m_invMassB,P3);aB+=this.m_invIB*Vec2.crossVec2Vec2(rB2,P3);this.m_bodyA.c_position.c.setVec2(cA2);this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c.setVec2(cB2);this.m_bodyB.c_position.a=aB;return length2-this.m_maxLength0){K.getInverse22(this.m_mass);var invM=iA+iB;var m=invM>0?1/invM:0;var C=aB-aA-this.m_referenceAngle;var omega=2*math_PI$2*this.m_frequencyHz;var d2=2*m*this.m_dampingRatio*omega;var k=m*omega*omega;var h=step.dt;this.m_gamma=h*(d2+h*k);this.m_gamma=this.m_gamma!=0?1/this.m_gamma:0;this.m_bias=C*h*k*this.m_gamma;invM+=this.m_gamma;this.m_mass.ez.z=invM!=0?1/invM:0}else if(K.ez.z==0){K.getInverse22(this.m_mass);this.m_gamma=0;this.m_bias=0}else{K.getSymInverse33(this.m_mass);this.m_gamma=0;this.m_bias=0}if(step.warmStarting){this.m_impulse.mul(step.dtRatio);var P3=Vec2.neo(this.m_impulse.x,this.m_impulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+this.m_impulse.z);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+this.m_impulse.z)}else{this.m_impulse.setZero()}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};WeldJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;if(this.m_frequencyHz>0){var Cdot2=wB-wA;var impulse2=-this.m_mass.ez.z*(Cdot2+this.m_bias+this.m_gamma*this.m_impulse.z);this.m_impulse.z+=impulse2;wA-=iA*impulse2;wB+=iB*impulse2;var Cdot1=Vec2.zero();Cdot1.addCombine(1,vB2,1,Vec2.crossNumVec2(wB,this.m_rB));Cdot1.subCombine(1,vA2,1,Vec2.crossNumVec2(wA,this.m_rA));var impulse1=Vec2.neg(Mat33.mulVec2(this.m_mass,Cdot1));this.m_impulse.x+=impulse1.x;this.m_impulse.y+=impulse1.y;var P3=Vec2.clone(impulse1);vA2.subMul(mA,P3);wA-=iA*Vec2.crossVec2Vec2(this.m_rA,P3);vB2.addMul(mB,P3);wB+=iB*Vec2.crossVec2Vec2(this.m_rB,P3)}else{var Cdot1=Vec2.zero();Cdot1.addCombine(1,vB2,1,Vec2.crossNumVec2(wB,this.m_rB));Cdot1.subCombine(1,vA2,1,Vec2.crossNumVec2(wA,this.m_rA));var Cdot2=wB-wA;var Cdot=new Vec3(Cdot1.x,Cdot1.y,Cdot2);var impulse=Vec3.neg(Mat33.mulVec3(this.m_mass,Cdot));this.m_impulse.add(impulse);var P3=Vec2.neo(impulse.x,impulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+impulse.z);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+impulse.z)}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};WeldJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var positionError;var angularError;var K=new Mat33;K.ex.x=mA+mB+rA2.y*rA2.y*iA+rB2.y*rB2.y*iB;K.ey.x=-rA2.y*rA2.x*iA-rB2.y*rB2.x*iB;K.ez.x=-rA2.y*iA-rB2.y*iB;K.ex.y=K.ey.x;K.ey.y=mA+mB+rA2.x*rA2.x*iA+rB2.x*rB2.x*iB;K.ez.y=rA2.x*iA+rB2.x*iB;K.ex.z=K.ez.x;K.ey.z=K.ez.y;K.ez.z=iA+iB;if(this.m_frequencyHz>0){var C1=Vec2.zero();C1.addCombine(1,cB2,1,rB2);C1.subCombine(1,cA2,1,rA2);positionError=C1.length();angularError=0;var P3=Vec2.neg(K.solve22(C1));cA2.subMul(mA,P3);aA-=iA*Vec2.crossVec2Vec2(rA2,P3);cB2.addMul(mB,P3);aB+=iB*Vec2.crossVec2Vec2(rB2,P3)}else{var C1=Vec2.zero();C1.addCombine(1,cB2,1,rB2);C1.subCombine(1,cA2,1,rA2);var C2=aB-aA-this.m_referenceAngle;positionError=C1.length();angularError=math_abs$2(C2);var C=new Vec3(C1.x,C1.y,C2);var impulse=new Vec3;if(K.ez.z>0){impulse=Vec3.neg(K.solve33(C))}else{var impulse2=Vec2.neg(K.solve22(C1));impulse.set(impulse2.x,impulse2.y,0)}var P3=Vec2.neo(impulse.x,impulse.y);cA2.subMul(mA,P3);aA-=iA*(Vec2.crossVec2Vec2(rA2,P3)+impulse.z);cB2.addMul(mB,P3);aB+=iB*(Vec2.crossVec2Vec2(rB2,P3)+impulse.z)}this.m_bodyA.c_position.c=cA2;this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c=cB2;this.m_bodyB.c_position.a=aB;return positionError<=SettingsInternal.linearSlop&&angularError<=SettingsInternal.angularSlop};WeldJoint2.TYPE="weld-joint";return WeldJoint2}(Joint);var math_abs$1=Math.abs;var math_PI$1=Math.PI;var DEFAULTS={enableMotor:false,maxMotorTorque:0,motorSpeed:0,frequencyHz:2,dampingRatio:.7};var WheelJoint=function(_super){__extends$a(WheelJoint2,_super);function WheelJoint2(def,bodyA,bodyB,anchor,axis){var _this=this;if(!(_this instanceof WheelJoint2)){return new WheelJoint2(def,bodyA,bodyB,anchor,axis)}def=options(def,DEFAULTS);_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_ax=Vec2.zero();_this.m_ay=Vec2.zero();_this.m_type=WheelJoint2.TYPE;_this.m_localAnchorA=Vec2.clone(anchor?bodyA.getLocalPoint(anchor):def.localAnchorA||Vec2.zero());_this.m_localAnchorB=Vec2.clone(anchor?bodyB.getLocalPoint(anchor):def.localAnchorB||Vec2.zero());if(Vec2.isValid(axis)){_this.m_localXAxisA=bodyA.getLocalVector(axis)}else if(Vec2.isValid(def.localAxisA)){_this.m_localXAxisA=Vec2.clone(def.localAxisA)}else if(Vec2.isValid(def.localAxis)){_this.m_localXAxisA=Vec2.clone(def.localAxis)}else{_this.m_localXAxisA=Vec2.neo(1,0)}_this.m_localYAxisA=Vec2.crossNumVec2(1,_this.m_localXAxisA);_this.m_mass=0;_this.m_impulse=0;_this.m_motorMass=0;_this.m_motorImpulse=0;_this.m_springMass=0;_this.m_springImpulse=0;_this.m_maxMotorTorque=def.maxMotorTorque;_this.m_motorSpeed=def.motorSpeed;_this.m_enableMotor=def.enableMotor;_this.m_frequencyHz=def.frequencyHz;_this.m_dampingRatio=def.dampingRatio;_this.m_bias=0;_this.m_gamma=0;return _this}WheelJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,enableMotor:this.m_enableMotor,maxMotorTorque:this.m_maxMotorTorque,motorSpeed:this.m_motorSpeed,frequencyHz:this.m_frequencyHz,dampingRatio:this.m_dampingRatio,localAnchorA:this.m_localAnchorA,localAnchorB:this.m_localAnchorB,localAxisA:this.m_localXAxisA}};WheelJoint2._deserialize=function(data,world,restore){data=__assign$1({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);var joint=new WheelJoint2(data);return joint};WheelJoint2.prototype._reset=function(def){if(def.anchorA){this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA))}else if(def.localAnchorA){this.m_localAnchorA.setVec2(def.localAnchorA)}if(def.anchorB){this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB))}else if(def.localAnchorB){this.m_localAnchorB.setVec2(def.localAnchorB)}if(def.localAxisA){this.m_localXAxisA.setVec2(def.localAxisA);this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1,def.localAxisA))}if(def.enableMotor!==void 0){this.m_enableMotor=def.enableMotor}if(Number.isFinite(def.maxMotorTorque)){this.m_maxMotorTorque=def.maxMotorTorque}if(Number.isFinite(def.motorSpeed)){this.m_motorSpeed=def.motorSpeed}if(Number.isFinite(def.frequencyHz)){this.m_frequencyHz=def.frequencyHz}if(Number.isFinite(def.dampingRatio)){this.m_dampingRatio=def.dampingRatio}};WheelJoint2.prototype.getLocalAnchorA=function(){return this.m_localAnchorA};WheelJoint2.prototype.getLocalAnchorB=function(){return this.m_localAnchorB};WheelJoint2.prototype.getLocalAxisA=function(){return this.m_localXAxisA};WheelJoint2.prototype.getJointTranslation=function(){var bA=this.m_bodyA;var bB=this.m_bodyB;var pA2=bA.getWorldPoint(this.m_localAnchorA);var pB2=bB.getWorldPoint(this.m_localAnchorB);var d2=Vec2.sub(pB2,pA2);var axis=bA.getWorldVector(this.m_localXAxisA);var translation2=Vec2.dot(d2,axis);return translation2};WheelJoint2.prototype.getJointSpeed=function(){var wA=this.m_bodyA.m_angularVelocity;var wB=this.m_bodyB.m_angularVelocity;return wB-wA};WheelJoint2.prototype.isMotorEnabled=function(){return this.m_enableMotor};WheelJoint2.prototype.enableMotor=function(flag){if(flag==this.m_enableMotor)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_enableMotor=flag};WheelJoint2.prototype.setMotorSpeed=function(speed){if(speed==this.m_motorSpeed)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_motorSpeed=speed};WheelJoint2.prototype.getMotorSpeed=function(){return this.m_motorSpeed};WheelJoint2.prototype.setMaxMotorTorque=function(torque){if(torque==this.m_maxMotorTorque)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_maxMotorTorque=torque};WheelJoint2.prototype.getMaxMotorTorque=function(){return this.m_maxMotorTorque};WheelJoint2.prototype.getMotorTorque=function(inv_dt){return inv_dt*this.m_motorImpulse};WheelJoint2.prototype.setSpringFrequencyHz=function(hz){this.m_frequencyHz=hz};WheelJoint2.prototype.getSpringFrequencyHz=function(){return this.m_frequencyHz};WheelJoint2.prototype.setSpringDampingRatio=function(ratio){this.m_dampingRatio=ratio};WheelJoint2.prototype.getSpringDampingRatio=function(){return this.m_dampingRatio};WheelJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};WheelJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};WheelJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.combine(this.m_impulse,this.m_ay,this.m_springImpulse,this.m_ax).mul(inv_dt)};WheelJoint2.prototype.getReactionTorque=function(inv_dt){return inv_dt*this.m_motorImpulse};WheelJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter;this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var d2=Vec2.zero();d2.addCombine(1,cB2,1,rB2);d2.subCombine(1,cA2,1,rA2);{this.m_ay=Rot.mulVec2(qA,this.m_localYAxisA);this.m_sAy=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),this.m_ay);this.m_sBy=Vec2.crossVec2Vec2(rB2,this.m_ay);this.m_mass=mA+mB+iA*this.m_sAy*this.m_sAy+iB*this.m_sBy*this.m_sBy;if(this.m_mass>0){this.m_mass=1/this.m_mass}}this.m_springMass=0;this.m_bias=0;this.m_gamma=0;if(this.m_frequencyHz>0){this.m_ax=Rot.mulVec2(qA,this.m_localXAxisA);this.m_sAx=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),this.m_ax);this.m_sBx=Vec2.crossVec2Vec2(rB2,this.m_ax);var invMass=mA+mB+iA*this.m_sAx*this.m_sAx+iB*this.m_sBx*this.m_sBx;if(invMass>0){this.m_springMass=1/invMass;var C=Vec2.dot(d2,this.m_ax);var omega=2*math_PI$1*this.m_frequencyHz;var damp=2*this.m_springMass*this.m_dampingRatio*omega;var k=this.m_springMass*omega*omega;var h=step.dt;this.m_gamma=h*(damp+h*k);if(this.m_gamma>0){this.m_gamma=1/this.m_gamma}this.m_bias=C*h*k*this.m_gamma;this.m_springMass=invMass+this.m_gamma;if(this.m_springMass>0){this.m_springMass=1/this.m_springMass}}}else{this.m_springImpulse=0}if(this.m_enableMotor){this.m_motorMass=iA+iB;if(this.m_motorMass>0){this.m_motorMass=1/this.m_motorMass}}else{this.m_motorMass=0;this.m_motorImpulse=0}if(step.warmStarting){this.m_impulse*=step.dtRatio;this.m_springImpulse*=step.dtRatio;this.m_motorImpulse*=step.dtRatio;var P3=Vec2.combine(this.m_impulse,this.m_ay,this.m_springImpulse,this.m_ax);var LA=this.m_impulse*this.m_sAy+this.m_springImpulse*this.m_sAx+this.m_motorImpulse;var LB=this.m_impulse*this.m_sBy+this.m_springImpulse*this.m_sBx+this.m_motorImpulse;vA2.subMul(this.m_invMassA,P3);wA-=this.m_invIA*LA;vB2.addMul(this.m_invMassB,P3);wB+=this.m_invIB*LB}else{this.m_impulse=0;this.m_springImpulse=0;this.m_motorImpulse=0}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};WheelJoint2.prototype.solveVelocityConstraints=function(step){var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;{var Cdot=Vec2.dot(this.m_ax,vB2)-Vec2.dot(this.m_ax,vA2)+this.m_sBx*wB-this.m_sAx*wA;var impulse=-this.m_springMass*(Cdot+this.m_bias+this.m_gamma*this.m_springImpulse);this.m_springImpulse+=impulse;var P3=Vec2.mulNumVec2(impulse,this.m_ax);var LA=impulse*this.m_sAx;var LB=impulse*this.m_sBx;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}{var Cdot=wB-wA-this.m_motorSpeed;var impulse=-this.m_motorMass*Cdot;var oldImpulse=this.m_motorImpulse;var maxImpulse=step.dt*this.m_maxMotorTorque;this.m_motorImpulse=clamp$1(this.m_motorImpulse+impulse,-maxImpulse,maxImpulse);impulse=this.m_motorImpulse-oldImpulse;wA-=iA*impulse;wB+=iB*impulse}{var Cdot=Vec2.dot(this.m_ay,vB2)-Vec2.dot(this.m_ay,vA2)+this.m_sBy*wB-this.m_sAy*wA;var impulse=-this.m_mass*Cdot;this.m_impulse+=impulse;var P3=Vec2.mulNumVec2(impulse,this.m_ay);var LA=impulse*this.m_sAy;var LB=impulse*this.m_sBy;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};WheelJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var d2=Vec2.zero();d2.addCombine(1,cB2,1,rB2);d2.subCombine(1,cA2,1,rA2);var ay=Rot.mulVec2(qA,this.m_localYAxisA);var sAy=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),ay);var sBy=Vec2.crossVec2Vec2(rB2,ay);var C=Vec2.dot(d2,ay);var k=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_sAy*this.m_sAy+this.m_invIB*this.m_sBy*this.m_sBy;var impulse=k!=0?-C/k:0;var P3=Vec2.mulNumVec2(impulse,ay);var LA=impulse*sAy;var LB=impulse*sBy;cA2.subMul(this.m_invMassA,P3);aA-=this.m_invIA*LA;cB2.addMul(this.m_invMassB,P3);aB+=this.m_invIB*LB;this.m_bodyA.c_position.c.setVec2(cA2);this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c.setVec2(cB2);this.m_bodyB.c_position.a=aB;return math_abs$1(C)<=SettingsInternal.linearSlop};WheelJoint2.TYPE="wheel-joint";return WheelJoint2}(Joint);var _a;var SID=0;var SERIALIZE_REF_TYPES={World:World,Body:Body,Joint:Joint,Fixture:Fixture,Shape:Shape};var DESERIALIZE_BY_REF_TYPE={Vec2:Vec2,Vec3:Vec3,World:World,Body:Body,Joint:Joint,Fixture:Fixture,Shape:Shape};var DESERIALIZE_BY_TYPE_FIELD=(_a={},_a[Body.STATIC]=Body,_a[Body.DYNAMIC]=Body,_a[Body.KINEMATIC]=Body,_a[ChainShape.TYPE]=ChainShape,_a[PolygonShape.TYPE]=PolygonShape,_a[EdgeShape.TYPE]=EdgeShape,_a[CircleShape.TYPE]=CircleShape,_a[DistanceJoint.TYPE]=DistanceJoint,_a[FrictionJoint.TYPE]=FrictionJoint,_a[GearJoint.TYPE]=GearJoint,_a[MotorJoint.TYPE]=MotorJoint,_a[MouseJoint.TYPE]=MouseJoint,_a[PrismaticJoint.TYPE]=PrismaticJoint,_a[PulleyJoint.TYPE]=PulleyJoint,_a[RevoluteJoint.TYPE]=RevoluteJoint,_a[RopeJoint.TYPE]=RopeJoint,_a[WeldJoint.TYPE]=WeldJoint,_a[WheelJoint.TYPE]=WheelJoint,_a);var DEFAULT_OPTIONS={rootClass:World,preSerialize:function(obj){return obj},postSerialize:function(data,obj){return data},preDeserialize:function(data){return data},postDeserialize:function(obj,data){return obj}};var Serializer=function(){function Serializer2(options2){var _this=this;this.toJson=function(root){var preSerialize=_this.options.preSerialize;var postSerialize=_this.options.postSerialize;var json=[];var refQueue=[root];var refMemoById={};function addToRefQueue(value,typeName){value.__sid=value.__sid||++SID;if(!refMemoById[value.__sid]){refQueue.push(value);var index=json.length+refQueue.length;var ref={refIndex:index,refType:typeName};refMemoById[value.__sid]=ref}return refMemoById[value.__sid]}function serializeWithHooks(obj2){obj2=preSerialize(obj2);var data=obj2._serialize();data=postSerialize(data,obj2);return data}function traverse(value,noRefType){if(noRefType===void 0){noRefType=false}if(typeof value!=="object"||value===null){return value}if(typeof value._serialize==="function"){if(!noRefType){for(var typeName in SERIALIZE_REF_TYPES){if(value instanceof SERIALIZE_REF_TYPES[typeName]){return addToRefQueue(value,typeName)}}}value=serializeWithHooks(value)}if(Array.isArray(value)){var newValue=[];for(var key=0;keyradius*radius){return}manifold.type=exports2.ManifoldType.e_circles;copyVec2(manifold.localPoint,circleA.m_p);zeroVec2(manifold.localNormal);manifold.pointCount=1;copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex)};Contact.addType(EdgeShape.TYPE,CircleShape.TYPE,EdgeCircleContact);Contact.addType(ChainShape.TYPE,CircleShape.TYPE,ChainCircleContact);function EdgeCircleContact(manifold,xfA2,fixtureA,indexA,xfB2,fixtureB,indexB){var shapeA=fixtureA.getShape();var shapeB=fixtureB.getShape();CollideEdgeCircle(manifold,shapeA,xfA2,shapeB,xfB2)}function ChainCircleContact(manifold,xfA2,fixtureA,indexA,xfB2,fixtureB,indexB){var chain=fixtureA.getShape();var edge=new EdgeShape;chain.getChildEdge(edge,indexA);var shapeA=edge;var shapeB=fixtureB.getShape();CollideEdgeCircle(manifold,shapeA,xfA2,shapeB,xfB2)}var e=vec2(0,0);var e1=vec2(0,0);var e2=vec2(0,0);var Q=vec2(0,0);var P=vec2(0,0);var n$2=vec2(0,0);var CollideEdgeCircle=function(manifold,edgeA,xfA2,circleB,xfB2){manifold.pointCount=0;retransformVec2(Q,xfB2,xfA2,circleB.m_p);var A=edgeA.m_vertex1;var B=edgeA.m_vertex2;subVec2(e,B,A);var u=dotVec2(e,B)-dotVec2(e,Q);var v3=dotVec2(e,Q)-dotVec2(e,A);var radius=edgeA.m_radius+circleB.m_radius;if(v3<=0){copyVec2(P,A);var dd_1=distSqrVec2(Q,A);if(dd_1>radius*radius){return}if(edgeA.m_hasVertex0){var A1=edgeA.m_vertex0;var B1=A;subVec2(e1,B1,A1);var u1=dotVec2(e1,B1)-dotVec2(e1,Q);if(u1>0){return}}manifold.type=exports2.ManifoldType.e_circles;zeroVec2(manifold.localNormal);copyVec2(manifold.localPoint,P);manifold.pointCount=1;copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex);return}if(u<=0){copyVec2(P,B);var dd_2=distSqrVec2(Q,P);if(dd_2>radius*radius){return}if(edgeA.m_hasVertex3){var B2=edgeA.m_vertex3;var A2=B;subVec2(e2,B2,A2);var v22=dotVec2(e2,Q)-dotVec2(e2,A2);if(v22>0){return}}manifold.type=exports2.ManifoldType.e_circles;zeroVec2(manifold.localNormal);copyVec2(manifold.localPoint,P);manifold.pointCount=1;copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(1,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex);return}var den=lengthSqrVec2(e);combine2Vec2(P,u/den,A,v3/den,B);var dd=distSqrVec2(Q,P);if(dd>radius*radius){return}crossNumVec2(n$2,1,e);if(dotVec2(n$2,Q)-dotVec2(n$2,A)<0){negVec2(n$2)}normalizeVec2(n$2);manifold.type=exports2.ManifoldType.e_faceA;copyVec2(manifold.localNormal,n$2);copyVec2(manifold.localPoint,A);manifold.pointCount=1;copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_face,0,exports2.ContactFeatureType.e_vertex)};var incidentEdge=[new ClipVertex,new ClipVertex];var clipPoints1$1=[new ClipVertex,new ClipVertex];var clipPoints2$1=[new ClipVertex,new ClipVertex];var clipSegmentToLineNormal=vec2(0,0);var v1=vec2(0,0);var n$1=vec2(0,0);var xf$1=transform(0,0,0);var v11=vec2(0,0);var v12=vec2(0,0);var localTangent=vec2(0,0);var localNormal=vec2(0,0);var planePoint=vec2(0,0);var tangent=vec2(0,0);var normal$1=vec2(0,0);var normal1$1=vec2(0,0);Contact.addType(PolygonShape.TYPE,PolygonShape.TYPE,PolygonContact);function PolygonContact(manifold,xfA2,fixtureA,indexA,xfB2,fixtureB,indexB){CollidePolygons(manifold,fixtureA.getShape(),xfA2,fixtureB.getShape(),xfB2)}function findMaxSeparation(poly1,xf1,poly2,xf2,output2){var count1=poly1.m_count;var count2=poly2.m_count;var n1s=poly1.m_normals;var v1s=poly1.m_vertices;var v2s=poly2.m_vertices;detransformTransform(xf$1,xf2,xf1);var bestIndex=0;var maxSeparation2=-Infinity;for(var i=0;imaxSeparation2){maxSeparation2=si;bestIndex=i}}output2.maxSeparation=maxSeparation2;output2.bestIndex=bestIndex}function findIncidentEdge(clipVertex,poly1,xf1,edge12,poly2,xf2){var normals1=poly1.m_normals;var count2=poly2.m_count;var vertices2=poly2.m_vertices;var normals2=poly2.m_normals;rerotVec2(normal1$1,xf2.q,xf1.q,normals1[edge12]);var index=0;var minDot=Infinity;for(var i=0;itotalRadius)return;findMaxSeparation(polyB,xfB2,polyA,xfA2,maxSeparation);var edgeB=maxSeparation.bestIndex;var separationB=maxSeparation.maxSeparation;if(separationB>totalRadius)return;var poly1;var poly2;var xf1;var xf2;var edge12;var flip;var k_tol=.1*SettingsInternal.linearSlop;if(separationB>separationA+k_tol){poly1=polyB;poly2=polyA;xf1=xfB2;xf2=xfA2;edge12=edgeB;manifold.type=exports2.ManifoldType.e_faceB;flip=true}else{poly1=polyA;poly2=polyB;xf1=xfA2;xf2=xfB2;edge12=edgeA;manifold.type=exports2.ManifoldType.e_faceA;flip=false}incidentEdge[0].recycle();incidentEdge[1].recycle();findIncidentEdge(incidentEdge,poly1,xf1,edge12,poly2,xf2);var count1=poly1.m_count;var vertices1=poly1.m_vertices;var iv1=edge12;var iv2=edge12+1radius){return}if(s2>separation){separation=s2;normalIndex=i}}var vertIndex1=normalIndex;var vertIndex2=vertIndex1+1radius*radius){return}manifold.pointCount=1;manifold.type=exports2.ManifoldType.e_faceA;subVec2(manifold.localNormal,cLocal,v13);normalizeVec2(manifold.localNormal);copyVec2(manifold.localPoint,v13);copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex)}else if(u2<=0){if(distSqrVec2(cLocal,v22)>radius*radius){return}manifold.pointCount=1;manifold.type=exports2.ManifoldType.e_faceA;subVec2(manifold.localNormal,cLocal,v22);normalizeVec2(manifold.localNormal);copyVec2(manifold.localPoint,v22);copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex)}else{combine2Vec2(faceCenter,.5,v13,.5,v22);var separation_1=dotVec2(cLocal,normals[vertIndex1])-dotVec2(faceCenter,normals[vertIndex1]);if(separation_1>radius){return}manifold.pointCount=1;manifold.type=exports2.ManifoldType.e_faceA;copyVec2(manifold.localNormal,normals[vertIndex1]);copyVec2(manifold.localPoint,faceCenter);copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex)}};var math_min$1=Math.min;Contact.addType(EdgeShape.TYPE,PolygonShape.TYPE,EdgePolygonContact);Contact.addType(ChainShape.TYPE,PolygonShape.TYPE,ChainPolygonContact);function EdgePolygonContact(manifold,xfA2,fA,indexA,xfB2,fB,indexB){CollideEdgePolygon(manifold,fA.getShape(),xfA2,fB.getShape(),xfB2)}var edge_reuse=new EdgeShape;function ChainPolygonContact(manifold,xfA2,fA,indexA,xfB2,fB,indexB){var chain=fA.getShape();chain.getChildEdge(edge_reuse,indexA);CollideEdgePolygon(manifold,edge_reuse,xfA2,fB.getShape(),xfB2)}var EPAxisType;(function(EPAxisType2){EPAxisType2[EPAxisType2["e_unknown"]=-1]="e_unknown";EPAxisType2[EPAxisType2["e_edgeA"]=1]="e_edgeA";EPAxisType2[EPAxisType2["e_edgeB"]=2]="e_edgeB"})(EPAxisType||(EPAxisType={}));var VertexType;(function(VertexType2){VertexType2[VertexType2["e_isolated"]=0]="e_isolated";VertexType2[VertexType2["e_concave"]=1]="e_concave";VertexType2[VertexType2["e_convex"]=2]="e_convex"})(VertexType||(VertexType={}));var EPAxis=function(){function EPAxis2(){}return EPAxis2}();var TempPolygon=function(){function TempPolygon2(){this.vertices=[];this.normals=[];this.count=0;for(var i=0;i=0;offset0=Vec2.dot(normal0,centroidB)-Vec2.dot(normal0,v0)}if(hasVertex3){subVec2(edge2,v3,v22);normalizeVec2(edge2);setVec2(normal2,edge2.y,-edge2.x);convex2=Vec2.crossVec2Vec2(edge1,edge2)>0;offset2=Vec2.dot(normal2,centroidB)-Vec2.dot(normal2,v22)}var front;zeroVec2(normal);zeroVec2(lowerLimit);zeroVec2(upperLimit);if(hasVertex0&&hasVertex3){if(convex1&&convex2){front=offset0>=0||offset1>=0||offset2>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal0);copyVec2(upperLimit,normal2)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal1);scaleVec2(upperLimit,-1,normal1)}}else if(convex1){front=offset0>=0||offset1>=0&&offset2>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal0);copyVec2(upperLimit,normal1)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal2);scaleVec2(upperLimit,-1,normal1)}}else if(convex2){front=offset2>=0||offset0>=0&&offset1>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal1);copyVec2(upperLimit,normal2)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal1);scaleVec2(upperLimit,-1,normal0)}}else{front=offset0>=0&&offset1>=0&&offset2>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal1);copyVec2(upperLimit,normal1)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal2);scaleVec2(upperLimit,-1,normal0)}}}else if(hasVertex0){if(convex1){front=offset0>=0||offset1>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal0);scaleVec2(upperLimit,-1,normal1)}else{scaleVec2(normal,-1,normal1);copyVec2(lowerLimit,normal1);scaleVec2(upperLimit,-1,normal1)}}else{front=offset0>=0&&offset1>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal1);scaleVec2(upperLimit,-1,normal1)}else{scaleVec2(normal,-1,normal1);copyVec2(lowerLimit,normal1);scaleVec2(upperLimit,-1,normal0)}}}else if(hasVertex3){if(convex2){front=offset1>=0||offset2>=0;if(front){copyVec2(normal,normal1);scaleVec2(lowerLimit,-1,normal1);copyVec2(upperLimit,normal2)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal1);copyVec2(upperLimit,normal1)}}else{front=offset1>=0&&offset2>=0;if(front){copyVec2(normal,normal1);scaleVec2(lowerLimit,-1,normal1);copyVec2(upperLimit,normal1)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal2);copyVec2(upperLimit,normal1)}}}else{front=offset1>=0;if(front){copyVec2(normal,normal1);scaleVec2(lowerLimit,-1,normal1);scaleVec2(upperLimit,-1,normal1)}else{scaleVec2(normal,-1,normal1);copyVec2(lowerLimit,normal1);copyVec2(upperLimit,normal1)}}polygonBA.count=polygonB.m_count;for(var i=0;iradius){return}{polygonAxis.type=EPAxisType.e_unknown;polygonAxis.index=-1;polygonAxis.separation=-Infinity;setVec2(perp,-normal.y,normal.x);for(var i=0;iradius){polygonAxis.type=EPAxisType.e_edgeB;polygonAxis.index=i;polygonAxis.separation=s2;break}if(dotVec2(n,perp)>=0){if(dotVec2(n,normal)-dotVec2(upperLimit,normal)<-SettingsInternal.angularSlop){continue}}else{if(dotVec2(n,normal)-dotVec2(lowerLimit,normal)<-SettingsInternal.angularSlop){continue}}if(s2>polygonAxis.separation){polygonAxis.type=EPAxisType.e_edgeB;polygonAxis.index=i;polygonAxis.separation=s2}}}if(polygonAxis.type!=EPAxisType.e_unknown&&polygonAxis.separation>radius){return}var k_relativeTol=.98;var k_absoluteTol=.001;var primaryAxis;if(polygonAxis.type==EPAxisType.e_unknown){primaryAxis=edgeAxis}else if(polygonAxis.separation>k_relativeTol*edgeAxis.separation+k_absoluteTol){primaryAxis=polygonAxis}else{primaryAxis=edgeAxis}ie[0].recycle();ie[1].recycle();if(primaryAxis.type==EPAxisType.e_edgeA){manifold.type=exports2.ManifoldType.e_faceA;var bestIndex=0;var bestValue=dotVec2(normal,polygonBA.normals[0]);for(var i=1;i= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from) {\r\n for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)\r\n to[j] = from[i];\r\n return to;\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","/** @internal */\nexport const options = function(input: T, defaults: object): T {\n if (input === null || typeof input === \"undefined\") {\n // tslint:disable-next-line:no-object-literal-type-assertion\n input = {} as T;\n }\n\n const output = {...input};\n\n // tslint:disable-next-line:no-for-in\n for (const key in defaults) {\n if (defaults.hasOwnProperty(key) && typeof input[key] === \"undefined\") {\n output[key] = defaults[key];\n }\n }\n\n if (typeof Object.getOwnPropertySymbols === \"function\") {\n const symbols = Object.getOwnPropertySymbols(defaults);\n for (let i = 0; i < symbols.length; i++) {\n const symbol = symbols[i];\n if (defaults.propertyIsEnumerable(symbol) && typeof input[symbol] === \"undefined\") {\n output[symbol] = defaults[symbol];\n }\n }\n }\n\n return output;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_random = Math.random;\n\n\nexport const EPSILON = 1e-9;\n\n/** @internal @deprecated */\nexport const isFinite = Number.isFinite;\n\n/**\n * @deprecated\n * Next Largest Power of 2 Given a binary integer value x, the next largest\n * power of 2 can be computed by a SWAR algorithm that recursively \"folds\" the\n * upper bits into the lower bits. This process yields a bit vector with the\n * same most significant 1 as x, but all 1's below it. Adding 1 to that value\n * yields the next largest power of 2. For a 32-bit value:\n */\nexport function nextPowerOfTwo(x: number): number {\n x |= (x >> 1);\n x |= (x >> 2);\n x |= (x >> 4);\n x |= (x >> 8);\n x |= (x >> 16);\n return x + 1;\n}\n\n/** @deprecated */\nexport function isPowerOfTwo(x: number): boolean {\n return x > 0 && (x & (x - 1)) === 0;\n}\n\n/** @deprecated */\nexport function mod(num: number, min?: number, max?: number): number {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n if (max > min) {\n num = (num - min) % (max - min);\n return num + (num < 0 ? max : min);\n } else {\n num = (num - max) % (min - max);\n return num + (num <= 0 ? min : max);\n }\n}\n\n/**\n * @deprecated\n * Returns a min if num is less than min, and max if more than max, otherwise returns num.\n */\nexport function clamp(num: number, min: number, max: number): number {\n if (num < min) {\n return min;\n } else if (num > max) {\n return max;\n } else {\n return num;\n }\n}\n\n/**\n * @deprecated\n * Returns a random number between min and max when two arguments are provided.\n * If one arg is provided between 0 to max.\n * If one arg is passed between 0 to 1.\n */\nexport function random(min?: number, max?: number): number {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n return min === max ? min : math_random() * (max - min) + min;\n}\n\n/** @ignore */\nexport const math = Object.create(Math);\nmath.EPSILON = EPSILON;\nmath.isFinite = isFinite;\nmath.nextPowerOfTwo = nextPowerOfTwo;\nmath.isPowerOfTwo = isPowerOfTwo;\nmath.mod = mod;\nmath.clamp = clamp;\nmath.random = random;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { clamp, EPSILON } from \"./Math\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/** 2D vector */\nexport interface Vec2Value {\n x: number;\n y: number;\n}\n\ndeclare module \"./Vec2\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(x: number, y: number): Vec2;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(obj: Vec2Value): Vec2;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(): Vec2;\n}\n\n/** 2D vector */\n// @ts-expect-error\nexport class Vec2 {\n x: number;\n y: number;\n\n constructor(x: number, y: number);\n constructor(obj: Vec2Value);\n constructor();\n // tslint:disable-next-line:typedef\n constructor(x?, y?) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Vec2)) {\n return new Vec2(x, y);\n }\n if (typeof x === \"undefined\") {\n this.x = 0;\n this.y = 0;\n } else if (typeof x === \"object\") {\n this.x = x.x;\n this.y = x.y;\n } else {\n this.x = x;\n this.y = y;\n }\n if (_ASSERT) Vec2.assert(this);\n }\n\n /** @internal */\n _serialize(): object {\n return {\n x: this.x,\n y: this.y\n };\n }\n\n /** @internal */\n static _deserialize(data: any): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = data.x;\n obj.y = data.y;\n return obj;\n }\n\n static zero(): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = 0;\n obj.y = 0;\n return obj;\n }\n\n /** @hidden */\n static neo(x: number, y: number): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = x;\n obj.y = y;\n return obj;\n }\n\n static clone(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(v.x, v.y);\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n /**\n * Does this vector contain finite coordinates?\n */\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.x) && Number.isFinite(obj.y);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Vec2.isValid(o), \"Invalid Vec2!\", o);\n }\n\n clone(): Vec2 {\n return Vec2.clone(this);\n }\n\n /**\n * Set this vector to all zeros.\n *\n * @returns this\n */\n setZero(): Vec2 {\n this.x = 0.0;\n this.y = 0.0;\n return this;\n }\n\n set(x: number, y: number): Vec2;\n set(value: Vec2Value): Vec2;\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n // tslint:disable-next-line:typedef\n set(x, y?) {\n if (typeof x === \"object\") {\n if (_ASSERT) Vec2.assert(x);\n this.x = x.x;\n this.y = x.y;\n } else {\n if (_ASSERT) console.assert(Number.isFinite(x));\n if (_ASSERT) console.assert(Number.isFinite(y));\n this.x = x;\n this.y = y;\n }\n return this;\n }\n\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n setNum(x: number, y: number) {\n if (_ASSERT) console.assert(Number.isFinite(x));\n if (_ASSERT) console.assert(Number.isFinite(y));\n this.x = x;\n this.y = y;\n\n return this;\n }\n\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n setVec2(value: Vec2Value) {\n if (_ASSERT) Vec2.assert(value);\n this.x = value.x;\n this.y = value.y;\n\n return this;\n }\n\n /** @internal @deprecated Use setCombine or setMul */\n wSet(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.setCombine(a, v, b, w);\n } else {\n return this.setMul(a, v);\n }\n }\n\n /**\n * Set linear combination of v and w: `a * v + b * w`\n */\n setCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x = x;\n this.y = y;\n return this;\n }\n\n setMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x = x;\n this.y = y;\n return this;\n }\n\n /**\n * Add a vector to this vector.\n *\n * @returns this\n */\n add(w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(w);\n this.x += w.x;\n this.y += w.y;\n return this;\n }\n\n /** @internal @deprecated Use addCombine or addMul */\n wAdd(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.addCombine(a, v, b, w);\n } else {\n return this.addMul(a, v);\n }\n }\n\n /**\n * Add linear combination of v and w: `a * v + b * w`\n */\n addCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x += x;\n this.y += y;\n return this;\n }\n\n addMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x += x;\n this.y += y;\n return this;\n }\n\n /**\n * @deprecated Use subCombine or subMul\n */\n wSub(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.subCombine(a, v, b, w);\n } else {\n return this.subMul(a, v);\n }}\n\n /**\n * Subtract linear combination of v and w: `a * v + b * w`\n */\n subCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x -= x;\n this.y -= y;\n return this;\n }\n\n subMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x -= x;\n this.y -= y;\n return this;\n }\n\n /**\n * Subtract a vector from this vector\n *\n * @returns this\n */\n sub(w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(w);\n this.x -= w.x;\n this.y -= w.y;\n return this;\n }\n\n /**\n * Multiply this vector by a scalar.\n *\n * @returns this\n */\n mul(m: number): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(m));\n this.x *= m;\n this.y *= m;\n return this;\n }\n\n /**\n * Get the length of this vector (the norm).\n *\n * For performance, use this instead of lengthSquared (if possible).\n */\n length(): number {\n return Vec2.lengthOf(this);\n }\n\n /**\n * Get the length squared.\n */\n lengthSquared(): number {\n return Vec2.lengthSquared(this);\n }\n\n /**\n * Convert this vector into a unit vector.\n *\n * @returns old length\n */\n normalize(): number {\n const length = this.length();\n if (length < EPSILON) {\n return 0.0;\n }\n const invLength = 1.0 / length;\n this.x *= invLength;\n this.y *= invLength;\n return length;\n }\n\n /**\n * Returns a new unit vector from the provided vector.\n *\n * @returns new unit vector\n */\n static normalize(v: Vec2Value): Vec2 {\n const length = Vec2.lengthOf(v);\n if (length < EPSILON) {\n return Vec2.zero();\n }\n const invLength = 1.0 / length;\n return Vec2.neo(v.x * invLength, v.y * invLength);\n }\n\n /**\n * Get the length of this vector (the norm).\n *\n * For performance, use this instead of lengthSquared (if possible).\n */\n static lengthOf(v: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n return math_sqrt(v.x * v.x + v.y * v.y);\n }\n\n /**\n * Get the length squared.\n */\n static lengthSquared(v: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n return v.x * v.x + v.y * v.y;\n }\n\n static distance(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n const dx = v.x - w.x;\n const dy = v.y - w.y;\n return math_sqrt(dx * dx + dy * dy);\n }\n\n static distanceSquared(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n const dx = v.x - w.x;\n const dy = v.y - w.y;\n return dx * dx + dy * dy;\n }\n\n static areEqual(v: Vec2Value, w: Vec2Value): boolean {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v === w || typeof w === \"object\" && w !== null && v.x === w.x && v.y === w.y;\n }\n\n /**\n * Get the skew vector such that dot(skew_vec, other) == cross(vec, other)\n */\n static skew(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(-v.y, v.x);\n }\n\n /** Dot product on two vectors */\n static dot(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.x + v.y * w.y;\n }\n\n /** Cross product between two vectors */\n static cross(v: Vec2Value, w: Vec2Value): number;\n /** Cross product between a vector and a scalar */\n static cross(v: Vec2Value, w: number): Vec2;\n /** Cross product between a scalar and a vector */\n static cross(v: number, w: Vec2Value): Vec2;\n static cross(v: any, w: any): any {\n if (typeof w === \"number\") {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y, -w * v.x);\n\n } else if (typeof v === \"number\") {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y, v * w.x);\n\n } else {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.y - v.y * w.x;\n }\n }\n\n /** Cross product on two vectors */\n static crossVec2Vec2(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.y - v.y * w.x;\n }\n\n /** Cross product on a vector and a scalar */\n static crossVec2Num(v: Vec2Value, w: number): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y, -w * v.x);\n }\n\n /** Cross product on a vector and a scalar */\n static crossNumVec2(v: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y, v * w.x);\n }\n\n /** Returns `a + (v x w)` */\n static addCross(a: Vec2Value, v: Vec2Value, w: number): Vec2;\n /** Returns `a + (v x w)` */\n static addCross(a: Vec2Value, v: number, w: Vec2Value): Vec2;\n static addCross(a: Vec2Value, v: any, w: any): Vec2 {\n if (typeof w === \"number\") {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y + a.x, -w * v.x + a.y);\n\n } else if (typeof v === \"number\") {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y + a.x, v * w.x + a.y);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n /**\n * Returns `a + (v x w)`\n */\n static addCrossVec2Num(a: Vec2Value, v: Vec2Value, w: number): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y + a.x, -w * v.x + a.y);\n }\n\n /**\n * Returns `a + (v x w)`\n */\n static addCrossNumVec2(a: Vec2Value, v: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y + a.x, v * w.x + a.y);\n }\n\n static add(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(v.x + w.x, v.y + w.y);\n }\n\n /** @hidden @deprecated */\n static wAdd(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return Vec2.combine(a, v, b, w);\n } else {\n return Vec2.mulNumVec2(a, v);\n }\n }\n\n static combine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n return Vec2.zero().setCombine(a, v, b, w);\n }\n\n static sub(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(v.x - w.x, v.y - w.y);\n }\n\n static mul(a: Vec2Value, b: number): Vec2;\n static mul(a: number, b: Vec2Value): Vec2;\n static mul(a: any, b: any): Vec2 {\n if (typeof a === \"object\") {\n if (_ASSERT) Vec2.assert(a);\n if (_ASSERT) console.assert(Number.isFinite(b));\n return Vec2.neo(a.x * b, a.y * b);\n\n } else if (typeof b === \"object\") {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(b);\n return Vec2.neo(a * b.x, a * b.y);\n }\n }\n\n static mulVec2Num(a: Vec2Value, b: number): Vec2 {\n if (_ASSERT) Vec2.assert(a);\n if (_ASSERT) console.assert(Number.isFinite(b));\n return Vec2.neo(a.x * b, a.y * b);\n }\n\n static mulNumVec2(a: number, b: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(b);\n return Vec2.neo(a * b.x, a * b.y);\n }\n\n neg(): Vec2 {\n this.x = -this.x;\n this.y = -this.y;\n return this;\n }\n\n static neg(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(-v.x, -v.y);\n }\n\n static abs(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(math_abs(v.x), math_abs(v.y));\n }\n\n static mid(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo((v.x + w.x) * 0.5, (v.y + w.y) * 0.5);\n }\n\n static upper(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(math_max(v.x, w.x), math_max(v.y, w.y));\n }\n\n static lower(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(math_min(v.x, w.x), math_min(v.y, w.y));\n }\n\n clamp(max: number): Vec2 {\n const lengthSqr = this.x * this.x + this.y * this.y;\n if (lengthSqr > max * max) {\n const scale = max / math_sqrt(lengthSqr);\n this.x *= scale;\n this.y *= scale;\n }\n return this;\n }\n\n static clamp(v: Vec2Value, max: number): Vec2 {\n const r = Vec2.neo(v.x, v.y);\n r.clamp(max);\n return r;\n }\n\n /** @hidden */\n static clampVec2(v: Vec2Value, min?: Vec2Value, max?: Vec2Value): Vec2Value {\n return {\n x: clamp(v.x, min?.x, max?.x),\n y: clamp(v.y, min?.y, max?.y)\n };\n }\n\n /** @hidden @deprecated */\n static scaleFn(x: number, y: number) {\n // todo: this was used in examples, remove in the future\n return function(v: Vec2Value): Vec2 {\n return Vec2.neo(v.x * x, v.y * y);\n };\n }\n\n /** @hidden @deprecated */\n static translateFn(x: number, y: number) {\n // todo: this was used in examples, remove in the future\n return function(v: Vec2Value): Vec2 {\n return Vec2.neo(v.x + x, v.y + y);\n };\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { EPSILON } from \"../common/Math\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n/**\n * Ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n */\nexport interface RayCastInput {\n p1: Vec2Value;\n p2: Vec2Value;\n maxFraction: number;\n}\n\nexport type RayCastCallback = (subInput: RayCastInput, id: number) => number;\n\n/**\n * Ray-cast output data. The ray hits at `p1 + fraction * (p2 - p1)`,\n * where `p1` and `p2` come from RayCastInput.\n */\nexport interface RayCastOutput {\n normal: Vec2;\n fraction: number;\n}\n\n/** Axis-aligned bounding box */\nexport interface AABBValue {\n lowerBound: Vec2Value;\n upperBound: Vec2Value;\n}\n\ndeclare module \"./AABB\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function AABB(lower?: Vec2Value, upper?: Vec2Value): AABB;\n}\n\n/** Axis-aligned bounding box */\n// @ts-expect-error\nexport class AABB {\n lowerBound: Vec2;\n upperBound: Vec2;\n\n constructor(lower?: Vec2Value, upper?: Vec2Value) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof AABB)) {\n return new AABB(lower, upper);\n }\n\n this.lowerBound = Vec2.zero();\n this.upperBound = Vec2.zero();\n\n if (typeof lower === \"object\") {\n this.lowerBound.setVec2(lower);\n }\n if (typeof upper === \"object\") {\n this.upperBound.setVec2(upper);\n } else if (typeof lower === \"object\") {\n this.upperBound.setVec2(lower);\n }\n }\n\n /**\n * Verify that the bounds are sorted.\n */\n isValid(): boolean {\n return AABB.isValid(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.lowerBound) && Vec2.isValid(obj.upperBound) && Vec2.sub(obj.upperBound, obj.lowerBound).lengthSquared() >= 0;\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!AABB.isValid(o), \"Invalid AABB!\", o);\n }\n\n /**\n * Get the center of the AABB.\n */\n getCenter(): Vec2 {\n return Vec2.neo((this.lowerBound.x + this.upperBound.x) * 0.5, (this.lowerBound.y + this.upperBound.y) * 0.5);\n }\n\n /**\n * Get the extents of the AABB (half-widths).\n */\n getExtents(): Vec2 {\n return Vec2.neo((this.upperBound.x - this.lowerBound.x) * 0.5, (this.upperBound.y - this.lowerBound.y) * 0.5);\n }\n\n /**\n * Get the perimeter length.\n */\n getPerimeter(): number {\n return 2.0 * (this.upperBound.x - this.lowerBound.x + this.upperBound.y - this.lowerBound.y);\n }\n\n /**\n * Combine one or two AABB into this one.\n */\n combine(a: AABBValue, b?: AABBValue): void {\n b = b || this;\n\n const lowerA = a.lowerBound;\n const upperA = a.upperBound;\n const lowerB = b.lowerBound;\n const upperB = b.upperBound;\n\n const lowerX = math_min(lowerA.x, lowerB.x);\n const lowerY = math_min(lowerA.y, lowerB.y);\n const upperX = math_max(upperB.x, upperA.x);\n const upperY = math_max(upperB.y, upperA.y);\n\n this.lowerBound.setNum(lowerX, lowerY);\n this.upperBound.setNum(upperX, upperY);\n }\n\n combinePoints(a: Vec2Value, b: Vec2Value): void {\n this.lowerBound.setNum(math_min(a.x, b.x), math_min(a.y, b.y));\n this.upperBound.setNum(math_max(a.x, b.x), math_max(a.y, b.y));\n }\n\n set(aabb: AABBValue): void {\n this.lowerBound.setNum(aabb.lowerBound.x, aabb.lowerBound.y);\n this.upperBound.setNum(aabb.upperBound.x, aabb.upperBound.y);\n }\n\n contains(aabb: AABBValue): boolean {\n let result = true;\n result = result && this.lowerBound.x <= aabb.lowerBound.x;\n result = result && this.lowerBound.y <= aabb.lowerBound.y;\n result = result && aabb.upperBound.x <= this.upperBound.x;\n result = result && aabb.upperBound.y <= this.upperBound.y;\n return result;\n }\n\n extend(value: number): AABB {\n AABB.extend(this, value);\n return this;\n }\n\n static extend(out: AABBValue, value: number): AABBValue {\n out.lowerBound.x -= value;\n out.lowerBound.y -= value;\n out.upperBound.x += value;\n out.upperBound.y += value;\n return out;\n }\n\n static testOverlap(a: AABBValue, b: AABBValue): boolean {\n const d1x = b.lowerBound.x - a.upperBound.x;\n const d2x = a.lowerBound.x - b.upperBound.x;\n\n const d1y = b.lowerBound.y - a.upperBound.y;\n const d2y = a.lowerBound.y - b.upperBound.y;\n\n if (d1x > 0 || d1y > 0 || d2x > 0 || d2y > 0) {\n return false;\n }\n return true;\n }\n\n static areEqual(a: AABBValue, b: AABBValue): boolean {\n return Vec2.areEqual(a.lowerBound, b.lowerBound) && Vec2.areEqual(a.upperBound, b.upperBound);\n }\n\n static diff(a: AABBValue, b: AABBValue): number {\n const wD = math_max(0, math_min(a.upperBound.x, b.upperBound.x) - math_max(b.lowerBound.x, a.lowerBound.x));\n const hD = math_max(0, math_min(a.upperBound.y, b.upperBound.y) - math_max(b.lowerBound.y, a.lowerBound.y));\n\n const wA = a.upperBound.x - a.lowerBound.x;\n const hA = a.upperBound.y - a.lowerBound.y;\n\n const wB = b.upperBound.x - b.lowerBound.x;\n const hB = b.upperBound.y - b.lowerBound.y;\n\n return wA * hA + wB * hB - wD * hD;\n }\n\n rayCast(output: RayCastOutput, input: RayCastInput): boolean {\n // From Real-time Collision Detection, p179.\n\n let tmin = -Infinity;\n let tmax = Infinity;\n\n const p = input.p1;\n const d = Vec2.sub(input.p2, input.p1);\n const absD = Vec2.abs(d);\n\n const normal = Vec2.zero();\n\n for (let f: \"x\" | \"y\" = \"x\"; f !== null; f = (f === \"x\" ? \"y\" : null)) {\n if (absD.x < EPSILON) {\n // Parallel.\n if (p[f] < this.lowerBound[f] || this.upperBound[f] < p[f]) {\n return false;\n }\n } else {\n const inv_d = 1.0 / d[f];\n let t1 = (this.lowerBound[f] - p[f]) * inv_d;\n let t2 = (this.upperBound[f] - p[f]) * inv_d;\n\n // Sign of the normal vector.\n let s = -1.0;\n\n if (t1 > t2) {\n const temp = t1;\n t1 = t2;\n t2 = temp;\n s = 1.0;\n }\n\n // Push the min up\n if (t1 > tmin) {\n normal.setZero();\n normal[f] = s;\n tmin = t1;\n }\n\n // Pull the max down\n tmax = math_min(tmax, t2);\n\n if (tmin > tmax) {\n return false;\n }\n }\n }\n\n // Does the ray start inside the box?\n // Does the ray intersect beyond the max fraction?\n if (tmin < 0.0 || input.maxFraction < tmin) {\n return false;\n }\n\n // Intersection.\n output.fraction = tmin;\n output.normal = normal;\n return true;\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static combinePoints(out: AABBValue, a: Vec2Value, b: Vec2Value): AABBValue {\n out.lowerBound.x = math_min(a.x, b.x);\n out.lowerBound.y = math_min(a.y, b.y);\n out.upperBound.x = math_max(a.x, b.x);\n out.upperBound.y = math_max(a.y, b.y);\n return out;\n }\n\n static combinedPerimeter(a: AABBValue, b: AABBValue) {\n const lx = math_min(a.lowerBound.x, b.lowerBound.x);\n const ly = math_min(a.lowerBound.y, b.lowerBound.y);\n const ux = math_max(a.upperBound.x, b.upperBound.x);\n const uy = math_max(a.upperBound.y, b.upperBound.y);\n return 2.0 * (ux - lx + uy - ly); \n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Tuning constants based on meters-kilograms-seconds (MKS) units.\n * \n * Some tolerances are absolute and some are relative. Absolute tolerances use MKS units.\n */\nexport class Settings {\n /**\n * You can use this to change the length scale used by your game.\n * \n * For example for inches you could use 39.4.\n */\n static lengthUnitsPerMeter = 1.0;\n \n // Collision\n /**\n * The maximum number of contact points between two convex shapes. Do not change\n * this value.\n */\n static maxManifoldPoints: number = 2;\n\n /**\n * The maximum number of vertices on a convex polygon. You cannot increase this\n * too much because BlockAllocator has a maximum object size.\n */\n static maxPolygonVertices: number = 12;\n\n /**\n * This is used to fatten AABBs in the dynamic tree. This allows proxies to move\n * by a small amount without triggering a tree adjustment. This is in meters.\n */\n static aabbExtension: number = 0.1;\n\n /**\n * This is used to fatten AABBs in the dynamic tree. This is used to predict the\n * future position based on the current displacement. This is a dimensionless\n * multiplier.\n */\n static aabbMultiplier: number = 2.0;\n\n /**\n * A small length used as a collision and constraint tolerance. Usually it is\n * chosen to be numerically significant, but visually insignificant.\n */\n static linearSlop: number = 0.005;\n\n /**\n * A small angle used as a collision and constraint tolerance. Usually it is\n * chosen to be numerically significant, but visually insignificant.\n */\n static angularSlop: number = (2.0 / 180.0 * math_PI);\n\n /**\n * The radius of the polygon/edge shape skin. This should not be modified.\n * Making this smaller means polygons will have an insufficient buffer for\n * continuous collision. Making it larger may create artifacts for vertex\n * collision.\n */\n static get polygonRadius(): number { return 2.0 * Settings.linearSlop; }\n\n /**\n * Maximum number of sub-steps per contact in continuous physics simulation.\n */\n static maxSubSteps: number = 8;\n\n // Dynamics\n\n /**\n * Maximum number of contacts to be handled to solve a TOI impact.\n */\n static maxTOIContacts: number = 32;\n\n /**\n * Maximum iterations to solve a TOI.\n */\n static maxTOIIterations: number = 20;\n\n /**\n * Maximum iterations to find Distance.\n */\n static maxDistanceIterations: number = 20;\n\n /**\n * A velocity threshold for elastic collisions. Any collision with a relative\n * linear velocity below this threshold will be treated as inelastic.\n */\n static velocityThreshold: number = 1.0;\n\n /**\n * The maximum linear position correction used when solving constraints. This\n * helps to prevent overshoot.\n */\n static maxLinearCorrection: number = 0.2;\n\n /**\n * The maximum angular position correction used when solving constraints. This\n * helps to prevent overshoot.\n */\n static maxAngularCorrection: number = (8.0 / 180.0 * math_PI);\n\n /**\n * The maximum linear velocity of a body. This limit is very large and is used\n * to prevent numerical problems. You shouldn't need to adjust Settings.\n */\n static maxTranslation: number = 2.0;\n\n /**\n * The maximum angular velocity of a body. This limit is very large and is used\n * to prevent numerical problems. You shouldn't need to adjust Settings.\n */\n static maxRotation: number = (0.5 * math_PI);\n\n /**\n * This scale factor controls how fast overlap is resolved. Ideally this would\n * be 1 so that overlap is removed in one time step. However using values close\n * to 1 often lead to overshoot.\n */\n static baumgarte: number = 0.2;\n static toiBaugarte: number = 0.75;\n\n // Sleep\n\n /**\n * The time that a body must be still before it will go to sleep.\n */\n static timeToSleep: number = 0.5;\n\n /**\n * A body cannot sleep if its linear velocity is above this tolerance.\n */\n static linearSleepTolerance: number = 0.01;\n\n /**\n * A body cannot sleep if its angular velocity is above this tolerance.\n */\n static angularSleepTolerance: number = (2.0 / 180.0 * math_PI);\n}\n\n/** @internal */\nexport class SettingsInternal {\n static get maxManifoldPoints() {\n return Settings.maxManifoldPoints;\n }\n static get maxPolygonVertices() {\n return Settings.maxPolygonVertices;\n }\n static get aabbExtension() {\n return Settings.aabbExtension * Settings.lengthUnitsPerMeter;\n }\n static get aabbMultiplier() {\n return Settings.aabbMultiplier;\n }\n static get linearSlop() {\n return Settings.linearSlop * Settings.lengthUnitsPerMeter;\n }\n static get linearSlopSquared() {\n return Settings.linearSlop * Settings.lengthUnitsPerMeter * Settings.linearSlop * Settings.lengthUnitsPerMeter;\n }\n static get angularSlop() {\n return Settings.angularSlop;\n }\n static get polygonRadius() {\n return 2.0 * Settings.linearSlop;\n }\n static get maxSubSteps() {\n return Settings.maxSubSteps;\n }\n static get maxTOIContacts() {\n return Settings.maxTOIContacts;\n }\n static get maxTOIIterations() {\n return Settings.maxTOIIterations;\n }\n static get maxDistanceIterations() {\n return Settings.maxDistanceIterations;\n }\n static get velocityThreshold() {\n return Settings.velocityThreshold * Settings.lengthUnitsPerMeter;\n }\n static get maxLinearCorrection() {\n return Settings.maxLinearCorrection * Settings.lengthUnitsPerMeter;\n }\n static get maxAngularCorrection() {\n return Settings.maxAngularCorrection;\n }\n static get maxTranslation() {\n return Settings.maxTranslation * Settings.lengthUnitsPerMeter;\n }\n static get maxTranslationSquared() {\n return Settings.maxTranslation * Settings.lengthUnitsPerMeter * Settings.maxTranslation * Settings.lengthUnitsPerMeter;\n }\n static get maxRotation() {\n return Settings.maxRotation;\n }\n static get maxRotationSquared() {\n return Settings.maxRotation * Settings.maxRotation;\n }\n static get baumgarte() {\n return Settings.baumgarte;\n }\n static get toiBaugarte() {\n return Settings.toiBaugarte;\n }\n static get timeToSleep() {\n return Settings.timeToSleep;\n }\n static get linearSleepTolerance() {\n return Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter;\n }\n static get linearSleepToleranceSqr() {\n return Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter * Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter;\n }\n static get angularSleepTolerance() {\n return Settings.angularSleepTolerance;\n }\n static get angularSleepToleranceSqr() {\n return Settings.angularSleepTolerance * Settings.angularSleepTolerance;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */\nexport interface PoolOptions {\n max?: number,\n create?: () => T,\n /** Called when an object is being re-allocated. */\n allocate?: (item: T) => void,\n /** Called when an object is returned to pool. */\n release?: (item: T) => void,\n /** Called when an object is returned to the pool but will be disposed from pool. */\n dispose?: (item: T) => T,\n}\n\n/** @internal */\nexport class Pool {\n _list: T[] = [];\n _max: number = Infinity;\n\n _createFn: () => T;\n _hasCreateFn: boolean = false;\n _createCount: number = 0;\n\n _allocateFn: (item: T) => void;\n _hasAllocateFn: boolean = false;\n _allocateCount: number = 0;\n\n _releaseFn: (item: T) => void;\n _hasReleaseFn: boolean = false;\n _releaseCount: number = 0;\n\n _disposeFn: (item: T) => T;\n _hasDisposeFn: boolean = false;\n _disposeCount: number = 0;\n\n constructor(opts: PoolOptions) {\n this._list = [];\n this._max = opts.max || this._max;\n\n this._createFn = opts.create;\n this._hasCreateFn = typeof this._createFn === \"function\";\n this._allocateFn = opts.allocate;\n this._hasAllocateFn = typeof this._allocateFn === \"function\";\n this._releaseFn = opts.release;\n this._hasReleaseFn = typeof this._releaseFn === \"function\";\n this._disposeFn = opts.dispose;\n this._hasDisposeFn = typeof this._disposeFn === \"function\";\n }\n\n max(n?: number): number | Pool {\n if (typeof n === \"number\") {\n this._max = n;\n return this;\n }\n return this._max;\n }\n\n size(): number {\n return this._list.length;\n }\n\n allocate(): T {\n let item: T;\n if (this._list.length > 0) {\n item = this._list.shift();\n } else {\n this._createCount++;\n if (this._hasCreateFn) {\n item = this._createFn();\n } else {\n // tslint:disable-next-line:no-object-literal-type-assertion\n item = {} as T;\n }\n }\n this._allocateCount++;\n if (this._hasAllocateFn) {\n this._allocateFn(item);\n }\n return item;\n }\n\n release(item: T): void {\n if (this._list.length < this._max) {\n this._releaseCount++;\n if (this._hasReleaseFn) {\n this._releaseFn(item);\n }\n this._list.push(item);\n } else {\n this._disposeCount++;\n if (this._hasDisposeFn) {\n item = this._disposeFn(item);\n }\n }\n }\n\n toString(): string {\n return \" +\" + this._createCount + \" >\" + this._allocateCount + \" <\" + this._releaseCount + \" -\"\n + this._disposeCount + \" =\" + this._list.length + \"/\" + this._max;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { Pool } from \"../util/Pool\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { AABB, AABBValue, RayCastCallback, RayCastInput } from \"./AABB\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n\n\nexport type DynamicTreeQueryCallback = (nodeId: number) => boolean;\n\n/**\n * A node in the dynamic tree. The client does not interact with this directly.\n */\nexport class TreeNode {\n id: number;\n /** Enlarged AABB */\n aabb: AABB = new AABB();\n userData: T = null;\n parent: TreeNode = null;\n child1: TreeNode = null;\n child2: TreeNode = null;\n /** 0: leaf, -1: free node */\n height: number = -1;\n\n constructor(id?: number) {\n this.id = id;\n }\n\n /** @internal */\n toString(): string {\n return this.id + \": \" + this.userData;\n }\n\n isLeaf(): boolean {\n return this.child1 == null;\n }\n}\n\n/** @internal */ const poolTreeNode = new Pool>({\n create(): TreeNode {\n return new TreeNode();\n },\n release(node: TreeNode) {\n node.userData = null;\n node.parent = null;\n node.child1 = null;\n node.child2 = null;\n node.height = -1;\n node.id = undefined;\n }\n});\n\n/**\n * A dynamic AABB tree broad-phase, inspired by Nathanael Presson's btDbvt. A\n * dynamic tree arranges data in a binary tree to accelerate queries such as\n * volume queries and ray casts. Leafs are proxies with an AABB. In the tree we\n * expand the proxy AABB by `aabbExtension` so that the proxy AABB is bigger\n * than the client object. This allows the client object to move by small\n * amounts without triggering a tree update.\n *\n * Nodes are pooled and relocatable, so we use node indices rather than\n * pointers.\n */\nexport class DynamicTree {\n m_root: TreeNode;\n m_lastProxyId: number;\n m_nodes: {\n [id: number]: TreeNode\n };\n\n constructor() {\n this.m_root = null;\n this.m_nodes = {};\n this.m_lastProxyId = 0;\n }\n\n /**\n * Get proxy user data.\n *\n * @return the proxy user data or 0 if the id is invalid.\n */\n getUserData(id: number): T {\n const node = this.m_nodes[id];\n if (_ASSERT) console.assert(!!node);\n return node.userData;\n }\n\n /**\n * Get the fat AABB for a node id.\n *\n * @return the proxy user data or 0 if the id is invalid.\n */\n getFatAABB(id: number): AABB {\n const node = this.m_nodes[id];\n if (_ASSERT) console.assert(!!node);\n return node.aabb;\n }\n\n allocateNode(): TreeNode {\n const node = poolTreeNode.allocate();\n node.id = ++this.m_lastProxyId;\n this.m_nodes[node.id] = node;\n return node;\n }\n\n freeNode(node: TreeNode): void {\n // tslint:disable-next-line:no-dynamic-delete\n delete this.m_nodes[node.id];\n poolTreeNode.release(node);\n }\n\n /**\n * Create a proxy in the tree as a leaf node. We return the index of the node\n * instead of a pointer so that we can grow the node pool.\n *\n * Create a proxy. Provide a tight fitting AABB and a userData pointer.\n */\n createProxy(aabb: AABBValue, userData: T): number {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n\n const node = this.allocateNode();\n\n node.aabb.set(aabb);\n\n // Fatten the aabb.\n AABB.extend(node.aabb, Settings.aabbExtension);\n\n node.userData = userData;\n node.height = 0;\n\n this.insertLeaf(node);\n\n return node.id;\n }\n\n /**\n * Destroy a proxy. This asserts if the id is invalid.\n */\n destroyProxy(id: number): void {\n const node = this.m_nodes[id];\n\n if (_ASSERT) console.assert(!!node);\n if (_ASSERT) console.assert(node.isLeaf());\n\n this.removeLeaf(node);\n this.freeNode(node);\n }\n\n /**\n * Move a proxy with a swepted AABB. If the proxy has moved outside of its\n * fattened AABB, then the proxy is removed from the tree and re-inserted.\n * Otherwise the function returns immediately.\n *\n * @param d Displacement\n *\n * @return true if the proxy was re-inserted.\n */\n moveProxy(id: number, aabb: AABBValue, d: Vec2Value): boolean {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n if (_ASSERT) console.assert(!d || Vec2.isValid(d));\n\n const node = this.m_nodes[id];\n\n if (_ASSERT) console.assert(!!node);\n if (_ASSERT) console.assert(node.isLeaf());\n\n if (node.aabb.contains(aabb)) {\n return false;\n }\n\n this.removeLeaf(node);\n\n node.aabb.set(aabb);\n\n // Extend AABB.\n aabb = node.aabb;\n AABB.extend(aabb, Settings.aabbExtension);\n\n // Predict AABB displacement.\n // const d = Vec2.mul(Settings.aabbMultiplier, displacement);\n\n if (d.x < 0.0) {\n aabb.lowerBound.x += d.x * Settings.aabbMultiplier;\n } else {\n aabb.upperBound.x += d.x * Settings.aabbMultiplier;\n }\n\n if (d.y < 0.0) {\n aabb.lowerBound.y += d.y * Settings.aabbMultiplier;\n } else {\n aabb.upperBound.y += d.y * Settings.aabbMultiplier;\n }\n\n this.insertLeaf(node);\n\n return true;\n }\n\n insertLeaf(leaf: TreeNode): void {\n if (_ASSERT) console.assert(AABB.isValid(leaf.aabb));\n\n if (this.m_root == null) {\n this.m_root = leaf;\n this.m_root.parent = null;\n return;\n }\n\n // Find the best sibling for this node\n const leafAABB = leaf.aabb;\n let index = this.m_root;\n while (!index.isLeaf()) {\n const child1 = index.child1;\n const child2 = index.child2;\n\n const area = index.aabb.getPerimeter();\n\n const combinedArea = AABB.combinedPerimeter(index.aabb, leafAABB);\n\n // Cost of creating a new parent for this node and the new leaf\n const cost = 2.0 * combinedArea;\n\n // Minimum cost of pushing the leaf further down the tree\n const inheritanceCost = 2.0 * (combinedArea - area);\n\n // Cost of descending into child1\n const newArea1 = AABB.combinedPerimeter(leafAABB, child1.aabb);\n let cost1 = newArea1 + inheritanceCost;\n if (!child1.isLeaf()) {\n const oldArea = child1.aabb.getPerimeter();\n cost1 -= oldArea;\n }\n\n // Cost of descending into child2\n const newArea2 = AABB.combinedPerimeter(leafAABB, child2.aabb);\n let cost2 = newArea2 + inheritanceCost;\n if (!child2.isLeaf()) {\n const oldArea = child2.aabb.getPerimeter();\n cost2 -= oldArea;\n }\n\n // Descend according to the minimum cost.\n if (cost < cost1 && cost < cost2) {\n break;\n }\n\n // Descend\n if (cost1 < cost2) {\n index = child1;\n } else {\n index = child2;\n }\n }\n\n const sibling = index;\n\n // Create a new parent.\n const oldParent = sibling.parent;\n const newParent = this.allocateNode();\n newParent.parent = oldParent;\n newParent.userData = null;\n newParent.aabb.combine(leafAABB, sibling.aabb);\n newParent.height = sibling.height + 1;\n\n if (oldParent != null) {\n // The sibling was not the root.\n if (oldParent.child1 === sibling) {\n oldParent.child1 = newParent;\n } else {\n oldParent.child2 = newParent;\n }\n\n newParent.child1 = sibling;\n newParent.child2 = leaf;\n sibling.parent = newParent;\n leaf.parent = newParent;\n } else {\n // The sibling was the root.\n newParent.child1 = sibling;\n newParent.child2 = leaf;\n sibling.parent = newParent;\n leaf.parent = newParent;\n this.m_root = newParent;\n }\n\n // Walk back up the tree fixing heights and AABBs\n index = leaf.parent;\n while (index != null) {\n index = this.balance(index);\n\n const child1 = index.child1;\n const child2 = index.child2;\n\n if (_ASSERT) console.assert(child1 != null);\n if (_ASSERT) console.assert(child2 != null);\n\n index.height = 1 + math_max(child1.height, child2.height);\n index.aabb.combine(child1.aabb, child2.aabb);\n\n index = index.parent;\n }\n\n // validate();\n }\n\n removeLeaf(leaf: TreeNode): void {\n if (leaf === this.m_root) {\n this.m_root = null;\n return;\n }\n\n const parent = leaf.parent;\n const grandParent = parent.parent;\n let sibling;\n if (parent.child1 === leaf) {\n sibling = parent.child2;\n } else {\n sibling = parent.child1;\n }\n\n if (grandParent != null) {\n // Destroy parent and connect sibling to grandParent.\n if (grandParent.child1 === parent) {\n grandParent.child1 = sibling;\n } else {\n grandParent.child2 = sibling;\n }\n sibling.parent = grandParent;\n this.freeNode(parent);\n\n // Adjust ancestor bounds.\n let index = grandParent;\n while (index != null) {\n index = this.balance(index);\n\n const child1 = index.child1;\n const child2 = index.child2;\n\n index.aabb.combine(child1.aabb, child2.aabb);\n index.height = 1 + math_max(child1.height, child2.height);\n\n index = index.parent;\n }\n } else {\n this.m_root = sibling;\n sibling.parent = null;\n this.freeNode(parent);\n }\n\n // validate();\n }\n\n /**\n * Perform a left or right rotation if node A is imbalanced. Returns the new\n * root index.\n */\n balance(iA: TreeNode): TreeNode {\n if (_ASSERT) console.assert(iA != null);\n\n const A = iA;\n if (A.isLeaf() || A.height < 2) {\n return iA;\n }\n\n const B = A.child1;\n const C = A.child2;\n\n const balance = C.height - B.height;\n\n // Rotate C up\n if (balance > 1) {\n const F = C.child1;\n const G = C.child2;\n\n // Swap A and C\n C.child1 = A;\n C.parent = A.parent;\n A.parent = C;\n\n // A's old parent should point to C\n if (C.parent != null) {\n if (C.parent.child1 === iA) {\n C.parent.child1 = C;\n } else {\n C.parent.child2 = C;\n }\n } else {\n this.m_root = C;\n }\n\n // Rotate\n if (F.height > G.height) {\n C.child2 = F;\n A.child2 = G;\n G.parent = A;\n A.aabb.combine(B.aabb, G.aabb);\n C.aabb.combine(A.aabb, F.aabb);\n\n A.height = 1 + math_max(B.height, G.height);\n C.height = 1 + math_max(A.height, F.height);\n } else {\n C.child2 = G;\n A.child2 = F;\n F.parent = A;\n A.aabb.combine(B.aabb, F.aabb);\n C.aabb.combine(A.aabb, G.aabb);\n\n A.height = 1 + math_max(B.height, F.height);\n C.height = 1 + math_max(A.height, G.height);\n }\n\n return C;\n }\n\n // Rotate B up\n if (balance < -1) {\n const D = B.child1;\n const E = B.child2;\n\n // Swap A and B\n B.child1 = A;\n B.parent = A.parent;\n A.parent = B;\n\n // A's old parent should point to B\n if (B.parent != null) {\n if (B.parent.child1 === A) {\n B.parent.child1 = B;\n } else {\n B.parent.child2 = B;\n }\n } else {\n this.m_root = B;\n }\n\n // Rotate\n if (D.height > E.height) {\n B.child2 = D;\n A.child1 = E;\n E.parent = A;\n A.aabb.combine(C.aabb, E.aabb);\n B.aabb.combine(A.aabb, D.aabb);\n\n A.height = 1 + math_max(C.height, E.height);\n B.height = 1 + math_max(A.height, D.height);\n } else {\n B.child2 = E;\n A.child1 = D;\n D.parent = A;\n A.aabb.combine(C.aabb, D.aabb);\n B.aabb.combine(A.aabb, E.aabb);\n\n A.height = 1 + math_max(C.height, D.height);\n B.height = 1 + math_max(A.height, E.height);\n }\n\n return B;\n }\n\n return A;\n }\n\n /**\n * Compute the height of the binary tree in O(N) time. Should not be called\n * often.\n */\n getHeight(): number {\n if (this.m_root == null) {\n return 0;\n }\n\n return this.m_root.height;\n }\n\n /**\n * Get the ratio of the sum of the node areas to the root area.\n */\n getAreaRatio(): number {\n if (this.m_root == null) {\n return 0.0;\n }\n\n const root = this.m_root;\n const rootArea = root.aabb.getPerimeter();\n\n let totalArea = 0.0;\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height < 0) {\n // Free node in pool\n continue;\n }\n\n totalArea += node.aabb.getPerimeter();\n }\n\n this.iteratorPool.release(it);\n\n return totalArea / rootArea;\n }\n\n /**\n * Compute the height of a sub-tree.\n */\n computeHeight(id?: number): number {\n let node;\n if (typeof id !== \"undefined\") {\n node = this.m_nodes[id];\n } else {\n node = this.m_root;\n }\n\n // if (_ASSERT) console.assert(0 <= id && id < this.m_nodeCapacity);\n\n if (node.isLeaf()) {\n return 0;\n }\n\n const height1 = this.computeHeight(node.child1.id);\n const height2 = this.computeHeight(node.child2.id);\n return 1 + math_max(height1, height2);\n }\n\n validateStructure(node: TreeNode): void {\n if (node == null) {\n return;\n }\n\n if (node === this.m_root) {\n if (_ASSERT) console.assert(node.parent == null);\n }\n\n const child1 = node.child1;\n const child2 = node.child2;\n\n if (node.isLeaf()) {\n if (_ASSERT) console.assert(child1 == null);\n if (_ASSERT) console.assert(child2 == null);\n if (_ASSERT) console.assert(node.height === 0);\n return;\n }\n\n // if (_ASSERT) console.assert(0 <= child1 && child1 < this.m_nodeCapacity);\n // if (_ASSERT) console.assert(0 <= child2 && child2 < this.m_nodeCapacity);\n\n if (_ASSERT) console.assert(child1.parent === node);\n if (_ASSERT) console.assert(child2.parent === node);\n\n this.validateStructure(child1);\n this.validateStructure(child2);\n }\n\n validateMetrics(node: TreeNode): void {\n if (node == null) {\n return;\n }\n\n const child1 = node.child1;\n const child2 = node.child2;\n\n if (node.isLeaf()) {\n if (_ASSERT) console.assert(child1 == null);\n if (_ASSERT) console.assert(child2 == null);\n if (_ASSERT) console.assert(node.height === 0);\n return;\n }\n\n // if (_ASSERT) console.assert(0 <= child1 && child1 < this.m_nodeCapacity);\n // if (_ASSERT) console.assert(0 <= child2 && child2 < this.m_nodeCapacity);\n\n const height1 = child1.height;\n const height2 = child2.height;\n const height = 1 + math_max(height1, height2);\n if (_ASSERT) console.assert(node.height === height);\n\n const aabb = new AABB();\n aabb.combine(child1.aabb, child2.aabb);\n\n if (_ASSERT) console.assert(AABB.areEqual(aabb, node.aabb));\n\n this.validateMetrics(child1);\n this.validateMetrics(child2);\n }\n\n /**\n * Validate this tree. For testing.\n */\n validate(): void {\n if (!_ASSERT) return;\n this.validateStructure(this.m_root);\n this.validateMetrics(this.m_root);\n\n console.assert(this.getHeight() === this.computeHeight());\n }\n\n /**\n * Get the maximum balance of an node in the tree. The balance is the difference\n * in height of the two children of a node.\n */\n getMaxBalance(): number {\n let maxBalance = 0;\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height <= 1) {\n continue;\n }\n\n if (_ASSERT) console.assert(!node.isLeaf());\n\n const balance = math_abs(node.child2.height - node.child1.height);\n maxBalance = math_max(maxBalance, balance);\n }\n this.iteratorPool.release(it);\n\n return maxBalance;\n }\n\n /**\n * Build an optimal tree. Very expensive. For testing.\n */\n rebuildBottomUp(): void {\n const nodes = [];\n let count = 0;\n\n // Build array of leaves. Free the rest.\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height < 0) {\n // free node in pool\n continue;\n }\n\n if (node.isLeaf()) {\n node.parent = null;\n nodes[count] = node;\n ++count;\n } else {\n this.freeNode(node);\n }\n }\n this.iteratorPool.release(it);\n\n while (count > 1) {\n let minCost = Infinity;\n let iMin = -1;\n let jMin = -1;\n for (let i = 0; i < count; ++i) {\n const aabbi = nodes[i].aabb;\n for (let j = i + 1; j < count; ++j) {\n const aabbj = nodes[j].aabb;\n const cost = AABB.combinedPerimeter(aabbi, aabbj);\n if (cost < minCost) {\n iMin = i;\n jMin = j;\n minCost = cost;\n }\n }\n }\n\n const child1 = nodes[iMin];\n const child2 = nodes[jMin];\n\n const parent = this.allocateNode();\n parent.child1 = child1;\n parent.child2 = child2;\n parent.height = 1 + math_max(child1.height, child2.height);\n parent.aabb.combine(child1.aabb, child2.aabb);\n parent.parent = null;\n\n child1.parent = parent;\n child2.parent = parent;\n\n nodes[jMin] = nodes[count - 1];\n nodes[iMin] = parent;\n --count;\n }\n\n this.m_root = nodes[0];\n\n if (_ASSERT) this.validate();\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n // Build array of leaves. Free the rest.\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n const aabb = node.aabb;\n aabb.lowerBound.x -= newOrigin.x;\n aabb.lowerBound.y -= newOrigin.y;\n aabb.upperBound.x -= newOrigin.x;\n aabb.upperBound.y -= newOrigin.y;\n }\n this.iteratorPool.release(it);\n }\n\n /**\n * Query an AABB for overlapping proxies. The callback class is called for each\n * proxy that overlaps the supplied AABB.\n */\n query(aabb: AABBValue, queryCallback: DynamicTreeQueryCallback): void {\n if (_ASSERT) console.assert(typeof queryCallback === \"function\");\n const stack = this.stackPool.allocate();\n\n stack.push(this.m_root);\n while (stack.length > 0) {\n const node = stack.pop();\n if (node == null) {\n continue;\n }\n\n if (AABB.testOverlap(node.aabb, aabb)) {\n if (node.isLeaf()) {\n const proceed = queryCallback(node.id);\n if (proceed === false) {\n return;\n }\n } else {\n stack.push(node.child1);\n stack.push(node.child2);\n }\n }\n }\n\n this.stackPool.release(stack);\n }\n\n /**\n * Ray-cast against the proxies in the tree. This relies on the callback to\n * perform a exact ray-cast in the case were the proxy contains a shape. The\n * callback also performs the any collision filtering. This has performance\n * roughly equal to k * log(n), where k is the number of collisions and n is the\n * number of proxies in the tree.\n *\n * @param input The ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n * @param rayCastCallback A function that is called for each proxy that is hit by the ray. If the return value is a positive number it will update the maxFraction of the ray cast input, and if it is zero it will terminate they ray cast.\n */\n rayCast(input: RayCastInput, rayCastCallback: RayCastCallback): void {\n // TODO: GC\n if (_ASSERT) console.assert(typeof rayCastCallback === \"function\");\n const p1 = input.p1;\n const p2 = input.p2;\n const r = Vec2.sub(p2, p1);\n if (_ASSERT) console.assert(r.lengthSquared() > 0.0);\n r.normalize();\n\n // v is perpendicular to the segment.\n const v = Vec2.crossNumVec2(1.0, r);\n const abs_v = Vec2.abs(v);\n\n // Separating axis for segment (Gino, p80).\n // |dot(v, p1 - c)| > dot(|v|, h)\n\n let maxFraction = input.maxFraction;\n\n // Build a bounding box for the segment.\n const segmentAABB = new AABB();\n let t = Vec2.combine((1 - maxFraction), p1, maxFraction, p2);\n segmentAABB.combinePoints(p1, t);\n\n const stack = this.stackPool.allocate();\n const subInput = this.inputPool.allocate();\n\n stack.push(this.m_root);\n while (stack.length > 0) {\n const node = stack.pop();\n if (node == null) {\n continue;\n }\n\n if (AABB.testOverlap(node.aabb, segmentAABB) === false) {\n continue;\n }\n\n // Separating axis for segment (Gino, p80).\n // |dot(v, p1 - c)| > dot(|v|, h)\n const c = node.aabb.getCenter();\n const h = node.aabb.getExtents();\n const separation = math_abs(Vec2.dot(v, Vec2.sub(p1, c))) - Vec2.dot(abs_v, h);\n if (separation > 0.0) {\n continue;\n }\n\n if (node.isLeaf()) {\n subInput.p1 = Vec2.clone(input.p1);\n subInput.p2 = Vec2.clone(input.p2);\n subInput.maxFraction = maxFraction;\n\n const value = rayCastCallback(subInput, node.id);\n\n if (value === 0.0) {\n // The client has terminated the ray cast.\n break;\n } else if (value > 0.0) {\n // update segment bounding box.\n maxFraction = value;\n t = Vec2.combine((1 - maxFraction), p1, maxFraction, p2);\n segmentAABB.combinePoints(p1, t);\n }\n } else {\n stack.push(node.child1);\n stack.push(node.child2);\n }\n }\n this.stackPool.release(stack);\n this.inputPool.release(subInput);\n }\n\n private inputPool: Pool = new Pool({\n create(): RayCastInput {\n // tslint:disable-next-line:no-object-literal-type-assertion\n return {} as RayCastInput;\n },\n release(stack: RayCastInput): void {\n }\n });\n\n private stackPool: Pool>> = new Pool>>({\n create(): Array> {\n return [];\n },\n release(stack: Array>): void {\n stack.length = 0;\n }\n });\n\n private iteratorPool: Pool> = new Pool>({\n create(): Iterator {\n return new Iterator();\n },\n release(iterator: Iterator): void {\n iterator.close();\n }\n });\n\n}\n\n/** @internal */\nclass Iterator {\n parents: Array> = [];\n states: number[] = [];\n preorder(root: TreeNode): Iterator {\n this.parents.length = 0;\n this.parents.push(root);\n this.states.length = 0;\n this.states.push(0);\n return this;\n }\n next(): TreeNode {\n while (this.parents.length > 0) {\n const i = this.parents.length - 1;\n const node = this.parents[i];\n if (this.states[i] === 0) {\n this.states[i] = 1;\n return node;\n }\n if (this.states[i] === 1) {\n this.states[i] = 2;\n if (node.child1) {\n this.parents.push(node.child1);\n this.states.push(1);\n return node.child1;\n }\n }\n if (this.states[i] === 2) {\n this.states[i] = 3;\n if (node.child2) {\n this.parents.push(node.child2);\n this.states.push(1);\n return node.child2;\n }\n }\n this.parents.pop();\n this.states.pop();\n }\n }\n close(): void {\n this.parents.length = 0;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2Value } from \"../common/Vec2\";\nimport { AABB, AABBValue, RayCastCallback, RayCastInput } from \"./AABB\";\nimport { DynamicTree, DynamicTreeQueryCallback } from \"./DynamicTree\";\nimport { FixtureProxy } from \"../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/**\n * The broad-phase wraps and extends a dynamic-tree to keep track of moved\n * objects and query them on update.\n */\nexport class BroadPhase {\n m_tree: DynamicTree = new DynamicTree();\n m_moveBuffer: number[] = [];\n\n m_callback: (userDataA: any, userDataB: any) => void;\n m_queryProxyId: number;\n\n /**\n * Get user data from a proxy. Returns null if the id is invalid.\n */\n getUserData(proxyId: number): FixtureProxy {\n return this.m_tree.getUserData(proxyId);\n }\n\n /**\n * Test overlap of fat AABBs.\n */\n testOverlap(proxyIdA: number, proxyIdB: number): boolean {\n const aabbA = this.m_tree.getFatAABB(proxyIdA);\n const aabbB = this.m_tree.getFatAABB(proxyIdB);\n return AABB.testOverlap(aabbA, aabbB);\n }\n\n /**\n * Get the fat AABB for a proxy.\n */\n getFatAABB(proxyId: number): AABB {\n return this.m_tree.getFatAABB(proxyId);\n }\n\n /**\n * Get the number of proxies.\n */\n getProxyCount(): number {\n return this.m_moveBuffer.length;\n }\n\n /**\n * Get the height of the embedded tree.\n */\n getTreeHeight(): number {\n return this.m_tree.getHeight();\n }\n\n /**\n * Get the balance (integer) of the embedded tree.\n */\n getTreeBalance(): number {\n return this.m_tree.getMaxBalance();\n }\n\n /**\n * Get the quality metric of the embedded tree.\n */\n getTreeQuality(): number {\n return this.m_tree.getAreaRatio();\n }\n\n /**\n * Query an AABB for overlapping proxies. The callback class is called for each\n * proxy that overlaps the supplied AABB.\n */\n query = (aabb: AABBValue, queryCallback: DynamicTreeQueryCallback): void => {\n this.m_tree.query(aabb, queryCallback);\n };\n\n /**\n * Ray-cast against the proxies in the tree. This relies on the callback to\n * perform a exact ray-cast in the case were the proxy contains a shape. The\n * callback also performs the any collision filtering. This has performance\n * roughly equal to k * log(n), where k is the number of collisions and n is the\n * number of proxies in the tree.\n *\n * @param input The ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n * @param rayCastCallback A function that is called for each proxy that is hit by the ray. If the return value is a positive number it will update the maxFraction of the ray cast input, and if it is zero it will terminate they ray cast.\n */\n rayCast(input: RayCastInput, rayCastCallback: RayCastCallback): void {\n this.m_tree.rayCast(input, rayCastCallback);\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_tree.shiftOrigin(newOrigin);\n }\n\n /**\n * Create a proxy with an initial AABB. Pairs are not reported until UpdatePairs\n * is called.\n */\n createProxy(aabb: AABBValue, userData: FixtureProxy): number {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n const proxyId = this.m_tree.createProxy(aabb, userData);\n this.bufferMove(proxyId);\n return proxyId;\n }\n\n /**\n * Destroy a proxy. It is up to the client to remove any pairs.\n */\n destroyProxy(proxyId: number): void {\n this.unbufferMove(proxyId);\n this.m_tree.destroyProxy(proxyId);\n }\n\n /**\n * Call moveProxy as many times as you like, then when you are done call\n * UpdatePairs to finalized the proxy pairs (for your time step).\n */\n moveProxy(proxyId: number, aabb: AABB, displacement: Vec2Value): void {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n const changed = this.m_tree.moveProxy(proxyId, aabb, displacement);\n if (changed) {\n this.bufferMove(proxyId);\n }\n }\n\n /**\n * Call to trigger a re-processing of it's pairs on the next call to\n * UpdatePairs.\n */\n touchProxy(proxyId: number): void {\n this.bufferMove(proxyId);\n }\n\n bufferMove(proxyId: number): void {\n this.m_moveBuffer.push(proxyId);\n }\n\n unbufferMove(proxyId: number): void {\n for (let i = 0; i < this.m_moveBuffer.length; ++i) {\n if (this.m_moveBuffer[i] === proxyId) {\n this.m_moveBuffer[i] = null;\n }\n }\n }\n\n /**\n * Update the pairs. This results in pair callbacks. This can only add pairs.\n */\n updatePairs(addPairCallback: (userDataA: FixtureProxy, userDataB: FixtureProxy) => void): void {\n if (_ASSERT) console.assert(typeof addPairCallback === \"function\");\n this.m_callback = addPairCallback;\n\n // Perform tree queries for all moving proxies.\n while (this.m_moveBuffer.length > 0) {\n this.m_queryProxyId = this.m_moveBuffer.pop();\n if (this.m_queryProxyId === null) {\n continue;\n }\n\n // We have to query the tree with the fat AABB so that\n // we don't fail to create a pair that may touch later.\n const fatAABB = this.m_tree.getFatAABB(this.m_queryProxyId);\n\n // Query tree, create pairs and add them pair buffer.\n this.m_tree.query(fatAABB, this.queryCallback);\n }\n\n // Try to keep the tree balanced.\n // this.m_tree.rebalance(4);\n }\n\n queryCallback = (proxyId: number): boolean => {\n // A proxy cannot form a pair with itself.\n if (proxyId === this.m_queryProxyId) {\n return true;\n }\n\n const proxyIdA = math_min(proxyId, this.m_queryProxyId);\n const proxyIdB = math_max(proxyId, this.m_queryProxyId);\n\n // TODO: Skip any duplicate pairs.\n\n const userDataA = this.m_tree.getUserData(proxyIdA);\n const userDataB = this.m_tree.getUserData(proxyIdB);\n\n // Send the pairs back to the client.\n this.m_callback(userDataA, userDataB);\n\n return true;\n };\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n/** @internal */ const math_sqrt = Math.sqrt;\n\n\nimport { RotValue } from \"./Rot\";\nimport { TransformValue } from \"./Transform\";\nimport { Vec2Value } from \"./Vec2\";\nimport { Vec3Value } from \"./Vec3\";\n\nexport function vec2(x: number, y: number): Vec2Value {\n return { x, y };\n}\n\nexport function vec3(x: number, y: number, z: number): Vec3Value {\n return { x, y, z };\n}\n\nexport function rotation(angle: number): RotValue {\n return { s: math_sin(angle), c: math_cos(angle) };\n}\n\nexport function setVec2(out: Vec2Value, x: number, y: number): Vec2Value {\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function copyVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = w.x;\n out.y = w.y;\n return out;\n}\n\nexport function zeroVec2(out: Vec2Value): Vec2Value {\n out.x = 0;\n out.y = 0;\n return out;\n}\n\nexport function negVec2(out: Vec2Value): Vec2Value {\n out.x = -out.x;\n out.y = -out.y;\n return out;\n}\n\nexport function plusVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x += w.x;\n out.y += w.y;\n return out;\n}\n\nexport function addVec2(out: Vec2Value, v: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = v.x + w.x;\n out.y = v.x + w.y;\n return out;\n}\n\nexport function minusVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x -= w.x;\n out.y -= w.y;\n return out;\n}\n\nexport function subVec2(out: Vec2Value, v: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = v.x - w.x;\n out.y = v.y - w.y;\n return out;\n}\n\nexport function mulVec2(out: Vec2Value, m: number): Vec2Value {\n out.x *= m;\n out.y *= m;\n return out;\n}\n\nexport function scaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x = m * w.x;\n out.y = m * w.y;\n return out;\n}\n\nexport function plusScaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x += m * w.x;\n out.y += m * w.y;\n return out;\n}\n\nexport function minusScaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x -= m * w.x;\n out.y -= m * w.y;\n return out;\n}\n\nexport function combine2Vec2(out: Vec2Value, am: number, a: Vec2Value, bm: number, b: Vec2Value): Vec2Value {\n out.x = am * a.x + bm * b.x;\n out.y = am * a.y + bm * b.y;\n return out;\n}\n\nexport function combine3Vec2(out: Vec2Value, am: number, a: Vec2Value, bm: number, b: Vec2Value, cm: number, c: Vec2Value): Vec2Value {\n out.x = am * a.x + bm * b.x + cm * c.x;\n out.y = am * a.y + bm * b.y + cm * c.y;\n return out;\n}\n\nexport function normalizeVec2Length(out: Vec2Value): number {\n const length = math_sqrt(out.x * out.x + out.y * out.y);\n if (length !== 0) {\n const invLength = 1 / length;\n out.x *= invLength;\n out.y *= invLength;\n }\n return length;\n}\n\nexport function normalizeVec2(out: Vec2Value): Vec2Value {\n const length = math_sqrt(out.x * out.x + out.y * out.y);\n if (length > 0) {\n const invLength = 1 / length;\n out.x *= invLength;\n out.y *= invLength;\n }\n return out;\n}\n\nexport function crossVec2Num(out: Vec2Value, v: Vec2Value, w: number): Vec2Value {\n const x = w * v.y;\n const y = -w * v.x;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function crossNumVec2(out: Vec2Value, w: number, v: Vec2Value): Vec2Value {\n const x = -w * v.y;\n const y = w * v.x;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function crossVec2Vec2(a: Vec2Value, b: Vec2Value): number {\n return a.x * b.y - a.y * b.x;\n}\n\nexport function dotVec2(a: Vec2Value, b: Vec2Value): number {\n return a.x * b.x + a.y * b.y;\n}\n\nexport function lengthVec2(a: Vec2Value): number {\n return math_sqrt(a.x * a.x + a.y * a.y);\n}\n\nexport function lengthSqrVec2(a: Vec2Value): number {\n return a.x * a.x + a.y * a.y;\n}\n\nexport function distVec2(a: Vec2Value, b: Vec2Value): number {\n const dx = a.x - b.x;\n const dy = a.y - b.y;\n return math_sqrt(dx * dx + dy * dy);\n}\n\nexport function distSqrVec2(a: Vec2Value, b: Vec2Value): number {\n const dx = a.x - b.x;\n const dy = a.y - b.y;\n return dx * dx + dy * dy;\n}\n\nexport function dotVec3(v: Vec3Value, w: Vec3Value): number {\n return v.x * w.x + v.y * w.y + v.z * w.z;\n}\n\nexport function setRotAngle(out: RotValue, a: number): RotValue {\n out.c = math_cos(a);\n out.s = math_sin(a);\n return out;\n}\n\nexport function rotVec2(out: Vec2Value, q: RotValue, v: Vec2Value): Vec2Value {\n out.x = q.c * v.x - q.s * v.y;\n out.y = q.s * v.x + q.c * v.y;\n return out;\n}\n\nexport function derotVec2(out: Vec2Value, q: RotValue, v: Vec2Value): Vec2Value {\n const x = q.c * v.x + q.s * v.y;\n const y = -q.s * v.x + q.c * v.y;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function rerotVec2(out: Vec2Value, before: RotValue, after: RotValue, v: Vec2Value): Vec2Value {\n const x0 = before.c * v.x + before.s * v.y;\n const y0 = -before.s * v.x + before.c * v.y;\n const x = after.c * x0 - after.s * y0;\n const y = after.s * x0 + after.c * y0;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function transform(x: number, y: number, a: number): TransformValue {\n return { p: vec2(x, y), q: rotation(a) };\n}\n\nexport function copyTransform(out: TransformValue, transform: TransformValue): TransformValue {\n out.p.x = transform.p.x;\n out.p.y = transform.p.y;\n out.q.s = transform.q.s;\n out.q.c = transform.q.c;\n return out;\n}\n\nexport function transformVec2(out: Vec2Value, xf: TransformValue, v: Vec2Value): Vec2Value {\n const x = xf.q.c * v.x - xf.q.s * v.y + xf.p.x;\n const y = xf.q.s * v.x + xf.q.c * v.y + xf.p.y;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function detransformVec2(out: Vec2Value, xf: TransformValue, v: Vec2Value): Vec2Value {\n const px = v.x - xf.p.x;\n const py = v.y - xf.p.y;\n const x = (xf.q.c * px + xf.q.s * py);\n const y = (-xf.q.s * px + xf.q.c * py);\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function retransformVec2(out: Vec2Value, from: TransformValue, to: TransformValue, v: Vec2Value): Vec2Value {\n const x0 = from.q.c * v.x - from.q.s * v.y + from.p.x;\n const y0 = from.q.s * v.x + from.q.c * v.y + from.p.y;\n const px = x0 - to.p.x;\n const py = y0 - to.p.y;\n const x = to.q.c * px + to.q.s * py;\n const y = -to.q.s * px + to.q.c * py;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function detransformTransform(out: TransformValue, a: TransformValue, b: TransformValue): TransformValue {\n const c = a.q.c * b.q.c + a.q.s * b.q.s;\n const s = a.q.c * b.q.s - a.q.s * b.q.c;\n const x = a.q.c * (b.p.x - a.p.x) + a.q.s * (b.p.y - a.p.y);\n const y = -a.q.s * (b.p.x - a.p.x) + a.q.c * (b.p.y - a.p.y);\n out.q.c = c;\n out.q.s = s;\n out.p.x = x;\n out.p.y = y;\n return out;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n/** @internal */ const math_atan2 = Math.atan2;\n\nexport interface RotValue {\n /** sin(angle) */\n s: number;\n /** cos(angle) */\n c: number;\n}\n\ndeclare module \"./Rot\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(angle: number): Rot;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(obj: RotValue): Rot;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(): Rot;\n}\n\n/** Rotation */\n// @ts-expect-error\nexport class Rot {\n /** sin(angle) */\n s: number;\n /** cos(angle) */\n c: number;\n\n /** Initialize from an angle in radians. */\n constructor(angle?: number | RotValue) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Rot)) {\n return new Rot(angle);\n }\n if (typeof angle === \"number\") {\n this.setAngle(angle);\n } else if (typeof angle === \"object\") {\n this.setRot(angle);\n } else {\n this.setIdentity();\n }\n }\n\n /** @hidden */\n static neo(angle: number): Rot {\n const obj = Object.create(Rot.prototype);\n obj.setAngle(angle);\n return obj;\n }\n\n static clone(rot: RotValue): Rot {\n if (_ASSERT) Rot.assert(rot);\n const obj = Object.create(Rot.prototype);\n obj.s = rot.s;\n obj.c = rot.c;\n return obj;\n }\n\n static identity(): Rot {\n const obj = Object.create(Rot.prototype);\n obj.s = 0.0;\n obj.c = 1.0;\n return obj;\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.s) && Number.isFinite(obj.c);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Rot.isValid(o), \"Invalid Rot!\", o);\n }\n\n /** Set to the identity rotation. */\n setIdentity(): void {\n this.s = 0.0;\n this.c = 1.0;\n }\n\n set(angle: number | RotValue): void {\n if (typeof angle === \"object\") {\n if (_ASSERT) Rot.assert(angle);\n this.s = angle.s;\n this.c = angle.c;\n\n } else {\n if (_ASSERT) console.assert(Number.isFinite(angle));\n // TODO_ERIN optimize\n this.s = math_sin(angle);\n this.c = math_cos(angle);\n }\n }\n\n setRot(angle: RotValue): void {\n if (_ASSERT) Rot.assert(angle);\n this.s = angle.s;\n this.c = angle.c;\n }\n\n /** Set using an angle in radians. */\n setAngle(angle: number): void {\n if (_ASSERT) console.assert(Number.isFinite(angle));\n // TODO_ERIN optimize\n this.s = math_sin(angle);\n this.c = math_cos(angle);\n }\n\n /** Get the angle in radians. */\n getAngle(): number {\n return math_atan2(this.s, this.c);\n }\n\n /** Get the x-axis. */\n getXAxis(): Vec2 {\n return Vec2.neo(this.c, this.s);\n }\n\n /** Get the y-axis. */\n getYAxis(): Vec2 {\n return Vec2.neo(-this.s, this.c);\n }\n\n /** Multiply two rotations: q * r */\n static mul(rot: RotValue, m: RotValue): Rot;\n /** Rotate a vector */\n static mul(rot: RotValue, m: Vec2Value): Vec2;\n static mul(rot, m) {\n if (_ASSERT) Rot.assert(rot);\n if (\"c\" in m && \"s\" in m) {\n if (_ASSERT) Rot.assert(m);\n // [qc -qs] * [rc -rs] = [qc*rc-qs*rs -qc*rs-qs*rc]\n // [qs qc] [rs rc] [qs*rc+qc*rs -qs*rs+qc*rc]\n // s = qs * rc + qc * rs\n // c = qc * rc - qs * rs\n const qr = Rot.identity();\n qr.s = rot.s * m.c + rot.c * m.s;\n qr.c = rot.c * m.c - rot.s * m.s;\n return qr;\n\n } else if (\"x\" in m && \"y\" in m) {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x - rot.s * m.y, rot.s * m.x + rot.c * m.y);\n }\n }\n\n /** Multiply two rotations: q * r */\n static mulRot(rot: RotValue, m: RotValue): Rot {\n if (_ASSERT) Rot.assert(rot);\n if (_ASSERT) Rot.assert(m);\n // [qc -qs] * [rc -rs] = [qc*rc-qs*rs -qc*rs-qs*rc]\n // [qs qc] [rs rc] [qs*rc+qc*rs -qs*rs+qc*rc]\n // s = qs * rc + qc * rs\n // c = qc * rc - qs * rs\n const qr = Rot.identity();\n qr.s = rot.s * m.c + rot.c * m.s;\n qr.c = rot.c * m.c - rot.s * m.s;\n return qr;\n }\n\n /** Rotate a vector */\n static mulVec2(rot: RotValue, m: Vec2Value): Vec2 {\n if (_ASSERT) Rot.assert(rot);\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x - rot.s * m.y, rot.s * m.x + rot.c * m.y);\n }\n\n static mulSub(rot: RotValue, v: Vec2Value, w: Vec2Value): Vec2 {\n const x = rot.c * (v.x - w.x) - rot.s * (v.y - w.y);\n const y = rot.s * (v.x - w.x) + rot.c * (v.y - w.y);\n return Vec2.neo(x, y);\n }\n\n /** Transpose multiply two rotations: qT * r */\n static mulT(rot: RotValue, m: RotValue): Rot;\n /** Inverse rotate a vector */\n static mulT(rot: RotValue, m: Vec2Value): Vec2;\n static mulT(rot, m) {\n if (\"c\" in m && \"s\" in m) {\n if (_ASSERT) Rot.assert(m);\n // [ qc qs] * [rc -rs] = [qc*rc+qs*rs -qc*rs+qs*rc]\n // [-qs qc] [rs rc] [-qs*rc+qc*rs qs*rs+qc*rc]\n // s = qc * rs - qs * rc\n // c = qc * rc + qs * rs\n const qr = Rot.identity();\n qr.s = rot.c * m.s - rot.s * m.c;\n qr.c = rot.c * m.c + rot.s * m.s;\n return qr;\n\n } else if (\"x\" in m && \"y\" in m) {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x + rot.s * m.y, -rot.s * m.x + rot.c * m.y);\n }\n }\n\n /** Transpose multiply two rotations: qT * r */\n static mulTRot(rot: RotValue, m: RotValue): Rot {\n if (_ASSERT) Rot.assert(m);\n // [ qc qs] * [rc -rs] = [qc*rc+qs*rs -qc*rs+qs*rc]\n // [-qs qc] [rs rc] [-qs*rc+qc*rs qs*rs+qc*rc]\n // s = qc * rs - qs * rc\n // c = qc * rc + qs * rs\n const qr = Rot.identity();\n qr.s = rot.c * m.s - rot.s * m.c;\n qr.c = rot.c * m.c + rot.s * m.s;\n return qr;\n }\n\n /** Inverse rotate a vector */\n static mulTVec2(rot: RotValue, m: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x + rot.s * m.y, -rot.s * m.x + rot.c * m.y);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"./Matrix\";\nimport { mod } from \"./Math\";\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { TransformValue } from \"./Transform\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_atan2 = Math.atan2;\n/** @internal */ const math_PI = Math.PI;\n\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n\n/**\n * This describes the motion of a body/shape for TOI computation. Shapes are\n * defined with respect to the body origin, which may not coincide with the\n * center of mass. However, to support dynamics we must interpolate the center\n * of mass position.\n */\nexport class Sweep {\n /** Local center of mass position */\n localCenter = Vec2.zero();\n\n /** World center position */\n c = Vec2.zero();\n\n /** World angle */\n a = 0;\n\n /** Fraction of the current time step in the range [0,1], c0 and a0 are c and a at alpha0. */\n alpha0 = 0;\n\n c0 = Vec2.zero();\n a0 = 0;\n\n /** @internal */\n recycle() {\n matrix.zeroVec2(this.localCenter);\n matrix.zeroVec2(this.c);\n this.a = 0;\n this.alpha0 = 0;\n matrix.zeroVec2(this.c0);\n this.a0 = 0;\n }\n\n setTransform(xf: TransformValue): void {\n matrix.transformVec2(temp, xf, this.localCenter);\n matrix.copyVec2(this.c, temp);\n matrix.copyVec2(this.c0, temp);\n\n this.a = this.a0 = math_atan2(xf.q.s, xf.q.c);\n }\n\n setLocalCenter(localCenter: Vec2Value, xf: TransformValue): void {\n matrix.copyVec2(this.localCenter, localCenter);\n\n matrix.transformVec2(temp, xf, this.localCenter);\n matrix.copyVec2(this.c, temp);\n matrix.copyVec2(this.c0, temp);\n }\n\n /**\n * Get the interpolated transform at a specific time.\n *\n * @param xf\n * @param beta A factor in [0,1], where 0 indicates alpha0\n */\n getTransform(xf: TransformValue, beta: number = 0): void {\n matrix.setRotAngle(xf.q, (1.0 - beta) * this.a0 + beta * this.a);\n matrix.combine2Vec2(xf.p, (1.0 - beta), this.c0, beta, this.c);\n\n // shift to origin\n matrix.minusVec2(xf.p, matrix.rotVec2(temp, xf.q, this.localCenter));\n }\n\n /**\n * Advance the sweep forward, yielding a new initial state.\n *\n * @param alpha The new initial time\n */\n advance(alpha: number): void {\n if (_ASSERT) console.assert(this.alpha0 < 1.0);\n const beta = (alpha - this.alpha0) / (1.0 - this.alpha0);\n matrix.combine2Vec2(this.c0, beta, this.c, 1 - beta, this.c0);\n this.a0 = beta * this.a + (1 - beta) * this.a0;\n this.alpha0 = alpha;\n }\n\n forward(): void {\n this.a0 = this.a;\n matrix.copyVec2(this.c0, this.c);\n }\n\n /**\n * normalize the angles in radians to be between -pi and pi.\n */\n normalize(): void {\n const a0 = mod(this.a0, -math_PI, +math_PI);\n this.a -= this.a0 - a0;\n this.a0 = a0;\n }\n\n set(that: Sweep): void {\n matrix.copyVec2(this.localCenter, that.localCenter);\n matrix.copyVec2(this.c, that.c);\n this.a = that.a;\n this.alpha0 = that.alpha0;\n matrix.copyVec2(this.c0, that.c0);\n this.a0 = that.a0;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { Rot, RotValue } from \"./Rot\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\nexport type TransformValue = {\n p: Vec2Value;\n q: RotValue;\n};\n\ndeclare module \"./Transform\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Transform(position?: Vec2Value, rotation?: number): Transform;\n}\n\n/**\n * A transform contains translation and rotation. It is used to represent the\n * position and orientation of rigid frames. Initialize using a position vector\n * and a rotation.\n */\n// @ts-expect-error\nexport class Transform {\n /** position */\n p: Vec2;\n\n /** rotation */\n q: Rot;\n\n constructor(position?: Vec2Value, rotation?: number) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Transform)) {\n return new Transform(position, rotation);\n }\n this.p = Vec2.zero();\n this.q = Rot.identity();\n if (typeof position !== \"undefined\") {\n this.p.setVec2(position);\n }\n if (typeof rotation !== \"undefined\") {\n this.q.setAngle(rotation);\n }\n }\n\n static clone(xf: Transform): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.clone(xf.p);\n obj.q = Rot.clone(xf.q);\n return obj;\n }\n\n /** @hidden */\n static neo(position: Vec2Value, rotation: Rot): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.clone(position);\n obj.q = Rot.clone(rotation);\n return obj;\n }\n\n static identity(): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.zero();\n obj.q = Rot.identity();\n return obj;\n }\n\n /** Set this to the identity transform */\n setIdentity(): void {\n this.p.setZero();\n this.q.setIdentity();\n }\n\n /** Set position and angle */\n set(position: Vec2Value, rotation: number): void;\n /** Copy from another transform */\n set(xf: TransformValue): void;\n set(a: any, b?: any) {\n if (typeof b === \"undefined\") {\n this.p.set(a.p);\n this.q.set(a.q);\n } else {\n this.p.set(a);\n this.q.set(b);\n }\n }\n\n /** Set position and angle */\n setNum(position: Vec2Value, rotation: number) {\n this.p.setVec2(position);\n this.q.setAngle(rotation);\n }\n\n setTransform(xf: TransformValue): void {\n this.p.setVec2(xf.p);\n this.q.setRot(xf.q);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.p) && Rot.isValid(obj.q);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Transform.isValid(o), \"Invalid Transform!\", o);\n }\n\n static mul(a: TransformValue, b: Vec2Value): Vec2;\n static mul(a: TransformValue, b: TransformValue): Transform;\n // static mul(a: Transform, b: Vec2Value[]): Vec2[];\n // static mul(a: Transform, b: Transform[]): Transform[];\n static mul(a, b) {\n if (Array.isArray(b)) {\n // todo: this was used in examples, remove in the future\n if (_ASSERT) Transform.assert(a);\n const arr = [];\n for (let i = 0; i < b.length; i++) {\n arr[i] = Transform.mul(a, b[i]);\n }\n return arr;\n\n } else if (\"x\" in b && \"y\" in b) {\n return Transform.mulVec2(a, b);\n\n } else if (\"p\" in b && \"q\" in b) {\n return Transform.mulXf(a, b);\n }\n }\n\n static mulAll(a: Transform, b: Vec2Value[]): Vec2[];\n static mulAll(a: Transform, b: Transform[]): Transform[];\n static mulAll(a: TransformValue, b) {\n if (_ASSERT) Transform.assert(a);\n const arr = [];\n for (let i = 0; i < b.length; i++) {\n arr[i] = Transform.mul(a, b[i]);\n }\n return arr;\n }\n\n /** @hidden @deprecated */\n static mulFn(a: TransformValue) {\n // todo: this was used in examples, remove in the future\n if (_ASSERT) Transform.assert(a);\n return function(b: Vec2Value): Vec2 {\n return Transform.mul(a, b);\n };\n }\n\n static mulVec2(a: TransformValue, b: Vec2Value): Vec2 {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const x = (a.q.c * b.x - a.q.s * b.y) + a.p.x;\n const y = (a.q.s * b.x + a.q.c * b.y) + a.p.y;\n return Vec2.neo(x, y);\n }\n\n static mulXf(a: TransformValue, b: TransformValue): Transform {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Transform.assert(b);\n // v2 = A.q.Rot(B.q.Rot(v1) + B.p) + A.p\n // = (A.q * B.q).Rot(v1) + A.q.Rot(B.p) + A.p\n const xf = Transform.identity();\n xf.q = Rot.mulRot(a.q, b.q);\n xf.p = Vec2.add(Rot.mulVec2(a.q, b.p), a.p);\n return xf;\n }\n\n static mulT(a: TransformValue, b: Vec2Value): Vec2;\n static mulT(a: TransformValue, b: TransformValue): Transform;\n static mulT(a, b) {\n if (\"x\" in b && \"y\" in b) {\n return Transform.mulTVec2(a, b);\n\n } else if (\"p\" in b && \"q\" in b) {\n return Transform.mulTXf(a, b);\n }\n }\n\n static mulTVec2(a: TransformValue, b: Vec2Value): Vec2 {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const px = b.x - a.p.x;\n const py = b.y - a.p.y;\n const x = (a.q.c * px + a.q.s * py);\n const y = (-a.q.s * px + a.q.c * py);\n return Vec2.neo(x, y);\n }\n\n static mulTXf(a: TransformValue, b: TransformValue): Transform {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Transform.assert(b);\n // v2 = A.q' * (B.q * v1 + B.p - A.p)\n // = A.q' * B.q * v1 + A.q' * (B.p - A.p)\n const xf = Transform.identity();\n xf.q.setRot(Rot.mulTRot(a.q, b.q));\n xf.p.setVec2(Rot.mulTVec2(a.q, Vec2.sub(b.p, a.p)));\n return xf;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2 } from \"../common/Vec2\";\n\nexport class Velocity {\n /** linear */\n v = Vec2.zero();\n\n /** angular */\n w = 0;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { TransformValue } from \"../common/Transform\";\n\n\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n\n\nexport class Position {\n /** location */\n c = Vec2.zero();\n\n /** angle */\n a = 0;\n\n // todo: cache sin/cos\n getTransform(xf: TransformValue, p: Vec2Value): TransformValue {\n // xf.q = rotation(this.a);\n // xf.p = this.c - xf.q * p\n xf.q.c = math_cos(this.a);\n xf.q.s = math_sin(this.a);\n xf.p.x = this.c.x - (xf.q.c * p.x - xf.q.s * p.y);\n xf.p.y = this.c.y - (xf.q.s * p.x + xf.q.c * p.y);\n return xf;\n }\n}\n\nexport function getTransform(xf: TransformValue, p: Vec2Value, c: Vec2Value, a: number): TransformValue {\n // xf.q = rotation(a);\n // xf.p = this.c - xf.q * p\n xf.q.c = math_cos(a);\n xf.q.s = math_sin(a);\n xf.p.x = c.x - (xf.q.c * p.x - xf.q.s * p.y);\n xf.p.y = c.y - (xf.q.s * p.x + xf.q.c * p.y);\n return xf;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { MassData } from \"../dynamics/Body\";\nimport { RayCastOutput, RayCastInput, AABBValue } from \"./AABB\";\nimport { DistanceProxy } from \"./Distance\";\nimport type { Transform, TransformValue } from \"../common/Transform\";\nimport type { Vec2Value } from \"../common/Vec2\";\nimport { Style } from \"../util/Testbed\";\n\n// todo make shape an interface\n\n/**\n * A shape is used for collision detection. You can create a shape however you\n * like. Shapes used for simulation in World are created automatically when a\n * Fixture is created. Shapes may encapsulate one or more child shapes.\n */\nexport abstract class Shape {\n /** @hidden */ m_type: ShapeType;\n\n /**\n * @hidden\n * Radius of a shape. For polygonal shapes this must be b2_polygonRadius.\n * There is no support for making rounded polygons.\n */\n m_radius: number;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n /** @hidden */\n abstract _reset(): void;\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return typeof obj.m_type === \"string\" && typeof obj.m_radius === \"number\";\n }\n\n abstract getRadius(): number;\n\n /**\n * Get the type of this shape. You can use this to down cast to the concrete\n * shape.\n *\n * @return the shape type.\n */\n abstract getType(): ShapeType;\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n abstract _clone(): Shape;\n\n /**\n * Get the number of child primitives.\n */\n abstract getChildCount(): number;\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n abstract testPoint(xf: TransformValue, p: Vec2Value): boolean;\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n abstract rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean;\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n abstract computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void;\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n abstract computeMass(massData: MassData, density?: number): void;\n\n abstract computeDistanceProxy(proxy: DistanceProxy, childIndex: number): void;\n\n}\n\nexport type ShapeType = \"circle\" | \"edge\" | \"polygon\" | \"chain\";\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { options } from \"../util/options\";\nimport { Vec2Value } from \"../common/Vec2\";\nimport { AABB, RayCastInput, RayCastOutput } from \"../collision/AABB\";\nimport { Shape, ShapeType } from \"../collision/Shape\";\nimport { Body, MassData } from \"./Body\";\nimport { BroadPhase } from \"../collision/BroadPhase\";\nimport { TransformValue } from \"../common/Transform\";\nimport { Style } from \"../util/Testbed\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/** @internal */ const synchronize_aabb1 = new AABB();\n/** @internal */ const synchronize_aabb2 = new AABB();\n/** @internal */ const displacement = matrix.vec2(0, 0);\n\n/**\n * A fixture definition is used to create a fixture. This class defines an\n * abstract fixture definition. You can reuse fixture definitions safely.\n */\nexport interface FixtureOpt {\n userData?: unknown;\n /**\n * The friction coefficient, usually in the range [0,1]\n */\n friction?: number;\n /**\n * The restitution (elasticity) usually in the range [0,1]\n */\n restitution?: number;\n /**\n * The density, usually in kg/m^2\n */\n density?: number;\n /**\n * A sensor shape collects contact information but never generates a collision response.\n */\n isSensor?: boolean;\n /**\n * Zero, positive or negative collision group.\n * Fixtures with same positive groupIndex always collide and fixtures with same negative groupIndex never collide.\n */\n filterGroupIndex?: number;\n /**\n * Collision category bit or bits that this fixture belongs to.\n * If groupIndex is zero or not matching, then at least one bit in this fixture categoryBits should match other fixture maskBits and vice versa.\n */\n filterCategoryBits?: number;\n /**\n * Collision category bit or bits that this fixture accept for collision.\n */\n filterMaskBits?: number;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\nexport interface FixtureDef extends FixtureOpt {\n shape: Shape;\n}\n\n/** @internal */ const FixtureDefDefault: FixtureOpt = {\n userData : null,\n friction : 0.2,\n restitution : 0.0,\n density : 0.0,\n isSensor : false,\n\n filterGroupIndex : 0,\n filterCategoryBits : 0x0001,\n filterMaskBits : 0xFFFF\n};\n\n/**\n * This proxy is used internally to connect shape children to the broad-phase.\n */\nexport class FixtureProxy {\n aabb: AABB;\n fixture: Fixture;\n childIndex: number;\n proxyId: number;\n constructor(fixture: Fixture, childIndex: number) {\n this.aabb = new AABB();\n this.fixture = fixture;\n this.childIndex = childIndex;\n // this.proxyId;\n }\n}\n\n/**\n * A fixture is used to attach a shape to a body for collision detection. A\n * fixture inherits its transform from its parent. Fixtures hold additional\n * non-geometric data such as friction, collision filters, etc.\n *\n * To create a new Fixture use {@link Body.createFixture}.\n */\nexport class Fixture {\n /** @internal */ m_body: Body;\n /** @internal */ m_friction: number;\n /** @internal */ m_restitution: number;\n /** @internal */ m_density: number;\n /** @internal */ m_isSensor: boolean;\n /** @internal */ m_filterGroupIndex: number;\n /** @internal */ m_filterCategoryBits: number;\n /** @internal */ m_filterMaskBits: number;\n /** @internal */ m_shape: Shape;\n /** @internal */ m_next: Fixture | null;\n /** @internal */ m_proxies: FixtureProxy[];\n // 0 indicates inactive state, this is not the same as m_proxies.length\n /** @internal */ m_proxyCount: number;\n /** @internal */ m_userData: unknown;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n constructor(body: Body, def: FixtureDef);\n constructor(body: Body, shape: Shape, def?: FixtureOpt);\n constructor(body: Body, shape: Shape, density?: number);\n /** @internal */\n constructor(body: Body, shape?, def?) {\n if (shape.shape) {\n def = shape;\n shape = shape.shape;\n\n } else if (typeof def === \"number\") {\n def = {density : def};\n }\n\n def = options(def, FixtureDefDefault);\n\n this.m_body = body;\n\n this.m_friction = def.friction;\n this.m_restitution = def.restitution;\n this.m_density = def.density;\n this.m_isSensor = def.isSensor;\n\n this.m_filterGroupIndex = def.filterGroupIndex;\n this.m_filterCategoryBits = def.filterCategoryBits;\n this.m_filterMaskBits = def.filterMaskBits;\n\n // TODO validate shape\n this.m_shape = shape; // .clone();\n\n this.m_next = null;\n\n this.m_proxies = [];\n this.m_proxyCount = 0;\n\n // fixture proxies are created here,\n // but they are activate in when a fixture is added to body\n const childCount = this.m_shape.getChildCount();\n for (let i = 0; i < childCount; ++i) {\n this.m_proxies[i] = new FixtureProxy(this, i);\n }\n\n this.m_userData = def.userData;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /** @hidden Re-setup fixture. */\n _reset(): void {\n const body = this.getBody();\n const broadPhase = body.m_world.m_broadPhase;\n this.destroyProxies(broadPhase);\n if (this.m_shape._reset) {\n this.m_shape._reset();\n }\n const childCount = this.m_shape.getChildCount();\n for (let i = 0; i < childCount; ++i) {\n this.m_proxies[i] = new FixtureProxy(this, i);\n }\n this.createProxies(broadPhase, body.m_xf);\n body.resetMassData();\n }\n\n /** @internal */\n _serialize(): object {\n return {\n friction: this.m_friction,\n restitution: this.m_restitution,\n density: this.m_density,\n isSensor: this.m_isSensor,\n\n filterGroupIndex: this.m_filterGroupIndex,\n filterCategoryBits: this.m_filterCategoryBits,\n filterMaskBits: this.m_filterMaskBits,\n\n shape: this.m_shape,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, body: any, restore: any): Fixture {\n const shape = restore(Shape, data.shape);\n const fixture = shape && new Fixture(body, shape, data);\n return fixture;\n }\n\n /**\n * Get the type of the child shape. You can use this to down cast to the\n * concrete shape.\n */\n getType(): ShapeType {\n return this.m_shape.m_type;\n }\n\n /**\n * Get the child shape. You can modify the child shape, however you should not\n * change the number of vertices because this will crash some collision caching\n * mechanisms. Manipulating the shape may lead to non-physical behavior.\n */\n getShape(): Shape {\n return this.m_shape;\n }\n\n /**\n * A sensor shape collects contact information but never generates a collision\n * response.\n */\n isSensor(): boolean {\n return this.m_isSensor;\n }\n\n /**\n * Set if this fixture is a sensor.\n */\n setSensor(sensor: boolean): void {\n if (sensor != this.m_isSensor) {\n this.m_body.setAwake(true);\n this.m_isSensor = sensor;\n }\n }\n\n // /**\n // * Get the contact filtering data.\n // */\n // getFilterData() {\n // return this.m_filter;\n // }\n\n /**\n * Get the user data that was assigned in the fixture definition. Use this to\n * store your application specific data.\n */\n getUserData(): unknown {\n return this.m_userData;\n }\n\n /**\n * Set the user data. Use this to store your application specific data.\n */\n setUserData(data: unknown): void {\n this.m_userData = data;\n }\n\n /**\n * Get the parent body of this fixture. This is null if the fixture is not\n * attached.\n */\n getBody(): Body {\n return this.m_body;\n }\n\n /**\n * Get the next fixture in the parent body's fixture list.\n */\n getNext(): Fixture | null {\n return this.m_next;\n }\n\n /**\n * Get the density of this fixture.\n */\n getDensity(): number {\n return this.m_density;\n }\n\n /**\n * Set the density of this fixture. This will _not_ automatically adjust the\n * mass of the body. You must call Body.resetMassData to update the body's mass.\n */\n setDensity(density: number): void {\n if (_ASSERT) console.assert(Number.isFinite(density) && density >= 0.0);\n this.m_density = density;\n }\n\n /**\n * Get the coefficient of friction, usually in the range [0,1].\n */\n getFriction(): number {\n return this.m_friction;\n }\n\n /**\n * Set the coefficient of friction. This will not change the friction of\n * existing contacts.\n */\n setFriction(friction: number): void {\n this.m_friction = friction;\n }\n\n /**\n * Get the coefficient of restitution.\n */\n getRestitution(): number {\n return this.m_restitution;\n }\n\n /**\n * Set the coefficient of restitution. This will not change the restitution of\n * existing contacts.\n */\n setRestitution(restitution: number): void {\n this.m_restitution = restitution;\n }\n\n /**\n * Test a point in world coordinates for containment in this fixture.\n */\n testPoint(p: Vec2Value): boolean {\n return this.m_shape.testPoint(this.m_body.getTransform(), p);\n }\n\n /**\n * Cast a ray against this shape.\n */\n rayCast(output: RayCastOutput, input: RayCastInput, childIndex: number): boolean {\n return this.m_shape.rayCast(output, input, this.m_body.getTransform(), childIndex);\n }\n\n /**\n * Get the mass data for this fixture. The mass data is based on the density and\n * the shape. The rotational inertia is about the shape's origin. This operation\n * may be expensive.\n */\n getMassData(massData: MassData): void {\n this.m_shape.computeMass(massData, this.m_density);\n }\n\n /**\n * Get the fixture's AABB. This AABB may be enlarge and/or stale. If you need a\n * more accurate AABB, compute it using the shape and the body transform.\n */\n getAABB(childIndex: number): AABB {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_proxies.length);\n return this.m_proxies[childIndex].aabb;\n }\n\n /**\n * These support body activation/deactivation.\n */\n createProxies(broadPhase: BroadPhase, xf: TransformValue): void {\n if (_ASSERT) console.assert(this.m_proxyCount == 0);\n\n // Create proxies in the broad-phase.\n this.m_proxyCount = this.m_shape.getChildCount();\n\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n this.m_shape.computeAABB(proxy.aabb, xf, i);\n proxy.proxyId = broadPhase.createProxy(proxy.aabb, proxy);\n }\n }\n\n destroyProxies(broadPhase: BroadPhase): void {\n // Destroy proxies in the broad-phase.\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n broadPhase.destroyProxy(proxy.proxyId);\n proxy.proxyId = null;\n }\n\n this.m_proxyCount = 0;\n }\n\n /**\n * Updates this fixture proxy in broad-phase (with combined AABB of current and\n * next transformation).\n */\n synchronize(broadPhase: BroadPhase, xf1: TransformValue, xf2: TransformValue): void {\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n // Compute an AABB that covers the swept shape (may miss some rotation\n // effect).\n this.m_shape.computeAABB(synchronize_aabb1, xf1, proxy.childIndex);\n this.m_shape.computeAABB(synchronize_aabb2, xf2, proxy.childIndex);\n\n proxy.aabb.combine(synchronize_aabb1, synchronize_aabb2);\n\n matrix.subVec2(displacement, xf2.p, xf1.p);\n\n broadPhase.moveProxy(proxy.proxyId, proxy.aabb, displacement);\n }\n }\n\n /**\n * Set the contact filtering data. This will not update contacts until the next\n * time step when either parent body is active and awake. This automatically\n * calls refilter.\n */\n setFilterData(filter: { groupIndex: number, categoryBits: number, maskBits: number }): void {\n this.m_filterGroupIndex = filter.groupIndex;\n this.m_filterCategoryBits = filter.categoryBits;\n this.m_filterMaskBits = filter.maskBits;\n this.refilter();\n }\n\n getFilterGroupIndex(): number {\n return this.m_filterGroupIndex;\n }\n\n setFilterGroupIndex(groupIndex: number): void {\n this.m_filterGroupIndex = groupIndex;\n this.refilter();\n }\n\n getFilterCategoryBits(): number {\n return this.m_filterCategoryBits;\n }\n\n setFilterCategoryBits(categoryBits: number): void {\n this.m_filterCategoryBits = categoryBits;\n this.refilter();\n }\n\n getFilterMaskBits(): number {\n return this.m_filterMaskBits;\n }\n\n setFilterMaskBits(maskBits: number): void {\n this.m_filterMaskBits = maskBits;\n this.refilter();\n }\n\n /**\n * Call this if you want to establish collision that was previously disabled by\n * ContactFilter.\n */\n refilter(): void {\n if (this.m_body == null) {\n return;\n }\n\n // Flag associated contacts for filtering.\n let edge = this.m_body.getContactList();\n while (edge) {\n const contact = edge.contact;\n const fixtureA = contact.getFixtureA();\n const fixtureB = contact.getFixtureB();\n if (fixtureA == this || fixtureB == this) {\n contact.flagForFiltering();\n }\n\n edge = edge.next;\n }\n\n const world = this.m_body.getWorld();\n\n if (world == null) {\n return;\n }\n\n // Touch each proxy so that new pairs may be created\n const broadPhase = world.m_broadPhase;\n for (let i = 0; i < this.m_proxyCount; ++i) {\n broadPhase.touchProxy(this.m_proxies[i].proxyId);\n }\n }\n\n /**\n * Implement this method to provide collision filtering, if you want finer\n * control over contact creation.\n *\n * Return true if contact calculations should be performed between these two\n * fixtures.\n *\n * Warning: for performance reasons this is only called when the AABBs begin to\n * overlap.\n */\n shouldCollide(that: Fixture): boolean {\n\n if (that.m_filterGroupIndex === this.m_filterGroupIndex && that.m_filterGroupIndex !== 0) {\n return that.m_filterGroupIndex > 0;\n }\n\n const collideA = (that.m_filterMaskBits & this.m_filterCategoryBits) !== 0;\n const collideB = (that.m_filterCategoryBits & this.m_filterMaskBits) !== 0;\n const collide = collideA && collideB;\n return collide;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { options } from \"../util/options\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { Rot } from \"../common/Rot\";\nimport { Sweep } from \"../common/Sweep\";\nimport { Transform, TransformValue } from \"../common/Transform\";\nimport { Velocity } from \"./Velocity\";\nimport { Position } from \"./Position\";\nimport { Fixture, FixtureDef, FixtureOpt } from \"./Fixture\";\nimport { Shape } from \"../collision/Shape\";\nimport { JointEdge } from \"./Joint\";\nimport { World } from \"./World\";\nimport { ContactEdge } from \"./Contact\";\nimport { Style } from \"../util/Testbed\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A static body does not move under simulation and behaves as if it has infinite mass.\n * Internally, zero is stored for the mass and the inverse mass.\n * Static bodies can be moved manually by the user.\n * A static body has zero velocity.\n * Static bodies do not collide with other static or kinematic bodies.\n * \n * A kinematic body moves under simulation according to its velocity.\n * Kinematic bodies do not respond to forces.\n * They can be moved manually by the user, but normally a kinematic body is moved by setting its velocity.\n * A kinematic body behaves as if it has infinite mass, however, zero is stored for the mass and the inverse mass.\n * Kinematic bodies do not collide with other kinematic or static bodies.\n * \n * A dynamic body is fully simulated.\n * They can be moved manually by the user, but normally they move according to forces.\n * A dynamic body can collide with all body types.\n * A dynamic body always has finite, non-zero mass.\n * If you try to set the mass of a dynamic body to zero, it will automatically acquire a mass of one kilogram and it won't rotate.\n */\nexport type BodyType = \"static\" | \"kinematic\" | \"dynamic\";\n\n/** @internal */ const STATIC = \"static\";\n/** @internal */ const KINEMATIC = \"kinematic\";\n/** @internal */ const DYNAMIC = \"dynamic\";\n\n/** @internal */ const oldCenter = matrix.vec2(0, 0);\n/** @internal */ const localCenter = matrix.vec2(0, 0);\n/** @internal */ const shift = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n\nexport interface BodyDef {\n /**\n * Body types are static, kinematic, or dynamic. Note: if a dynamic\n * body would have zero mass, the mass is set to one.\n */\n type?: BodyType;\n /**\n * The world position of the body. Avoid creating bodies at the\n * origin since this can lead to many overlapping shapes.\n */\n position?: Vec2Value;\n /**\n * The world angle of the body in radians.\n */\n angle?: number;\n /**\n * The linear velocity of the body's origin in world co-ordinates.\n */\n linearVelocity?: Vec2Value;\n angularVelocity?: number;\n /**\n * Linear damping is use to reduce the linear velocity. The\n * damping parameter can be larger than 1.0 but the damping effect becomes\n * sensitive to the time step when the damping parameter is large.\n * Units are 1/time\n */\n linearDamping?: number;\n /**\n * Angular damping is use to reduce the angular velocity.\n * The damping parameter can be larger than 1.0 but the damping effect\n * becomes sensitive to the time step when the damping parameter is large.\n * Units are 1/time\n */\n angularDamping?: number;\n /**\n * Should this body be prevented from rotating? Useful for characters.\n */\n fixedRotation?: boolean;\n /**\n * Is this a fast moving body that should be prevented from\n * tunneling through other moving bodies? Note that all bodies are\n * prevented from tunneling through kinematic and static bodies. This\n * setting is only considered on dynamic bodies. Warning: You should use\n * this flag sparingly since it increases processing time.\n */\n bullet?: boolean;\n gravityScale?: number;\n /**\n * Set this flag to false if this body should never fall asleep. Note that this increases CPU usage.\n */\n allowSleep?: boolean;\n /**\n * Is this body initially awake or sleeping?\n */\n awake?: boolean;\n /**\n * Does this body start out active?\n */\n active?: boolean;\n userData?: any;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\n/** @internal */ const BodyDefDefault: BodyDef = {\n type : STATIC,\n position : Vec2.zero(),\n angle : 0.0,\n\n linearVelocity : Vec2.zero(),\n angularVelocity : 0.0,\n\n linearDamping : 0.0,\n angularDamping : 0.0,\n\n fixedRotation : false,\n bullet : false,\n gravityScale : 1.0,\n\n allowSleep : true,\n awake : true,\n active : true,\n\n userData : null\n};\n\n/**\n * MassData This holds the mass data computed for a shape.\n */\nexport interface MassData {\n /** The mass of the shape, usually in kilograms. */\n mass: number;\n /** The position of the shape's centroid relative to the shape's origin. */\n center: Vec2Value;\n /** The rotational inertia of the shape about the local origin. */\n I: number;\n}\n\n/**\n * A rigid body composed of one or more fixtures.\n *\n * To create a new Body use {@link World.createBody}.\n */\nexport class Body {\n /** @hidden */\n static readonly STATIC: BodyType = \"static\";\n /** @hidden */\n static readonly KINEMATIC: BodyType = \"kinematic\";\n /** @hidden */\n static readonly DYNAMIC: BodyType = \"dynamic\";\n\n /** @internal */ m_world: World;\n /** @internal */ m_awakeFlag: boolean;\n /** @internal */ m_autoSleepFlag: boolean;\n /** @internal */ m_bulletFlag: boolean;\n /** @internal */ m_fixedRotationFlag: boolean;\n /** @internal */ m_activeFlag: boolean;\n /** @internal */ m_islandFlag: boolean;\n /** @internal */ m_toiFlag: boolean;\n /** @internal */ m_userData: unknown;\n /** @internal */ m_type: BodyType;\n /** @internal */ m_mass: number;\n /** @internal */ m_invMass: number;\n /** @internal Rotational inertia about the center of mass. */\n m_I: number;\n /** @internal */ m_invI: number;\n /** @internal the body origin transform */\n m_xf: Transform;\n /** @internal the swept motion for CCD */\n m_sweep: Sweep;\n // position and velocity correction\n /** @internal */ c_velocity: Velocity;\n /** @internal */ c_position: Position;\n /** @internal */ m_force: Vec2;\n /** @internal */ m_torque: number;\n /** @internal */ m_linearVelocity: Vec2;\n /** @internal */ m_angularVelocity: number;\n /** @internal */ m_linearDamping: number;\n /** @internal */ m_angularDamping: number;\n /** @internal */ m_gravityScale: number;\n /** @internal */ m_sleepTime: number;\n /** @internal */ m_jointList: JointEdge | null;\n /** @internal */ m_contactList: ContactEdge | null;\n /** @internal */ m_fixtureList: Fixture | null;\n /** @internal */ m_prev: Body | null;\n /** @internal */ m_next: Body | null;\n /** @internal */ m_destroyed: boolean;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n /** @internal */\n constructor(world: World, def: BodyDef) {\n def = options(def, BodyDefDefault);\n\n if (_ASSERT) console.assert(Vec2.isValid(def.position));\n if (_ASSERT) console.assert(Vec2.isValid(def.linearVelocity));\n if (_ASSERT) console.assert(Number.isFinite(def.angle));\n if (_ASSERT) console.assert(Number.isFinite(def.angularVelocity));\n if (_ASSERT) console.assert(Number.isFinite(def.angularDamping) && def.angularDamping >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.linearDamping) && def.linearDamping >= 0.0);\n\n this.m_world = world;\n\n this.m_awakeFlag = def.awake;\n this.m_autoSleepFlag = def.allowSleep;\n this.m_bulletFlag = def.bullet;\n this.m_fixedRotationFlag = def.fixedRotation;\n this.m_activeFlag = def.active;\n\n this.m_islandFlag = false;\n this.m_toiFlag = false;\n\n this.m_userData = def.userData;\n this.m_type = def.type;\n\n if (this.m_type == DYNAMIC) {\n this.m_mass = 1.0;\n this.m_invMass = 1.0;\n } else {\n this.m_mass = 0.0;\n this.m_invMass = 0.0;\n }\n\n // Rotational inertia about the center of mass.\n this.m_I = 0.0;\n this.m_invI = 0.0;\n\n // the body origin transform\n this.m_xf = Transform.identity();\n this.m_xf.p.setVec2(def.position);\n this.m_xf.q.setAngle(def.angle);\n\n // the swept motion for CCD\n this.m_sweep = new Sweep();\n this.m_sweep.setTransform(this.m_xf);\n\n // position and velocity correction\n this.c_velocity = new Velocity();\n this.c_position = new Position();\n\n this.m_force = Vec2.zero();\n this.m_torque = 0.0;\n\n this.m_linearVelocity = Vec2.clone(def.linearVelocity);\n this.m_angularVelocity = def.angularVelocity;\n\n this.m_linearDamping = def.linearDamping;\n this.m_angularDamping = def.angularDamping;\n this.m_gravityScale = def.gravityScale;\n\n this.m_sleepTime = 0.0;\n\n this.m_jointList = null;\n this.m_contactList = null;\n this.m_fixtureList = null;\n\n this.m_prev = null;\n this.m_next = null;\n\n this.m_destroyed = false;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /** @internal */\n _serialize(): object {\n const fixtures = [];\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n fixtures.push(f);\n }\n return {\n type: this.m_type,\n bullet: this.m_bulletFlag,\n position: this.m_xf.p,\n angle: this.m_xf.q.getAngle(),\n linearVelocity: this.m_linearVelocity,\n angularVelocity: this.m_angularVelocity,\n fixtures,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): Body {\n const body = new Body(world, data);\n\n if (data.fixtures) {\n for (let i = data.fixtures.length - 1; i >= 0; i--) {\n const fixture = restore(Fixture, data.fixtures[i], body);\n body._addFixture(fixture);\n }\n }\n return body;\n }\n\n isWorldLocked(): boolean {\n return this.m_world && this.m_world.isLocked() ? true : false;\n }\n\n getWorld(): World {\n return this.m_world;\n }\n\n getNext(): Body | null {\n return this.m_next;\n }\n\n setUserData(data: any): void {\n this.m_userData = data;\n }\n\n getUserData(): unknown {\n return this.m_userData;\n }\n\n getFixtureList(): Fixture | null {\n return this.m_fixtureList;\n }\n\n getJointList(): JointEdge | null {\n return this.m_jointList;\n }\n\n /**\n * Warning: this list changes during the time step and you may miss some\n * collisions if you don't use ContactListener.\n */\n getContactList(): ContactEdge | null {\n return this.m_contactList;\n }\n\n isStatic(): boolean {\n return this.m_type == STATIC;\n }\n\n isDynamic(): boolean {\n return this.m_type == DYNAMIC;\n }\n\n isKinematic(): boolean {\n return this.m_type == KINEMATIC;\n }\n\n /**\n * This will alter the mass and velocity.\n */\n setStatic(): Body {\n this.setType(STATIC);\n return this;\n }\n\n setDynamic(): Body {\n this.setType(DYNAMIC);\n return this;\n }\n\n setKinematic(): Body {\n this.setType(KINEMATIC);\n return this;\n }\n\n /**\n * Get the type of the body.\n */\n getType(): BodyType {\n return this.m_type;\n }\n\n /**\n * Set the type of the body to \"static\", \"kinematic\" or \"dynamic\".\n * @param type The type of the body.\n */\n setType(type: BodyType): void {\n if (_ASSERT) console.assert(type === STATIC || type === KINEMATIC || type === DYNAMIC);\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (this.m_type == type) {\n return;\n }\n\n this.m_type = type;\n\n this.resetMassData();\n\n if (this.m_type == STATIC) {\n this.m_linearVelocity.setZero();\n this.m_angularVelocity = 0.0;\n this.m_sweep.forward();\n this.synchronizeFixtures();\n }\n\n this.setAwake(true);\n\n this.m_force.setZero();\n this.m_torque = 0.0;\n\n // Delete the attached contacts.\n let ce = this.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n this.m_world.destroyContact(ce0.contact);\n }\n this.m_contactList = null;\n\n // Touch the proxies so that new contacts will be created (when appropriate)\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n for (let i = 0; i < f.m_proxyCount; ++i) {\n broadPhase.touchProxy(f.m_proxies[i].proxyId);\n }\n }\n }\n\n isBullet(): boolean {\n return this.m_bulletFlag;\n }\n\n /**\n * Should this body be treated like a bullet for continuous collision detection?\n */\n setBullet(flag: boolean): void {\n this.m_bulletFlag = !!flag;\n }\n\n isSleepingAllowed(): boolean {\n return this.m_autoSleepFlag;\n }\n\n setSleepingAllowed(flag: boolean): void {\n this.m_autoSleepFlag = !!flag;\n if (this.m_autoSleepFlag == false) {\n this.setAwake(true);\n }\n }\n\n isAwake(): boolean {\n return this.m_awakeFlag;\n }\n\n /**\n * Set the sleep state of the body. A sleeping body has very low CPU cost.\n *\n * @param flag Set to true to wake the body, false to put it to sleep.\n */\n setAwake(flag: boolean): void {\n if (flag) {\n this.m_awakeFlag = true;\n this.m_sleepTime = 0.0;\n } else {\n this.m_awakeFlag = false;\n this.m_sleepTime = 0.0;\n this.m_linearVelocity.setZero();\n this.m_angularVelocity = 0.0;\n this.m_force.setZero();\n this.m_torque = 0.0;\n }\n }\n\n isActive(): boolean {\n return this.m_activeFlag;\n }\n\n /**\n * Set the active state of the body. An inactive body is not simulated and\n * cannot be collided with or woken up. If you pass a flag of true, all fixtures\n * will be added to the broad-phase. If you pass a flag of false, all fixtures\n * will be removed from the broad-phase and all contacts will be destroyed.\n * Fixtures and joints are otherwise unaffected.\n *\n * You may continue to create/destroy fixtures and joints on inactive bodies.\n * Fixtures on an inactive body are implicitly inactive and will not participate\n * in collisions, ray-casts, or queries. Joints connected to an inactive body\n * are implicitly inactive. An inactive body is still owned by a World object\n * and remains\n */\n setActive(flag: boolean): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (flag == this.m_activeFlag) {\n return;\n }\n\n this.m_activeFlag = !!flag;\n\n if (this.m_activeFlag) {\n // Create all proxies.\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.createProxies(broadPhase, this.m_xf);\n }\n\t\t // Contacts are created at the beginning of the next\n\t\t this.m_world.m_newFixture = true;\n } else {\n // Destroy all proxies.\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.destroyProxies(broadPhase);\n }\n\n // Destroy the attached contacts.\n let ce = this.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n this.m_world.destroyContact(ce0.contact);\n }\n this.m_contactList = null;\n }\n }\n\n isFixedRotation(): boolean {\n return this.m_fixedRotationFlag;\n }\n\n /**\n * Set this body to have fixed rotation. This causes the mass to be reset.\n */\n setFixedRotation(flag: boolean): void {\n if (this.m_fixedRotationFlag == flag) {\n return;\n }\n\n this.m_fixedRotationFlag = !!flag;\n\n this.m_angularVelocity = 0.0;\n\n this.resetMassData();\n }\n\n /**\n * Get the world transform for the body's origin.\n */\n getTransform(): Transform {\n return this.m_xf;\n }\n\n /**\n * Set the position of the body's origin and rotation. Manipulating a body's\n * transform may cause non-physical behavior. Note: contacts are updated on the\n * next call to World.step.\n *\n * @param position The world position of the body's local origin.\n * @param angle The world rotation in radians.\n */\n setTransform(position: Vec2Value, angle: number): void;\n /**\n * Set the position of the body's origin and rotation. Manipulating a body's\n * transform may cause non-physical behavior. Note: contacts are updated on the\n * next call to World.step.\n */\n setTransform(xf: Transform): void;\n setTransform(a: Vec2Value | Transform, b?: number): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return;\n }\n if (typeof b === \"number\") {\n this.m_xf.setNum(a as Vec2Value, b);\n } else {\n this.m_xf.setTransform(a as TransformValue);\n }\n\n this.m_sweep.setTransform(this.m_xf);\n\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.synchronize(broadPhase, this.m_xf, this.m_xf);\n }\n this.setAwake(true);\n }\n\n synchronizeTransform(): void {\n this.m_sweep.getTransform(this.m_xf, 1);\n }\n\n /**\n * Update fixtures in broad-phase.\n */\n synchronizeFixtures(): void {\n this.m_sweep.getTransform(xf, 0);\n\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.synchronize(broadPhase, xf, this.m_xf);\n }\n }\n\n /**\n * Used in TOI.\n */\n advance(alpha: number): void {\n // Advance to the new safe time. This doesn't sync the broad-phase.\n this.m_sweep.advance(alpha);\n matrix.copyVec2(this.m_sweep.c, this.m_sweep.c0);\n this.m_sweep.a = this.m_sweep.a0;\n this.m_sweep.getTransform(this.m_xf, 1);\n }\n\n /**\n * Get the world position for the body's origin.\n */\n getPosition(): Vec2 {\n return this.m_xf.p;\n }\n\n setPosition(p: Vec2Value): void {\n this.setTransform(p, this.m_sweep.a);\n }\n\n /**\n * Get the current world rotation angle in radians.\n */\n getAngle(): number {\n return this.m_sweep.a;\n }\n\n setAngle(angle: number): void {\n this.setTransform(this.m_xf.p, angle);\n }\n\n /**\n * Get the world position of the center of mass.\n */\n getWorldCenter(): Vec2 {\n return this.m_sweep.c;\n }\n\n /**\n * Get the local position of the center of mass.\n */\n getLocalCenter(): Vec2 {\n return this.m_sweep.localCenter;\n }\n\n /**\n * Get the linear velocity of the center of mass.\n *\n * @return the linear velocity of the center of mass.\n */\n getLinearVelocity(): Vec2 {\n return this.m_linearVelocity;\n }\n\n /**\n * Get the world linear velocity of a world point attached to this body.\n *\n * @param worldPoint A point in world coordinates.\n */\n getLinearVelocityFromWorldPoint(worldPoint: Vec2Value): Vec2 {\n const localCenter = Vec2.sub(worldPoint, this.m_sweep.c);\n return Vec2.add(this.m_linearVelocity, Vec2.crossNumVec2(this.m_angularVelocity,\n localCenter));\n }\n\n /**\n * Get the world velocity of a local point.\n *\n * @param localPoint A point in local coordinates.\n */\n getLinearVelocityFromLocalPoint(localPoint: Vec2Value): Vec2 {\n return this.getLinearVelocityFromWorldPoint(this.getWorldPoint(localPoint));\n }\n\n /**\n * Set the linear velocity of the center of mass.\n *\n * @param v The new linear velocity of the center of mass.\n */\n setLinearVelocity(v: Vec2Value): void {\n if (this.m_type == STATIC) {\n return;\n }\n if (Vec2.dot(v, v) > 0.0) {\n this.setAwake(true);\n }\n this.m_linearVelocity.setVec2(v);\n }\n\n /**\n * Get the angular velocity.\n *\n * @returns the angular velocity in radians/second.\n */\n getAngularVelocity(): number {\n return this.m_angularVelocity;\n }\n\n /**\n * Set the angular velocity.\n *\n * @param w The new angular velocity in radians/second.\n */\n setAngularVelocity(w: number): void {\n if (this.m_type == STATIC) {\n return;\n }\n if (w * w > 0.0) {\n this.setAwake(true);\n }\n this.m_angularVelocity = w;\n }\n\n getLinearDamping(): number {\n return this.m_linearDamping;\n }\n\n setLinearDamping(linearDamping: number): void {\n this.m_linearDamping = linearDamping;\n }\n\n getAngularDamping(): number {\n return this.m_angularDamping;\n }\n\n setAngularDamping(angularDamping: number): void {\n this.m_angularDamping = angularDamping;\n }\n\n getGravityScale(): number {\n return this.m_gravityScale;\n }\n\n /**\n * Scale the gravity applied to this body.\n */\n setGravityScale(scale: number): void {\n this.m_gravityScale = scale;\n }\n\n /**\n * Get the total mass of the body.\n *\n * @returns The mass, usually in kilograms (kg).\n */\n getMass(): number {\n return this.m_mass;\n }\n\n /**\n * Get the rotational inertia of the body about the local origin.\n *\n * @return the rotational inertia, usually in kg-m^2.\n */\n getInertia(): number {\n return this.m_I + this.m_mass\n * Vec2.dot(this.m_sweep.localCenter, this.m_sweep.localCenter);\n }\n\n /**\n * Copy the mass data of the body to data.\n */\n getMassData(data: MassData): void {\n data.mass = this.m_mass;\n data.I = this.getInertia();\n matrix.copyVec2(data.center, this.m_sweep.localCenter);\n }\n\n /**\n * This resets the mass properties to the sum of the mass properties of the\n * fixtures. This normally does not need to be called unless you called\n * SetMassData to override the mass and you later want to reset the mass.\n */\n resetMassData(): void {\n // Compute mass data from shapes. Each shape has its own density.\n this.m_mass = 0.0;\n this.m_invMass = 0.0;\n this.m_I = 0.0;\n this.m_invI = 0.0;\n matrix.zeroVec2(this.m_sweep.localCenter);\n\n // Static and kinematic bodies have zero mass.\n if (this.isStatic() || this.isKinematic()) {\n matrix.copyVec2(this.m_sweep.c0, this.m_xf.p);\n matrix.copyVec2(this.m_sweep.c, this.m_xf.p);\n this.m_sweep.a0 = this.m_sweep.a;\n return;\n }\n\n if (_ASSERT) console.assert(this.isDynamic());\n\n // Accumulate mass over all fixtures.\n matrix.zeroVec2(localCenter);\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n if (f.m_density == 0.0) {\n continue;\n }\n\n const massData: MassData = {\n mass: 0,\n center: matrix.vec2(0, 0),\n I: 0\n };\n f.getMassData(massData);\n this.m_mass += massData.mass;\n matrix.plusScaleVec2(localCenter, massData.mass, massData.center);\n this.m_I += massData.I;\n }\n\n // Compute center of mass.\n if (this.m_mass > 0.0) {\n this.m_invMass = 1.0 / this.m_mass;\n matrix.scaleVec2(localCenter, this.m_invMass, localCenter);\n\n } else {\n // Force all dynamic bodies to have a positive mass.\n this.m_mass = 1.0;\n this.m_invMass = 1.0;\n }\n\n if (this.m_I > 0.0 && this.m_fixedRotationFlag == false) {\n // Center the inertia about the center of mass.\n this.m_I -= this.m_mass * matrix.dotVec2(localCenter, localCenter);\n if (_ASSERT) console.assert(this.m_I > 0.0);\n this.m_invI = 1.0 / this.m_I;\n\n } else {\n this.m_I = 0.0;\n this.m_invI = 0.0;\n }\n\n // Move center of mass.\n matrix.copyVec2(oldCenter, this.m_sweep.c);\n this.m_sweep.setLocalCenter(localCenter, this.m_xf);\n\n // Update center of mass velocity.\n matrix.subVec2(shift, this.m_sweep.c, oldCenter);\n matrix.crossNumVec2(temp, this.m_angularVelocity, shift);\n matrix.plusVec2(this.m_linearVelocity, temp);\n }\n\n /**\n * Set the mass properties to override the mass properties of the fixtures. Note\n * that this changes the center of mass position. Note that creating or\n * destroying fixtures can also alter the mass. This function has no effect if\n * the body isn't dynamic.\n *\n * @param massData The mass properties.\n */\n setMassData(massData: MassData): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (this.m_type != DYNAMIC) {\n return;\n }\n\n this.m_invMass = 0.0;\n this.m_I = 0.0;\n this.m_invI = 0.0;\n\n this.m_mass = massData.mass;\n if (this.m_mass <= 0.0) {\n this.m_mass = 1.0;\n }\n\n this.m_invMass = 1.0 / this.m_mass;\n\n if (massData.I > 0.0 && this.m_fixedRotationFlag == false) {\n this.m_I = massData.I - this.m_mass * matrix.dotVec2(massData.center, massData.center);\n if (_ASSERT) console.assert(this.m_I > 0.0);\n this.m_invI = 1.0 / this.m_I;\n }\n\n // Move center of mass.\n matrix.copyVec2(oldCenter, this.m_sweep.c);\n this.m_sweep.setLocalCenter(massData.center, this.m_xf);\n\n // Update center of mass velocity.\n matrix.subVec2(shift, this.m_sweep.c, oldCenter);\n matrix.crossNumVec2(temp, this.m_angularVelocity, shift);\n matrix.plusVec2(this.m_linearVelocity, temp);\n }\n\n /**\n * Apply a force at a world point. If the force is not applied at the center of\n * mass, it will generate a torque and affect the angular velocity. This wakes\n * up the body.\n *\n * @param force The world force vector, usually in Newtons (N).\n * @param point The world position of the point of application.\n * @param wake Also wake up the body\n */\n applyForce(force: Vec2Value, point: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping.\n if (this.m_awakeFlag) {\n this.m_force.add(force);\n this.m_torque += Vec2.crossVec2Vec2(Vec2.sub(point, this.m_sweep.c), force);\n }\n }\n\n /**\n * Apply a force to the center of mass. This wakes up the body.\n *\n * @param force The world force vector, usually in Newtons (N).\n * @param wake Also wake up the body\n */\n applyForceToCenter(force: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_force.add(force);\n }\n }\n\n /**\n * Apply a torque. This affects the angular velocity without affecting the\n * linear velocity of the center of mass. This wakes up the body.\n *\n * @param torque About the z-axis (out of the screen), usually in N-m.\n * @param wake Also wake up the body\n */\n applyTorque(torque: number, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_torque += torque;\n }\n }\n\n /**\n * Apply an impulse at a point. This immediately modifies the velocity. It also\n * modifies the angular velocity if the point of application is not at the\n * center of mass. This wakes up the body.\n *\n * @param impulse The world impulse vector, usually in N-seconds or kg-m/s.\n * @param point The world position of the point of application.\n * @param wake Also wake up the body\n */\n applyLinearImpulse(impulse: Vec2Value, point: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n\n // Don't accumulate velocity if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_linearVelocity.addMul(this.m_invMass, impulse);\n this.m_angularVelocity += this.m_invI * Vec2.crossVec2Vec2(Vec2.sub(point, this.m_sweep.c), impulse);\n }\n }\n\n /**\n * Apply an angular impulse.\n *\n * @param impulse The angular impulse in units of kg*m*m/s\n * @param wake Also wake up the body\n */\n applyAngularImpulse(impulse: number, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate velocity if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_angularVelocity += this.m_invI * impulse;\n }\n }\n\n /**\n * This is used to test if two bodies should collide.\n * \n * Bodies do not collide when:\n * - Neither of them is dynamic\n * - They are connected by a joint with collideConnected == false\n */\n shouldCollide(that: Body): boolean {\n // At least one body should be dynamic.\n if (this.m_type != DYNAMIC && that.m_type != DYNAMIC) {\n return false;\n }\n // Does a joint prevent collision?\n for (let jn = this.m_jointList; jn; jn = jn.next) {\n if (jn.other == that) {\n if (jn.joint.m_collideConnected == false) {\n return false;\n }\n }\n }\n return true;\n }\n\n /** @internal Used for deserialize. */\n _addFixture(fixture: Fixture): Fixture {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return null;\n }\n\n if (this.m_activeFlag) {\n const broadPhase = this.m_world.m_broadPhase;\n fixture.createProxies(broadPhase, this.m_xf);\n }\n\n fixture.m_next = this.m_fixtureList;\n this.m_fixtureList = fixture;\n\n // Adjust mass properties if needed.\n if (fixture.m_density > 0.0) {\n this.resetMassData();\n }\n\n // Let the world know we have a new fixture. This will cause new contacts\n // to be created at the beginning of the next time step.\n this.m_world.m_newFixture = true;\n\n return fixture;\n }\n\n /**\n * Creates a fixture and attach it to this body.\n *\n * If the density is non-zero, this function automatically updates the mass of\n * the body.\n *\n * Contacts are not created until the next time step.\n *\n * Warning: This function is locked during callbacks.\n */\n createFixture(def: FixtureDef): Fixture;\n createFixture(shape: Shape, opt?: FixtureOpt): Fixture;\n createFixture(shape: Shape, density?: number): Fixture;\n // tslint:disable-next-line:typedef\n createFixture(shape, fixdef?) {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return null;\n }\n\n const fixture = new Fixture(this, shape, fixdef);\n this._addFixture(fixture);\n return fixture;\n }\n\n /**\n * Destroy a fixture. This removes the fixture from the broad-phase and destroys\n * all contacts associated with this fixture. This will automatically adjust the\n * mass of the body if the body is dynamic and the fixture has positive density.\n * All fixtures attached to a body are implicitly destroyed when the body is\n * destroyed.\n *\n * Warning: This function is locked during callbacks.\n *\n * @param fixture The fixture to be removed.\n */\n destroyFixture(fixture: Fixture): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (_ASSERT) console.assert(fixture.m_body == this);\n\n // Remove the fixture from this body's singly linked list.\n let found = false;\n if (this.m_fixtureList === fixture) {\n this.m_fixtureList = fixture.m_next;\n found = true;\n\n } else {\n let node = this.m_fixtureList;\n while (node != null) {\n if (node.m_next === fixture) {\n node.m_next = fixture.m_next;\n found = true;\n break;\n }\n node = node.m_next;\n }\n }\n\n // You tried to remove a shape that is not attached to this body.\n if (_ASSERT) console.assert(found);\n\n // Destroy any contacts associated with the fixture.\n let edge = this.m_contactList;\n while (edge) {\n const c = edge.contact;\n edge = edge.next;\n\n const fixtureA = c.getFixtureA();\n const fixtureB = c.getFixtureB();\n\n if (fixture == fixtureA || fixture == fixtureB) {\n // This destroys the contact and removes it from\n // this body's contact list.\n this.m_world.destroyContact(c);\n }\n }\n\n if (this.m_activeFlag) {\n const broadPhase = this.m_world.m_broadPhase;\n fixture.destroyProxies(broadPhase);\n }\n\n fixture.m_body = null;\n fixture.m_next = null;\n\n this.m_world.publish(\"remove-fixture\", fixture);\n\n // Reset the mass data.\n this.resetMassData();\n }\n\n /**\n * Get the corresponding world point of a local point.\n */\n getWorldPoint(localPoint: Vec2Value): Vec2 {\n return Transform.mulVec2(this.m_xf, localPoint);\n }\n\n /**\n * Get the corresponding world vector of a local vector.\n */\n getWorldVector(localVector: Vec2Value): Vec2 {\n return Rot.mulVec2(this.m_xf.q, localVector);\n }\n\n /**\n * Gets the corresponding local point of a world point.\n */\n getLocalPoint(worldPoint: Vec2Value): Vec2 {\n return Transform.mulTVec2(this.m_xf, worldPoint);\n }\n\n /**\n * Gets the corresponding local vector of a world vector.\n */\n getLocalVector(worldVector: Vec2Value): Vec2 {\n return Rot.mulTVec2(this.m_xf.q, worldVector);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { Vec2, Vec2Value } from \"../common/Vec2\";\nimport type { Body } from \"./Body\";\nimport { TimeStep } from \"./Solver\";\nimport { Style } from \"../util/Testbed\";\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/**\n * A joint edge is used to connect bodies and joints together in a joint graph\n * where each body is a node and each joint is an edge. A joint edge belongs to\n * a doubly linked list maintained in each attached body. Each joint has two\n * joint nodes, one for each attached body.\n */\nexport class JointEdge {\n /**\n * provides quick access to the other body attached.\n */\n other: Body | null = null;\n /**\n * the joint\n */\n joint: Joint | null = null;\n /**\n * prev the previous joint edge in the body's joint list\n */\n prev: JointEdge | null = null;\n /**\n * the next joint edge in the body's joint list\n */\n next: JointEdge | null = null;\n}\n\n/**\n * Joint definitions are used to construct joints.\n */\nexport interface JointOpt {\n /**\n * Use this to attach application specific data to your joints.\n */\n userData?: any;\n /**\n * Set this flag to true if the attached bodies\n * should collide.\n */\n collideConnected?: boolean;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\n/**\n * Joint definitions are used to construct joints.\n */\nexport interface JointDef extends JointOpt {\n /**\n * The first attached body.\n */\n bodyA: Body;\n /**\n * The second attached body.\n */\n bodyB: Body;\n}\n\n/** @internal */ const DEFAULTS = {\n userData : null,\n collideConnected : false\n};\n\n/**\n * The base joint class. Joints are used to constraint two bodies together in\n * various fashions. Some joints also feature limits and motors.\n */\nexport abstract class Joint {\n\n /** @internal */ m_type: string = \"unknown-joint\";\n\n /** @internal */ m_bodyA: Body;\n /** @internal */ m_bodyB: Body;\n\n /** @internal */ m_collideConnected: boolean;\n\n /** @internal */ m_prev: Joint | null = null;\n /** @internal */ m_next: Joint | null = null;\n\n /** @internal */ m_edgeA: JointEdge = new JointEdge();\n /** @internal */ m_edgeB: JointEdge = new JointEdge();\n\n /** @internal */ m_islandFlag: boolean = false;\n /** @internal */ m_userData: unknown;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n constructor(def: JointDef);\n constructor(def: JointOpt, bodyA: Body, bodyB: Body);\n constructor(def: JointDef | JointOpt, bodyA?: Body, bodyB?: Body) {\n bodyA = \"bodyA\" in def ? def.bodyA : bodyA;\n bodyB = \"bodyB\" in def ? def.bodyB : bodyB;\n\n if (_ASSERT) console.assert(!!bodyA);\n if (_ASSERT) console.assert(!!bodyB);\n if (_ASSERT) console.assert(bodyA != bodyB);\n\n this.m_bodyA = bodyA!;\n this.m_bodyB = bodyB!;\n\n this.m_collideConnected = !!def.collideConnected;\n this.m_userData = def.userData;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /**\n * Short-cut function to determine if either body is inactive.\n */\n isActive(): boolean {\n return this.m_bodyA.isActive() && this.m_bodyB.isActive();\n }\n\n /**\n * Get the type of the concrete joint.\n */\n getType(): string {\n return this.m_type;\n }\n\n /**\n * Get the first body attached to this joint.\n */\n getBodyA(): Body {\n return this.m_bodyA;\n }\n\n /**\n * Get the second body attached to this joint.\n */\n getBodyB(): Body {\n return this.m_bodyB;\n }\n\n /**\n * Get the next joint the world joint list.\n */\n getNext(): Joint {\n return this.m_next;\n }\n\n getUserData(): unknown {\n return this.m_userData;\n }\n\n setUserData(data: unknown): void {\n this.m_userData = data;\n }\n\n /**\n * Get collide connected. Note: modifying the collide connect flag won't work\n * correctly because the flag is only checked when fixture AABBs begin to\n * overlap.\n */\n getCollideConnected(): boolean {\n return this.m_collideConnected;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n abstract getAnchorA(): Vec2;\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n abstract getAnchorB(): Vec2;\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n abstract getReactionForce(inv_dt: number): Vec2;\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n abstract getReactionTorque(inv_dt: number): number;\n\n /**\n * Shift the origin for any points stored in world coordinates.\n */\n shiftOrigin(newOrigin: Vec2Value): void {}\n\n abstract initVelocityConstraints(step: TimeStep): void;\n\n abstract solveVelocityConstraints(step: TimeStep): void;\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n abstract solvePositionConstraints(step: TimeStep): boolean;\n\n /**\n * @hidden @experimental\n * Update joint with new props.\n */\n abstract _reset(def: Partial): void;\n\n /**\n * @internal @deprecated\n * Temporary for backward compatibility, will be removed.\n */\n _resetAnchors(def: any): void {\n return this._reset(def);\n }\n}\n","/** @hidden */\nexport const stats = {\n gjkCalls: 0,\n gjkIters: 0,\n gjkMaxIters: 0,\n\n toiTime: 0,\n toiMaxTime: 0,\n toiCalls: 0,\n toiIters: 0,\n toiMaxIters: 0,\n toiRootIters: 0,\n toiMaxRootIters: 0,\n\n toString(newline?: string): string {\n newline = typeof newline === \"string\" ? newline : \"\\n\";\n let string = \"\";\n // tslint:disable-next-line:no-for-in\n for (const name in this) {\n if (typeof this[name] !== \"function\" && typeof this[name] !== \"object\") {\n string += name + \": \" + this[name] + newline;\n }\n }\n return string;\n }\n};\n","/** @internal */\nexport const now = function(): number {\n return Date.now();\n};\n\n/** @internal */\nexport const diff = function(time: number): number {\n return Date.now() - time;\n};\n\n/** @internal */\nexport default {\n now,\n diff,\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { stats } from \"../util/stats\";\nimport { Shape } from \"./Shape\";\nimport { EPSILON } from \"../common/Math\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { Rot } from \"../common/Rot\";\nimport { Transform, TransformValue } from \"../common/Transform\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_max = Math.max;\n\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const e12 = matrix.vec2(0, 0);\n/** @internal */ const e13 = matrix.vec2(0, 0);\n/** @internal */ const e23 = matrix.vec2(0, 0);\n/** @internal */ const temp1 = matrix.vec2(0, 0);\n/** @internal */ const temp2 = matrix.vec2(0, 0);\n\n/**\n * GJK using Voronoi regions (Christer Ericson) and Barycentric coordinates.\n */\n\nstats.gjkCalls = 0;\nstats.gjkIters = 0;\nstats.gjkMaxIters = 0;\n\n/**\n * Input for Distance. You have to option to use the shape radii in the\n * computation. Even\n */\nexport class DistanceInput {\n readonly proxyA = new DistanceProxy();\n readonly proxyB = new DistanceProxy();\n readonly transformA = Transform.identity();\n readonly transformB = Transform.identity();\n useRadii = false;\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.transformA.setIdentity();\n this.transformB.setIdentity();\n this.useRadii = false;\n }\n}\n\n/**\n * Output for Distance.\n */\nexport class DistanceOutput {\n /** closest point on shapeA */\n pointA = matrix.vec2(0, 0);\n /** closest point on shapeB */\n pointB = matrix.vec2(0, 0);\n distance = 0;\n /** iterations number of GJK iterations used */\n iterations = 0;\n recycle() {\n matrix.zeroVec2(this.pointA);\n matrix.zeroVec2(this.pointB);\n this.distance = 0;\n this.iterations = 0;\n }\n}\n\n/**\n * Used to warm start Distance. Set count to zero on first call.\n */\nexport class SimplexCache {\n /** length or area */\n metric: number = 0;\n /** vertices on shape A */\n indexA: number[] = [];\n /** vertices on shape B */\n indexB: number[] = [];\n count: number = 0;\n recycle() {\n this.metric = 0;\n this.indexA.length = 0;\n this.indexB.length = 0;\n this.count = 0;\n }\n}\n\n/**\n * Compute the closest points between two shapes. Supports any combination of:\n * CircleShape, PolygonShape, EdgeShape. The simplex cache is input/output. On\n * the first call set SimplexCache.count to zero.\n */\nexport const Distance = function (output: DistanceOutput, cache: SimplexCache, input: DistanceInput): void {\n ++stats.gjkCalls;\n\n const proxyA = input.proxyA;\n const proxyB = input.proxyB;\n const xfA = input.transformA;\n const xfB = input.transformB;\n\n // Initialize the simplex.\n // const simplex = new Simplex();\n simplex.recycle();\n simplex.readCache(cache, proxyA, xfA, proxyB, xfB);\n\n // Get simplex vertices as an array.\n const vertices = simplex.m_v;\n const k_maxIters = Settings.maxDistanceIterations;\n\n // These store the vertices of the last simplex so that we\n // can check for duplicates and prevent cycling.\n const saveA = [];\n const saveB = []; // int[3]\n let saveCount = 0;\n\n // Main iteration loop.\n let iter = 0;\n while (iter < k_maxIters) {\n // Copy simplex so we can identify duplicates.\n saveCount = simplex.m_count;\n for (let i = 0; i < saveCount; ++i) {\n saveA[i] = vertices[i].indexA;\n saveB[i] = vertices[i].indexB;\n }\n\n simplex.solve();\n\n // If we have 3 points, then the origin is in the corresponding triangle.\n if (simplex.m_count === 3) {\n break;\n }\n\n // Get search direction.\n const d = simplex.getSearchDirection();\n\n // Ensure the search direction is numerically fit.\n if (matrix.lengthSqrVec2(d) < EPSILON * EPSILON) {\n // The origin is probably contained by a line segment\n // or triangle. Thus the shapes are overlapped.\n\n // We can't return zero here even though there may be overlap.\n // In case the simplex is a point, segment, or triangle it is difficult\n // to determine if the origin is contained in the CSO or very close to it.\n break;\n }\n\n // Compute a tentative new simplex vertex using support points.\n const vertex = vertices[simplex.m_count]; // SimplexVertex\n\n vertex.indexA = proxyA.getSupport(matrix.derotVec2(temp, xfA.q, matrix.scaleVec2(temp, -1, d)));\n matrix.transformVec2(vertex.wA, xfA, proxyA.getVertex(vertex.indexA));\n\n vertex.indexB = proxyB.getSupport(matrix.derotVec2(temp, xfB.q, d));\n matrix.transformVec2(vertex.wB, xfB, proxyB.getVertex(vertex.indexB));\n\n matrix.subVec2(vertex.w, vertex.wB, vertex.wA);\n\n // Iteration count is equated to the number of support point calls.\n ++iter;\n ++stats.gjkIters;\n\n // Check for duplicate support points. This is the main termination\n // criteria.\n let duplicate = false;\n for (let i = 0; i < saveCount; ++i) {\n if (vertex.indexA === saveA[i] && vertex.indexB === saveB[i]) {\n duplicate = true;\n break;\n }\n }\n\n // If we found a duplicate support point we must exit to avoid cycling.\n if (duplicate) {\n break;\n }\n\n // New vertex is ok and needed.\n ++simplex.m_count;\n }\n\n stats.gjkMaxIters = math_max(stats.gjkMaxIters, iter);\n\n // Prepare output.\n simplex.getWitnessPoints(output.pointA, output.pointB);\n output.distance = matrix.distVec2(output.pointA, output.pointB);\n output.iterations = iter;\n\n // Cache the simplex.\n simplex.writeCache(cache);\n\n // Apply radii if requested.\n if (input.useRadii) {\n const rA = proxyA.m_radius;\n const rB = proxyB.m_radius;\n\n if (output.distance > rA + rB && output.distance > EPSILON) {\n // Shapes are still no overlapped.\n // Move the witness points to the outer surface.\n output.distance -= rA + rB;\n matrix.subVec2(normal, output.pointB, output.pointA);\n matrix.normalizeVec2(normal);\n matrix.plusScaleVec2(output.pointA, rA, normal);\n matrix.minusScaleVec2(output.pointB, rB, normal);\n } else {\n // Shapes are overlapped when radii are considered.\n // Move the witness points to the middle.\n const p = matrix.subVec2(temp, output.pointA, output.pointB);\n matrix.copyVec2(output.pointA, p);\n matrix.copyVec2(output.pointB, p);\n output.distance = 0.0;\n }\n }\n};\n\n/**\n * A distance proxy is used by the GJK algorithm. It encapsulates any shape.\n */\nexport class DistanceProxy {\n /** @internal */ m_vertices: Vec2Value[] = [];\n // todo: remove this?\n /** @internal */ m_count = 0;\n /** @internal */ m_radius = 0;\n\n recycle() {\n this.m_vertices.length = 0;\n this.m_count = 0;\n this.m_radius = 0;\n }\n\n /**\n * Get the vertex count.\n */\n getVertexCount(): number {\n return this.m_count;\n }\n\n /**\n * Get a vertex by index. Used by Distance.\n */\n getVertex(index: number): Vec2Value {\n if (_ASSERT) console.assert(0 <= index && index < this.m_count);\n return this.m_vertices[index];\n }\n\n /**\n * Get the supporting vertex index in the given direction.\n */\n getSupport(d: Vec2Value): number {\n let bestIndex = -1;\n let bestValue = -Infinity;\n for (let i = 0; i < this.m_count; ++i) {\n const value = matrix.dotVec2(this.m_vertices[i], d);\n if (value > bestValue) {\n bestIndex = i;\n bestValue = value;\n }\n }\n return bestIndex;\n }\n\n /**\n * Get the supporting vertex in the given direction.\n */\n getSupportVertex(d: Vec2Value): Vec2Value {\n return this.m_vertices[this.getSupport(d)];\n }\n\n /**\n * Initialize the proxy using the given shape. The shape must remain in scope\n * while the proxy is in use.\n */\n set(shape: Shape, index: number): void {\n // TODO remove, use shape instead\n if (_ASSERT) console.assert(typeof shape.computeDistanceProxy === \"function\");\n shape.computeDistanceProxy(this, index);\n }\n\n /**\n * Initialize the proxy using a vertex cloud and radius. The vertices\n * must remain in scope while the proxy is in use.\n */\n setVertices(vertices: Vec2Value[], count: number, radius: number) {\n this.m_vertices = vertices;\n this.m_count = count;\n this.m_radius = radius;\n }\n}\n\nclass SimplexVertex {\n /** support point in proxyA */\n wA = matrix.vec2(0, 0);\n /** wA index */\n indexA = 0;\n\n /** support point in proxyB */\n wB = matrix.vec2(0, 0);\n /** wB index */\n indexB = 0;\n\n /** wB - wA; */\n w = matrix.vec2(0, 0);\n /** barycentric coordinate for closest point */\n a = 0;\n\n recycle() {\n this.indexA = 0;\n this.indexB = 0;\n matrix.zeroVec2(this.wA);\n matrix.zeroVec2(this.wB);\n matrix.zeroVec2(this.w);\n this.a = 0;\n }\n set(v: SimplexVertex): void {\n this.indexA = v.indexA;\n this.indexB = v.indexB;\n matrix.copyVec2(this.wA, v.wA);\n matrix.copyVec2(this.wB, v.wB);\n matrix.copyVec2(this.w, v.w);\n this.a = v.a;\n }\n}\n\n/** @internal */ const searchDirection_reuse = matrix.vec2(0, 0);\n/** @internal */ const closestPoint_reuse = matrix.vec2(0, 0); \n\nclass Simplex {\n m_v1 = new SimplexVertex();\n m_v2 = new SimplexVertex();\n m_v3 = new SimplexVertex();\n m_v = [this.m_v1, this.m_v2, this.m_v3];\n m_count: number;\n recycle() {\n this.m_v1.recycle();\n this.m_v2.recycle();\n this.m_v3.recycle();\n this.m_count = 0;\n }\n\n /** @internal */ toString(): string {\n if (this.m_count === 3) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y,\n this.m_v2.a, this.m_v2.wA.x, this.m_v2.wA.y, this.m_v2.wB.x, this.m_v2.wB.y,\n this.m_v3.a, this.m_v3.wA.x, this.m_v3.wA.y, this.m_v3.wB.x, this.m_v3.wB.y\n ].toString();\n\n } else if (this.m_count === 2) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y,\n this.m_v2.a, this.m_v2.wA.x, this.m_v2.wA.y, this.m_v2.wB.x, this.m_v2.wB.y\n ].toString();\n\n } else if (this.m_count === 1) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y\n ].toString();\n\n } else {\n return \"+\" + this.m_count;\n }\n }\n\n readCache(cache: SimplexCache, proxyA: DistanceProxy, transformA: TransformValue, proxyB: DistanceProxy, transformB: TransformValue): void {\n if (_ASSERT) console.assert(cache.count <= 3);\n\n // Copy data from cache.\n this.m_count = cache.count;\n for (let i = 0; i < this.m_count; ++i) {\n const v = this.m_v[i];\n v.indexA = cache.indexA[i];\n v.indexB = cache.indexB[i];\n const wALocal = proxyA.getVertex(v.indexA);\n const wBLocal = proxyB.getVertex(v.indexB);\n matrix.transformVec2(v.wA, transformA, wALocal);\n matrix.transformVec2(v.wB, transformB, wBLocal);\n matrix.subVec2(v.w,v.wB, v.wA);\n v.a = 0.0;\n }\n\n // Compute the new simplex metric, if it is substantially different than\n // old metric then flush the simplex.\n if (this.m_count > 1) {\n const metric1 = cache.metric;\n const metric2 = this.getMetric();\n if (metric2 < 0.5 * metric1 || 2.0 * metric1 < metric2 || metric2 < EPSILON) {\n // Reset the simplex.\n this.m_count = 0;\n }\n }\n\n // If the cache is empty or invalid...\n if (this.m_count === 0) {\n const v = this.m_v[0];\n v.indexA = 0;\n v.indexB = 0;\n const wALocal = proxyA.getVertex(0);\n const wBLocal = proxyB.getVertex(0);\n matrix.transformVec2(v.wA, transformA, wALocal);\n matrix.transformVec2(v.wB, transformB, wBLocal);\n matrix.subVec2(v.w,v.wB, v.wA);\n v.a = 1.0;\n this.m_count = 1;\n }\n }\n\n writeCache(cache: SimplexCache): void {\n cache.metric = this.getMetric();\n cache.count = this.m_count;\n for (let i = 0; i < this.m_count; ++i) {\n cache.indexA[i] = this.m_v[i].indexA;\n cache.indexB[i] = this.m_v[i].indexB;\n }\n }\n\n getSearchDirection(): Vec2Value {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 1:\n return matrix.setVec2(searchDirection_reuse, -v1.w.x, -v1.w.y);\n\n case 2: {\n matrix.subVec2(e12, v2.w, v1.w);\n const sgn = -matrix.crossVec2Vec2(e12, v1.w);\n if (sgn > 0.0) {\n // Origin is left of e12.\n return matrix.setVec2(searchDirection_reuse, -e12.y, e12.x);\n } else {\n // Origin is right of e12.\n return matrix.setVec2(searchDirection_reuse, e12.y, -e12.x);\n }\n }\n\n default:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(searchDirection_reuse);\n }\n }\n\n getClosestPoint(): Vec2Value {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(closestPoint_reuse);\n\n case 1:\n return matrix.copyVec2(closestPoint_reuse, v1.w);\n\n case 2:\n return matrix.combine2Vec2(closestPoint_reuse, v1.a, v1.w, v2.a, v2.w);\n\n case 3:\n return matrix.zeroVec2(closestPoint_reuse);\n\n default:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(closestPoint_reuse);\n }\n }\n\n getWitnessPoints(pA: Vec2Value, pB: Vec2Value): void {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n break;\n\n case 1:\n matrix.copyVec2(pA, v1.wA);\n matrix.copyVec2(pB, v1.wB);\n break;\n\n case 2:\n matrix.combine2Vec2(pA, v1.a, v1.wA, v2.a, v2.wA);\n matrix.combine2Vec2(pB, v1.a, v1.wB, v2.a, v2.wB);\n break;\n\n case 3:\n matrix.combine3Vec2(pA, v1.a, v1.wA, v2.a, v2.wA, v3.a, v3.wA);\n matrix.copyVec2(pB, pA);\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n break;\n }\n }\n\n getMetric(): number {\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n return 0.0;\n\n case 1:\n return 0.0;\n\n case 2:\n return matrix.distVec2(this.m_v1.w, this.m_v2.w);\n\n case 3:\n return matrix.crossVec2Vec2(\n matrix.subVec2(temp1, this.m_v2.w, this.m_v1.w),\n matrix.subVec2(temp2, this.m_v3.w, this.m_v1.w),\n );\n\n default:\n if (_ASSERT) console.assert(false);\n return 0.0;\n }\n }\n\n solve(): void {\n switch (this.m_count) {\n case 1:\n break;\n\n case 2:\n this.solve2();\n break;\n\n case 3:\n this.solve3();\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n }\n }\n\n// Solve a line segment using barycentric coordinates.\n//\n// p = a1 * w1 + a2 * w2\n// a1 + a2 = 1\n//\n// The vector from the origin to the closest point on the line is\n// perpendicular to the line.\n// e12 = w2 - w1\n// dot(p, e) = 0\n// a1 * dot(w1, e) + a2 * dot(w2, e) = 0\n//\n// 2-by-2 linear system\n// [1 1 ][a1] = [1]\n// [w1.e12 w2.e12][a2] = [0]\n//\n// Define\n// d12_1 = dot(w2, e12)\n// d12_2 = -dot(w1, e12)\n// d12 = d12_1 + d12_2\n//\n// Solution\n// a1 = d12_1 / d12\n// a2 = d12_2 / d12\n solve2(): void {\n const w1 = this.m_v1.w;\n const w2 = this.m_v2.w;\n matrix.subVec2(e12, w2, w1);\n\n // w1 region\n const d12_2 = -matrix.dotVec2(w1, e12);\n if (d12_2 <= 0.0) {\n // a2 <= 0, so we clamp it to 0\n this.m_v1.a = 1.0;\n this.m_count = 1;\n return;\n }\n\n // w2 region\n const d12_1 = matrix.dotVec2(w2, e12);\n if (d12_1 <= 0.0) {\n // a1 <= 0, so we clamp it to 0\n this.m_v2.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v2);\n return;\n }\n\n // Must be in e12 region.\n const inv_d12 = 1.0 / (d12_1 + d12_2);\n this.m_v1.a = d12_1 * inv_d12;\n this.m_v2.a = d12_2 * inv_d12;\n this.m_count = 2;\n }\n\n// Possible regions:\n// - points[2]\n// - edge points[0]-points[2]\n// - edge points[1]-points[2]\n// - inside the triangle\n solve3(): void {\n const w1 = this.m_v1.w;\n const w2 = this.m_v2.w;\n const w3 = this.m_v3.w;\n\n // Edge12\n // [1 1 ][a1] = [1]\n // [w1.e12 w2.e12][a2] = [0]\n // a3 = 0\n matrix.subVec2(e12, w2, w1);\n const w1e12 = matrix.dotVec2(w1, e12);\n const w2e12 = matrix.dotVec2(w2, e12);\n const d12_1 = w2e12;\n const d12_2 = -w1e12;\n\n // Edge13\n // [1 1 ][a1] = [1]\n // [w1.e13 w3.e13][a3] = [0]\n // a2 = 0\n matrix.subVec2(e13, w3, w1);\n const w1e13 = matrix.dotVec2(w1, e13);\n const w3e13 = matrix.dotVec2(w3, e13);\n const d13_1 = w3e13;\n const d13_2 = -w1e13;\n\n // Edge23\n // [1 1 ][a2] = [1]\n // [w2.e23 w3.e23][a3] = [0]\n // a1 = 0\n matrix.subVec2(e23, w3, w2);\n const w2e23 = matrix.dotVec2(w2, e23);\n const w3e23 = matrix.dotVec2(w3, e23);\n const d23_1 = w3e23;\n const d23_2 = -w2e23;\n\n // Triangle123\n const n123 = matrix.crossVec2Vec2(e12, e13);\n\n const d123_1 = n123 * matrix.crossVec2Vec2(w2, w3);\n const d123_2 = n123 * matrix.crossVec2Vec2(w3, w1);\n const d123_3 = n123 * matrix.crossVec2Vec2(w1, w2);\n\n // w1 region\n if (d12_2 <= 0.0 && d13_2 <= 0.0) {\n this.m_v1.a = 1.0;\n this.m_count = 1;\n return;\n }\n\n // e12\n if (d12_1 > 0.0 && d12_2 > 0.0 && d123_3 <= 0.0) {\n const inv_d12 = 1.0 / (d12_1 + d12_2);\n this.m_v1.a = d12_1 * inv_d12;\n this.m_v2.a = d12_2 * inv_d12;\n this.m_count = 2;\n return;\n }\n\n // e13\n if (d13_1 > 0.0 && d13_2 > 0.0 && d123_2 <= 0.0) {\n const inv_d13 = 1.0 / (d13_1 + d13_2);\n this.m_v1.a = d13_1 * inv_d13;\n this.m_v3.a = d13_2 * inv_d13;\n this.m_count = 2;\n this.m_v2.set(this.m_v3);\n return;\n }\n\n // w2 region\n if (d12_1 <= 0.0 && d23_2 <= 0.0) {\n this.m_v2.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v2);\n return;\n }\n\n // w3 region\n if (d13_1 <= 0.0 && d23_1 <= 0.0) {\n this.m_v3.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v3);\n return;\n }\n\n // e23\n if (d23_1 > 0.0 && d23_2 > 0.0 && d123_1 <= 0.0) {\n const inv_d23 = 1.0 / (d23_1 + d23_2);\n this.m_v2.a = d23_1 * inv_d23;\n this.m_v3.a = d23_2 * inv_d23;\n this.m_count = 2;\n this.m_v1.set(this.m_v3);\n return;\n }\n\n // Must be in triangle123\n const inv_d123 = 1.0 / (d123_1 + d123_2 + d123_3);\n this.m_v1.a = d123_1 * inv_d123;\n this.m_v2.a = d123_2 * inv_d123;\n this.m_v3.a = d123_3 * inv_d123;\n this.m_count = 3;\n }\n}\n\n/** @internal */ const simplex = new Simplex();\n\n/** @internal */ const input = new DistanceInput();\n/** @internal */ const cache = new SimplexCache();\n/** @internal */ const output = new DistanceOutput();\n\n/**\n * Determine if two generic shapes overlap.\n */\nexport const testOverlap = function (shapeA: Shape, indexA: number, shapeB: Shape, indexB: number, xfA: TransformValue, xfB: TransformValue): boolean {\n input.recycle();\n input.proxyA.set(shapeA, indexA);\n input.proxyB.set(shapeB, indexB);\n matrix.copyTransform(input.transformA, xfA);\n matrix.copyTransform(input.transformB, xfB);\n input.useRadii = true;\n\n output.recycle();\n cache.recycle();\n\n Distance(output, cache, input);\n\n return output.distance < 10.0 * EPSILON;\n};\n\n// legacy exports\nDistance.testOverlap = testOverlap;\nDistance.Input = DistanceInput;\nDistance.Output = DistanceOutput;\nDistance.Proxy = DistanceProxy;\nDistance.Cache = SimplexCache;\n\n/**\n * Input parameters for ShapeCast\n */\nexport class ShapeCastInput {\n readonly proxyA = new DistanceProxy();\n readonly proxyB = new DistanceProxy();\n readonly transformA = Transform.identity();\n readonly transformB = Transform.identity();\n readonly translationB = Vec2.zero();\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.transformA.setIdentity();\n this.transformB.setIdentity();\n matrix.zeroVec2(this.translationB);\n }\n}\n\n/**\n * Output results for b2ShapeCast\n */\nexport class ShapeCastOutput {\n point: Vec2 = Vec2.zero();\n normal: Vec2 = Vec2.zero();\n lambda = 1.0;\n iterations = 0;\n}\n\n/**\n * Perform a linear shape cast of shape B moving and shape A fixed. Determines\n * the hit point, normal, and translation fraction.\n * \n * @returns true if hit, false if there is no hit or an initial overlap\n */\n//\n// GJK-raycast\n// Algorithm by Gino van den Bergen.\n// \"Smooth Mesh Contacts with GJK\" in Game Physics Pearls. 2010\nexport const ShapeCast = function(output: ShapeCastOutput, input: ShapeCastInput): boolean {\n output.iterations = 0;\n output.lambda = 1.0;\n output.normal.setZero();\n output.point.setZero();\n\n const proxyA = input.proxyA;\n const proxyB = input.proxyB;\n\n const radiusA = math_max(proxyA.m_radius, Settings.polygonRadius);\n const radiusB = math_max(proxyB.m_radius, Settings.polygonRadius);\n const radius = radiusA + radiusB;\n\n const xfA = input.transformA;\n const xfB = input.transformB;\n\n const r = input.translationB;\n const n = Vec2.zero();\n let lambda = 0.0;\n\n // Initial simplex\n const simplex = new Simplex();\n simplex.m_count = 0;\n\n // Get simplex vertices as an array.\n const vertices = simplex.m_v;\n\n // Get support point in -r direction\n let indexA = proxyA.getSupport(Rot.mulTVec2(xfA.q, Vec2.neg(r)));\n let wA = Transform.mulVec2(xfA, proxyA.getVertex(indexA));\n let indexB = proxyB.getSupport(Rot.mulTVec2(xfB.q, r));\n let wB = Transform.mulVec2(xfB, proxyB.getVertex(indexB));\n const v = Vec2.sub(wA, wB);\n\n // Sigma is the target distance between polygons\n const sigma = math_max(Settings.polygonRadius, radius - Settings.polygonRadius);\n const tolerance = 0.5 * Settings.linearSlop;\n\n // Main iteration loop.\n const k_maxIters = 20;\n let iter = 0;\n while (iter < k_maxIters && v.length() - sigma > tolerance) {\n if (_ASSERT) console.assert(simplex.m_count < 3);\n\n output.iterations += 1;\n\n // Support in direction -v (A - B)\n indexA = proxyA.getSupport(Rot.mulTVec2(xfA.q, Vec2.neg(v)));\n wA = Transform.mulVec2(xfA, proxyA.getVertex(indexA));\n indexB = proxyB.getSupport(Rot.mulTVec2(xfB.q, v));\n wB = Transform.mulVec2(xfB, proxyB.getVertex(indexB));\n const p = Vec2.sub(wA, wB);\n\n // -v is a normal at p\n v.normalize();\n\n // Intersect ray with plane\n const vp = Vec2.dot(v, p);\n const vr = Vec2.dot(v, r);\n if (vp - sigma > lambda * vr) {\n if (vr <= 0.0) {\n return false;\n }\n\n lambda = (vp - sigma) / vr;\n if (lambda > 1.0) {\n return false;\n }\n\n n.setMul(-1, v);\n simplex.m_count = 0;\n }\n\n // Reverse simplex since it works with B - A.\n // Shift by lambda * r because we want the closest point to the current clip point.\n // Note that the support point p is not shifted because we want the plane equation\n // to be formed in unshifted space.\n const vertex = vertices[simplex.m_count];\n vertex.indexA = indexB;\n vertex.wA = Vec2.combine(1, wB, lambda, r);\n vertex.indexB = indexA;\n vertex.wB = wA;\n vertex.w = Vec2.sub(vertex.wB, vertex.wA);\n vertex.a = 1.0;\n simplex.m_count += 1;\n\n switch (simplex.m_count) {\n case 1:\n break;\n\n case 2:\n simplex.solve2();\n break;\n\n case 3:\n simplex.solve3();\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n }\n \n // If we have 3 points, then the origin is in the corresponding triangle.\n if (simplex.m_count == 3) {\n // Overlap\n return false;\n }\n\n // Get search direction.\n v.setVec2(simplex.getClosestPoint());\n\n // Iteration count is equated to the number of support point calls.\n ++iter;\n }\n\n if (iter == 0) {\n // Initial overlap\n return false;\n\t}\n\n // Prepare output.\n const pointA = Vec2.zero();\n const pointB = Vec2.zero();\n simplex.getWitnessPoints(pointB, pointA);\n\n if (v.lengthSquared() > 0.0) {\n n.setMul(-1, v);\n n.normalize();\n }\n\n output.point = Vec2.combine(1, pointA, radiusA, n);\n output.normal = n;\n output.lambda = lambda;\n output.iterations = iter;\n return true;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { stats } from \"../util/stats\";\nimport Timer from \"../util/Timer\";\nimport { Sweep } from \"../common/Sweep\";\nimport { Transform } from \"../common/Transform\";\nimport { Distance, DistanceInput, DistanceOutput, DistanceProxy, SimplexCache } from \"./Distance\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n\n\n/**\n * Input parameters for TimeOfImpact.\n */\nexport class TOIInput {\n proxyA = new DistanceProxy();\n proxyB = new DistanceProxy();\n sweepA = new Sweep();\n sweepB = new Sweep();\n /** defines sweep interval [0, tMax] */\n tMax: number;\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.sweepA.recycle();\n this.sweepB.recycle();\n this.tMax = -1;\n }\n}\n\nexport enum TOIOutputState {\n e_unset = -1,\n e_unknown = 0,\n e_failed = 1,\n e_overlapped = 2,\n e_touching = 3,\n e_separated = 4,\n}\n\n/**\n * Output parameters for TimeOfImpact.\n */\nexport class TOIOutput {\n state = TOIOutputState.e_unset;\n t = -1;\n recycle() {\n this.state = TOIOutputState.e_unset;\n this.t = -1;\n }\n}\n\nstats.toiTime = 0;\nstats.toiMaxTime = 0;\nstats.toiCalls = 0;\nstats.toiIters = 0;\nstats.toiMaxIters = 0;\nstats.toiRootIters = 0;\nstats.toiMaxRootIters = 0;\n\n/** @internal */ const distanceInput = new DistanceInput();\n/** @internal */ const distanceOutput = new DistanceOutput();\n// this is passed to Distance and SeparationFunction\n/** @internal */ const cache = new SimplexCache();\n\n/** @internal */ const xfA = matrix.transform(0, 0, 0);\n/** @internal */ const xfB = matrix.transform(0, 0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const axisA = matrix.vec2(0, 0);\n/** @internal */ const axisB = matrix.vec2(0, 0);\n/** @internal */ const localPointA = matrix.vec2(0, 0);\n/** @internal */ const localPointB = matrix.vec2(0, 0);\n\n\n/**\n * Compute the upper bound on time before two shapes penetrate. Time is\n * represented as a fraction between [0,tMax]. This uses a swept separating axis\n * and may miss some intermediate, non-tunneling collisions. If you change the\n * time interval, you should call this function again.\n *\n * Note: use Distance to compute the contact point and normal at the time of\n * impact.\n *\n * CCD via the local separating axis method. This seeks progression by computing\n * the largest time at which separation is maintained.\n */\nexport const TimeOfImpact = function (output: TOIOutput, input: TOIInput): void {\n const timer = Timer.now();\n\n ++stats.toiCalls;\n\n output.state = TOIOutputState.e_unknown;\n output.t = input.tMax;\n\n const proxyA = input.proxyA; // DistanceProxy\n const proxyB = input.proxyB; // DistanceProxy\n\n const sweepA = input.sweepA; // Sweep\n const sweepB = input.sweepB; // Sweep\n\n // Large rotations can make the root finder fail, so we normalize the\n // sweep angles.\n sweepA.normalize();\n sweepB.normalize();\n\n const tMax = input.tMax;\n\n const totalRadius = proxyA.m_radius + proxyB.m_radius;\n const target = math_max(Settings.linearSlop, totalRadius - 3.0 * Settings.linearSlop);\n const tolerance = 0.25 * Settings.linearSlop;\n if (_ASSERT) console.assert(target > tolerance);\n\n let t1 = 0.0;\n const k_maxIterations = Settings.maxTOIIterations;\n let iter = 0;\n\n // Prepare input for distance query.\n // const cache = new SimplexCache();\n cache.recycle();\n\n distanceInput.proxyA.setVertices(proxyA.m_vertices, proxyA.m_count, proxyA.m_radius);\n distanceInput.proxyB.setVertices(proxyB.m_vertices, proxyB.m_count, proxyB.m_radius);\n distanceInput.useRadii = false;\n\n // The outer loop progressively attempts to compute new separating axes.\n // This loop terminates when an axis is repeated (no progress is made).\n while (true) {\n sweepA.getTransform(xfA, t1);\n sweepB.getTransform(xfB, t1);\n\n // Get the distance between shapes. We can also use the results\n // to get a separating axis.\n matrix.copyTransform(distanceInput.transformA, xfA);\n matrix.copyTransform(distanceInput.transformB, xfB);\n Distance(distanceOutput, cache, distanceInput);\n\n // If the shapes are overlapped, we give up on continuous collision.\n if (distanceOutput.distance <= 0.0) {\n // Failure!\n output.state = TOIOutputState.e_overlapped;\n output.t = 0.0;\n break;\n }\n\n if (distanceOutput.distance < target + tolerance) {\n // Victory!\n output.state = TOIOutputState.e_touching;\n output.t = t1;\n break;\n }\n\n // Initialize the separating axis.\n separationFunction.initialize(cache, proxyA, sweepA, proxyB, sweepB, t1);\n\n // if (false) {\n // // Dump the curve seen by the root finder\n // const N = 100;\n // const dx = 1.0 / N;\n // const xs = []; // [ N + 1 ];\n // const fs = []; // [ N + 1 ];\n // const x = 0.0;\n // for (const i = 0; i <= N; ++i) {\n // sweepA.getTransform(xfA, x);\n // sweepB.getTransform(xfB, x);\n // const f = fcn.evaluate(xfA, xfB) - target;\n // printf(\"%g %g\\n\", x, f);\n // xs[i] = x;\n // fs[i] = f;\n // x += dx;\n // }\n // }\n\n // Compute the TOI on the separating axis. We do this by successively\n // resolving the deepest point. This loop is bounded by the number of\n // vertices.\n let done = false;\n let t2 = tMax;\n let pushBackIter = 0;\n while (true) {\n // Find the deepest point at t2. Store the witness point indices.\n let s2 = separationFunction.findMinSeparation(t2);\n\n // Is the final configuration separated?\n if (s2 > target + tolerance) {\n // Victory!\n output.state = TOIOutputState.e_separated;\n output.t = tMax;\n done = true;\n break;\n }\n\n // Has the separation reached tolerance?\n if (s2 > target - tolerance) {\n // Advance the sweeps\n t1 = t2;\n break;\n }\n\n // Compute the initial separation of the witness points.\n let s1 = separationFunction.evaluate(t1);\n\n // Check for initial overlap. This might happen if the root finder\n // runs out of iterations.\n if (s1 < target - tolerance) {\n output.state = TOIOutputState.e_failed;\n output.t = t1;\n done = true;\n break;\n }\n\n // Check for touching\n if (s1 <= target + tolerance) {\n // Victory! t1 should hold the TOI (could be 0.0).\n output.state = TOIOutputState.e_touching;\n output.t = t1;\n done = true;\n break;\n }\n\n // Compute 1D root of: f(x) - target = 0\n let rootIterCount = 0;\n let a1 = t1;\n let a2 = t2;\n while (true) {\n // Use a mix of the secant rule and bisection.\n let t;\n if (rootIterCount & 1) {\n // Secant rule to improve convergence.\n t = a1 + (target - s1) * (a2 - a1) / (s2 - s1);\n } else {\n // Bisection to guarantee progress.\n t = 0.5 * (a1 + a2);\n }\n\n ++rootIterCount;\n ++stats.toiRootIters;\n\n const s = separationFunction.evaluate(t);\n\n if (math_abs(s - target) < tolerance) {\n // t2 holds a tentative value for t1\n t2 = t;\n break;\n }\n\n // Ensure we continue to bracket the root.\n if (s > target) {\n a1 = t;\n s1 = s;\n } else {\n a2 = t;\n s2 = s;\n }\n\n if (rootIterCount === 50) {\n break;\n }\n }\n\n stats.toiMaxRootIters = math_max(stats.toiMaxRootIters, rootIterCount);\n\n ++pushBackIter;\n\n if (pushBackIter === Settings.maxPolygonVertices) {\n break;\n }\n }\n\n ++iter;\n ++stats.toiIters;\n\n if (done) {\n break;\n }\n\n if (iter === k_maxIterations) {\n // Root finder got stuck. Semi-victory.\n output.state = TOIOutputState.e_failed;\n output.t = t1;\n break;\n }\n }\n\n stats.toiMaxIters = math_max(stats.toiMaxIters, iter);\n\n const time = Timer.diff(timer);\n stats.toiMaxTime = math_max(stats.toiMaxTime, time);\n stats.toiTime += time;\n\n separationFunction.recycle();\n};\n\nenum SeparationFunctionType {\n e_unset = -1,\n e_points = 1,\n e_faceA = 2,\n e_faceB = 3,\n}\n\nclass SeparationFunction {\n // input cache\n // todo: maybe assign by copy instead of reference?\n m_proxyA: DistanceProxy = null;\n m_proxyB: DistanceProxy = null;\n m_sweepA: Sweep = null;\n m_sweepB: Sweep = null;\n\n // initialize cache\n m_type = SeparationFunctionType.e_unset;\n m_localPoint = matrix.vec2(0, 0);\n m_axis = matrix.vec2(0, 0);\n\n // compute output\n indexA = -1;\n indexB = -1;\n\n recycle() {\n this.m_proxyA = null;\n this.m_proxyB = null;\n this.m_sweepA = null;\n this.m_sweepB = null;\n\n this.m_type = SeparationFunctionType.e_unset;\n matrix.zeroVec2(this.m_localPoint);\n matrix.zeroVec2(this.m_axis);\n\n this.indexA = -1;\n this.indexB = -1;\n }\n\n // TODO_ERIN might not need to return the separation\n\n initialize(cache: SimplexCache, proxyA: DistanceProxy, sweepA: Sweep, proxyB: DistanceProxy, sweepB: Sweep, t1: number): number {\n const count = cache.count;\n if (_ASSERT) console.assert(0 < count && count < 3);\n\n this.m_proxyA = proxyA;\n this.m_proxyB = proxyB;\n this.m_sweepA = sweepA;\n this.m_sweepB = sweepB;\n\n this.m_sweepA.getTransform(xfA, t1);\n this.m_sweepB.getTransform(xfB, t1);\n\n if (count === 1) {\n this.m_type = SeparationFunctionType.e_points;\n const localPointA = this.m_proxyA.getVertex(cache.indexA[0]);\n const localPointB = this.m_proxyB.getVertex(cache.indexB[0]);\n matrix.transformVec2(pointA, xfA, localPointA);\n matrix.transformVec2(pointB, xfB, localPointB);\n matrix.subVec2(this.m_axis, pointB, pointA);\n const s = matrix.normalizeVec2Length(this.m_axis);\n return s;\n\n } else if (cache.indexA[0] === cache.indexA[1]) {\n // Two points on B and one on A.\n this.m_type = SeparationFunctionType.e_faceB;\n const localPointB1 = proxyB.getVertex(cache.indexB[0]);\n const localPointB2 = proxyB.getVertex(cache.indexB[1]);\n\n matrix.crossVec2Num(this.m_axis, matrix.subVec2(temp, localPointB2, localPointB1), 1.0);\n matrix.normalizeVec2(this.m_axis);\n matrix.rotVec2(normal, xfB.q, this.m_axis);\n\n matrix.combine2Vec2(this.m_localPoint, 0.5, localPointB1, 0.5, localPointB2);\n matrix.transformVec2(pointB, xfB, this.m_localPoint);\n\n const localPointA = proxyA.getVertex(cache.indexA[0]);\n const pointA = Transform.mulVec2(xfA, localPointA);\n\n let s = matrix.dotVec2(pointA, normal) - matrix.dotVec2(pointB, normal);\n if (s < 0.0) {\n matrix.negVec2(this.m_axis);\n s = -s;\n }\n return s;\n\n } else {\n // Two points on A and one or two points on B.\n this.m_type = SeparationFunctionType.e_faceA;\n const localPointA1 = this.m_proxyA.getVertex(cache.indexA[0]);\n const localPointA2 = this.m_proxyA.getVertex(cache.indexA[1]);\n\n matrix.crossVec2Num(this.m_axis, matrix.subVec2(temp, localPointA2, localPointA1), 1.0);\n matrix.normalizeVec2(this.m_axis);\n matrix.rotVec2(normal, xfA.q, this.m_axis);\n\n matrix.combine2Vec2(this.m_localPoint, 0.5, localPointA1, 0.5, localPointA2);\n matrix.transformVec2(pointA, xfA, this.m_localPoint);\n\n const localPointB = this.m_proxyB.getVertex(cache.indexB[0]);\n matrix.transformVec2(pointB, xfB, localPointB);\n\n let s = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal);\n if (s < 0.0) {\n matrix.negVec2(this.m_axis);\n s = -s;\n }\n return s;\n }\n }\n\n compute(find: boolean, t: number): number {\n // It was findMinSeparation and evaluate\n this.m_sweepA.getTransform(xfA, t);\n this.m_sweepB.getTransform(xfB, t);\n\n switch (this.m_type) {\n case SeparationFunctionType.e_points: {\n if (find) {\n matrix.derotVec2(axisA, xfA.q, this.m_axis);\n matrix.derotVec2(axisB, xfB.q, matrix.scaleVec2(temp, -1, this.m_axis));\n\n this.indexA = this.m_proxyA.getSupport(axisA);\n this.indexB = this.m_proxyB.getSupport(axisB);\n }\n\n matrix.copyVec2(localPointA, this.m_proxyA.getVertex(this.indexA));\n matrix.copyVec2(localPointB, this.m_proxyB.getVertex(this.indexB));\n\n matrix.transformVec2(pointA, xfA, localPointA);\n matrix.transformVec2(pointB, xfB, localPointB);\n\n const sep = matrix.dotVec2(pointB, this.m_axis) - matrix.dotVec2(pointA, this.m_axis);\n return sep;\n }\n\n case SeparationFunctionType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.m_axis);\n matrix.transformVec2(pointA, xfA, this.m_localPoint);\n\n if (find) {\n matrix.derotVec2(axisB, xfB.q, matrix.scaleVec2(temp, -1, normal));\n\n this.indexA = -1;\n this.indexB = this.m_proxyB.getSupport(axisB);\n }\n\n matrix.copyVec2(localPointB, this.m_proxyB.getVertex(this.indexB));\n matrix.transformVec2(pointB, xfB, localPointB);\n\n const sep = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal);\n return sep;\n }\n\n case SeparationFunctionType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.m_axis);\n matrix.transformVec2(pointB, xfB, this.m_localPoint);\n\n if (find) {\n matrix.derotVec2(axisA, xfA.q, matrix.scaleVec2(temp, -1, normal));\n\n this.indexB = -1;\n this.indexA = this.m_proxyA.getSupport(axisA);\n }\n\n matrix.copyVec2(localPointA, this.m_proxyA.getVertex(this.indexA));\n matrix.transformVec2(pointA, xfA, localPointA);\n\n const sep = matrix.dotVec2(pointA, normal) - matrix.dotVec2(pointB, normal);\n return sep;\n }\n\n default:\n if (_ASSERT) console.assert(false);\n if (find) {\n this.indexA = -1;\n this.indexB = -1;\n }\n return 0.0;\n }\n }\n\n findMinSeparation(t: number): number {\n return this.compute(true, t);\n }\n\n evaluate(t: number): number {\n return this.compute(false, t);\n }\n}\n\n/** @internal */ const separationFunction = new SeparationFunction();\n\n// legacy exports\nTimeOfImpact.Input = TOIInput;\nTimeOfImpact.Output = TOIOutput;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { EPSILON } from \"../common/Math\";\nimport { Body } from \"./Body\";\nimport type { Contact } from \"./Contact\";\nimport { Joint } from \"./Joint\";\nimport { TimeOfImpact, TOIInput, TOIOutput, TOIOutputState } from \"../collision/TimeOfImpact\";\nimport { Distance, DistanceInput, DistanceOutput, SimplexCache } from \"../collision/Distance\";\nimport { World } from \"./World\";\nimport { Sweep } from \"../common/Sweep\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_min = Math.min;\n\n\nexport class TimeStep {\n /** time step */\n dt: number = 0;\n /** inverse time step (0 if dt == 0) */\n inv_dt: number = 0;\n velocityIterations: number = 0;\n positionIterations: number = 0;\n warmStarting: boolean = false;\n blockSolve: boolean = true;\n\n /** timestep ratio for variable timestep */\n inv_dt0: number = 0.0;\n /** dt * inv_dt0 */\n dtRatio: number = 1;\n\n reset(dt: number): void {\n if (this.dt > 0.0) {\n this.inv_dt0 = this.inv_dt;\n }\n this.dt = dt;\n this.inv_dt = dt == 0 ? 0 : 1 / dt;\n this.dtRatio = dt * this.inv_dt0;\n }\n}\n\n// reuse\n/** @internal */ const s_subStep = new TimeStep();\n/** @internal */ const c = matrix.vec2(0, 0);\n/** @internal */ const v = matrix.vec2(0, 0);\n/** @internal */ const translation = matrix.vec2(0, 0);\n/** @internal */ const input = new TOIInput();\n/** @internal */ const output = new TOIOutput();\n/** @internal */ const backup = new Sweep();\n/** @internal */ const backup1 = new Sweep();\n/** @internal */ const backup2 = new Sweep();\n\n/**\n * Contact impulses for reporting. Impulses are used instead of forces because\n * sub-step forces may approach infinity for rigid body collisions. These match\n * up one-to-one with the contact points in Manifold.\n */\nexport class ContactImpulse {\n // TODO: merge with Contact class?\n\n private readonly contact: Contact;\n private readonly normals: number[];\n private readonly tangents: number[];\n\n constructor(contact: Contact) {\n this.contact = contact;\n this.normals = [];\n this.tangents = [];\n }\n\n recycle() {\n this.normals.length = 0;\n this.tangents.length = 0;\n }\n\n get normalImpulses(): number[] {\n const contact = this.contact;\n const normals = this.normals;\n normals.length = 0;\n for (let p = 0; p < contact.v_points.length; ++p) {\n normals.push(contact.v_points[p].normalImpulse);\n }\n return normals;\n }\n\n get tangentImpulses(): number[] {\n const contact = this.contact;\n const tangents = this.tangents;\n tangents.length = 0;\n for (let p = 0; p < contact.v_points.length; ++p) {\n tangents.push(contact.v_points[p].tangentImpulse);\n }\n return tangents;\n }\n}\n\n/**\n * Finds and solves islands. An island is a connected subset of the world.\n */\nexport class Solver {\n m_world: World;\n m_stack: Body[];\n m_bodies: Body[];\n m_contacts: Contact[];\n m_joints: Joint[];\n\n constructor(world: World) {\n this.m_world = world;\n this.m_stack = [];\n this.m_bodies = [];\n this.m_contacts = [];\n this.m_joints = [];\n }\n\n clear(): void {\n this.m_stack.length = 0;\n this.m_bodies.length = 0;\n this.m_contacts.length = 0;\n this.m_joints.length = 0;\n }\n\n addBody(body: Body): void {\n if (_ASSERT) console.assert(body instanceof Body, \"Not a Body!\", body);\n this.m_bodies.push(body);\n // why?\n // body.c_position.c.setZero();\n // body.c_position.a = 0;\n // body.c_velocity.v.setZero();\n // body.c_velocity.w = 0;\n }\n\n addContact(contact: Contact): void {\n // if (_ASSERT) console.assert(contact instanceof Contact, 'Not a Contact!', contact);\n this.m_contacts.push(contact);\n }\n\n addJoint(joint: Joint): void {\n if (_ASSERT) console.assert(joint instanceof Joint, \"Not a Joint!\", joint);\n this.m_joints.push(joint);\n }\n\n solveWorld(step: TimeStep): void {\n const world = this.m_world;\n\n // Clear all the island flags.\n for (let b = world.m_bodyList; b; b = b.m_next) {\n b.m_islandFlag = false;\n }\n for (let c = world.m_contactList; c; c = c.m_next) {\n c.m_islandFlag = false;\n }\n for (let j = world.m_jointList; j; j = j.m_next) {\n j.m_islandFlag = false;\n }\n\n // Build and simulate all awake islands.\n const stack = this.m_stack;\n let loop = -1;\n for (let seed = world.m_bodyList; seed; seed = seed.m_next) {\n loop++;\n if (seed.m_islandFlag) {\n continue;\n }\n\n if (seed.isAwake() == false || seed.isActive() == false) {\n continue;\n }\n\n // The seed can be dynamic or kinematic.\n if (seed.isStatic()) {\n continue;\n }\n\n // Reset island and stack.\n this.clear();\n\n stack.push(seed);\n\n seed.m_islandFlag = true;\n\n // Perform a depth first search (DFS) on the constraint graph.\n while (stack.length > 0) {\n // Grab the next body off the stack and add it to the island.\n const b = stack.pop();\n if (_ASSERT) console.assert(b.isActive() == true);\n this.addBody(b);\n\n // Make sure the body is awake (without resetting sleep timer).\n b.m_awakeFlag = true;\n\n // To keep islands as small as possible, we don't\n // propagate islands across static bodies.\n if (b.isStatic()) {\n continue;\n }\n\n // Search all contacts connected to this body.\n for (let ce = b.m_contactList; ce; ce = ce.next) {\n const contact = ce.contact;\n\n // Has this contact already been added to an island?\n if (contact.m_islandFlag) {\n continue;\n }\n\n // Is this contact solid and touching?\n if (contact.isEnabled() == false || contact.isTouching() == false) {\n continue;\n }\n\n // Skip sensors.\n const sensorA = contact.m_fixtureA.m_isSensor;\n const sensorB = contact.m_fixtureB.m_isSensor;\n if (sensorA || sensorB) {\n continue;\n }\n\n this.addContact(contact);\n contact.m_islandFlag = true;\n\n const other = ce.other;\n\n // Was the other body already added to this island?\n if (other.m_islandFlag) {\n continue;\n }\n\n // if (_ASSERT) console.assert(stack.length < world.m_bodyCount);\n stack.push(other);\n other.m_islandFlag = true;\n }\n\n // Search all joints connect to this body.\n for (let je = b.m_jointList; je; je = je.next) {\n if (je.joint.m_islandFlag == true) {\n continue;\n }\n\n const other = je.other;\n\n // Don't simulate joints connected to inactive bodies.\n if (other.isActive() == false) {\n continue;\n }\n\n this.addJoint(je.joint);\n je.joint.m_islandFlag = true;\n\n if (other.m_islandFlag) {\n continue;\n }\n\n // if (_ASSERT) console.assert(stack.length < world.m_bodyCount);\n stack.push(other);\n other.m_islandFlag = true;\n }\n }\n\n this.solveIsland(step);\n\n // Post solve cleanup.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n // Allow static bodies to participate in other islands.\n // TODO: are they added at all?\n const b = this.m_bodies[i];\n if (b.isStatic()) {\n b.m_islandFlag = false;\n }\n }\n }\n }\n\n solveIsland(step: TimeStep): void {\n // B2: Island Solve\n const world = this.m_world;\n const gravity = world.m_gravity;\n const allowSleep = world.m_allowSleep;\n\n const h = step.dt;\n\n // Integrate velocities and apply damping. Initialize the body state.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.m_sweep.c);\n const a = body.m_sweep.a;\n matrix.copyVec2(v, body.m_linearVelocity);\n let w = body.m_angularVelocity;\n\n // Store positions for continuous collision.\n matrix.copyVec2(body.m_sweep.c0, body.m_sweep.c);\n body.m_sweep.a0 = body.m_sweep.a;\n\n if (body.isDynamic()) {\n // Integrate velocities.\n matrix.plusScaleVec2(v, h * body.m_gravityScale, gravity);\n matrix.plusScaleVec2(v, h * body.m_invMass, body.m_force);\n w += h * body.m_invI * body.m_torque;\n /**\n *
\n         * Apply damping.\n         * ODE: dv/dt + c * v = 0\n         * Solution: v(t) = v0 * exp(-c * t)\n         * Time step: v(t + dt) = v0 * exp(-c * (t + dt)) = v0 * exp(-c * t) * exp(-c * dt) = v * exp(-c * dt)\n         * v2 = exp(-c * dt) * v1\n         * Pade approximation:\n         * v2 = v1 * 1 / (1 + c * dt)\n         * 
\n */\n matrix.scaleVec2(v, 1.0 / (1.0 + h * body.m_linearDamping), v);\n w *= 1.0 / (1.0 + h * body.m_angularDamping);\n }\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initConstraint(step);\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initVelocityConstraint(step);\n }\n\n if (step.warmStarting) {\n // Warm start.\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.warmStartConstraint(step);\n }\n }\n\n for (let i = 0; i < this.m_joints.length; ++i) {\n const joint = this.m_joints[i];\n joint.initVelocityConstraints(step);\n }\n\n // Solve velocity constraints\n for (let i = 0; i < step.velocityIterations; ++i) {\n for (let j = 0; j < this.m_joints.length; ++j) {\n const joint = this.m_joints[j];\n joint.solveVelocityConstraints(step);\n }\n\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n contact.solveVelocityConstraint(step);\n }\n }\n\n // Store impulses for warm starting\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.storeConstraintImpulses(step);\n }\n\n // Integrate positions\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.c_position.c);\n let a = body.c_position.a;\n matrix.copyVec2(v, body.c_velocity.v);\n let w = body.c_velocity.w;\n\n // Check for large velocities\n matrix.scaleVec2(translation, h, v);\n const translationLengthSqr = matrix.lengthSqrVec2(translation);\n if (translationLengthSqr > Settings.maxTranslationSquared) {\n const ratio = Settings.maxTranslation / math_sqrt(translationLengthSqr);\n matrix.mulVec2(v, ratio);\n }\n\n const rotation = h * w;\n if (rotation * rotation > Settings.maxRotationSquared) {\n const ratio = Settings.maxRotation / math_abs(rotation);\n w *= ratio;\n }\n\n // Integrate\n matrix.plusScaleVec2(c, h, v);\n a += h * w;\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n }\n\n // Solve position constraints\n let positionSolved = false;\n for (let i = 0; i < step.positionIterations; ++i) {\n let minSeparation = 0.0;\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n const separation = contact.solvePositionConstraint(step);\n minSeparation = math_min(minSeparation, separation);\n }\n // We can't expect minSpeparation >= -Settings.linearSlop because we don't\n // push the separation above -Settings.linearSlop.\n const contactsOkay = minSeparation >= -3.0 * Settings.linearSlop;\n\n let jointsOkay = true;\n for (let j = 0; j < this.m_joints.length; ++j) {\n const joint = this.m_joints[j];\n const jointOkay = joint.solvePositionConstraints(step);\n jointsOkay = jointsOkay && jointOkay;\n }\n\n if (contactsOkay && jointsOkay) {\n // Exit early if the position errors are small.\n positionSolved = true;\n break;\n }\n }\n\n // Copy state buffers back to the bodies\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(body.m_sweep.c, body.c_position.c);\n body.m_sweep.a = body.c_position.a;\n matrix.copyVec2(body.m_linearVelocity, body.c_velocity.v);\n body.m_angularVelocity = body.c_velocity.w;\n body.synchronizeTransform();\n }\n\n this.postSolveIsland();\n\n if (allowSleep) {\n let minSleepTime = Infinity;\n\n const linTolSqr = Settings.linearSleepToleranceSqr;\n const angTolSqr = Settings.angularSleepToleranceSqr;\n\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n if (body.isStatic()) {\n continue;\n }\n\n if ((body.m_autoSleepFlag == false)\n || (body.m_angularVelocity * body.m_angularVelocity > angTolSqr)\n || (matrix.lengthSqrVec2(body.m_linearVelocity) > linTolSqr)) {\n body.m_sleepTime = 0.0;\n minSleepTime = 0.0;\n } else {\n body.m_sleepTime += h;\n minSleepTime = math_min(minSleepTime, body.m_sleepTime);\n }\n }\n\n if (minSleepTime >= Settings.timeToSleep && positionSolved) {\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n body.setAwake(false);\n }\n }\n }\n }\n\n /**\n * Find TOI contacts and solve them.\n */\n solveWorldTOI(step: TimeStep): void {\n const world = this.m_world;\n\n if (world.m_stepComplete) {\n for (let b = world.m_bodyList; b; b = b.m_next) {\n b.m_islandFlag = false;\n b.m_sweep.alpha0 = 0.0;\n }\n\n for (let c = world.m_contactList; c; c = c.m_next) {\n // Invalidate TOI\n c.m_toiFlag = false;\n c.m_islandFlag = false;\n c.m_toiCount = 0;\n c.m_toi = 1.0;\n }\n }\n\n // Find TOI events and solve them.\n while (true) {\n // Find the first TOI.\n let minContact: Contact | null = null;\n let minAlpha = 1.0;\n\n for (let c = world.m_contactList; c; c = c.m_next) {\n // Is this contact disabled?\n if (c.isEnabled() == false) {\n continue;\n }\n\n // Prevent excessive sub-stepping.\n if (c.m_toiCount > Settings.maxSubSteps) {\n continue;\n }\n\n let alpha = 1.0;\n if (c.m_toiFlag) {\n // This contact has a valid cached TOI.\n alpha = c.m_toi;\n } else {\n const fA = c.getFixtureA();\n const fB = c.getFixtureB();\n\n // Is there a sensor?\n if (fA.isSensor() || fB.isSensor()) {\n continue;\n }\n\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n if (_ASSERT) console.assert(bA.isDynamic() || bB.isDynamic());\n\n const activeA = bA.isAwake() && !bA.isStatic();\n const activeB = bB.isAwake() && !bB.isStatic();\n\n // Is at least one body active (awake and dynamic or kinematic)?\n if (activeA == false && activeB == false) {\n continue;\n }\n\n const collideA = bA.isBullet() || !bA.isDynamic();\n const collideB = bB.isBullet() || !bB.isDynamic();\n\n // Are these two non-bullet dynamic bodies?\n if (collideA == false && collideB == false) {\n continue;\n }\n\n // Compute the TOI for this contact.\n // Put the sweeps onto the same time interval.\n let alpha0 = bA.m_sweep.alpha0;\n\n if (bA.m_sweep.alpha0 < bB.m_sweep.alpha0) {\n alpha0 = bB.m_sweep.alpha0;\n bA.m_sweep.advance(alpha0);\n } else if (bB.m_sweep.alpha0 < bA.m_sweep.alpha0) {\n alpha0 = bA.m_sweep.alpha0;\n bB.m_sweep.advance(alpha0);\n }\n\n if (_ASSERT) console.assert(alpha0 < 1.0);\n\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n\n const sweepA = bA.m_sweep;\n const sweepB = bB.m_sweep;\n\n // Compute the time of impact in interval [0, minTOI]\n input.proxyA.set(fA.getShape(), indexA);\n input.proxyB.set(fB.getShape(), indexB);\n input.sweepA.set(bA.m_sweep);\n input.sweepB.set(bB.m_sweep);\n input.tMax = 1.0;\n\n TimeOfImpact(output, input);\n\n // Beta is the fraction of the remaining portion of the [time?].\n const beta = output.t;\n if (output.state == TOIOutputState.e_touching) {\n alpha = math_min(alpha0 + (1.0 - alpha0) * beta, 1.0);\n } else {\n alpha = 1.0;\n }\n\n c.m_toi = alpha;\n c.m_toiFlag = true;\n }\n\n if (alpha < minAlpha) {\n // This is the minimum TOI found so far.\n minContact = c;\n minAlpha = alpha;\n }\n }\n\n if (minContact == null || 1.0 - 10.0 * EPSILON < minAlpha) {\n // No more TOI events. Done!\n world.m_stepComplete = true;\n break;\n }\n\n // Advance the bodies to the TOI.\n const fA = minContact.getFixtureA();\n const fB = minContact.getFixtureB();\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n backup1.set(bA.m_sweep);\n backup2.set(bB.m_sweep);\n\n bA.advance(minAlpha);\n bB.advance(minAlpha);\n\n // The TOI contact likely has some new contact points.\n minContact.update(world);\n minContact.m_toiFlag = false;\n ++minContact.m_toiCount;\n\n // Is the contact solid?\n if (minContact.isEnabled() == false || minContact.isTouching() == false) {\n // Restore the sweeps.\n minContact.setEnabled(false);\n bA.m_sweep.set(backup1);\n bB.m_sweep.set(backup2);\n bA.synchronizeTransform();\n bB.synchronizeTransform();\n continue;\n }\n\n bA.setAwake(true);\n bB.setAwake(true);\n\n // Build the island\n this.clear();\n this.addBody(bA);\n this.addBody(bB);\n this.addContact(minContact);\n\n bA.m_islandFlag = true;\n bB.m_islandFlag = true;\n minContact.m_islandFlag = true;\n\n // Get contacts on bodyA and bodyB.\n const bodies = [ bA, bB ];\n for (let i = 0; i < bodies.length; ++i) {\n const body = bodies[i];\n if (body.isDynamic()) {\n for (let ce = body.m_contactList; ce; ce = ce.next) {\n // if (this.m_bodyCount == this.m_bodyCapacity) { break; }\n // if (this.m_contactCount == this.m_contactCapacity) { break; }\n\n const contact = ce.contact;\n\n // Has this contact already been added to the island?\n if (contact.m_islandFlag) {\n continue;\n }\n\n // Only add if either is static, kinematic or bullet.\n const other = ce.other;\n if (other.isDynamic() && !body.isBullet() && !other.isBullet()) {\n continue;\n }\n\n // Skip sensors.\n const sensorA = contact.m_fixtureA.m_isSensor;\n const sensorB = contact.m_fixtureB.m_isSensor;\n if (sensorA || sensorB) {\n continue;\n }\n\n // Tentatively advance the body to the TOI.\n backup.set(other.m_sweep);\n if (other.m_islandFlag == false) {\n other.advance(minAlpha);\n }\n\n // Update the contact points\n contact.update(world);\n\n // Was the contact disabled by the user?\n // Are there contact points?\n if (contact.isEnabled() == false || contact.isTouching() == false) {\n other.m_sweep.set(backup);\n other.synchronizeTransform();\n continue;\n }\n\n // Add the contact to the island\n contact.m_islandFlag = true;\n this.addContact(contact);\n\n // Has the other body already been added to the island?\n if (other.m_islandFlag) {\n continue;\n }\n\n // Add the other body to the island.\n other.m_islandFlag = true;\n\n if (!other.isStatic()) {\n other.setAwake(true);\n }\n\n this.addBody(other);\n }\n }\n }\n\n s_subStep.reset((1.0 - minAlpha) * step.dt);\n s_subStep.dtRatio = 1.0;\n s_subStep.positionIterations = 20;\n s_subStep.velocityIterations = step.velocityIterations;\n s_subStep.warmStarting = false;\n\n this.solveIslandTOI(s_subStep, bA, bB);\n\n // Reset island flags and synchronize broad-phase proxies.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n body.m_islandFlag = false;\n\n if (!body.isDynamic()) {\n continue;\n }\n\n body.synchronizeFixtures();\n\n // Invalidate all contact TOIs on this displaced body.\n for (let ce = body.m_contactList; ce; ce = ce.next) {\n ce.contact.m_toiFlag = false;\n ce.contact.m_islandFlag = false;\n }\n }\n\n // Commit fixture proxy movements to the broad-phase so that new contacts\n // are created.\n // Also, some contacts can be destroyed.\n world.findNewContacts();\n\n if (world.m_subStepping) {\n world.m_stepComplete = false;\n break;\n }\n }\n }\n\n solveIslandTOI(subStep: TimeStep, toiA: Body, toiB: Body): void {\n\n // Initialize the body state.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n matrix.copyVec2(body.c_position.c, body.m_sweep.c);\n body.c_position.a = body.m_sweep.a;\n matrix.copyVec2(body.c_velocity.v, body.m_linearVelocity);\n body.c_velocity.w = body.m_angularVelocity;\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initConstraint(subStep);\n }\n\n // Solve position constraints.\n for (let i = 0; i < subStep.positionIterations; ++i) {\n let minSeparation = 0.0;\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n const separation = contact.solvePositionConstraintTOI(subStep, toiA, toiB);\n minSeparation = math_min(minSeparation, separation);\n }\n // We can't expect minSpeparation >= -Settings.linearSlop because we don't\n // push the separation above -Settings.linearSlop.\n const contactsOkay = minSeparation >= -1.5 * Settings.linearSlop;\n if (contactsOkay) {\n break;\n }\n }\n\n if (false) {\n // Is the new position really safe?\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const c = this.m_contacts[i];\n const fA = c.getFixtureA();\n const fB = c.getFixtureB();\n\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n\n const input = new DistanceInput();\n input.proxyA.set(fA.getShape(), indexA);\n input.proxyB.set(fB.getShape(), indexB);\n input.transformA.set(bA.getTransform());\n input.transformB.set(bB.getTransform());\n input.useRadii = false;\n\n const output = new DistanceOutput();\n const cache = new SimplexCache();\n Distance(output, cache, input);\n\n if (output.distance == 0 || cache.count == 3) {\n cache.count += 0;\n }\n }\n }\n\n // Leap of faith to new safe state.\n matrix.copyVec2(toiA.m_sweep.c0, toiA.c_position.c);\n toiA.m_sweep.a0 = toiA.c_position.a;\n matrix.copyVec2(toiB.m_sweep.c0, toiB.c_position.c);\n toiB.m_sweep.a0 = toiB.c_position.a;\n\n // No warm starting is needed for TOI events because warm\n // starting impulses were applied in the discrete solver.\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initVelocityConstraint(subStep);\n }\n\n // Solve velocity constraints.\n for (let i = 0; i < subStep.velocityIterations; ++i) {\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n contact.solveVelocityConstraint(subStep);\n }\n }\n\n // Don't store the TOI contact forces for warm starting\n // because they can be quite large.\n\n const h = subStep.dt;\n\n // Integrate positions\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.c_position.c);\n let a = body.c_position.a;\n matrix.copyVec2(v, body.c_velocity.v);\n let w = body.c_velocity.w;\n\n // Check for large velocities\n matrix.scaleVec2(translation, h, v);\n const translationLengthSqr = matrix.lengthSqrVec2(translation);\n if (translationLengthSqr > Settings.maxTranslationSquared) {\n const ratio = Settings.maxTranslation / math_sqrt(translationLengthSqr);\n matrix.mulVec2(v, ratio);\n }\n\n const rotation = h * w;\n if (rotation * rotation > Settings.maxRotationSquared) {\n const ratio = Settings.maxRotation / math_abs(rotation);\n w *= ratio;\n }\n\n // Integrate\n matrix.plusScaleVec2(c, h, v);\n a += h * w;\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n\n // Sync bodies\n matrix.copyVec2(body.m_sweep.c, c);\n body.m_sweep.a = a;\n matrix.copyVec2(body.m_linearVelocity, v);\n body.m_angularVelocity = w;\n body.synchronizeTransform();\n }\n\n this.postSolveIsland();\n }\n\n /** @internal */\n postSolveIsland(): void {\n for (let c = 0; c < this.m_contacts.length; ++c) {\n const contact = this.m_contacts[c];\n this.m_world.postSolve(contact, contact.m_impulse);\n }\n }\n}\n\n// @ts-ignore\nSolver.TimeStep = TimeStep;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A 2-by-2 matrix. Stored in column-major order.\n */\nexport class Mat22 {\n ex: Vec2;\n ey: Vec2;\n\n constructor(a: number, b: number, c: number, d: number);\n constructor(a: { x: number; y: number }, b: { x: number; y: number });\n constructor();\n constructor(a?, b?, c?, d?) {\n if (typeof a === \"object\" && a !== null) {\n this.ex = Vec2.clone(a);\n this.ey = Vec2.clone(b);\n } else if (typeof a === \"number\") {\n this.ex = Vec2.neo(a, c);\n this.ey = Vec2.neo(b, d);\n } else {\n this.ex = Vec2.zero();\n this.ey = Vec2.zero();\n }\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.ex) && Vec2.isValid(obj.ey);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Mat22.isValid(o), \"Invalid Mat22!\", o);\n }\n\n set(a: Mat22): void;\n set(a: Vec2Value, b: Vec2Value): void;\n set(a: number, b: number, c: number, d: number): void;\n set(a, b?, c?, d?): void {\n if (typeof a === \"number\" && typeof b === \"number\" && typeof c === \"number\"\n && typeof d === \"number\") {\n this.ex.setNum(a, c);\n this.ey.setNum(b, d);\n\n } else if (typeof a === \"object\" && typeof b === \"object\") {\n this.ex.setVec2(a);\n this.ey.setVec2(b);\n\n } else if (typeof a === \"object\") {\n if (_ASSERT) Mat22.assert(a);\n this.ex.setVec2(a.ex);\n this.ey.setVec2(a.ey);\n\n } else {\n if (_ASSERT) console.assert(false);\n }\n }\n\n setIdentity(): void {\n this.ex.x = 1.0;\n this.ey.x = 0.0;\n this.ex.y = 0.0;\n this.ey.y = 1.0;\n }\n\n setZero(): void {\n this.ex.x = 0.0;\n this.ey.x = 0.0;\n this.ex.y = 0.0;\n this.ey.y = 0.0;\n }\n\n getInverse(): Mat22 {\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const imx = new Mat22();\n imx.ex.x = det * d;\n imx.ey.x = -det * b;\n imx.ex.y = -det * c;\n imx.ey.y = det * a;\n return imx;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases.\n */\n solve(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const w = Vec2.zero();\n w.x = det * (d * v.x - b * v.y);\n w.y = det * (a * v.y - c * v.x);\n return w;\n }\n\n /**\n * Multiply a matrix times a vector. If a rotation matrix is provided, then this\n * transforms the vector from one frame to another.\n */\n static mul(mx: Mat22, my: Mat22): Mat22;\n static mul(mx: Mat22, v: Vec2Value): Vec2;\n static mul(mx, v) {\n if (v && \"x\" in v && \"y\" in v) {\n if (_ASSERT) Vec2.assert(v);\n const x = mx.ex.x * v.x + mx.ey.x * v.y;\n const y = mx.ex.y * v.x + mx.ey.y * v.y;\n return Vec2.neo(x, y);\n\n } else if (v && \"ex\" in v && \"ey\" in v) { // Mat22\n if (_ASSERT) Mat22.assert(v);\n // return new Mat22(Vec2.mul(mx, v.ex), Vec2.mul(mx, v.ey));\n const a = mx.ex.x * v.ex.x + mx.ey.x * v.ex.y;\n const b = mx.ex.x * v.ey.x + mx.ey.x * v.ey.y;\n const c = mx.ex.y * v.ex.x + mx.ey.y * v.ex.y;\n const d = mx.ex.y * v.ey.x + mx.ey.y * v.ey.y;\n return new Mat22(a, b, c, d);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulVec2(mx: Mat22, v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n const x = mx.ex.x * v.x + mx.ey.x * v.y;\n const y = mx.ex.y * v.x + mx.ey.y * v.y;\n return Vec2.neo(x, y);\n }\n\n static mulMat22(mx: Mat22, v: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(v);\n // return new Mat22(Vec2.mul(mx, v.ex), Vec2.mul(mx, v.ey));\n const a = mx.ex.x * v.ex.x + mx.ey.x * v.ex.y;\n const b = mx.ex.x * v.ey.x + mx.ey.x * v.ey.y;\n const c = mx.ex.y * v.ex.x + mx.ey.y * v.ex.y;\n const d = mx.ex.y * v.ey.x + mx.ey.y * v.ey.y;\n return new Mat22(a, b, c, d);\n }\n\n /**\n * Multiply a matrix transpose times a vector. If a rotation matrix is provided,\n * then this transforms the vector from one frame to another (inverse\n * transform).\n */\n static mulT(mx: Mat22, my: Mat22): Mat22;\n static mulT(mx: Mat22, v: Vec2Value): Vec2;\n static mulT(mx, v) {\n if (v && \"x\" in v && \"y\" in v) { // Vec2\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(Vec2.dot(v, mx.ex), Vec2.dot(v, mx.ey));\n\n } else if (v && \"ex\" in v && \"ey\" in v) { // Mat22\n if (_ASSERT) Mat22.assert(v);\n const c1 = Vec2.neo(Vec2.dot(mx.ex, v.ex), Vec2.dot(mx.ey, v.ex));\n const c2 = Vec2.neo(Vec2.dot(mx.ex, v.ey), Vec2.dot(mx.ey, v.ey));\n return new Mat22(c1, c2);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulTVec2(mx: Mat22, v: Vec2Value): Vec2 {\n if (_ASSERT) Mat22.assert(mx);\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(Vec2.dot(v, mx.ex), Vec2.dot(v, mx.ey));\n }\n\n static mulTMat22(mx: Mat22, v: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx);\n if (_ASSERT) Mat22.assert(v);\n const c1 = Vec2.neo(Vec2.dot(mx.ex, v.ex), Vec2.dot(mx.ey, v.ex));\n const c2 = Vec2.neo(Vec2.dot(mx.ex, v.ey), Vec2.dot(mx.ey, v.ey));\n return new Mat22(c1, c2);\n }\n\n static abs(mx: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx);\n return new Mat22(Vec2.abs(mx.ex), Vec2.abs(mx.ey));\n }\n\n static add(mx1: Mat22, mx2: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx1);\n if (_ASSERT) Mat22.assert(mx2);\n return new Mat22(Vec2.add(mx1.ex, mx2.ex), Vec2.add(mx1.ey, mx2.ey));\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { Vec2Value } from \"../common/Vec2\";\nimport { TransformValue } from \"../common/Transform\";\nimport { EPSILON } from \"../common/Math\";\n\n\n/** @internal */ const math_sqrt = Math.sqrt;\n\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const cA = matrix.vec2(0, 0);\n/** @internal */ const cB = matrix.vec2(0, 0);\n/** @internal */ const dist = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const clipPoint = matrix.vec2(0, 0);\n\nexport enum ManifoldType {\n e_unset = -1,\n e_circles = 0,\n e_faceA = 1,\n e_faceB = 2\n}\n\nexport enum ContactFeatureType {\n e_unset = -1,\n e_vertex = 0,\n e_face = 1\n}\n\n/**\n * This is used for determining the state of contact points.\n */\n export enum PointState {\n /** Point does not exist */\n nullState = 0,\n /** Point was added in the update */\n addState = 1,\n /** Point persisted across the update */\n persistState = 2,\n /** Point was removed in the update */\n removeState = 3\n}\n\n/**\n * Used for computing contact manifolds.\n */\n export class ClipVertex {\n v = matrix.vec2(0, 0);\n id: ContactID = new ContactID();\n\n set(o: ClipVertex): void {\n matrix.copyVec2(this.v, o.v);\n this.id.set(o.id);\n }\n recycle() {\n matrix.zeroVec2(this.v);\n this.id.recycle();\n }\n}\n\n/**\n * A manifold for two touching convex shapes. Manifolds are created in `evaluate`\n * method of Contact subclasses.\n *\n * Supported manifold types are e_faceA or e_faceB for clip point versus plane\n * with radius and e_circles point versus point with radius.\n *\n * We store contacts in this way so that position correction can account for\n * movement, which is critical for continuous physics. All contact scenarios\n * must be expressed in one of these types. This structure is stored across time\n * steps, so we keep it small.\n */\nexport class Manifold {\n type: ManifoldType;\n\n /**\n * Usage depends on manifold type:\n * - circles: not used\n * - faceA: the normal on polygonA\n * - faceB: the normal on polygonB\n */\n localNormal = matrix.vec2(0, 0);\n\n /**\n * Usage depends on manifold type:\n * - circles: the local center of circleA\n * - faceA: the center of faceA\n * - faceB: the center of faceB\n */\n localPoint = matrix.vec2(0, 0);\n\n /** The points of contact */\n points: ManifoldPoint[] = [ new ManifoldPoint(), new ManifoldPoint() ];\n\n /** The number of manifold points */\n pointCount: number = 0;\n\n set(that: Manifold): void {\n this.type = that.type;\n matrix.copyVec2(this.localNormal, that.localNormal);\n matrix.copyVec2(this.localPoint, that.localPoint);\n this.pointCount = that.pointCount;\n this.points[0].set(that.points[0]);\n this.points[1].set(that.points[1]);\n }\n\n recycle(): void {\n this.type = ManifoldType.e_unset;\n matrix.zeroVec2(this.localNormal);\n matrix.zeroVec2(this.localPoint);\n this.pointCount = 0;\n this.points[0].recycle();\n this.points[1].recycle();\n }\n\n /**\n * Evaluate the manifold with supplied transforms. This assumes modest motion\n * from the original state. This does not change the point count, impulses, etc.\n * The radii must come from the shapes that generated the manifold.\n */\n getWorldManifold(wm: WorldManifold | null, xfA: TransformValue, radiusA: number, xfB: TransformValue, radiusB: number): WorldManifold {\n if (this.pointCount == 0) {\n return wm;\n }\n\n wm = wm || new WorldManifold();\n\n wm.pointCount = this.pointCount;\n\n const normal = wm.normal;\n const points = wm.points;\n const separations = wm.separations;\n\n switch (this.type) {\n case ManifoldType.e_circles: {\n matrix.setVec2(normal, 1.0, 0.0);\n const manifoldPoint = this.points[0];\n matrix.transformVec2(pointA, xfA, this.localPoint);\n matrix.transformVec2(pointB, xfB, manifoldPoint.localPoint);\n matrix.subVec2(dist, pointB, pointA);\n const lengthSqr = matrix.lengthSqrVec2(dist);\n if (lengthSqr > EPSILON * EPSILON) {\n const length = math_sqrt(lengthSqr);\n matrix.scaleVec2(normal, 1 / length, dist);\n }\n matrix.combine2Vec2(cA, 1, pointA, radiusA, normal);\n matrix.combine2Vec2(cB, 1, pointB, -radiusB, normal);\n matrix.combine2Vec2(points[0], 0.5, cA, 0.5, cB);\n separations[0] = matrix.dotVec2(matrix.subVec2(temp, cB, cA), normal);\n break;\n }\n\n case ManifoldType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.localNormal);\n matrix.transformVec2(planePoint, xfA, this.localPoint);\n\n for (let i = 0; i < this.pointCount; ++i) {\n const manifoldPoint = this.points[i];\n matrix.transformVec2(clipPoint, xfB, manifoldPoint.localPoint);\n matrix.combine2Vec2(cA, 1, clipPoint, radiusA - matrix.dotVec2(matrix.subVec2(temp, clipPoint, planePoint), normal), normal);\n matrix.combine2Vec2(cB, 1, clipPoint, -radiusB, normal);\n matrix.combine2Vec2(points[i], 0.5, cA, 0.5, cB);\n separations[i] = matrix.dotVec2(matrix.subVec2(temp, cB, cA), normal);\n }\n break;\n }\n\n case ManifoldType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.localNormal);\n matrix.transformVec2(planePoint, xfB, this.localPoint);\n\n for (let i = 0; i < this.pointCount; ++i) {\n const manifoldPoint = this.points[i];\n matrix.transformVec2(clipPoint, xfA, manifoldPoint.localPoint);\n matrix.combine2Vec2(cB, 1, clipPoint, radiusB - matrix.dotVec2(matrix.subVec2(temp, clipPoint, planePoint), normal), normal);\n matrix.combine2Vec2(cA, 1, clipPoint, -radiusA, normal);\n matrix.combine2Vec2(points[i], 0.5, cA, 0.5, cB);\n separations[i] = matrix.dotVec2(matrix.subVec2(temp, cA, cB), normal);\n }\n // Ensure normal points from A to B.\n matrix.negVec2(normal);\n break;\n }\n }\n\n return wm;\n }\n\n static clipSegmentToLine = clipSegmentToLine;\n static ClipVertex = ClipVertex;\n static getPointStates = getPointStates;\n static PointState = PointState;\n}\n\n/**\n * A manifold point is a contact point belonging to a contact manifold. It holds\n * details related to the geometry and dynamics of the contact points.\n *\n * This structure is stored across time steps, so we keep it small.\n *\n * Note: impulses are used for internal caching and may not provide reliable\n * contact forces, especially for high speed collisions.\n */\nexport class ManifoldPoint {\n /**\n * Usage depends on manifold type:\n * - circles: the local center of circleB\n * - faceA: the local center of circleB or the clip point of polygonB\n * - faceB: the clip point of polygonA\n */\n localPoint = matrix.vec2(0, 0);\n /**\n * The non-penetration impulse\n */\n normalImpulse = 0;\n /**\n * The friction impulse\n */\n tangentImpulse = 0;\n /**\n * Uniquely identifies a contact point between two shapes to facilitate warm starting\n */\n readonly id = new ContactID();\n\n set(that: ManifoldPoint): void {\n matrix.copyVec2(this.localPoint, that.localPoint);\n this.normalImpulse = that.normalImpulse;\n this.tangentImpulse = that.tangentImpulse;\n this.id.set(that.id);\n }\n\n recycle(): void {\n matrix.zeroVec2(this.localPoint);\n this.normalImpulse = 0;\n this.tangentImpulse = 0;\n this.id.recycle();\n }\n}\n\n/**\n * Contact ids to facilitate warm starting.\n * \n * ContactFeature: The features that intersect to form the contact point.\n */\nexport class ContactID {\n\n /**\n * Used to quickly compare contact ids.\n */\n key = -1;\n\n /** ContactFeature index on shapeA */\n indexA = -1;\n\n /** ContactFeature index on shapeB */\n indexB = -1;\n\n /** ContactFeature type on shapeA */\n typeA = ContactFeatureType.e_unset;\n\n /** ContactFeature type on shapeB */\n typeB = ContactFeatureType.e_unset;\n\n setFeatures(indexA: number, typeA: ContactFeatureType, indexB: number, typeB: ContactFeatureType): void {\n this.indexA = indexA;\n this.indexB = indexB;\n this.typeA = typeA;\n this.typeB = typeB;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n set(that: ContactID): void {\n this.indexA = that.indexA;\n this.indexB = that.indexB;\n this.typeA = that.typeA;\n this.typeB = that.typeB;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n swapFeatures(): void {\n const indexA = this.indexA;\n const indexB = this.indexB;\n const typeA = this.typeA;\n const typeB = this.typeB;\n this.indexA = indexB;\n this.indexB = indexA;\n this.typeA = typeB;\n this.typeB = typeA;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n recycle(): void {\n this.indexA = 0;\n this.indexB = 0;\n this.typeA = ContactFeatureType.e_unset;\n this.typeB = ContactFeatureType.e_unset;\n this.key = -1;\n }\n}\n\n/**\n * This is used to compute the current state of a contact manifold.\n */\nexport class WorldManifold {\n /** World vector pointing from A to B */\n normal = matrix.vec2(0, 0);\n\n /** World contact point (point of intersection) */\n points = [matrix.vec2(0, 0), matrix.vec2(0, 0)]; // [maxManifoldPoints]\n\n /** A negative value indicates overlap, in meters */\n separations = [0, 0]; // [maxManifoldPoints]\n\n /** The number of manifold points */\n pointCount = 0;\n\n recycle() {\n matrix.zeroVec2(this.normal);\n matrix.zeroVec2(this.points[0]);\n matrix.zeroVec2(this.points[1]);\n this.separations[0] = 0;\n this.separations[1] = 0;\n this.pointCount = 0;\n }\n}\n\n/**\n * Compute the point states given two manifolds. The states pertain to the\n * transition from manifold1 to manifold2. So state1 is either persist or remove\n * while state2 is either add or persist.\n */\nexport function getPointStates(\n state1: PointState[],\n state2: PointState[],\n manifold1: Manifold,\n manifold2: Manifold\n): void {\n // state1, state2: PointState[Settings.maxManifoldPoints]\n\n // for (var i = 0; i < Settings.maxManifoldPoints; ++i) {\n // state1[i] = PointState.nullState;\n // state2[i] = PointState.nullState;\n // }\n\n // Detect persists and removes.\n for (let i = 0; i < manifold1.pointCount; ++i) {\n const id = manifold1.points[i].id;\n\n state1[i] = PointState.removeState;\n\n for (let j = 0; j < manifold2.pointCount; ++j) {\n if (manifold2.points[j].id.key === id.key) {\n state1[i] = PointState.persistState;\n break;\n }\n }\n }\n\n // Detect persists and adds.\n for (let i = 0; i < manifold2.pointCount; ++i) {\n const id = manifold2.points[i].id;\n\n state2[i] = PointState.addState;\n\n for (let j = 0; j < manifold1.pointCount; ++j) {\n if (manifold1.points[j].id.key === id.key) {\n state2[i] = PointState.persistState;\n break;\n }\n }\n }\n}\n\n/**\n * Clipping for contact manifolds. Sutherland-Hodgman clipping.\n */\nexport function clipSegmentToLine(\n vOut: ClipVertex[],\n vIn: ClipVertex[],\n normal: Vec2Value,\n offset: number,\n vertexIndexA: number\n): number {\n // Start with no output points\n let numOut = 0;\n\n // Calculate the distance of end points to the line\n const distance0 = matrix.dotVec2(normal, vIn[0].v) - offset;\n const distance1 = matrix.dotVec2(normal, vIn[1].v) - offset;\n\n // If the points are behind the plane\n if (distance0 <= 0.0)\n vOut[numOut++].set(vIn[0]);\n if (distance1 <= 0.0)\n vOut[numOut++].set(vIn[1]);\n\n // If the points are on different sides of the plane\n if (distance0 * distance1 < 0.0) {\n // Find intersection point of edge and plane\n const interp = distance0 / (distance0 - distance1);\n matrix.combine2Vec2(vOut[numOut].v, 1 - interp, vIn[0].v, interp, vIn[1].v);\n\n // VertexA is hitting edgeB.\n vOut[numOut].id.setFeatures(vertexIndexA, ContactFeatureType.e_vertex, vIn[0].id.indexB, ContactFeatureType.e_face);\n ++numOut;\n }\n\n return numOut;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { ShapeType } from \"../collision/Shape\";\nimport { clamp } from \"../common/Math\";\nimport { TransformValue } from \"../common/Transform\";\nimport { Mat22 } from \"../common/Mat22\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { Manifold, ManifoldType, WorldManifold } from \"../collision/Manifold\";\nimport { testOverlap } from \"../collision/Distance\";\nimport { Fixture } from \"./Fixture\";\nimport { Body } from \"./Body\";\nimport { ContactImpulse, TimeStep } from \"./Solver\";\nimport { Pool } from \"../util/Pool\";\nimport { getTransform } from \"./Position\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n// Solver debugging is normally disabled because the block solver sometimes has to deal with a poorly conditioned effective mass matrix.\n/** @internal */ const DEBUG_SOLVER = false;\n\n/** @internal */ const contactPool = new Pool({\n create() {\n return new Contact();\n },\n release(contact: Contact) {\n contact.recycle();\n }\n});\n\n/** @internal */ const oldManifold = new Manifold();\n\n/** @internal */ const worldManifold = new WorldManifold();\n\n/**\n * A contact edge is used to connect bodies and contacts together in a contact\n * graph where each body is a node and each contact is an edge. A contact edge\n * belongs to a doubly linked list maintained in each attached body. Each\n * contact has two contact nodes, one for each attached body.\n */\nexport class ContactEdge {\n contact: Contact;\n prev: ContactEdge | null = null;\n next: ContactEdge | null = null;\n other: Body | null = null;\n constructor(contact: Contact) {\n this.contact = contact;\n }\n\n /** @internal */\n recycle() {\n this.prev = null;\n this.next = null;\n this.other = null;\n }\n}\n\nexport type EvaluateFunction = (\n manifold: Manifold,\n xfA: TransformValue,\n fixtureA: Fixture,\n indexA: number,\n xfB: TransformValue,\n fixtureB: Fixture,\n indexB: number\n) => void;\n\n/**\n * Friction mixing law. The idea is to allow either fixture to drive the\n * friction to zero. For example, anything slides on ice.\n */\nexport function mixFriction(friction1: number, friction2: number): number {\n return math_sqrt(friction1 * friction2);\n}\n\n/**\n * Restitution mixing law. The idea is allow for anything to bounce off an\n * inelastic surface. For example, a superball bounces on anything.\n */\nexport function mixRestitution(restitution1: number, restitution2: number): number {\n return restitution1 > restitution2 ? restitution1 : restitution2;\n}\n\n// TODO: move this to Settings?\n/** @internal */ const s_registers = [];\n\n// TODO: merge with ManifoldPoint?\nexport class VelocityConstraintPoint {\n rA = matrix.vec2(0, 0);\n rB = matrix.vec2(0, 0);\n normalImpulse = 0;\n tangentImpulse = 0;\n normalMass = 0;\n tangentMass = 0;\n velocityBias = 0;\n\n recycle() {\n matrix.zeroVec2(this.rA);\n matrix.zeroVec2(this.rB);\n this.normalImpulse = 0;\n this.tangentImpulse = 0;\n this.normalMass = 0;\n this.tangentMass = 0;\n this.velocityBias = 0;\n }\n}\n\n/** @internal */ const cA = matrix.vec2(0, 0);\n/** @internal */ const vA = matrix.vec2(0, 0);\n/** @internal */ const cB = matrix.vec2(0, 0);\n/** @internal */ const vB = matrix.vec2(0, 0);\n/** @internal */ const tangent = matrix.vec2(0, 0);\n/** @internal */ const xfA = matrix.transform(0, 0, 0);\n/** @internal */ const xfB = matrix.transform(0, 0, 0);\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const clipPoint = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const rA = matrix.vec2(0, 0);\n/** @internal */ const rB = matrix.vec2(0, 0);\n/** @internal */ const P = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const point = matrix.vec2(0, 0);\n/** @internal */ const dv = matrix.vec2(0, 0);\n/** @internal */ const dv1 = matrix.vec2(0, 0);\n/** @internal */ const dv2 = matrix.vec2(0, 0);\n/** @internal */ const b = matrix.vec2(0, 0);\n/** @internal */ const a = matrix.vec2(0, 0);\n/** @internal */ const x = matrix.vec2(0, 0);\n/** @internal */ const d = matrix.vec2(0, 0);\n/** @internal */ const P1 = matrix.vec2(0, 0);\n/** @internal */ const P2 = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n\n/**\n * The class manages contact between two shapes. A contact exists for each\n * overlapping AABB in the broad-phase (except if filtered). Therefore a contact\n * object may exist that has no contact points.\n */\nexport class Contact {\n // Nodes for connecting bodies.\n /** @internal */ m_nodeA = new ContactEdge(this);\n /** @internal */ m_nodeB = new ContactEdge(this);\n /** @internal */ m_fixtureA: Fixture | null = null;\n /** @internal */ m_fixtureB: Fixture | null = null;\n /** @internal */ m_indexA = -1;\n /** @internal */ m_indexB = -1;\n /** @internal */ m_evaluateFcn: EvaluateFunction | null = null;\n /** @internal */ m_manifold: Manifold = new Manifold();\n /** @internal */ m_prev: Contact | null = null;\n /** @internal */ m_next: Contact | null = null;\n /** @internal */ m_toi = 1.0;\n /** @internal */ m_toiCount = 0;\n // This contact has a valid TOI in m_toi\n /** @internal */ m_toiFlag = false;\n /** @internal */ m_friction = 0.0;\n /** @internal */ m_restitution = 0.0;\n /** @internal */ m_tangentSpeed = 0.0;\n /** @internal This contact can be disabled (by user) */\n m_enabledFlag = true;\n /** @internal Used when crawling contact graph when forming islands. */\n m_islandFlag = false;\n /** @internal Set when the shapes are touching. */\n m_touchingFlag = false;\n /** @internal This contact needs filtering because a fixture filter was changed. */\n m_filterFlag = false;\n /** @internal This bullet contact had a TOI event */\n m_bulletHitFlag = false;\n\n /** @internal Contact reporting impulse object cache */\n m_impulse: ContactImpulse = new ContactImpulse(this);\n\n // VelocityConstraint\n /** @internal */ v_points = [new VelocityConstraintPoint(), new VelocityConstraintPoint()]; // [maxManifoldPoints];\n /** @internal */ v_normal = matrix.vec2(0, 0);\n /** @internal */ v_normalMass: Mat22 = new Mat22();\n /** @internal */ v_K: Mat22 = new Mat22();\n /** @internal */ v_pointCount = 0;\n /** @internal */ v_tangentSpeed = 0;\n /** @internal */ v_friction = 0;\n /** @internal */ v_restitution = 0;\n /** @internal */ v_invMassA = 0;\n /** @internal */ v_invMassB = 0;\n /** @internal */ v_invIA = 0;\n /** @internal */ v_invIB = 0;\n\n // PositionConstraint\n /** @internal */ p_localPoints = [matrix.vec2(0, 0), matrix.vec2(0, 0)]; // [maxManifoldPoints];\n /** @internal */ p_localNormal = matrix.vec2(0, 0);\n /** @internal */ p_localPoint = matrix.vec2(0, 0);\n /** @internal */ p_localCenterA = matrix.vec2(0, 0);\n /** @internal */ p_localCenterB = matrix.vec2(0, 0);\n /** @internal */ p_type = ManifoldType.e_unset;\n /** @internal */ p_radiusA = 0;\n /** @internal */ p_radiusB = 0;\n /** @internal */ p_pointCount = 0;\n /** @internal */ p_invMassA = 0;\n /** @internal */ p_invMassB = 0;\n /** @internal */ p_invIA = 0;\n /** @internal */ p_invIB = 0;\n\n /** @internal */ \n initialize(fA: Fixture, indexA: number, fB: Fixture, indexB: number, evaluateFcn: EvaluateFunction) {\n this.m_fixtureA = fA;\n this.m_fixtureB = fB;\n\n this.m_indexA = indexA;\n this.m_indexB = indexB;\n\n this.m_evaluateFcn = evaluateFcn;\n\n this.m_friction = mixFriction(this.m_fixtureA.m_friction, this.m_fixtureB.m_friction);\n this.m_restitution = mixRestitution(this.m_fixtureA.m_restitution, this.m_fixtureB.m_restitution);\n }\n\n /** @internal */ \n recycle() {\n this.m_nodeA.recycle();\n this.m_nodeB.recycle();\n this.m_fixtureA = null;\n this.m_fixtureB = null;\n this.m_indexA = -1;\n this.m_indexB = -1;\n this.m_evaluateFcn = null;\n this.m_manifold.recycle();\n this.m_prev = null;\n this.m_next = null;\n this.m_toi = 1;\n this.m_toiCount = 0;\n this.m_toiFlag = false;\n this.m_friction = 0;\n this.m_restitution = 0;\n this.m_tangentSpeed = 0;\n this.m_enabledFlag = true;\n this.m_islandFlag = false;\n this.m_touchingFlag = false;\n this.m_filterFlag = false;\n this.m_bulletHitFlag = false;\n\n this.m_impulse.recycle();\n\n // VelocityConstraint\n for(const point of this.v_points) {\n point.recycle();\n }\n matrix.zeroVec2(this.v_normal);\n this.v_normalMass.setZero();\n this.v_K.setZero();\n this.v_pointCount = 0;\n this.v_tangentSpeed = 0;\n this.v_friction = 0;\n this.v_restitution = 0;\n this.v_invMassA = 0;\n this.v_invMassB = 0;\n this.v_invIA = 0;\n this.v_invIB = 0;\n\n // PositionConstraint\n for(const point of this.p_localPoints) {\n matrix.zeroVec2(point);\n }\n matrix.zeroVec2(this.p_localNormal);\n matrix.zeroVec2(this.p_localPoint);\n matrix.zeroVec2(this.p_localCenterA);\n matrix.zeroVec2(this.p_localCenterB);\n this.p_type = ManifoldType.e_unset;\n this.p_radiusA = 0;\n this.p_radiusB = 0;\n this.p_pointCount = 0;\n this.p_invMassA = 0;\n this.p_invMassB = 0;\n this.p_invIA = 0;\n this.p_invIB = 0;\n }\n\n initConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n const manifold = this.m_manifold;\n\n const pointCount = manifold.pointCount;\n if (_ASSERT) console.assert(pointCount > 0);\n\n this.v_invMassA = bodyA.m_invMass;\n this.v_invMassB = bodyB.m_invMass;\n this.v_invIA = bodyA.m_invI;\n this.v_invIB = bodyB.m_invI;\n\n this.v_friction = this.m_friction;\n this.v_restitution = this.m_restitution;\n this.v_tangentSpeed = this.m_tangentSpeed;\n\n this.v_pointCount = pointCount;\n\n this.v_K.setZero();\n this.v_normalMass.setZero();\n\n this.p_invMassA = bodyA.m_invMass;\n this.p_invMassB = bodyB.m_invMass;\n this.p_invIA = bodyA.m_invI;\n this.p_invIB = bodyB.m_invI;\n matrix.copyVec2(this.p_localCenterA, bodyA.m_sweep.localCenter);\n matrix.copyVec2(this.p_localCenterB, bodyB.m_sweep.localCenter);\n\n this.p_radiusA = shapeA.m_radius;\n this.p_radiusB = shapeB.m_radius;\n\n this.p_type = manifold.type;\n matrix.copyVec2(this.p_localNormal, manifold.localNormal);\n matrix.copyVec2(this.p_localPoint, manifold.localPoint);\n this.p_pointCount = pointCount;\n\n for (let j = 0; j < Settings.maxManifoldPoints; ++j) {\n this.v_points[j].recycle();\n matrix.zeroVec2(this.p_localPoints[j]);\n }\n\n for (let j = 0; j < pointCount; ++j) {\n const cp = manifold.points[j];\n const vcp = this.v_points[j];\n if (step.warmStarting) {\n vcp.normalImpulse = step.dtRatio * cp.normalImpulse;\n vcp.tangentImpulse = step.dtRatio * cp.tangentImpulse;\n }\n matrix.copyVec2(this.p_localPoints[j], cp.localPoint);\n }\n }\n\n /**\n * Get the contact manifold. Do not modify the manifold unless you understand\n * the internals of the library.\n */\n getManifold(): Manifold {\n return this.m_manifold;\n }\n\n /**\n * Get the world manifold.\n */\n getWorldManifold(worldManifold: WorldManifold | null): WorldManifold | undefined {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n return this.m_manifold.getWorldManifold(\n worldManifold,\n bodyA.getTransform(), shapeA.m_radius,\n bodyB.getTransform(), shapeB.m_radius\n );\n }\n\n /**\n * Enable/disable this contact. This can be used inside the pre-solve contact\n * listener. The contact is only disabled for the current time step (or sub-step\n * in continuous collisions).\n */\n setEnabled(flag: boolean): void {\n this.m_enabledFlag = !!flag;\n }\n\n /**\n * Has this contact been disabled?\n */\n isEnabled(): boolean {\n return this.m_enabledFlag;\n }\n\n /**\n * Is this contact touching?\n */\n isTouching(): boolean {\n return this.m_touchingFlag;\n }\n\n /**\n * Get the next contact in the world's contact list.\n */\n getNext(): Contact | null {\n return this.m_next;\n }\n\n /**\n * Get fixture A in this contact.\n */\n getFixtureA(): Fixture {\n return this.m_fixtureA;\n }\n\n /**\n * Get fixture B in this contact.\n */\n getFixtureB(): Fixture {\n return this.m_fixtureB;\n }\n\n /**\n * Get the child primitive index for fixture A.\n */\n getChildIndexA(): number {\n return this.m_indexA;\n }\n\n /**\n * Get the child primitive index for fixture B.\n */\n getChildIndexB(): number {\n return this.m_indexB;\n }\n\n /**\n * Flag this contact for filtering. Filtering will occur the next time step.\n */\n flagForFiltering(): void {\n this.m_filterFlag = true;\n }\n\n /**\n * Override the default friction mixture. You can call this in\n * \"pre-solve\" callback. This value persists until set or reset.\n */\n setFriction(friction: number): void {\n this.m_friction = friction;\n }\n\n /**\n * Get the friction.\n */\n getFriction(): number {\n return this.m_friction;\n }\n\n /**\n * Reset the friction mixture to the default value.\n */\n resetFriction(): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_friction = mixFriction(fixtureA.m_friction, fixtureB.m_friction);\n }\n\n /**\n * Override the default restitution mixture. You can call this in\n * \"pre-solve\" callback. The value persists until you set or reset.\n */\n setRestitution(restitution: number): void {\n this.m_restitution = restitution;\n }\n\n /**\n * Get the restitution.\n */\n getRestitution(): number {\n return this.m_restitution;\n }\n\n /**\n * Reset the restitution to the default value.\n */\n resetRestitution(): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_restitution = mixRestitution(fixtureA.m_restitution, fixtureB.m_restitution);\n }\n\n /**\n * Set the desired tangent speed for a conveyor belt behavior. In meters per\n * second.\n */\n setTangentSpeed(speed: number): void {\n this.m_tangentSpeed = speed;\n }\n\n /**\n * Get the desired tangent speed. In meters per second.\n */\n getTangentSpeed(): number {\n return this.m_tangentSpeed;\n }\n\n /**\n * Called by Update method, and implemented by subclasses.\n */\n evaluate(manifold: Manifold, xfA: TransformValue, xfB: TransformValue): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_evaluateFcn(manifold, xfA, fixtureA, this.m_indexA, xfB, fixtureB, this.m_indexB);\n }\n\n /**\n * Updates the contact manifold and touching status.\n *\n * Note: do not assume the fixture AABBs are overlapping or are valid.\n *\n * @param listener.beginContact\n * @param listener.endContact\n * @param listener.preSolve\n */\n update(listener?: {\n beginContact(contact: Contact): void,\n endContact(contact: Contact): void,\n preSolve(contact: Contact, oldManifold: Manifold): void\n }): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n // Re-enable this contact.\n this.m_enabledFlag = true;\n\n let touching = false;\n const wasTouching = this.m_touchingFlag;\n\n const sensorA = fixtureA.m_isSensor;\n const sensorB = fixtureB.m_isSensor;\n const sensor = sensorA || sensorB;\n\n const xfA = bodyA.m_xf;\n const xfB = bodyB.m_xf;\n\n // Is this contact a sensor?\n if (sensor) {\n touching = testOverlap(shapeA, this.m_indexA, shapeB, this.m_indexB, xfA, xfB);\n\n // Sensors don't generate manifolds.\n this.m_manifold.pointCount = 0;\n } else {\n\n oldManifold.recycle();\n oldManifold.set(this.m_manifold);\n this.m_manifold.recycle();\n\n this.evaluate(this.m_manifold, xfA, xfB);\n touching = this.m_manifold.pointCount > 0;\n\n // Match old contact ids to new contact ids and copy the\n // stored impulses to warm start the solver.\n for (let i = 0; i < this.m_manifold.pointCount; ++i) {\n const nmp = this.m_manifold.points[i];\n nmp.normalImpulse = 0.0;\n nmp.tangentImpulse = 0.0;\n\n for (let j = 0; j < oldManifold.pointCount; ++j) {\n const omp = oldManifold.points[j];\n if (omp.id.key === nmp.id.key) {\n nmp.normalImpulse = omp.normalImpulse;\n nmp.tangentImpulse = omp.tangentImpulse;\n break;\n }\n }\n }\n\n if (touching !== wasTouching) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n }\n\n this.m_touchingFlag = touching;\n\n const hasListener = typeof listener === \"object\" && listener !== null;\n\n if (!wasTouching && touching && hasListener) {\n listener.beginContact(this);\n }\n\n if (wasTouching && !touching && hasListener) {\n listener.endContact(this);\n }\n\n if (!sensor && touching && hasListener && oldManifold) {\n listener.preSolve(this, oldManifold);\n }\n }\n\n solvePositionConstraint(step: TimeStep): number {\n return this._solvePositionConstraint(step, null, null);\n }\n\n solvePositionConstraintTOI(step: TimeStep, toiA: Body, toiB: Body): number {\n return this._solvePositionConstraint(step, toiA, toiB);\n }\n\n private _solvePositionConstraint(step: TimeStep, toiA: Body | null, toiB: Body | null): number {\n const toi = toiA !== null && toiB !== null ? true : false;\n let minSeparation = 0.0;\n\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return minSeparation;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return minSeparation;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const localCenterA = this.p_localCenterA;\n const localCenterB = this.p_localCenterB;\n\n let mA = 0.0;\n let iA = 0.0;\n if (!toi || (bodyA === toiA || bodyA === toiB)) {\n mA = this.p_invMassA;\n iA = this.p_invIA;\n }\n\n let mB = 0.0;\n let iB = 0.0;\n if (!toi || (bodyB === toiA || bodyB === toiB)) {\n mB = this.p_invMassB;\n iB = this.p_invIB;\n }\n\n matrix.copyVec2(cA, positionA.c);\n let aA = positionA.a;\n\n matrix.copyVec2(cB, positionB.c);\n let aB = positionB.a;\n\n // Solve normal constraints\n for (let j = 0; j < this.p_pointCount; ++j) {\n getTransform(xfA, localCenterA, cA, aA);\n getTransform(xfB, localCenterB, cB, aB);\n\n // PositionSolverManifold\n let separation: number;\n switch (this.p_type) {\n case ManifoldType.e_circles: {\n matrix.transformVec2(pointA, xfA, this.p_localPoint);\n matrix.transformVec2(pointB, xfB, this.p_localPoints[0]);\n matrix.subVec2(normal, pointB, pointA);\n matrix.normalizeVec2(normal);\n\n matrix.combine2Vec2(point, 0.5, pointA, 0.5, pointB);\n separation = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal) - this.p_radiusA - this.p_radiusB;\n break;\n }\n\n case ManifoldType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.p_localNormal);\n matrix.transformVec2(planePoint, xfA, this.p_localPoint);\n matrix.transformVec2(clipPoint, xfB, this.p_localPoints[j]);\n separation = matrix.dotVec2(clipPoint, normal) - matrix.dotVec2(planePoint, normal) - this.p_radiusA - this.p_radiusB;\n matrix.copyVec2(point, clipPoint);\n break;\n }\n\n case ManifoldType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.p_localNormal);\n matrix.transformVec2(planePoint, xfB, this.p_localPoint);\n matrix.transformVec2(clipPoint, xfA, this.p_localPoints[j]);\n separation = matrix.dotVec2(clipPoint, normal) - matrix.dotVec2(planePoint, normal) - this.p_radiusA - this.p_radiusB;\n matrix.copyVec2(point, clipPoint);\n\n // Ensure normal points from A to B\n matrix.negVec2(normal);\n break;\n }\n // todo: what should we do here?\n default: {\n return minSeparation;\n }\n }\n\n matrix.subVec2(rA, point, cA);\n matrix.subVec2(rB, point, cB);\n\n // Track max constraint error.\n minSeparation = math_min(minSeparation, separation);\n\n const baumgarte = toi ? Settings.toiBaugarte : Settings.baumgarte;\n const linearSlop = Settings.linearSlop;\n const maxLinearCorrection = Settings.maxLinearCorrection;\n\n // Prevent large corrections and allow slop.\n const C = clamp(baumgarte * (separation + linearSlop), -maxLinearCorrection, 0.0);\n\n // Compute the effective mass.\n const rnA = matrix.crossVec2Vec2(rA, normal);\n const rnB = matrix.crossVec2Vec2(rB, normal);\n const K = mA + mB + iA * rnA * rnA + iB * rnB * rnB;\n\n // Compute normal impulse\n const impulse = K > 0.0 ? -C / K : 0.0;\n\n matrix.scaleVec2(P, impulse, normal);\n\n matrix.minusScaleVec2(cA, mA, P);\n aA -= iA * matrix.crossVec2Vec2(rA, P);\n\n matrix.plusScaleVec2(cB, mB, P);\n aB += iB * matrix.crossVec2Vec2(rB, P);\n }\n\n matrix.copyVec2(positionA.c, cA);\n positionA.a = aA;\n\n matrix.copyVec2(positionB.c, cB);\n positionB.a = aB;\n\n return minSeparation;\n }\n\n initVelocityConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const radiusA = this.p_radiusA;\n const radiusB = this.p_radiusB;\n const manifold = this.m_manifold;\n\n const mA = this.v_invMassA;\n const mB = this.v_invMassB;\n const iA = this.v_invIA;\n const iB = this.v_invIB;\n const localCenterA = this.p_localCenterA;\n const localCenterB = this.p_localCenterB;\n\n matrix.copyVec2(cA, positionA.c);\n const aA = positionA.a;\n matrix.copyVec2(vA, velocityA.v);\n const wA = velocityA.w;\n\n matrix.copyVec2(cB, positionB.c);\n const aB = positionB.a;\n matrix.copyVec2(vB, velocityB.v);\n const wB = velocityB.w;\n\n if (_ASSERT) console.assert(manifold.pointCount > 0);\n\n getTransform(xfA, localCenterA, cA, aA);\n getTransform(xfB, localCenterB, cB, aB);\n\n worldManifold.recycle();\n manifold.getWorldManifold(worldManifold, xfA, radiusA, xfB, radiusB);\n\n matrix.copyVec2(this.v_normal, worldManifold.normal);\n\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n const wmp = worldManifold.points[j];\n\n matrix.subVec2(vcp.rA, wmp, cA);\n matrix.subVec2(vcp.rB, wmp, cB);\n\n const rnA = matrix.crossVec2Vec2(vcp.rA, this.v_normal);\n const rnB = matrix.crossVec2Vec2(vcp.rB, this.v_normal);\n\n const kNormal = mA + mB + iA * rnA * rnA + iB * rnB * rnB;\n\n vcp.normalMass = kNormal > 0.0 ? 1.0 / kNormal : 0.0;\n\n matrix.crossVec2Num(tangent, this.v_normal, 1.0);\n\n const rtA = matrix.crossVec2Vec2(vcp.rA, tangent);\n const rtB = matrix.crossVec2Vec2(vcp.rB, tangent);\n\n const kTangent = mA + mB + iA * rtA * rtA + iB * rtB * rtB;\n\n vcp.tangentMass = kTangent > 0.0 ? 1.0 / kTangent : 0.0;\n\n // Setup a velocity bias for restitution.\n vcp.velocityBias = 0.0;\n let vRel = 0;\n vRel += matrix.dotVec2(this.v_normal, vB);\n vRel += matrix.dotVec2(this.v_normal, matrix.crossNumVec2(temp, wB, vcp.rB));\n vRel -= matrix.dotVec2(this.v_normal, vA);\n vRel -= matrix.dotVec2(this.v_normal, matrix.crossNumVec2(temp, wA, vcp.rA));\n if (vRel < -Settings.velocityThreshold) {\n vcp.velocityBias = -this.v_restitution * vRel;\n }\n }\n\n // If we have two points, then prepare the block solver.\n if (this.v_pointCount == 2 && step.blockSolve) {\n const vcp1 = this.v_points[0]; // VelocityConstraintPoint\n const vcp2 = this.v_points[1]; // VelocityConstraintPoint\n\n const rn1A = matrix.crossVec2Vec2(vcp1.rA, this.v_normal);\n const rn1B = matrix.crossVec2Vec2(vcp1.rB, this.v_normal);\n const rn2A = matrix.crossVec2Vec2(vcp2.rA, this.v_normal);\n const rn2B = matrix.crossVec2Vec2(vcp2.rB, this.v_normal);\n\n const k11 = mA + mB + iA * rn1A * rn1A + iB * rn1B * rn1B;\n const k22 = mA + mB + iA * rn2A * rn2A + iB * rn2B * rn2B;\n const k12 = mA + mB + iA * rn1A * rn2A + iB * rn1B * rn2B;\n\n // Ensure a reasonable condition number.\n const k_maxConditionNumber = 1000.0;\n if (k11 * k11 < k_maxConditionNumber * (k11 * k22 - k12 * k12)) {\n // K is safe to invert.\n this.v_K.ex.setNum(k11, k12);\n this.v_K.ey.setNum(k12, k22);\n // this.v_normalMass.set(this.v_K.getInverse());\n const a = this.v_K.ex.x;\n const b = this.v_K.ey.x;\n const c = this.v_K.ex.y;\n const d = this.v_K.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n this.v_normalMass.ex.x = det * d;\n this.v_normalMass.ey.x = -det * b;\n this.v_normalMass.ex.y = -det * c;\n this.v_normalMass.ey.y = det * a;\n\n } else {\n // The constraints are redundant, just use one.\n // TODO_ERIN use deepest?\n this.v_pointCount = 1;\n }\n }\n\n matrix.copyVec2(positionA.c, cA);\n positionA.a = aA;\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n\n matrix.copyVec2(positionB.c, cB);\n positionB.a = aB;\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n warmStartConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const mA = this.v_invMassA;\n const iA = this.v_invIA;\n const mB = this.v_invMassB;\n const iB = this.v_invIB;\n\n matrix.copyVec2(vA, velocityA.v);\n let wA = velocityA.w;\n matrix.copyVec2(vB, velocityB.v);\n let wB = velocityB.w;\n\n matrix.copyVec2(normal, this.v_normal);\n matrix.crossVec2Num(tangent, normal, 1.0);\n\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n\n matrix.combine2Vec2(P, vcp.normalImpulse, normal, vcp.tangentImpulse, tangent);\n\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n matrix.minusScaleVec2(vA, mA, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n matrix.plusScaleVec2(vB, mB, P);\n }\n\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n storeConstraintImpulses(step: TimeStep): void {\n const manifold = this.m_manifold;\n for (let j = 0; j < this.v_pointCount; ++j) {\n manifold.points[j].normalImpulse = this.v_points[j].normalImpulse;\n manifold.points[j].tangentImpulse = this.v_points[j].tangentImpulse;\n }\n }\n\n solveVelocityConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const positionA = bodyA.c_position;\n\n const velocityB = bodyB.c_velocity;\n const positionB = bodyB.c_position;\n\n const mA = this.v_invMassA;\n const iA = this.v_invIA;\n const mB = this.v_invMassB;\n const iB = this.v_invIB;\n\n matrix.copyVec2(vA, velocityA.v);\n let wA = velocityA.w;\n matrix.copyVec2(vB, velocityB.v);\n let wB = velocityB.w;\n\n matrix.copyVec2(normal, this.v_normal);\n matrix.crossVec2Num(tangent, normal, 1.0);\n const friction = this.v_friction;\n\n if (_ASSERT) console.assert(this.v_pointCount == 1 || this.v_pointCount == 2);\n\n // Solve tangent constraints first because non-penetration is more important\n // than friction.\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n\n // Relative velocity at contact\n matrix.zeroVec2(dv);\n matrix.plusVec2(dv, vB);\n matrix.plusVec2(dv, matrix.crossNumVec2(temp, wB, vcp.rB));\n matrix.minusVec2(dv, vA);\n matrix.minusVec2(dv, matrix.crossNumVec2(temp, wA, vcp.rA));\n\n // Compute tangent force\n const vt = matrix.dotVec2(dv, tangent) - this.v_tangentSpeed;\n let lambda = vcp.tangentMass * (-vt);\n\n // Clamp the accumulated force\n const maxFriction = friction * vcp.normalImpulse;\n const newImpulse = clamp(vcp.tangentImpulse + lambda, -maxFriction, maxFriction);\n lambda = newImpulse - vcp.tangentImpulse;\n vcp.tangentImpulse = newImpulse;\n\n // Apply contact impulse\n matrix.scaleVec2(P, lambda, tangent);\n\n matrix.minusScaleVec2(vA, mA, P);\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n\n matrix.plusScaleVec2(vB, mB, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n }\n\n // Solve normal constraints\n if (this.v_pointCount == 1 || step.blockSolve == false) {\n for (let i = 0; i < this.v_pointCount; ++i) {\n const vcp = this.v_points[i]; // VelocityConstraintPoint\n\n // Relative velocity at contact\n matrix.zeroVec2(dv);\n matrix.plusVec2(dv, vB);\n matrix.plusVec2(dv, matrix.crossNumVec2(temp, wB, vcp.rB));\n matrix.minusVec2(dv, vA);\n matrix.minusVec2(dv, matrix.crossNumVec2(temp, wA, vcp.rA));\n\n // Compute normal impulse\n const vn = matrix.dotVec2(dv, normal);\n let lambda = -vcp.normalMass * (vn - vcp.velocityBias);\n\n // Clamp the accumulated impulse\n const newImpulse = math_max(vcp.normalImpulse + lambda, 0.0);\n lambda = newImpulse - vcp.normalImpulse;\n vcp.normalImpulse = newImpulse;\n\n // Apply contact impulse\n matrix.scaleVec2(P, lambda, normal);\n\n matrix.minusScaleVec2(vA, mA, P);\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n\n matrix.plusScaleVec2(vB, mB, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n }\n } else {\n // Block solver developed in collaboration with Dirk Gregorius (back in\n // 01/07 on Box2D_Lite).\n // Build the mini LCP for this contact patch\n //\n // vn = A * x + b, vn >= 0, x >= 0 and vn_i * x_i = 0 with i = 1..2\n //\n // A = J * W * JT and J = ( -n, -r1 x n, n, r2 x n )\n // b = vn0 - velocityBias\n //\n // The system is solved using the \"Total enumeration method\" (s. Murty).\n // The complementary constraint vn_i * x_i\n // implies that we must have in any solution either vn_i = 0 or x_i = 0.\n // So for the 2D contact problem the cases\n // vn1 = 0 and vn2 = 0, x1 = 0 and x2 = 0, x1 = 0 and vn2 = 0, x2 = 0 and\n // vn1 = 0 need to be tested. The first valid\n // solution that satisfies the problem is chosen.\n //\n // In order to account of the accumulated impulse 'a' (because of the\n // iterative nature of the solver which only requires\n // that the accumulated impulse is clamped and not the incremental\n // impulse) we change the impulse variable (x_i).\n //\n // Substitute:\n //\n // x = a + d\n //\n // a := old total impulse\n // x := new total impulse\n // d := incremental impulse\n //\n // For the current iteration we extend the formula for the incremental\n // impulse\n // to compute the new total impulse:\n //\n // vn = A * d + b\n // = A * (x - a) + b\n // = A * x + b - A * a\n // = A * x + b'\n // b' = b - A * a;\n\n const vcp1 = this.v_points[0]; // VelocityConstraintPoint\n const vcp2 = this.v_points[1]; // VelocityConstraintPoint\n\n matrix.setVec2(a, vcp1.normalImpulse, vcp2.normalImpulse);\n if (_ASSERT) console.assert(a.x >= 0.0 && a.y >= 0.0);\n\n // Relative velocity at contact\n // let dv1 = Vec2.zero().add(vB).add(Vec2.crossNumVec2(wB, vcp1.rB)).sub(vA).sub(Vec2.crossNumVec2(wA, vcp1.rA));\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n // let dv2 = Vec2.zero().add(vB).add(Vec2.crossNumVec2(wB, vcp2.rB)).sub(vA).sub(Vec2.crossNumVec2(wA, vcp2.rA));\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n let vn1 = matrix.dotVec2(dv1, normal);\n let vn2 = matrix.dotVec2(dv2, normal);\n\n matrix.setVec2(b, vn1 - vcp1.velocityBias, vn2 - vcp2.velocityBias);\n\n // Compute b'\n // b.sub(Mat22.mulVec2(this.v_K, a));\n b.x -= this.v_K.ex.x * a.x + this.v_K.ey.x * a.y;\n b.y -= this.v_K.ex.y * a.x + this.v_K.ey.y * a.y;\n\n const k_errorTol = 1e-3;\n // NOT_USED(k_errorTol);\n\n while (true) {\n //\n // Case 1: vn = 0\n //\n // 0 = A * x + b'\n //\n // Solve for x:\n //\n // x = - inv(A) * b'\n //\n // const x = Mat22.mulVec2(this.v_normalMass, b).neg();\n matrix.zeroVec2(x);\n x.x = -(this.v_normalMass.ex.x * b.x + this.v_normalMass.ey.x * b.y);\n x.y = -(this.v_normalMass.ex.y * b.x + this.v_normalMass.ey.y * b.y);\n\n if (x.x >= 0.0 && x.y >= 0.0) {\n // Get the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n vn1 = matrix.dotVec2(dv1, normal);\n vn2 = matrix.dotVec2(dv2, normal);\n\n if (_ASSERT) console.assert(math_abs(vn1 - vcp1.velocityBias) < k_errorTol);\n if (_ASSERT) console.assert(math_abs(vn2 - vcp2.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 2: vn1 = 0 and x2 = 0\n //\n // 0 = a11 * x1 + a12 * 0 + b1'\n // vn2 = a21 * x1 + a22 * 0 + b2'\n //\n x.x = -vcp1.normalMass * b.x;\n x.y = 0.0;\n vn1 = 0.0;\n vn2 = this.v_K.ex.y * x.x + b.y;\n\n if (x.x >= 0.0 && vn2 >= 0.0) {\n // Get the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n // Compute normal velocity\n vn1 = matrix.dotVec2(dv1, normal);\n\n if (_ASSERT) console.assert(math_abs(vn1 - vcp1.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 3: vn2 = 0 and x1 = 0\n //\n // vn1 = a11 * 0 + a12 * x2 + b1'\n // 0 = a21 * 0 + a22 * x2 + b2'\n //\n x.x = 0.0;\n x.y = -vcp2.normalMass * b.y;\n vn1 = this.v_K.ey.x * x.y + b.x;\n vn2 = 0.0;\n\n if (x.y >= 0.0 && vn1 >= 0.0) {\n // Resubstitute for the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n vn2 = matrix.dotVec2(dv2, normal);\n\n if (_ASSERT) console.assert(math_abs(vn2 - vcp2.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 4: x1 = 0 and x2 = 0\n //\n // vn1 = b1\n // vn2 = b2;\n //\n x.x = 0.0;\n x.y = 0.0;\n vn1 = b.x;\n vn2 = b.y;\n\n if (vn1 >= 0.0 && vn2 >= 0.0) {\n // Resubstitute for the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n break;\n }\n\n // No solution, give up. This is hit sometimes, but it doesn't seem to\n // matter.\n break;\n }\n }\n\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n /** @internal */\n static addType(type1: ShapeType, type2: ShapeType, callback: EvaluateFunction): void {\n s_registers[type1] = s_registers[type1] || {};\n s_registers[type1][type2] = callback;\n }\n\n /** @internal */\n static create(fixtureA: Fixture, indexA: number, fixtureB: Fixture, indexB: number): Contact | null {\n const typeA = fixtureA.m_shape.m_type;\n const typeB = fixtureB.m_shape.m_type;\n\n const contact = contactPool.allocate();\n let evaluateFcn;\n if (evaluateFcn = s_registers[typeA] && s_registers[typeA][typeB]) {\n contact.initialize(fixtureA, indexA, fixtureB, indexB, evaluateFcn);\n } else if (evaluateFcn = s_registers[typeB] && s_registers[typeB][typeA]) {\n contact.initialize(fixtureB, indexB, fixtureA, indexA, evaluateFcn);\n } else {\n return null;\n }\n\n // Contact creation may swap fixtures.\n fixtureA = contact.m_fixtureA;\n fixtureB = contact.m_fixtureB;\n indexA = contact.getChildIndexA();\n indexB = contact.getChildIndexB();\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n\n // Connect to body A\n contact.m_nodeA.contact = contact;\n contact.m_nodeA.other = bodyB;\n\n contact.m_nodeA.prev = null;\n contact.m_nodeA.next = bodyA.m_contactList;\n if (bodyA.m_contactList != null) {\n bodyA.m_contactList.prev = contact.m_nodeA;\n }\n bodyA.m_contactList = contact.m_nodeA;\n\n // Connect to body B\n contact.m_nodeB.contact = contact;\n contact.m_nodeB.other = bodyA;\n\n contact.m_nodeB.prev = null;\n contact.m_nodeB.next = bodyB.m_contactList;\n if (bodyB.m_contactList != null) {\n bodyB.m_contactList.prev = contact.m_nodeB;\n }\n bodyB.m_contactList = contact.m_nodeB;\n\n // Wake up the bodies\n if (fixtureA.isSensor() == false && fixtureB.isSensor() == false) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n\n return contact;\n }\n\n /** @internal */\n static destroy(contact: Contact, listener: { endContact: (contact: Contact) => void }): void {\n const fixtureA = contact.m_fixtureA;\n const fixtureB = contact.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n if (contact.isTouching()) {\n listener.endContact(contact);\n }\n\n // Remove from body 1\n if (contact.m_nodeA.prev) {\n contact.m_nodeA.prev.next = contact.m_nodeA.next;\n }\n\n if (contact.m_nodeA.next) {\n contact.m_nodeA.next.prev = contact.m_nodeA.prev;\n }\n\n if (contact.m_nodeA == bodyA.m_contactList) {\n bodyA.m_contactList = contact.m_nodeA.next;\n }\n\n // Remove from body 2\n if (contact.m_nodeB.prev) {\n contact.m_nodeB.prev.next = contact.m_nodeB.next;\n }\n\n if (contact.m_nodeB.next) {\n contact.m_nodeB.next.prev = contact.m_nodeB.prev;\n }\n\n if (contact.m_nodeB == bodyB.m_contactList) {\n bodyB.m_contactList = contact.m_nodeB.next;\n }\n\n if (contact.m_manifold.pointCount > 0 && !fixtureA.m_isSensor && !fixtureB.m_isSensor) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n\n // const typeA = fixtureA.getType();\n // const typeB = fixtureB.getType();\n\n // const destroyFcn = s_registers[typeA][typeB].destroyFcn;\n // if (typeof destroyFcn === 'function') {\n // destroyFcn(contact);\n // }\n\n contactPool.release(contact);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../util/options\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { BroadPhase } from \"../collision/BroadPhase\";\nimport { Solver, ContactImpulse, TimeStep } from \"./Solver\";\nimport { Body, BodyDef } from \"./Body\";\nimport { Joint } from \"./Joint\";\nimport { Contact } from \"./Contact\";\nimport { AABBValue, RayCastInput, RayCastOutput } from \"../collision/AABB\";\nimport { Fixture, FixtureProxy } from \"./Fixture\";\nimport { Manifold } from \"../collision/Manifold\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\nexport interface WorldDef {\n /** [default: { x : 0, y : 0}] */\n gravity?: Vec2Value;\n\n /** [default: true] */\n allowSleep?: boolean;\n\n /** [default: true] */\n warmStarting?: boolean;\n\n /** [default: true] */\n continuousPhysics?: boolean;\n\n /** [default: false] */\n subStepping?: boolean;\n\n /** [default: true] */\n blockSolve?: boolean;\n\n /** @internal [8] For the velocity constraint solver. */\n velocityIterations?: number;\n\n /** @internal [3] For the position constraint solver. */\n positionIterations?: number;\n}\n\n/** @internal */ const DEFAULTS: WorldDef = {\n gravity : Vec2.zero(),\n allowSleep : true,\n warmStarting : true,\n continuousPhysics : true,\n subStepping : false,\n blockSolve : true,\n velocityIterations : 8,\n positionIterations : 3\n};\n\n/**\n * Callback function for ray casts, see {@link World.rayCast}.\n *\n * Called for each fixture found in the query.\n * The returned value replaces the ray-cast input maxFraction.\n * You control how the ray cast proceeds by returning a numeric/float value.\n * \n * - `0` to terminate the ray cast\n * - `fraction` to clip the ray cast at current point\n * - `1` don't clip the ray and continue\n * - `-1` (or anything else) to continue\n *\n * @param fixture The fixture hit by the ray\n * @param point The point of initial intersection\n * @param normal The normal vector at the point of intersection\n * @param fraction The fraction along the ray at the point of intersection\n *\n * @returns A number to update the maxFraction\n */\nexport type WorldRayCastCallback = (fixture: Fixture, point: Vec2, normal: Vec2, fraction: number) => number;\n\n/**\n * Called for each fixture found in the query AABB. It may return `false` to terminate the query.\n */\nexport type WorldAABBQueryCallback = (fixture: Fixture) => boolean;\n\ndeclare module \"./World\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(deg: WorldDef): World;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(gravity: Vec2): World;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(): World;\n}\n\n/**\n * The `World` class contains the bodies and joints. It manages all aspects\n * of the simulation and allows for asynchronous queries (like AABB queries\n * and ray-casts). Much of your interactions with Planck.js will be with a\n * World object.\n */\n// @ts-expect-error\nexport class World {\n /** @internal */ m_solver: Solver;\n /** @internal */ m_broadPhase: BroadPhase;\n /** @internal */ m_contactList: Contact | null;\n /** @internal */ m_contactCount: number;\n /** @internal */ m_bodyList: Body | null;\n /** @internal */ m_bodyCount: number;\n /** @internal */ m_jointList: Joint | null;\n /** @internal */ m_jointCount: number;\n /** @internal */ m_stepComplete: boolean;\n /** @internal */ m_allowSleep: boolean;\n /** @internal */ m_gravity: Vec2;\n /** @internal */ m_clearForces: boolean;\n /** @internal */ m_newFixture: boolean;\n /** @internal */ m_locked: boolean;\n /** @internal */ m_warmStarting: boolean;\n /** @internal */ m_continuousPhysics: boolean;\n /** @internal */ m_subStepping: boolean;\n /** @internal */ m_blockSolve: boolean;\n /** @internal */ m_velocityIterations: number;\n /** @internal */ m_positionIterations: number;\n /** @internal */ m_t: number;\n\n // TODO\n /** @internal */ _listeners: {\n [key: string]: any[]\n };\n\n /**\n * @param def World definition or gravity vector.\n */\n constructor(def?: WorldDef | Vec2Value) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof World)) {\n return new World(def);\n }\n\n this.s_step = new TimeStep();\n\n\n if (!def) {\n def = {};\n } else if (Vec2.isValid(def)) {\n def = { gravity: def as Vec2 };\n }\n\n def = options(def, DEFAULTS) as WorldDef;\n\n this.m_solver = new Solver(this);\n\n this.m_broadPhase = new BroadPhase();\n\n this.m_contactList = null;\n this.m_contactCount = 0;\n\n this.m_bodyList = null;\n this.m_bodyCount = 0;\n\n this.m_jointList = null;\n this.m_jointCount = 0;\n\n this.m_stepComplete = true;\n\n this.m_allowSleep = def.allowSleep;\n this.m_gravity = Vec2.clone(def.gravity);\n\n this.m_clearForces = true;\n this.m_newFixture = false;\n this.m_locked = false;\n\n // These are for debugging the solver.\n this.m_warmStarting = def.warmStarting;\n this.m_continuousPhysics = def.continuousPhysics;\n this.m_subStepping = def.subStepping;\n\n this.m_blockSolve = def.blockSolve;\n this.m_velocityIterations = def.velocityIterations;\n this.m_positionIterations = def.positionIterations;\n\n this.m_t = 0;\n }\n\n /** @internal */\n _serialize(): object {\n const bodies = [];\n const joints = [];\n\n for (let b = this.getBodyList(); b; b = b.getNext()) {\n bodies.push(b);\n }\n\n for (let j = this.getJointList(); j; j = j.getNext()) {\n // @ts-ignore\n if (typeof j._serialize === \"function\") {\n joints.push(j);\n }\n }\n\n return {\n gravity: this.m_gravity,\n bodies,\n joints,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, context: any, restore: any): World {\n if (!data) {\n return new World();\n }\n\n const world = new World(data.gravity);\n\n if (data.bodies) {\n for (let i = data.bodies.length - 1; i >= 0; i -= 1) {\n world._addBody(restore(Body, data.bodies[i], world));\n }\n }\n\n if (data.joints) {\n for (let i = data.joints.length - 1; i >= 0; i--) {\n world.createJoint(restore(Joint, data.joints[i], world));\n }\n }\n\n return world;\n }\n\n /**\n * Get the world body list. With the returned body, use Body.getNext to get the\n * next body in the world list. A null body indicates the end of the list.\n *\n * @return the head of the world body list.\n */\n getBodyList(): Body | null {\n return this.m_bodyList;\n }\n\n /**\n * Get the world joint list. With the returned joint, use Joint.getNext to get\n * the next joint in the world list. A null joint indicates the end of the list.\n *\n * @return the head of the world joint list.\n */\n getJointList(): Joint | null {\n return this.m_jointList;\n }\n\n /**\n * Get the world contact list. With the returned contact, use Contact.getNext to\n * get the next contact in the world list. A null contact indicates the end of\n * the list.\n *\n * Warning: contacts are created and destroyed in the middle of a time step.\n * Use ContactListener to avoid missing contacts.\n *\n * @return the head of the world contact list.\n */\n getContactList(): Contact | null {\n return this.m_contactList;\n }\n\n getBodyCount(): number {\n return this.m_bodyCount;\n }\n\n getJointCount(): number {\n return this.m_jointCount;\n }\n\n /**\n * Get the number of contacts (each may have 0 or more contact points).\n */\n getContactCount(): number {\n return this.m_contactCount;\n }\n\n /**\n * Change the global gravity vector.\n */\n setGravity(gravity: Vec2Value): void {\n this.m_gravity.set(gravity);\n }\n\n /**\n * Get the global gravity vector.\n */\n getGravity(): Vec2 {\n return this.m_gravity;\n }\n\n /**\n * Is the world locked (in the middle of a time step).\n */\n isLocked(): boolean {\n return this.m_locked;\n }\n\n /**\n * Enable/disable sleep.\n */\n setAllowSleeping(flag: boolean): void {\n if (flag == this.m_allowSleep) {\n return;\n }\n\n this.m_allowSleep = flag;\n if (this.m_allowSleep == false) {\n for (let b = this.m_bodyList; b; b = b.m_next) {\n b.setAwake(true);\n }\n }\n }\n\n getAllowSleeping(): boolean {\n return this.m_allowSleep;\n }\n\n /**\n * Enable/disable warm starting. For testing.\n */\n setWarmStarting(flag: boolean): void {\n this.m_warmStarting = flag;\n }\n\n getWarmStarting(): boolean {\n return this.m_warmStarting;\n }\n\n /**\n * Enable/disable continuous physics. For testing.\n */\n setContinuousPhysics(flag: boolean): void {\n this.m_continuousPhysics = flag;\n }\n\n getContinuousPhysics(): boolean {\n return this.m_continuousPhysics;\n }\n\n /**\n * Enable/disable single stepped continuous physics. For testing.\n */\n setSubStepping(flag: boolean): void {\n this.m_subStepping = flag;\n }\n\n getSubStepping(): boolean {\n return this.m_subStepping;\n }\n\n /**\n * Set flag to control automatic clearing of forces after each time step.\n */\n setAutoClearForces(flag: boolean): void {\n this.m_clearForces = flag;\n }\n\n /**\n * Get the flag that controls automatic clearing of forces after each time step.\n */\n getAutoClearForces(): boolean {\n return this.m_clearForces;\n }\n\n /**\n * Manually clear the force buffer on all bodies. By default, forces are cleared\n * automatically after each call to step. The default behavior is modified by\n * calling setAutoClearForces. The purpose of this function is to support\n * sub-stepping. Sub-stepping is often used to maintain a fixed sized time step\n * under a variable frame-rate. When you perform sub-stepping you will disable\n * auto clearing of forces and instead call clearForces after all sub-steps are\n * complete in one pass of your game loop.\n *\n * See {@link World.setAutoClearForces}\n */\n clearForces(): void {\n for (let body = this.m_bodyList; body; body = body.getNext()) {\n body.m_force.setZero();\n body.m_torque = 0.0;\n }\n }\n\n /**\n * Query the world for all fixtures that potentially overlap the provided AABB.\n *\n * @param aabb The query box.\n * @param callback Called for each fixture found in the query AABB. It may return `false` to terminate the query.\n */\n queryAABB(aabb: AABBValue, callback: WorldAABBQueryCallback): void {\n if (_ASSERT) console.assert(typeof callback === \"function\");\n const broadPhase = this.m_broadPhase;\n this.m_broadPhase.query(aabb, function(proxyId: number): boolean { // TODO GC\n const proxy = broadPhase.getUserData(proxyId);\n return callback(proxy.fixture);\n });\n }\n\n /**\n * Ray-cast the world for all fixtures in the path of the ray. Your callback\n * controls whether you get the closest point, any point, or n-points. The\n * ray-cast ignores shapes that contain the starting point.\n *\n * @param point1 The ray starting point\n * @param point2 The ray ending point\n * @param callback A function that is called for each fixture that is hit by the ray. You control how the ray cast proceeds by returning a numeric/float value.\n */\n rayCast(point1: Vec2Value, point2: Vec2Value, callback: WorldRayCastCallback): void {\n if (_ASSERT) console.assert(typeof callback === \"function\");\n const broadPhase = this.m_broadPhase;\n\n this.m_broadPhase.rayCast({\n maxFraction : 1.0,\n p1 : point1,\n p2 : point2\n }, function(input: RayCastInput, proxyId: number): number { // TODO GC\n const proxy = broadPhase.getUserData(proxyId);\n const fixture = proxy.fixture;\n const index = proxy.childIndex;\n // @ts-ignore\n const output: RayCastOutput = {}; // TODO GC\n const hit = fixture.rayCast(output, input, index);\n if (hit) {\n const fraction = output.fraction;\n const point = Vec2.add(Vec2.mulNumVec2((1.0 - fraction), input.p1), Vec2.mulNumVec2(fraction, input.p2));\n return callback(fixture, point, output.normal, fraction);\n }\n return input.maxFraction;\n });\n }\n\n /**\n * Get the number of broad-phase proxies.\n */\n getProxyCount(): number {\n return this.m_broadPhase.getProxyCount();\n }\n\n /**\n * Get the height of broad-phase dynamic tree.\n */\n getTreeHeight(): number {\n return this.m_broadPhase.getTreeHeight();\n }\n\n /**\n * Get the balance of broad-phase dynamic tree.\n */\n getTreeBalance(): number {\n return this.m_broadPhase.getTreeBalance();\n }\n\n /**\n * Get the quality metric of broad-phase dynamic tree. The smaller the better.\n * The minimum is 1.\n */\n getTreeQuality(): number {\n return this.m_broadPhase.getTreeQuality();\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The body shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n if (_ASSERT) console.assert(this.m_locked == false);\n if (this.m_locked) {\n return;\n }\n\n for (let b = this.m_bodyList; b; b = b.m_next) {\n b.m_xf.p.sub(newOrigin);\n b.m_sweep.c0.sub(newOrigin);\n b.m_sweep.c.sub(newOrigin);\n }\n\n for (let j = this.m_jointList; j; j = j.m_next) {\n j.shiftOrigin(newOrigin);\n }\n\n this.m_broadPhase.shiftOrigin(newOrigin);\n }\n\n /** @internal Used for deserialize. */\n _addBody(body: Body): void {\n if (_ASSERT) console.assert(this.isLocked() === false);\n if (this.isLocked()) {\n return;\n }\n\n // Add to world doubly linked list.\n body.m_prev = null;\n body.m_next = this.m_bodyList;\n if (this.m_bodyList) {\n this.m_bodyList.m_prev = body;\n }\n this.m_bodyList = body;\n ++this.m_bodyCount;\n }\n\n /**\n * Create a rigid body given a definition. No reference to the definition is\n * retained.\n *\n * Warning: This function is locked during callbacks.\n */\n createBody(def?: BodyDef): Body;\n createBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createBody(arg1?, arg2?) {\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return null;\n }\n\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n\n const body = new Body(this, def);\n this._addBody(body);\n return body;\n }\n\n createDynamicBody(def?: BodyDef): Body;\n createDynamicBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createDynamicBody(arg1?, arg2?) {\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n def.type = \"dynamic\";\n return this.createBody(def);\n }\n\n createKinematicBody(def?: BodyDef): Body;\n createKinematicBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createKinematicBody(arg1?, arg2?) {\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n def.type = \"kinematic\";\n return this.createBody(def);\n }\n\n /**\n * Destroy a rigid body given a definition. No reference to the definition is\n * retained.\n *\n * Warning: This automatically deletes all associated shapes and joints.\n *\n * Warning: This function is locked during callbacks.\n */\n destroyBody(b: Body): boolean {\n if (_ASSERT) console.assert(this.m_bodyCount > 0);\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return;\n }\n\n if (b.m_destroyed) {\n return false;\n }\n\n // Delete the attached joints.\n let je = b.m_jointList;\n while (je) {\n const je0 = je;\n je = je.next;\n\n this.publish(\"remove-joint\", je0.joint);\n this.destroyJoint(je0.joint);\n\n b.m_jointList = je;\n }\n b.m_jointList = null;\n\n // Delete the attached contacts.\n let ce = b.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n\n this.destroyContact(ce0.contact);\n\n b.m_contactList = ce;\n }\n b.m_contactList = null;\n\n // Delete the attached fixtures. This destroys broad-phase proxies.\n let f = b.m_fixtureList;\n while (f) {\n const f0 = f;\n f = f.m_next;\n\n this.publish(\"remove-fixture\", f0);\n f0.destroyProxies(this.m_broadPhase);\n\n b.m_fixtureList = f;\n }\n b.m_fixtureList = null;\n\n // Remove world body list.\n if (b.m_prev) {\n b.m_prev.m_next = b.m_next;\n }\n\n if (b.m_next) {\n b.m_next.m_prev = b.m_prev;\n }\n\n if (b == this.m_bodyList) {\n this.m_bodyList = b.m_next;\n }\n\n b.m_destroyed = true;\n\n --this.m_bodyCount;\n\n this.publish(\"remove-body\", b);\n\n return true;\n }\n\n /**\n * Create a joint to constrain bodies together. No reference to the definition\n * is retained. This may cause the connected bodies to cease colliding.\n *\n * Warning: This function is locked during callbacks.\n */\n createJoint(joint: T): T | null {\n if (_ASSERT) console.assert(!!joint.m_bodyA);\n if (_ASSERT) console.assert(!!joint.m_bodyB);\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return null;\n }\n\n // Connect to the world list.\n joint.m_prev = null;\n joint.m_next = this.m_jointList;\n if (this.m_jointList) {\n this.m_jointList.m_prev = joint;\n }\n this.m_jointList = joint;\n ++this.m_jointCount;\n\n // Connect to the bodies' doubly linked lists.\n joint.m_edgeA.joint = joint;\n joint.m_edgeA.other = joint.m_bodyB;\n joint.m_edgeA.prev = null;\n joint.m_edgeA.next = joint.m_bodyA.m_jointList;\n if (joint.m_bodyA.m_jointList)\n joint.m_bodyA.m_jointList.prev = joint.m_edgeA;\n joint.m_bodyA.m_jointList = joint.m_edgeA;\n\n joint.m_edgeB.joint = joint;\n joint.m_edgeB.other = joint.m_bodyA;\n joint.m_edgeB.prev = null;\n joint.m_edgeB.next = joint.m_bodyB.m_jointList;\n if (joint.m_bodyB.m_jointList)\n joint.m_bodyB.m_jointList.prev = joint.m_edgeB;\n joint.m_bodyB.m_jointList = joint.m_edgeB;\n\n // If the joint prevents collisions, then flag any contacts for filtering.\n if (joint.m_collideConnected == false) {\n for (let edge = joint.m_bodyB.getContactList(); edge; edge = edge.next) {\n if (edge.other == joint.m_bodyA) {\n // Flag the contact for filtering at the next time step (where either\n // body is awake).\n edge.contact.flagForFiltering();\n }\n }\n }\n\n // Note: creating a joint doesn't wake the bodies.\n\n return joint;\n }\n\n /**\n * Destroy a joint. This may cause the connected bodies to begin colliding.\n * Warning: This function is locked during callbacks.\n */\n destroyJoint(joint: Joint): void {\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return;\n }\n\n // Remove from the doubly linked list.\n if (joint.m_prev) {\n joint.m_prev.m_next = joint.m_next;\n }\n\n if (joint.m_next) {\n joint.m_next.m_prev = joint.m_prev;\n }\n\n if (joint == this.m_jointList) {\n this.m_jointList = joint.m_next;\n }\n\n // Disconnect from bodies.\n const bodyA = joint.m_bodyA;\n const bodyB = joint.m_bodyB;\n\n // Wake up connected bodies.\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n\n // Remove from body 1.\n if (joint.m_edgeA.prev) {\n joint.m_edgeA.prev.next = joint.m_edgeA.next;\n }\n\n if (joint.m_edgeA.next) {\n joint.m_edgeA.next.prev = joint.m_edgeA.prev;\n }\n\n if (joint.m_edgeA == bodyA.m_jointList) {\n bodyA.m_jointList = joint.m_edgeA.next;\n }\n\n joint.m_edgeA.prev = null;\n joint.m_edgeA.next = null;\n\n // Remove from body 2\n if (joint.m_edgeB.prev) {\n joint.m_edgeB.prev.next = joint.m_edgeB.next;\n }\n\n if (joint.m_edgeB.next) {\n joint.m_edgeB.next.prev = joint.m_edgeB.prev;\n }\n\n if (joint.m_edgeB == bodyB.m_jointList) {\n bodyB.m_jointList = joint.m_edgeB.next;\n }\n\n joint.m_edgeB.prev = null;\n joint.m_edgeB.next = null;\n\n if (_ASSERT) console.assert(this.m_jointCount > 0);\n --this.m_jointCount;\n\n // If the joint prevents collisions, then flag any contacts for filtering.\n if (joint.m_collideConnected == false) {\n let edge = bodyB.getContactList();\n while (edge) {\n if (edge.other == bodyA) {\n // Flag the contact for filtering at the next time step (where either\n // body is awake).\n edge.contact.flagForFiltering();\n }\n\n edge = edge.next;\n }\n }\n\n this.publish(\"remove-joint\", joint);\n }\n\n /** @internal */\n s_step: TimeStep; // reuse\n\n /**\n * Take a time step. This performs collision detection, integration, and\n * constraint solution.\n *\n * Broad-phase, narrow-phase, solve and solve time of impacts.\n *\n * @param timeStep Time step, this should not vary.\n */\n step(timeStep: number, velocityIterations?: number, positionIterations?: number): void {\n this.publish(\"pre-step\", timeStep);\n\n if ((velocityIterations | 0) !== velocityIterations) {\n // TODO: remove this in future\n velocityIterations = 0;\n }\n\n velocityIterations = velocityIterations || this.m_velocityIterations;\n positionIterations = positionIterations || this.m_positionIterations;\n\n // If new fixtures were added, we need to find the new contacts.\n if (this.m_newFixture) {\n this.findNewContacts();\n this.m_newFixture = false;\n }\n\n this.m_locked = true;\n\n this.s_step.reset(timeStep);\n this.s_step.velocityIterations = velocityIterations;\n this.s_step.positionIterations = positionIterations;\n this.s_step.warmStarting = this.m_warmStarting;\n this.s_step.blockSolve = this.m_blockSolve;\n\n // Update contacts. This is where some contacts are destroyed.\n this.updateContacts();\n\n // Integrate velocities, solve velocity constraints, and integrate positions.\n if (this.m_stepComplete && timeStep > 0.0) {\n this.m_solver.solveWorld(this.s_step);\n\n // Synchronize fixtures, check for out of range bodies.\n for (let b = this.m_bodyList; b; b = b.getNext()) {\n // If a body was not in an island then it did not move.\n if (b.m_islandFlag == false) {\n continue;\n }\n\n if (b.isStatic()) {\n continue;\n }\n\n // Update fixtures (for broad-phase).\n b.synchronizeFixtures();\n }\n // Look for new contacts.\n this.findNewContacts();\n }\n\n // Handle TOI events.\n if (this.m_continuousPhysics && timeStep > 0.0) {\n this.m_solver.solveWorldTOI(this.s_step);\n }\n\n if (this.m_clearForces) {\n this.clearForces();\n }\n\n this.m_locked = false;\n\n this.publish(\"post-step\", timeStep);\n }\n\n /**\n * @internal\n * Call this method to find new contacts.\n */\n findNewContacts(): void {\n this.m_broadPhase.updatePairs(\n (proxyA: FixtureProxy, proxyB: FixtureProxy) => this.createContact(proxyA, proxyB)\n );\n }\n\n /**\n * @internal\n * Callback for broad-phase.\n */\n createContact(proxyA: FixtureProxy, proxyB: FixtureProxy): void {\n const fixtureA = proxyA.fixture;\n const fixtureB = proxyB.fixture;\n\n const indexA = proxyA.childIndex;\n const indexB = proxyB.childIndex;\n\n const bodyA = fixtureA.getBody();\n const bodyB = fixtureB.getBody();\n\n // Are the fixtures on the same body?\n if (bodyA == bodyB) {\n return;\n }\n\n // TODO_ERIN use a hash table to remove a potential bottleneck when both\n // bodies have a lot of contacts.\n // Does a contact already exist?\n let edge = bodyB.getContactList(); // ContactEdge\n while (edge) {\n if (edge.other == bodyA) {\n const fA = edge.contact.getFixtureA();\n const fB = edge.contact.getFixtureB();\n const iA = edge.contact.getChildIndexA();\n const iB = edge.contact.getChildIndexB();\n\n if (fA == fixtureA && fB == fixtureB && iA == indexA && iB == indexB) {\n // A contact already exists.\n return;\n }\n\n if (fA == fixtureB && fB == fixtureA && iA == indexB && iB == indexA) {\n // A contact already exists.\n return;\n }\n }\n\n edge = edge.next;\n }\n\n if (bodyB.shouldCollide(bodyA) == false) {\n return;\n }\n if (fixtureB.shouldCollide(fixtureA) == false) {\n return;\n }\n\n // Call the factory.\n const contact = Contact.create(fixtureA, indexA, fixtureB, indexB);\n if (contact == null) {\n return;\n }\n\n // Insert into the world.\n contact.m_prev = null;\n if (this.m_contactList != null) {\n contact.m_next = this.m_contactList;\n this.m_contactList.m_prev = contact;\n }\n this.m_contactList = contact;\n\n ++this.m_contactCount;\n }\n\n /**\n * @internal\n * Removes old non-overlapping contacts, applies filters and updates contacts.\n */\n updateContacts(): void {\n // Update awake contacts.\n let c: Contact;\n let next_c = this.m_contactList;\n while (c = next_c) {\n next_c = c.getNext();\n const fixtureA = c.getFixtureA();\n const fixtureB = c.getFixtureB();\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n const bodyA = fixtureA.getBody();\n const bodyB = fixtureB.getBody();\n\n // Is this contact flagged for filtering?\n if (c.m_filterFlag) {\n if (bodyB.shouldCollide(bodyA) == false) {\n this.destroyContact(c);\n continue;\n }\n\n if (fixtureB.shouldCollide(fixtureA) == false) {\n this.destroyContact(c);\n continue;\n }\n\n // Clear the filtering flag.\n c.m_filterFlag = false;\n }\n\n const activeA = bodyA.isAwake() && !bodyA.isStatic();\n const activeB = bodyB.isAwake() && !bodyB.isStatic();\n\n // At least one body must be awake and it must be dynamic or kinematic.\n if (activeA == false && activeB == false) {\n continue;\n }\n\n const proxyIdA = fixtureA.m_proxies[indexA].proxyId;\n const proxyIdB = fixtureB.m_proxies[indexB].proxyId;\n const overlap = this.m_broadPhase.testOverlap(proxyIdA, proxyIdB);\n\n // Here we destroy contacts that cease to overlap in the broad-phase.\n if (overlap == false) {\n this.destroyContact(c);\n continue;\n }\n\n // The contact persists.\n c.update(this);\n }\n }\n\n /** @internal */\n destroyContact(contact: Contact): void {\n // Remove from the world.\n if (contact.m_prev) {\n contact.m_prev.m_next = contact.m_next;\n }\n if (contact.m_next) {\n contact.m_next.m_prev = contact.m_prev;\n }\n if (contact == this.m_contactList) {\n this.m_contactList = contact.m_next;\n }\n\n Contact.destroy(contact, this);\n\n --this.m_contactCount;\n }\n\n\n /**\n * Called when two fixtures begin to touch.\n *\n * Implement contact callbacks to get contact information. You can use these\n * results for things like sounds and game logic. You can also get contact\n * results by traversing the contact lists after the time step. However, you\n * might miss some contacts because continuous physics leads to sub-stepping.\n * Additionally you may receive multiple callbacks for the same contact in a\n * single time step. You should strive to make your callbacks efficient because\n * there may be many callbacks per time step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"begin-contact\", listener: (contact: Contact) => void): World;\n /**\n * Called when two fixtures cease to touch.\n *\n * Implement contact callbacks to get contact information. You can use these\n * results for things like sounds and game logic. You can also get contact\n * results by traversing the contact lists after the time step. However, you\n * might miss some contacts because continuous physics leads to sub-stepping.\n * Additionally you may receive multiple callbacks for the same contact in a\n * single time step. You should strive to make your callbacks efficient because\n * there may be many callbacks per time step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"end-contact\", listener: (contact: Contact) => void): World;\n /**\n * This is called after a contact is updated. This allows you to inspect a\n * contact before it goes to the solver. If you are careful, you can modify the\n * contact manifold (e.g. disable contact). A copy of the old manifold is\n * provided so that you can detect changes. Note: this is called only for awake\n * bodies. Note: this is called even when the number of contact points is zero.\n * Note: this is not called for sensors. Note: if you set the number of contact\n * points to zero, you will not get an end-contact callback. However, you may get\n * a begin-contact callback the next step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"pre-solve\", listener: (contact: Contact, oldManifold: Manifold) => void): World;\n /**\n * This lets you inspect a contact after the solver is finished. This is useful\n * for inspecting impulses. Note: the contact manifold does not include time of\n * impact impulses, which can be arbitrarily large if the sub-step is small.\n * Hence the impulse is provided explicitly in a separate data structure. Note:\n * this is only called for contacts that are touching, solid, and awake.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"post-solve\", listener: (contact: Contact, impulse: ContactImpulse) => void): World;\n /** Listener is called whenever a body is removed. */\n on(name: \"remove-body\", listener: (body: Body) => void): World;\n /** Listener is called whenever a joint is removed implicitly or explicitly. */\n on(name: \"remove-joint\", listener: (joint: Joint) => void): World;\n /** Listener is called whenever a fixture is removed implicitly or explicitly. */\n on(name: \"remove-fixture\", listener: (fixture: Fixture) => void): World;\n /**\n * Register an event listener.\n */\n // tslint:disable-next-line:typedef\n on(name, listener) {\n if (typeof name !== \"string\" || typeof listener !== \"function\") {\n return this;\n }\n if (!this._listeners) {\n this._listeners = {};\n }\n if (!this._listeners[name]) {\n this._listeners[name] = [];\n }\n this._listeners[name].push(listener);\n return this;\n }\n\n off(name: \"begin-contact\", listener: (contact: Contact) => void): World;\n off(name: \"end-contact\", listener: (contact: Contact) => void): World;\n off(name: \"pre-solve\", listener: (contact: Contact, oldManifold: Manifold) => void): World;\n off(name: \"post-solve\", listener: (contact: Contact, impulse: ContactImpulse) => void): World;\n off(name: \"remove-body\", listener: (body: Body) => void): World;\n off(name: \"remove-joint\", listener: (joint: Joint) => void): World;\n off(name: \"remove-fixture\", listener: (fixture: Fixture) => void): World;\n /**\n * Remove an event listener.\n */\n // tslint:disable-next-line:typedef\n off(name, listener) {\n if (typeof name !== \"string\" || typeof listener !== \"function\") {\n return this;\n }\n const listeners = this._listeners && this._listeners[name];\n if (!listeners || !listeners.length) {\n return this;\n }\n const index = listeners.indexOf(listener);\n if (index >= 0) {\n listeners.splice(index, 1);\n }\n return this;\n }\n\n publish(name: string, arg1?: any, arg2?: any, arg3?: any): number {\n const listeners = this._listeners && this._listeners[name];\n if (!listeners || !listeners.length) {\n return 0;\n }\n for (let l = 0; l < listeners.length; l++) {\n listeners[l].call(this, arg1, arg2, arg3);\n }\n return listeners.length;\n }\n\n /** @internal */\n beginContact(contact: Contact): void {\n this.publish(\"begin-contact\", contact);\n }\n\n /** @internal */\n endContact(contact: Contact): void {\n this.publish(\"end-contact\", contact);\n }\n\n /** @internal */\n preSolve(contact: Contact, oldManifold: Manifold): void {\n this.publish(\"pre-solve\", contact, oldManifold);\n }\n\n /** @internal */\n postSolve(contact: Contact, impulse: ContactImpulse): void {\n this.publish(\"post-solve\", contact, impulse);\n }\n\n /**\n * Joints and fixtures are destroyed when their associated body is destroyed.\n * Register a destruction listener so that you may nullify references to these\n * joints and shapes.\n *\n * `function(object)` is called when any joint or fixture is about to\n * be destroyed due to the destruction of one of its attached or parent bodies.\n */\n\n /**\n * Register a contact filter to provide specific control over collision.\n * Otherwise the default filter is used (defaultFilter). The listener is owned\n * by you and must remain in scope.\n *\n * Moved to Fixture.\n */\n}","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/** 3D vector */\nexport interface Vec3Value {\n x: number;\n y: number;\n z: number;\n}\n\ndeclare module \"./Vec3\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(x: number, y: number, z: number): Vec3;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(obj: Vec3Value): Vec3;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(): Vec3;\n}\n\n/** 3D vector */\n// @ts-expect-error\nexport class Vec3 {\n x: number;\n y: number;\n z: number;\n\n constructor(x: number, y: number, z: number);\n constructor(obj: Vec3Value);\n constructor();\n constructor(x?, y?, z?) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Vec3)) {\n return new Vec3(x, y, z);\n }\n if (typeof x === \"undefined\") {\n this.x = 0;\n this.y = 0;\n this.z = 0;\n } else if (typeof x === \"object\") {\n this.x = x.x;\n this.y = x.y;\n this.z = x.z;\n } else {\n this.x = x;\n this.y = y;\n this.z = z;\n }\n if (_ASSERT) Vec3.assert(this);\n }\n\n /** @internal */\n _serialize(): object {\n return {\n x: this.x,\n y: this.y,\n z: this.z\n };\n }\n\n /** @internal */\n static _deserialize(data: any): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = data.x;\n obj.y = data.y;\n obj.z = data.z;\n return obj;\n }\n\n /** @hidden */\n static neo(x: number, y: number, z: number): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = x;\n obj.y = y;\n obj.z = z;\n return obj;\n }\n\n static zero(): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = 0;\n obj.y = 0;\n obj.z = 0;\n return obj;\n }\n\n static clone(v: Vec3Value): Vec3 {\n if (_ASSERT) Vec3.assert(v);\n return Vec3.neo(v.x, v.y, v.z);\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n /** Does this vector contain finite coordinates? */\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.x) && Number.isFinite(obj.y) && Number.isFinite(obj.z);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Vec3.isValid(o), \"Invalid Vec3!\", o);\n }\n\n setZero(): Vec3 {\n this.x = 0.0;\n this.y = 0.0;\n this.z = 0.0;\n return this;\n }\n\n set(x: number, y: number, z: number): Vec3 {\n this.x = x;\n this.y = y;\n this.z = z;\n return this;\n }\n\n add(w: Vec3Value): Vec3 {\n this.x += w.x;\n this.y += w.y;\n this.z += w.z;\n return this;\n }\n\n sub(w: Vec3Value): Vec3 {\n this.x -= w.x;\n this.y -= w.y;\n this.z -= w.z;\n return this;\n }\n\n mul(m: number): Vec3 {\n this.x *= m;\n this.y *= m;\n this.z *= m;\n return this;\n }\n\n static areEqual(v: Vec3Value, w: Vec3Value): boolean {\n if (_ASSERT) Vec3.assert(v);\n if (_ASSERT) Vec3.assert(w);\n return v === w ||\n typeof v === \"object\" && v !== null &&\n typeof w === \"object\" && w !== null &&\n v.x === w.x && v.y === w.y && v.z === w.z;\n }\n\n /** Dot product on two vectors */\n static dot(v: Vec3Value, w: Vec3Value): number {\n return v.x * w.x + v.y * w.y + v.z * w.z;\n }\n\n /** Cross product on two vectors */\n static cross(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(\n v.y * w.z - v.z * w.y,\n v.z * w.x - v.x * w.z,\n v.x * w.y - v.y * w.x\n );\n }\n\n static add(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(v.x + w.x, v.y + w.y, v.z + w.z);\n }\n\n static sub(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(v.x - w.x, v.y - w.y, v.z - w.z);\n }\n\n static mul(v: Vec3Value, m: number): Vec3 {\n return new Vec3(m * v.x, m * v.y, m * v.z);\n }\n\n neg(): Vec3 {\n this.x = -this.x;\n this.y = -this.y;\n this.z = -this.z;\n return this;\n }\n\n static neg(v: Vec3Value): Vec3 {\n return new Vec3(-v.x, -v.y, -v.z);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport * as matrix from \"../../common/Matrix\";\nimport { Shape } from \"../Shape\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { AABB, AABBValue, RayCastInput, RayCastOutput } from \"../AABB\";\nimport { MassData } from \"../../dynamics/Body\";\nimport { DistanceProxy } from \"../Distance\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const v2 = matrix.vec2(0, 0);\n\ndeclare module \"./EdgeShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function EdgeShape(v1?: Vec2Value, v2?: Vec2Value): EdgeShape;\n}\n\n/**\n * A line segment (edge) shape. These can be connected in chains or loops to\n * other edge shapes. The connectivity information is used to ensure correct\n * contact normals.\n */\n// @ts-expect-error\nexport class EdgeShape extends Shape {\n static TYPE = \"edge\" as const;\n /** @hidden */ m_type: \"edge\";\n\n /** @hidden */ m_radius: number;\n\n // These are the edge vertices\n /** @hidden */ m_vertex1: Vec2;\n /** @hidden */ m_vertex2: Vec2;\n\n // Optional adjacent vertices. These are used for smooth collision.\n // Used by chain shape.\n /** @hidden */ m_vertex0: Vec2;\n /** @hidden */ m_vertex3: Vec2;\n /** @hidden */ m_hasVertex0: boolean;\n /** @hidden */ m_hasVertex3: boolean;\n\n constructor(v1?: Vec2Value, v2?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof EdgeShape)) {\n return new EdgeShape(v1, v2);\n }\n\n super();\n\n this.m_type = EdgeShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n\n this.m_vertex1 = v1 ? Vec2.clone(v1) : Vec2.zero();\n this.m_vertex2 = v2 ? Vec2.clone(v2) : Vec2.zero();\n\n this.m_vertex0 = Vec2.zero();\n this.m_vertex3 = Vec2.zero();\n this.m_hasVertex0 = false;\n this.m_hasVertex3 = false;\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n vertex1: this.m_vertex1,\n vertex2: this.m_vertex2,\n\n vertex0: this.m_vertex0,\n vertex3: this.m_vertex3,\n hasVertex0: this.m_hasVertex0,\n hasVertex3: this.m_hasVertex3,\n };\n }\n\n /** @internal */\n static _deserialize(data: any): EdgeShape {\n const shape = new EdgeShape(data.vertex1, data.vertex2);\n if (shape.m_hasVertex0) {\n shape.setPrevVertex(data.vertex0);\n }\n if (shape.m_hasVertex3) {\n shape.setNextVertex(data.vertex3);\n }\n return shape;\n }\n\n /** @hidden */\n _reset(): void {\n // noop\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n getType(): \"edge\" {\n return this.m_type;\n }\n\n /** @internal @deprecated */\n setNext(v?: Vec2Value): EdgeShape {\n return this.setNextVertex(v);\n }\n\n /**\n * Optional next vertex, used for smooth collision.\n */\n setNextVertex(v?: Vec2Value): EdgeShape {\n if (v) {\n this.m_vertex3.setVec2(v);\n this.m_hasVertex3 = true;\n } else {\n this.m_vertex3.setZero();\n this.m_hasVertex3 = false;\n }\n return this;\n }\n\n /**\n * Optional next vertex, used for smooth collision.\n */\n getNextVertex(): Vec2 {\n return this.m_vertex3;\n }\n\n /** @internal @deprecated */\n setPrev(v?: Vec2Value): EdgeShape {\n return this.setPrevVertex(v);\n }\n\n /**\n * Optional prev vertex, used for smooth collision.\n */\n setPrevVertex(v?: Vec2Value): EdgeShape {\n if (v) {\n this.m_vertex0.setVec2(v);\n this.m_hasVertex0 = true;\n } else {\n this.m_vertex0.setZero();\n this.m_hasVertex0 = false;\n }\n return this;\n }\n\n /**\n * Optional prev vertex, used for smooth collision.\n */\n getPrevVertex(): Vec2 {\n return this.m_vertex0;\n }\n\n /**\n * Set this as an isolated edge.\n */\n _set(v1: Vec2Value, v2: Vec2Value): EdgeShape {\n this.m_vertex1.setVec2(v1);\n this.m_vertex2.setVec2(v2);\n this.m_hasVertex0 = false;\n this.m_hasVertex3 = false;\n return this;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): EdgeShape {\n const clone = new EdgeShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_vertex1.setVec2(this.m_vertex1);\n clone.m_vertex2.setVec2(this.m_vertex2);\n clone.m_vertex0.setVec2(this.m_vertex0);\n clone.m_vertex3.setVec2(this.m_vertex3);\n clone.m_hasVertex0 = this.m_hasVertex0;\n clone.m_hasVertex3 = this.m_hasVertex3;\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): false {\n return false;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n // p = p1 + t * d\n // v = v1 + s * e\n // p1 + t * d = v1 + s * e\n // s * e - t * d = p1 - v1\n\n // NOT_USED(childIndex);\n\n // Put the ray into the edge's frame of reference.\n const p1 = Rot.mulTVec2(xf.q, Vec2.sub(input.p1, xf.p));\n const p2 = Rot.mulTVec2(xf.q, Vec2.sub(input.p2, xf.p));\n const d = Vec2.sub(p2, p1);\n\n const v1 = this.m_vertex1;\n const v2 = this.m_vertex2;\n const e = Vec2.sub(v2, v1);\n const normal = Vec2.neo(e.y, -e.x);\n normal.normalize();\n\n // q = p1 + t * d\n // dot(normal, q - v1) = 0\n // dot(normal, p1 - v1) + t * dot(normal, d) = 0\n const numerator = Vec2.dot(normal, Vec2.sub(v1, p1));\n const denominator = Vec2.dot(normal, d);\n\n if (denominator == 0.0) {\n return false;\n }\n\n const t = numerator / denominator;\n if (t < 0.0 || input.maxFraction < t) {\n return false;\n }\n\n const q = Vec2.add(p1, Vec2.mulNumVec2(t, d));\n\n // q = v1 + s * r\n // s = dot(q - v1, r) / dot(r, r)\n const r = Vec2.sub(v2, v1);\n const rr = Vec2.dot(r, r);\n if (rr == 0.0) {\n return false;\n }\n\n const s = Vec2.dot(Vec2.sub(q, v1), r) / rr;\n if (s < 0.0 || 1.0 < s) {\n return false;\n }\n\n output.fraction = t;\n if (numerator > 0.0) {\n output.normal = Rot.mulVec2(xf.q, normal).neg();\n } else {\n output.normal = Rot.mulVec2(xf.q, normal);\n }\n return true;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n matrix.transformVec2(v1, xf, this.m_vertex1);\n matrix.transformVec2(v2, xf, this.m_vertex2);\n\n AABB.combinePoints(aabb, v1, v2);\n AABB.extend(aabb, this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density?: number): void {\n massData.mass = 0.0;\n matrix.combine2Vec2(massData.center, 0.5, this.m_vertex1, 0.5, this.m_vertex2);\n massData.I = 0.0;\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n proxy.m_vertices[0] = this.m_vertex1;\n proxy.m_vertices[1] = this.m_vertex2;\n proxy.m_vertices.length = 2;\n proxy.m_count = 2;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Edge = EdgeShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport type { MassData } from \"../../dynamics/Body\";\nimport { AABBValue, RayCastOutput, RayCastInput, AABB } from \"../AABB\";\nimport { DistanceProxy } from \"../Distance\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Shape } from \"../Shape\";\nimport { EdgeShape } from \"./EdgeShape\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const v2 = matrix.vec2(0, 0);\n\ndeclare module \"./ChainShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function ChainShape(vertices?: Vec2Value[], loop?: boolean): ChainShape;\n}\n\n/**\n * A chain shape is a free form sequence of line segments. The chain has\n * two-sided collision, so you can use inside and outside collision. Therefore,\n * you may use any winding order. Connectivity information is used to create\n * smooth collisions.\n *\n * WARNING: The chain will not collide properly if there are self-intersections.\n */\n// @ts-expect-error\nexport class ChainShape extends Shape {\n static TYPE = \"chain\" as const;\n /** @hidden */ m_type: \"chain\";\n\n /** @hidden */ m_radius: number;\n\n /** @hidden */ m_vertices: Vec2[];\n /** @hidden */ m_count: number;\n /** @hidden */ m_prevVertex: Vec2 | null;\n /** @hidden */ m_nextVertex: Vec2 | null;\n /** @hidden */ m_hasPrevVertex: boolean;\n /** @hidden */ m_hasNextVertex: boolean;\n\n /** @hidden */ m_isLoop: boolean;\n\n constructor(vertices?: Vec2Value[], loop?: boolean) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof ChainShape)) {\n return new ChainShape(vertices, loop);\n }\n\n super();\n\n this.m_type = ChainShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n this.m_vertices = [];\n this.m_count = 0;\n this.m_prevVertex = null;\n this.m_nextVertex = null;\n this.m_hasPrevVertex = false;\n this.m_hasNextVertex = false;\n\n this.m_isLoop = !!loop;\n\n if (vertices && vertices.length) {\n if (loop) {\n this._createLoop(vertices);\n } else {\n this._createChain(vertices);\n }\n }\n }\n\n /** @internal */\n _serialize(): object {\n const data = {\n type: this.m_type,\n vertices: this.m_isLoop ? this.m_vertices.slice(0, this.m_vertices.length - 1) : this.m_vertices,\n isLoop: this.m_isLoop,\n hasPrevVertex: this.m_hasPrevVertex,\n hasNextVertex: this.m_hasNextVertex,\n prevVertex: null as Vec2 | null,\n nextVertex: null as Vec2 | null,\n };\n if (this.m_prevVertex) {\n data.prevVertex = this.m_prevVertex;\n }\n if (this.m_nextVertex) {\n data.nextVertex = this.m_nextVertex;\n }\n return data;\n }\n\n /** @internal */\n static _deserialize(data: any, fixture: any, restore: any): ChainShape {\n const vertices: Vec2[] = [];\n if (data.vertices) {\n for (let i = 0; i < data.vertices.length; i++) {\n vertices.push(restore(Vec2, data.vertices[i]));\n }\n }\n const shape = new ChainShape(vertices, data.isLoop);\n if (data.prevVertex) {\n shape.setPrevVertex(data.prevVertex);\n }\n if (data.nextVertex) {\n shape.setNextVertex(data.nextVertex);\n }\n return shape;\n }\n\n // clear() {\n // this.m_vertices.length = 0;\n // this.m_count = 0;\n // }\n\n getType(): \"chain\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n /**\n * @internal\n * Create a loop. This automatically adjusts connectivity.\n *\n * @param vertices an array of vertices, these are copied\n */\n _createLoop(vertices: Vec2Value[]): ChainShape {\n if (_ASSERT) console.assert(this.m_vertices.length == 0 && this.m_count == 0);\n if (_ASSERT) console.assert(vertices.length >= 3);\n if (vertices.length < 3) {\n return;\n }\n\n for (let i = 1; i < vertices.length; ++i) {\n const v1 = vertices[i - 1];\n const v2 = vertices[i];\n // If the code crashes here, it means your vertices are too close together.\n if (_ASSERT) console.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);\n }\n\n this.m_vertices = [];\n this.m_count = vertices.length + 1;\n for (let i = 0; i < vertices.length; ++i) {\n this.m_vertices[i] = Vec2.clone(vertices[i]);\n }\n this.m_vertices[vertices.length] = Vec2.clone(vertices[0]);\n\n this.m_prevVertex = this.m_vertices[this.m_count - 2];\n this.m_nextVertex = this.m_vertices[1];\n this.m_hasPrevVertex = true;\n this.m_hasNextVertex = true;\n return this;\n }\n\n /**\n * @internal\n * Create a chain with isolated end vertices.\n *\n * @param vertices an array of vertices, these are copied\n */\n _createChain(vertices: Vec2Value[]): ChainShape {\n if (_ASSERT) console.assert(this.m_vertices.length == 0 && this.m_count == 0);\n if (_ASSERT) console.assert(vertices.length >= 2);\n for (let i = 1; i < vertices.length; ++i) {\n const v1 = vertices[i - 1];\n const v2 = vertices[i];\n // If the code crashes here, it means your vertices are too close together.\n if (_ASSERT) console.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);\n }\n\n this.m_vertices = [];\n this.m_count = vertices.length;\n for (let i = 0; i < vertices.length; ++i) {\n this.m_vertices[i] = Vec2.clone(vertices[i]);\n }\n\n this.m_prevVertex = null;\n this.m_nextVertex = null;\n this.m_hasPrevVertex = false;\n this.m_hasNextVertex = false;\n return this;\n }\n\n /** @hidden */\n _reset(): void {\n if (this.m_isLoop) {\n this._createLoop(this.m_vertices.slice(0, this.m_vertices.length - 1));\n } else {\n this._createChain(this.m_vertices);\n }\n }\n\n /**\n * Establish connectivity to a vertex that precedes the first vertex. Don't call\n * this for loops.\n */\n setPrevVertex(prevVertex: Vec2): void {\n // todo: copy or reference\n this.m_prevVertex = prevVertex;\n this.m_hasPrevVertex = true;\n }\n\n getPrevVertex(): Vec2 {\n return this.m_prevVertex;\n }\n\n /**\n * Establish connectivity to a vertex that follows the last vertex. Don't call\n * this for loops.\n */\n setNextVertex(nextVertex: Vec2): void {\n // todo: copy or reference\n this.m_nextVertex = nextVertex;\n this.m_hasNextVertex = true;\n }\n\n getNextVertex(): Vec2 {\n return this.m_nextVertex;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): ChainShape {\n const clone = new ChainShape();\n clone._createChain(this.m_vertices);\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_prevVertex = this.m_prevVertex;\n clone.m_nextVertex = this.m_nextVertex;\n clone.m_hasPrevVertex = this.m_hasPrevVertex;\n clone.m_hasNextVertex = this.m_hasNextVertex;\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): number {\n // edge count = vertex count - 1\n return this.m_count - 1;\n }\n\n // Get a child edge.\n getChildEdge(edge: EdgeShape, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count - 1);\n edge.m_type = EdgeShape.TYPE;\n edge.m_radius = this.m_radius;\n\n edge.m_vertex1 = this.m_vertices[childIndex];\n edge.m_vertex2 = this.m_vertices[childIndex + 1];\n\n if (childIndex > 0) {\n edge.m_vertex0 = this.m_vertices[childIndex - 1];\n edge.m_hasVertex0 = true;\n } else {\n edge.m_vertex0 = this.m_prevVertex;\n edge.m_hasVertex0 = this.m_hasPrevVertex;\n }\n\n if (childIndex < this.m_count - 2) {\n edge.m_vertex3 = this.m_vertices[childIndex + 2];\n edge.m_hasVertex3 = true;\n } else {\n edge.m_vertex3 = this.m_nextVertex;\n edge.m_hasVertex3 = this.m_hasNextVertex;\n }\n }\n\n getVertex(index: number): Vec2 {\n if (_ASSERT) console.assert(0 <= index && index <= this.m_count);\n if (index < this.m_count) {\n return this.m_vertices[index];\n } else {\n return this.m_vertices[0];\n }\n }\n\n isLoop(): boolean {\n return this.m_isLoop;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * This always return false.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): false {\n return false;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n\n const edgeShape = new EdgeShape(this.getVertex(childIndex), this.getVertex(childIndex + 1));\n return edgeShape.rayCast(output, input, xf, 0);\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n\n matrix.transformVec2(v1, xf, this.getVertex(childIndex));\n matrix.transformVec2(v2, xf, this.getVertex(childIndex + 1));\n\n AABB.combinePoints(aabb, v1, v2);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * Chains have zero mass.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density?: number): void {\n massData.mass = 0.0;\n matrix.zeroVec2(massData.center);\n massData.I = 0.0;\n }\n\n computeDistanceProxy(proxy: DistanceProxy, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n proxy.m_vertices[0] = this.getVertex(childIndex);\n proxy.m_vertices[1] = this.getVertex(childIndex + 1);\n proxy.m_count = 2;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Chain = ChainShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport type { MassData } from \"../../dynamics/Body\";\nimport { RayCastOutput, RayCastInput, AABBValue } from \"../AABB\";\nimport { DistanceProxy } from \"../Distance\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Shape } from \"../Shape\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const e = matrix.vec2(0, 0);\n/** @internal */ const e1 = matrix.vec2(0, 0);\n/** @internal */ const e2 = matrix.vec2(0, 0);\n/** @internal */ const center = matrix.vec2(0, 0);\n/** @internal */ const s = matrix.vec2(0, 0);\n\ndeclare module \"./PolygonShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PolygonShape(vertices?: Vec2Value[]): PolygonShape;\n}\n\n/**\n * A convex polygon. It is assumed that the interior of the polygon is to the\n * left of each edge. Polygons have a maximum number of vertices equal to\n * Settings.maxPolygonVertices. In most cases you should not need many vertices\n * for a convex polygon. extends Shape\n */\n// @ts-expect-error\nexport class PolygonShape extends Shape {\n static TYPE = \"polygon\" as const;\n /** @hidden */ m_type: \"polygon\";\n\n /** @hidden */ m_centroid: Vec2;\n /** @hidden */ m_vertices: Vec2[]; // [Settings.maxPolygonVertices]\n /** @hidden */ m_normals: Vec2[]; // [Settings.maxPolygonVertices]\n /** @hidden */ m_count: number;\n /** @hidden */ m_radius: number;\n\n constructor(vertices?: Vec2Value[]) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PolygonShape)) {\n return new PolygonShape(vertices);\n }\n\n super();\n\n this.m_type = PolygonShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n this.m_centroid = Vec2.zero();\n this.m_vertices = [];\n this.m_normals = [];\n this.m_count = 0;\n\n if (vertices && vertices.length) {\n this._set(vertices);\n }\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n vertices: this.m_vertices,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, fixture: any, restore: any): PolygonShape {\n const vertices: Vec2[] = [];\n if (data.vertices) {\n for (let i = 0; i < data.vertices.length; i++) {\n vertices.push(restore(Vec2, data.vertices[i]));\n }\n }\n\n const shape = new PolygonShape(vertices);\n return shape;\n }\n\n getType(): \"polygon\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): PolygonShape {\n const clone = new PolygonShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_count = this.m_count;\n clone.m_centroid.setVec2(this.m_centroid);\n for (let i = 0; i < this.m_count; i++) {\n clone.m_vertices.push(this.m_vertices[i].clone());\n }\n for (let i = 0; i < this.m_normals.length; i++) {\n clone.m_normals.push(this.m_normals[i].clone());\n }\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /** @hidden */\n _reset(): void {\n this._set(this.m_vertices);\n }\n\n /**\n * @internal\n *\n * Create a convex hull from the given array of local points. The count must be\n * in the range [3, Settings.maxPolygonVertices].\n *\n * Warning: the points may be re-ordered, even if they form a convex polygon\n * Warning: collinear points are handled but not removed. Collinear points may\n * lead to poor stacking behavior.\n */\n _set(vertices: Vec2Value[]): void {\n if (_ASSERT) console.assert(3 <= vertices.length && vertices.length <= Settings.maxPolygonVertices);\n if (vertices.length < 3) {\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n let n = math_min(vertices.length, Settings.maxPolygonVertices);\n\n // Perform welding and copy vertices into local buffer.\n const ps: Vec2[] = []; // [Settings.maxPolygonVertices];\n for (let i = 0; i < n; ++i) {\n const v = vertices[i];\n\n let unique = true;\n for (let j = 0; j < ps.length; ++j) {\n if (Vec2.distanceSquared(v, ps[j]) < 0.25 * Settings.linearSlopSquared) {\n unique = false;\n break;\n }\n }\n\n if (unique) {\n ps.push(Vec2.clone(v));\n }\n }\n\n n = ps.length;\n if (n < 3) {\n // Polygon is degenerate.\n if (_ASSERT) console.assert(false);\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n // Create the convex hull using the Gift wrapping algorithm\n // http://en.wikipedia.org/wiki/Gift_wrapping_algorithm\n\n // Find the right most point on the hull (in case of multiple points bottom most is used)\n let i0 = 0;\n let x0 = ps[0].x;\n for (let i = 1; i < n; ++i) {\n const x = ps[i].x;\n if (x > x0 || (x === x0 && ps[i].y < ps[i0].y)) {\n i0 = i;\n x0 = x;\n }\n }\n\n const hull = [] as number[]; // [Settings.maxPolygonVertices];\n let m = 0;\n let ih = i0;\n\n while (true) {\n if (_ASSERT) console.assert(m < Settings.maxPolygonVertices);\n hull[m] = ih;\n\n let ie = 0;\n for (let j = 1; j < n; ++j) {\n if (ie === ih) {\n ie = j;\n continue;\n }\n\n const r = Vec2.sub(ps[ie], ps[hull[m]]);\n const v = Vec2.sub(ps[j], ps[hull[m]]);\n const c = Vec2.crossVec2Vec2(r, v);\n // c < 0 means counter-clockwise wrapping, c > 0 means clockwise wrapping\n if (c < 0.0) {\n ie = j;\n }\n\n // Collinearity check\n if (c === 0.0 && v.lengthSquared() > r.lengthSquared()) {\n ie = j;\n }\n }\n\n ++m;\n ih = ie;\n\n if (ie === i0) {\n break;\n }\n }\n\n if (m < 3) {\n // Polygon is degenerate.\n if (_ASSERT) console.assert(false);\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n this.m_count = m;\n\n // Copy vertices.\n this.m_vertices = [];\n for (let i = 0; i < m; ++i) {\n this.m_vertices[i] = ps[hull[i]];\n }\n\n // Compute normals. Ensure the edges have non-zero length.\n for (let i = 0; i < m; ++i) {\n const i1 = i;\n const i2 = i + 1 < m ? i + 1 : 0;\n const edge = Vec2.sub(this.m_vertices[i2], this.m_vertices[i1]);\n if (_ASSERT) console.assert(edge.lengthSquared() > EPSILON * EPSILON);\n this.m_normals[i] = Vec2.crossVec2Num(edge, 1.0);\n this.m_normals[i].normalize();\n }\n\n // Compute the polygon centroid.\n this.m_centroid = computeCentroid(this.m_vertices, m);\n }\n\n /** @internal */ _setAsBox(hx: number, hy: number, center?: Vec2Value, angle?: number): void {\n // start with right-bottom, counter-clockwise, as in Gift wrapping algorithm in PolygonShape._set()\n this.m_vertices[0] = Vec2.neo(hx, -hy);\n this.m_vertices[1] = Vec2.neo(hx, hy);\n this.m_vertices[2] = Vec2.neo(-hx, hy);\n this.m_vertices[3] = Vec2.neo(-hx, -hy);\n\n this.m_normals[0] = Vec2.neo(1.0, 0.0);\n this.m_normals[1] = Vec2.neo(0.0, 1.0);\n this.m_normals[2] = Vec2.neo(-1.0, 0.0);\n this.m_normals[3] = Vec2.neo(0.0, -1.0);\n\n this.m_count = 4;\n\n if (center && Vec2.isValid(center)) {\n angle = angle || 0;\n\n matrix.copyVec2(this.m_centroid, center);\n\n const xf = Transform.identity();\n xf.p.setVec2(center);\n xf.q.setAngle(angle);\n\n // Transform vertices and normals.\n for (let i = 0; i < this.m_count; ++i) {\n this.m_vertices[i] = Transform.mulVec2(xf, this.m_vertices[i]);\n this.m_normals[i] = Rot.mulVec2(xf.q, this.m_normals[i]);\n }\n }\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): boolean {\n const pLocal = matrix.detransformVec2(temp, xf, p);\n\n for (let i = 0; i < this.m_count; ++i) {\n const dot = matrix.dotVec2(this.m_normals[i], pLocal) - matrix.dotVec2(this.m_normals[i], this.m_vertices[i]);\n if (dot > 0.0) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n\n // Put the ray into the polygon's frame of reference.\n const p1 = Rot.mulTVec2(xf.q, Vec2.sub(input.p1, xf.p));\n const p2 = Rot.mulTVec2(xf.q, Vec2.sub(input.p2, xf.p));\n const d = Vec2.sub(p2, p1);\n\n let lower = 0.0;\n let upper = input.maxFraction;\n\n let index = -1;\n\n for (let i = 0; i < this.m_count; ++i) {\n // p = p1 + a * d\n // dot(normal, p - v) = 0\n // dot(normal, p1 - v) + a * dot(normal, d) = 0\n const numerator = Vec2.dot(this.m_normals[i], Vec2.sub(this.m_vertices[i], p1));\n const denominator = Vec2.dot(this.m_normals[i], d);\n\n if (denominator == 0.0) {\n if (numerator < 0.0) {\n return false;\n }\n } else {\n // Note: we want this predicate without division:\n // lower < numerator / denominator, where denominator < 0\n // Since denominator < 0, we have to flip the inequality:\n // lower < numerator / denominator <==> denominator * lower > numerator.\n if (denominator < 0.0 && numerator < lower * denominator) {\n // Increase lower.\n // The segment enters this half-space.\n lower = numerator / denominator;\n index = i;\n } else if (denominator > 0.0 && numerator < upper * denominator) {\n // Decrease upper.\n // The segment exits this half-space.\n upper = numerator / denominator;\n }\n }\n\n // The use of epsilon here causes the assert on lower to trip\n // in some cases. Apparently the use of epsilon was to make edge\n // shapes work, but now those are handled separately.\n // if (upper < lower - matrix.EPSILON)\n if (upper < lower) {\n return false;\n }\n }\n\n if (_ASSERT) console.assert(0.0 <= lower && lower <= input.maxFraction);\n\n if (index >= 0) {\n output.fraction = lower;\n output.normal = Rot.mulVec2(xf.q, this.m_normals[index]);\n return true;\n }\n\n return false;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (let i = 0; i < this.m_count; ++i) {\n const v = matrix.transformVec2(temp, xf, this.m_vertices[i]);\n minX = math_min(minX, v.x);\n maxX = math_max(maxX, v.x);\n minY = math_min(minY, v.y);\n maxY = math_max(maxY, v.y);\n }\n\n matrix.setVec2(aabb.lowerBound, minX - this.m_radius, minY - this.m_radius);\n matrix.setVec2(aabb.upperBound, maxX + this.m_radius, maxY + this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density: number): void {\n // Polygon mass, centroid, and inertia.\n // Let rho be the polygon density in mass per unit area.\n // Then:\n // mass = rho * int(dA)\n // centroid.x = (1/mass) * rho * int(x * dA)\n // centroid.y = (1/mass) * rho * int(y * dA)\n // I = rho * int((x*x + y*y) * dA)\n //\n // We can compute these integrals by summing all the integrals\n // for each triangle of the polygon. To evaluate the integral\n // for a single triangle, we make a change of variables to\n // the (u,v) coordinates of the triangle:\n // x = x0 + e1x * u + e2x * v\n // y = y0 + e1y * u + e2y * v\n // where 0 <= u && 0 <= v && u + v <= 1.\n //\n // We integrate u from [0,1-v] and then v from [0,1].\n // We also need to use the Jacobian of the transformation:\n // D = cross(e1, e2)\n //\n // Simplification: triangle centroid = (1/3) * (p1 + p2 + p3)\n //\n // The rest of the derivation is handled by computer algebra.\n\n if (_ASSERT) console.assert(this.m_count >= 3);\n\n matrix.zeroVec2(center);\n let area = 0.0;\n let I = 0.0;\n\n // s is the reference point for forming triangles.\n // It's location doesn't change the result (except for rounding error).\n matrix.zeroVec2(s);\n\n // This code would put the reference point inside the polygon.\n for (let i = 0; i < this.m_count; ++i) {\n matrix.plusVec2(s, this.m_vertices[i]);\n }\n matrix.scaleVec2(s, 1.0 / this.m_count, s);\n\n const k_inv3 = 1.0 / 3.0;\n\n for (let i = 0; i < this.m_count; ++i) {\n // Triangle vertices.\n matrix.subVec2(e1, this.m_vertices[i], s);\n if ( i + 1 < this.m_count) {\n matrix.subVec2(e2, this.m_vertices[i + 1], s);\n } else {\n matrix.subVec2(e2, this.m_vertices[0], s);\n }\n\n const D = matrix.crossVec2Vec2(e1, e2);\n\n const triangleArea = 0.5 * D;\n area += triangleArea;\n\n // Area weighted centroid\n matrix.combine2Vec2(temp, triangleArea * k_inv3, e1, triangleArea * k_inv3, e2);\n matrix.plusVec2(center, temp);\n\n const ex1 = e1.x;\n const ey1 = e1.y;\n const ex2 = e2.x;\n const ey2 = e2.y;\n\n const intx2 = ex1 * ex1 + ex2 * ex1 + ex2 * ex2;\n const inty2 = ey1 * ey1 + ey2 * ey1 + ey2 * ey2;\n\n I += (0.25 * k_inv3 * D) * (intx2 + inty2);\n }\n\n // Total mass\n massData.mass = density * area;\n\n // Center of mass\n if (_ASSERT) console.assert(area > EPSILON);\n matrix.scaleVec2(center, 1.0 / area, center);\n matrix.addVec2(massData.center, center, s);\n\n // Inertia tensor relative to the local origin (point s).\n massData.I = density * I;\n\n // Shift to center of mass then to original body origin.\n massData.I += massData.mass * (matrix.dotVec2(massData.center, massData.center) - matrix.dotVec2(center, center));\n }\n\n /**\n * Validate convexity. This is a very time consuming operation.\n * @returns true if valid\n */\n validate(): boolean {\n for (let i = 0; i < this.m_count; ++i) {\n const i1 = i;\n const i2 = i < this.m_count - 1 ? i1 + 1 : 0;\n const p = this.m_vertices[i1];\n matrix.subVec2(e, this.m_vertices[i2], p);\n\n for (let j = 0; j < this.m_count; ++j) {\n if (j == i1 || j == i2) {\n continue;\n }\n\n const c = matrix.crossVec2Vec2(e, matrix.subVec2(temp, this.m_vertices[j], p));\n if (c < 0.0) {\n return false;\n }\n }\n }\n\n return true;\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n for (let i = 0; i < this.m_count; ++i) {\n proxy.m_vertices[i] = this.m_vertices[i];\n }\n proxy.m_vertices.length = this.m_count;\n proxy.m_count = this.m_count;\n proxy.m_radius = this.m_radius;\n }\n}\n\n/** @internal */ function computeCentroid(vs: Vec2[], count: number): Vec2 {\n if (_ASSERT) console.assert(count >= 3);\n\n const c = Vec2.zero();\n let area = 0.0;\n\n // pRef is the reference point for forming triangles.\n // It's location doesn't change the result (except for rounding error).\n const pRef = Vec2.zero();\n if (false) {\n // This code would put the reference point inside the polygon.\n for (let i = 0; i < count; ++i) {\n pRef.add(vs[i]);\n }\n pRef.mul(1.0 / count);\n }\n\n const inv3 = 1.0 / 3.0;\n\n for (let i = 0; i < count; ++i) {\n // Triangle vertices.\n const p1 = pRef;\n const p2 = vs[i];\n const p3 = i + 1 < count ? vs[i + 1] : vs[0];\n\n const e1 = Vec2.sub(p2, p1);\n const e2 = Vec2.sub(p3, p1);\n\n const D = Vec2.crossVec2Vec2(e1, e2);\n\n const triangleArea = 0.5 * D;\n area += triangleArea;\n\n // Area weighted centroid\n matrix.combine3Vec2(temp, 1, p1, 1, p2, 1, p3);\n matrix.plusScaleVec2(c, triangleArea * inv3, temp);\n }\n\n // Centroid\n if (_ASSERT) console.assert(area > EPSILON);\n c.mul(1.0 / area);\n return c;\n}\n\nexport const Polygon = PolygonShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Shape } from \"../Shape\";\nimport { AABBValue, RayCastInput, RayCastOutput } from \"../AABB\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { MassData } from \"../../dynamics/Body\";\nimport { DistanceProxy } from \"../Distance\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_PI = Math.PI;\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n\ndeclare module \"./CircleShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function CircleShape(position: Vec2Value, radius?: number): CircleShape;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function CircleShape(radius?: number): CircleShape;\n}\n\n/** Circle shape. */\n// @ts-expect-error\nexport class CircleShape extends Shape {\n static TYPE = \"circle\" as const;\n /** @hidden */ m_type: \"circle\";\n\n /** @hidden */ m_p: Vec2;\n /** @hidden */ m_radius: number;\n\n constructor(position: Vec2Value, radius?: number);\n constructor(radius?: number);\n constructor(a: any, b?: any) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof CircleShape)) {\n return new CircleShape(a, b);\n }\n\n super();\n\n this.m_type = CircleShape.TYPE;\n this.m_p = Vec2.zero();\n this.m_radius = 1;\n\n if (typeof a === \"object\" && Vec2.isValid(a)) {\n this.m_p.setVec2(a);\n\n if (typeof b === \"number\") {\n this.m_radius = b;\n }\n\n } else if (typeof a === \"number\") {\n this.m_radius = a;\n }\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n p: this.m_p,\n radius: this.m_radius,\n };\n }\n\n /** @internal */\n static _deserialize(data: any): CircleShape {\n return new CircleShape(data.p, data.radius);\n }\n\n /** @hidden */\n _reset(): void {\n // noop\n }\n\n getType(): \"circle\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n getCenter(): Vec2 {\n return this.m_p;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): CircleShape {\n const clone = new CircleShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_p = this.m_p.clone();\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): boolean {\n const center = matrix.transformVec2(temp, xf, this.m_p);\n return matrix.distSqrVec2(p, center) <= this.m_radius * this.m_radius;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n // Collision Detection in Interactive 3D Environments by Gino van den Bergen\n // From Section 3.1.2\n // x = s + a * r\n // norm(x) = radius\n\n const position = Vec2.add(xf.p, Rot.mulVec2(xf.q, this.m_p));\n const s = Vec2.sub(input.p1, position);\n const b = Vec2.dot(s, s) - this.m_radius * this.m_radius;\n\n // Solve quadratic equation.\n const r = Vec2.sub(input.p2, input.p1);\n const c = Vec2.dot(s, r);\n const rr = Vec2.dot(r, r);\n const sigma = c * c - rr * b;\n\n // Check for negative discriminant and short segment.\n if (sigma < 0.0 || rr < EPSILON) {\n return false;\n }\n\n // Find the point of intersection of the line with the circle.\n let a = -(c + math_sqrt(sigma));\n\n // Is the intersection point on the segment?\n if (0.0 <= a && a <= input.maxFraction * rr) {\n a /= rr;\n output.fraction = a;\n output.normal = Vec2.add(s, Vec2.mulNumVec2(a, r));\n output.normal.normalize();\n return true;\n }\n\n return false;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n const p = matrix.transformVec2(temp, xf, this.m_p);\n\n matrix.setVec2(aabb.lowerBound, p.x - this.m_radius, p.y - this.m_radius);\n matrix.setVec2(aabb.upperBound, p.x + this.m_radius, p.y + this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density: number): void {\n massData.mass = density * math_PI * this.m_radius * this.m_radius;\n matrix.copyVec2(massData.center, this.m_p);\n // inertia about the local origin\n massData.I = massData.mass * (0.5 * this.m_radius * this.m_radius + matrix.lengthSqrVec2(this.m_p));\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n proxy.m_vertices[0] = this.m_p;\n proxy.m_vertices.length = 1;\n proxy.m_count = 1;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Circle = CircleShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Distance joint definition. This requires defining an anchor point on both\n * bodies and the non-zero length of the distance joint. The definition uses\n * local anchor points so that the initial configuration can violate the\n * constraint slightly. This helps when saving and loading a game. Warning: Do\n * not use a zero or short length.\n */\nexport interface DistanceJointOpt extends JointOpt {\n /**\n * The mass-spring-damper frequency in Hertz. A value of 0 disables softness.\n */\n frequencyHz?: number;\n /**\n * The damping ratio. 0 = no damping, 1 = critical damping.\n */\n dampingRatio?: number;\n /**\n * Distance length.\n */\n length?: number;\n}\n/**\n * Distance joint definition. This requires defining an anchor point on both\n * bodies and the non-zero length of the distance joint. The definition uses\n * local anchor points so that the initial configuration can violate the\n * constraint slightly. This helps when saving and loading a game. Warning: Do\n * not use a zero or short length.\n */\nexport interface DistanceJointDef extends JointDef, DistanceJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n frequencyHz : 0.0,\n dampingRatio : 0.0\n};\n\ndeclare module \"./DistanceJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function DistanceJoint(def: DistanceJointDef): DistanceJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function DistanceJoint(def: DistanceJointOpt, bodyA: Body, bodyB: Body, anchorA: Vec2Value, anchorB: Vec2Value): DistanceJoint;\n}\n\n/**\n * A distance joint constrains two points on two bodies to remain at a fixed\n * distance from each other. You can view this as a massless, rigid rod.\n */\n// @ts-expect-error\nexport class DistanceJoint extends Joint {\n static TYPE = \"distance-joint\" as const;\n\n // Solver shared\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_length: number;\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_gamma: number;\n /** @internal */ m_bias: number;\n\n // Solver temp\n /** @internal */ m_u: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: number;\n\n /**\n * @param def DistanceJoint definition.\n */\n constructor(def: DistanceJointDef);\n /**\n * @param anchorA Anchor A in global coordination.\n * @param anchorB Anchor B in global coordination.\n */\n constructor(def: DistanceJointOpt, bodyA: Body, bodyB: Body, anchorA?: Vec2Value, anchorB?: Vec2Value);\n constructor(def: DistanceJointDef, bodyA?: Body, bodyB?: Body, anchorA?: Vec2Value, anchorB?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof DistanceJoint)) {\n return new DistanceJoint(def, bodyA, bodyB, anchorA, anchorB);\n }\n\n // order of constructor arguments is changed in v0.2\n if (bodyB && anchorA && (\"m_type\" in anchorA) && (\"x\" in bodyB) && (\"y\" in bodyB)) {\n const temp = bodyB;\n bodyB = anchorA as any as Body;\n anchorA = temp as any as Vec2;\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = DistanceJoint.TYPE;\n\n // Solver shared\n this.m_localAnchorA = Vec2.clone(anchorA ? bodyA.getLocalPoint(anchorA) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchorB ? bodyB.getLocalPoint(anchorB) : def.localAnchorB || Vec2.zero());\n this.m_length = Number.isFinite(def.length) ? def.length :\n Vec2.distance(bodyA.getWorldPoint(this.m_localAnchorA), bodyB.getWorldPoint(this.m_localAnchorB));\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n this.m_impulse = 0.0;\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n\n // 1-D constrained system\n // m (v2 - v1) = lambda\n // v2 + (beta/h) * x1 + gamma * lambda = 0, gamma has units of inverse mass.\n // x2 = x1 + h * v2\n\n // 1-D mass-damper-spring system\n // m (v2 - v1) + h * d * v2 + h * k *\n\n // C = norm(p2 - p1) - L\n // u = (p2 - p1) / norm(p2 - p1)\n // Cdot = dot(u, v2 + cross(w2, r2) - v1 - cross(w1, r1))\n // J = [-u -cross(r1, u) u cross(r2, u)]\n // K = J * invM * JT\n // = invMass1 + invI1 * cross(r1, u)^2 + invMass2 + invI2 * cross(r2, u)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n length: this.m_length,\n\n impulse: this.m_impulse,\n gamma: this.m_gamma,\n bias: this.m_bias,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): DistanceJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new DistanceJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n\n if (def.length > 0) {\n this.m_length = +def.length;\n } else if (def.length < 0) { // don't change length\n } else if (def.anchorA || def.anchorA || def.anchorA || def.anchorA) {\n this.m_length = Vec2.distance(\n this.m_bodyA.getWorldPoint(this.m_localAnchorA),\n this.m_bodyB.getWorldPoint(this.m_localAnchorB)\n );\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the natural length. Manipulating the length can lead to non-physical\n * behavior when the frequency is zero.\n */\n setLength(length: number): void {\n this.m_length = length;\n }\n\n /**\n * Get the natural length.\n */\n getLength(): number {\n return this.m_length;\n }\n\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_u).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n this.m_u = Vec2.sub(Vec2.add(cB, this.m_rB), Vec2.add(cA, this.m_rA));\n\n // Handle singularity.\n const length = this.m_u.length();\n if (length > Settings.linearSlop) {\n this.m_u.mul(1.0 / length);\n } else {\n this.m_u.setNum(0.0, 0.0);\n }\n\n const crAu = Vec2.crossVec2Vec2(this.m_rA, this.m_u);\n const crBu = Vec2.crossVec2Vec2(this.m_rB, this.m_u);\n let invMass = this.m_invMassA + this.m_invIA * crAu * crAu + this.m_invMassB + this.m_invIB * crBu * crBu;\n\n // Compute the effective mass matrix.\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n\n if (this.m_frequencyHz > 0.0) {\n const C = length - this.m_length;\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * this.m_mass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = this.m_mass * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (d + h * k);\n this.m_gamma = this.m_gamma != 0.0 ? 1.0 / this.m_gamma : 0.0;\n this.m_bias = C * h * k * this.m_gamma;\n\n invMass += this.m_gamma;\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n } else {\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n }\n\n if (step.warmStarting) {\n // Scale the impulse to support a variable time step.\n this.m_impulse *= step.dtRatio;\n\n const P = Vec2.mulNumVec2(this.m_impulse, this.m_u);\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Cdot = dot(u, v + cross(w, r))\n const vpA = Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA));\n const vpB = Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB));\n const Cdot = Vec2.dot(this.m_u, vpB) - Vec2.dot(this.m_u, vpA);\n\n const impulse = -this.m_mass * (Cdot + this.m_bias + this.m_gamma * this.m_impulse);\n this.m_impulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_u);\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n if (this.m_frequencyHz > 0.0) {\n // There is no position correction for soft distance constraints.\n return true;\n }\n\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n const u = Vec2.sub(Vec2.add(cB, rB), Vec2.add(cA, rA));\n\n const length = u.normalize();\n const C = clamp(length - this.m_length, -Settings.maxLinearCorrection, Settings.maxLinearCorrection);\n\n const impulse = -this.m_mass * C;\n const P = Vec2.mulNumVec2(impulse, u);\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * Vec2.crossVec2Vec2(rA, P);\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, P);\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return math_abs(C) < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Friction joint definition.\n */\nexport interface FrictionJointOpt extends JointOpt {\n /**\n * The maximum friction force in N.\n */\n maxForce?: number;\n /**\n * The maximum friction torque in N-m.\n */\n maxTorque?: number;\n}\n\n/**\n * Friction joint definition.\n */\nexport interface FrictionJointDef extends JointDef, FrictionJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 0.0,\n maxTorque : 0.0,\n};\n\ndeclare module \"./FrictionJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function FrictionJoint(def: FrictionJointDef): FrictionJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function FrictionJoint(def: FrictionJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): FrictionJoint;\n}\n\n/**\n * Friction joint. This is used for top-down friction. It provides 2D\n * translational friction and angular friction.\n */\n// @ts-expect-error\nexport class FrictionJoint extends Joint {\n static TYPE = \"friction-joint\" as const;\n\n /** @internal */ m_type: \"friction-joint\";\n\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n\n // Solver shared\n /** @internal */ m_linearImpulse: Vec2;\n /** @internal */ m_angularImpulse: number;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_maxTorque: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_linearMass: Mat22;\n /** @internal */ m_angularMass: number;\n\n constructor(def: FrictionJointDef);\n /**\n * @param anchor Anchor in global coordination.\n */\n constructor(def: FrictionJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: FrictionJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof FrictionJoint)) {\n return new FrictionJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = FrictionJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n\n // Solver shared\n this.m_linearImpulse = Vec2.zero();\n this.m_angularImpulse = 0.0;\n this.m_maxForce = def.maxForce;\n this.m_maxTorque = def.maxTorque;\n\n // Point-to-point constraint\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Angle constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n maxForce: this.m_maxForce,\n maxTorque: this.m_maxTorque,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): FrictionJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new FrictionJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.maxTorque)) {\n this.m_maxTorque = def.maxTorque;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the maximum friction force in N.\n */\n setMaxForce(force: number): void {\n if (_ASSERT) console.assert(Number.isFinite(force) && force >= 0.0);\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum friction force in N.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the maximum friction torque in N*m.\n */\n setMaxTorque(torque: number): void {\n if (_ASSERT) console.assert(Number.isFinite(torque) && torque >= 0.0);\n this.m_maxTorque = torque;\n }\n\n /**\n * Get the maximum friction torque in N*m.\n */\n getMaxTorque(): number {\n return this.m_maxTorque;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_linearImpulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_angularImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective mass matrix.\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat22();\n K.ex.x = mA + mB + iA * this.m_rA.y * this.m_rA.y + iB * this.m_rB.y\n * this.m_rB.y;\n K.ex.y = -iA * this.m_rA.x * this.m_rA.y - iB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * this.m_rA.x * this.m_rA.x + iB * this.m_rB.x\n * this.m_rB.x;\n\n this.m_linearMass = K.getInverse();\n\n this.m_angularMass = iA + iB;\n if (this.m_angularMass > 0.0) {\n this.m_angularMass = 1.0 / this.m_angularMass;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_linearImpulse.mul(step.dtRatio);\n this.m_angularImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_linearImpulse.x, this.m_linearImpulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_angularImpulse);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_angularImpulse);\n\n } else {\n this.m_linearImpulse.setZero();\n this.m_angularImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const h = step.dt;\n\n // Solve angular friction\n {\n const Cdot = wB - wA;\n let impulse = -this.m_angularMass * Cdot;\n\n const oldImpulse = this.m_angularImpulse;\n const maxImpulse = h * this.m_maxTorque;\n this.m_angularImpulse = clamp(this.m_angularImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_angularImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve linear friction\n {\n const Cdot = Vec2.sub(\n Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB)),\n Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA))\n );\n\n let impulse = Vec2.neg(Mat22.mulVec2(this.m_linearMass, Cdot));\n const oldImpulse = this.m_linearImpulse;\n this.m_linearImpulse.add(impulse);\n\n const maxImpulse = h * this.m_maxForce;\n\n if (this.m_linearImpulse.lengthSquared() > maxImpulse * maxImpulse) {\n this.m_linearImpulse.normalize();\n this.m_linearImpulse.mul(maxImpulse);\n }\n\n impulse = Vec2.sub(this.m_linearImpulse, oldImpulse);\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { Vec3, Vec3Value } from \"./Vec3\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A 3-by-3 matrix. Stored in column-major order.\n */\nexport class Mat33 {\n ex: Vec3;\n ey: Vec3;\n ez: Vec3;\n\n constructor(a: Vec3Value, b: Vec3Value, c: Vec3Value);\n constructor();\n constructor(a?: Vec3Value, b?: Vec3Value, c?: Vec3Value) {\n if (typeof a === \"object\" && a !== null) {\n this.ex = Vec3.clone(a);\n this.ey = Vec3.clone(b);\n this.ez = Vec3.clone(c);\n } else {\n this.ex = Vec3.zero();\n this.ey = Vec3.zero();\n this.ez = Vec3.zero();\n }\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec3.isValid(obj.ex) && Vec3.isValid(obj.ey) && Vec3.isValid(obj.ez);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Mat33.isValid(o), \"Invalid Mat33!\", o);\n }\n\n /**\n * Set this matrix to all zeros.\n */\n setZero(): Mat33 {\n this.ex.setZero();\n this.ey.setZero();\n this.ez.setZero();\n return this;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases.\n */\n solve33(v: Vec3Value): Vec3 {\n // let det = matrix.dotVec3(this.ex, matrix.newCrossVec3(this.ey, this.ez));\n let cross_x = this.ey.y * this.ez.z - this.ey.z * this.ez.y;\n let cross_y = this.ey.z * this.ez.x - this.ey.x * this.ez.z;\n let cross_z = this.ey.x * this.ez.y - this.ey.y * this.ez.x;\n let det = this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const r = new Vec3();\n // r.x = det * matrix.dotVec3(v, matrix.newCrossVec3(this.ey, this.ez));\n cross_x = this.ey.y * this.ez.z - this.ey.z * this.ez.y;\n cross_y = this.ey.z * this.ez.x - this.ey.x * this.ez.z;\n cross_z = this.ey.x * this.ez.y - this.ey.y * this.ez.x;\n r.x = det * (v.x * cross_x + v.y * cross_y + v.z * cross_z);\n\n // r.y = det * matrix.dotVec3(this.ex, matrix.newCrossVec3(v, this.ez));\n cross_x = v.y * this.ez.z - v.z * this.ez.y;\n cross_y = v.z * this.ez.x - v.x * this.ez.z;\n cross_z = v.x * this.ez.y - v.y * this.ez.x;\n r.y = det * (this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z);\n\n // r.z = det * matrix.dotVec3(this.ex, matrix.newCrossVec3(this.ey, v));\n cross_x = this.ey.y * v.z - this.ey.z * v.y;\n cross_y = this.ey.z * v.x - this.ey.x * v.z;\n cross_z = this.ey.x * v.y - this.ey.y * v.x;\n r.z = det * (this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z);\n return r;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases. Solve only the upper 2-by-2 matrix\n * equation.\n */\n solve22(v: Vec2Value): Vec2 {\n const a11 = this.ex.x;\n const a12 = this.ey.x;\n const a21 = this.ex.y;\n const a22 = this.ey.y;\n let det = a11 * a22 - a12 * a21;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const r = Vec2.zero();\n r.x = det * (a22 * v.x - a12 * v.y);\n r.y = det * (a11 * v.y - a21 * v.x);\n return r;\n }\n\n /**\n * Get the inverse of this matrix as a 2-by-2. Returns the zero matrix if\n * singular.\n */\n getInverse22(M: Mat33): void {\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n M.ex.x = det * d;\n M.ey.x = -det * b;\n M.ex.z = 0.0;\n M.ex.y = -det * c;\n M.ey.y = det * a;\n M.ey.z = 0.0;\n M.ez.x = 0.0;\n M.ez.y = 0.0;\n M.ez.z = 0.0;\n }\n\n /**\n * Get the symmetric inverse of this matrix as a 3-by-3. Returns the zero matrix\n * if singular.\n */\n getSymInverse33(M: Mat33): void {\n let det = Vec3.dot(this.ex, Vec3.cross(this.ey, this.ez));\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const a11 = this.ex.x;\n const a12 = this.ey.x;\n const a13 = this.ez.x;\n const a22 = this.ey.y;\n const a23 = this.ez.y;\n const a33 = this.ez.z;\n\n M.ex.x = det * (a22 * a33 - a23 * a23);\n M.ex.y = det * (a13 * a23 - a12 * a33);\n M.ex.z = det * (a12 * a23 - a13 * a22);\n\n M.ey.x = M.ex.y;\n M.ey.y = det * (a11 * a33 - a13 * a13);\n M.ey.z = det * (a13 * a12 - a11 * a23);\n\n M.ez.x = M.ex.z;\n M.ez.y = M.ey.z;\n M.ez.z = det * (a11 * a22 - a12 * a12);\n }\n\n /**\n * Multiply a matrix times a vector.\n */\n static mul(a: Mat33, b: Vec2Value): Vec2;\n static mul(a: Mat33, b: Vec3Value): Vec3;\n static mul(a, b) {\n if (_ASSERT) Mat33.assert(a);\n if (b && \"z\" in b && \"y\" in b && \"x\" in b) {\n if (_ASSERT) Vec3.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y + a.ez.x * b.z;\n const y = a.ex.y * b.x + a.ey.y * b.y + a.ez.y * b.z;\n const z = a.ex.z * b.x + a.ey.z * b.y + a.ez.z * b.z;\n return new Vec3(x, y, z);\n\n } else if (b && \"y\" in b && \"x\" in b) {\n if (_ASSERT) Vec2.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y;\n const y = a.ex.y * b.x + a.ey.y * b.y;\n return Vec2.neo(x, y);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulVec3(a: Mat33, b: Vec3Value): Vec3 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Vec3.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y + a.ez.x * b.z;\n const y = a.ex.y * b.x + a.ey.y * b.y + a.ez.y * b.z;\n const z = a.ex.z * b.x + a.ey.z * b.y + a.ez.z * b.z;\n return new Vec3(x, y, z);\n }\n\n static mulVec2(a: Mat33, b: Vec2Value): Vec2 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y;\n const y = a.ex.y * b.x + a.ey.y * b.y;\n return Vec2.neo(x, y);\n }\n\n static add(a: Mat33, b: Mat33): Mat33 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Mat33.assert(b);\n return new Mat33(\n Vec3.add(a.ex, b.ex),\n Vec3.add(a.ey, b.ey),\n Vec3.add(a.ez, b.ez)\n );\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n\n\n// todo: use string?\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3,\n} \n\n/**\n * Revolute joint definition. This requires defining an anchor point where the\n * bodies are joined. The definition uses local anchor points so that the\n * initial configuration can violate the constraint slightly. You also need to\n * specify the initial relative angle for joint limits. This helps when saving\n * and loading a game.\n *\n * The local anchor points are measured from the body's origin rather than the\n * center of mass because: 1. you might not know where the center of mass will\n * be. 2. if you add/remove shapes from a body and recompute the mass, the\n * joints will be broken.\n */\nexport interface RevoluteJointOpt extends JointOpt {\n /**\n * The lower angle for the joint limit (radians).\n */\n lowerAngle?: number;\n /**\n * The upper angle for the joint limit (radians).\n */\n upperAngle?: number;\n /**\n * The maximum motor torque used to achieve the desired motor speed. Usually\n * in N-m.\n */\n maxMotorTorque?: number;\n /**\n * The desired motor speed. Usually in radians per second.\n */\n motorSpeed?: number;\n /**\n * A flag to enable joint limits.\n */\n enableLimit?: boolean;\n /**\n * A flag to enable the joint motor.\n */\n enableMotor?: boolean;\n}\n\n/**\n * Revolute joint definition. This requires defining an anchor point where the\n * bodies are joined. The definition uses local anchor points so that the\n * initial configuration can violate the constraint slightly. You also need to\n * specify the initial relative angle for joint limits. This helps when saving\n * and loading a game.\n *\n * The local anchor points are measured from the body's origin rather than the\n * center of mass because: 1. you might not know where the center of mass will\n * be. 2. if you add/remove shapes from a body and recompute the mass, the\n * joints will be broken.\n */\nexport interface RevoluteJointDef extends JointDef, RevoluteJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The bodyB angle minus bodyA angle in the reference state (radians).\n */\n referenceAngle?: number;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n lowerAngle : 0.0,\n upperAngle : 0.0,\n maxMotorTorque : 0.0,\n motorSpeed : 0.0,\n enableLimit : false,\n enableMotor : false\n};\n\ndeclare module \"./RevoluteJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RevoluteJoint(def: RevoluteJointDef): RevoluteJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RevoluteJoint(def: RevoluteJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): RevoluteJoint;\n}\n\n/**\n * A revolute joint constrains two bodies to share a common point while they are\n * free to rotate about the point. The relative rotation about the shared point\n * is the joint angle. You can limit the relative rotation with a joint limit\n * that specifies a lower and upper angle. You can use a motor to drive the\n * relative rotation about the shared point. A maximum motor torque is provided\n * so that infinite forces are not generated.\n */\n// @ts-expect-error\nexport class RevoluteJoint extends Joint {\n static TYPE = \"revolute-joint\" as const;\n\n /** @internal */ m_type: \"revolute-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngle: number;\n /** @internal */ m_impulse: Vec3;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_lowerAngle: number;\n /** @internal */ m_upperAngle: number;\n /** @internal */ m_maxMotorTorque: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableLimit: boolean;\n /** @internal */ m_enableMotor: boolean;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n // effective mass for point-to-point constraint.\n /** @internal */ m_mass: Mat33;\n // effective mass for motor/limit angular constraint.\n /** @internal */ m_motorMass: number;\n /** @internal */ m_limitState: number;\n\n constructor(def: RevoluteJointDef);\n constructor(def: RevoluteJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: RevoluteJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof RevoluteJoint)) {\n return new RevoluteJoint(def, bodyA, bodyB, anchor);\n }\n\n def = def ?? {} as RevoluteJointDef;\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_mass = new Mat33();\n this.m_limitState = LimitState.inactiveLimit;\n\n this.m_type = RevoluteJoint.TYPE;\n\n if (Vec2.isValid(anchor)) {\n this.m_localAnchorA = bodyA.getLocalPoint(anchor);\n } else if (Vec2.isValid(def.localAnchorA)) {\n this.m_localAnchorA = Vec2.clone(def.localAnchorA);\n } else {\n this.m_localAnchorA = Vec2.zero();\n }\n\n if (Vec2.isValid(anchor)) {\n this.m_localAnchorB = bodyB.getLocalPoint(anchor);\n } else if (Vec2.isValid(def.localAnchorB)) {\n this.m_localAnchorB = Vec2.clone(def.localAnchorB);\n } else {\n this.m_localAnchorB = Vec2.zero();\n }\n\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n } else {\n this.m_referenceAngle = bodyB.getAngle() - bodyA.getAngle();\n }\n\n this.m_impulse = new Vec3();\n this.m_motorImpulse = 0.0;\n\n this.m_lowerAngle = def.lowerAngle ?? DEFAULTS.lowerAngle;\n this.m_upperAngle = def.upperAngle ?? DEFAULTS.upperAngle;\n this.m_maxMotorTorque = def.maxMotorTorque ?? DEFAULTS.maxMotorTorque;\n this.m_motorSpeed = def.motorSpeed ?? DEFAULTS.motorSpeed;\n this.m_enableLimit = def.enableLimit ?? DEFAULTS.enableLimit;\n this.m_enableMotor = def.enableMotor ?? DEFAULTS.enableMotor;\n\n // Point-to-point constraint\n // C = p2 - p1\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Motor constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n lowerAngle: this.m_lowerAngle,\n upperAngle: this.m_upperAngle,\n maxMotorTorque: this.m_maxMotorTorque,\n motorSpeed: this.m_motorSpeed,\n enableLimit: this.m_enableLimit,\n enableMotor: this.m_enableMotor,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any):RevoluteJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new RevoluteJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n }\n if (def.enableLimit !== undefined) {\n this.m_enableLimit = def.enableLimit;\n }\n if (Number.isFinite(def.lowerAngle)) {\n this.m_lowerAngle = def.lowerAngle;\n }\n if (Number.isFinite(def.upperAngle)) {\n this.m_upperAngle = def.upperAngle;\n }\n if (Number.isFinite(def.maxMotorTorque)) {\n this.m_maxMotorTorque = def.maxMotorTorque;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n if (def.enableMotor !== undefined) {\n this.m_enableMotor = def.enableMotor;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Get the current joint angle in radians.\n */\n getJointAngle(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n return bB.m_sweep.a - bA.m_sweep.a - this.m_referenceAngle;\n }\n\n /**\n * Get the current joint angle speed in radians per second.\n */\n getJointSpeed(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n return bB.m_angularVelocity - bA.m_angularVelocity;\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Get the current motor torque given the inverse time step. Unit is N*m.\n */\n getMotorTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Set the motor speed in radians per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Get the motor speed in radians per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Set the maximum motor torque, usually in N-m.\n */\n setMaxMotorTorque(torque: number): void {\n if (torque == this.m_maxMotorTorque) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorTorque = torque;\n }\n\n getMaxMotorTorque(): number {\n return this.m_maxMotorTorque;\n }\n\n /**\n * Is the joint limit enabled?\n */\n isLimitEnabled(): boolean {\n return this.m_enableLimit;\n }\n\n /**\n * Enable/disable the joint limit.\n */\n enableLimit(flag: boolean): void {\n if (flag != this.m_enableLimit) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableLimit = flag;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Get the lower joint limit in radians.\n */\n getLowerLimit(): number {\n return this.m_lowerAngle;\n }\n\n /**\n * Get the upper joint limit in radians.\n */\n getUpperLimit(): number {\n return this.m_upperAngle;\n }\n\n /**\n * Set the joint limits in radians.\n */\n setLimits(lower: number, upper: number): void {\n if (_ASSERT) console.assert(lower <= upper);\n\n if (lower != this.m_lowerAngle || upper != this.m_upperAngle) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_impulse.z = 0.0;\n this.m_lowerAngle = lower;\n this.m_upperAngle = upper;\n }\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force given the inverse time step. Unit is N.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.neo(this.m_impulse.x, this.m_impulse.y).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque due to the joint limit given the inverse time step.\n * Unit is N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.z;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const fixedRotation = (iA + iB === 0.0);\n\n this.m_mass.ex.x = mA + mB + this.m_rA.y * this.m_rA.y * iA + this.m_rB.y * this.m_rB.y * iB;\n this.m_mass.ey.x = -this.m_rA.y * this.m_rA.x * iA - this.m_rB.y * this.m_rB.x * iB;\n this.m_mass.ez.x = -this.m_rA.y * iA - this.m_rB.y * iB;\n this.m_mass.ex.y = this.m_mass.ey.x;\n this.m_mass.ey.y = mA + mB + this.m_rA.x * this.m_rA.x * iA + this.m_rB.x * this.m_rB.x * iB;\n this.m_mass.ez.y = this.m_rA.x * iA + this.m_rB.x * iB;\n this.m_mass.ex.z = this.m_mass.ez.x;\n this.m_mass.ey.z = this.m_mass.ez.y;\n this.m_mass.ez.z = iA + iB;\n\n this.m_motorMass = iA + iB;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n\n if (this.m_enableMotor == false || fixedRotation) {\n this.m_motorImpulse = 0.0;\n }\n\n if (this.m_enableLimit && fixedRotation == false) {\n const jointAngle = aB - aA - this.m_referenceAngle;\n\n if (math_abs(this.m_upperAngle - this.m_lowerAngle) < 2.0 * Settings.angularSlop) {\n this.m_limitState = LimitState.equalLimits;\n\n } else if (jointAngle <= this.m_lowerAngle) {\n if (this.m_limitState != LimitState.atLowerLimit) {\n this.m_impulse.z = 0.0;\n }\n this.m_limitState = LimitState.atLowerLimit;\n\n } else if (jointAngle >= this.m_upperAngle) {\n if (this.m_limitState != LimitState.atUpperLimit) {\n this.m_impulse.z = 0.0;\n }\n this.m_limitState = LimitState.atUpperLimit;\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_impulse.mul(step.dtRatio);\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_impulse.x, this.m_impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_motorImpulse + this.m_impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_motorImpulse + this.m_impulse.z);\n\n } else {\n this.m_impulse.setZero();\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const fixedRotation = (iA + iB === 0.0);\n\n // Solve motor constraint.\n if (this.m_enableMotor && this.m_limitState != LimitState.equalLimits && fixedRotation == false) {\n const Cdot = wB - wA - this.m_motorSpeed;\n let impulse = -this.m_motorMass * Cdot;\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorTorque;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve limit constraint.\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit && fixedRotation == false) {\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const Cdot2 = wB - wA;\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const impulse = Vec3.neg(this.m_mass.solve33(Cdot));\n\n if (this.m_limitState == LimitState.equalLimits) {\n this.m_impulse.add(impulse);\n\n } else if (this.m_limitState == LimitState.atLowerLimit) {\n const newImpulse = this.m_impulse.z + impulse.z;\n\n if (newImpulse < 0.0) {\n const rhs = Vec2.combine(-1, Cdot1, this.m_impulse.z, Vec2.neo(this.m_mass.ez.x, this.m_mass.ez.y));\n const reduced = this.m_mass.solve22(rhs);\n impulse.x = reduced.x;\n impulse.y = reduced.y;\n impulse.z = -this.m_impulse.z;\n this.m_impulse.x += reduced.x;\n this.m_impulse.y += reduced.y;\n this.m_impulse.z = 0.0;\n\n } else {\n this.m_impulse.add(impulse);\n }\n\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n const newImpulse = this.m_impulse.z + impulse.z;\n\n if (newImpulse > 0.0) {\n const rhs = Vec2.combine(-1, Cdot1, this.m_impulse.z, Vec2.neo(this.m_mass.ez.x, this.m_mass.ez.y));\n const reduced = this.m_mass.solve22(rhs);\n impulse.x = reduced.x;\n impulse.y = reduced.y;\n impulse.z = -this.m_impulse.z;\n this.m_impulse.x += reduced.x;\n this.m_impulse.y += reduced.y;\n this.m_impulse.z = 0.0;\n\n } else {\n this.m_impulse.add(impulse);\n }\n }\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + impulse.z);\n\n } else {\n // Solve point-to-point constraint\n const Cdot = Vec2.zero();\n Cdot.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const impulse = this.m_mass.solve22(Vec2.neg(Cdot));\n\n this.m_impulse.x += impulse.x;\n this.m_impulse.y += impulse.y;\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n let angularError = 0.0;\n let positionError = 0.0;\n\n const fixedRotation = (this.m_invIA + this.m_invIB == 0.0);\n\n // Solve angular limit constraint.\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit && fixedRotation == false) {\n const angle = aB - aA - this.m_referenceAngle;\n let limitImpulse = 0.0;\n\n if (this.m_limitState == LimitState.equalLimits) {\n // Prevent large angular corrections\n const C = clamp(angle - this.m_lowerAngle, -Settings.maxAngularCorrection, Settings.maxAngularCorrection);\n limitImpulse = -this.m_motorMass * C;\n angularError = math_abs(C);\n\n } else if (this.m_limitState == LimitState.atLowerLimit) {\n let C = angle - this.m_lowerAngle;\n angularError = -C;\n\n // Prevent large angular corrections and allow some slop.\n C = clamp(C + Settings.angularSlop, -Settings.maxAngularCorrection, 0.0);\n limitImpulse = -this.m_motorMass * C;\n\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n let C = angle - this.m_upperAngle;\n angularError = C;\n\n // Prevent large angular corrections and allow some slop.\n C = clamp(C - Settings.angularSlop, 0.0, Settings.maxAngularCorrection);\n limitImpulse = -this.m_motorMass * C;\n }\n\n aA -= this.m_invIA * limitImpulse;\n aB += this.m_invIB * limitImpulse;\n }\n\n // Solve point-to-point constraint.\n {\n qA.setAngle(aA);\n qB.setAngle(aB);\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n const C = Vec2.zero();\n C.addCombine(1, cB, 1, rB);\n C.subCombine(1, cA, 1, rA);\n positionError = C.length();\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat22();\n K.ex.x = mA + mB + iA * rA.y * rA.y + iB * rB.y * rB.y;\n K.ex.y = -iA * rA.x * rA.y - iB * rB.x * rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * rA.x * rA.x + iB * rB.x * rB.x;\n\n const impulse = Vec2.neg(K.solve(C));\n\n cA.subMul(mA, impulse);\n aA -= iA * Vec2.crossVec2Vec2(rA, impulse);\n\n cB.addMul(mB, impulse);\n aB += iB * Vec2.crossVec2Vec2(rB, impulse);\n }\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return positionError <= Settings.linearSlop && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3, \n}\n\n/**\n * Prismatic joint definition. This requires defining a line of motion using an\n * axis and an anchor point. The definition uses local anchor points and a local\n * axis so that the initial configuration can violate the constraint slightly.\n * The joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface PrismaticJointOpt extends JointOpt {\n /**\n * Enable/disable the joint limit.\n */\n enableLimit?: boolean;\n /**\n * The lower translation limit, usually in meters.\n */\n lowerTranslation?: number;\n /**\n * The upper translation limit, usually in meters.\n */\n upperTranslation?: number;\n /**\n * Enable/disable the joint motor.\n */\n enableMotor?: boolean;\n /**\n * The maximum motor torque, usually in N-m.\n */\n maxMotorForce?: number;\n /**\n * The desired motor speed in radians per second.\n */\n motorSpeed?: number;\n}\n\n/**\n * Prismatic joint definition. This requires defining a line of motion using an\n * axis and an anchor point. The definition uses local anchor points and a local\n * axis so that the initial configuration can violate the constraint slightly.\n * The joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface PrismaticJointDef extends JointDef, PrismaticJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The local translation unit axis in bodyA.\n */\n localAxisA: Vec2Value;\n /**\n * referenceAngle The constrained angle between the bodies:\n * bodyB_angle - bodyA_angle.\n */\n referenceAngle?: number;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n enableLimit : false,\n lowerTranslation : 0.0,\n upperTranslation : 0.0,\n enableMotor : false,\n maxMotorForce : 0.0,\n motorSpeed : 0.0\n};\n\ndeclare module \"./PrismaticJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PrismaticJoint(def: PrismaticJointDef): PrismaticJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PrismaticJoint(def: PrismaticJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value, axis: Vec2Value): PrismaticJoint;\n}\n\n/**\n * A prismatic joint. This joint provides one degree of freedom: translation\n * along an axis fixed in bodyA. Relative rotation is prevented. You can use a\n * joint limit to restrict the range of motion and a joint motor to drive the\n * motion or to model joint friction.\n */\n// @ts-expect-error\nexport class PrismaticJoint extends Joint {\n static TYPE = \"prismatic-joint\" as const;\n\n /** @internal */ m_type: \"prismatic-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_localXAxisA: Vec2;\n /** @internal */ m_localYAxisA: Vec2;\n /** @internal */ m_referenceAngle: number;\n /** @internal */ m_impulse: Vec3;\n /** @internal */ m_motorMass: number;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_lowerTranslation: number;\n /** @internal */ m_upperTranslation: number;\n /** @internal */ m_maxMotorForce: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableLimit: boolean;\n /** @internal */ m_enableMotor: boolean;\n /** @internal */ m_limitState: number; // TODO enum\n /** @internal */ m_axis: Vec2;\n /** @internal */ m_perp: Vec2;\n // Solver temp\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_s1: number;\n /** @internal */ m_s2: number;\n /** @internal */ m_a1: number;\n /** @internal */ m_a2: number;\n /** @internal */ m_K: Mat33;\n\n constructor(def: PrismaticJointDef);\n constructor(def: PrismaticJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value, axis?: Vec2Value);\n constructor(def: PrismaticJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value, axis?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PrismaticJoint)) {\n return new PrismaticJoint(def, bodyA, bodyB, anchor, axis);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = PrismaticJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n this.m_localXAxisA = Vec2.clone(axis ? bodyA.getLocalVector(axis) : def.localAxisA || Vec2.neo(1.0, 0.0));\n this.m_localXAxisA.normalize();\n this.m_localYAxisA = Vec2.crossNumVec2(1.0, this.m_localXAxisA);\n this.m_referenceAngle = Number.isFinite(def.referenceAngle) ? def.referenceAngle : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_impulse = new Vec3();\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n\n this.m_lowerTranslation = def.lowerTranslation;\n this.m_upperTranslation = def.upperTranslation;\n this.m_maxMotorForce = def.maxMotorForce;\n this.m_motorSpeed = def.motorSpeed;\n this.m_enableLimit = def.enableLimit;\n this.m_enableMotor = def.enableMotor;\n this.m_limitState = LimitState.inactiveLimit;\n\n this.m_axis = Vec2.zero();\n this.m_perp = Vec2.zero();\n\n this.m_K = new Mat33();\n\n // Linear constraint (point-to-line)\n // d = p2 - p1 = x2 + r2 - x1 - r1\n // C = dot(perp, d)\n // Cdot = dot(d, cross(w1, perp)) + dot(perp, v2 + cross(w2, r2) - v1 -\n // cross(w1, r1))\n // = -dot(perp, v1) - dot(cross(d + r1, perp), w1) + dot(perp, v2) +\n // dot(cross(r2, perp), v2)\n // J = [-perp, -cross(d + r1, perp), perp, cross(r2,perp)]\n //\n // Angular constraint\n // C = a2 - a1 + a_initial\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n //\n // K = J * invM * JT\n //\n // J = [-a -s1 a s2]\n // [0 -1 0 1]\n // a = perp\n // s1 = cross(d + r1, a) = cross(p2 - x1, a)\n // s2 = cross(r2, a) = cross(p2 - x2, a)\n\n // Motor/Limit linear constraint\n // C = dot(ax1, d)\n // Cdot = = -dot(ax1, v1) - dot(cross(d + r1, ax1), w1) + dot(ax1, v2) +\n // dot(cross(r2, ax1), v2)\n // J = [-ax1 -cross(d+r1,ax1) ax1 cross(r2,ax1)]\n\n // Block Solver\n // We develop a block solver that includes the joint limit. This makes the\n // limit stiff (inelastic) even\n // when the mass has poor distribution (leading to large torques about the\n // joint anchor points).\n //\n // The Jacobian has 3 rows:\n // J = [-uT -s1 uT s2] // linear\n // [0 -1 0 1] // angular\n // [-vT -a1 vT a2] // limit\n //\n // u = perp\n // v = axis\n // s1 = cross(d + r1, u), s2 = cross(r2, u)\n // a1 = cross(d + r1, v), a2 = cross(r2, v)\n\n // M * (v2 - v1) = JT * df\n // J * v2 = bias\n //\n // v2 = v1 + invM * JT * df\n // J * (v1 + invM * JT * df) = bias\n // K * df = bias - J * v1 = -Cdot\n // K = J * invM * JT\n // Cdot = J * v1 - bias\n //\n // Now solve for f2.\n // df = f2 - f1\n // K * (f2 - f1) = -Cdot\n // f2 = invK * (-Cdot) + f1\n //\n // Clamp accumulated limit impulse.\n // lower: f2(3) = max(f2(3), 0)\n // upper: f2(3) = min(f2(3), 0)\n //\n // Solve for correct f2(1:2)\n // K(1:2, 1:2) * f2(1:2) = -Cdot(1:2) - K(1:2,3) * f2(3) + K(1:2,1:3) * f1\n // = -Cdot(1:2) - K(1:2,3) * f2(3) + K(1:2,1:2) * f1(1:2) + K(1:2,3) * f1(3)\n // K(1:2, 1:2) * f2(1:2) = -Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3)) +\n // K(1:2,1:2) * f1(1:2)\n // f2(1:2) = invK(1:2,1:2) * (-Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3))) +\n // f1(1:2)\n //\n // Now compute impulse to be applied:\n // df = f2 - f1\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n lowerTranslation: this.m_lowerTranslation,\n upperTranslation: this.m_upperTranslation,\n maxMotorForce: this.m_maxMotorForce,\n motorSpeed: this.m_motorSpeed,\n enableLimit: this.m_enableLimit,\n enableMotor: this.m_enableMotor,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n localAxisA: this.m_localXAxisA,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): PrismaticJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.localAxisA = Vec2.clone(data.localAxisA);\n const joint = new PrismaticJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (def.localAxisA) {\n this.m_localXAxisA.setVec2(def.localAxisA);\n this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1.0, def.localAxisA));\n }\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n }\n if (typeof def.enableLimit !== \"undefined\") {\n this.m_enableLimit = !!def.enableLimit;\n }\n if (Number.isFinite(def.lowerTranslation)) {\n this.m_lowerTranslation = def.lowerTranslation;\n }\n if (Number.isFinite(def.upperTranslation)) {\n this.m_upperTranslation = def.upperTranslation;\n }\n if (typeof def.enableMotor !== \"undefined\") {\n this.m_enableMotor = !!def.enableMotor;\n }\n if (Number.isFinite(def.maxMotorForce)) {\n this.m_maxMotorForce = def.maxMotorForce;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * The local joint axis relative to bodyA.\n */\n getLocalAxisA(): Vec2 {\n return this.m_localXAxisA;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Get the current joint translation, usually in meters.\n */\n getJointTranslation(): number {\n const pA = this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n const pB = this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n const d = Vec2.sub(pB, pA);\n const axis = this.m_bodyA.getWorldVector(this.m_localXAxisA);\n\n const translation = Vec2.dot(d, axis);\n return translation;\n }\n\n /**\n * Get the current joint translation speed, usually in meters per second.\n */\n getJointSpeed(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n\n const rA = Rot.mulVec2(bA.m_xf.q, Vec2.sub(this.m_localAnchorA, bA.m_sweep.localCenter));\n const rB = Rot.mulVec2(bB.m_xf.q, Vec2.sub(this.m_localAnchorB, bB.m_sweep.localCenter));\n const p1 = Vec2.add(bA.m_sweep.c, rA);\n const p2 = Vec2.add(bB.m_sweep.c, rB);\n const d = Vec2.sub(p2, p1);\n const axis = Rot.mulVec2(bA.m_xf.q, this.m_localXAxisA);\n\n const vA = bA.m_linearVelocity;\n const vB = bB.m_linearVelocity;\n const wA = bA.m_angularVelocity;\n const wB = bB.m_angularVelocity;\n\n const speed = Vec2.dot(d, Vec2.crossNumVec2(wA, axis)) + Vec2.dot(axis, Vec2.sub(Vec2.addCrossNumVec2(vB, wB, rB), Vec2.addCrossNumVec2(vA, wA, rA)));\n return speed;\n }\n\n /**\n * Is the joint limit enabled?\n */\n isLimitEnabled(): boolean {\n return this.m_enableLimit;\n }\n\n /**\n * Enable/disable the joint limit.\n */\n enableLimit(flag: boolean): void {\n if (flag != this.m_enableLimit) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableLimit = flag;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Get the lower joint limit, usually in meters.\n */\n getLowerLimit(): number {\n return this.m_lowerTranslation;\n }\n\n /**\n * Get the upper joint limit, usually in meters.\n */\n getUpperLimit(): number {\n return this.m_upperTranslation;\n }\n\n /**\n * Set the joint limits, usually in meters.\n */\n setLimits(lower: number, upper: number): void {\n if (_ASSERT) console.assert(lower <= upper);\n if (lower != this.m_lowerTranslation || upper != this.m_upperTranslation) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_lowerTranslation = lower;\n this.m_upperTranslation = upper;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Set the motor speed, usually in meters per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Set the maximum motor force, usually in N.\n */\n setMaxMotorForce(force: number): void {\n if (force == this.m_maxMotorForce) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorForce = force;\n }\n\n getMaxMotorForce(): number {\n return this.m_maxMotorForce;\n }\n\n /**\n * Get the motor speed, usually in meters per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Get the current motor force given the inverse time step, usually in N.\n */\n getMotorForce(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.combine(this.m_impulse.x, this.m_perp, this.m_motorImpulse + this.m_impulse.z, this.m_axis).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.y;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective masses.\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Compute motor Jacobian and effective mass.\n {\n this.m_axis = Rot.mulVec2(qA, this.m_localXAxisA);\n this.m_a1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_axis);\n this.m_a2 = Vec2.crossVec2Vec2(rB, this.m_axis);\n\n this.m_motorMass = mA + mB + iA * this.m_a1 * this.m_a1 + iB * this.m_a2\n * this.m_a2;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n }\n\n // Prismatic constraint.\n {\n this.m_perp = Rot.mulVec2(qA, this.m_localYAxisA);\n\n this.m_s1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_perp);\n this.m_s2 = Vec2.crossVec2Vec2(rB, this.m_perp);\n\n const s1test = Vec2.crossVec2Vec2(rA, this.m_perp);\n\n const k11 = mA + mB + iA * this.m_s1 * this.m_s1 + iB * this.m_s2 * this.m_s2;\n const k12 = iA * this.m_s1 + iB * this.m_s2;\n const k13 = iA * this.m_s1 * this.m_a1 + iB * this.m_s2 * this.m_a2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n // For bodies with fixed rotation.\n k22 = 1.0;\n }\n const k23 = iA * this.m_a1 + iB * this.m_a2;\n const k33 = mA + mB + iA * this.m_a1 * this.m_a1 + iB * this.m_a2 * this.m_a2;\n\n this.m_K.ex.set(k11, k12, k13);\n this.m_K.ey.set(k12, k22, k23);\n this.m_K.ez.set(k13, k23, k33);\n }\n\n // Compute motor and limit terms.\n if (this.m_enableLimit) {\n\n const jointTranslation = Vec2.dot(this.m_axis, d);\n if (math_abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * Settings.linearSlop) {\n this.m_limitState = LimitState.equalLimits;\n\n } else if (jointTranslation <= this.m_lowerTranslation) {\n if (this.m_limitState != LimitState.atLowerLimit) {\n this.m_limitState = LimitState.atLowerLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else if (jointTranslation >= this.m_upperTranslation) {\n if (this.m_limitState != LimitState.atUpperLimit) {\n this.m_limitState = LimitState.atUpperLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n if (this.m_enableMotor == false) {\n this.m_motorImpulse = 0.0;\n }\n\n if (step.warmStarting) {\n // Account for variable time step.\n this.m_impulse.mul(step.dtRatio);\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.combine(this.m_impulse.x, this.m_perp, this.m_motorImpulse\n + this.m_impulse.z, this.m_axis);\n const LA = this.m_impulse.x * this.m_s1 + this.m_impulse.y\n + (this.m_motorImpulse + this.m_impulse.z) * this.m_a1;\n const LB = this.m_impulse.x * this.m_s2 + this.m_impulse.y\n + (this.m_motorImpulse + this.m_impulse.z) * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n } else {\n this.m_impulse.setZero();\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Solve linear motor constraint.\n if (this.m_enableMotor && this.m_limitState != LimitState.equalLimits) {\n const Cdot = Vec2.dot(this.m_axis, Vec2.sub(vB, vA)) + this.m_a2 * wB\n - this.m_a1 * wA;\n let impulse = this.m_motorMass * (this.m_motorSpeed - Cdot);\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorForce;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse,\n -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_axis);\n const LA = impulse * this.m_a1;\n const LB = impulse * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n const Cdot1 = Vec2.zero();\n Cdot1.x += Vec2.dot(this.m_perp, vB) + this.m_s2 * wB;\n Cdot1.x -= Vec2.dot(this.m_perp, vA) + this.m_s1 * wA;\n Cdot1.y = wB - wA;\n\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit) {\n // Solve prismatic and limit constraint in block form.\n let Cdot2 = 0;\n Cdot2 += Vec2.dot(this.m_axis, vB) + this.m_a2 * wB;\n Cdot2 -= Vec2.dot(this.m_axis, vA) + this.m_a1 * wA;\n\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const f1 = Vec3.clone(this.m_impulse);\n let df = this.m_K.solve33(Vec3.neg(Cdot));\n this.m_impulse.add(df);\n\n if (this.m_limitState == LimitState.atLowerLimit) {\n this.m_impulse.z = math_max(this.m_impulse.z, 0.0);\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n this.m_impulse.z = math_min(this.m_impulse.z, 0.0);\n }\n\n // f2(1:2) = invK(1:2,1:2) * (-Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3))) +\n // f1(1:2)\n const b = Vec2.combine(-1, Cdot1, -(this.m_impulse.z - f1.z), Vec2.neo(this.m_K.ez.x, this.m_K.ez.y));\n const f2r = Vec2.add(this.m_K.solve22(b), Vec2.neo(f1.x, f1.y));\n this.m_impulse.x = f2r.x;\n this.m_impulse.y = f2r.y;\n\n df = Vec3.sub(this.m_impulse, f1);\n\n const P = Vec2.combine(df.x, this.m_perp, df.z, this.m_axis);\n const LA = df.x * this.m_s1 + df.y + df.z * this.m_a1;\n const LB = df.x * this.m_s2 + df.y + df.z * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n } else {\n // Limit is inactive, just solve the prismatic constraint in block form.\n const df = this.m_K.solve22(Vec2.neg(Cdot1));\n this.m_impulse.x += df.x;\n this.m_impulse.y += df.y;\n\n const P = Vec2.mulNumVec2(df.x, this.m_perp);\n const LA = df.x * this.m_s1 + df.y;\n const LB = df.x * this.m_s2 + df.y;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Compute fresh Jacobians\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.sub(Vec2.add(cB, rB), Vec2.add(cA, rA));\n\n const axis = Rot.mulVec2(qA, this.m_localXAxisA);\n const a1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), axis);\n const a2 = Vec2.crossVec2Vec2(rB, axis);\n const perp = Rot.mulVec2(qA, this.m_localYAxisA);\n\n const s1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), perp);\n const s2 = Vec2.crossVec2Vec2(rB, perp);\n\n let impulse = new Vec3();\n const C1 = Vec2.zero();\n C1.x = Vec2.dot(perp, d);\n C1.y = aB - aA - this.m_referenceAngle;\n\n let linearError = math_abs(C1.x);\n const angularError = math_abs(C1.y);\n\n const linearSlop = Settings.linearSlop;\n const maxLinearCorrection = Settings.maxLinearCorrection;\n\n let active = false; // bool\n let C2 = 0.0;\n if (this.m_enableLimit) {\n\n const translation = Vec2.dot(axis, d);\n if (math_abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * linearSlop) {\n // Prevent large angular corrections\n C2 = clamp(translation, -maxLinearCorrection, maxLinearCorrection);\n linearError = math_max(linearError, math_abs(translation));\n active = true;\n\n } else if (translation <= this.m_lowerTranslation) {\n // Prevent large linear corrections and allow some slop.\n C2 = clamp(translation - this.m_lowerTranslation + linearSlop,\n -maxLinearCorrection, 0.0);\n linearError = Math\n .max(linearError, this.m_lowerTranslation - translation);\n active = true;\n\n } else if (translation >= this.m_upperTranslation) {\n // Prevent large linear corrections and allow some slop.\n C2 = clamp(translation - this.m_upperTranslation - linearSlop, 0.0,\n maxLinearCorrection);\n linearError = Math\n .max(linearError, translation - this.m_upperTranslation);\n active = true;\n }\n }\n\n if (active) {\n const k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2;\n const k12 = iA * s1 + iB * s2;\n const k13 = iA * s1 * a1 + iB * s2 * a2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n // For fixed rotation\n k22 = 1.0;\n }\n const k23 = iA * a1 + iB * a2;\n const k33 = mA + mB + iA * a1 * a1 + iB * a2 * a2;\n\n const K = new Mat33();\n K.ex.set(k11, k12, k13);\n K.ey.set(k12, k22, k23);\n K.ez.set(k13, k23, k33);\n\n const C = new Vec3();\n C.x = C1.x;\n C.y = C1.y;\n C.z = C2;\n\n impulse = K.solve33(Vec3.neg(C));\n } else {\n const k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2;\n const k12 = iA * s1 + iB * s2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n k22 = 1.0;\n }\n\n const K = new Mat22();\n K.ex.setNum(k11, k12);\n K.ey.setNum(k12, k22);\n\n const impulse1 = K.solve(Vec2.neg(C1));\n impulse.x = impulse1.x;\n impulse.y = impulse1.y;\n impulse.z = 0.0;\n }\n\n const P = Vec2.combine(impulse.x, perp, impulse.z, axis);\n const LA = impulse.x * s1 + impulse.y + impulse.z * a1;\n const LB = impulse.x * s2 + impulse.y + impulse.z * a2;\n\n cA.subMul(mA, P);\n aA -= iA * LA;\n cB.addMul(mB, P);\n aB += iB * LB;\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return linearError <= Settings.linearSlop\n && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { } from \"../../common/Math\";\nimport { Vec2 } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { RevoluteJoint } from \"./RevoluteJoint\";\nimport { PrismaticJoint } from \"./PrismaticJoint\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Gear joint definition.\n */\nexport interface GearJointOpt extends JointOpt {\n /**\n * The gear ratio. See {@link GearJoint} for explanation.\n */\n ratio?: number;\n}\n\n/**\n * Gear joint definition.\n */\nexport interface GearJointDef extends JointDef, GearJointOpt {\n /**\n * The first revolute/prismatic joint attached to the gear joint.\n */\n joint1: RevoluteJoint | PrismaticJoint;\n /**\n * The second prismatic/revolute joint attached to the gear joint.\n */\n joint2: RevoluteJoint | PrismaticJoint;\n}\n\n/** @internal */ const DEFAULTS = {\n ratio : 1.0\n};\n\ndeclare module \"./GearJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function GearJoint(def: GearJointDef): GearJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function GearJoint(def: GearJointOpt, bodyA: Body, bodyB: Body, joint1: RevoluteJoint | PrismaticJoint, joint2: RevoluteJoint | PrismaticJoint, ratio?: number): GearJoint;\n}\n\n/**\n * A gear joint is used to connect two joints together. Either joint can be a\n * revolute or prismatic joint. You specify a gear ratio to bind the motions\n * together: coordinate1 + ratio * coordinate2 = constant\n *\n * The ratio can be negative or positive. If one joint is a revolute joint and\n * the other joint is a prismatic joint, then the ratio will have units of\n * length or units of 1/length. Warning: You have to manually destroy the gear\n * joint if joint1 or joint2 is destroyed.\n *\n * This definition requires two existing revolute or prismatic joints (any\n * combination will work).\n */\n// @ts-expect-error\nexport class GearJoint extends Joint {\n static TYPE = \"gear-joint\" as const;\n\n /** @internal */ m_type: \"gear-joint\";\n /** @internal */ m_joint1: RevoluteJoint | PrismaticJoint;\n /** @internal */ m_joint2: RevoluteJoint | PrismaticJoint;\n /** @internal */ m_type1: \"revolute-joint\" | \"prismatic-joint\";\n /** @internal */ m_type2: \"revolute-joint\" | \"prismatic-joint\";\n /** @internal */ m_bodyC: Body;\n /** @internal */ m_localAnchorC: Vec2;\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_referenceAngleA: number;\n /** @internal */ m_localAxisC: Vec2;\n /** @internal */ m_bodyD: Body;\n /** @internal */ m_localAnchorD: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngleB: number;\n /** @internal */ m_localAxisD: Vec2;\n /** @internal */ m_ratio: number;\n /** @internal */ m_constant: number;\n /** @internal */ m_impulse: number;\n\n // Solver temp\n /** @internal */ m_lcA: Vec2;\n /** @internal */ m_lcB: Vec2;\n /** @internal */ m_lcC: Vec2;\n /** @internal */ m_lcD: Vec2;\n /** @internal */ m_mA: number;\n /** @internal */ m_mB: number;\n /** @internal */ m_mC: number;\n /** @internal */ m_mD: number;\n /** @internal */ m_iA: number;\n /** @internal */ m_iB: number;\n /** @internal */ m_iC: number;\n /** @internal */ m_iD: number;\n /** @internal */ m_JvAC: Vec2;\n /** @internal */ m_JvBD: Vec2;\n /** @internal */ m_JwA: number;\n /** @internal */ m_JwB: number;\n /** @internal */ m_JwC: number;\n /** @internal */ m_JwD: number;\n /** @internal */ m_mass: number;\n\n constructor(def: GearJointDef);\n constructor(def: GearJointOpt, bodyA: Body, bodyB: Body, joint1: RevoluteJoint | PrismaticJoint, joint2: RevoluteJoint | PrismaticJoint, ratio?: number);\n constructor(def: GearJointDef, bodyA?: Body, bodyB?: Body, joint1?: RevoluteJoint | PrismaticJoint, joint2?: RevoluteJoint | PrismaticJoint, ratio?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof GearJoint)) {\n return new GearJoint(def, bodyA, bodyB, joint1, joint2, ratio);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = GearJoint.TYPE;\n\n if (_ASSERT) console.assert(joint1.m_type === RevoluteJoint.TYPE || joint1.m_type === PrismaticJoint.TYPE);\n if (_ASSERT) console.assert(joint2.m_type === RevoluteJoint.TYPE || joint2.m_type === PrismaticJoint.TYPE);\n\n this.m_joint1 = joint1 ? joint1 : def.joint1;\n this.m_joint2 = joint2 ? joint2 : def.joint2;\n this.m_ratio = Number.isFinite(ratio) ? ratio : def.ratio;\n\n this.m_type1 = this.m_joint1.getType() as \"revolute-joint\" | \"prismatic-joint\";\n this.m_type2 = this.m_joint2.getType() as \"revolute-joint\" | \"prismatic-joint\";\n\n // joint1 connects body A to body C\n // joint2 connects body B to body D\n\n let coordinateA: number;\n let coordinateB: number;\n\n // TODO_ERIN there might be some problem with the joint edges in Joint.\n\n this.m_bodyC = this.m_joint1.getBodyA();\n this.m_bodyA = this.m_joint1.getBodyB();\n\n // Get geometry of joint1\n const xfA = this.m_bodyA.m_xf;\n const aA = this.m_bodyA.m_sweep.a;\n const xfC = this.m_bodyC.m_xf;\n const aC = this.m_bodyC.m_sweep.a;\n\n if (this.m_type1 === RevoluteJoint.TYPE) {\n const revolute = this.m_joint1 as RevoluteJoint;\n this.m_localAnchorC = revolute.m_localAnchorA;\n this.m_localAnchorA = revolute.m_localAnchorB;\n this.m_referenceAngleA = revolute.m_referenceAngle;\n this.m_localAxisC = Vec2.zero();\n\n coordinateA = aA - aC - this.m_referenceAngleA;\n } else {\n const prismatic = this.m_joint1 as PrismaticJoint;\n this.m_localAnchorC = prismatic.m_localAnchorA;\n this.m_localAnchorA = prismatic.m_localAnchorB;\n this.m_referenceAngleA = prismatic.m_referenceAngle;\n this.m_localAxisC = prismatic.m_localXAxisA;\n\n const pC = this.m_localAnchorC;\n const pA = Rot.mulTVec2(xfC.q, Vec2.add(Rot.mulVec2(xfA.q, this.m_localAnchorA), Vec2.sub(xfA.p, xfC.p)));\n coordinateA = Vec2.dot(pA, this.m_localAxisC) - Vec2.dot(pC, this.m_localAxisC);\n }\n\n this.m_bodyD = this.m_joint2.getBodyA();\n this.m_bodyB = this.m_joint2.getBodyB();\n\n // Get geometry of joint2\n const xfB = this.m_bodyB.m_xf;\n const aB = this.m_bodyB.m_sweep.a;\n const xfD = this.m_bodyD.m_xf;\n const aD = this.m_bodyD.m_sweep.a;\n\n if (this.m_type2 === RevoluteJoint.TYPE) {\n const revolute = this.m_joint2 as RevoluteJoint;\n this.m_localAnchorD = revolute.m_localAnchorA;\n this.m_localAnchorB = revolute.m_localAnchorB;\n this.m_referenceAngleB = revolute.m_referenceAngle;\n this.m_localAxisD = Vec2.zero();\n\n coordinateB = aB - aD - this.m_referenceAngleB;\n } else {\n const prismatic = this.m_joint2 as PrismaticJoint;\n this.m_localAnchorD = prismatic.m_localAnchorA;\n this.m_localAnchorB = prismatic.m_localAnchorB;\n this.m_referenceAngleB = prismatic.m_referenceAngle;\n this.m_localAxisD = prismatic.m_localXAxisA;\n\n const pD = this.m_localAnchorD;\n const pB = Rot.mulTVec2(xfD.q, Vec2.add(Rot.mulVec2(xfB.q, this.m_localAnchorB), Vec2.sub(xfB.p, xfD.p)));\n coordinateB = Vec2.dot(pB, this.m_localAxisD) - Vec2.dot(pD, this.m_localAxisD);\n }\n\n this.m_constant = coordinateA + this.m_ratio * coordinateB;\n\n this.m_impulse = 0.0;\n\n // Gear Joint:\n // C0 = (coordinate1 + ratio * coordinate2)_initial\n // C = (coordinate1 + ratio * coordinate2) - C0 = 0\n // J = [J1 ratio * J2]\n // K = J * invM * JT\n // = J1 * invM1 * J1T + ratio * ratio * J2 * invM2 * J2T\n //\n // Revolute:\n // coordinate = rotation\n // Cdot = angularVelocity\n // J = [0 0 1]\n // K = J * invM * JT = invI\n //\n // Prismatic:\n // coordinate = dot(p - pg, ug)\n // Cdot = dot(v + cross(w, r), ug)\n // J = [ug cross(r, ug)]\n // K = J * invM * JT = invMass + invI * cross(r, ug)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n joint1: this.m_joint1,\n joint2: this.m_joint2,\n ratio: this.m_ratio,\n\n // _constant: this.m_constant,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): GearJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.joint1 = restore(Joint, data.joint1, world);\n data.joint2 = restore(Joint, data.joint2, world);\n const joint = new GearJoint(data);\n // if (data._constant) joint.m_constant = data._constant;\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n // todo: implement other fields\n if (Number.isFinite(def.ratio)) {\n this.m_ratio = def.ratio;\n }\n }\n\n /**\n * Get the first joint.\n */\n getJoint1(): Joint {\n return this.m_joint1;\n }\n\n /**\n * Get the second joint.\n */\n getJoint2(): Joint {\n return this.m_joint2;\n }\n\n /**\n * Set the gear ratio.\n */\n setRatio(ratio: number): void {\n if (_ASSERT) console.assert(Number.isFinite(ratio));\n this.m_ratio = ratio;\n }\n\n /**\n * Get the gear ratio.\n */\n getRatio(): number {\n return this.m_ratio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_JvAC).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n const L = this.m_impulse * this.m_JwA;\n return inv_dt * L;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_lcA = this.m_bodyA.m_sweep.localCenter;\n this.m_lcB = this.m_bodyB.m_sweep.localCenter;\n this.m_lcC = this.m_bodyC.m_sweep.localCenter;\n this.m_lcD = this.m_bodyD.m_sweep.localCenter;\n this.m_mA = this.m_bodyA.m_invMass;\n this.m_mB = this.m_bodyB.m_invMass;\n this.m_mC = this.m_bodyC.m_invMass;\n this.m_mD = this.m_bodyD.m_invMass;\n this.m_iA = this.m_bodyA.m_invI;\n this.m_iB = this.m_bodyB.m_invI;\n this.m_iC = this.m_bodyC.m_invI;\n this.m_iD = this.m_bodyD.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const aC = this.m_bodyC.c_position.a;\n const vC = this.m_bodyC.c_velocity.v;\n let wC = this.m_bodyC.c_velocity.w;\n\n const aD = this.m_bodyD.c_position.a;\n const vD = this.m_bodyD.c_velocity.v;\n let wD = this.m_bodyD.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n const qC = Rot.neo(aC);\n const qD = Rot.neo(aD);\n\n this.m_mass = 0.0;\n\n if (this.m_type1 == RevoluteJoint.TYPE) {\n this.m_JvAC = Vec2.zero();\n this.m_JwA = 1.0;\n this.m_JwC = 1.0;\n this.m_mass += this.m_iA + this.m_iC;\n } else {\n const u = Rot.mulVec2(qC, this.m_localAxisC);\n const rC = Rot.mulSub(qC, this.m_localAnchorC, this.m_lcC);\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_lcA);\n this.m_JvAC = u;\n this.m_JwC = Vec2.crossVec2Vec2(rC, u);\n this.m_JwA = Vec2.crossVec2Vec2(rA, u);\n this.m_mass += this.m_mC + this.m_mA + this.m_iC * this.m_JwC * this.m_JwC + this.m_iA * this.m_JwA * this.m_JwA;\n }\n\n if (this.m_type2 == RevoluteJoint.TYPE) {\n this.m_JvBD = Vec2.zero();\n this.m_JwB = this.m_ratio;\n this.m_JwD = this.m_ratio;\n this.m_mass += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD);\n } else {\n const u = Rot.mulVec2(qD, this.m_localAxisD);\n const rD = Rot.mulSub(qD, this.m_localAnchorD, this.m_lcD);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_lcB);\n this.m_JvBD = Vec2.mulNumVec2(this.m_ratio, u);\n this.m_JwD = this.m_ratio * Vec2.crossVec2Vec2(rD, u);\n this.m_JwB = this.m_ratio * Vec2.crossVec2Vec2(rB, u);\n this.m_mass += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * this.m_JwD * this.m_JwD + this.m_iB * this.m_JwB * this.m_JwB;\n }\n\n // Compute effective mass.\n this.m_mass = this.m_mass > 0.0 ? 1.0 / this.m_mass : 0.0;\n\n if (step.warmStarting) {\n vA.addMul(this.m_mA * this.m_impulse, this.m_JvAC);\n wA += this.m_iA * this.m_impulse * this.m_JwA;\n\n vB.addMul(this.m_mB * this.m_impulse, this.m_JvBD);\n wB += this.m_iB * this.m_impulse * this.m_JwB;\n\n vC.subMul(this.m_mC * this.m_impulse, this.m_JvAC);\n wC -= this.m_iC * this.m_impulse * this.m_JwC;\n\n vD.subMul(this.m_mD * this.m_impulse, this.m_JvBD);\n wD -= this.m_iD * this.m_impulse * this.m_JwD;\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n this.m_bodyC.c_velocity.v.setVec2(vC);\n this.m_bodyC.c_velocity.w = wC;\n this.m_bodyD.c_velocity.v.setVec2(vD);\n this.m_bodyD.c_velocity.w = wD;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n const vC = this.m_bodyC.c_velocity.v;\n let wC = this.m_bodyC.c_velocity.w;\n const vD = this.m_bodyD.c_velocity.v;\n let wD = this.m_bodyD.c_velocity.w;\n\n let Cdot = Vec2.dot(this.m_JvAC, vA) - Vec2.dot(this.m_JvAC, vC) + Vec2.dot(this.m_JvBD, vB) - Vec2.dot(this.m_JvBD, vD);\n Cdot += (this.m_JwA * wA - this.m_JwC * wC) + (this.m_JwB * wB - this.m_JwD * wD);\n\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n vA.addMul(this.m_mA * impulse, this.m_JvAC);\n wA += this.m_iA * impulse * this.m_JwA;\n vB.addMul(this.m_mB * impulse, this.m_JvBD);\n wB += this.m_iB * impulse * this.m_JwB;\n vC.subMul(this.m_mC * impulse, this.m_JvAC);\n wC -= this.m_iC * impulse * this.m_JwC;\n vD.subMul(this.m_mD * impulse, this.m_JvBD);\n wD -= this.m_iD * impulse * this.m_JwD;\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n this.m_bodyC.c_velocity.v.setVec2(vC);\n this.m_bodyC.c_velocity.w = wC;\n this.m_bodyD.c_velocity.v.setVec2(vD);\n this.m_bodyD.c_velocity.w = wD;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n const cC = this.m_bodyC.c_position.c;\n let aC = this.m_bodyC.c_position.a;\n const cD = this.m_bodyD.c_position.c;\n let aD = this.m_bodyD.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n const qC = Rot.neo(aC);\n const qD = Rot.neo(aD);\n\n const linearError = 0.0;\n\n let coordinateA: number;\n let coordinateB: number;\n\n let JvAC: Vec2;\n let JvBD: Vec2;\n let JwA: number;\n let JwB: number;\n let JwC: number;\n let JwD: number;\n let mass = 0.0;\n\n if (this.m_type1 == RevoluteJoint.TYPE) {\n JvAC = Vec2.zero();\n JwA = 1.0;\n JwC = 1.0;\n mass += this.m_iA + this.m_iC;\n\n coordinateA = aA - aC - this.m_referenceAngleA;\n } else {\n const u = Rot.mulVec2(qC, this.m_localAxisC);\n const rC = Rot.mulSub(qC, this.m_localAnchorC, this.m_lcC);\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_lcA);\n JvAC = u;\n JwC = Vec2.crossVec2Vec2(rC, u);\n JwA = Vec2.crossVec2Vec2(rA, u);\n mass += this.m_mC + this.m_mA + this.m_iC * JwC * JwC + this.m_iA * JwA * JwA;\n\n const pC = Vec2.sub(this.m_localAnchorC, this.m_lcC);\n const pA = Rot.mulTVec2(qC, Vec2.add(rA, Vec2.sub(cA, cC)));\n coordinateA = Vec2.dot(Vec2.sub(pA, pC), this.m_localAxisC);\n }\n\n if (this.m_type2 == RevoluteJoint.TYPE) {\n JvBD = Vec2.zero();\n JwB = this.m_ratio;\n JwD = this.m_ratio;\n mass += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD);\n\n coordinateB = aB - aD - this.m_referenceAngleB;\n } else {\n const u = Rot.mulVec2(qD, this.m_localAxisD);\n const rD = Rot.mulSub(qD, this.m_localAnchorD, this.m_lcD);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_lcB);\n JvBD = Vec2.mulNumVec2(this.m_ratio, u);\n JwD = this.m_ratio * Vec2.crossVec2Vec2(rD, u);\n JwB = this.m_ratio * Vec2.crossVec2Vec2(rB, u);\n mass += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * JwD * JwD + this.m_iB * JwB * JwB;\n\n const pD = Vec2.sub(this.m_localAnchorD, this.m_lcD);\n const pB = Rot.mulTVec2(qD, Vec2.add(rB, Vec2.sub(cB, cD)));\n coordinateB = Vec2.dot(pB, this.m_localAxisD) - Vec2.dot(pD, this.m_localAxisD);\n }\n\n const C = (coordinateA + this.m_ratio * coordinateB) - this.m_constant;\n\n let impulse = 0.0;\n if (mass > 0.0) {\n impulse = -C / mass;\n }\n\n cA.addMul(this.m_mA * impulse, JvAC);\n aA += this.m_iA * impulse * JwA;\n cB.addMul(this.m_mB * impulse, JvBD);\n aB += this.m_iB * impulse * JwB;\n cC.subMul(this.m_mC * impulse, JvAC);\n aC -= this.m_iC * impulse * JwC;\n cD.subMul(this.m_mD * impulse, JvBD);\n aD -= this.m_iD * impulse * JwD;\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n this.m_bodyC.c_position.c.setVec2(cC);\n this.m_bodyC.c_position.a = aC;\n this.m_bodyD.c_position.c.setVec2(cD);\n this.m_bodyD.c_position.a = aD;\n\n // TODO_ERIN not implemented\n return linearError < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Motor joint definition.\n */\nexport interface MotorJointOpt extends JointOpt {\n /**\n * The bodyB angle minus bodyA angle in radians.\n */\n angularOffset?: number;\n /**\n * The maximum motor force in N.\n */\n maxForce?: number;\n /**\n * The maximum motor torque in N-m.\n */\n maxTorque?: number;\n /**\n * Position correction factor in the range [0,1].\n */\n correctionFactor?: number;\n /**\n * Position of bodyB minus the position of bodyA, in bodyA's frame, in meters.\n */\n linearOffset?: Vec2Value;\n}\n\n/**\n * Motor joint definition.\n */\nexport interface MotorJointDef extends JointDef, MotorJointOpt {\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 1.0,\n maxTorque : 1.0,\n correctionFactor : 0.3\n};\n\ndeclare module \"./MotorJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MotorJoint(def: MotorJointDef): MotorJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MotorJoint(def: MotorJointOpt, bodyA: Body, bodyB: Body): MotorJoint;\n}\n\n/**\n * A motor joint is used to control the relative motion between two bodies. A\n * typical usage is to control the movement of a dynamic body with respect to\n * the ground.\n */\n// @ts-expect-error\nexport class MotorJoint extends Joint {\n static TYPE = \"motor-joint\" as const;\n\n /** @internal */ m_type: \"motor-joint\";\n /** @internal */ m_linearOffset: Vec2;\n /** @internal */ m_angularOffset: number;\n /** @internal */ m_linearImpulse: Vec2;\n /** @internal */ m_angularImpulse: number;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_maxTorque: number;\n /** @internal */ m_correctionFactor: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_linearError: Vec2;\n /** @internal */ m_angularError: number;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_linearMass: Mat22;\n /** @internal */ m_angularMass: number;\n\n constructor(def: MotorJointDef);\n constructor(def: MotorJointOpt, bodyA: Body, bodyB: Body);\n constructor(def: MotorJointDef | MotorJointOpt, bodyA?: Body, bodyB?: Body) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof MotorJoint)) {\n return new MotorJoint(def, bodyA, bodyB);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = MotorJoint.TYPE;\n\n this.m_linearOffset = Vec2.isValid(def.linearOffset) ? Vec2.clone(def.linearOffset) : bodyA.getLocalPoint(bodyB.getPosition());\n this.m_angularOffset = Number.isFinite(def.angularOffset) ? def.angularOffset : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_linearImpulse = Vec2.zero();\n this.m_angularImpulse = 0.0;\n\n this.m_maxForce = def.maxForce;\n this.m_maxTorque = def.maxTorque;\n this.m_correctionFactor = def.correctionFactor;\n\n // Point-to-point constraint\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n //\n // r1 = offset - c1\n // r2 = -c2\n\n // Angle constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n maxForce: this.m_maxForce,\n maxTorque: this.m_maxTorque,\n correctionFactor: this.m_correctionFactor,\n\n linearOffset: this.m_linearOffset,\n angularOffset: this.m_angularOffset,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): MotorJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new MotorJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.angularOffset)) {\n this.m_angularOffset = def.angularOffset;\n }\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.maxTorque)) {\n this.m_maxTorque = def.maxTorque;\n }\n if (Number.isFinite(def.correctionFactor)) {\n this.m_correctionFactor = def.correctionFactor;\n }\n if (Vec2.isValid(def.linearOffset)) {\n this.m_linearOffset.set(def.linearOffset); \n }\n }\n\n /**\n * Set the maximum friction force in N.\n */\n setMaxForce(force: number): void {\n if (_ASSERT) console.assert(Number.isFinite(force) && force >= 0.0);\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum friction force in N.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the maximum friction torque in N*m.\n */\n setMaxTorque(torque: number): void {\n if (_ASSERT) console.assert(Number.isFinite(torque) && torque >= 0.0);\n this.m_maxTorque = torque;\n }\n\n /**\n * Get the maximum friction torque in N*m.\n */\n getMaxTorque(): number {\n return this.m_maxTorque;\n }\n\n /**\n * Set the position correction factor in the range [0,1].\n */\n setCorrectionFactor(factor: number): void {\n if (_ASSERT) console.assert(Number.isFinite(factor) && 0.0 <= factor && factor <= 1.0);\n this.m_correctionFactor = factor;\n }\n\n /**\n * Get the position correction factor in the range [0,1].\n */\n getCorrectionFactor(): number {\n return this.m_correctionFactor;\n }\n\n /**\n * Set/get the target linear offset, in frame A, in meters.\n */\n setLinearOffset(linearOffset: Vec2Value): void {\n if (linearOffset.x != this.m_linearOffset.x || linearOffset.y != this.m_linearOffset.y) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_linearOffset.set(linearOffset);\n }\n }\n\n getLinearOffset(): Vec2 {\n return this.m_linearOffset;\n }\n\n /**\n * Set/get the target angular offset, in radians.\n */\n setAngularOffset(angularOffset: number): void {\n if (angularOffset != this.m_angularOffset) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_angularOffset = angularOffset;\n }\n }\n\n getAngularOffset(): number {\n return this.m_angularOffset;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getPosition();\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getPosition();\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_linearImpulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_angularImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective mass matrix.\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_linearOffset, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.neg(this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Upper 2 by 2 of K for point to point\n const K = new Mat22();\n K.ex.x = mA + mB + iA * this.m_rA.y * this.m_rA.y + iB * this.m_rB.y * this.m_rB.y;\n K.ex.y = -iA * this.m_rA.x * this.m_rA.y - iB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * this.m_rA.x * this.m_rA.x + iB * this.m_rB.x * this.m_rB.x;\n\n this.m_linearMass = K.getInverse();\n\n this.m_angularMass = iA + iB;\n if (this.m_angularMass > 0.0) {\n this.m_angularMass = 1.0 / this.m_angularMass;\n }\n\n this.m_linearError = Vec2.zero();\n this.m_linearError.addCombine(1, cB, 1, this.m_rB);\n this.m_linearError.subCombine(1, cA, 1, this.m_rA);\n\n this.m_angularError = aB - aA - this.m_angularOffset;\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_linearImpulse.mul(step.dtRatio);\n this.m_angularImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_linearImpulse.x, this.m_linearImpulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_angularImpulse);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_angularImpulse);\n\n } else {\n this.m_linearImpulse.setZero();\n this.m_angularImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const h = step.dt;\n const inv_h = step.inv_dt;\n\n // Solve angular friction\n {\n const Cdot = wB - wA + inv_h * this.m_correctionFactor * this.m_angularError;\n let impulse = -this.m_angularMass * Cdot;\n\n const oldImpulse = this.m_angularImpulse;\n const maxImpulse = h * this.m_maxTorque;\n this.m_angularImpulse = clamp(this.m_angularImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_angularImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve linear friction\n {\n const Cdot = Vec2.zero();\n Cdot.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n Cdot.addMul(inv_h * this.m_correctionFactor, this.m_linearError);\n\n let impulse = Vec2.neg(Mat22.mulVec2(this.m_linearMass, Cdot));\n const oldImpulse = Vec2.clone(this.m_linearImpulse);\n this.m_linearImpulse.add(impulse);\n\n const maxImpulse = h * this.m_maxForce;\n\n this.m_linearImpulse.clamp(maxImpulse);\n\n impulse = Vec2.sub(this.m_linearImpulse, oldImpulse);\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Transform } from \"../../common/Transform\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Mouse joint definition. This requires a world target point, tuning\n * parameters, and the time step.\n */\nexport interface MouseJointOpt extends JointOpt {\n /**\n * [maxForce = 0.0] The maximum constraint force that can be exerted to move\n * the candidate body. Usually you will express as some multiple of the\n * weight (multiplier * mass * gravity).\n */\n maxForce?: number;\n /**\n * [frequencyHz = 5.0] The response speed.\n */\n frequencyHz?: number;\n /**\n * [dampingRatio = 0.7] The damping ratio. 0 = no damping, 1 = critical\n * damping.\n */\n dampingRatio?: number;\n}\n\n/**\n * Mouse joint definition. This requires a world target point, tuning\n * parameters, and the time step.\n */\nexport interface MouseJointDef extends JointDef, MouseJointOpt {\n /**\n * The initial world target point. This is assumed to coincide with the body\n * anchor initially.\n */\n target: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 0.0,\n frequencyHz : 5.0,\n dampingRatio : 0.7\n};\n\ndeclare module \"./MouseJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MouseJoint(def: MouseJointDef): MouseJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MouseJoint(def: MouseJointOpt, bodyA: Body, bodyB: Body, target: Vec2Value): MouseJoint;\n}\n\n/**\n * A mouse joint is used to make a point on a body track a specified world\n * point. This a soft constraint with a maximum force. This allows the\n * constraint to stretch and without applying huge forces.\n *\n * You need to call setTarget(target) every time that mouse is \n * moved, to track the new location of the mouse.\n *\n * NOTE: this joint is not documented in the manual because it was developed to\n * be used in the testbed. If you want to learn how to use the mouse joint, look\n * at the testbed.\n */\n// @ts-expect-error\nexport class MouseJoint extends Joint {\n static TYPE = \"mouse-joint\" as const;\n\n /** @internal */ m_type: \"mouse-joint\";\n /** @internal */ m_targetA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_impulse: Vec2;\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n /** @internal */ m_beta: number;\n /** @internal */ m_gamma: number;\n // Solver temp\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: Mat22;\n /** @internal */ m_C: Vec2;\n\n constructor(def: MouseJointDef);\n constructor(def: MouseJointOpt, bodyA: Body, bodyB: Body, target?: Vec2Value);\n constructor(def: MouseJointDef, bodyA?: Body, bodyB?: Body, target?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof MouseJoint)) {\n return new MouseJoint(def, bodyA, bodyB, target);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = MouseJoint.TYPE;\n\n if (_ASSERT) console.assert(Number.isFinite(def.maxForce) && def.maxForce >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.frequencyHz) && def.frequencyHz >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.dampingRatio) && def.dampingRatio >= 0.0);\n\n if (Vec2.isValid(target)) {\n this.m_targetA = Vec2.clone(target);\n } else if (Vec2.isValid(def.target)) {\n this.m_targetA = Vec2.clone(def.target);\n } else {\n this.m_targetA = Vec2.zero();\n }\n\n this.m_localAnchorB = Transform.mulTVec2(bodyB.getTransform(), this.m_targetA);\n\n this.m_maxForce = def.maxForce;\n this.m_impulse = Vec2.zero();\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_beta = 0.0;\n this.m_gamma = 0.0;\n\n // Solver temp\n this.m_rB = Vec2.zero();\n this.m_localCenterB = Vec2.zero();\n this.m_invMassB = 0.0;\n this.m_invIB = 0.0;\n this.m_mass = new Mat22();\n this.m_C = Vec2.zero();\n\n // p = attached point, m = mouse point\n // C = p - m\n // Cdot = v\n // = v + cross(w, r)\n // J = [I r_skew]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n target: this.m_targetA,\n maxForce: this.m_maxForce,\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n _localAnchorB: this.m_localAnchorB,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): MouseJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.target = Vec2.clone(data.target);\n const joint = new MouseJoint(data);\n if (data._localAnchorB) {\n joint.m_localAnchorB = data._localAnchorB;\n }\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * Use this to update the target point.\n */\n setTarget(target: Vec2Value): void {\n if (Vec2.areEqual(target, this.m_targetA)) return;\n this.m_bodyB.setAwake(true);\n this.m_targetA.set(target);\n }\n\n getTarget(): Vec2 {\n return this.m_targetA;\n }\n\n /**\n * Set the maximum force in Newtons.\n */\n setMaxForce(force: number): void {\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum force in Newtons.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the frequency in Hertz.\n */\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n /**\n * Get the frequency in Hertz.\n */\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set the damping ratio (dimensionless).\n */\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n /**\n * Get the damping ratio (dimensionless).\n */\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return Vec2.clone(this.m_targetA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_impulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * 0.0;\n }\n\n /**\n * Shift the origin for any points stored in world coordinates.\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_targetA.sub(newOrigin);\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const position = this.m_bodyB.c_position;\n const velocity = this.m_bodyB.c_velocity;\n\n const cB = position.c;\n const aB = position.a;\n const vB = velocity.v;\n let wB = velocity.w;\n\n const qB = Rot.neo(aB);\n\n const mass = this.m_bodyB.getMass();\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * mass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = mass * (omega * omega);\n\n // magic formulas\n // gamma has units of inverse mass.\n // beta has units of inverse time.\n const h = step.dt;\n if (_ASSERT) console.assert(d + h * k > EPSILON);\n this.m_gamma = h * (d + h * k);\n if (this.m_gamma != 0.0) {\n this.m_gamma = 1.0 / this.m_gamma;\n }\n this.m_beta = h * k * this.m_gamma;\n\n // Compute the effective mass matrix.\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // K = [(1/m1 + 1/m2) * eye(2) - skew(r1) * invI1 * skew(r1) - skew(r2) *\n // invI2 * skew(r2)]\n // = [1/m1+1/m2 0 ] + invI1 * [r1.y*r1.y -r1.x*r1.y] + invI2 * [r1.y*r1.y\n // -r1.x*r1.y]\n // [ 0 1/m1+1/m2] [-r1.x*r1.y r1.x*r1.x] [-r1.x*r1.y r1.x*r1.x]\n const K = new Mat22();\n K.ex.x = this.m_invMassB + this.m_invIB * this.m_rB.y * this.m_rB.y\n + this.m_gamma;\n K.ex.y = -this.m_invIB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = this.m_invMassB + this.m_invIB * this.m_rB.x * this.m_rB.x\n + this.m_gamma;\n\n this.m_mass = K.getInverse();\n\n this.m_C.setVec2(cB);\n this.m_C.addCombine(1, this.m_rB, -1, this.m_targetA);\n this.m_C.mul(this.m_beta);\n\n // Cheat with some damping\n wB *= 0.98;\n\n if (step.warmStarting) {\n this.m_impulse.mul(step.dtRatio);\n vB.addMul(this.m_invMassB, this.m_impulse);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, this.m_impulse);\n\n } else {\n this.m_impulse.setZero();\n }\n\n velocity.v.setVec2(vB);\n velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const velocity = this.m_bodyB.c_velocity;\n const vB = Vec2.clone(velocity.v);\n let wB = velocity.w;\n\n // Cdot = v + cross(w, r)\n\n const Cdot = Vec2.crossNumVec2(wB, this.m_rB);\n Cdot.add(vB);\n\n Cdot.addCombine(1, this.m_C, this.m_gamma, this.m_impulse);\n Cdot.neg();\n\n let impulse = Mat22.mulVec2(this.m_mass, Cdot);\n\n const oldImpulse = Vec2.clone(this.m_impulse);\n this.m_impulse.add(impulse);\n const maxImpulse = step.dt * this.m_maxForce;\n this.m_impulse.clamp(maxImpulse);\n impulse = Vec2.sub(this.m_impulse, oldImpulse);\n\n vB.addMul(this.m_invMassB, impulse);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n\n velocity.v.setVec2(vB);\n velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n\n\n/**\n * Pulley joint definition. This requires two ground anchors, two dynamic body\n * anchor points, and a pulley ratio.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface PulleyJointOpt extends JointOpt {\n}\n\n/**\n * Pulley joint definition. This requires two ground anchors, two dynamic body\n * anchor points, and a pulley ratio.\n */\nexport interface PulleyJointDef extends JointDef, PulleyJointOpt {\n /**\n * The first ground anchor in world coordinates. This point never moves.\n */\n groundAnchorA: Vec2Value;\n /**\n * The second ground anchor in world coordinates. This point never moves.\n */\n groundAnchorB: Vec2Value;\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The reference length for the segment attached to bodyA.\n */\n lengthA: number;\n /**\n * The reference length for the segment attached to bodyB.\n */\n lengthB: number;\n /**\n * The pulley ratio, used to simulate a block-and-tackle.\n */\n ratio: number;\n\n /** @hidden */ anchorA?: Vec2Value;\n /** @hidden */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n collideConnected : true\n};\n\ndeclare module \"./PulleyJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PulleyJoint(def: PulleyJointDef): PulleyJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PulleyJoint(def: PulleyJointOpt, bodyA: Body, bodyB: Body, groundA: Vec2Value, groundB: Vec2Value, anchorA: Vec2Value, anchorB: Vec2Value, ratio: number): PulleyJoint;\n}\n\n/**\n * The pulley joint is connected to two bodies and two fixed ground points. The\n * pulley supports a ratio such that: length1 + ratio * length2 <= constant\n *\n * Yes, the force transmitted is scaled by the ratio.\n *\n * Warning: the pulley joint can get a bit squirrelly by itself. They often work\n * better when combined with prismatic joints. You should also cover the the\n * anchor points with static shapes to prevent one side from going to zero\n * length.\n */\n// @ts-expect-error\nexport class PulleyJoint extends Joint {\n static TYPE = \"pulley-joint\" as const;\n // static MIN_PULLEY_LENGTH: number = 2.0; // TODO where this is used?\n\n /** @internal */ m_type: \"pulley-joint\";\n /** @internal */ m_groundAnchorA: Vec2;\n /** @internal */ m_groundAnchorB: Vec2;\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_lengthA: number;\n /** @internal */ m_lengthB: number;\n /** @internal */ m_ratio: number;\n /** @internal */ m_constant: number;\n /** @internal */ m_impulse: number;\n\n // Solver temp\n /** @internal */ m_uA: Vec2;\n /** @internal */ m_uB: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: number;\n\n constructor(def: PulleyJointDef);\n constructor(def: PulleyJointOpt, bodyA: Body, bodyB: Body, groundA?: Vec2Value, groundB?: Vec2Value, anchorA?: Vec2Value, anchorB?: Vec2Value, ratio?: number);\n constructor(def: PulleyJointDef, bodyA?: Body, bodyB?: Body, groundA?: Vec2Value, groundB?: Vec2Value, anchorA?: Vec2Value, anchorB?: Vec2Value, ratio?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PulleyJoint)) {\n return new PulleyJoint(def, bodyA, bodyB, groundA, groundB, anchorA, anchorB, ratio);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = PulleyJoint.TYPE;\n this.m_groundAnchorA = Vec2.clone(groundA ? groundA : def.groundAnchorA || Vec2.neo(-1.0, 1.0));\n this.m_groundAnchorB = Vec2.clone(groundB ? groundB : def.groundAnchorB || Vec2.neo(1.0, 1.0));\n this.m_localAnchorA = Vec2.clone(anchorA ? bodyA.getLocalPoint(anchorA) : def.localAnchorA || Vec2.neo(-1.0, 0.0));\n this.m_localAnchorB = Vec2.clone(anchorB ? bodyB.getLocalPoint(anchorB) : def.localAnchorB || Vec2.neo(1.0, 0.0));\n this.m_lengthA = Number.isFinite(def.lengthA) ? def.lengthA : Vec2.distance(anchorA, groundA);\n this.m_lengthB = Number.isFinite(def.lengthB) ? def.lengthB : Vec2.distance(anchorB, groundB);\n this.m_ratio = Number.isFinite(ratio) ? ratio : def.ratio;\n\n if (_ASSERT) console.assert(ratio > EPSILON);\n\n this.m_constant = this.m_lengthA + this.m_ratio * this.m_lengthB;\n\n this.m_impulse = 0.0;\n\n // Pulley:\n // length1 = norm(p1 - s1)\n // length2 = norm(p2 - s2)\n // C0 = (length1 + ratio * length2)_initial\n // C = C0 - (length1 + ratio * length2)\n // u1 = (p1 - s1) / norm(p1 - s1)\n // u2 = (p2 - s2) / norm(p2 - s2)\n // Cdot = -dot(u1, v1 + cross(w1, r1)) - ratio * dot(u2, v2 + cross(w2, r2))\n // J = -[u1 cross(r1, u1) ratio * u2 ratio * cross(r2, u2)]\n // K = J * invM * JT\n // = invMass1 + invI1 * cross(r1, u1)^2 + ratio^2 * (invMass2 + invI2 *\n // cross(r2, u2)^2)\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n groundAnchorA: this.m_groundAnchorA,\n groundAnchorB: this.m_groundAnchorB,\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n lengthA: this.m_lengthA,\n lengthB: this.m_lengthB,\n ratio: this.m_ratio,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): PulleyJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new PulleyJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Vec2.isValid(def.groundAnchorA)) {\n this.m_groundAnchorA.set(def.groundAnchorA);\n }\n if (Vec2.isValid(def.groundAnchorB)) {\n this.m_groundAnchorB.set(def.groundAnchorB);\n }\n if (Vec2.isValid(def.localAnchorA)) {\n this.m_localAnchorA.set(def.localAnchorA);\n } else if (Vec2.isValid(def.anchorA)) {\n this.m_localAnchorA.set(this.m_bodyA.getLocalPoint(def.anchorA));\n }\n if (Vec2.isValid(def.localAnchorB)) {\n this.m_localAnchorB.set(def.localAnchorB);\n } else if (Vec2.isValid(def.anchorB)) {\n this.m_localAnchorB.set(this.m_bodyB.getLocalPoint(def.anchorB));\n }\n if (Number.isFinite(def.lengthA)) {\n this.m_lengthA = def.lengthA;\n }\n if (Number.isFinite(def.lengthB)) {\n this.m_lengthB = def.lengthB;\n }\n if (Number.isFinite(def.ratio)) {\n this.m_ratio = def.ratio;\n }\n }\n\n /**\n * Get the first ground anchor.\n */\n getGroundAnchorA(): Vec2 {\n return this.m_groundAnchorA;\n }\n\n /**\n * Get the second ground anchor.\n */\n getGroundAnchorB(): Vec2 {\n return this.m_groundAnchorB;\n }\n\n /**\n * Get the current length of the segment attached to bodyA.\n */\n getLengthA(): number {\n return this.m_lengthA;\n }\n\n /**\n * Get the current length of the segment attached to bodyB.\n */\n getLengthB(): number {\n return this.m_lengthB;\n }\n\n /**\n * Get the pulley ratio.\n */\n getRatio(): number {\n return this.m_ratio;\n }\n\n /**\n * Get the current length of the segment attached to bodyA.\n */\n getCurrentLengthA(): number {\n const p = this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n const s = this.m_groundAnchorA;\n return Vec2.distance(p, s);\n }\n\n /**\n * Get the current length of the segment attached to bodyB.\n */\n getCurrentLengthB(): number {\n const p = this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n const s = this.m_groundAnchorB;\n return Vec2.distance(p, s);\n }\n\n /**\n * Shift the origin for any points stored in world coordinates.\n *\n * @param newOrigin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_groundAnchorA.sub(newOrigin);\n this.m_groundAnchorB.sub(newOrigin);\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_uB).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // Get the pulley axes.\n this.m_uA = Vec2.sub(Vec2.add(cA, this.m_rA), this.m_groundAnchorA);\n this.m_uB = Vec2.sub(Vec2.add(cB, this.m_rB), this.m_groundAnchorB);\n\n const lengthA = this.m_uA.length();\n const lengthB = this.m_uB.length();\n\n if (lengthA > 10.0 * Settings.linearSlop) {\n this.m_uA.mul(1.0 / lengthA);\n } else {\n this.m_uA.setZero();\n }\n\n if (lengthB > 10.0 * Settings.linearSlop) {\n this.m_uB.mul(1.0 / lengthB);\n } else {\n this.m_uB.setZero();\n }\n\n // Compute effective mass.\n const ruA = Vec2.crossVec2Vec2(this.m_rA, this.m_uA);\n const ruB = Vec2.crossVec2Vec2(this.m_rB, this.m_uB);\n\n const mA = this.m_invMassA + this.m_invIA * ruA * ruA;\n const mB = this.m_invMassB + this.m_invIB * ruB * ruB;\n\n this.m_mass = mA + this.m_ratio * this.m_ratio * mB;\n\n if (this.m_mass > 0.0) {\n this.m_mass = 1.0 / this.m_mass;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support variable time steps.\n this.m_impulse *= step.dtRatio;\n\n // Warm starting.\n const PA = Vec2.mulNumVec2(-this.m_impulse, this.m_uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * this.m_impulse, this.m_uB);\n\n vA.addMul(this.m_invMassA, PA);\n wA += this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, PA);\n\n vB.addMul(this.m_invMassB, PB);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, PB);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const vpA = Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA));\n const vpB = Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB));\n\n const Cdot = -Vec2.dot(this.m_uA, vpA) - this.m_ratio * Vec2.dot(this.m_uB, vpB);\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n const PA = Vec2.mulNumVec2(-impulse, this.m_uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * impulse, this.m_uB);\n vA.addMul(this.m_invMassA, PA);\n wA += this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, PA);\n vB.addMul(this.m_invMassB, PB);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, PB);\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // Get the pulley axes.\n const uA = Vec2.sub(Vec2.add(cA, this.m_rA), this.m_groundAnchorA);\n const uB = Vec2.sub(Vec2.add(cB, this.m_rB), this.m_groundAnchorB);\n\n const lengthA = uA.length();\n const lengthB = uB.length();\n\n if (lengthA > 10.0 * Settings.linearSlop) {\n uA.mul(1.0 / lengthA);\n } else {\n uA.setZero();\n }\n\n if (lengthB > 10.0 * Settings.linearSlop) {\n uB.mul(1.0 / lengthB);\n } else {\n uB.setZero();\n }\n\n // Compute effective mass.\n const ruA = Vec2.crossVec2Vec2(rA, uA);\n const ruB = Vec2.crossVec2Vec2(rB, uB);\n\n const mA = this.m_invMassA + this.m_invIA * ruA * ruA;\n const mB = this.m_invMassB + this.m_invIB * ruB * ruB;\n\n let mass = mA + this.m_ratio * this.m_ratio * mB;\n\n if (mass > 0.0) {\n mass = 1.0 / mass;\n }\n\n const C = this.m_constant - lengthA - this.m_ratio * lengthB;\n const linearError = math_abs(C);\n\n const impulse = -mass * C;\n\n const PA = Vec2.mulNumVec2(-impulse, uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * impulse, uB);\n\n cA.addMul(this.m_invMassA, PA);\n aA += this.m_invIA * Vec2.crossVec2Vec2(rA, PA);\n cB.addMul(this.m_invMassB, PB);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, PB);\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return linearError < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_min = Math.min;\n\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3,\n}\n\n/**\n * Rope joint definition. This requires two body anchor points and a maximum\n * lengths. Note: by default the connected objects will not collide. see\n * collideConnected in JointDef.\n */\nexport interface RopeJointOpt extends JointOpt {\n /**\n * The maximum length of the rope.\n * Warning: this must be larger than linearSlop or the joint will have no effect.\n */\n maxLength?: number;\n}\n\n/**\n * Rope joint definition. This requires two body anchor points and a maximum\n * lengths. Note: by default the connected objects will not collide. see\n * collideConnected in JointDef.\n */\nexport interface RopeJointDef extends JointDef, RopeJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxLength : 0.0,\n};\n\ndeclare module \"./RopeJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RopeJoint(def: RopeJointDef): RopeJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RopeJoint(def: RopeJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): RopeJoint;\n}\n\n/**\n * A rope joint enforces a maximum distance between two points on two bodies. It\n * has no other effect.\n *\n * Warning: if you attempt to change the maximum length during the simulation\n * you will get some non-physical behavior.\n *\n * A model that would allow you to dynamically modify the length would have some\n * sponginess, so I chose not to implement it that way. See {@link DistanceJoint} if you\n * want to dynamically control length.\n */\n// @ts-expect-error\nexport class RopeJoint extends Joint {\n static TYPE = \"rope-joint\" as const;\n\n /** @internal */ m_type: \"rope-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n\n /** @internal */ m_maxLength: number;\n\n /** @internal */ m_mass: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_length: number;\n /** @internal */ m_state: number; // TODO enum\n\n // Solver temp\n /** @internal */ m_u: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n\n constructor(def: RopeJointDef);\n constructor(def: RopeJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: RopeJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof RopeJoint)) {\n return new RopeJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = RopeJoint.TYPE;\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.neo(-1.0, 0.0));\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.neo(1.0, 0.0));\n\n this.m_maxLength = def.maxLength;\n\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n this.m_length = 0.0;\n this.m_state = LimitState.inactiveLimit;\n\n // Limit:\n // C = norm(pB - pA) - L\n // u = (pB - pA) / norm(pB - pA)\n // Cdot = dot(u, vB + cross(wB, rB) - vA - cross(wA, rA))\n // J = [-u -cross(rA, u) u cross(rB, u)]\n // K = J * invM * JT\n // = invMassA + invIA * cross(rA, u)^2 + invMassB + invIB * cross(rB, u)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n maxLength: this.m_maxLength,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): RopeJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new RopeJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.maxLength)) {\n this.m_maxLength = def.maxLength;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the maximum length of the rope.\n */\n setMaxLength(length: number): void {\n this.m_maxLength = length;\n }\n\n /**\n * Get the maximum length of the rope.\n */\n getMaxLength(): number {\n return this.m_maxLength;\n }\n\n getLimitState(): number {\n // TODO LimitState\n return this.m_state;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_u).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n this.m_rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n this.m_u = Vec2.zero();\n this.m_u.addCombine(1, cB, 1, this.m_rB);\n this.m_u.subCombine(1, cA, 1, this.m_rA);\n\n this.m_length = this.m_u.length();\n\n const C = this.m_length - this.m_maxLength;\n if (C > 0.0) {\n this.m_state = LimitState.atUpperLimit;\n } else {\n this.m_state = LimitState.inactiveLimit;\n }\n\n if (this.m_length > Settings.linearSlop) {\n this.m_u.mul(1.0 / this.m_length);\n } else {\n this.m_u.setZero();\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n return;\n }\n\n // Compute effective mass.\n const crA = Vec2.crossVec2Vec2(this.m_rA, this.m_u);\n const crB = Vec2.crossVec2Vec2(this.m_rB, this.m_u);\n const invMass = this.m_invMassA + this.m_invIA * crA * crA + this.m_invMassB + this.m_invIB * crB * crB;\n\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n\n if (step.warmStarting) {\n // Scale the impulse to support a variable time step.\n this.m_impulse *= step.dtRatio;\n\n const P = Vec2.mulNumVec2(this.m_impulse, this.m_u);\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Cdot = dot(u, v + cross(w, r))\n const vpA = Vec2.addCrossNumVec2(vA, wA, this.m_rA);\n const vpB = Vec2.addCrossNumVec2(vB, wB, this.m_rB);\n const C = this.m_length - this.m_maxLength;\n let Cdot = Vec2.dot(this.m_u, Vec2.sub(vpB, vpA));\n\n // Predictive constraint.\n if (C < 0.0) {\n Cdot += step.inv_dt * C;\n }\n\n let impulse = -this.m_mass * Cdot;\n const oldImpulse = this.m_impulse;\n this.m_impulse = math_min(0.0, this.m_impulse + impulse);\n impulse = this.m_impulse - oldImpulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_u);\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n const u = Vec2.zero();\n u.addCombine(1, cB, 1, rB);\n u.subCombine(1, cA, 1, rA);\n\n const length = u.normalize();\n let C = length - this.m_maxLength;\n\n C = clamp(C, 0.0, Settings.maxLinearCorrection);\n\n const impulse = -this.m_mass * C;\n const P = Vec2.mulNumVec2(impulse, u);\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * Vec2.crossVec2Vec2(rA, P);\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, P);\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return length - this.m_maxLength < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Weld joint definition. You need to specify local anchor points where they are\n * attached and the relative body angle. The position of the anchor points is\n * important for computing the reaction torque.\n */\nexport interface WeldJointOpt extends JointOpt {\n /**\n * The mass-spring-damper frequency in Hertz. Rotation only. Disable softness\n * with a value of 0.\n */\n frequencyHz?: number;\n /**\n * The damping ratio. 0 = no damping, 1 = critical damping.\n */\n dampingRatio?: number;\n /**\n * The bodyB angle minus bodyA angle in the reference state (radians).\n */\n referenceAngle?: number;\n}\n\n/**\n * Weld joint definition. You need to specify local anchor points where they are\n * attached and the relative body angle. The position of the anchor points is\n * important for computing the reaction torque.\n */\nexport interface WeldJointDef extends JointDef, WeldJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n frequencyHz : 0.0,\n dampingRatio : 0.0,\n};\n\ndeclare module \"./WeldJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WeldJoint(def: WeldJointDef): WeldJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WeldJoint(def: WeldJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): WeldJoint;\n}\n\n/**\n * A weld joint essentially glues two bodies together. A weld joint may distort\n * somewhat because the island constraint solver is approximate.\n */\n// @ts-expect-error\nexport class WeldJoint extends Joint {\n static TYPE = \"weld-joint\" as const;\n\n /** @internal */ m_type: \"weld-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngle: number;\n\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n\n /** @internal */ m_impulse: Vec3;\n\n /** @internal */ m_bias: number;\n /** @internal */ m_gamma: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: Mat33;\n\n constructor(def: WeldJointDef);\n constructor(def: WeldJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: WeldJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof WeldJoint)) {\n return new WeldJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = WeldJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n this.m_referenceAngle = Number.isFinite(def.referenceAngle) ? def.referenceAngle : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_impulse = new Vec3();\n\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n\n // Solver temp\n // todo: do we need to initialize?\n // this.m_rA;\n // this.m_rB;\n // this.m_localCenterA;\n // this.m_localCenterB;\n // this.m_invMassA;\n // this.m_invMassB;\n // this.m_invIA;\n // this.m_invIB;\n this.m_mass = new Mat33();\n\n // Point-to-point constraint\n // C = p2 - p1\n // Cdot = v2 - v1\n // / = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Angle constraint\n // C = angle2 - angle1 - referenceAngle\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): WeldJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new WeldJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Set frequency in Hz.\n */\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n /**\n * Get frequency in Hz.\n */\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set damping ratio.\n */\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n /**\n * Get damping ratio.\n */\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.neo(this.m_impulse.x, this.m_impulse.y).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.z;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat33();\n K.ex.x = mA + mB + this.m_rA.y * this.m_rA.y * iA + this.m_rB.y * this.m_rB.y\n * iB;\n K.ey.x = -this.m_rA.y * this.m_rA.x * iA - this.m_rB.y * this.m_rB.x * iB;\n K.ez.x = -this.m_rA.y * iA - this.m_rB.y * iB;\n K.ex.y = K.ey.x;\n K.ey.y = mA + mB + this.m_rA.x * this.m_rA.x * iA + this.m_rB.x * this.m_rB.x\n * iB;\n K.ez.y = this.m_rA.x * iA + this.m_rB.x * iB;\n K.ex.z = K.ez.x;\n K.ey.z = K.ez.y;\n K.ez.z = iA + iB;\n\n if (this.m_frequencyHz > 0.0) {\n K.getInverse22(this.m_mass);\n\n let invM = iA + iB;\n const m = invM > 0.0 ? 1.0 / invM : 0.0;\n\n const C = aB - aA - this.m_referenceAngle;\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * m * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = m * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (d + h * k);\n this.m_gamma = this.m_gamma != 0.0 ? 1.0 / this.m_gamma : 0.0;\n this.m_bias = C * h * k * this.m_gamma;\n\n invM += this.m_gamma;\n this.m_mass.ez.z = invM != 0.0 ? 1.0 / invM : 0.0;\n } else if (K.ez.z == 0.0) {\n K.getInverse22(this.m_mass);\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n } else {\n K.getSymInverse33(this.m_mass);\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_impulse.mul(step.dtRatio);\n\n const P = Vec2.neo(this.m_impulse.x, this.m_impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_impulse.z);\n\n } else {\n this.m_impulse.setZero();\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n if (this.m_frequencyHz > 0.0) {\n const Cdot2 = wB - wA;\n\n const impulse2 = -this.m_mass.ez.z * (Cdot2 + this.m_bias + this.m_gamma * this.m_impulse.z);\n this.m_impulse.z += impulse2;\n\n wA -= iA * impulse2;\n wB += iB * impulse2;\n\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n\n const impulse1 = Vec2.neg(Mat33.mulVec2(this.m_mass, Cdot1));\n this.m_impulse.x += impulse1.x;\n this.m_impulse.y += impulse1.y;\n\n const P = Vec2.clone(impulse1);\n\n vA.subMul(mA, P);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(mB, P);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, P);\n } else {\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const Cdot2 = wB - wA;\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const impulse = Vec3.neg(Mat33.mulVec3(this.m_mass, Cdot));\n this.m_impulse.add(impulse);\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + impulse.z);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n let positionError: number;\n let angularError: number;\n\n const K = new Mat33();\n K.ex.x = mA + mB + rA.y * rA.y * iA + rB.y * rB.y * iB;\n K.ey.x = -rA.y * rA.x * iA - rB.y * rB.x * iB;\n K.ez.x = -rA.y * iA - rB.y * iB;\n K.ex.y = K.ey.x;\n K.ey.y = mA + mB + rA.x * rA.x * iA + rB.x * rB.x * iB;\n K.ez.y = rA.x * iA + rB.x * iB;\n K.ex.z = K.ez.x;\n K.ey.z = K.ez.y;\n K.ez.z = iA + iB;\n\n if (this.m_frequencyHz > 0.0) {\n const C1 = Vec2.zero();\n C1.addCombine(1, cB, 1, rB);\n C1.subCombine(1, cA, 1, rA);\n\n positionError = C1.length();\n angularError = 0.0;\n\n const P = Vec2.neg(K.solve22(C1));\n\n cA.subMul(mA, P);\n aA -= iA * Vec2.crossVec2Vec2(rA, P);\n\n cB.addMul(mB, P);\n aB += iB * Vec2.crossVec2Vec2(rB, P);\n } else {\n const C1 = Vec2.zero();\n C1.addCombine(1, cB, 1, rB);\n C1.subCombine(1, cA, 1, rA);\n\n const C2 = aB - aA - this.m_referenceAngle;\n\n positionError = C1.length();\n angularError = math_abs(C2);\n\n const C = new Vec3(C1.x, C1.y, C2);\n\n let impulse = new Vec3();\n if (K.ez.z > 0.0) {\n impulse = Vec3.neg(K.solve33(C));\n } else {\n const impulse2 = Vec2.neg(K.solve22(C1));\n impulse.set(impulse2.x, impulse2.y, 0.0);\n }\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n cA.subMul(mA, P);\n aA -= iA * (Vec2.crossVec2Vec2(rA, P) + impulse.z);\n\n cB.addMul(mB, P);\n aB += iB * (Vec2.crossVec2Vec2(rB, P) + impulse.z);\n }\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return positionError <= Settings.linearSlop && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Wheel joint definition. This requires defining a line of motion using an axis\n * and an anchor point. The definition uses local anchor points and a local axis\n * so that the initial configuration can violate the constraint slightly. The\n * joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface WheelJointOpt extends JointOpt {\n /**\n * Enable/disable the joint motor.\n */\n enableMotor?: boolean;\n /**\n * The maximum motor torque, usually in N-m.\n */\n maxMotorTorque?: number;\n /**\n * The desired motor speed in radians per second.\n */\n motorSpeed?: number;\n /**\n * Suspension frequency, zero indicates no suspension.\n */\n frequencyHz?: number;\n /**\n * Suspension damping ratio, one indicates critical damping.\n */\n dampingRatio?: number;\n}\n\n/**\n * Wheel joint definition. This requires defining a line of motion using an axis\n * and an anchor point. The definition uses local anchor points and a local axis\n * so that the initial configuration can violate the constraint slightly. The\n * joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface WheelJointDef extends JointDef, WheelJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The local translation axis in bodyA.\n */\n localAxisA: Vec2Value;\n\n /** @internal renamed to localAxisA */\n localAxis?: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n enableMotor : false,\n maxMotorTorque : 0.0,\n motorSpeed : 0.0,\n frequencyHz : 2.0,\n dampingRatio : 0.7,\n};\n\ndeclare module \"./WheelJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WheelJoint(def: WheelJointDef): WheelJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WheelJoint(def: WheelJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value, axis: Vec2Value): WheelJoint;\n}\n\n/**\n * A wheel joint. This joint provides two degrees of freedom: translation along\n * an axis fixed in bodyA and rotation in the plane. In other words, it is a\n * point to line constraint with a rotational motor and a linear spring/damper.\n * This joint is designed for vehicle suspensions.\n */\n// @ts-expect-error\nexport class WheelJoint extends Joint {\n static TYPE = \"wheel-joint\" as const;\n\n /** @internal */ m_type: \"wheel-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_localXAxisA: Vec2;\n /** @internal */ m_localYAxisA: Vec2;\n\n /** @internal */ m_mass: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_motorMass: number;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_springMass: number;\n /** @internal */ m_springImpulse: number;\n\n /** @internal */ m_maxMotorTorque: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableMotor: boolean;\n\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n\n /** @internal */ m_bias: number;\n /** @internal */ m_gamma: number;\n\n // Solver temp\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n\n /** @internal */ m_ax: Vec2;\n /** @internal */ m_ay: Vec2;\n /** @internal */ m_sAx: number;\n /** @internal */ m_sBx: number;\n /** @internal */ m_sAy: number;\n /** @internal */ m_sBy: number;\n\n constructor(def: WheelJointDef);\n constructor(def: WheelJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value, axis?: Vec2Value);\n constructor(def: WheelJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value, axis?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof WheelJoint)) {\n return new WheelJoint(def, bodyA, bodyB, anchor, axis);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_ax = Vec2.zero();\n this.m_ay = Vec2.zero();\n\n this.m_type = WheelJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n\n if (Vec2.isValid(axis)) {\n this.m_localXAxisA = bodyA.getLocalVector(axis);\n } else if (Vec2.isValid(def.localAxisA)) {\n this.m_localXAxisA = Vec2.clone(def.localAxisA);\n } else if (Vec2.isValid(def.localAxis)) {\n // localAxis is renamed to localAxisA, this is for backward compatibility\n this.m_localXAxisA = Vec2.clone(def.localAxis);\n } else {\n this.m_localXAxisA = Vec2.neo(1.0, 0.0);\n }\n\n this.m_localYAxisA = Vec2.crossNumVec2(1.0, this.m_localXAxisA);\n\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n this.m_springMass = 0.0;\n this.m_springImpulse = 0.0;\n\n this.m_maxMotorTorque = def.maxMotorTorque;\n this.m_motorSpeed = def.motorSpeed;\n this.m_enableMotor = def.enableMotor;\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n\n // Linear constraint (point-to-line)\n // d = pB - pA = xB + rB - xA - rA\n // C = dot(ay, d)\n // Cdot = dot(d, cross(wA, ay)) + dot(ay, vB + cross(wB, rB) - vA - cross(wA,\n // rA))\n // = -dot(ay, vA) - dot(cross(d + rA, ay), wA) + dot(ay, vB) + dot(cross(rB,\n // ay), vB)\n // J = [-ay, -cross(d + rA, ay), ay, cross(rB, ay)]\n\n // Spring linear constraint\n // C = dot(ax, d)\n // Cdot = = -dot(ax, vA) - dot(cross(d + rA, ax), wA) + dot(ax, vB) +\n // dot(cross(rB, ax), vB)\n // J = [-ax -cross(d+rA, ax) ax cross(rB, ax)]\n\n // Motor rotational constraint\n // Cdot = wB - wA\n // J = [0 0 -1 0 0 1]\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n enableMotor: this.m_enableMotor,\n maxMotorTorque: this.m_maxMotorTorque,\n motorSpeed: this.m_motorSpeed,\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n localAxisA: this.m_localXAxisA,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): WheelJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new WheelJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (def.localAxisA) {\n this.m_localXAxisA.setVec2(def.localAxisA);\n this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1.0, def.localAxisA));\n }\n if (def.enableMotor !== undefined) {\n this.m_enableMotor = def.enableMotor;\n }\n if (Number.isFinite(def.maxMotorTorque)) {\n this.m_maxMotorTorque = def.maxMotorTorque;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * The local joint axis relative to bodyA.\n */\n getLocalAxisA(): Vec2 {\n return this.m_localXAxisA;\n }\n\n /**\n * Get the current joint translation, usually in meters.\n */\n getJointTranslation(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n\n const pA = bA.getWorldPoint(this.m_localAnchorA);\n const pB = bB.getWorldPoint(this.m_localAnchorB);\n const d = Vec2.sub(pB, pA);\n const axis = bA.getWorldVector(this.m_localXAxisA);\n\n const translation = Vec2.dot(d, axis);\n return translation;\n }\n\n /**\n * Get the current joint translation speed, usually in meters per second.\n */\n getJointSpeed(): number {\n const wA = this.m_bodyA.m_angularVelocity;\n const wB = this.m_bodyB.m_angularVelocity;\n return wB - wA;\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Set the motor speed, usually in radians per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Get the motor speed, usually in radians per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Set/Get the maximum motor force, usually in N-m.\n */\n setMaxMotorTorque(torque: number): void {\n if (torque == this.m_maxMotorTorque) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorTorque = torque;\n }\n\n getMaxMotorTorque(): number {\n return this.m_maxMotorTorque;\n }\n\n /**\n * Get the current motor torque given the inverse time step, usually in N-m.\n */\n getMotorTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Set/Get the spring frequency in hertz. Setting the frequency to zero disables\n * the spring.\n */\n setSpringFrequencyHz(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n getSpringFrequencyHz(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set/Get the spring damping ratio\n */\n setSpringDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n getSpringDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.combine(this.m_impulse, this.m_ay, this.m_springImpulse, this.m_ax).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective masses.\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n // Point to line constraint\n {\n this.m_ay = Rot.mulVec2(qA, this.m_localYAxisA);\n this.m_sAy = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_ay);\n this.m_sBy = Vec2.crossVec2Vec2(rB, this.m_ay);\n\n this.m_mass = mA + mB + iA * this.m_sAy * this.m_sAy + iB * this.m_sBy\n * this.m_sBy;\n\n if (this.m_mass > 0.0) {\n this.m_mass = 1.0 / this.m_mass;\n }\n }\n\n // Spring constraint\n this.m_springMass = 0.0;\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n if (this.m_frequencyHz > 0.0) {\n this.m_ax = Rot.mulVec2(qA, this.m_localXAxisA);\n this.m_sAx = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_ax);\n this.m_sBx = Vec2.crossVec2Vec2(rB, this.m_ax);\n\n const invMass = mA + mB + iA * this.m_sAx * this.m_sAx + iB * this.m_sBx\n * this.m_sBx;\n\n if (invMass > 0.0) {\n this.m_springMass = 1.0 / invMass;\n\n const C = Vec2.dot(d, this.m_ax);\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const damp = 2.0 * this.m_springMass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = this.m_springMass * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (damp + h * k);\n if (this.m_gamma > 0.0) {\n this.m_gamma = 1.0 / this.m_gamma;\n }\n\n this.m_bias = C * h * k * this.m_gamma;\n\n this.m_springMass = invMass + this.m_gamma;\n if (this.m_springMass > 0.0) {\n this.m_springMass = 1.0 / this.m_springMass;\n }\n }\n } else {\n this.m_springImpulse = 0.0;\n }\n\n // Rotational motor\n if (this.m_enableMotor) {\n this.m_motorMass = iA + iB;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n } else {\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n }\n\n if (step.warmStarting) {\n // Account for variable time step.\n this.m_impulse *= step.dtRatio;\n this.m_springImpulse *= step.dtRatio;\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.combine(this.m_impulse, this.m_ay, this.m_springImpulse, this.m_ax);\n const LA = this.m_impulse * this.m_sAy + this.m_springImpulse * this.m_sAx + this.m_motorImpulse;\n const LB = this.m_impulse * this.m_sBy + this.m_springImpulse * this.m_sBx + this.m_motorImpulse;\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * LA;\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * LB;\n\n } else {\n this.m_impulse = 0.0;\n this.m_springImpulse = 0.0;\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Solve spring constraint\n {\n const Cdot = Vec2.dot(this.m_ax, vB) - Vec2.dot(this.m_ax, vA) + this.m_sBx * wB - this.m_sAx * wA;\n const impulse = -this.m_springMass * (Cdot + this.m_bias + this.m_gamma * this.m_springImpulse);\n this.m_springImpulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_ax);\n const LA = impulse * this.m_sAx;\n const LB = impulse * this.m_sBx;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n // Solve rotational motor constraint\n {\n const Cdot = wB - wA - this.m_motorSpeed;\n let impulse = -this.m_motorMass * Cdot;\n\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorTorque;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve point to line constraint\n {\n const Cdot = Vec2.dot(this.m_ay, vB) - Vec2.dot(this.m_ay, vA) + this.m_sBy * wB - this.m_sAy * wA;\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_ay);\n const LA = impulse * this.m_sAy;\n const LB = impulse * this.m_sBy;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n const ay = Rot.mulVec2(qA, this.m_localYAxisA);\n\n const sAy = Vec2.crossVec2Vec2(Vec2.add(d, rA), ay);\n const sBy = Vec2.crossVec2Vec2(rB, ay);\n\n const C = Vec2.dot(d, ay);\n\n const k = this.m_invMassA + this.m_invMassB + this.m_invIA * this.m_sAy * this.m_sAy + this.m_invIB * this.m_sBy * this.m_sBy;\n\n const impulse = k != 0.0 ? -C / k : 0.0;\n\n const P = Vec2.mulNumVec2(impulse, ay);\n const LA = impulse * sAy;\n const LB = impulse * sBy;\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * LA;\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * LB;\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return math_abs(C) <= Settings.linearSlop;\n }\n\n}\n","import { World } from \"../dynamics/World\";\nimport { Body } from \"../dynamics/Body\";\nimport { Joint } from \"../dynamics/Joint\";\nimport { Fixture } from \"../dynamics/Fixture\";\nimport { Shape } from \"../collision/Shape\";\nimport { Vec2 } from \"../common/Vec2\";\nimport { Vec3 } from \"../common/Vec3\";\nimport { ChainShape } from \"../collision/shape/ChainShape\";\n// import { BoxShape } from \"../collision/shape/BoxShape\";\nimport { EdgeShape } from \"../collision/shape/EdgeShape\";\nimport { PolygonShape } from \"../collision/shape/PolygonShape\";\nimport { CircleShape } from \"../collision/shape/CircleShape\";\nimport { DistanceJoint } from \"../dynamics/joint/DistanceJoint\";\nimport { FrictionJoint } from \"../dynamics/joint/FrictionJoint\";\nimport { GearJoint } from \"../dynamics/joint/GearJoint\";\nimport { MotorJoint } from \"../dynamics/joint/MotorJoint\";\nimport { MouseJoint } from \"../dynamics/joint/MouseJoint\";\nimport { PrismaticJoint } from \"../dynamics/joint/PrismaticJoint\";\nimport { PulleyJoint } from \"../dynamics/joint/PulleyJoint\";\nimport { RevoluteJoint } from \"../dynamics/joint/RevoluteJoint\";\nimport { RopeJoint } from \"../dynamics/joint/RopeJoint\";\nimport { WeldJoint } from \"../dynamics/joint/WeldJoint\";\nimport { WheelJoint } from \"../dynamics/joint/WheelJoint\";\n\nlet SID = 0;\n\n// Classes to be serialized as reference objects\nconst SERIALIZE_REF_TYPES = {\n \"World\": World,\n \"Body\": Body,\n \"Joint\": Joint,\n \"Fixture\": Fixture,\n \"Shape\": Shape,\n};\n\n// For deserializing reference objects by reference type\nconst DESERIALIZE_BY_REF_TYPE = {\n \"Vec2\": Vec2,\n \"Vec3\": Vec3,\n \"World\": World,\n \"Body\": Body,\n \"Joint\": Joint,\n \"Fixture\": Fixture,\n \"Shape\": Shape,\n};\n\n// For deserializing data objects by type field\nconst DESERIALIZE_BY_TYPE_FIELD = {\n [Body.STATIC]: Body,\n [Body.DYNAMIC]: Body,\n [Body.KINEMATIC]: Body,\n [ChainShape.TYPE]: ChainShape,\n // [BoxShape.TYPE]: BoxShape,\n [PolygonShape.TYPE]: PolygonShape,\n [EdgeShape.TYPE]: EdgeShape,\n [CircleShape.TYPE]: CircleShape,\n [DistanceJoint.TYPE]: DistanceJoint,\n [FrictionJoint.TYPE]: FrictionJoint,\n [GearJoint.TYPE]: GearJoint,\n [MotorJoint.TYPE]: MotorJoint,\n [MouseJoint.TYPE]: MouseJoint,\n [PrismaticJoint.TYPE]: PrismaticJoint,\n [PulleyJoint.TYPE]: PulleyJoint,\n [RevoluteJoint.TYPE]: RevoluteJoint,\n [RopeJoint.TYPE]: RopeJoint,\n [WeldJoint.TYPE]: WeldJoint,\n [WheelJoint.TYPE]: WheelJoint,\n};\n\n// dummy types\ntype DataType = any;\ntype ObjectType = any;\ntype ClassName = any;\n\ntype SerializedType = object[];\n\ntype RefType = {\n refIndex: number,\n refType: string,\n};\n\ntype SerializerOptions = {\n rootClass: ClassName,\n preSerialize?: (obj: ObjectType) => DataType,\n postSerialize?: (data: DataType, obj: any) => DataType,\n preDeserialize?: (data: DataType) => DataType,\n postDeserialize?: (obj: ObjectType, data: DataType) => ObjectType,\n};\n\nconst DEFAULT_OPTIONS: SerializerOptions = {\n rootClass: World,\n preSerialize: function(obj) { return obj; },\n postSerialize: function(data, obj) { return data; },\n preDeserialize: function(data: DataType) { return data; },\n postDeserialize: function(obj, data) { return obj; },\n};\n\ntype DeserializeChildCallback = (classHint: any, obj: any, context: any) => any;\ntype ClassDeserializerMethod = (data: any, context: any, deserialize: DeserializeChildCallback) => any;\n\nexport class Serializer {\n private options: SerializerOptions;\n constructor(options: SerializerOptions) {\n this.options = {\n ...DEFAULT_OPTIONS,\n ...options,\n };\n }\n\n toJson = (root: T): SerializedType => {\n const preSerialize = this.options.preSerialize;\n const postSerialize = this.options.postSerialize;\n const json = [];\n\n // Breadth-first ref serialization queue\n const refQueue = [root];\n\n const refMemoById: Record = {};\n\n function addToRefQueue(value: any, typeName: string) {\n value.__sid = value.__sid || ++SID;\n if (!refMemoById[value.__sid]) {\n refQueue.push(value);\n const index = json.length + refQueue.length;\n const ref = {\n refIndex: index,\n refType: typeName\n };\n refMemoById[value.__sid] = ref;\n }\n return refMemoById[value.__sid];\n }\n\n function serializeWithHooks(obj: ObjectType) {\n obj = preSerialize(obj);\n let data = obj._serialize();\n data = postSerialize(data, obj);\n return data;\n }\n\n // traverse the object graph\n // ref objects are pushed into the queue\n // other objects are serialize in-place \n function traverse(value: any, noRefType = false) {\n if (typeof value !== \"object\" || value === null) {\n return value;\n }\n // object with _serialize function\n if (typeof value._serialize === \"function\") {\n if (!noRefType) {\n for (const typeName in SERIALIZE_REF_TYPES) {\n if (value instanceof SERIALIZE_REF_TYPES[typeName]) {\n return addToRefQueue(value, typeName);\n }\n }\n }\n // object with _serialize function\n value = serializeWithHooks(value);\n }\n // recursive for arrays any objects\n if (Array.isArray(value)) {\n const newValue = [];\n for (let key = 0; key < value.length; key++) {\n newValue[key] = traverse(value[key]);\n }\n value = newValue;\n\n } else {\n const newValue = {};\n for (const key in value) {\n if (value.hasOwnProperty(key)) {\n newValue[key] = traverse(value[key]);\n }\n }\n value = newValue;\n }\n return value;\n }\n\n while (refQueue.length) {\n const obj = refQueue.shift();\n const str = traverse(obj, true);\n json.push(str);\n }\n\n return json;\n };\n\n fromJson = (json: SerializedType): T => {\n const preDeserialize = this.options.preDeserialize;\n const postDeserialize = this.options.postDeserialize;\n const rootClass = this.options.rootClass;\n\n const deserializedRefMemoByIndex: Record = {};\n\n function deserializeWithHooks(classHint: ClassName, data: DataType, context: any): ObjectType {\n if (!classHint || !classHint._deserialize) {\n classHint = DESERIALIZE_BY_TYPE_FIELD[data.type];\n }\n const deserializer = classHint && classHint._deserialize;\n if (!deserializer) {\n return;\n }\n data = preDeserialize(data);\n const classDeserializeFn = classHint._deserialize as ClassDeserializerMethod;\n let obj = classDeserializeFn(data, context, deserializeChild);\n obj = postDeserialize(obj, data);\n return obj;\n }\n\n /**\n * Recursive callback function to deserialize a child data object or reference object.\n * \n * @param classHint suggested class to deserialize obj to\n * @param dataOrRef data or reference object\n * @param context for example world when deserializing bodies and joints\n */\n function deserializeChild(classHint: ClassName, dataOrRef: DataType | RefType, context: any) {\n const isRefObject = dataOrRef.refIndex && dataOrRef.refType;\n if (!isRefObject) {\n return deserializeWithHooks(classHint, dataOrRef, context); \n }\n const ref = dataOrRef as RefType;\n if (DESERIALIZE_BY_REF_TYPE[ref.refType]) {\n classHint = DESERIALIZE_BY_REF_TYPE[ref.refType];\n }\n const refIndex = ref.refIndex;\n if (!deserializedRefMemoByIndex[refIndex]) {\n const data = json[refIndex];\n const obj = deserializeWithHooks(classHint, data, context);\n deserializedRefMemoByIndex[refIndex] = obj;\n }\n return deserializedRefMemoByIndex[refIndex];\n }\n\n const root = deserializeWithHooks(rootClass, json[0], null);\n\n return root;\n };\n\n static toJson: (root: World) => SerializedType;\n static fromJson: (json: SerializedType) => World;\n}\n\nconst worldSerializer = new Serializer({\n rootClass: World,\n});\n\nSerializer.fromJson = worldSerializer.fromJson;\nSerializer.toJson = worldSerializer.toJson;\n","import type { AABBValue } from \"../collision/AABB\";\nimport type { World } from \"../dynamics/World\";\nimport type { Joint } from \"../dynamics/Joint\";\nimport type { Fixture } from \"../dynamics/Fixture\";\nimport type { Body } from \"../dynamics/Body\";\n\nexport interface Style {\n stroke?: string;\n fill?: string;\n lineWidth?: number;\n}\n\ntype KEY = \"0\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" |\n \"8\" | \"9\" | \"A\" | \"B\" | \"C\" | \"D\" | \"E\" | \"F\" | \"G\" |\n \"H\" | \"I\" | \"J\" | \"K\" | \"L\" | \"M\" | \"N\" | \"O\" | \"P\" |\n \"Q\" | \"R\" | \"S\" | \"T\" | \"U\" | \"V\" | \"W\" | \"X\" | \"Y\" |\n \"Z\" | \"right\" | \"left\" | \"up\" | \"down\" | \"fire\";\n\nexport type ActiveKeys = { [key in KEY]?: boolean };\n\ntype TestbedMountOptions = { [key: string]: any };\n\nexport abstract class Testbed {\n /**\n * Mounts testbed. Call start with a world to start simulation and rendering.\n */\n static mount(options?: TestbedMountOptions): Testbed {\n throw new Error(\"Not implemented\");\n }\n\n /**\n * Mounts testbed if needed, then starts simulation and rendering.\n * \n * If you need to customize testbed before starting, first run `const testbed = Testbed.mount()` and then `testbed.start()`.\n */\n static start(world: World): Testbed {\n const testbed = Testbed.mount();\n testbed.start(world);\n return testbed;\n }\n\n /** World viewbox width. */\n width: number = 80;\n\n /** World viewbox height. */\n height: number = 60;\n\n /** World viewbox center vertical offset. */\n x: number = 0;\n\n /** World viewbox center horizontal offset. */\n y: number = -10;\n\n /** @hidden */\n scaleY: number = -1;\n\n /** World simulation step frequency */\n hz: number = 60;\n\n /** World simulation speed, default is 1 */\n speed: number = 1;\n\n background: string = \"#222222\";\n\n mouseForce?: number;\n activeKeys: ActiveKeys = {};\n\n /** callback, to be implemented by user */\n step = (dt: number, t: number): void => {\n return;\n };\n\n /** callback, to be implemented by user */\n keydown = (keyCode: number, label: string): void => {\n return;\n };\n\n /** callback, to be implemented by user */\n keyup = (keyCode: number, label: string): void => {\n return;\n };\n\n abstract status(name: string, value: any): void;\n abstract status(value: object | string): void;\n\n abstract info(text: string): void;\n\n color(r: number, g: number, b: number): string {\n r = r * 256 | 0;\n g = g * 256 | 0;\n b = b * 256 | 0;\n return \"rgb(\" + r + \", \" + g + \", \" + b + \")\";\n }\n\n abstract drawPoint(p: {x: number, y: number}, r: any, color: string): void;\n abstract drawCircle(p: {x: number, y: number}, r: number, color: string): void;\n abstract drawEdge(a: {x: number, y: number}, b: {x: number, y: number}, color: string): void;\n abstract drawSegment(a: {x: number, y: number}, b: {x: number, y: number}, color: string): void;\n abstract drawPolygon(points: Array<{x: number, y: number}>, color: string): void;\n abstract drawAABB(aabb: AABBValue, color: string): void;\n\n abstract start(world: World): void;\n\n abstract findOne(query: string): (Body | Joint | Fixture | null);\n abstract findAll(query: string): (Body | Joint | Fixture)[];\n}\n\ntype TestbedFactoryOptions = string | TestbedMountOptions;\n\n/** @deprecated */\ntype TestbedCallback = (testbed: Testbed) => (World | undefined);\n\n/** @deprecated */\nexport function testbed(callback: TestbedCallback): void;\n/** @deprecated */\nexport function testbed(options: TestbedFactoryOptions, callback: TestbedCallback): void;\n/** @internal */\nexport function testbed(a?: any, b?: any) {\n let callback: TestbedCallback | undefined;\n let options;\n if (typeof a === \"function\") {\n callback = a;\n options = b;\n } else if (typeof b === \"function\") {\n callback = b;\n options = a;\n } else {\n options = a ?? b;\n }\n const testbed = Testbed.mount(options);\n if (callback) {\n // this is for backwards compatibility\n const world = callback(testbed) || (testbed as any).world;\n testbed.start(world);\n } else {\n return testbed;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { Vec2Value } from \"../../common/Vec2\";\nimport { PolygonShape } from \"./PolygonShape\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\ndeclare module \"./BoxShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function BoxShape(halfWidth: number, halfHeight: number, center?: Vec2Value, angle?: number): BoxShape;\n}\n\n/**\n * A rectangle polygon which extend PolygonShape.\n */\n// @ts-expect-error\nexport class BoxShape extends PolygonShape {\n // note that box is serialized/deserialized as polygon\n static TYPE = \"polygon\" as const;\n\n /**\n * \n * @param halfWidth \n * @param halfHeight \n * @param center coordinate of the center of the box relative to the body\n * @param angle angle of the box relative to the body\n */\n constructor(halfWidth: number, halfHeight: number, center?: Vec2Value, angle?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof BoxShape)) {\n return new BoxShape(halfWidth, halfHeight, center, angle);\n }\n\n super();\n\n this._setAsBox(halfWidth, halfHeight, center, angle);\n }\n}\n\nexport const Box = BoxShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { CircleShape } from \"./CircleShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(CircleShape.TYPE, CircleShape.TYPE, CircleCircleContact);\n\n/** @internal */ function CircleCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == CircleShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n CollideCircles(manifold, fixtureA.getShape() as CircleShape, xfA, fixtureB.getShape() as CircleShape, xfB);\n}\n\n/** @internal */ const pA = matrix.vec2(0, 0);\n/** @internal */ const pB = matrix.vec2(0, 0);\n\nexport const CollideCircles = function (manifold: Manifold, circleA: CircleShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n matrix.transformVec2(pA, xfA, circleA.m_p);\n matrix.transformVec2(pB, xfB, circleB.m_p);\n\n const distSqr = matrix.distSqrVec2(pB, pA);\n const rA = circleA.m_radius;\n const rB = circleB.m_radius;\n const radius = rA + rB;\n if (distSqr > radius * radius) {\n return;\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.copyVec2(manifold.localPoint, circleA.m_p);\n matrix.zeroVec2(manifold.localNormal);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { TransformValue } from \"../../common/Transform\";\nimport * as matrix from \"../../common/Matrix\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { EdgeShape } from \"./EdgeShape\";\nimport { ChainShape } from \"./ChainShape\";\nimport { CircleShape } from \"./CircleShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(EdgeShape.TYPE, CircleShape.TYPE, EdgeCircleContact);\nContact.addType(ChainShape.TYPE, CircleShape.TYPE, ChainCircleContact);\n\n/** @internal */ function EdgeCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == EdgeShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n\n const shapeA = fixtureA.getShape() as EdgeShape;\n const shapeB = fixtureB.getShape() as CircleShape;\n\n CollideEdgeCircle(manifold, shapeA, xfA, shapeB, xfB);\n}\n\nfunction ChainCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == ChainShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n\n const chain = fixtureA.getShape() as ChainShape;\n const edge = new EdgeShape();\n chain.getChildEdge(edge, indexA);\n\n const shapeA = edge;\n const shapeB = fixtureB.getShape() as CircleShape;\n\n CollideEdgeCircle(manifold, shapeA, xfA, shapeB, xfB);\n}\n\n/** @internal */ const e = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const e1 = matrix.vec2(0, 0);\n/** @internal */ const e2 = matrix.vec2(0, 0);\n/** @internal */ const Q = matrix.vec2(0, 0);\n/** @internal */ const P = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n\n// Compute contact points for edge versus circle.\n// This accounts for edge connectivity.\nexport const CollideEdgeCircle = function (manifold: Manifold, edgeA: EdgeShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n // Compute circle in frame of edge\n matrix.retransformVec2(Q, xfB, xfA, circleB.m_p);\n\n const A = edgeA.m_vertex1;\n const B = edgeA.m_vertex2;\n matrix.subVec2(e, B, A);\n\n // Barycentric coordinates\n const u = matrix.dotVec2(e, B) - matrix.dotVec2(e, Q);\n const v = matrix.dotVec2(e, Q) - matrix.dotVec2(e, A);\n\n const radius = edgeA.m_radius + circleB.m_radius;\n\n // Region A\n if (v <= 0.0) {\n matrix.copyVec2(P, A);\n const dd = matrix.distSqrVec2(Q, A);\n if (dd > radius * radius) {\n return;\n }\n\n // Is there an edge connected to A?\n if (edgeA.m_hasVertex0) {\n const A1 = edgeA.m_vertex0;\n const B1 = A;\n matrix.subVec2(e1, B1, A1);\n const u1 = matrix.dotVec2(e1, B1) - matrix.dotVec2(e1, Q);\n\n // Is the circle in Region AB of the previous edge?\n if (u1 > 0.0) {\n return;\n }\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.zeroVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, P);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n return;\n }\n\n // Region B\n if (u <= 0.0) {\n matrix.copyVec2(P, B);\n const dd = matrix.distSqrVec2(Q, P);\n if (dd > radius * radius) {\n return;\n }\n\n // Is there an edge connected to B?\n if (edgeA.m_hasVertex3) {\n const B2 = edgeA.m_vertex3;\n const A2 = B;\n matrix.subVec2(e2, B2, A2);\n const v2 = matrix.dotVec2(e2, Q) - matrix.dotVec2(e2, A2);\n\n // Is the circle in Region AB of the next edge?\n if (v2 > 0.0) {\n return;\n }\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.zeroVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, P);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(1, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n\n return;\n }\n\n // Region AB\n const den = matrix.lengthSqrVec2(e);\n if (_ASSERT) console.assert(den > 0.0);\n matrix.combine2Vec2(P, u / den, A, v / den, B);\n const dd = matrix.distSqrVec2(Q, P);\n if (dd > radius * radius) {\n return;\n }\n\n matrix.crossNumVec2(n, 1, e);\n if (matrix.dotVec2(n, Q) - matrix.dotVec2(n, A) < 0.0) {\n matrix.negVec2(n);\n }\n matrix.normalizeVec2(n);\n\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, n);\n matrix.copyVec2(manifold.localPoint, A);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_face, 0, ContactFeatureType.e_vertex);\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { TransformValue } from \"../../common/Transform\";\nimport * as matrix from \"../../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Manifold, clipSegmentToLine, ClipVertex, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/** @internal */ const incidentEdge = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints1 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints2 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipSegmentToLineNormal = matrix.vec2(0, 0);\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const v11 = matrix.vec2(0, 0);\n/** @internal */ const v12 = matrix.vec2(0, 0);\n/** @internal */ const localTangent = matrix.vec2(0, 0);\n/** @internal */ const localNormal = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const tangent = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const normal1 = matrix.vec2(0, 0);\n\n\nContact.addType(PolygonShape.TYPE, PolygonShape.TYPE, PolygonContact);\n\n/** @internal */ function PolygonContact(\n manifold: Manifold,\n xfA: TransformValue,\n fixtureA: Fixture,\n indexA: number,\n xfB: TransformValue,\n fixtureB: Fixture,\n indexB: number,\n): void {\n if (_ASSERT) console.assert(fixtureA.getType() == PolygonShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == PolygonShape.TYPE);\n CollidePolygons(manifold, fixtureA.getShape() as PolygonShape, xfA, fixtureB.getShape() as PolygonShape, xfB);\n}\n\n/** @internal */ interface MaxSeparation {\n maxSeparation: number;\n bestIndex: number;\n}\n\n/**\n * Find the max separation between poly1 and poly2 using edge normals from\n * poly1.\n */\n/** @internal */ function findMaxSeparation(\n poly1: PolygonShape,\n xf1: TransformValue,\n poly2: PolygonShape,\n xf2: TransformValue,\n output: MaxSeparation,\n): void {\n const count1 = poly1.m_count;\n const count2 = poly2.m_count;\n const n1s = poly1.m_normals;\n const v1s = poly1.m_vertices;\n const v2s = poly2.m_vertices;\n\n matrix.detransformTransform(xf, xf2, xf1);\n\n let bestIndex = 0;\n let maxSeparation = -Infinity;\n for (let i = 0; i < count1; ++i) {\n // Get poly1 normal in frame2.\n matrix.rotVec2(n, xf.q, n1s[i]);\n matrix.transformVec2(v1, xf, v1s[i]);\n\n // Find deepest point for normal i.\n let si = Infinity;\n for (let j = 0; j < count2; ++j) {\n const sij = matrix.dotVec2(n, v2s[j]) - matrix.dotVec2(n, v1);\n if (sij < si) {\n si = sij;\n }\n }\n\n if (si > maxSeparation) {\n maxSeparation = si;\n bestIndex = i;\n }\n }\n\n // used to keep last FindMaxSeparation call values\n output.maxSeparation = maxSeparation;\n output.bestIndex = bestIndex;\n}\n\n/** @internal */ function findIncidentEdge(\n clipVertex: ClipVertex[],\n poly1: PolygonShape,\n xf1: TransformValue,\n edge1: number,\n poly2: PolygonShape,\n xf2: TransformValue,\n): void {\n const normals1 = poly1.m_normals;\n\n const count2 = poly2.m_count;\n const vertices2 = poly2.m_vertices;\n const normals2 = poly2.m_normals;\n\n if (_ASSERT) console.assert(0 <= edge1 && edge1 < poly1.m_count);\n\n // Get the normal of the reference edge in poly2's frame.\n matrix.rerotVec2(normal1, xf2.q, xf1.q, normals1[edge1]);\n\n // Find the incident edge on poly2.\n let index = 0;\n let minDot = Infinity;\n for (let i = 0; i < count2; ++i) {\n const dot = matrix.dotVec2(normal1, normals2[i]);\n if (dot < minDot) {\n minDot = dot;\n index = i;\n }\n }\n\n // Build the clip vertices for the incident edge.\n const i1 = index;\n const i2 = i1 + 1 < count2 ? i1 + 1 : 0;\n\n matrix.transformVec2(clipVertex[0].v, xf2, vertices2[i1]);\n clipVertex[0].id.setFeatures(edge1, ContactFeatureType.e_face, i1, ContactFeatureType.e_vertex);\n\n matrix.transformVec2(clipVertex[1].v, xf2, vertices2[i2]);\n clipVertex[1].id.setFeatures(edge1, ContactFeatureType.e_face, i2, ContactFeatureType.e_vertex);\n}\n\n/** @internal */ const maxSeparation = {\n maxSeparation: 0,\n bestIndex: 0,\n};\n\n/**\n *\n * Find edge normal of max separation on A - return if separating axis is found
\n * Find edge normal of max separation on B - return if separation axis is found
\n * Choose reference edge as min(minA, minB)
\n * Find incident edge
\n * Clip\n *\n * The normal points from 1 to 2\n */\nexport const CollidePolygons = function (\n manifold: Manifold,\n polyA: PolygonShape,\n xfA: TransformValue,\n polyB: PolygonShape,\n xfB: TransformValue,\n): void {\n manifold.pointCount = 0;\n const totalRadius = polyA.m_radius + polyB.m_radius;\n\n findMaxSeparation(polyA, xfA, polyB, xfB, maxSeparation);\n const edgeA = maxSeparation.bestIndex;\n const separationA = maxSeparation.maxSeparation;\n if (separationA > totalRadius)\n return;\n\n findMaxSeparation(polyB, xfB, polyA, xfA, maxSeparation);\n const edgeB = maxSeparation.bestIndex;\n const separationB = maxSeparation.maxSeparation;\n if (separationB > totalRadius)\n return;\n\n let poly1: PolygonShape; // reference polygon\n let poly2: PolygonShape; // incident polygon\n let xf1: TransformValue;\n let xf2: TransformValue;\n let edge1: number; // reference edge\n let flip: boolean;\n const k_tol = 0.1 * Settings.linearSlop;\n\n if (separationB > separationA + k_tol) {\n poly1 = polyB;\n poly2 = polyA;\n xf1 = xfB;\n xf2 = xfA;\n edge1 = edgeB;\n manifold.type = ManifoldType.e_faceB;\n flip = true;\n } else {\n poly1 = polyA;\n poly2 = polyB;\n xf1 = xfA;\n xf2 = xfB;\n edge1 = edgeA;\n manifold.type = ManifoldType.e_faceA;\n flip = false;\n }\n\n incidentEdge[0].recycle();\n incidentEdge[1].recycle();\n findIncidentEdge(incidentEdge, poly1, xf1, edge1, poly2, xf2);\n\n const count1 = poly1.m_count;\n const vertices1 = poly1.m_vertices;\n\n const iv1 = edge1;\n const iv2 = edge1 + 1 < count1 ? edge1 + 1 : 0;\n\n matrix.copyVec2(v11, vertices1[iv1]);\n matrix.copyVec2(v12, vertices1[iv2]);\n\n matrix.subVec2(localTangent, v12, v11);\n matrix.normalizeVec2(localTangent);\n\n matrix.crossVec2Num(localNormal, localTangent, 1.0);\n matrix.combine2Vec2(planePoint, 0.5, v11, 0.5, v12);\n\n matrix.rotVec2(tangent, xf1.q, localTangent);\n matrix.crossVec2Num(normal, tangent, 1.0);\n\n matrix.transformVec2(v11, xf1, v11);\n matrix.transformVec2(v12, xf1, v12);\n\n // Face offset.\n const frontOffset = matrix.dotVec2(normal, v11);\n\n // Side offsets, extended by polytope skin thickness.\n const sideOffset1 = -matrix.dotVec2(tangent, v11) + totalRadius;\n const sideOffset2 = matrix.dotVec2(tangent, v12) + totalRadius;\n\n // Clip incident edge against extruded edge1 side edges.\n clipPoints1[0].recycle();\n clipPoints1[1].recycle();\n clipPoints2[0].recycle();\n clipPoints2[1].recycle();\n\n // Clip to box side 1\n matrix.setVec2(clipSegmentToLineNormal, -tangent.x, -tangent.y);\n const np1 = clipSegmentToLine(clipPoints1, incidentEdge, clipSegmentToLineNormal, sideOffset1, iv1);\n\n if (np1 < 2) {\n return;\n }\n\n // Clip to negative box side 1\n matrix.setVec2(clipSegmentToLineNormal, tangent.x, tangent.y);\n const np2 = clipSegmentToLine(clipPoints2, clipPoints1, clipSegmentToLineNormal, sideOffset2, iv2);\n\n if (np2 < 2) {\n return;\n }\n\n // Now clipPoints2 contains the clipped points.\n matrix.copyVec2(manifold.localNormal, localNormal);\n matrix.copyVec2(manifold.localPoint, planePoint);\n\n let pointCount = 0;\n for (let i = 0; i < clipPoints2.length/* maxManifoldPoints */; ++i) {\n const separation = matrix.dotVec2(normal, clipPoints2[i].v) - frontOffset;\n\n if (separation <= totalRadius) {\n const cp = manifold.points[pointCount];\n matrix.detransformVec2(cp.localPoint, xf2, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n if (flip) {\n // Swap features\n cp.id.swapFeatures();\n }\n ++pointCount;\n }\n }\n\n manifold.pointCount = pointCount;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { EPSILON } from \"../../common/Math\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { CircleShape } from \"./CircleShape\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(PolygonShape.TYPE, CircleShape.TYPE, PolygonCircleContact);\n\n/** @internal */ function PolygonCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == PolygonShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n CollidePolygonCircle(manifold, fixtureA.getShape() as PolygonShape, xfA, fixtureB.getShape() as CircleShape, xfB);\n}\n\n/** @internal */ const cLocal = matrix.vec2(0, 0);\n/** @internal */ const faceCenter = matrix.vec2(0, 0);\n\nexport const CollidePolygonCircle = function (manifold: Manifold, polygonA: PolygonShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n // Compute circle position in the frame of the polygon.\n matrix.retransformVec2(cLocal, xfB, xfA, circleB.m_p);\n\n // Find the min separating edge.\n let normalIndex = 0;\n let separation = -Infinity;\n const radius = polygonA.m_radius + circleB.m_radius;\n const vertexCount = polygonA.m_count;\n const vertices = polygonA.m_vertices;\n const normals = polygonA.m_normals;\n\n for (let i = 0; i < vertexCount; ++i) {\n const s = matrix.dotVec2(normals[i], cLocal) - matrix.dotVec2(normals[i], vertices[i]);\n\n if (s > radius) {\n // Early out.\n return;\n }\n\n if (s > separation) {\n separation = s;\n normalIndex = i;\n }\n }\n\n // Vertices that subtend the incident face.\n const vertIndex1 = normalIndex;\n const vertIndex2 = vertIndex1 + 1 < vertexCount ? vertIndex1 + 1 : 0;\n const v1 = vertices[vertIndex1];\n const v2 = vertices[vertIndex2];\n\n // If the center is inside the polygon ...\n if (separation < EPSILON) {\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, normals[normalIndex]);\n matrix.combine2Vec2(manifold.localPoint, 0.5, v1, 0.5, v2);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n return;\n }\n\n // Compute barycentric coordinates\n // u1 = (cLocal - v1) dot (v2 - v1))\n const u1 = matrix.dotVec2(cLocal, v2) - matrix.dotVec2(cLocal, v1) - matrix.dotVec2(v1, v2) + matrix.dotVec2(v1, v1);\n // u2 = (cLocal - v2) dot (v1 - v2)\n const u2 = matrix.dotVec2(cLocal, v1) - matrix.dotVec2(cLocal, v2) - matrix.dotVec2(v2, v1) + matrix.dotVec2(v2, v2);\n if (u1 <= 0.0) {\n if (matrix.distSqrVec2(cLocal, v1) > radius * radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.subVec2(manifold.localNormal, cLocal, v1);\n matrix.normalizeVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, v1);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n } else if (u2 <= 0.0) {\n if (matrix.distSqrVec2(cLocal, v2) > radius * radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.subVec2(manifold.localNormal, cLocal, v2);\n matrix.normalizeVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, v2);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n } else {\n matrix.combine2Vec2(faceCenter, 0.5, v1, 0.5, v2);\n const separation = matrix.dotVec2(cLocal, normals[vertIndex1]) - matrix.dotVec2(faceCenter, normals[vertIndex1]);\n if (separation > radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, normals[vertIndex1]);\n matrix.copyVec2(manifold.localPoint, faceCenter);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n }\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { Manifold, clipSegmentToLine, ClipVertex, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { EdgeShape } from \"./EdgeShape\";\nimport { ChainShape } from \"./ChainShape\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_min = Math.min;\n\nContact.addType(EdgeShape.TYPE, PolygonShape.TYPE, EdgePolygonContact);\nContact.addType(ChainShape.TYPE, PolygonShape.TYPE, ChainPolygonContact);\n\n/** @internal */ function EdgePolygonContact(manifold: Manifold, xfA: TransformValue, fA: Fixture, indexA: number, xfB: TransformValue, fB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fA.getType() == EdgeShape.TYPE);\n if (_ASSERT) console.assert(fB.getType() == PolygonShape.TYPE);\n\n CollideEdgePolygon(manifold, fA.getShape() as EdgeShape, xfA, fB.getShape() as PolygonShape, xfB);\n}\n\n// reused\n/** @internal */ const edge_reuse = new EdgeShape();\n\n/** @internal */ function ChainPolygonContact(manifold: Manifold, xfA: TransformValue, fA: Fixture, indexA: number, xfB: TransformValue, fB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fA.getType() == ChainShape.TYPE);\n if (_ASSERT) console.assert(fB.getType() == PolygonShape.TYPE);\n\n const chain = fA.getShape() as ChainShape;\n chain.getChildEdge(edge_reuse, indexA);\n\n CollideEdgePolygon(manifold, edge_reuse, xfA, fB.getShape() as PolygonShape, xfB);\n}\n\n/** @internal */ enum EPAxisType {\n e_unknown = -1,\n e_edgeA = 1,\n e_edgeB = 2,\n}\n\n// unused?\n/** @internal */ enum VertexType {\n e_isolated = 0,\n e_concave = 1,\n e_convex = 2,\n}\n\n/**\n * This structure is used to keep track of the best separating axis.\n */\n/** @internal */ class EPAxis {\n type: EPAxisType;\n index: number;\n separation: number;\n}\n\n/**\n * This holds polygon B expressed in frame A.\n */\n/** @internal */ class TempPolygon {\n vertices: Vec2Value[] = []; // [Settings.maxPolygonVertices]\n normals: Vec2Value[] = []; // [Settings.maxPolygonVertices];\n count: number = 0;\n constructor() {\n for (let i = 0; i < Settings.maxPolygonVertices; i++) {\n this.vertices.push(matrix.vec2(0, 0));\n this.normals.push(matrix.vec2(0, 0));\n }\n }\n}\n\n/**\n * Reference face used for clipping\n */\n/** @internal */ class ReferenceFace {\n i1: number;\n i2: number;\n readonly v1 = matrix.vec2(0 ,0);\n readonly v2 = matrix.vec2(0 ,0);\n readonly normal = matrix.vec2(0 ,0);\n readonly sideNormal1 = matrix.vec2(0 ,0);\n sideOffset1: number;\n readonly sideNormal2 = matrix.vec2(0 ,0);\n sideOffset2: number;\n recycle() {\n matrix.zeroVec2(this.v1);\n matrix.zeroVec2(this.v2);\n matrix.zeroVec2(this.normal);\n matrix.zeroVec2(this.sideNormal1);\n matrix.zeroVec2(this.sideNormal2);\n }\n}\n\n// reused\n/** @internal */ const clipPoints1 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints2 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const ie = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const edgeAxis = new EPAxis();\n/** @internal */ const polygonAxis = new EPAxis();\n/** @internal */ const polygonBA = new TempPolygon();\n/** @internal */ const rf = new ReferenceFace();\n/** @internal */ const centroidB = matrix.vec2(0, 0);\n/** @internal */ const edge0 = matrix.vec2(0, 0);\n/** @internal */ const edge1 = matrix.vec2(0, 0);\n/** @internal */ const edge2 = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const normal0 = matrix.vec2(0, 0);\n/** @internal */ const normal1 = matrix.vec2(0, 0);\n/** @internal */ const normal2 = matrix.vec2(0, 0);\n/** @internal */ const lowerLimit = matrix.vec2(0, 0);\n/** @internal */ const upperLimit = matrix.vec2(0, 0);\n/** @internal */ const perp = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n\n/**\n * This function collides and edge and a polygon, taking into account edge\n * adjacency.\n */\nexport const CollideEdgePolygon = function (manifold: Manifold, edgeA: EdgeShape, xfA: TransformValue, polygonB: PolygonShape, xfB: TransformValue): void {\n // Algorithm:\n // 1. Classify v1 and v2\n // 2. Classify polygon centroid as front or back\n // 3. Flip normal if necessary\n // 4. Initialize normal range to [-pi, pi] about face normal\n // 5. Adjust normal range according to adjacent edges\n // 6. Visit each separating axes, only accept axes within the range\n // 7. Return if _any_ axis indicates separation\n // 8. Clip\n\n // let m_type1: VertexType;\n // let m_type2: VertexType;\n\n matrix.detransformTransform(xf, xfA, xfB);\n matrix.transformVec2(centroidB, xf, polygonB.m_centroid);\n\n const v0 = edgeA.m_vertex0;\n const v1 = edgeA.m_vertex1;\n const v2 = edgeA.m_vertex2;\n const v3 = edgeA.m_vertex3;\n\n const hasVertex0 = edgeA.m_hasVertex0;\n const hasVertex3 = edgeA.m_hasVertex3;\n\n matrix.subVec2(edge1, v2, v1);\n matrix.normalizeVec2(edge1);\n matrix.setVec2(normal1, edge1.y, -edge1.x);\n const offset1 = matrix.dotVec2(normal1, centroidB) - matrix.dotVec2(normal1, v1);\n let offset0 = 0.0;\n let offset2 = 0.0;\n let convex1 = false;\n let convex2 = false;\n\n matrix.zeroVec2(normal0);\n matrix.zeroVec2(normal2);\n\n // Is there a preceding edge?\n if (hasVertex0) {\n matrix.subVec2(edge0, v1, v0);\n matrix.normalizeVec2(edge0);\n matrix.setVec2(normal0, edge0.y, -edge0.x);\n convex1 = matrix.crossVec2Vec2(edge0, edge1) >= 0.0;\n offset0 = Vec2.dot(normal0, centroidB) - Vec2.dot(normal0, v0);\n }\n\n // Is there a following edge?\n if (hasVertex3) {\n matrix.subVec2(edge2, v3, v2);\n matrix.normalizeVec2(edge2);\n matrix.setVec2(normal2, edge2.y, -edge2.x);\n convex2 = Vec2.crossVec2Vec2(edge1, edge2) > 0.0;\n offset2 = Vec2.dot(normal2, centroidB) - Vec2.dot(normal2, v2);\n }\n\n let front: boolean;\n matrix.zeroVec2(normal);\n matrix.zeroVec2(lowerLimit);\n matrix.zeroVec2(upperLimit);\n\n // Determine front or back collision. Determine collision normal limits.\n if (hasVertex0 && hasVertex3) {\n if (convex1 && convex2) {\n front = offset0 >= 0.0 || offset1 >= 0.0 || offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else if (convex1) {\n front = offset0 >= 0.0 || (offset1 >= 0.0 && offset2 >= 0.0);\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else if (convex2) {\n front = offset2 >= 0.0 || (offset0 >= 0.0 && offset1 >= 0.0);\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n } else {\n front = offset0 >= 0.0 && offset1 >= 0.0 && offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n }\n } else if (hasVertex0) {\n if (convex1) {\n front = offset0 >= 0.0 || offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else {\n front = offset0 >= 0.0 && offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n }\n } else if (hasVertex3) {\n if (convex2) {\n front = offset1 >= 0.0 || offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal1);\n }\n } else {\n front = offset1 >= 0.0 && offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.copyVec2(upperLimit, normal1);\n }\n }\n } else {\n front = offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal1);\n }\n }\n\n // Get polygonB in frameA\n polygonBA.count = polygonB.m_count;\n for (let i = 0; i < polygonB.m_count; ++i) {\n matrix.transformVec2(polygonBA.vertices[i], xf, polygonB.m_vertices[i]);\n matrix.rotVec2(polygonBA.normals[i], xf.q, polygonB.m_normals[i]);\n }\n\n const radius = polygonB.m_radius + edgeA.m_radius;\n\n manifold.pointCount = 0;\n\n { // ComputeEdgeSeparation\n edgeAxis.type = EPAxisType.e_edgeA;\n edgeAxis.index = front ? 0 : 1;\n edgeAxis.separation = Infinity;\n\n for (let i = 0; i < polygonBA.count; ++i) {\n const v = polygonBA.vertices[i];\n const s = matrix.dotVec2(normal, v) - matrix.dotVec2(normal, v1);\n if (s < edgeAxis.separation) {\n edgeAxis.separation = s;\n }\n }\n }\n\n // If no valid normal can be found than this edge should not collide.\n // @ts-ignore todo: why we need this if here?\n if (edgeAxis.type == EPAxisType.e_unknown) {\n return;\n }\n\n if (edgeAxis.separation > radius) {\n return;\n }\n\n { // ComputePolygonSeparation\n polygonAxis.type = EPAxisType.e_unknown;\n polygonAxis.index = -1;\n polygonAxis.separation = -Infinity;\n\n matrix.setVec2(perp, -normal.y, normal.x);\n\n for (let i = 0; i < polygonBA.count; ++i) {\n matrix.scaleVec2(n, -1, polygonBA.normals[i]);\n\n const s1 = matrix.dotVec2(n, polygonBA.vertices[i]) - matrix.dotVec2(n, v1);\n const s2 = matrix.dotVec2(n, polygonBA.vertices[i]) - matrix.dotVec2(n, v2);\n const s = math_min(s1, s2);\n\n if (s > radius) {\n // No collision\n polygonAxis.type = EPAxisType.e_edgeB;\n polygonAxis.index = i;\n polygonAxis.separation = s;\n break;\n }\n\n // Adjacency\n if (matrix.dotVec2(n, perp) >= 0.0) {\n if (matrix.dotVec2(n, normal) - matrix.dotVec2(upperLimit, normal) < -Settings.angularSlop) {\n continue;\n }\n } else {\n if (matrix.dotVec2(n, normal) - matrix.dotVec2(lowerLimit, normal) < -Settings.angularSlop) {\n continue;\n }\n }\n\n if (s > polygonAxis.separation) {\n polygonAxis.type = EPAxisType.e_edgeB;\n polygonAxis.index = i;\n polygonAxis.separation = s;\n }\n }\n }\n\n if (polygonAxis.type != EPAxisType.e_unknown && polygonAxis.separation > radius) {\n return;\n }\n\n // Use hysteresis for jitter reduction.\n const k_relativeTol = 0.98;\n const k_absoluteTol = 0.001;\n\n let primaryAxis: EPAxis;\n if (polygonAxis.type == EPAxisType.e_unknown) {\n primaryAxis = edgeAxis;\n } else if (polygonAxis.separation > k_relativeTol * edgeAxis.separation + k_absoluteTol) {\n primaryAxis = polygonAxis;\n } else {\n primaryAxis = edgeAxis;\n }\n\n ie[0].recycle();\n ie[1].recycle();\n\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n manifold.type = ManifoldType.e_faceA;\n\n // Search for the polygon normal that is most anti-parallel to the edge\n // normal.\n let bestIndex = 0;\n let bestValue = matrix.dotVec2(normal, polygonBA.normals[0]);\n for (let i = 1; i < polygonBA.count; ++i) {\n const value = matrix.dotVec2(normal, polygonBA.normals[i]);\n if (value < bestValue) {\n bestValue = value;\n bestIndex = i;\n }\n }\n\n const i1 = bestIndex;\n const i2 = i1 + 1 < polygonBA.count ? i1 + 1 : 0;\n\n matrix.copyVec2(ie[0].v, polygonBA.vertices[i1]);\n ie[0].id.setFeatures(0, ContactFeatureType.e_face, i1, ContactFeatureType.e_vertex);\n\n matrix.copyVec2(ie[1].v, polygonBA.vertices[i2]);\n ie[1].id.setFeatures(0, ContactFeatureType.e_face, i2, ContactFeatureType.e_vertex);\n\n if (front) {\n rf.i1 = 0;\n rf.i2 = 1;\n matrix.copyVec2(rf.v1, v1);\n matrix.copyVec2(rf.v2, v2);\n matrix.copyVec2(rf.normal, normal1);\n } else {\n rf.i1 = 1;\n rf.i2 = 0;\n matrix.copyVec2(rf.v1, v2);\n matrix.copyVec2(rf.v2, v1);\n matrix.scaleVec2(rf.normal, -1, normal1);\n }\n } else {\n manifold.type = ManifoldType.e_faceB;\n\n matrix.copyVec2(ie[0].v, v1);\n ie[0].id.setFeatures(0, ContactFeatureType.e_vertex, primaryAxis.index, ContactFeatureType.e_face);\n\n matrix.copyVec2(ie[1].v, v2);\n ie[1].id.setFeatures(0, ContactFeatureType.e_vertex, primaryAxis.index, ContactFeatureType.e_face);\n\n rf.i1 = primaryAxis.index;\n rf.i2 = rf.i1 + 1 < polygonBA.count ? rf.i1 + 1 : 0;\n matrix.copyVec2(rf.v1, polygonBA.vertices[rf.i1]);\n matrix.copyVec2(rf.v2, polygonBA.vertices[rf.i2]);\n matrix.copyVec2(rf.normal, polygonBA.normals[rf.i1]);\n }\n\n matrix.setVec2(rf.sideNormal1, rf.normal.y, -rf.normal.x);\n matrix.setVec2(rf.sideNormal2, -rf.sideNormal1.x, -rf.sideNormal1.y);\n rf.sideOffset1 = matrix.dotVec2(rf.sideNormal1, rf.v1);\n rf.sideOffset2 = matrix.dotVec2(rf.sideNormal2, rf.v2);\n\n // Clip incident edge against extruded edge1 side edges.\n clipPoints1[0].recycle();\n clipPoints1[1].recycle();\n clipPoints2[0].recycle();\n clipPoints2[1].recycle();\n\n // Clip to box side 1\n const np1 = clipSegmentToLine(clipPoints1, ie, rf.sideNormal1, rf.sideOffset1, rf.i1);\n\n if (np1 < Settings.maxManifoldPoints) {\n return;\n }\n\n // Clip to negative box side 1\n const np2 = clipSegmentToLine(clipPoints2, clipPoints1, rf.sideNormal2, rf.sideOffset2, rf.i2);\n\n if (np2 < Settings.maxManifoldPoints) {\n return;\n }\n\n // Now clipPoints2 contains the clipped points.\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n matrix.copyVec2(manifold.localNormal, rf.normal);\n matrix.copyVec2(manifold.localPoint, rf.v1);\n } else {\n matrix.copyVec2(manifold.localNormal, polygonB.m_normals[rf.i1]);\n matrix.copyVec2(manifold.localPoint, polygonB.m_vertices[rf.i1]);\n }\n\n let pointCount = 0;\n for (let i = 0; i < Settings.maxManifoldPoints; ++i) {\n const separation = matrix.dotVec2(rf.normal, clipPoints2[i].v) - matrix.dotVec2(rf.normal, rf.v1);\n\n if (separation <= radius) {\n const cp = manifold.points[pointCount]; // ManifoldPoint\n\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n matrix.detransformVec2(cp.localPoint, xf, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n } else {\n matrix.copyVec2(cp.localPoint, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n cp.id.swapFeatures();\n }\n\n ++pointCount;\n }\n }\n\n manifold.pointCount = pointCount;\n};\n","import { CollidePolygons } from \"./collision/shape/CollidePolygon\";\nimport { Settings } from \"./Settings\";\nimport { Sweep } from \"./common/Sweep\";\nimport { DynamicTree } from \"./collision/DynamicTree\";\nimport { Manifold } from \"./collision/Manifold\";\nimport { Distance } from \"./collision/Distance\";\nimport { TimeOfImpact } from \"./collision/TimeOfImpact\";\nimport { stats } from \"./util/stats\";\n\n/** @hidden @deprecated Merged with main namespace */\nexport const internal = {\n CollidePolygons,\n Settings,\n Sweep,\n Manifold,\n Distance,\n TimeOfImpact,\n DynamicTree,\n stats\n};\n","/**\n * Stage.js 1.0.0-alpha.5\n *\n * @copyright Copyright (c) 2024 Ali Shakiba\n * @license The MIT License (MIT)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\nvar math_random = Math.random;\nvar math_sqrt = Math.sqrt;\nfunction random(min, max) {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n return min == max ? min : math_random() * (max - min) + min;\n}\nfunction wrap(num, min, max) {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n if (max > min) {\n num = (num - min) % (max - min);\n return num + (num < 0 ? max : min);\n } else {\n num = (num - max) % (min - max);\n return num + (num <= 0 ? min : max);\n }\n}\nfunction clamp(num, min, max) {\n if (num < min) {\n return min;\n } else if (num > max) {\n return max;\n } else {\n return num;\n }\n}\nfunction length(x, y) {\n return math_sqrt(x * x + y * y);\n}\nvar math = Object.create(Math);\nmath.random = random;\nmath.wrap = wrap;\nmath.clamp = clamp;\nmath.length = length;\nmath.rotate = wrap;\nmath.limit = clamp;\nvar Matrix = (\n /** @class */\n function() {\n function Matrix2(a, b, c, d, e, f) {\n this.a = 1;\n this.b = 0;\n this.c = 0;\n this.d = 1;\n this.e = 0;\n this.f = 0;\n if (typeof a === \"object\") {\n this.reset(a);\n } else {\n this.reset(a, b, c, d, e, f);\n }\n }\n Matrix2.prototype.toString = function() {\n return \"[\" + this.a + \", \" + this.b + \", \" + this.c + \", \" + this.d + \", \" + this.e + \", \" + this.f + \"]\";\n };\n Matrix2.prototype.clone = function() {\n return new Matrix2(this.a, this.b, this.c, this.d, this.e, this.f);\n };\n Matrix2.prototype.reset = function(a, b, c, d, e, f) {\n this._dirty = true;\n if (typeof a === \"object\") {\n this.a = a.a;\n this.d = a.d;\n this.b = a.b;\n this.c = a.c;\n this.e = a.e;\n this.f = a.f;\n } else {\n this.a = typeof a === \"number\" ? a : 1;\n this.b = typeof b === \"number\" ? b : 0;\n this.c = typeof c === \"number\" ? c : 0;\n this.d = typeof d === \"number\" ? d : 1;\n this.e = typeof e === \"number\" ? e : 0;\n this.f = typeof f === \"number\" ? f : 0;\n }\n return this;\n };\n Matrix2.prototype.identity = function() {\n this._dirty = true;\n this.a = 1;\n this.b = 0;\n this.c = 0;\n this.d = 1;\n this.e = 0;\n this.f = 0;\n return this;\n };\n Matrix2.prototype.rotate = function(angle) {\n if (!angle) {\n return this;\n }\n this._dirty = true;\n var u = angle ? Math.cos(angle) : 1;\n var v = angle ? Math.sin(angle) : 0;\n var a = u * this.a - v * this.b;\n var b = u * this.b + v * this.a;\n var c = u * this.c - v * this.d;\n var d = u * this.d + v * this.c;\n var e = u * this.e - v * this.f;\n var f = u * this.f + v * this.e;\n this.a = a;\n this.b = b;\n this.c = c;\n this.d = d;\n this.e = e;\n this.f = f;\n return this;\n };\n Matrix2.prototype.translate = function(x, y) {\n if (!x && !y) {\n return this;\n }\n this._dirty = true;\n this.e += x;\n this.f += y;\n return this;\n };\n Matrix2.prototype.scale = function(x, y) {\n if (!(x - 1) && !(y - 1)) {\n return this;\n }\n this._dirty = true;\n this.a *= x;\n this.b *= y;\n this.c *= x;\n this.d *= y;\n this.e *= x;\n this.f *= y;\n return this;\n };\n Matrix2.prototype.skew = function(x, y) {\n if (!x && !y) {\n return this;\n }\n this._dirty = true;\n var a = this.a + this.b * x;\n var b = this.b + this.a * y;\n var c = this.c + this.d * x;\n var d = this.d + this.c * y;\n var e = this.e + this.f * x;\n var f = this.f + this.e * y;\n this.a = a;\n this.b = b;\n this.c = c;\n this.d = d;\n this.e = e;\n this.f = f;\n return this;\n };\n Matrix2.prototype.concat = function(m) {\n this._dirty = true;\n var a = this.a * m.a + this.b * m.c;\n var b = this.b * m.d + this.a * m.b;\n var c = this.c * m.a + this.d * m.c;\n var d = this.d * m.d + this.c * m.b;\n var e = this.e * m.a + m.e + this.f * m.c;\n var f = this.f * m.d + m.f + this.e * m.b;\n this.a = a;\n this.b = b;\n this.c = c;\n this.d = d;\n this.e = e;\n this.f = f;\n return this;\n };\n Matrix2.prototype.inverse = function() {\n if (this._dirty) {\n this._dirty = false;\n if (!this.inverted) {\n this.inverted = new Matrix2();\n }\n var z = this.a * this.d - this.b * this.c;\n this.inverted.a = this.d / z;\n this.inverted.b = -this.b / z;\n this.inverted.c = -this.c / z;\n this.inverted.d = this.a / z;\n this.inverted.e = (this.c * this.f - this.e * this.d) / z;\n this.inverted.f = (this.e * this.b - this.a * this.f) / z;\n }\n return this.inverted;\n };\n Matrix2.prototype.map = function(p, q) {\n q = q || { x: 0, y: 0 };\n q.x = this.a * p.x + this.c * p.y + this.e;\n q.y = this.b * p.x + this.d * p.y + this.f;\n return q;\n };\n Matrix2.prototype.mapX = function(x, y) {\n if (typeof x === \"object\") {\n y = x.y;\n x = x.x;\n }\n return this.a * x + this.c * y + this.e;\n };\n Matrix2.prototype.mapY = function(x, y) {\n if (typeof x === \"object\") {\n y = x.y;\n x = x.x;\n }\n return this.b * x + this.d * y + this.f;\n };\n return Matrix2;\n }()\n);\nvar objectToString = Object.prototype.toString;\nfunction isFn(value) {\n var str = objectToString.call(value);\n return str === \"[object Function]\" || str === \"[object GeneratorFunction]\" || str === \"[object AsyncFunction]\";\n}\nfunction isHash(value) {\n return objectToString.call(value) === \"[object Object]\" && value.constructor === Object;\n}\nconst stats = {\n create: 0,\n tick: 0,\n node: 0,\n draw: 0,\n fps: 0\n};\nvar uid = function() {\n return Date.now().toString(36) + Math.random().toString(36).slice(2);\n};\nvar Texture = (\n /** @class */\n function() {\n function Texture2() {\n this.uid = \"texture:\" + uid();\n this.sx = 0;\n this.sy = 0;\n this.dx = 0;\n this.dy = 0;\n }\n Texture2.prototype.setSourceCoordinate = function(x, y) {\n this.sx = x;\n this.sy = y;\n };\n Texture2.prototype.setSourceDimension = function(w, h) {\n this.sw = w;\n this.sh = h;\n };\n Texture2.prototype.setDestinationCoordinate = function(x, y) {\n this.dx = x;\n this.dy = y;\n };\n Texture2.prototype.setDestinationDimension = function(w, h) {\n this.dw = w;\n this.dh = h;\n };\n Texture2.prototype.draw = function(context, x1, y1, w1, h1, x2, y2, w2, h2) {\n var sx = this.sx;\n var sy = this.sy;\n var sw = this.sw;\n var sh = this.sh;\n var dx = this.dx;\n var dy = this.dy;\n var dw = this.dw;\n var dh = this.dh;\n if (typeof x1 === \"number\" || typeof y1 === \"number\" || typeof w1 === \"number\" || typeof h1 === \"number\" || typeof x2 === \"number\" || typeof y2 === \"number\" || typeof w2 === \"number\" || typeof h2 === \"number\") {\n if (typeof x2 === \"number\" || typeof y2 === \"number\" || typeof w2 === \"number\" || typeof h2 === \"number\") {\n sx += x1;\n sy += y1;\n sw = w1 !== null && w1 !== void 0 ? w1 : sw;\n sh = h1 !== null && h1 !== void 0 ? h1 : sh;\n dx += x2;\n dy += y2;\n dw = w2 !== null && w2 !== void 0 ? w2 : dw;\n dh = h2 !== null && h2 !== void 0 ? h2 : dh;\n } else {\n dx += x1;\n dy += y1;\n dw = w1;\n dh = h1;\n }\n }\n this.drawWithNormalizedArgs(context, sx, sy, sw, sh, dx, dy, dw, dh);\n };\n return Texture2;\n }()\n);\nvar __extends$9 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar ImageTexture = (\n /** @class */\n function(_super) {\n __extends$9(ImageTexture2, _super);\n function ImageTexture2(source, pixelRatio) {\n var _this = _super.call(this) || this;\n _this._pixelRatio = 1;\n if (typeof source === \"object\") {\n _this.setSourceImage(source, pixelRatio);\n }\n return _this;\n }\n ImageTexture2.prototype.setSourceImage = function(image2, pixelRatio) {\n if (pixelRatio === void 0) {\n pixelRatio = 1;\n }\n this._source = image2;\n this._pixelRatio = pixelRatio;\n };\n ImageTexture2.prototype.getWidth = function() {\n return this._source.width / this._pixelRatio;\n };\n ImageTexture2.prototype.getHeight = function() {\n return this._source.height / this._pixelRatio;\n };\n ImageTexture2.prototype.prerender = function(context) {\n return false;\n };\n ImageTexture2.prototype.drawWithNormalizedArgs = function(context, sx, sy, sw, sh, dx, dy, dw, dh) {\n var image2 = this._source;\n if (image2 === null || typeof image2 !== \"object\") {\n return;\n }\n sw = sw !== null && sw !== void 0 ? sw : this.getWidth();\n sh = sh !== null && sh !== void 0 ? sh : this.getHeight();\n dw = dw !== null && dw !== void 0 ? dw : sw;\n dh = dh !== null && dh !== void 0 ? dh : sh;\n sx *= this._pixelRatio;\n sy *= this._pixelRatio;\n sw *= this._pixelRatio;\n sh *= this._pixelRatio;\n try {\n stats.draw++;\n context.drawImage(image2, sx, sy, sw, sh, dx, dy, dw, dh);\n } catch (ex) {\n if (!this._draw_failed) {\n console.log(\"Unable to draw: \", image2);\n console.log(ex);\n this._draw_failed = true;\n }\n }\n };\n return ImageTexture2;\n }(Texture)\n);\nvar __extends$8 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar PipeTexture = (\n /** @class */\n function(_super) {\n __extends$8(PipeTexture2, _super);\n function PipeTexture2(source) {\n var _this = _super.call(this) || this;\n _this._source = source;\n return _this;\n }\n PipeTexture2.prototype.setSourceTexture = function(texture2) {\n this._source = texture2;\n };\n PipeTexture2.prototype.getWidth = function() {\n var _a, _b;\n return (_b = (_a = this.dw) !== null && _a !== void 0 ? _a : this.sw) !== null && _b !== void 0 ? _b : this._source.getWidth();\n };\n PipeTexture2.prototype.getHeight = function() {\n var _a, _b;\n return (_b = (_a = this.dh) !== null && _a !== void 0 ? _a : this.sh) !== null && _b !== void 0 ? _b : this._source.getHeight();\n };\n PipeTexture2.prototype.prerender = function(context) {\n return this._source.prerender(context);\n };\n PipeTexture2.prototype.drawWithNormalizedArgs = function(context, sx, sy, sw, sh, dx, dy, dw, dh) {\n var texture2 = this._source;\n if (texture2 === null || typeof texture2 !== \"object\") {\n return;\n }\n texture2.draw(context, sx, sy, sw, sh, dx, dy, dw, dh);\n };\n return PipeTexture2;\n }(Texture)\n);\nvar __extends$7 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar __awaiter$1 = function(thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function(resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function(resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator$1 = function(thisArg, body) {\n var _ = { label: 0, sent: function() {\n if (t[0] & 1)\n throw t[1];\n return t[1];\n }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() {\n return this;\n }), g;\n function verb(n) {\n return function(v) {\n return step([n, v]);\n };\n }\n function step(op) {\n if (f)\n throw new TypeError(\"Generator is already executing.\");\n while (_)\n try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)\n return t;\n if (y = 0, t)\n op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0:\n case 1:\n t = op;\n break;\n case 4:\n _.label++;\n return { value: op[1], done: false };\n case 5:\n _.label++;\n y = op[1];\n op = [0];\n continue;\n case 7:\n op = _.ops.pop();\n _.trys.pop();\n continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {\n _ = 0;\n continue;\n }\n if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {\n _.label = op[1];\n break;\n }\n if (op[0] === 6 && _.label < t[1]) {\n _.label = t[1];\n t = op;\n break;\n }\n if (t && _.label < t[2]) {\n _.label = t[2];\n _.ops.push(op);\n break;\n }\n if (t[2])\n _.ops.pop();\n _.trys.pop();\n continue;\n }\n op = body.call(thisArg, _);\n } catch (e) {\n op = [6, e];\n y = 0;\n } finally {\n f = t = 0;\n }\n if (op[0] & 5)\n throw op[1];\n return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar Atlas = (\n /** @class */\n function(_super) {\n __extends$7(Atlas2, _super);\n function Atlas2(def) {\n if (def === void 0) {\n def = {};\n }\n var _this = _super.call(this) || this;\n _this.pipeSpriteTexture = function(def2) {\n var map = _this._map;\n var ppu = _this._ppu;\n var trim = _this._trim;\n if (!def2) {\n return void 0;\n }\n def2 = Object.assign({}, def2);\n if (isFn(map)) {\n def2 = map(def2);\n }\n if (ppu != 1) {\n def2.x *= ppu;\n def2.y *= ppu;\n def2.width *= ppu;\n def2.height *= ppu;\n def2.top *= ppu;\n def2.bottom *= ppu;\n def2.left *= ppu;\n def2.right *= ppu;\n }\n if (trim != 0) {\n def2.x += trim;\n def2.y += trim;\n def2.width -= 2 * trim;\n def2.height -= 2 * trim;\n def2.top -= trim;\n def2.bottom -= trim;\n def2.left -= trim;\n def2.right -= trim;\n }\n var texture2 = new PipeTexture(_this);\n texture2.top = def2.top;\n texture2.bottom = def2.bottom;\n texture2.left = def2.left;\n texture2.right = def2.right;\n texture2.setSourceCoordinate(def2.x, def2.y);\n texture2.setSourceDimension(def2.width, def2.height);\n return texture2;\n };\n _this.findSpriteDefinition = function(query) {\n var textures = _this._textures;\n if (textures) {\n if (isFn(textures)) {\n return textures(query);\n } else if (isHash(textures)) {\n return textures[query];\n }\n }\n };\n _this.select = function(query) {\n if (!query) {\n return new TextureSelection(new PipeTexture(_this));\n }\n var textureDefinition = _this.findSpriteDefinition(query);\n if (textureDefinition) {\n return new TextureSelection(textureDefinition, _this);\n }\n };\n _this.name = def.name;\n _this._ppu = def.ppu || def.ratio || 1;\n _this._trim = def.trim || 0;\n _this._map = def.map || def.filter;\n _this._textures = def.textures;\n if (typeof def.image === \"object\" && isHash(def.image)) {\n _this._imageSrc = def.image.src || def.image.url;\n if (typeof def.image.ratio === \"number\") {\n _this._pixelRatio = def.image.ratio;\n }\n } else {\n if (typeof def.imagePath === \"string\") {\n _this._imageSrc = def.imagePath;\n } else if (typeof def.image === \"string\") {\n _this._imageSrc = def.image;\n }\n if (typeof def.imageRatio === \"number\") {\n _this._pixelRatio = def.imageRatio;\n }\n }\n deprecatedWarning(def);\n return _this;\n }\n Atlas2.prototype.load = function() {\n return __awaiter$1(this, void 0, void 0, function() {\n var image2;\n return __generator$1(this, function(_a) {\n switch (_a.label) {\n case 0:\n if (!this._imageSrc)\n return [3, 2];\n return [4, asyncLoadImage(this._imageSrc)];\n case 1:\n image2 = _a.sent();\n this.setSourceImage(image2, this._pixelRatio);\n _a.label = 2;\n case 2:\n return [\n 2\n /*return*/\n ];\n }\n });\n });\n };\n return Atlas2;\n }(ImageTexture)\n);\nfunction asyncLoadImage(src) {\n return new Promise(function(resolve, reject) {\n var img = new Image();\n img.onload = function() {\n resolve(img);\n };\n img.onerror = function(error) {\n console.error(\"Loading failed: \" + src);\n reject(error);\n };\n img.src = src;\n });\n}\nfunction deprecatedWarning(def) {\n if (\"filter\" in def)\n console.warn(\"'filter' field of atlas definition is deprecated\");\n if (\"cutouts\" in def)\n console.warn(\"'cutouts' field of atlas definition is deprecated\");\n if (\"sprites\" in def)\n console.warn(\"'sprites' field of atlas definition is deprecated\");\n if (\"factory\" in def)\n console.warn(\"'factory' field of atlas definition is deprecated\");\n if (\"ratio\" in def)\n console.warn(\"'ratio' field of atlas definition is deprecated\");\n if (\"imagePath\" in def)\n console.warn(\"'imagePath' field of atlas definition is deprecated\");\n if (\"imageRatio\" in def)\n console.warn(\"'imageRatio' field of atlas definition is deprecated\");\n if (typeof def.image === \"object\" && \"url\" in def.image)\n console.warn(\"'image.url' field of atlas definition is deprecated\");\n}\nvar __extends$6 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar __awaiter = function(thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function(resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function(resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = function(thisArg, body) {\n var _ = { label: 0, sent: function() {\n if (t[0] & 1)\n throw t[1];\n return t[1];\n }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() {\n return this;\n }), g;\n function verb(n) {\n return function(v) {\n return step([n, v]);\n };\n }\n function step(op) {\n if (f)\n throw new TypeError(\"Generator is already executing.\");\n while (_)\n try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)\n return t;\n if (y = 0, t)\n op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0:\n case 1:\n t = op;\n break;\n case 4:\n _.label++;\n return { value: op[1], done: false };\n case 5:\n _.label++;\n y = op[1];\n op = [0];\n continue;\n case 7:\n op = _.ops.pop();\n _.trys.pop();\n continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {\n _ = 0;\n continue;\n }\n if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {\n _.label = op[1];\n break;\n }\n if (op[0] === 6 && _.label < t[1]) {\n _.label = t[1];\n t = op;\n break;\n }\n if (t && _.label < t[2]) {\n _.label = t[2];\n _.ops.push(op);\n break;\n }\n if (t[2])\n _.ops.pop();\n _.trys.pop();\n continue;\n }\n op = body.call(thisArg, _);\n } catch (e) {\n op = [6, e];\n y = 0;\n } finally {\n f = t = 0;\n }\n if (op[0] & 5)\n throw op[1];\n return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nfunction isAtlasSpriteDefinition(selection) {\n return typeof selection === \"object\" && isHash(selection) && \"number\" === typeof selection.width && \"number\" === typeof selection.height;\n}\nvar TextureSelection = (\n /** @class */\n function() {\n function TextureSelection2(selection, atlas2) {\n this.selection = selection;\n this.atlas = atlas2;\n }\n TextureSelection2.prototype.resolve = function(selection, subquery) {\n if (!selection) {\n return NO_TEXTURE;\n } else if (Array.isArray(selection)) {\n return this.resolve(selection[0]);\n } else if (selection instanceof Texture) {\n return selection;\n } else if (isAtlasSpriteDefinition(selection)) {\n if (!this.atlas) {\n return NO_TEXTURE;\n }\n return this.atlas.pipeSpriteTexture(selection);\n } else if (typeof selection === \"object\" && isHash(selection) && typeof subquery !== \"undefined\") {\n return this.resolve(selection[subquery]);\n } else if (typeof selection === \"function\" && isFn(selection)) {\n return this.resolve(selection(subquery));\n } else if (typeof selection === \"string\") {\n if (!this.atlas) {\n return NO_TEXTURE;\n }\n return this.resolve(this.atlas.findSpriteDefinition(selection));\n }\n };\n TextureSelection2.prototype.one = function(subquery) {\n return this.resolve(this.selection, subquery);\n };\n TextureSelection2.prototype.array = function(arr) {\n var array = Array.isArray(arr) ? arr : [];\n if (Array.isArray(this.selection)) {\n for (var i = 0; i < this.selection.length; i++) {\n array[i] = this.resolve(this.selection[i]);\n }\n } else {\n array[0] = this.resolve(this.selection);\n }\n return array;\n };\n return TextureSelection2;\n }()\n);\nvar NO_TEXTURE = new /** @class */\n(function(_super) {\n __extends$6(class_1, _super);\n function class_1() {\n var _this = _super.call(this) || this;\n _this.setSourceDimension(0, 0);\n return _this;\n }\n class_1.prototype.getWidth = function() {\n return 0;\n };\n class_1.prototype.getHeight = function() {\n return 0;\n };\n class_1.prototype.prerender = function(context) {\n return false;\n };\n class_1.prototype.drawWithNormalizedArgs = function(context, sx, sy, sw, sh, dx, dy, dw, dh) {\n };\n class_1.prototype.setSourceCoordinate = function(x, y) {\n };\n class_1.prototype.setSourceDimension = function(w, h) {\n };\n class_1.prototype.setDestinationCoordinate = function(x, y) {\n };\n class_1.prototype.setDestinationDimension = function(w, h) {\n };\n class_1.prototype.draw = function() {\n };\n return class_1;\n}(Texture))();\nvar NO_SELECTION = new TextureSelection(NO_TEXTURE);\nvar ATLAS_MEMO_BY_NAME = {};\nvar ATLAS_ARRAY = [];\nfunction atlas(def) {\n return __awaiter(this, void 0, Promise, function() {\n var atlas2;\n return __generator(this, function(_a) {\n switch (_a.label) {\n case 0:\n if (def instanceof Atlas) {\n atlas2 = def;\n } else {\n atlas2 = new Atlas(def);\n }\n if (atlas2.name) {\n ATLAS_MEMO_BY_NAME[atlas2.name] = atlas2;\n }\n ATLAS_ARRAY.push(atlas2);\n return [4, atlas2.load()];\n case 1:\n _a.sent();\n return [2, atlas2];\n }\n });\n });\n}\nfunction texture(query) {\n if (\"string\" !== typeof query) {\n return new TextureSelection(query);\n }\n var result = null;\n var colonIndex = query.indexOf(\":\");\n if (colonIndex > 0 && query.length > colonIndex + 1) {\n var atlas_1 = ATLAS_MEMO_BY_NAME[query.slice(0, colonIndex)];\n result = atlas_1 && atlas_1.select(query.slice(colonIndex + 1));\n }\n if (!result) {\n var atlas_2 = ATLAS_MEMO_BY_NAME[query];\n result = atlas_2 && atlas_2.select();\n }\n if (!result) {\n for (var i = 0; i < ATLAS_ARRAY.length; i++) {\n result = ATLAS_ARRAY[i].select(query);\n if (result) {\n break;\n }\n }\n }\n if (!result) {\n console.error(\"Texture not found: \" + query);\n result = NO_SELECTION;\n }\n return result;\n}\nvar __extends$5 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar ResizableTexture = (\n /** @class */\n function(_super) {\n __extends$5(ResizableTexture2, _super);\n function ResizableTexture2(source, mode) {\n var _this = _super.call(this) || this;\n _this._source = source;\n _this._resizeMode = mode;\n return _this;\n }\n ResizableTexture2.prototype.getWidth = function() {\n var _a;\n return (_a = this.dw) !== null && _a !== void 0 ? _a : this._source.getWidth();\n };\n ResizableTexture2.prototype.getHeight = function() {\n var _a;\n return (_a = this.dh) !== null && _a !== void 0 ? _a : this._source.getHeight();\n };\n ResizableTexture2.prototype.prerender = function(context) {\n return false;\n };\n ResizableTexture2.prototype.drawWithNormalizedArgs = function(context, sx, sy, sw, sh, dx, dy, dw, dh) {\n var texture2 = this._source;\n if (texture2 === null || typeof texture2 !== \"object\") {\n return;\n }\n var outWidth = dw;\n var outHeight = dh;\n var left = Number.isFinite(texture2.left) ? texture2.left : 0;\n var right = Number.isFinite(texture2.right) ? texture2.right : 0;\n var top = Number.isFinite(texture2.top) ? texture2.top : 0;\n var bottom = Number.isFinite(texture2.bottom) ? texture2.bottom : 0;\n var width = texture2.getWidth() - left - right;\n var height = texture2.getHeight() - top - bottom;\n if (!this._innerSize) {\n outWidth = Math.max(outWidth - left - right, 0);\n outHeight = Math.max(outHeight - top - bottom, 0);\n }\n if (top > 0 && left > 0) {\n texture2.draw(context, 0, 0, left, top, 0, 0, left, top);\n }\n if (bottom > 0 && left > 0) {\n texture2.draw(context, 0, height + top, left, bottom, 0, outHeight + top, left, bottom);\n }\n if (top > 0 && right > 0) {\n texture2.draw(context, width + left, 0, right, top, outWidth + left, 0, right, top);\n }\n if (bottom > 0 && right > 0) {\n texture2.draw(context, width + left, height + top, right, bottom, outWidth + left, outHeight + top, right, bottom);\n }\n if (this._resizeMode === \"stretch\") {\n if (top > 0) {\n texture2.draw(context, left, 0, width, top, left, 0, outWidth, top);\n }\n if (bottom > 0) {\n texture2.draw(context, left, height + top, width, bottom, left, outHeight + top, outWidth, bottom);\n }\n if (left > 0) {\n texture2.draw(context, 0, top, left, height, 0, top, left, outHeight);\n }\n if (right > 0) {\n texture2.draw(context, width + left, top, right, height, outWidth + left, top, right, outHeight);\n }\n texture2.draw(context, left, top, width, height, left, top, outWidth, outHeight);\n } else if (this._resizeMode === \"tile\") {\n var l = left;\n var r = outWidth;\n var w = void 0;\n while (r > 0) {\n w = Math.min(width, r);\n r -= width;\n var t = top;\n var b = outHeight;\n var h = void 0;\n while (b > 0) {\n h = Math.min(height, b);\n b -= height;\n texture2.draw(context, left, top, w, h, l, t, w, h);\n if (r <= 0) {\n if (left) {\n texture2.draw(context, 0, top, left, h, 0, t, left, h);\n }\n if (right) {\n texture2.draw(context, width + left, top, right, h, l + w, t, right, h);\n }\n }\n t += h;\n }\n if (top) {\n texture2.draw(context, left, 0, w, top, l, 0, w, top);\n }\n if (bottom) {\n texture2.draw(context, left, height + top, w, bottom, l, t, w, bottom);\n }\n l += w;\n }\n }\n };\n return ResizableTexture2;\n }(Texture)\n);\nfunction getPixelRatio() {\n return typeof window !== \"undefined\" ? window.devicePixelRatio || 1 : 1;\n}\nfunction isValidFitMode(value) {\n return value && (value === \"cover\" || value === \"contain\" || value === \"fill\" || value === \"in\" || value === \"in-pad\" || value === \"out\" || value === \"out-crop\");\n}\nvar iid$1 = 0;\nvar Pin = (\n /** @class */\n function() {\n function Pin2(owner) {\n this.uid = \"pin:\" + uid();\n this._owner = owner;\n this._parent = null;\n this._relativeMatrix = new Matrix();\n this._absoluteMatrix = new Matrix();\n this.reset();\n }\n Pin2.prototype.reset = function() {\n this._textureAlpha = 1;\n this._alpha = 1;\n this._width = 0;\n this._height = 0;\n this._scaleX = 1;\n this._scaleY = 1;\n this._skewX = 0;\n this._skewY = 0;\n this._rotation = 0;\n this._pivoted = false;\n this._pivotX = 0;\n this._pivotY = 0;\n this._handled = false;\n this._handleX = 0;\n this._handleY = 0;\n this._aligned = false;\n this._alignX = 0;\n this._alignY = 0;\n this._offsetX = 0;\n this._offsetY = 0;\n this._boxX = 0;\n this._boxY = 0;\n this._boxWidth = this._width;\n this._boxHeight = this._height;\n this._ts_translate = ++iid$1;\n this._ts_transform = ++iid$1;\n this._ts_matrix = ++iid$1;\n };\n Pin2.prototype._update = function() {\n this._parent = this._owner._parent && this._owner._parent._pin;\n if (this._handled && this._mo_handle != this._ts_transform) {\n this._mo_handle = this._ts_transform;\n this._ts_translate = ++iid$1;\n }\n if (this._aligned && this._parent && this._mo_align != this._parent._ts_transform) {\n this._mo_align = this._parent._ts_transform;\n this._ts_translate = ++iid$1;\n }\n return this;\n };\n Pin2.prototype.toString = function() {\n return this._owner + \" (\" + (this._parent ? this._parent._owner : null) + \")\";\n };\n Pin2.prototype.absoluteMatrix = function() {\n this._update();\n var ts = Math.max(this._ts_transform, this._ts_translate, this._parent ? this._parent._ts_matrix : 0);\n if (this._mo_abs == ts) {\n return this._absoluteMatrix;\n }\n this._mo_abs = ts;\n var abs = this._absoluteMatrix;\n abs.reset(this.relativeMatrix());\n this._parent && abs.concat(this._parent._absoluteMatrix);\n this._ts_matrix = ++iid$1;\n return abs;\n };\n Pin2.prototype.relativeMatrix = function() {\n this._update();\n var ts = Math.max(this._ts_transform, this._ts_translate, this._parent ? this._parent._ts_transform : 0);\n if (this._mo_rel == ts) {\n return this._relativeMatrix;\n }\n this._mo_rel = ts;\n var rel = this._relativeMatrix;\n rel.identity();\n if (this._pivoted) {\n rel.translate(-this._pivotX * this._width, -this._pivotY * this._height);\n }\n rel.scale(this._scaleX, this._scaleY);\n rel.skew(this._skewX, this._skewY);\n rel.rotate(this._rotation);\n if (this._pivoted) {\n rel.translate(this._pivotX * this._width, this._pivotY * this._height);\n }\n if (this._pivoted) {\n this._boxX = 0;\n this._boxY = 0;\n this._boxWidth = this._width;\n this._boxHeight = this._height;\n } else {\n var p = void 0;\n var q = void 0;\n if (rel.a > 0 && rel.c > 0 || rel.a < 0 && rel.c < 0) {\n p = 0;\n q = rel.a * this._width + rel.c * this._height;\n } else {\n p = rel.a * this._width;\n q = rel.c * this._height;\n }\n if (p > q) {\n this._boxX = q;\n this._boxWidth = p - q;\n } else {\n this._boxX = p;\n this._boxWidth = q - p;\n }\n if (rel.b > 0 && rel.d > 0 || rel.b < 0 && rel.d < 0) {\n p = 0;\n q = rel.b * this._width + rel.d * this._height;\n } else {\n p = rel.b * this._width;\n q = rel.d * this._height;\n }\n if (p > q) {\n this._boxY = q;\n this._boxHeight = p - q;\n } else {\n this._boxY = p;\n this._boxHeight = q - p;\n }\n }\n this._x = this._offsetX;\n this._y = this._offsetY;\n this._x -= this._boxX + this._handleX * this._boxWidth;\n this._y -= this._boxY + this._handleY * this._boxHeight;\n if (this._aligned && this._parent) {\n this._parent.relativeMatrix();\n this._x += this._alignX * this._parent._width;\n this._y += this._alignY * this._parent._height;\n }\n rel.translate(this._x, this._y);\n return this._relativeMatrix;\n };\n Pin2.prototype.get = function(key) {\n if (typeof getters[key] === \"function\") {\n return getters[key](this);\n }\n };\n Pin2.prototype.set = function(a, b) {\n if (typeof a === \"string\") {\n if (typeof setters[a] === \"function\" && typeof b !== \"undefined\") {\n setters[a](this, b);\n }\n } else if (typeof a === \"object\") {\n for (b in a) {\n if (typeof setters[b] === \"function\" && typeof a[b] !== \"undefined\") {\n setters[b](this, a[b], a);\n }\n }\n }\n if (this._owner) {\n this._owner._ts_pin = ++iid$1;\n this._owner.touch();\n }\n return this;\n };\n Pin2.prototype.fit = function(width, height, mode) {\n this._ts_transform = ++iid$1;\n if (mode === \"contain\") {\n mode = \"in-pad\";\n }\n if (mode === \"cover\") {\n mode = \"out-crop\";\n }\n if (typeof width === \"number\") {\n this._scaleX = width / this._unscaled_width;\n this._width = this._unscaled_width;\n }\n if (typeof height === \"number\") {\n this._scaleY = height / this._unscaled_height;\n this._height = this._unscaled_height;\n }\n if (typeof width === \"number\" && typeof height === \"number\" && typeof mode === \"string\") {\n if (mode === \"fill\")\n ;\n else if (mode === \"out\" || mode === \"out-crop\") {\n this._scaleX = this._scaleY = Math.max(this._scaleX, this._scaleY);\n } else if (mode === \"in\" || mode === \"in-pad\") {\n this._scaleX = this._scaleY = Math.min(this._scaleX, this._scaleY);\n }\n if (mode === \"out-crop\" || mode === \"in-pad\") {\n this._width = width / this._scaleX;\n this._height = height / this._scaleY;\n }\n }\n };\n return Pin2;\n }()\n);\nvar getters = {\n alpha: function(pin) {\n return pin._alpha;\n },\n textureAlpha: function(pin) {\n return pin._textureAlpha;\n },\n width: function(pin) {\n return pin._width;\n },\n height: function(pin) {\n return pin._height;\n },\n boxWidth: function(pin) {\n return pin._boxWidth;\n },\n boxHeight: function(pin) {\n return pin._boxHeight;\n },\n // scale : function(pin: Pin) {\n // },\n scaleX: function(pin) {\n return pin._scaleX;\n },\n scaleY: function(pin) {\n return pin._scaleY;\n },\n // skew : function(pin: Pin) {\n // },\n skewX: function(pin) {\n return pin._skewX;\n },\n skewY: function(pin) {\n return pin._skewY;\n },\n rotation: function(pin) {\n return pin._rotation;\n },\n // pivot : function(pin: Pin) {\n // },\n pivotX: function(pin) {\n return pin._pivotX;\n },\n pivotY: function(pin) {\n return pin._pivotY;\n },\n // offset : function(pin: Pin) {\n // },\n offsetX: function(pin) {\n return pin._offsetX;\n },\n offsetY: function(pin) {\n return pin._offsetY;\n },\n // align : function(pin: Pin) {\n // },\n alignX: function(pin) {\n return pin._alignX;\n },\n alignY: function(pin) {\n return pin._alignY;\n },\n // handle : function(pin: Pin) {\n // },\n handleX: function(pin) {\n return pin._handleX;\n },\n handleY: function(pin) {\n return pin._handleY;\n }\n};\nvar setters = {\n alpha: function(pin, value) {\n pin._alpha = value;\n },\n textureAlpha: function(pin, value) {\n pin._textureAlpha = value;\n },\n width: function(pin, value) {\n pin._unscaled_width = value;\n pin._width = value;\n pin._ts_transform = ++iid$1;\n },\n height: function(pin, value) {\n pin._unscaled_height = value;\n pin._height = value;\n pin._ts_transform = ++iid$1;\n },\n scale: function(pin, value) {\n pin._scaleX = value;\n pin._scaleY = value;\n pin._ts_transform = ++iid$1;\n },\n scaleX: function(pin, value) {\n pin._scaleX = value;\n pin._ts_transform = ++iid$1;\n },\n scaleY: function(pin, value) {\n pin._scaleY = value;\n pin._ts_transform = ++iid$1;\n },\n skew: function(pin, value) {\n pin._skewX = value;\n pin._skewY = value;\n pin._ts_transform = ++iid$1;\n },\n skewX: function(pin, value) {\n pin._skewX = value;\n pin._ts_transform = ++iid$1;\n },\n skewY: function(pin, value) {\n pin._skewY = value;\n pin._ts_transform = ++iid$1;\n },\n rotation: function(pin, value) {\n pin._rotation = value;\n pin._ts_transform = ++iid$1;\n },\n pivot: function(pin, value) {\n pin._pivotX = value;\n pin._pivotY = value;\n pin._pivoted = true;\n pin._ts_transform = ++iid$1;\n },\n pivotX: function(pin, value) {\n pin._pivotX = value;\n pin._pivoted = true;\n pin._ts_transform = ++iid$1;\n },\n pivotY: function(pin, value) {\n pin._pivotY = value;\n pin._pivoted = true;\n pin._ts_transform = ++iid$1;\n },\n offset: function(pin, value) {\n pin._offsetX = value;\n pin._offsetY = value;\n pin._ts_translate = ++iid$1;\n },\n offsetX: function(pin, value) {\n pin._offsetX = value;\n pin._ts_translate = ++iid$1;\n },\n offsetY: function(pin, value) {\n pin._offsetY = value;\n pin._ts_translate = ++iid$1;\n },\n align: function(pin, value) {\n this.alignX(pin, value);\n this.alignY(pin, value);\n },\n alignX: function(pin, value) {\n pin._alignX = value;\n pin._aligned = true;\n pin._ts_translate = ++iid$1;\n this.handleX(pin, value);\n },\n alignY: function(pin, value) {\n pin._alignY = value;\n pin._aligned = true;\n pin._ts_translate = ++iid$1;\n this.handleY(pin, value);\n },\n handle: function(pin, value) {\n this.handleX(pin, value);\n this.handleY(pin, value);\n },\n handleX: function(pin, value) {\n pin._handleX = value;\n pin._handled = true;\n pin._ts_translate = ++iid$1;\n },\n handleY: function(pin, value) {\n pin._handleY = value;\n pin._handled = true;\n pin._ts_translate = ++iid$1;\n },\n resizeMode: function(pin, value, all) {\n if (all) {\n if (value == \"in\") {\n value = \"in-pad\";\n } else if (value == \"out\") {\n value = \"out-crop\";\n }\n pin.fit(all.resizeWidth, all.resizeHeight, value);\n }\n },\n resizeWidth: function(pin, value, all) {\n if (!all || !all.resizeMode) {\n pin.fit(value, null);\n }\n },\n resizeHeight: function(pin, value, all) {\n if (!all || !all.resizeMode) {\n pin.fit(null, value);\n }\n },\n scaleMode: function(pin, value, all) {\n if (all) {\n pin.fit(all.scaleWidth, all.scaleHeight, value);\n }\n },\n scaleWidth: function(pin, value, all) {\n if (!all || !all.scaleMode) {\n pin.fit(value, null);\n }\n },\n scaleHeight: function(pin, value, all) {\n if (!all || !all.scaleMode) {\n pin.fit(null, value);\n }\n },\n matrix: function(pin, value) {\n this.scaleX(pin, value.a);\n this.skewX(pin, value.c / value.d);\n this.skewY(pin, value.b / value.a);\n this.scaleY(pin, value.d);\n this.offsetX(pin, value.e);\n this.offsetY(pin, value.f);\n this.rotation(pin, 0);\n }\n};\nfunction IDENTITY(x) {\n return x;\n}\nvar LOOKUP_CACHE = {};\nvar MODE_BY_NAME = {};\nvar EASE_BY_NAME = {};\nvar Easing = (\n /** @class */\n function() {\n function Easing2() {\n }\n Easing2.get = function(token, fallback) {\n fallback = fallback || IDENTITY;\n if (typeof token === \"function\") {\n return token;\n }\n if (typeof token !== \"string\") {\n return fallback;\n }\n var easeFn = LOOKUP_CACHE[token];\n if (easeFn) {\n return easeFn;\n }\n var tokens = /^(\\w+)(-(in|out|in-out|out-in))?(\\((.*)\\))?$/i.exec(token);\n if (!tokens || !tokens.length) {\n return fallback;\n }\n var easeName = tokens[1];\n var easing = EASE_BY_NAME[easeName];\n var modeName = tokens[3];\n var modeFn = MODE_BY_NAME[modeName];\n var params = tokens[5];\n if (!easing) {\n easeFn = fallback;\n } else if (\"fn\" in easing && typeof easing.fn === \"function\") {\n easeFn = easing.fn;\n } else if (\"fc\" in easing && typeof easing.fc === \"function\") {\n var args = params ? params.replace(/\\s+/, \"\").split(\",\") : void 0;\n easeFn = easing.fc.apply(easing.fc, args);\n } else {\n easeFn = fallback;\n }\n if (modeFn) {\n easeFn = modeFn(easeFn);\n }\n LOOKUP_CACHE[token] = easeFn;\n return easeFn;\n };\n return Easing2;\n }()\n);\nfunction addMode(name, fn) {\n MODE_BY_NAME[name] = fn;\n}\nfunction addEaseFn(data) {\n var names = data.name.split(/\\s+/);\n for (var i = 0; i < names.length; i++) {\n var key = names[i];\n if (key) {\n EASE_BY_NAME[key] = data;\n }\n }\n}\naddMode(\"in\", function(f) {\n return f;\n});\naddMode(\"out\", function(f) {\n return function(t) {\n return 1 - f(1 - t);\n };\n});\naddMode(\"in-out\", function(f) {\n return function(t) {\n return t < 0.5 ? f(2 * t) / 2 : 1 - f(2 * (1 - t)) / 2;\n };\n});\naddMode(\"out-in\", function(f) {\n return function(t) {\n return t < 0.5 ? 1 - f(2 * (1 - t)) / 2 : f(2 * t) / 2;\n };\n});\naddEaseFn({\n name: \"linear\",\n fn: function(t) {\n return t;\n }\n});\naddEaseFn({\n name: \"quad\",\n fn: function(t) {\n return t * t;\n }\n});\naddEaseFn({\n name: \"cubic\",\n fn: function(t) {\n return t * t * t;\n }\n});\naddEaseFn({\n name: \"quart\",\n fn: function(t) {\n return t * t * t * t;\n }\n});\naddEaseFn({\n name: \"quint\",\n fn: function(t) {\n return t * t * t * t * t;\n }\n});\naddEaseFn({\n name: \"sin sine\",\n fn: function(t) {\n return 1 - Math.cos(t * Math.PI / 2);\n }\n});\naddEaseFn({\n name: \"exp expo\",\n fn: function(t) {\n return t == 0 ? 0 : Math.pow(2, 10 * (t - 1));\n }\n});\naddEaseFn({\n name: \"circle circ\",\n fn: function(t) {\n return 1 - Math.sqrt(1 - t * t);\n }\n});\naddEaseFn({\n name: \"bounce\",\n fn: function(t) {\n return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + 0.75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + 0.9375 : 7.5625 * (t -= 2.625 / 2.75) * t + 0.984375;\n }\n});\naddEaseFn({\n name: \"poly\",\n fc: function(e) {\n return function(t) {\n return Math.pow(t, e);\n };\n }\n});\naddEaseFn({\n name: \"elastic\",\n fc: function(a, p) {\n p = p || 0.45;\n a = a || 1;\n var s = p / (2 * Math.PI) * Math.asin(1 / a);\n return function(t) {\n return 1 + a * Math.pow(2, -10 * t) * Math.sin((t - s) * (2 * Math.PI) / p);\n };\n }\n});\naddEaseFn({\n name: \"back\",\n fc: function(s) {\n s = typeof s !== \"undefined\" ? s : 1.70158;\n return function(t) {\n return t * t * ((s + 1) * t - s);\n };\n }\n});\nvar Transition = (\n /** @class */\n function() {\n function Transition2(owner, options) {\n if (options === void 0) {\n options = {};\n }\n this.uid = \"transition:\" + uid();\n this._ending = [];\n this._end = {};\n this._duration = options.duration || 400;\n this._delay = options.delay || 0;\n this._owner = owner;\n this._time = 0;\n }\n Transition2.prototype.tick = function(node, elapsed, now, last) {\n this._time += elapsed;\n if (this._time < this._delay) {\n return;\n }\n var time = this._time - this._delay;\n if (!this._start) {\n this._start = {};\n for (var key in this._end) {\n this._start[key] = this._owner.pin(key);\n }\n }\n var p = Math.min(time / this._duration, 1);\n var ended = p >= 1;\n if (typeof this._easing == \"function\") {\n p = this._easing(p);\n }\n var q = 1 - p;\n for (var key in this._end) {\n this._owner.pin(key, this._start[key] * q + this._end[key] * p);\n }\n return ended;\n };\n Transition2.prototype.finish = function() {\n var _this = this;\n this._ending.forEach(function(callback) {\n try {\n callback.call(_this._owner);\n } catch (e) {\n console.error(e);\n }\n });\n return this._next;\n };\n Transition2.prototype.tween = function(a, b) {\n var options;\n if (typeof a === \"object\" && a !== null) {\n options = a;\n } else {\n options = {};\n if (typeof a === \"number\") {\n options.duration = a;\n if (typeof b === \"number\") {\n options.delay = b;\n }\n }\n }\n return this._next = new Transition2(this._owner, options);\n };\n Transition2.prototype.duration = function(duration) {\n this._duration = duration;\n return this;\n };\n Transition2.prototype.delay = function(delay) {\n this._delay = delay;\n return this;\n };\n Transition2.prototype.ease = function(easing) {\n this._easing = Easing.get(easing);\n return this;\n };\n Transition2.prototype.done = function(fn) {\n this._ending.push(fn);\n return this;\n };\n Transition2.prototype.hide = function() {\n this._ending.push(function() {\n this.hide();\n });\n this._hide = true;\n return this;\n };\n Transition2.prototype.remove = function() {\n this._ending.push(function() {\n this.remove();\n });\n this._remove = true;\n return this;\n };\n Transition2.prototype.pin = function(a, b) {\n if (typeof a === \"object\") {\n for (var attr in a) {\n pinning(this._owner, this._end, attr, a[attr]);\n }\n } else if (typeof b !== \"undefined\") {\n pinning(this._owner, this._end, a, b);\n }\n return this;\n };\n Transition2.prototype.then = function(fn) {\n this.done(fn);\n return this;\n };\n Transition2.prototype.clear = function(forward) {\n return this;\n };\n Transition2.prototype.size = function(w, h) {\n this.pin(\"width\", w);\n this.pin(\"height\", h);\n return this;\n };\n Transition2.prototype.width = function(w) {\n if (typeof w === \"undefined\") {\n return this.pin(\"width\");\n }\n this.pin(\"width\", w);\n return this;\n };\n Transition2.prototype.height = function(h) {\n if (typeof h === \"undefined\") {\n return this.pin(\"height\");\n }\n this.pin(\"height\", h);\n return this;\n };\n Transition2.prototype.offset = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n }\n this.pin(\"offsetX\", a);\n this.pin(\"offsetY\", b);\n return this;\n };\n Transition2.prototype.rotate = function(a) {\n this.pin(\"rotation\", a);\n return this;\n };\n Transition2.prototype.skew = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n } else if (typeof b === \"undefined\") {\n b = a;\n }\n this.pin(\"skewX\", a);\n this.pin(\"skewY\", b);\n return this;\n };\n Transition2.prototype.scale = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n } else if (typeof b === \"undefined\") {\n b = a;\n }\n this.pin(\"scaleX\", a);\n this.pin(\"scaleY\", b);\n return this;\n };\n Transition2.prototype.alpha = function(a, ta) {\n this.pin(\"alpha\", a);\n if (typeof ta !== \"undefined\") {\n this.pin(\"textureAlpha\", ta);\n }\n return this;\n };\n return Transition2;\n }()\n);\nfunction pinning(node, map, key, value) {\n if (typeof node.pin(key) === \"number\") {\n map[key] = value;\n } else if (typeof node.pin(key + \"X\") === \"number\" && typeof node.pin(key + \"Y\") === \"number\") {\n map[key + \"X\"] = value;\n map[key + \"Y\"] = value;\n }\n}\nvar iid = 0;\nstats.create = 0;\nfunction assertType(obj) {\n if (obj && obj instanceof Node) {\n return obj;\n }\n throw \"Invalid node: \" + obj;\n}\nfunction create() {\n return layout();\n}\nfunction layer() {\n return maximize();\n}\nfunction box() {\n return minimize();\n}\nfunction layout() {\n return new Node();\n}\nfunction row(align) {\n return layout().row(align).label(\"Row\");\n}\nfunction column(align) {\n return layout().column(align).label(\"Column\");\n}\nfunction minimize() {\n return layout().minimize().label(\"Minimize\");\n}\nfunction maximize() {\n return layout().maximize().label(\"Maximize\");\n}\nvar Node = (\n /** @class */\n function() {\n function Node2() {\n var _this = this;\n this.uid = \"node:\" + uid();\n this._label = \"\";\n this._parent = null;\n this._next = null;\n this._prev = null;\n this._first = null;\n this._last = null;\n this._visible = true;\n this._alpha = 1;\n this._padding = 0;\n this._spacing = 0;\n this._pin = new Pin(this);\n this._listeners = {};\n this._attrs = {};\n this._flags = {};\n this._transitions = [];\n this._tickBefore = [];\n this._tickAfter = [];\n this.MAX_ELAPSE = Infinity;\n this._transitionTickInitied = false;\n this._transitionTickLastTime = 0;\n this._transitionTick = function(elapsed, now, last) {\n if (!_this._transitions.length) {\n return false;\n }\n var ignore = _this._transitionTickLastTime !== last;\n _this._transitionTickLastTime = now;\n if (ignore) {\n return true;\n }\n var head = _this._transitions[0];\n var ended = head.tick(_this, elapsed, now, last);\n if (ended) {\n if (head === _this._transitions[0]) {\n _this._transitions.shift();\n }\n var next = head.finish();\n if (next) {\n _this._transitions.unshift(next);\n }\n }\n return true;\n };\n stats.create++;\n }\n Node2.prototype.matrix = function(relative) {\n if (relative === void 0) {\n relative = false;\n }\n if (relative === true) {\n return this._pin.relativeMatrix();\n }\n return this._pin.absoluteMatrix();\n };\n Node2.prototype.getPixelRatio = function() {\n var _a;\n var m = (_a = this._parent) === null || _a === void 0 ? void 0 : _a.matrix();\n var pixelRatio = !m ? 1 : Math.max(Math.abs(m.a), Math.abs(m.b)) / getPixelRatio();\n return pixelRatio;\n };\n Node2.prototype.pin = function(a, b) {\n if (typeof a === \"object\") {\n this._pin.set(a);\n return this;\n } else if (typeof a === \"string\") {\n if (typeof b === \"undefined\") {\n return this._pin.get(a);\n } else {\n this._pin.set(a, b);\n return this;\n }\n } else if (typeof a === \"undefined\") {\n return this._pin;\n }\n };\n Node2.prototype.fit = function(a, b, c) {\n if (typeof a === \"object\") {\n c = b;\n b = a.y;\n a = a.x;\n }\n this._pin.fit(a, b, c);\n return this;\n };\n Node2.prototype.scaleTo = function(a, b, c) {\n return this.fit(a, b, c);\n };\n Node2.prototype.toString = function() {\n return \"[\" + this._label + \"]\";\n };\n Node2.prototype.id = function(id) {\n return this.label(id);\n };\n Node2.prototype.label = function(label) {\n if (typeof label === \"undefined\") {\n return this._label;\n }\n this._label = label;\n return this;\n };\n Node2.prototype.attr = function(name, value) {\n if (typeof value === \"undefined\") {\n return this._attrs !== null ? this._attrs[name] : void 0;\n }\n (this._attrs !== null ? this._attrs : this._attrs = {})[name] = value;\n return this;\n };\n Node2.prototype.visible = function(visible) {\n if (typeof visible === \"undefined\") {\n return this._visible;\n }\n this._visible = visible;\n this._parent && (this._parent._ts_children = ++iid);\n this._ts_pin = ++iid;\n this.touch();\n return this;\n };\n Node2.prototype.hide = function() {\n this.visible(false);\n return this;\n };\n Node2.prototype.show = function() {\n this.visible(true);\n return this;\n };\n Node2.prototype.parent = function() {\n return this._parent;\n };\n Node2.prototype.next = function(visible) {\n var next = this._next;\n while (next && visible && !next._visible) {\n next = next._next;\n }\n return next;\n };\n Node2.prototype.prev = function(visible) {\n var prev = this._prev;\n while (prev && visible && !prev._visible) {\n prev = prev._prev;\n }\n return prev;\n };\n Node2.prototype.first = function(visible) {\n var next = this._first;\n while (next && visible && !next._visible) {\n next = next._next;\n }\n return next;\n };\n Node2.prototype.last = function(visible) {\n var prev = this._last;\n while (prev && visible && !prev._visible) {\n prev = prev._prev;\n }\n return prev;\n };\n Node2.prototype.visit = function(visitor, payload) {\n var reverse = visitor.reverse;\n var visible = visitor.visible;\n if (visitor.start && visitor.start(this, payload)) {\n return;\n }\n var child;\n var next = reverse ? this.last(visible) : this.first(visible);\n while (child = next) {\n next = reverse ? child.prev(visible) : child.next(visible);\n if (child.visit(visitor, payload)) {\n return true;\n }\n }\n return visitor.end && visitor.end(this, payload);\n };\n Node2.prototype.append = function(child, more) {\n if (Array.isArray(child)) {\n for (var i = 0; i < child.length; i++) {\n Node2.append(this, child[i]);\n }\n } else if (typeof more !== \"undefined\") {\n for (var i = 0; i < arguments.length; i++) {\n Node2.append(this, arguments[i]);\n }\n } else if (typeof child !== \"undefined\")\n Node2.append(this, child);\n return this;\n };\n Node2.prototype.prepend = function(child, more) {\n if (Array.isArray(child)) {\n for (var i = child.length - 1; i >= 0; i--) {\n Node2.prepend(this, child[i]);\n }\n } else if (typeof more !== \"undefined\") {\n for (var i = arguments.length - 1; i >= 0; i--) {\n Node2.prepend(this, arguments[i]);\n }\n } else if (typeof child !== \"undefined\")\n Node2.prepend(this, child);\n return this;\n };\n Node2.prototype.appendTo = function(parent) {\n Node2.append(parent, this);\n return this;\n };\n Node2.prototype.prependTo = function(parent) {\n Node2.prepend(parent, this);\n return this;\n };\n Node2.prototype.insertNext = function(sibling, more) {\n if (Array.isArray(sibling)) {\n for (var i = 0; i < sibling.length; i++) {\n Node2.insertAfter(sibling[i], this);\n }\n } else if (typeof more !== \"undefined\") {\n for (var i = 0; i < arguments.length; i++) {\n Node2.insertAfter(arguments[i], this);\n }\n } else if (typeof sibling !== \"undefined\") {\n Node2.insertAfter(sibling, this);\n }\n return this;\n };\n Node2.prototype.insertPrev = function(sibling, more) {\n if (Array.isArray(sibling)) {\n for (var i = sibling.length - 1; i >= 0; i--) {\n Node2.insertBefore(sibling[i], this);\n }\n } else if (typeof more !== \"undefined\") {\n for (var i = arguments.length - 1; i >= 0; i--) {\n Node2.insertBefore(arguments[i], this);\n }\n } else if (typeof sibling !== \"undefined\") {\n Node2.insertBefore(sibling, this);\n }\n return this;\n };\n Node2.prototype.insertAfter = function(prev) {\n Node2.insertAfter(this, prev);\n return this;\n };\n Node2.prototype.insertBefore = function(next) {\n Node2.insertBefore(this, next);\n return this;\n };\n Node2.append = function(parent, child) {\n assertType(child);\n assertType(parent);\n child.remove();\n if (parent._last) {\n parent._last._next = child;\n child._prev = parent._last;\n }\n child._parent = parent;\n parent._last = child;\n if (!parent._first) {\n parent._first = child;\n }\n child._parent._flag(child, true);\n child._ts_parent = ++iid;\n parent._ts_children = ++iid;\n parent.touch();\n };\n Node2.prepend = function(parent, child) {\n assertType(child);\n assertType(parent);\n child.remove();\n if (parent._first) {\n parent._first._prev = child;\n child._next = parent._first;\n }\n child._parent = parent;\n parent._first = child;\n if (!parent._last) {\n parent._last = child;\n }\n child._parent._flag(child, true);\n child._ts_parent = ++iid;\n parent._ts_children = ++iid;\n parent.touch();\n };\n Node2.insertBefore = function(self, next) {\n assertType(self);\n assertType(next);\n self.remove();\n var parent = next._parent;\n var prev = next._prev;\n if (!parent) {\n return;\n }\n next._prev = self;\n prev && (prev._next = self) || parent && (parent._first = self);\n self._parent = parent;\n self._prev = prev;\n self._next = next;\n self._parent._flag(self, true);\n self._ts_parent = ++iid;\n self.touch();\n };\n Node2.insertAfter = function(self, prev) {\n assertType(self);\n assertType(prev);\n self.remove();\n var parent = prev._parent;\n var next = prev._next;\n if (!parent) {\n return;\n }\n prev._next = self;\n next && (next._prev = self) || parent && (parent._last = self);\n self._parent = parent;\n self._prev = prev;\n self._next = next;\n self._parent._flag(self, true);\n self._ts_parent = ++iid;\n self.touch();\n };\n Node2.prototype.remove = function(child, more) {\n if (typeof child !== \"undefined\") {\n if (Array.isArray(child)) {\n for (var i = 0; i < child.length; i++) {\n assertType(child[i]).remove();\n }\n } else if (typeof more !== \"undefined\") {\n for (var i = 0; i < arguments.length; i++) {\n assertType(arguments[i]).remove();\n }\n } else {\n assertType(child).remove();\n }\n return this;\n }\n if (this._prev) {\n this._prev._next = this._next;\n }\n if (this._next) {\n this._next._prev = this._prev;\n }\n if (this._parent) {\n if (this._parent._first === this) {\n this._parent._first = this._next;\n }\n if (this._parent._last === this) {\n this._parent._last = this._prev;\n }\n this._parent._flag(this, false);\n this._parent._ts_children = ++iid;\n this._parent.touch();\n }\n this._prev = this._next = this._parent = null;\n this._ts_parent = ++iid;\n return this;\n };\n Node2.prototype.empty = function() {\n var child = null;\n var next = this._first;\n while (child = next) {\n next = child._next;\n child._prev = child._next = child._parent = null;\n this._flag(child, false);\n }\n this._first = this._last = null;\n this._ts_children = ++iid;\n this.touch();\n return this;\n };\n Node2.prototype.touch = function() {\n this._ts_touch = ++iid;\n this._parent && this._parent.touch();\n return this;\n };\n Node2.prototype._flag = function(key, value) {\n if (typeof value === \"undefined\") {\n return this._flags !== null && this._flags[key] || 0;\n }\n if (typeof key === \"string\") {\n if (value) {\n this._flags = this._flags || {};\n if (!this._flags[key] && this._parent) {\n this._parent._flag(key, true);\n }\n this._flags[key] = (this._flags[key] || 0) + 1;\n } else if (this._flags && this._flags[key] > 0) {\n if (this._flags[key] == 1 && this._parent) {\n this._parent._flag(key, false);\n }\n this._flags[key] = this._flags[key] - 1;\n }\n }\n if (typeof key === \"object\") {\n if (key._flags) {\n for (var type in key._flags) {\n if (key._flags[type] > 0) {\n this._flag(type, value);\n }\n }\n }\n }\n return this;\n };\n Node2.prototype.hitTest = function(hit) {\n var width = this._pin._width;\n var height = this._pin._height;\n return hit.x >= 0 && hit.x <= width && hit.y >= 0 && hit.y <= height;\n };\n Node2.prototype.prerender = function() {\n if (!this._visible) {\n return;\n }\n var child;\n var next = this._first;\n while (child = next) {\n next = child._next;\n child.prerender();\n }\n };\n Node2.prototype.render = function(context) {\n if (!this._visible) {\n return;\n }\n stats.node++;\n var m = this.matrix();\n context.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);\n this._alpha = this._pin._alpha * (this._parent ? this._parent._alpha : 1);\n var alpha = this._pin._textureAlpha * this._alpha;\n if (context.globalAlpha != alpha) {\n context.globalAlpha = alpha;\n }\n if (this._textures) {\n for (var i = 0, n = this._textures.length; i < n; i++) {\n this._textures[i].draw(context);\n }\n }\n if (context.globalAlpha != this._alpha) {\n context.globalAlpha = this._alpha;\n }\n var child;\n var next = this._first;\n while (child = next) {\n next = child._next;\n child.render(context);\n }\n };\n Node2.prototype._tick = function(elapsed, now, last) {\n if (!this._visible) {\n return;\n }\n if (elapsed > this.MAX_ELAPSE) {\n elapsed = this.MAX_ELAPSE;\n }\n var ticked = false;\n if (this._tickBefore !== null) {\n for (var i = 0; i < this._tickBefore.length; i++) {\n stats.tick++;\n var tickFn = this._tickBefore[i];\n ticked = tickFn.call(this, elapsed, now, last) === true || ticked;\n }\n }\n var child;\n var next = this._first;\n while (child = next) {\n next = child._next;\n if (child._flag(\"_tick\")) {\n ticked = child._tick(elapsed, now, last) === true ? true : ticked;\n }\n }\n if (this._tickAfter !== null) {\n for (var i = 0; i < this._tickAfter.length; i++) {\n stats.tick++;\n var tickFn = this._tickAfter[i];\n ticked = tickFn.call(this, elapsed, now, last) === true || ticked;\n }\n }\n return ticked;\n };\n Node2.prototype.tick = function(callback, before) {\n var _a, _b;\n if (before === void 0) {\n before = false;\n }\n if (typeof callback !== \"function\") {\n return;\n }\n if (before) {\n if (this._tickBefore === null) {\n this._tickBefore = [];\n }\n this._tickBefore.push(callback);\n } else {\n if (this._tickAfter === null) {\n this._tickAfter = [];\n }\n this._tickAfter.push(callback);\n }\n var hasTickListener = ((_a = this._tickAfter) === null || _a === void 0 ? void 0 : _a.length) > 0 || ((_b = this._tickBefore) === null || _b === void 0 ? void 0 : _b.length) > 0;\n this._flag(\"_tick\", hasTickListener);\n };\n Node2.prototype.untick = function(callback) {\n if (typeof callback !== \"function\") {\n return;\n }\n var i;\n if (this._tickBefore !== null && (i = this._tickBefore.indexOf(callback)) >= 0) {\n this._tickBefore.splice(i, 1);\n }\n if (this._tickAfter !== null && (i = this._tickAfter.indexOf(callback)) >= 0) {\n this._tickAfter.splice(i, 1);\n }\n };\n Node2.prototype.timeout = function(callback, time) {\n this.setTimeout(callback, time);\n };\n Node2.prototype.setTimeout = function(callback, time) {\n function timer(t) {\n if ((time -= t) < 0) {\n this.untick(timer);\n callback.call(this);\n } else {\n return true;\n }\n }\n this.tick(timer);\n return timer;\n };\n Node2.prototype.clearTimeout = function(timer) {\n this.untick(timer);\n };\n Node2.prototype.on = function(type, listener) {\n if (!type || !type.length || typeof listener !== \"function\") {\n return this;\n }\n if (typeof type !== \"string\" && typeof type.join === \"function\") {\n for (var i = 0; i < type.length; i++) {\n this.on(type[i], listener);\n }\n } else if (typeof type === \"string\" && type.indexOf(\" \") > -1) {\n type = type.match(/\\S+/g);\n for (var i = 0; i < type.length; i++) {\n this._on(type[i], listener);\n }\n } else if (typeof type === \"string\") {\n this._on(type, listener);\n } else\n ;\n return this;\n };\n Node2.prototype._on = function(type, listener) {\n if (typeof type !== \"string\" && typeof listener !== \"function\") {\n return;\n }\n this._listeners[type] = this._listeners[type] || [];\n this._listeners[type].push(listener);\n this._flag(type, true);\n };\n Node2.prototype.off = function(type, listener) {\n if (!type || !type.length || typeof listener !== \"function\") {\n return this;\n }\n if (typeof type !== \"string\" && typeof type.join === \"function\") {\n for (var i = 0; i < type.length; i++) {\n this.off(type[i], listener);\n }\n } else if (typeof type === \"string\" && type.indexOf(\" \") > -1) {\n type = type.match(/\\S+/g);\n for (var i = 0; i < type.length; i++) {\n this._off(type[i], listener);\n }\n } else if (typeof type === \"string\") {\n this._off(type, listener);\n } else\n ;\n return this;\n };\n Node2.prototype._off = function(type, listener) {\n if (typeof type !== \"string\" && typeof listener !== \"function\") {\n return;\n }\n var listeners = this._listeners[type];\n if (!listeners || !listeners.length) {\n return;\n }\n var index = listeners.indexOf(listener);\n if (index >= 0) {\n listeners.splice(index, 1);\n this._flag(type, false);\n }\n };\n Node2.prototype.listeners = function(type) {\n return this._listeners[type];\n };\n Node2.prototype.publish = function(name, args) {\n var listeners = this.listeners(name);\n if (!listeners || !listeners.length) {\n return 0;\n }\n for (var l = 0; l < listeners.length; l++) {\n listeners[l].apply(this, args);\n }\n return listeners.length;\n };\n Node2.prototype.trigger = function(name, args) {\n this.publish(name, args);\n return this;\n };\n Node2.prototype.size = function(w, h) {\n this.pin(\"width\", w);\n this.pin(\"height\", h);\n return this;\n };\n Node2.prototype.width = function(w) {\n if (typeof w === \"undefined\") {\n return this.pin(\"width\");\n }\n this.pin(\"width\", w);\n return this;\n };\n Node2.prototype.height = function(h) {\n if (typeof h === \"undefined\") {\n return this.pin(\"height\");\n }\n this.pin(\"height\", h);\n return this;\n };\n Node2.prototype.offset = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n }\n this.pin(\"offsetX\", a);\n this.pin(\"offsetY\", b);\n return this;\n };\n Node2.prototype.rotate = function(a) {\n this.pin(\"rotation\", a);\n return this;\n };\n Node2.prototype.skew = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n } else if (typeof b === \"undefined\")\n b = a;\n this.pin(\"skewX\", a);\n this.pin(\"skewY\", b);\n return this;\n };\n Node2.prototype.scale = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n } else if (typeof b === \"undefined\")\n b = a;\n this.pin(\"scaleX\", a);\n this.pin(\"scaleY\", b);\n return this;\n };\n Node2.prototype.alpha = function(a, ta) {\n this.pin(\"alpha\", a);\n if (typeof ta !== \"undefined\") {\n this.pin(\"textureAlpha\", ta);\n }\n return this;\n };\n Node2.prototype.tween = function(a, b, c) {\n var options;\n if (typeof a === \"object\" && a !== null) {\n options = a;\n } else {\n options = {};\n if (typeof a === \"number\") {\n options.duration = a;\n if (typeof b === \"number\") {\n options.delay = b;\n if (typeof c === \"boolean\") {\n options.append = c;\n }\n } else if (typeof b === \"boolean\") {\n options.append = b;\n }\n } else if (typeof a === \"boolean\") {\n options.append = a;\n }\n }\n if (!this._transitionTickInitied) {\n this.tick(this._transitionTick, true);\n this._transitionTickInitied = true;\n }\n this.touch();\n if (!options.append) {\n this._transitions.length = 0;\n }\n var transition = new Transition(this, options);\n this._transitions.push(transition);\n return transition;\n };\n Node2.prototype.row = function(align) {\n this.align(\"row\", align);\n return this;\n };\n Node2.prototype.column = function(align) {\n this.align(\"column\", align);\n return this;\n };\n Node2.prototype.align = function(type, align) {\n var _this = this;\n this._padding = this._padding;\n this._spacing = this._spacing;\n this._layoutTicker && this.untick(this._layoutTicker);\n this.tick(this._layoutTicker = function() {\n if (_this._mo_seq == _this._ts_touch) {\n return;\n }\n _this._mo_seq = _this._ts_touch;\n var alignChildren = _this._mo_seqAlign != _this._ts_children;\n _this._mo_seqAlign = _this._ts_children;\n var width = 0;\n var height = 0;\n var child;\n var next = _this.first(true);\n var first = true;\n while (child = next) {\n next = child.next(true);\n child.matrix(true);\n var w = child.pin(\"boxWidth\");\n var h = child.pin(\"boxHeight\");\n if (type == \"column\") {\n !first && (height += _this._spacing);\n child.pin(\"offsetY\") != height && child.pin(\"offsetY\", height);\n width = Math.max(width, w);\n height = height + h;\n alignChildren && child.pin(\"alignX\", align);\n } else if (type == \"row\") {\n !first && (width += _this._spacing);\n child.pin(\"offsetX\") != width && child.pin(\"offsetX\", width);\n width = width + w;\n height = Math.max(height, h);\n alignChildren && child.pin(\"alignY\", align);\n }\n first = false;\n }\n width += 2 * _this._padding;\n height += 2 * _this._padding;\n _this.pin(\"width\") != width && _this.pin(\"width\", width);\n _this.pin(\"height\") != height && _this.pin(\"height\", height);\n });\n return this;\n };\n Node2.prototype.box = function() {\n return this.minimize();\n };\n Node2.prototype.layer = function() {\n return this.maximize();\n };\n Node2.prototype.minimize = function() {\n var _this = this;\n this._padding = this._padding;\n this._layoutTicker && this.untick(this._layoutTicker);\n this.tick(this._layoutTicker = function() {\n if (_this._mo_box == _this._ts_touch) {\n return;\n }\n _this._mo_box = _this._ts_touch;\n var width = 0;\n var height = 0;\n var child;\n var next = _this.first(true);\n while (child = next) {\n next = child.next(true);\n child.matrix(true);\n var w = child.pin(\"boxWidth\");\n var h = child.pin(\"boxHeight\");\n width = Math.max(width, w);\n height = Math.max(height, h);\n }\n width += 2 * _this._padding;\n height += 2 * _this._padding;\n _this.pin(\"width\") != width && _this.pin(\"width\", width);\n _this.pin(\"height\") != height && _this.pin(\"height\", height);\n });\n return this;\n };\n Node2.prototype.maximize = function() {\n var _this = this;\n this._layoutTicker && this.untick(this._layoutTicker);\n this.tick(this._layoutTicker = function() {\n var parent = _this.parent();\n if (parent) {\n var width = parent.pin(\"width\");\n if (_this.pin(\"width\") != width) {\n _this.pin(\"width\", width);\n }\n var height = parent.pin(\"height\");\n if (_this.pin(\"height\") != height) {\n _this.pin(\"height\", height);\n }\n }\n }, true);\n return this;\n };\n Node2.prototype.padding = function(pad) {\n this._padding = pad;\n return this;\n };\n Node2.prototype.spacing = function(space) {\n this._spacing = space;\n return this;\n };\n return Node2;\n }()\n);\nvar __extends$4 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nfunction sprite(frame) {\n var sprite2 = new Sprite();\n frame && sprite2.texture(frame);\n return sprite2;\n}\nvar Sprite = (\n /** @class */\n function(_super) {\n __extends$4(Sprite2, _super);\n function Sprite2() {\n var _this = _super.call(this) || this;\n _this._tiled = false;\n _this._stretched = false;\n _this.prerenderContext = {};\n _this.label(\"Sprite\");\n _this._textures = [];\n _this._image = null;\n return _this;\n }\n Sprite2.prototype.texture = function(frame) {\n this._image = texture(frame).one();\n if (this._image) {\n this.pin(\"width\", this._image.getWidth());\n this.pin(\"height\", this._image.getHeight());\n if (this._tiled) {\n this._textures[0] = new ResizableTexture(this._image, \"tile\");\n } else if (this._stretched) {\n this._textures[0] = new ResizableTexture(this._image, \"stretch\");\n } else {\n this._textures[0] = new PipeTexture(this._image);\n }\n this._textures.length = 1;\n } else {\n this.pin(\"width\", 0);\n this.pin(\"height\", 0);\n this._textures.length = 0;\n }\n return this;\n };\n Sprite2.prototype.image = function(frame) {\n return this.texture(frame);\n };\n Sprite2.prototype.tile = function(inner) {\n this._tiled = true;\n var texture2 = new ResizableTexture(this._image, \"tile\");\n this._textures[0] = texture2;\n return this;\n };\n Sprite2.prototype.stretch = function(inner) {\n this._stretched = true;\n var texture2 = new ResizableTexture(this._image, \"stretch\");\n this._textures[0] = texture2;\n return this;\n };\n Sprite2.prototype.prerender = function() {\n if (!this._visible) {\n return;\n }\n if (this._image) {\n var pixelRatio = this.getPixelRatio();\n this.prerenderContext.pixelRatio = pixelRatio;\n var updated = this._image.prerender(this.prerenderContext);\n if (updated === true) {\n var w = this._image.getWidth();\n var h = this._image.getHeight();\n this.size(w, h);\n }\n }\n _super.prototype.prerender.call(this);\n };\n Sprite2.prototype.render = function(context) {\n var texture2 = this._textures[0];\n if (texture2 === null || texture2 === void 0 ? void 0 : texture2[\"_resizeMode\"]) {\n texture2.dw = this.pin(\"width\");\n texture2.dh = this.pin(\"height\");\n }\n _super.prototype.render.call(this, context);\n };\n return Sprite2;\n }(Node)\n);\nvar image = sprite;\nvar Image$1 = Sprite;\nvar __extends$3 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar CanvasTexture = (\n /** @class */\n function(_super) {\n __extends$3(CanvasTexture2, _super);\n function CanvasTexture2() {\n var _this = _super.call(this, document.createElement(\"canvas\")) || this;\n _this._lastPixelRatio = 0;\n return _this;\n }\n CanvasTexture2.prototype.setSize = function(textureWidth, textureHeight, pixelRatio) {\n if (pixelRatio === void 0) {\n pixelRatio = 1;\n }\n this._source.width = textureWidth * pixelRatio;\n this._source.height = textureHeight * pixelRatio;\n this._pixelRatio = pixelRatio;\n };\n CanvasTexture2.prototype.getContext = function(type, attributes) {\n if (type === void 0) {\n type = \"2d\";\n }\n return this._source.getContext(type, attributes);\n };\n CanvasTexture2.prototype.getOptimalPixelRatio = function() {\n return Math.ceil(this._lastPixelRatio);\n };\n CanvasTexture2.prototype.setMemoizer = function(memoizer) {\n this._memoizer = memoizer;\n };\n CanvasTexture2.prototype.setDrawer = function(drawer) {\n this._drawer = drawer;\n };\n CanvasTexture2.prototype.prerender = function(context) {\n var newPixelRatio = context.pixelRatio;\n var lastPixelRatio = this._lastPixelRatio;\n var pixelRationChange = lastPixelRatio / newPixelRatio;\n var pixelRatioChanged = lastPixelRatio === 0 || pixelRationChange > 1.25 || pixelRationChange < 0.8;\n if (pixelRatioChanged) {\n this._lastPixelRatio = newPixelRatio;\n }\n var newMemoKey = this._memoizer ? this._memoizer.call(this) : null;\n var memoKeyChanged = this._lastMemoKey !== newMemoKey;\n if (pixelRatioChanged || memoKeyChanged) {\n this._lastMemoKey = newMemoKey;\n this._lastPixelRatio = newPixelRatio;\n if (typeof this._drawer === \"function\") {\n this._drawer.call(this);\n }\n return true;\n }\n };\n CanvasTexture2.prototype.size = function(width, height, pixelRatio) {\n this.setSize(width, height, pixelRatio);\n return this;\n };\n CanvasTexture2.prototype.context = function(type, attributes) {\n if (type === void 0) {\n type = \"2d\";\n }\n return this.getContext(type, attributes);\n };\n CanvasTexture2.prototype.canvas = function(legacyTextureDrawer) {\n if (typeof legacyTextureDrawer === \"function\") {\n legacyTextureDrawer.call(this, this.getContext());\n } else if (typeof legacyTextureDrawer === \"undefined\") {\n if (typeof this._drawer === \"function\") {\n this._drawer.call(this);\n }\n }\n return this;\n };\n return CanvasTexture2;\n }(ImageTexture)\n);\nfunction canvas(type, attributes, legacyTextureDrawer) {\n if (typeof type === \"function\") {\n var texture_1 = new CanvasTexture();\n legacyTextureDrawer = type;\n texture_1.setDrawer(function() {\n legacyTextureDrawer.call(texture_1, texture_1.getContext());\n });\n return texture_1;\n } else if (typeof attributes === \"function\") {\n var texture_2 = new CanvasTexture();\n legacyTextureDrawer = attributes;\n texture_2.setDrawer(function() {\n legacyTextureDrawer.call(texture_2, texture_2.getContext(type));\n });\n return texture_2;\n } else if (typeof legacyTextureDrawer === \"function\") {\n var texture_3 = new CanvasTexture();\n texture_3.setDrawer(function() {\n legacyTextureDrawer.call(texture_3, texture_3.getContext(type, attributes));\n });\n return texture_3;\n } else {\n var texture2 = new CanvasTexture();\n return texture2;\n }\n}\nfunction memoizeDraw(legacySpriteDrawer, legacySpriteMemoizer) {\n if (legacySpriteMemoizer === void 0) {\n legacySpriteMemoizer = function() {\n return null;\n };\n }\n var sprite2 = new Sprite();\n var texture2 = new CanvasTexture();\n sprite2.texture(texture2);\n texture2.setDrawer(function() {\n legacySpriteDrawer(2.5 * texture2._lastPixelRatio, texture2, sprite2);\n });\n texture2.setMemoizer(legacySpriteMemoizer);\n return sprite2;\n}\nvar POINTER_CLICK = \"click\";\nvar POINTER_START = \"touchstart mousedown\";\nvar POINTER_MOVE = \"touchmove mousemove\";\nvar POINTER_END = \"touchend mouseup\";\nvar POINTER_CANCEL = \"touchcancel mousecancel\";\nvar EventPoint = (\n /** @class */\n function() {\n function EventPoint2() {\n }\n EventPoint2.prototype.clone = function(obj) {\n if (obj) {\n obj.x = this.x;\n obj.y = this.y;\n } else {\n obj = {\n x: this.x,\n y: this.y\n };\n }\n return obj;\n };\n EventPoint2.prototype.toString = function() {\n return (this.x | 0) + \"x\" + (this.y | 0);\n };\n return EventPoint2;\n }()\n);\nvar PointerSyntheticEvent = (\n /** @class */\n function() {\n function PointerSyntheticEvent2() {\n this.abs = new EventPoint();\n }\n PointerSyntheticEvent2.prototype.clone = function(obj) {\n if (obj) {\n obj.x = this.x;\n obj.y = this.y;\n } else {\n obj = {\n x: this.x,\n y: this.y\n };\n }\n return obj;\n };\n PointerSyntheticEvent2.prototype.toString = function() {\n return this.type + \": \" + (this.x | 0) + \"x\" + (this.y | 0);\n };\n return PointerSyntheticEvent2;\n }()\n);\nvar VisitPayload = (\n /** @class */\n function() {\n function VisitPayload2() {\n this.type = \"\";\n this.x = 0;\n this.y = 0;\n this.timeStamp = -1;\n this.event = null;\n this.root = null;\n this.collected = null;\n }\n VisitPayload2.prototype.toString = function() {\n return this.type + \": \" + (this.x | 0) + \"x\" + (this.y | 0);\n };\n return VisitPayload2;\n }()\n);\nvar syntheticEvent = new PointerSyntheticEvent();\nvar PAYLOAD = new VisitPayload();\nvar Pointer = (\n /** @class */\n function() {\n function Pointer2() {\n var _this = this;\n this.ratio = 1;\n this.clickList = [];\n this.cancelList = [];\n this.handleStart = function(event) {\n event.preventDefault();\n _this.localPoint(event);\n _this.dispatchEvent(event.type, event);\n _this.findTargets(\"click\", _this.clickList);\n _this.findTargets(\"mousecancel\", _this.cancelList);\n };\n this.handleMove = function(event) {\n event.preventDefault();\n _this.localPoint(event);\n _this.dispatchEvent(event.type, event);\n };\n this.handleEnd = function(event) {\n event.preventDefault();\n _this.dispatchEvent(event.type, event);\n if (_this.clickList.length) {\n _this.dispatchEvent(\"click\", event, _this.clickList);\n }\n _this.cancelList.length = 0;\n };\n this.handleCancel = function(event) {\n if (_this.cancelList.length) {\n _this.dispatchEvent(\"mousecancel\", event, _this.cancelList);\n }\n _this.clickList.length = 0;\n };\n this.visitStart = function(node, payload) {\n return !node._flag(payload.type);\n };\n this.visitEnd = function(node, payload) {\n syntheticEvent.raw = payload.event;\n syntheticEvent.type = payload.type;\n syntheticEvent.timeStamp = payload.timeStamp;\n syntheticEvent.abs.x = payload.x;\n syntheticEvent.abs.y = payload.y;\n var listeners = node.listeners(payload.type);\n if (!listeners) {\n return;\n }\n node.matrix().inverse().map(payload, syntheticEvent);\n var isEventTarget = node === payload.root || node.attr(\"spy\") || node.hitTest(syntheticEvent);\n if (!isEventTarget) {\n return;\n }\n if (payload.collected) {\n payload.collected.push(node);\n }\n if (payload.event) {\n var cancel = false;\n for (var l = 0; l < listeners.length; l++) {\n cancel = listeners[l].call(node, syntheticEvent) ? true : cancel;\n }\n return cancel;\n }\n };\n }\n Pointer2.prototype.mount = function(stage, elem) {\n var _this = this;\n this.stage = stage;\n this.elem = elem;\n this.ratio = stage.viewport().ratio || 1;\n stage.on(\"viewport\", function(viewport) {\n var _a;\n _this.ratio = (_a = viewport.ratio) !== null && _a !== void 0 ? _a : _this.ratio;\n });\n elem.addEventListener(\"touchstart\", this.handleStart);\n elem.addEventListener(\"touchend\", this.handleEnd);\n elem.addEventListener(\"touchmove\", this.handleMove);\n elem.addEventListener(\"touchcancel\", this.handleCancel);\n elem.addEventListener(\"mousedown\", this.handleStart);\n elem.addEventListener(\"mouseup\", this.handleEnd);\n elem.addEventListener(\"mousemove\", this.handleMove);\n document.addEventListener(\"mouseup\", this.handleCancel);\n window.addEventListener(\"blur\", this.handleCancel);\n return this;\n };\n Pointer2.prototype.unmount = function() {\n var elem = this.elem;\n elem.removeEventListener(\"touchstart\", this.handleStart);\n elem.removeEventListener(\"touchend\", this.handleEnd);\n elem.removeEventListener(\"touchmove\", this.handleMove);\n elem.removeEventListener(\"touchcancel\", this.handleCancel);\n elem.removeEventListener(\"mousedown\", this.handleStart);\n elem.removeEventListener(\"mouseup\", this.handleEnd);\n elem.removeEventListener(\"mousemove\", this.handleMove);\n document.removeEventListener(\"mouseup\", this.handleCancel);\n window.removeEventListener(\"blur\", this.handleCancel);\n return this;\n };\n Pointer2.prototype.localPoint = function(event) {\n var _a;\n var elem = this.elem;\n var x;\n var y;\n if ((_a = event.touches) === null || _a === void 0 ? void 0 : _a.length) {\n x = event.touches[0].clientX;\n y = event.touches[0].clientY;\n } else {\n x = event.clientX;\n y = event.clientY;\n }\n var rect = elem.getBoundingClientRect();\n x -= rect.left;\n y -= rect.top;\n x -= elem.clientLeft | 0;\n y -= elem.clientTop | 0;\n PAYLOAD.x = x * this.ratio;\n PAYLOAD.y = y * this.ratio;\n };\n Pointer2.prototype.findTargets = function(type, result) {\n var payload = PAYLOAD;\n payload.type = type;\n payload.root = this.stage;\n payload.event = null;\n payload.collected = result;\n payload.collected.length = 0;\n this.stage.visit({\n reverse: true,\n visible: true,\n start: this.visitStart,\n end: this.visitEnd\n }, payload);\n };\n Pointer2.prototype.dispatchEvent = function(type, event, targets) {\n var payload = PAYLOAD;\n payload.type = type;\n payload.root = this.stage;\n payload.event = event;\n payload.timeStamp = Date.now();\n payload.collected = null;\n if (targets) {\n while (targets.length) {\n var node = targets.shift();\n if (this.visitEnd(node, payload)) {\n break;\n }\n }\n targets.length = 0;\n } else {\n this.stage.visit({\n reverse: true,\n visible: true,\n start: this.visitStart,\n end: this.visitEnd\n }, payload);\n }\n };\n return Pointer2;\n }()\n);\nvar Mouse = {\n CLICK: \"click\",\n START: \"touchstart mousedown\",\n MOVE: \"touchmove mousemove\",\n END: \"touchend mouseup\",\n CANCEL: \"touchcancel mousecancel\"\n};\nvar __extends$2 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar __assign = function() {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s)\n if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar ROOTS = [];\nfunction pause() {\n for (var i = ROOTS.length - 1; i >= 0; i--) {\n ROOTS[i].pause();\n }\n}\nfunction resume() {\n for (var i = ROOTS.length - 1; i >= 0; i--) {\n ROOTS[i].resume();\n }\n}\nfunction mount(configs) {\n if (configs === void 0) {\n configs = {};\n }\n var root = new Root();\n root.mount(configs);\n root.pointer = new Pointer().mount(root, root.dom);\n return root;\n}\nvar Root = (\n /** @class */\n function(_super) {\n __extends$2(Root2, _super);\n function Root2() {\n var _this = _super.call(this) || this;\n _this.canvas = null;\n _this.dom = null;\n _this.context = null;\n _this.pixelWidth = -1;\n _this.pixelHeight = -1;\n _this.pixelRatio = 1;\n _this.drawingWidth = 0;\n _this.drawingHeight = 0;\n _this.mounted = false;\n _this.paused = false;\n _this.sleep = false;\n _this.mount = function(configs) {\n if (configs === void 0) {\n configs = {};\n }\n if (typeof configs.canvas === \"string\") {\n _this.canvas = document.getElementById(configs.canvas);\n if (!_this.canvas) {\n console.error(\"Canvas element not found: \", configs.canvas);\n }\n } else if (configs.canvas instanceof HTMLCanvasElement) {\n _this.canvas = configs.canvas;\n } else if (configs.canvas) {\n console.error(\"Unknown value for canvas:\", configs.canvas);\n }\n if (!_this.canvas) {\n _this.canvas = document.getElementById(\"cutjs\") || document.getElementById(\"stage\");\n }\n if (!_this.canvas) {\n _this.canvas = document.createElement(\"canvas\");\n Object.assign(_this.canvas.style, {\n position: \"absolute\",\n display: \"block\",\n top: \"0\",\n left: \"0\",\n bottom: \"0\",\n right: \"0\",\n width: \"100%\",\n height: \"100%\"\n });\n var body = document.body;\n body.insertBefore(_this.canvas, body.firstChild);\n }\n _this.dom = _this.canvas;\n _this.context = _this.canvas.getContext(\"2d\");\n var devicePixelRatio = window.devicePixelRatio || 1;\n var backingStorePixelRatio = (\n // @ts-ignore\n _this.context.webkitBackingStorePixelRatio || // @ts-ignore\n _this.context.mozBackingStorePixelRatio || // @ts-ignore\n _this.context.msBackingStorePixelRatio || // @ts-ignore\n _this.context.oBackingStorePixelRatio || // @ts-ignore\n _this.context.backingStorePixelRatio || 1\n );\n _this.devicePixelRatio = devicePixelRatio;\n _this.backingStoreRatio = backingStorePixelRatio;\n _this.pixelRatio = _this.devicePixelRatio / _this.backingStoreRatio;\n _this.mounted = true;\n ROOTS.push(_this);\n _this.requestFrame();\n };\n _this.frameRequested = false;\n _this.requestFrame = function() {\n if (!_this.frameRequested) {\n _this.frameRequested = true;\n requestAnimationFrame(_this.onFrame);\n }\n };\n _this._lastFrameTime = 0;\n _this._mo_touch = null;\n _this.onFrame = function(now) {\n _this.frameRequested = false;\n if (!_this.mounted || !_this.canvas || !_this.context) {\n return;\n }\n _this.requestFrame();\n var newPixelWidth = _this.canvas.clientWidth;\n var newPixelHeight = _this.canvas.clientHeight;\n if (_this.pixelWidth !== newPixelWidth || _this.pixelHeight !== newPixelHeight) {\n _this.pixelWidth = newPixelWidth;\n _this.pixelHeight = newPixelHeight;\n _this.drawingWidth = newPixelWidth * _this.pixelRatio;\n _this.drawingHeight = newPixelHeight * _this.pixelRatio;\n if (_this.canvas.width !== _this.drawingWidth || _this.canvas.height !== _this.drawingHeight) {\n _this.canvas.width = _this.drawingWidth;\n _this.canvas.height = _this.drawingHeight;\n _this.viewport({\n width: _this.drawingWidth,\n height: _this.drawingHeight,\n ratio: _this.pixelRatio\n });\n }\n }\n var last = _this._lastFrameTime || now;\n var elapsed = now - last;\n if (!_this.mounted || _this.paused || _this.sleep) {\n return;\n }\n _this._lastFrameTime = now;\n _this.prerender();\n var tickRequest = _this._tick(elapsed, now, last);\n if (_this._mo_touch != _this._ts_touch) {\n _this._mo_touch = _this._ts_touch;\n _this.sleep = false;\n if (_this.drawingWidth > 0 && _this.drawingHeight > 0) {\n _this.context.setTransform(1, 0, 0, 1, 0, 0);\n _this.context.clearRect(0, 0, _this.drawingWidth, _this.drawingHeight);\n _this.render(_this.context);\n }\n } else if (tickRequest) {\n _this.sleep = false;\n } else {\n _this.sleep = true;\n }\n stats.fps = elapsed ? 1e3 / elapsed : 0;\n };\n _this.label(\"Root\");\n return _this;\n }\n Root2.prototype.resume = function() {\n if (this.sleep || this.paused) {\n this.requestFrame();\n }\n this.paused = false;\n this.sleep = false;\n this.publish(\"resume\");\n return this;\n };\n Root2.prototype.pause = function() {\n if (!this.paused) {\n this.publish(\"pause\");\n }\n this.paused = true;\n return this;\n };\n Root2.prototype.touch = function() {\n if (this.sleep || this.paused) {\n this.requestFrame();\n }\n this.sleep = false;\n return _super.prototype.touch.call(this);\n };\n Root2.prototype.unmount = function() {\n var _a;\n this.mounted = false;\n var index = ROOTS.indexOf(this);\n if (index >= 0) {\n ROOTS.splice(index, 1);\n }\n (_a = this.pointer) === null || _a === void 0 ? void 0 : _a.unmount();\n return this;\n };\n Root2.prototype.background = function(color) {\n if (this.dom) {\n this.dom.style.backgroundColor = color;\n }\n return this;\n };\n Root2.prototype.viewport = function(width, height, ratio) {\n if (typeof width === \"undefined\") {\n return Object.assign({}, this._viewport);\n }\n if (typeof width === \"object\") {\n var options = width;\n width = options.width;\n height = options.height;\n ratio = options.ratio;\n }\n if (typeof width === \"number\" && typeof height === \"number\") {\n this._viewport = {\n width,\n height,\n ratio: typeof ratio === \"number\" ? ratio : 1\n };\n this.viewbox();\n var data_1 = Object.assign({}, this._viewport);\n this.visit({\n start: function(node) {\n if (!node._flag(\"viewport\")) {\n return true;\n }\n node.publish(\"viewport\", [data_1]);\n }\n });\n }\n return this;\n };\n Root2.prototype.viewbox = function(width, height, mode) {\n if (typeof width === \"number\" && typeof height === \"number\") {\n this._viewbox = {\n width,\n height,\n mode\n };\n } else if (typeof width === \"object\" && width !== null) {\n this._viewbox = __assign({}, width);\n }\n this.rescale();\n return this;\n };\n Root2.prototype.camera = function(matrix) {\n this._camera = matrix;\n this.rescale();\n return this;\n };\n Root2.prototype.rescale = function() {\n var viewbox = this._viewbox;\n var viewport = this._viewport;\n var camera = this._camera;\n if (viewport && viewbox) {\n var viewportWidth = viewport.width;\n var viewportHeight = viewport.height;\n var viewboxMode = isValidFitMode(viewbox.mode) ? viewbox.mode : \"in-pad\";\n var viewboxWidth = viewbox.width;\n var viewboxHeight = viewbox.height;\n this.pin({\n width: viewboxWidth,\n height: viewboxHeight\n });\n this.scaleTo(viewportWidth, viewportHeight, viewboxMode);\n var viewboxX = viewbox.x || 0;\n var viewboxY = viewbox.y || 0;\n var cameraZoom = (camera === null || camera === void 0 ? void 0 : camera.a) || 1;\n var cameraX = (camera === null || camera === void 0 ? void 0 : camera.e) || 0;\n var cameraY = (camera === null || camera === void 0 ? void 0 : camera.f) || 0;\n var scaleX = this.pin(\"scaleX\");\n var scaleY = this.pin(\"scaleY\");\n this.pin(\"scaleX\", scaleX * cameraZoom);\n this.pin(\"scaleY\", scaleY * cameraZoom);\n this.pin(\"offsetX\", cameraX - viewboxX * scaleX * cameraZoom);\n this.pin(\"offsetY\", cameraY - viewboxY * scaleY * cameraZoom);\n } else if (viewport) {\n this.pin({\n width: viewport.width,\n height: viewport.height\n });\n }\n return this;\n };\n return Root2;\n }(Node)\n);\nvar __extends$1 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nfunction anim(frames, fps) {\n var anim2 = new Anim();\n anim2.frames(frames).gotoFrame(0);\n fps && anim2.fps(fps);\n return anim2;\n}\nvar FPS = 15;\nvar Anim = (\n /** @class */\n function(_super) {\n __extends$1(Anim2, _super);\n function Anim2() {\n var _this = _super.call(this) || this;\n _this.label(\"Anim\");\n _this._textures = [];\n _this._fps = FPS;\n _this._ft = 1e3 / _this._fps;\n _this._time = -1;\n _this._repeat = 0;\n _this._index = 0;\n _this._frames = [];\n var lastTime = 0;\n _this.tick(function(t, now, last) {\n if (this._time < 0 || this._frames.length <= 1) {\n return;\n }\n var ignore = lastTime != last;\n lastTime = now;\n if (ignore) {\n return true;\n }\n this._time += t;\n if (this._time < this._ft) {\n return true;\n }\n var n = this._time / this._ft | 0;\n this._time -= n * this._ft;\n this.moveFrame(n);\n if (this._repeat > 0 && (this._repeat -= n) <= 0) {\n this.stop();\n this._callback && this._callback();\n return false;\n }\n return true;\n }, false);\n return _this;\n }\n Anim2.prototype.fps = function(fps) {\n if (typeof fps === \"undefined\") {\n return this._fps;\n }\n this._fps = fps > 0 ? fps : FPS;\n this._ft = 1e3 / this._fps;\n return this;\n };\n Anim2.prototype.setFrames = function(frames) {\n return this.frames(frames);\n };\n Anim2.prototype.frames = function(frames) {\n this._index = 0;\n this._frames = texture(frames).array();\n this.touch();\n return this;\n };\n Anim2.prototype.length = function() {\n return this._frames ? this._frames.length : 0;\n };\n Anim2.prototype.gotoFrame = function(frame, resize) {\n if (resize === void 0) {\n resize = false;\n }\n this._index = math.wrap(frame, this._frames.length) | 0;\n resize = resize || !this._textures[0];\n this._textures[0] = this._frames[this._index];\n if (resize) {\n this.pin(\"width\", this._textures[0].getWidth());\n this.pin(\"height\", this._textures[0].getHeight());\n }\n this.touch();\n return this;\n };\n Anim2.prototype.moveFrame = function(move) {\n return this.gotoFrame(this._index + move);\n };\n Anim2.prototype.repeat = function(repeat, callback) {\n this._repeat = repeat * this._frames.length - 1;\n this._callback = callback;\n this.play();\n return this;\n };\n Anim2.prototype.play = function(frame) {\n if (typeof frame !== \"undefined\") {\n this.gotoFrame(frame);\n this._time = 0;\n } else if (this._time < 0) {\n this._time = 0;\n }\n this.touch();\n return this;\n };\n Anim2.prototype.stop = function(frame) {\n this._time = -1;\n if (typeof frame !== \"undefined\") {\n this.gotoFrame(frame);\n }\n return this;\n };\n return Anim2;\n }(Node)\n);\nvar __extends = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nfunction monotype(chars) {\n return new Monotype().frames(chars);\n}\nvar Monotype = (\n /** @class */\n function(_super) {\n __extends(Monotype2, _super);\n function Monotype2() {\n var _this = _super.call(this) || this;\n _this.label(\"String\");\n _this._textures = [];\n return _this;\n }\n Monotype2.prototype.setFont = function(frames) {\n return this.frames(frames);\n };\n Monotype2.prototype.frames = function(frames) {\n this._textures = [];\n if (typeof frames == \"string\") {\n var selection_1 = texture(frames);\n this._font = function(value) {\n return selection_1.one(value);\n };\n } else if (typeof frames === \"object\") {\n this._font = function(value) {\n return frames[value];\n };\n } else if (typeof frames === \"function\") {\n this._font = frames;\n }\n return this;\n };\n Monotype2.prototype.setValue = function(value) {\n return this.value(value);\n };\n Monotype2.prototype.value = function(value) {\n if (typeof value === \"undefined\") {\n return this._value;\n }\n if (this._value === value) {\n return this;\n }\n this._value = value;\n if (value === null) {\n value = \"\";\n } else if (typeof value !== \"string\" && !Array.isArray(value)) {\n value = value.toString();\n }\n this._spacing = this._spacing || 0;\n var width = 0;\n var height = 0;\n for (var i = 0; i < value.length; i++) {\n var v = value[i];\n var texture_1 = this._textures[i] = this._font(typeof v === \"string\" ? v : v + \"\");\n width += i > 0 ? this._spacing : 0;\n texture_1.setDestinationCoordinate(width, 0);\n width = width + texture_1.getWidth();\n height = Math.max(height, texture_1.getHeight());\n }\n this.pin(\"width\", width);\n this.pin(\"height\", height);\n this._textures.length = value.length;\n return this;\n };\n return Monotype2;\n }(Node)\n);\nvar string = monotype;\nvar Str = Monotype;\nconst Stage = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({\n __proto__: null,\n Anim,\n Atlas,\n CanvasTexture,\n Image: Image$1,\n ImageTexture,\n Math: math,\n Matrix,\n Monotype,\n Mouse,\n Node,\n POINTER_CANCEL,\n POINTER_CLICK,\n POINTER_END,\n POINTER_MOVE,\n POINTER_START,\n Pin,\n PipeTexture,\n Pointer,\n ResizableTexture,\n Root,\n Sprite,\n Str,\n Texture,\n TextureSelection,\n Transition,\n anim,\n atlas,\n box,\n canvas,\n clamp,\n column,\n create,\n image,\n isValidFitMode,\n layer,\n layout,\n length,\n math,\n maximize,\n memoizeDraw,\n minimize,\n monotype,\n mount,\n pause,\n random,\n resume,\n row,\n sprite,\n string,\n texture,\n wrap\n}, Symbol.toStringTag, { value: \"Module\" }));\nexport {\n Anim,\n Atlas,\n CanvasTexture,\n Image$1 as Image,\n ImageTexture,\n math as Math,\n Matrix,\n Monotype,\n Mouse,\n Node,\n POINTER_CANCEL,\n POINTER_CLICK,\n POINTER_END,\n POINTER_MOVE,\n POINTER_START,\n Pin,\n PipeTexture,\n Pointer,\n ResizableTexture,\n Root,\n Sprite,\n Str,\n Texture,\n TextureSelection,\n Transition,\n anim,\n atlas,\n box,\n canvas,\n clamp,\n column,\n create,\n Stage as default,\n image,\n isValidFitMode,\n layer,\n layout,\n length,\n math,\n maximize,\n memoizeDraw,\n minimize,\n monotype,\n mount,\n pause,\n random,\n resume,\n row,\n sprite,\n string,\n texture,\n wrap\n};\n","import * as Stage from \"stage-js\";\n\nimport type { Vec2Value } from \"../src/common/Vec2\";\nimport type { World } from \"../src/dynamics/World\";\nimport type { Joint } from \"../src/dynamics/Joint\";\nimport type { Fixture } from \"../src/dynamics/Fixture\";\nimport type { Body } from \"../src/dynamics/Body\";\nimport type { AABBValue } from \"../src/collision/AABB\";\nimport type { Shape } from \"../src/collision/Shape\";\nimport type { Style } from \"../src/util/Testbed\";\nimport { Testbed } from \"../src/util/Testbed\";\nimport type { EdgeShape } from \"../src/collision/shape/EdgeShape\";\nimport type { PolygonShape } from \"../src/collision/shape/PolygonShape\";\nimport type { ChainShape } from \"../src/collision/shape/ChainShape\";\nimport type { CircleShape } from \"../src/collision/shape/CircleShape\";\nimport type { PulleyJoint } from \"../src/dynamics/joint/PulleyJoint\";\nimport { MouseJoint } from \"../src/dynamics/joint/MouseJoint\";\n\nconst math_atan2 = Math.atan2;\nconst math_abs = Math.abs;\nconst math_sqrt = Math.sqrt;\nconst math_PI = Math.PI;\nconst math_max = Math.max;\nconst math_min = Math.min;\n\ninterface DrawOptions {\n scaleY: number;\n lineWidth: number;\n stroke: string;\n fill: string;\n}\n\nlet mounted: StageTestbed | null = null;\n\n/** @internal */\nfunction memo() {\n const memory: any = [];\n function recall(...rest: any[]) {\n let equal = memory.length === rest.length;\n for (let i = 0; equal && i < rest.length; i++) {\n equal = equal && memory[i] === rest[i];\n memory[i] = rest[i];\n }\n memory.length = rest.length;\n return equal;\n }\n function reset() {\n memory.length = 0;\n // void 0;\n }\n return {\n recall,\n reset,\n };\n}\n\nTestbed.mount = () => {\n if (mounted) {\n return mounted;\n }\n\n mounted = new StageTestbed();\n\n // todo: merge rest of this into StageTestbed\n\n // todo: should we create these elements if not exists?\n const playButton = document.getElementById(\"testbed-play\");\n const statusElement = document.getElementById(\"testbed-status\");\n const infoElement = document.getElementById(\"testbed-info\");\n\n if (playButton) {\n playButton.addEventListener(\"click\", () => {\n if (mounted.isPaused() ) {\n mounted.resume();\n } else {\n mounted.pause();\n }\n });\n\n mounted._pause = () => {\n playButton.classList.add(\"pause\");\n playButton.classList.remove(\"play\");\n };\n\n mounted._resume = () => {\n playButton.classList.add(\"play\");\n playButton.classList.remove(\"pause\");\n };\n } else {\n console.log(\"Please create a button with id='testbed-play'\");\n }\n\n let lastStatus = \"\";\n if (statusElement) {\n statusElement.innerText = lastStatus;\n }\n mounted._status = (text: string) => {\n if (lastStatus === text) {\n return;\n }\n lastStatus = text;\n if (statusElement) {\n statusElement.innerText = text;\n }\n };\n\n let lastInfo = \"\";\n if (infoElement) {\n infoElement.innerText = lastInfo;\n }\n mounted._info = (text: string) => {\n if (lastInfo === text) {\n return;\n }\n lastInfo = text;\n if (infoElement) {\n infoElement.innerText = text;\n }\n };\n\n return mounted;\n};\n\nfunction getStyle(obj: Body | Fixture | Joint | Shape): Style {\n if (typeof obj[\"render\"] === \"object\" && (\"stroke\" in obj[\"render\"] || \"fill\" in obj[\"render\"])) {\n // this was used in planck before v1\n return obj[\"render\"];\n } else if (typeof obj[\"style\"] === \"object\") {\n return obj[\"style\"];\n }\n}\n\nfunction findBody(world: World, point: Vec2Value) {\n let body: Body | null = null;\n const aabb = {\n lowerBound: point,\n upperBound: point,\n };\n world.queryAABB(aabb, (fixture: Fixture) => {\n if (!fixture.getBody().isDynamic() || !fixture.testPoint(point)) {\n return true;\n }\n body = fixture.getBody();\n return false;\n });\n return body;\n}\n\n/** @internal */\nexport class StageTestbed extends Testbed {\n private canvas: HTMLCanvasElement;\n private stage: Stage.Root;\n private paused: boolean = false;\n private lastDrawHash = \"\";\n private newDrawHash = \"\";\n private buffer: ((context: CanvasRenderingContext2D, ratio: number)=> void)[] = [];\n\n start(world: World) {\n const stage = this.stage = Stage.mount();\n const canvas = this.canvas = stage.dom as HTMLCanvasElement;\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const testbed = this;\n this.canvas = canvas;\n\n stage.on(Stage.POINTER_START, () => {\n window.focus();\n // @ts-ignore\n document.activeElement?.blur();\n canvas.focus();\n });\n\n stage.MAX_ELAPSE = 1000 / 30;\n\n stage.on(\"resume\", () => {\n this.paused = false;\n this._resume();\n });\n stage.on(\"pause\", () => {\n this.paused = true;\n this._pause();\n });\n\n const drawingTexture = new Stage.CanvasTexture();\n drawingTexture.draw = (ctx: CanvasRenderingContext2D) => {\n const pixelRatio = 2 * drawingTexture.getOptimalPixelRatio();\n ctx.save();\n ctx.transform(1, 0, 0, this.scaleY, -this.x, -this.y);\n ctx.lineWidth = 3 / pixelRatio;\n ctx.lineCap = \"round\";\n for (let drawing = this.buffer.shift(); drawing; drawing = this.buffer.shift()) {\n drawing(ctx, pixelRatio);\n }\n ctx.restore();\n };\n\n const drawingElement = Stage.sprite(drawingTexture);\n stage.append(drawingElement);\n stage.tick(() => {\n this.buffer.length = 0;\n }, true);\n\n\n stage.background(this.background);\n stage.viewbox(this.width, this.height);\n stage.pin(\"alignX\", -0.5);\n stage.pin(\"alignY\", -0.5);\n\n const worldNode = new WorldStageNode(world, this);\n\n // stage.empty();\n stage.prepend(worldNode);\n\n let lastX = 0;\n let lastY = 0;\n stage.tick((dt: number, t: number) => {\n // update camera position\n if (lastX !== this.x || lastY !== this.y) {\n worldNode.offset(-this.x, -this.y);\n lastX = this.x;\n lastY = this.y;\n }\n });\n\n worldNode.tick((dt: number, t: number) => {\n this.step(dt, t);\n\n if (targetBody) {\n this.drawSegment(targetBody.getPosition(), mouseMove, \"rgba(255,255,255,0.2)\");\n }\n\n if (this.lastDrawHash !== this.newDrawHash) {\n this.lastDrawHash = this.newDrawHash;\n stage.touch();\n }\n this.newDrawHash = \"\";\n\n return true;\n });\n\n const mouseGround = world.createBody();\n let mouseJoint: MouseJoint | null = null;\n let targetBody: Body | null = null;\n const mouseMove = {x: 0, y: 0};\n\n worldNode.attr(\"spy\", true);\n\n worldNode.on(Stage.POINTER_START, (point: Vec2Value) => {\n point = { x: point.x, y: testbed.scaleY * point.y };\n if (targetBody) {\n return;\n }\n\n const body = findBody(world, point);\n if (!body) {\n return;\n }\n\n if (this.mouseForce) {\n targetBody = body;\n\n } else {\n mouseJoint = new MouseJoint({maxForce: 1000}, mouseGround, body, { x: point.x, y: point.y });\n world.createJoint(mouseJoint);\n }\n });\n\n worldNode.on(Stage.POINTER_MOVE, (point: Vec2Value) => {\n point = { x: point.x, y: testbed.scaleY * point.y };\n if (mouseJoint) {\n mouseJoint.setTarget(point);\n }\n\n mouseMove.x = point.x;\n mouseMove.y = point.y;\n });\n\n worldNode.on(Stage.POINTER_END, (point: Vec2Value) => {\n point = { x: point.x, y: testbed.scaleY * point.y };\n if (mouseJoint) {\n world.destroyJoint(mouseJoint);\n mouseJoint = null;\n }\n if (targetBody && this.mouseForce) {\n const target = targetBody.getPosition();\n const force = {\n x: (point.x - target.x) * this.mouseForce,\n y: (point.y - target.y) * this.mouseForce,\n };\n targetBody.applyForceToCenter(force, true);\n targetBody = null;\n }\n });\n\n worldNode.on(Stage.POINTER_CANCEL, (point: Vec2Value) => {\n point = { x: point.x, y: testbed.scaleY * point.y };\n if (mouseJoint) {\n world.destroyJoint(mouseJoint);\n mouseJoint = null;\n }\n if (targetBody) {\n targetBody = null;\n }\n });\n\n const activeKeys = testbed.activeKeys;\n const downKeys: Record = {};\n function updateActiveKeys(keyCode: number, down: boolean) {\n const char = String.fromCharCode(keyCode);\n if (/\\w/.test(char)) {\n activeKeys[char] = down;\n }\n activeKeys.right = downKeys[39] || activeKeys[\"D\"];\n activeKeys.left = downKeys[37] || activeKeys[\"A\"];\n activeKeys.up = downKeys[38] || activeKeys[\"W\"];\n activeKeys.down = downKeys[40] || activeKeys[\"S\"];\n activeKeys.fire = downKeys[32] || downKeys[13] ;\n }\n\n window.addEventListener(\"keydown\", function(e) {\n const keyCode = e.keyCode;\n downKeys[keyCode] = true;\n updateActiveKeys(keyCode, true);\n testbed.keydown?.(keyCode, String.fromCharCode(keyCode));\n });\n window.addEventListener(\"keyup\", function(e) {\n const keyCode = e.keyCode;\n downKeys[keyCode] = false;\n updateActiveKeys(keyCode, false);\n testbed.keyup?.(keyCode, String.fromCharCode(keyCode));\n });\n\n this.resume();\n }\n\n /** @private @internal */\n focus() {\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n document.activeElement && document.activeElement.blur();\n this.canvas.focus();\n }\n\n /** @internal */\n _pause() {\n }\n\n /** @internal */\n _resume() {\n }\n\n private statusText = \"\";\n private statusMap: Record = {};\n\n status(name: string, value: any): void;\n status(value: object | string): void;\n status(a: any, b?: any) {\n if (typeof b !== \"undefined\") {\n const key = a;\n const value = b;\n if (typeof value !== \"function\" && typeof value !== \"object\") {\n this.statusMap[key] = value;\n }\n } else if (a && typeof a === \"object\") {\n // tslint:disable-next-line:no-for-in\n for (const key in a) {\n const value = a[key];\n if (typeof value !== \"function\" && typeof value !== \"object\") {\n this.statusMap[key] = value;\n }\n }\n } else if (typeof a === \"string\") {\n this.statusText = a;\n }\n\n var newline = \"\\n\";\n var text = this.statusText || \"\";\n for (var key in this.statusMap) {\n var value = this.statusMap[key];\n if (typeof value === \"function\") continue;\n text += (text && newline) + key + \": \" + value;\n }\n\n this._status(text);\n }\n\n info(text: string): void {\n this._info(text);\n }\n\n /** @internal */\n _status(string: string) {\n }\n\n /** @internal */ \n _info(text: string) {\n }\n\n /** @internal */\n isPaused() {\n return this.paused;\n }\n\n /** @internal */\n togglePause() {\n if (this.paused) {\n this.resume();\n } else {\n this.pause();\n }\n }\n\n /** @internal */\n pause() {\n this.stage.pause();\n }\n\n /** @internal */\n resume() {\n this.stage.resume();\n this.focus();\n }\n\n drawPoint(p: {x: number, y: number}, r: number, color: string): void {\n this.buffer.push(function(ctx, ratio) {\n ctx.beginPath();\n ctx.arc(p.x, p.y, 5 / ratio, 0, 2 * math_PI);\n ctx.strokeStyle = color;\n ctx.stroke();\n });\n this.newDrawHash += \"point\" + p.x + \",\" + p.y + \",\" + r + \",\" + color;\n }\n\n drawCircle(p: {x: number, y: number}, r: number, color: string): void {\n this.buffer.push(function(ctx) {\n ctx.beginPath();\n ctx.arc(p.x, p.y, r, 0, 2 * math_PI);\n ctx.strokeStyle = color;\n ctx.stroke();\n });\n this.newDrawHash += \"circle\" + p.x + \",\" + p.y + \",\" + r + \",\" + color;\n }\n\n drawEdge(a: {x: number, y: number}, b: {x: number, y: number}, color: string): void {\n this.buffer.push(function(ctx) {\n ctx.beginPath();\n ctx.moveTo(a.x, a.y);\n ctx.lineTo(b.x, b.y);\n ctx.strokeStyle = color;\n ctx.stroke();\n });\n this.newDrawHash += \"segment\" + a.x + \",\" + a.y + \",\" + b.x + \",\" + b.y + \",\" + color;\n }\n\n drawSegment = this.drawEdge;\n\n drawPolygon(points: Array<{x: number, y: number}>, color: string): void {\n if (!points || !points.length) {\n return;\n }\n this.buffer.push(function(ctx) {\n ctx.beginPath();\n ctx.moveTo(points[0].x, points[0].y);\n for (let i = 1; i < points.length; i++) {\n ctx.lineTo(points[i].x, points[i].y);\n }\n ctx.strokeStyle = color;\n ctx.closePath();\n ctx.stroke();\n });\n this.newDrawHash += \"segment\";\n for (let i = 1; i < points.length; i++) {\n this.newDrawHash += points[i].x + \",\" + points[i].y + \",\";\n }\n this.newDrawHash += color;\n }\n\n drawAABB(aabb: AABBValue, color: string): void {\n this.buffer.push(function(ctx) {\n ctx.beginPath();\n ctx.moveTo(aabb.lowerBound.x, aabb.lowerBound.y);\n ctx.lineTo(aabb.upperBound.x, aabb.lowerBound.y);\n ctx.lineTo(aabb.upperBound.x, aabb.upperBound.y);\n ctx.lineTo(aabb.lowerBound.x, aabb.upperBound.y);\n ctx.strokeStyle = color;\n ctx.closePath();\n ctx.stroke();\n });\n this.newDrawHash += \"aabb\";\n this.newDrawHash += aabb.lowerBound.x + \",\" + aabb.lowerBound.y + \",\";\n this.newDrawHash += aabb.upperBound.x + \",\" + aabb.upperBound.y + \",\";\n this.newDrawHash += color;\n }\n\n findOne(query: string): (Body | Joint | Fixture | null) {\n throw new Error(\"Not implemented\");\n }\n\n findAll(query: string): (Body | Joint | Fixture)[] {\n throw new Error(\"Not implemented\");\n }\n}\n\ninterface WorldStageOptions {\n speed: number;\n hz: number;\n scaleY: number;\n lineWidth: number;\n stroke: string | undefined;\n fill: string | undefined;\n}\n\nclass WorldStageNode extends Stage.Node {\n private nodes = new WeakMap();\n\n private options: WorldStageOptions = {\n speed: 1,\n hz: 60,\n scaleY: -1,\n lineWidth: 3,\n stroke: undefined,\n fill: undefined\n };\n\n private world: World;\n private testbed: Testbed;\n\n constructor(world: World, opts: Partial = {}) {\n super();\n this.label(\"Planck\");\n\n this.options = { ...this.options, ...opts };\n\n if (math_abs(this.options.hz) < 1) {\n this.options.hz = 1 / this.options.hz;\n }\n\n this.world = world;\n this.testbed = opts as Testbed;\n\n const timeStep = 1 / this.options.hz;\n let elapsedTime = 0;\n let errored = false;\n this.tick((dt: number) => {\n if (errored) {\n return false;\n }\n try {\n dt = dt * 0.001 * this.options.speed;\n elapsedTime += dt;\n while (elapsedTime > timeStep) {\n world.step(timeStep);\n elapsedTime -= timeStep;\n }\n this.renderWorld();\n return true; \n } catch (error) {\n errored = true;\n console.error(error);\n return false;\n }\n }, true);\n\n world.on(\"remove-fixture\", (obj: Fixture) => {\n this.nodes.get(obj)?.remove();\n });\n\n world.on(\"remove-joint\", (obj: Joint) => {\n this.nodes.get(obj)?.remove();\n });\n }\n\n renderWorld() {\n const world = this.world;\n const options = this.options;\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const viewer = this;\n\n for (let b = world.getBodyList(); b; b = b.getNext()) {\n for (let f = b.getFixtureList(); f; f = f.getNext()) {\n\n let node = this.nodes.get(f);\n if (!node) {\n const type = f.getType();\n const shape = f.getShape();\n\n const opts: DrawOptions = Object.assign({\n stroke: options.stroke,\n fill: options.fill,\n scaleY: options.scaleY,\n lineWidth: options.lineWidth,\n }, getStyle(b), getStyle(f), getStyle(shape));\n\n if (opts.stroke) {\n // good\n } else if (b.isDynamic()) {\n opts.stroke = \"rgba(255,255,255,0.9)\";\n } else if (b.isKinematic()) {\n opts.stroke = \"rgba(255,255,255,0.7)\";\n } else if (b.isStatic()) {\n opts.stroke = \"rgba(255,255,255,0.5)\";\n }\n\n if (type == \"circle\") {\n node = viewer.drawCircle(shape as CircleShape, opts);\n }\n if (type == \"edge\") {\n node = viewer.drawEdge(shape as EdgeShape, opts);\n }\n if (type == \"polygon\") {\n node = viewer.drawPolygon(shape as PolygonShape, opts);\n }\n if (type == \"chain\") {\n node = viewer.drawChain(shape as ChainShape, opts);\n }\n\n if (node) {\n node.appendTo(viewer);\n this.nodes.set(f, node);\n }\n }\n\n if (node) {\n const p = b.getPosition();\n const r = b.getAngle();\n // @ts-ignore\n const isChanged = node.__lastX !== p.x || node.__lastY !== p.y || node.__lastR !== r;\n if (isChanged) {\n // @ts-ignore\n node.__lastX = p.x;\n // @ts-ignore\n node.__lastY = p.y;\n // @ts-ignore\n node.__lastR = r;\n node.offset(p.x, options.scaleY * p.y);\n node.rotate(options.scaleY * r);\n }\n }\n\n }\n }\n\n for (let j = world.getJointList(); j; j = j.getNext()) {\n const type = j.getType();\n if (type == \"pulley-joint\") {\n this.testbed.drawSegment(j.getAnchorA(), (j as PulleyJoint).getGroundAnchorA(), \"rgba(255,255,255,0.5)\");\n this.testbed.drawSegment(j.getAnchorB(), (j as PulleyJoint).getGroundAnchorB(), \"rgba(255,255,255,0.5)\");\n this.testbed.drawSegment((j as PulleyJoint).getGroundAnchorB(), (j as PulleyJoint).getGroundAnchorA(), \"rgba(255,255,255,0.5)\");\n } else {\n this.testbed.drawSegment(j.getAnchorA(), j.getAnchorB(), \"rgba(255,255,255,0.5)\");\n }\n }\n }\n\n drawCircle(shape: CircleShape, options: DrawOptions) {\n let offsetX = 0;\n let offsetY = 0;\n const offsetMemo = memo();\n\n const texture = Stage.canvas();\n texture.setDrawer(function () {\n const ctx = this.getContext();\n const ratio = 2 * this.getOptimalPixelRatio();\n const lw = options.lineWidth / ratio;\n\n const r = shape.m_radius;\n const cx = r + lw;\n const cy = r + lw;\n const w = r * 2 + lw * 2;\n const h = r * 2 + lw * 2;\n\n offsetX = shape.m_p.x - cx;\n offsetY = options.scaleY * shape.m_p.y - cy;\n\n this.setSize(w, h, ratio);\n\n ctx.scale(ratio, ratio);\n ctx.arc(cx, cy, r, 0, 2 * math_PI);\n if (options.fill) {\n ctx.fillStyle = options.fill;\n ctx.fill();\n }\n ctx.lineTo(cx, cy);\n ctx.lineWidth = options.lineWidth / ratio;\n ctx.strokeStyle = options.stroke ?? \"\";\n ctx.stroke();\n });\n\n const sprite = Stage.sprite(texture);\n sprite.tick(() => {\n if (!offsetMemo.recall(offsetX, offsetY)) {\n sprite.offset(offsetX, offsetY);\n }\n });\n\n const node = Stage.layout().append(sprite);\n return node;\n }\n\n drawEdge(edge: EdgeShape, options: DrawOptions) {\n let offsetX = 0;\n let offsetY = 0;\n let offsetA = 0;\n const offsetMemo = memo();\n\n const texture = Stage.canvas();\n texture.setDrawer(function () {\n const ctx = this.getContext();\n const ratio = 2 * this.getOptimalPixelRatio();\n const lw = options.lineWidth / ratio;\n\n const v1 = edge.m_vertex1;\n const v2 = edge.m_vertex2;\n\n const dx = v2.x - v1.x;\n const dy = v2.y - v1.y;\n\n const length = math_sqrt(dx * dx + dy * dy);\n\n this.setSize(length + 2 * lw, 2 * lw, ratio);\n\n const minX = math_min(v1.x, v2.x);\n const minY = math_min(options.scaleY * v1.y, options.scaleY * v2.y);\n \n offsetX = minX - lw;\n offsetY = minY - lw;\n offsetA = options.scaleY * math_atan2(dy, dx);\n\n ctx.scale(ratio, ratio);\n ctx.beginPath();\n ctx.moveTo(lw, lw);\n ctx.lineTo(lw + length, lw);\n\n ctx.lineCap = \"round\";\n ctx.lineWidth = options.lineWidth / ratio;\n ctx.strokeStyle = options.stroke ?? \"\";\n ctx.stroke();\n });\n\n const sprite = Stage.sprite(texture);\n sprite.tick(() => {\n if(!offsetMemo.recall(offsetX, offsetY, offsetA)) {\n sprite.offset(offsetX, offsetY);\n sprite.rotate(offsetA);\n }\n });\n const node = Stage.layout().append(sprite);\n return node;\n }\n\n drawPolygon(shape: PolygonShape, options: DrawOptions) {\n let offsetX = 0;\n let offsetY = 0;\n const offsetMemo = memo();\n\n const texture = Stage.canvas();\n texture.setDrawer(function () {\n const ctx = this.getContext();\n const ratio = 2 * this.getOptimalPixelRatio();\n const lw = options.lineWidth / ratio;\n\n const vertices = shape.m_vertices;\n\n if (!vertices.length) {\n return;\n }\n \n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (let i = 0; i < vertices.length; ++i) {\n const v = vertices[i];\n minX = math_min(minX, v.x);\n maxX = math_max(maxX, v.x);\n minY = math_min(minY, options.scaleY * v.y);\n maxY = math_max(maxY, options.scaleY * v.y);\n }\n \n const width = maxX - minX;\n const height = maxY - minY;\n\n offsetX = minX;\n offsetY = minY;\n\n this.setSize(width + 2 * lw, height + 2 * lw, ratio);\n\n ctx.scale(ratio, ratio);\n ctx.beginPath();\n for (let i = 0; i < vertices.length; ++i) {\n const v = vertices[i];\n const x = v.x - minX + lw;\n const y = options.scaleY * v.y - minY + lw;\n if (i == 0)\n ctx.moveTo(x, y);\n\n else\n ctx.lineTo(x, y);\n }\n\n if (vertices.length > 2) {\n ctx.closePath();\n }\n\n if (options.fill) {\n ctx.fillStyle = options.fill;\n ctx.fill();\n ctx.closePath();\n }\n\n ctx.lineCap = \"round\";\n ctx.lineWidth = options.lineWidth / ratio;\n ctx.strokeStyle = options.stroke ?? \"\";\n ctx.stroke();\n });\n\n const sprite = Stage.sprite(texture);\n sprite.tick(() => {\n if(!offsetMemo.recall(offsetX, offsetY)) {\n sprite.offset(offsetX, offsetY);\n }\n });\n\n const node = Stage.layout().append(sprite);\n return node;\n }\n\n drawChain(shape: ChainShape, options: DrawOptions) {\n let offsetX = 0;\n let offsetY = 0;\n const offsetMemo = memo();\n\n const texture = Stage.canvas();\n texture.setDrawer(function () {\n const ctx = this.getContext();\n const ratio = 2 * this.getOptimalPixelRatio();\n const lw = options.lineWidth / ratio;\n\n const vertices = shape.m_vertices;\n\n if (!vertices.length) {\n return;\n }\n \n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (let i = 0; i < vertices.length; ++i) {\n const v = vertices[i];\n minX = math_min(minX, v.x);\n maxX = math_max(maxX, v.x);\n minY = math_min(minY, options.scaleY * v.y);\n maxY = math_max(maxY, options.scaleY * v.y);\n }\n \n const width = maxX - minX;\n const height = maxY - minY;\n\n offsetX = minX;\n offsetY = minY;\n\n this.setSize(width + 2 * lw, height + 2 * lw, ratio);\n\n ctx.scale(ratio, ratio);\n ctx.beginPath();\n for (let i = 0; i < vertices.length; ++i) {\n const v = vertices[i];\n const x = v.x - minX + lw;\n const y = options.scaleY * v.y - minY + lw;\n if (i == 0)\n ctx.moveTo(x, y);\n\n else\n ctx.lineTo(x, y);\n }\n\n // TODO: if loop\n if (vertices.length > 2) {\n // ctx.closePath();\n }\n\n if (options.fill) {\n ctx.fillStyle = options.fill;\n ctx.fill();\n ctx.closePath();\n }\n\n ctx.lineCap = \"round\";\n ctx.lineWidth = options.lineWidth / ratio;\n ctx.strokeStyle = options.stroke ?? \"\";\n ctx.stroke();\n });\n\n const sprite = Stage.sprite(texture);\n sprite.tick(() => {\n if(!offsetMemo.recall(offsetX, offsetY)) {\n sprite.offset(offsetX, offsetY);\n }\n });\n\n const node = Stage.layout().append(sprite);\n return node;\n }\n}\n"],"names":["d","b","__extends","__assign","s","n","input","output","math_random","x","clamp","random","math","math_abs","math_sqrt","math_max","math_min","Vec2","v","a","length","AABB","normal","temp","math_PI","Settings","SettingsInternal","Pool","TreeNode","DynamicTree","c","Iterator","BroadPhase","displacement","math_sin","math_cos","transform","xf","math_atan2","Rot","matrix.vec2","Sweep","matrix.zeroVec2","matrix.transformVec2","matrix.copyVec2","localCenter","matrix.setRotAngle","matrix.combine2Vec2","matrix.minusVec2","matrix.rotVec2","Transform","rotation","Velocity","Position","Shape","FixtureProxy","Fixture","matrix.subVec2","matrix.transform","Body","matrix.plusScaleVec2","matrix.scaleVec2","matrix.dotVec2","matrix.crossNumVec2","matrix.plusVec2","point","JointEdge","Joint","stats","DistanceInput","DistanceOutput","SimplexCache","cache","xfA","xfB","matrix.lengthSqrVec2","matrix.derotVec2","matrix.distVec2","rA","rB","matrix.normalizeVec2","matrix.minusScaleVec2","DistanceProxy","SimplexVertex","Simplex","v1","v2","matrix.setVec2","matrix.crossVec2Vec2","pA","pB","matrix.combine3Vec2","matrix.copyTransform","ShapeCastInput","ShapeCastOutput","simplex","pointA","pointB","TOIInput","TOIOutputState","TOIOutput","SeparationFunctionType","SeparationFunction","matrix.normalizeVec2Length","matrix.crossVec2Num","matrix.negVec2","TimeStep","ContactImpulse","Solver","matrix.mulVec2","Mat22","cA","cB","planePoint","clipPoint","ManifoldType","ContactFeatureType","PointState","ClipVertex","Manifold","ManifoldPoint","ContactID","WorldManifold","ContactEdge","VelocityConstraintPoint","tangent","P","Contact","_a","worldManifold","DEFAULTS","World","oldManifold","Vec3","EdgeShape","e","ChainShape","e1","e2","PolygonShape","ie","center","matrix.detransformVec2","matrix.addVec2","CircleShape","matrix.distSqrVec2","DistanceJoint","vA","vB","FrictionJoint","Mat33","LimitState","RevoluteJoint","PrismaticJoint","translation","perp","GearJoint","MotorJoint","MouseJoint","PulleyJoint","RopeJoint","WeldJoint","WheelJoint","Serializer","options","obj","Testbed","testbed","BoxShape","matrix.retransformVec2","clipPoints1","clipPoints2","normal1","matrix.detransformTransform","maxSeparation","edge1","matrix.rerotVec2","EPAxisType","VertexType","EPAxis","TempPolygon","ReferenceFace","s2","extendStatics","d2","b2","now","StageTestbed","Stage.mount","canvas","Stage.POINTER_START","Stage.CanvasTexture","Stage.sprite","Stage.POINTER_MOVE","Stage.POINTER_END","Stage.POINTER_CANCEL","i","WorldStageNode","texture","Stage.canvas","sprite","Stage.layout","Stage.Node"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,IAAI,gBAAgB,SAASA,IAAGC,IAAG;AAC/B,kBAAgB,OAAO,kBAClB,EAAE,WAAW,CAAA,eAAgB,SAAS,SAA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M;AAAA,MAAA,CACX;AAEK,UAAAwE,WAASR,OAAaM,QAAO;AACnCE,eAAO,KAAK,WAAA;AACV,YAAG,CAAC,WAAW,OAAO,SAAS,OAAO,GAAG;AAChCA,mBAAA,OAAO,SAAS,OAAO;AAAA,QAAA;AAAA,MAChC,CACD;AAED,UAAM,OAAOC,SAAe,OAAOD,QAAM;AAClC,aAAA;AAAA,IACT;AACDH,WAAAA;AAAAA,EAAA,EAxY6BK,IAAU;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","x_google_ignoreList":[0,54]} \ No newline at end of file +{"version":3,"file":"planck-with-testbed.mjs","sources":["../node_modules/tslib/tslib.es6.js","../src/util/options.ts","../src/common/Math.ts","../src/common/Vec2.ts","../src/collision/AABB.ts","../src/Settings.ts","../src/util/Pool.ts","../src/collision/DynamicTree.ts","../src/collision/BroadPhase.ts","../src/common/Matrix.ts","../src/common/Rot.ts","../src/common/Sweep.ts","../src/common/Transform.ts","../src/dynamics/Velocity.ts","../src/dynamics/Position.ts","../src/collision/Shape.ts","../src/dynamics/Fixture.ts","../src/dynamics/Body.ts","../src/dynamics/Joint.ts","../src/util/stats.ts","../src/util/Timer.ts","../src/collision/Distance.ts","../src/collision/TimeOfImpact.ts","../src/dynamics/Solver.ts","../src/common/Mat22.ts","../src/collision/Manifold.ts","../src/dynamics/Contact.ts","../src/dynamics/World.ts","../src/common/Vec3.ts","../src/collision/shape/EdgeShape.ts","../src/collision/shape/ChainShape.ts","../src/collision/shape/PolygonShape.ts","../src/collision/shape/CircleShape.ts","../src/dynamics/joint/DistanceJoint.ts","../src/dynamics/joint/FrictionJoint.ts","../src/common/Mat33.ts","../src/dynamics/joint/RevoluteJoint.ts","../src/dynamics/joint/PrismaticJoint.ts","../src/dynamics/joint/GearJoint.ts","../src/dynamics/joint/MotorJoint.ts","../src/dynamics/joint/MouseJoint.ts","../src/dynamics/joint/PulleyJoint.ts","../src/dynamics/joint/RopeJoint.ts","../src/dynamics/joint/WeldJoint.ts","../src/dynamics/joint/WheelJoint.ts","../src/serializer/index.ts","../src/util/Testbed.ts","../src/collision/shape/BoxShape.ts","../src/collision/shape/CollideCircle.ts","../src/collision/shape/CollideEdgeCircle.ts","../src/collision/shape/CollidePolygon.ts","../src/collision/shape/CollideCirclePolygon.ts","../src/collision/shape/CollideEdgePolygon.ts","../src/internal.ts","../node_modules/stage-js/dist/stage.js","../testbed/StageTestbed.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from) {\r\n for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)\r\n to[j] = from[i];\r\n return to;\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","/** @internal */\nexport const options = function(input: T, defaults: object): T {\n if (input === null || typeof input === \"undefined\") {\n // tslint:disable-next-line:no-object-literal-type-assertion\n input = {} as T;\n }\n\n const output = {...input};\n\n // tslint:disable-next-line:no-for-in\n for (const key in defaults) {\n if (defaults.hasOwnProperty(key) && typeof input[key] === \"undefined\") {\n output[key] = defaults[key];\n }\n }\n\n if (typeof Object.getOwnPropertySymbols === \"function\") {\n const symbols = Object.getOwnPropertySymbols(defaults);\n for (let i = 0; i < symbols.length; i++) {\n const symbol = symbols[i];\n if (defaults.propertyIsEnumerable(symbol) && typeof input[symbol] === \"undefined\") {\n output[symbol] = defaults[symbol];\n }\n }\n }\n\n return output;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_random = Math.random;\n\n\nexport const EPSILON = 1e-9;\n\n/** @internal @deprecated */\nexport const isFinite = Number.isFinite;\n\n/**\n * @deprecated\n * Next Largest Power of 2 Given a binary integer value x, the next largest\n * power of 2 can be computed by a SWAR algorithm that recursively \"folds\" the\n * upper bits into the lower bits. This process yields a bit vector with the\n * same most significant 1 as x, but all 1's below it. Adding 1 to that value\n * yields the next largest power of 2. For a 32-bit value:\n */\nexport function nextPowerOfTwo(x: number): number {\n x |= (x >> 1);\n x |= (x >> 2);\n x |= (x >> 4);\n x |= (x >> 8);\n x |= (x >> 16);\n return x + 1;\n}\n\n/** @deprecated */\nexport function isPowerOfTwo(x: number): boolean {\n return x > 0 && (x & (x - 1)) === 0;\n}\n\n/** @deprecated */\nexport function mod(num: number, min?: number, max?: number): number {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n if (max > min) {\n num = (num - min) % (max - min);\n return num + (num < 0 ? max : min);\n } else {\n num = (num - max) % (min - max);\n return num + (num <= 0 ? min : max);\n }\n}\n\n/**\n * @deprecated\n * Returns a min if num is less than min, and max if more than max, otherwise returns num.\n */\nexport function clamp(num: number, min: number, max: number): number {\n if (num < min) {\n return min;\n } else if (num > max) {\n return max;\n } else {\n return num;\n }\n}\n\n/**\n * @deprecated\n * Returns a random number between min and max when two arguments are provided.\n * If one arg is provided between 0 to max.\n * If one arg is passed between 0 to 1.\n */\nexport function random(min?: number, max?: number): number {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n return min === max ? min : math_random() * (max - min) + min;\n}\n\n/** @ignore */\nexport const math = Object.create(Math);\nmath.EPSILON = EPSILON;\nmath.isFinite = isFinite;\nmath.nextPowerOfTwo = nextPowerOfTwo;\nmath.isPowerOfTwo = isPowerOfTwo;\nmath.mod = mod;\nmath.clamp = clamp;\nmath.random = random;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { clamp, EPSILON } from \"./Math\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/** 2D vector */\nexport interface Vec2Value {\n x: number;\n y: number;\n}\n\ndeclare module \"./Vec2\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(x: number, y: number): Vec2;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(obj: Vec2Value): Vec2;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(): Vec2;\n}\n\n/** 2D vector */\n// @ts-expect-error\nexport class Vec2 {\n x: number;\n y: number;\n\n constructor(x: number, y: number);\n constructor(obj: Vec2Value);\n constructor();\n // tslint:disable-next-line:typedef\n constructor(x?, y?) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Vec2)) {\n return new Vec2(x, y);\n }\n if (typeof x === \"undefined\") {\n this.x = 0;\n this.y = 0;\n } else if (typeof x === \"object\") {\n this.x = x.x;\n this.y = x.y;\n } else {\n this.x = x;\n this.y = y;\n }\n if (_ASSERT) Vec2.assert(this);\n }\n\n /** @internal */\n _serialize(): object {\n return {\n x: this.x,\n y: this.y\n };\n }\n\n /** @internal */\n static _deserialize(data: any): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = data.x;\n obj.y = data.y;\n return obj;\n }\n\n static zero(): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = 0;\n obj.y = 0;\n return obj;\n }\n\n /** @hidden */\n static neo(x: number, y: number): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = x;\n obj.y = y;\n return obj;\n }\n\n static clone(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(v.x, v.y);\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n /**\n * Does this vector contain finite coordinates?\n */\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.x) && Number.isFinite(obj.y);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Vec2.isValid(o), \"Invalid Vec2!\", o);\n }\n\n clone(): Vec2 {\n return Vec2.clone(this);\n }\n\n /**\n * Set this vector to all zeros.\n *\n * @returns this\n */\n setZero(): Vec2 {\n this.x = 0.0;\n this.y = 0.0;\n return this;\n }\n\n set(x: number, y: number): Vec2;\n set(value: Vec2Value): Vec2;\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n // tslint:disable-next-line:typedef\n set(x, y?) {\n if (typeof x === \"object\") {\n if (_ASSERT) Vec2.assert(x);\n this.x = x.x;\n this.y = x.y;\n } else {\n if (_ASSERT) console.assert(Number.isFinite(x));\n if (_ASSERT) console.assert(Number.isFinite(y));\n this.x = x;\n this.y = y;\n }\n return this;\n }\n\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n setNum(x: number, y: number) {\n if (_ASSERT) console.assert(Number.isFinite(x));\n if (_ASSERT) console.assert(Number.isFinite(y));\n this.x = x;\n this.y = y;\n\n return this;\n }\n\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n setVec2(value: Vec2Value) {\n if (_ASSERT) Vec2.assert(value);\n this.x = value.x;\n this.y = value.y;\n\n return this;\n }\n\n /** @internal @deprecated Use setCombine or setMul */\n wSet(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.setCombine(a, v, b, w);\n } else {\n return this.setMul(a, v);\n }\n }\n\n /**\n * Set linear combination of v and w: `a * v + b * w`\n */\n setCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x = x;\n this.y = y;\n return this;\n }\n\n setMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x = x;\n this.y = y;\n return this;\n }\n\n /**\n * Add a vector to this vector.\n *\n * @returns this\n */\n add(w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(w);\n this.x += w.x;\n this.y += w.y;\n return this;\n }\n\n /** @internal @deprecated Use addCombine or addMul */\n wAdd(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.addCombine(a, v, b, w);\n } else {\n return this.addMul(a, v);\n }\n }\n\n /**\n * Add linear combination of v and w: `a * v + b * w`\n */\n addCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x += x;\n this.y += y;\n return this;\n }\n\n addMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x += x;\n this.y += y;\n return this;\n }\n\n /**\n * @deprecated Use subCombine or subMul\n */\n wSub(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.subCombine(a, v, b, w);\n } else {\n return this.subMul(a, v);\n }}\n\n /**\n * Subtract linear combination of v and w: `a * v + b * w`\n */\n subCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x -= x;\n this.y -= y;\n return this;\n }\n\n subMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x -= x;\n this.y -= y;\n return this;\n }\n\n /**\n * Subtract a vector from this vector\n *\n * @returns this\n */\n sub(w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(w);\n this.x -= w.x;\n this.y -= w.y;\n return this;\n }\n\n /**\n * Multiply this vector by a scalar.\n *\n * @returns this\n */\n mul(m: number): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(m));\n this.x *= m;\n this.y *= m;\n return this;\n }\n\n /**\n * Get the length of this vector (the norm).\n *\n * For performance, use this instead of lengthSquared (if possible).\n */\n length(): number {\n return Vec2.lengthOf(this);\n }\n\n /**\n * Get the length squared.\n */\n lengthSquared(): number {\n return Vec2.lengthSquared(this);\n }\n\n /**\n * Convert this vector into a unit vector.\n *\n * @returns old length\n */\n normalize(): number {\n const length = this.length();\n if (length < EPSILON) {\n return 0.0;\n }\n const invLength = 1.0 / length;\n this.x *= invLength;\n this.y *= invLength;\n return length;\n }\n\n /**\n * Returns a new unit vector from the provided vector.\n *\n * @returns new unit vector\n */\n static normalize(v: Vec2Value): Vec2 {\n const length = Vec2.lengthOf(v);\n if (length < EPSILON) {\n return Vec2.zero();\n }\n const invLength = 1.0 / length;\n return Vec2.neo(v.x * invLength, v.y * invLength);\n }\n\n /**\n * Get the length of this vector (the norm).\n *\n * For performance, use this instead of lengthSquared (if possible).\n */\n static lengthOf(v: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n return math_sqrt(v.x * v.x + v.y * v.y);\n }\n\n /**\n * Get the length squared.\n */\n static lengthSquared(v: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n return v.x * v.x + v.y * v.y;\n }\n\n static distance(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n const dx = v.x - w.x;\n const dy = v.y - w.y;\n return math_sqrt(dx * dx + dy * dy);\n }\n\n static distanceSquared(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n const dx = v.x - w.x;\n const dy = v.y - w.y;\n return dx * dx + dy * dy;\n }\n\n static areEqual(v: Vec2Value, w: Vec2Value): boolean {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v === w || typeof w === \"object\" && w !== null && v.x === w.x && v.y === w.y;\n }\n\n /**\n * Get the skew vector such that dot(skew_vec, other) == cross(vec, other)\n */\n static skew(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(-v.y, v.x);\n }\n\n /** Dot product on two vectors */\n static dot(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.x + v.y * w.y;\n }\n\n /** Cross product between two vectors */\n static cross(v: Vec2Value, w: Vec2Value): number;\n /** Cross product between a vector and a scalar */\n static cross(v: Vec2Value, w: number): Vec2;\n /** Cross product between a scalar and a vector */\n static cross(v: number, w: Vec2Value): Vec2;\n static cross(v: any, w: any): any {\n if (typeof w === \"number\") {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y, -w * v.x);\n\n } else if (typeof v === \"number\") {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y, v * w.x);\n\n } else {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.y - v.y * w.x;\n }\n }\n\n /** Cross product on two vectors */\n static crossVec2Vec2(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.y - v.y * w.x;\n }\n\n /** Cross product on a vector and a scalar */\n static crossVec2Num(v: Vec2Value, w: number): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y, -w * v.x);\n }\n\n /** Cross product on a vector and a scalar */\n static crossNumVec2(v: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y, v * w.x);\n }\n\n /** Returns `a + (v x w)` */\n static addCross(a: Vec2Value, v: Vec2Value, w: number): Vec2;\n /** Returns `a + (v x w)` */\n static addCross(a: Vec2Value, v: number, w: Vec2Value): Vec2;\n static addCross(a: Vec2Value, v: any, w: any): Vec2 {\n if (typeof w === \"number\") {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y + a.x, -w * v.x + a.y);\n\n } else if (typeof v === \"number\") {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y + a.x, v * w.x + a.y);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n /**\n * Returns `a + (v x w)`\n */\n static addCrossVec2Num(a: Vec2Value, v: Vec2Value, w: number): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y + a.x, -w * v.x + a.y);\n }\n\n /**\n * Returns `a + (v x w)`\n */\n static addCrossNumVec2(a: Vec2Value, v: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y + a.x, v * w.x + a.y);\n }\n\n static add(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(v.x + w.x, v.y + w.y);\n }\n\n /** @hidden @deprecated */\n static wAdd(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return Vec2.combine(a, v, b, w);\n } else {\n return Vec2.mulNumVec2(a, v);\n }\n }\n\n static combine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n return Vec2.zero().setCombine(a, v, b, w);\n }\n\n static sub(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(v.x - w.x, v.y - w.y);\n }\n\n static mul(a: Vec2Value, b: number): Vec2;\n static mul(a: number, b: Vec2Value): Vec2;\n static mul(a: any, b: any): Vec2 {\n if (typeof a === \"object\") {\n if (_ASSERT) Vec2.assert(a);\n if (_ASSERT) console.assert(Number.isFinite(b));\n return Vec2.neo(a.x * b, a.y * b);\n\n } else if (typeof b === \"object\") {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(b);\n return Vec2.neo(a * b.x, a * b.y);\n }\n }\n\n static mulVec2Num(a: Vec2Value, b: number): Vec2 {\n if (_ASSERT) Vec2.assert(a);\n if (_ASSERT) console.assert(Number.isFinite(b));\n return Vec2.neo(a.x * b, a.y * b);\n }\n\n static mulNumVec2(a: number, b: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(b);\n return Vec2.neo(a * b.x, a * b.y);\n }\n\n neg(): Vec2 {\n this.x = -this.x;\n this.y = -this.y;\n return this;\n }\n\n static neg(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(-v.x, -v.y);\n }\n\n static abs(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(math_abs(v.x), math_abs(v.y));\n }\n\n static mid(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo((v.x + w.x) * 0.5, (v.y + w.y) * 0.5);\n }\n\n static upper(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(math_max(v.x, w.x), math_max(v.y, w.y));\n }\n\n static lower(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(math_min(v.x, w.x), math_min(v.y, w.y));\n }\n\n clamp(max: number): Vec2 {\n const lengthSqr = this.x * this.x + this.y * this.y;\n if (lengthSqr > max * max) {\n const scale = max / math_sqrt(lengthSqr);\n this.x *= scale;\n this.y *= scale;\n }\n return this;\n }\n\n static clamp(v: Vec2Value, max: number): Vec2 {\n const r = Vec2.neo(v.x, v.y);\n r.clamp(max);\n return r;\n }\n\n /** @hidden */\n static clampVec2(v: Vec2Value, min?: Vec2Value, max?: Vec2Value): Vec2Value {\n return {\n x: clamp(v.x, min?.x, max?.x),\n y: clamp(v.y, min?.y, max?.y)\n };\n }\n\n /** @hidden @deprecated */\n static scaleFn(x: number, y: number) {\n // todo: this was used in examples, remove in the future\n return function(v: Vec2Value): Vec2 {\n return Vec2.neo(v.x * x, v.y * y);\n };\n }\n\n /** @hidden @deprecated */\n static translateFn(x: number, y: number) {\n // todo: this was used in examples, remove in the future\n return function(v: Vec2Value): Vec2 {\n return Vec2.neo(v.x + x, v.y + y);\n };\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { EPSILON } from \"../common/Math\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n/**\n * Ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n */\nexport interface RayCastInput {\n p1: Vec2Value;\n p2: Vec2Value;\n maxFraction: number;\n}\n\nexport type RayCastCallback = (subInput: RayCastInput, id: number) => number;\n\n/**\n * Ray-cast output data. The ray hits at `p1 + fraction * (p2 - p1)`,\n * where `p1` and `p2` come from RayCastInput.\n */\nexport interface RayCastOutput {\n normal: Vec2;\n fraction: number;\n}\n\n/** Axis-aligned bounding box */\nexport interface AABBValue {\n lowerBound: Vec2Value;\n upperBound: Vec2Value;\n}\n\ndeclare module \"./AABB\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function AABB(lower?: Vec2Value, upper?: Vec2Value): AABB;\n}\n\n/** Axis-aligned bounding box */\n// @ts-expect-error\nexport class AABB {\n lowerBound: Vec2;\n upperBound: Vec2;\n\n constructor(lower?: Vec2Value, upper?: Vec2Value) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof AABB)) {\n return new AABB(lower, upper);\n }\n\n this.lowerBound = Vec2.zero();\n this.upperBound = Vec2.zero();\n\n if (typeof lower === \"object\") {\n this.lowerBound.setVec2(lower);\n }\n if (typeof upper === \"object\") {\n this.upperBound.setVec2(upper);\n } else if (typeof lower === \"object\") {\n this.upperBound.setVec2(lower);\n }\n }\n\n /**\n * Verify that the bounds are sorted.\n */\n isValid(): boolean {\n return AABB.isValid(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.lowerBound) && Vec2.isValid(obj.upperBound) && Vec2.sub(obj.upperBound, obj.lowerBound).lengthSquared() >= 0;\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!AABB.isValid(o), \"Invalid AABB!\", o);\n }\n\n /**\n * Get the center of the AABB.\n */\n getCenter(): Vec2 {\n return Vec2.neo((this.lowerBound.x + this.upperBound.x) * 0.5, (this.lowerBound.y + this.upperBound.y) * 0.5);\n }\n\n /**\n * Get the extents of the AABB (half-widths).\n */\n getExtents(): Vec2 {\n return Vec2.neo((this.upperBound.x - this.lowerBound.x) * 0.5, (this.upperBound.y - this.lowerBound.y) * 0.5);\n }\n\n /**\n * Get the perimeter length.\n */\n getPerimeter(): number {\n return 2.0 * (this.upperBound.x - this.lowerBound.x + this.upperBound.y - this.lowerBound.y);\n }\n\n /**\n * Combine one or two AABB into this one.\n */\n combine(a: AABBValue, b?: AABBValue): void {\n b = b || this;\n\n const lowerA = a.lowerBound;\n const upperA = a.upperBound;\n const lowerB = b.lowerBound;\n const upperB = b.upperBound;\n\n const lowerX = math_min(lowerA.x, lowerB.x);\n const lowerY = math_min(lowerA.y, lowerB.y);\n const upperX = math_max(upperB.x, upperA.x);\n const upperY = math_max(upperB.y, upperA.y);\n\n this.lowerBound.setNum(lowerX, lowerY);\n this.upperBound.setNum(upperX, upperY);\n }\n\n combinePoints(a: Vec2Value, b: Vec2Value): void {\n this.lowerBound.setNum(math_min(a.x, b.x), math_min(a.y, b.y));\n this.upperBound.setNum(math_max(a.x, b.x), math_max(a.y, b.y));\n }\n\n set(aabb: AABBValue): void {\n this.lowerBound.setNum(aabb.lowerBound.x, aabb.lowerBound.y);\n this.upperBound.setNum(aabb.upperBound.x, aabb.upperBound.y);\n }\n\n contains(aabb: AABBValue): boolean {\n let result = true;\n result = result && this.lowerBound.x <= aabb.lowerBound.x;\n result = result && this.lowerBound.y <= aabb.lowerBound.y;\n result = result && aabb.upperBound.x <= this.upperBound.x;\n result = result && aabb.upperBound.y <= this.upperBound.y;\n return result;\n }\n\n extend(value: number): AABB {\n AABB.extend(this, value);\n return this;\n }\n\n static extend(out: AABBValue, value: number): AABBValue {\n out.lowerBound.x -= value;\n out.lowerBound.y -= value;\n out.upperBound.x += value;\n out.upperBound.y += value;\n return out;\n }\n\n static testOverlap(a: AABBValue, b: AABBValue): boolean {\n const d1x = b.lowerBound.x - a.upperBound.x;\n const d2x = a.lowerBound.x - b.upperBound.x;\n\n const d1y = b.lowerBound.y - a.upperBound.y;\n const d2y = a.lowerBound.y - b.upperBound.y;\n\n if (d1x > 0 || d1y > 0 || d2x > 0 || d2y > 0) {\n return false;\n }\n return true;\n }\n\n static areEqual(a: AABBValue, b: AABBValue): boolean {\n return Vec2.areEqual(a.lowerBound, b.lowerBound) && Vec2.areEqual(a.upperBound, b.upperBound);\n }\n\n static diff(a: AABBValue, b: AABBValue): number {\n const wD = math_max(0, math_min(a.upperBound.x, b.upperBound.x) - math_max(b.lowerBound.x, a.lowerBound.x));\n const hD = math_max(0, math_min(a.upperBound.y, b.upperBound.y) - math_max(b.lowerBound.y, a.lowerBound.y));\n\n const wA = a.upperBound.x - a.lowerBound.x;\n const hA = a.upperBound.y - a.lowerBound.y;\n\n const wB = b.upperBound.x - b.lowerBound.x;\n const hB = b.upperBound.y - b.lowerBound.y;\n\n return wA * hA + wB * hB - wD * hD;\n }\n\n rayCast(output: RayCastOutput, input: RayCastInput): boolean {\n // From Real-time Collision Detection, p179.\n\n let tmin = -Infinity;\n let tmax = Infinity;\n\n const p = input.p1;\n const d = Vec2.sub(input.p2, input.p1);\n const absD = Vec2.abs(d);\n\n const normal = Vec2.zero();\n\n for (let f: \"x\" | \"y\" = \"x\"; f !== null; f = (f === \"x\" ? \"y\" : null)) {\n if (absD.x < EPSILON) {\n // Parallel.\n if (p[f] < this.lowerBound[f] || this.upperBound[f] < p[f]) {\n return false;\n }\n } else {\n const inv_d = 1.0 / d[f];\n let t1 = (this.lowerBound[f] - p[f]) * inv_d;\n let t2 = (this.upperBound[f] - p[f]) * inv_d;\n\n // Sign of the normal vector.\n let s = -1.0;\n\n if (t1 > t2) {\n const temp = t1;\n t1 = t2;\n t2 = temp;\n s = 1.0;\n }\n\n // Push the min up\n if (t1 > tmin) {\n normal.setZero();\n normal[f] = s;\n tmin = t1;\n }\n\n // Pull the max down\n tmax = math_min(tmax, t2);\n\n if (tmin > tmax) {\n return false;\n }\n }\n }\n\n // Does the ray start inside the box?\n // Does the ray intersect beyond the max fraction?\n if (tmin < 0.0 || input.maxFraction < tmin) {\n return false;\n }\n\n // Intersection.\n output.fraction = tmin;\n output.normal = normal;\n return true;\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static combinePoints(out: AABBValue, a: Vec2Value, b: Vec2Value): AABBValue {\n out.lowerBound.x = math_min(a.x, b.x);\n out.lowerBound.y = math_min(a.y, b.y);\n out.upperBound.x = math_max(a.x, b.x);\n out.upperBound.y = math_max(a.y, b.y);\n return out;\n }\n\n static combinedPerimeter(a: AABBValue, b: AABBValue) {\n const lx = math_min(a.lowerBound.x, b.lowerBound.x);\n const ly = math_min(a.lowerBound.y, b.lowerBound.y);\n const ux = math_max(a.upperBound.x, b.upperBound.x);\n const uy = math_max(a.upperBound.y, b.upperBound.y);\n return 2.0 * (ux - lx + uy - ly); \n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Tuning constants based on meters-kilograms-seconds (MKS) units.\n * \n * Some tolerances are absolute and some are relative. Absolute tolerances use MKS units.\n */\nexport class Settings {\n /**\n * You can use this to change the length scale used by your game.\n * \n * For example for inches you could use 39.4.\n */\n static lengthUnitsPerMeter = 1.0;\n \n // Collision\n /**\n * The maximum number of contact points between two convex shapes. Do not change\n * this value.\n */\n static maxManifoldPoints: number = 2;\n\n /**\n * The maximum number of vertices on a convex polygon. You cannot increase this\n * too much because BlockAllocator has a maximum object size.\n */\n static maxPolygonVertices: number = 12;\n\n /**\n * This is used to fatten AABBs in the dynamic tree. This allows proxies to move\n * by a small amount without triggering a tree adjustment. This is in meters.\n */\n static aabbExtension: number = 0.1;\n\n /**\n * This is used to fatten AABBs in the dynamic tree. This is used to predict the\n * future position based on the current displacement. This is a dimensionless\n * multiplier.\n */\n static aabbMultiplier: number = 2.0;\n\n /**\n * A small length used as a collision and constraint tolerance. Usually it is\n * chosen to be numerically significant, but visually insignificant.\n */\n static linearSlop: number = 0.005;\n\n /**\n * A small angle used as a collision and constraint tolerance. Usually it is\n * chosen to be numerically significant, but visually insignificant.\n */\n static angularSlop: number = (2.0 / 180.0 * math_PI);\n\n /**\n * The radius of the polygon/edge shape skin. This should not be modified.\n * Making this smaller means polygons will have an insufficient buffer for\n * continuous collision. Making it larger may create artifacts for vertex\n * collision.\n */\n static get polygonRadius(): number { return 2.0 * Settings.linearSlop; }\n\n /**\n * Maximum number of sub-steps per contact in continuous physics simulation.\n */\n static maxSubSteps: number = 8;\n\n // Dynamics\n\n /**\n * Maximum number of contacts to be handled to solve a TOI impact.\n */\n static maxTOIContacts: number = 32;\n\n /**\n * Maximum iterations to solve a TOI.\n */\n static maxTOIIterations: number = 20;\n\n /**\n * Maximum iterations to find Distance.\n */\n static maxDistanceIterations: number = 20;\n\n /**\n * A velocity threshold for elastic collisions. Any collision with a relative\n * linear velocity below this threshold will be treated as inelastic.\n */\n static velocityThreshold: number = 1.0;\n\n /**\n * The maximum linear position correction used when solving constraints. This\n * helps to prevent overshoot.\n */\n static maxLinearCorrection: number = 0.2;\n\n /**\n * The maximum angular position correction used when solving constraints. This\n * helps to prevent overshoot.\n */\n static maxAngularCorrection: number = (8.0 / 180.0 * math_PI);\n\n /**\n * The maximum linear velocity of a body. This limit is very large and is used\n * to prevent numerical problems. You shouldn't need to adjust Settings.\n */\n static maxTranslation: number = 2.0;\n\n /**\n * The maximum angular velocity of a body. This limit is very large and is used\n * to prevent numerical problems. You shouldn't need to adjust Settings.\n */\n static maxRotation: number = (0.5 * math_PI);\n\n /**\n * This scale factor controls how fast overlap is resolved. Ideally this would\n * be 1 so that overlap is removed in one time step. However using values close\n * to 1 often lead to overshoot.\n */\n static baumgarte: number = 0.2;\n static toiBaugarte: number = 0.75;\n\n // Sleep\n\n /**\n * The time that a body must be still before it will go to sleep.\n */\n static timeToSleep: number = 0.5;\n\n /**\n * A body cannot sleep if its linear velocity is above this tolerance.\n */\n static linearSleepTolerance: number = 0.01;\n\n /**\n * A body cannot sleep if its angular velocity is above this tolerance.\n */\n static angularSleepTolerance: number = (2.0 / 180.0 * math_PI);\n}\n\n/** @internal */\nexport class SettingsInternal {\n static get maxManifoldPoints() {\n return Settings.maxManifoldPoints;\n }\n static get maxPolygonVertices() {\n return Settings.maxPolygonVertices;\n }\n static get aabbExtension() {\n return Settings.aabbExtension * Settings.lengthUnitsPerMeter;\n }\n static get aabbMultiplier() {\n return Settings.aabbMultiplier;\n }\n static get linearSlop() {\n return Settings.linearSlop * Settings.lengthUnitsPerMeter;\n }\n static get linearSlopSquared() {\n return Settings.linearSlop * Settings.lengthUnitsPerMeter * Settings.linearSlop * Settings.lengthUnitsPerMeter;\n }\n static get angularSlop() {\n return Settings.angularSlop;\n }\n static get polygonRadius() {\n return 2.0 * Settings.linearSlop;\n }\n static get maxSubSteps() {\n return Settings.maxSubSteps;\n }\n static get maxTOIContacts() {\n return Settings.maxTOIContacts;\n }\n static get maxTOIIterations() {\n return Settings.maxTOIIterations;\n }\n static get maxDistanceIterations() {\n return Settings.maxDistanceIterations;\n }\n static get velocityThreshold() {\n return Settings.velocityThreshold * Settings.lengthUnitsPerMeter;\n }\n static get maxLinearCorrection() {\n return Settings.maxLinearCorrection * Settings.lengthUnitsPerMeter;\n }\n static get maxAngularCorrection() {\n return Settings.maxAngularCorrection;\n }\n static get maxTranslation() {\n return Settings.maxTranslation * Settings.lengthUnitsPerMeter;\n }\n static get maxTranslationSquared() {\n return Settings.maxTranslation * Settings.lengthUnitsPerMeter * Settings.maxTranslation * Settings.lengthUnitsPerMeter;\n }\n static get maxRotation() {\n return Settings.maxRotation;\n }\n static get maxRotationSquared() {\n return Settings.maxRotation * Settings.maxRotation;\n }\n static get baumgarte() {\n return Settings.baumgarte;\n }\n static get toiBaugarte() {\n return Settings.toiBaugarte;\n }\n static get timeToSleep() {\n return Settings.timeToSleep;\n }\n static get linearSleepTolerance() {\n return Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter;\n }\n static get linearSleepToleranceSqr() {\n return Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter * Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter;\n }\n static get angularSleepTolerance() {\n return Settings.angularSleepTolerance;\n }\n static get angularSleepToleranceSqr() {\n return Settings.angularSleepTolerance * Settings.angularSleepTolerance;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */\nexport interface PoolOptions {\n max?: number,\n create?: () => T,\n /** Called when an object is being re-allocated. */\n allocate?: (item: T) => void,\n /** Called when an object is returned to pool. */\n release?: (item: T) => void,\n /** Called when an object is returned to the pool but will be disposed from pool. */\n dispose?: (item: T) => T,\n}\n\n/** @internal */\nexport class Pool {\n _list: T[] = [];\n _max: number = Infinity;\n\n _createFn: () => T;\n _hasCreateFn: boolean = false;\n _createCount: number = 0;\n\n _allocateFn: (item: T) => void;\n _hasAllocateFn: boolean = false;\n _allocateCount: number = 0;\n\n _releaseFn: (item: T) => void;\n _hasReleaseFn: boolean = false;\n _releaseCount: number = 0;\n\n _disposeFn: (item: T) => T;\n _hasDisposeFn: boolean = false;\n _disposeCount: number = 0;\n\n constructor(opts: PoolOptions) {\n this._list = [];\n this._max = opts.max || this._max;\n\n this._createFn = opts.create;\n this._hasCreateFn = typeof this._createFn === \"function\";\n this._allocateFn = opts.allocate;\n this._hasAllocateFn = typeof this._allocateFn === \"function\";\n this._releaseFn = opts.release;\n this._hasReleaseFn = typeof this._releaseFn === \"function\";\n this._disposeFn = opts.dispose;\n this._hasDisposeFn = typeof this._disposeFn === \"function\";\n }\n\n max(n?: number): number | Pool {\n if (typeof n === \"number\") {\n this._max = n;\n return this;\n }\n return this._max;\n }\n\n size(): number {\n return this._list.length;\n }\n\n allocate(): T {\n let item: T;\n if (this._list.length > 0) {\n item = this._list.shift();\n } else {\n this._createCount++;\n if (this._hasCreateFn) {\n item = this._createFn();\n } else {\n // tslint:disable-next-line:no-object-literal-type-assertion\n item = {} as T;\n }\n }\n this._allocateCount++;\n if (this._hasAllocateFn) {\n this._allocateFn(item);\n }\n return item;\n }\n\n release(item: T): void {\n if (this._list.length < this._max) {\n this._releaseCount++;\n if (this._hasReleaseFn) {\n this._releaseFn(item);\n }\n this._list.push(item);\n } else {\n this._disposeCount++;\n if (this._hasDisposeFn) {\n item = this._disposeFn(item);\n }\n }\n }\n\n toString(): string {\n return \" +\" + this._createCount + \" >\" + this._allocateCount + \" <\" + this._releaseCount + \" -\"\n + this._disposeCount + \" =\" + this._list.length + \"/\" + this._max;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { Pool } from \"../util/Pool\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { AABB, AABBValue, RayCastCallback, RayCastInput } from \"./AABB\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n\n\nexport type DynamicTreeQueryCallback = (nodeId: number) => boolean;\n\n/**\n * A node in the dynamic tree. The client does not interact with this directly.\n */\nexport class TreeNode {\n id: number;\n /** Enlarged AABB */\n aabb: AABB = new AABB();\n userData: T = null;\n parent: TreeNode = null;\n child1: TreeNode = null;\n child2: TreeNode = null;\n /** 0: leaf, -1: free node */\n height: number = -1;\n\n constructor(id?: number) {\n this.id = id;\n }\n\n /** @internal */\n toString(): string {\n return this.id + \": \" + this.userData;\n }\n\n isLeaf(): boolean {\n return this.child1 == null;\n }\n}\n\n/** @internal */ const poolTreeNode = new Pool>({\n create(): TreeNode {\n return new TreeNode();\n },\n release(node: TreeNode) {\n node.userData = null;\n node.parent = null;\n node.child1 = null;\n node.child2 = null;\n node.height = -1;\n node.id = undefined;\n }\n});\n\n/**\n * A dynamic AABB tree broad-phase, inspired by Nathanael Presson's btDbvt. A\n * dynamic tree arranges data in a binary tree to accelerate queries such as\n * volume queries and ray casts. Leafs are proxies with an AABB. In the tree we\n * expand the proxy AABB by `aabbExtension` so that the proxy AABB is bigger\n * than the client object. This allows the client object to move by small\n * amounts without triggering a tree update.\n *\n * Nodes are pooled and relocatable, so we use node indices rather than\n * pointers.\n */\nexport class DynamicTree {\n m_root: TreeNode;\n m_lastProxyId: number;\n m_nodes: {\n [id: number]: TreeNode\n };\n\n constructor() {\n this.m_root = null;\n this.m_nodes = {};\n this.m_lastProxyId = 0;\n }\n\n /**\n * Get proxy user data.\n *\n * @return the proxy user data or 0 if the id is invalid.\n */\n getUserData(id: number): T {\n const node = this.m_nodes[id];\n if (_ASSERT) console.assert(!!node);\n return node.userData;\n }\n\n /**\n * Get the fat AABB for a node id.\n *\n * @return the proxy user data or 0 if the id is invalid.\n */\n getFatAABB(id: number): AABB {\n const node = this.m_nodes[id];\n if (_ASSERT) console.assert(!!node);\n return node.aabb;\n }\n\n allocateNode(): TreeNode {\n const node = poolTreeNode.allocate();\n node.id = ++this.m_lastProxyId;\n this.m_nodes[node.id] = node;\n return node;\n }\n\n freeNode(node: TreeNode): void {\n // tslint:disable-next-line:no-dynamic-delete\n delete this.m_nodes[node.id];\n poolTreeNode.release(node);\n }\n\n /**\n * Create a proxy in the tree as a leaf node. We return the index of the node\n * instead of a pointer so that we can grow the node pool.\n *\n * Create a proxy. Provide a tight fitting AABB and a userData pointer.\n */\n createProxy(aabb: AABBValue, userData: T): number {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n\n const node = this.allocateNode();\n\n node.aabb.set(aabb);\n\n // Fatten the aabb.\n AABB.extend(node.aabb, Settings.aabbExtension);\n\n node.userData = userData;\n node.height = 0;\n\n this.insertLeaf(node);\n\n return node.id;\n }\n\n /**\n * Destroy a proxy. This asserts if the id is invalid.\n */\n destroyProxy(id: number): void {\n const node = this.m_nodes[id];\n\n if (_ASSERT) console.assert(!!node);\n if (_ASSERT) console.assert(node.isLeaf());\n\n this.removeLeaf(node);\n this.freeNode(node);\n }\n\n /**\n * Move a proxy with a swepted AABB. If the proxy has moved outside of its\n * fattened AABB, then the proxy is removed from the tree and re-inserted.\n * Otherwise the function returns immediately.\n *\n * @param d Displacement\n *\n * @return true if the proxy was re-inserted.\n */\n moveProxy(id: number, aabb: AABBValue, d: Vec2Value): boolean {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n if (_ASSERT) console.assert(!d || Vec2.isValid(d));\n\n const node = this.m_nodes[id];\n\n if (_ASSERT) console.assert(!!node);\n if (_ASSERT) console.assert(node.isLeaf());\n\n if (node.aabb.contains(aabb)) {\n return false;\n }\n\n this.removeLeaf(node);\n\n node.aabb.set(aabb);\n\n // Extend AABB.\n aabb = node.aabb;\n AABB.extend(aabb, Settings.aabbExtension);\n\n // Predict AABB displacement.\n // const d = Vec2.mul(Settings.aabbMultiplier, displacement);\n\n if (d.x < 0.0) {\n aabb.lowerBound.x += d.x * Settings.aabbMultiplier;\n } else {\n aabb.upperBound.x += d.x * Settings.aabbMultiplier;\n }\n\n if (d.y < 0.0) {\n aabb.lowerBound.y += d.y * Settings.aabbMultiplier;\n } else {\n aabb.upperBound.y += d.y * Settings.aabbMultiplier;\n }\n\n this.insertLeaf(node);\n\n return true;\n }\n\n insertLeaf(leaf: TreeNode): void {\n if (_ASSERT) console.assert(AABB.isValid(leaf.aabb));\n\n if (this.m_root == null) {\n this.m_root = leaf;\n this.m_root.parent = null;\n return;\n }\n\n // Find the best sibling for this node\n const leafAABB = leaf.aabb;\n let index = this.m_root;\n while (!index.isLeaf()) {\n const child1 = index.child1;\n const child2 = index.child2;\n\n const area = index.aabb.getPerimeter();\n\n const combinedArea = AABB.combinedPerimeter(index.aabb, leafAABB);\n\n // Cost of creating a new parent for this node and the new leaf\n const cost = 2.0 * combinedArea;\n\n // Minimum cost of pushing the leaf further down the tree\n const inheritanceCost = 2.0 * (combinedArea - area);\n\n // Cost of descending into child1\n const newArea1 = AABB.combinedPerimeter(leafAABB, child1.aabb);\n let cost1 = newArea1 + inheritanceCost;\n if (!child1.isLeaf()) {\n const oldArea = child1.aabb.getPerimeter();\n cost1 -= oldArea;\n }\n\n // Cost of descending into child2\n const newArea2 = AABB.combinedPerimeter(leafAABB, child2.aabb);\n let cost2 = newArea2 + inheritanceCost;\n if (!child2.isLeaf()) {\n const oldArea = child2.aabb.getPerimeter();\n cost2 -= oldArea;\n }\n\n // Descend according to the minimum cost.\n if (cost < cost1 && cost < cost2) {\n break;\n }\n\n // Descend\n if (cost1 < cost2) {\n index = child1;\n } else {\n index = child2;\n }\n }\n\n const sibling = index;\n\n // Create a new parent.\n const oldParent = sibling.parent;\n const newParent = this.allocateNode();\n newParent.parent = oldParent;\n newParent.userData = null;\n newParent.aabb.combine(leafAABB, sibling.aabb);\n newParent.height = sibling.height + 1;\n\n if (oldParent != null) {\n // The sibling was not the root.\n if (oldParent.child1 === sibling) {\n oldParent.child1 = newParent;\n } else {\n oldParent.child2 = newParent;\n }\n\n newParent.child1 = sibling;\n newParent.child2 = leaf;\n sibling.parent = newParent;\n leaf.parent = newParent;\n } else {\n // The sibling was the root.\n newParent.child1 = sibling;\n newParent.child2 = leaf;\n sibling.parent = newParent;\n leaf.parent = newParent;\n this.m_root = newParent;\n }\n\n // Walk back up the tree fixing heights and AABBs\n index = leaf.parent;\n while (index != null) {\n index = this.balance(index);\n\n const child1 = index.child1;\n const child2 = index.child2;\n\n if (_ASSERT) console.assert(child1 != null);\n if (_ASSERT) console.assert(child2 != null);\n\n index.height = 1 + math_max(child1.height, child2.height);\n index.aabb.combine(child1.aabb, child2.aabb);\n\n index = index.parent;\n }\n\n // validate();\n }\n\n removeLeaf(leaf: TreeNode): void {\n if (leaf === this.m_root) {\n this.m_root = null;\n return;\n }\n\n const parent = leaf.parent;\n const grandParent = parent.parent;\n let sibling;\n if (parent.child1 === leaf) {\n sibling = parent.child2;\n } else {\n sibling = parent.child1;\n }\n\n if (grandParent != null) {\n // Destroy parent and connect sibling to grandParent.\n if (grandParent.child1 === parent) {\n grandParent.child1 = sibling;\n } else {\n grandParent.child2 = sibling;\n }\n sibling.parent = grandParent;\n this.freeNode(parent);\n\n // Adjust ancestor bounds.\n let index = grandParent;\n while (index != null) {\n index = this.balance(index);\n\n const child1 = index.child1;\n const child2 = index.child2;\n\n index.aabb.combine(child1.aabb, child2.aabb);\n index.height = 1 + math_max(child1.height, child2.height);\n\n index = index.parent;\n }\n } else {\n this.m_root = sibling;\n sibling.parent = null;\n this.freeNode(parent);\n }\n\n // validate();\n }\n\n /**\n * Perform a left or right rotation if node A is imbalanced. Returns the new\n * root index.\n */\n balance(iA: TreeNode): TreeNode {\n if (_ASSERT) console.assert(iA != null);\n\n const A = iA;\n if (A.isLeaf() || A.height < 2) {\n return iA;\n }\n\n const B = A.child1;\n const C = A.child2;\n\n const balance = C.height - B.height;\n\n // Rotate C up\n if (balance > 1) {\n const F = C.child1;\n const G = C.child2;\n\n // Swap A and C\n C.child1 = A;\n C.parent = A.parent;\n A.parent = C;\n\n // A's old parent should point to C\n if (C.parent != null) {\n if (C.parent.child1 === iA) {\n C.parent.child1 = C;\n } else {\n C.parent.child2 = C;\n }\n } else {\n this.m_root = C;\n }\n\n // Rotate\n if (F.height > G.height) {\n C.child2 = F;\n A.child2 = G;\n G.parent = A;\n A.aabb.combine(B.aabb, G.aabb);\n C.aabb.combine(A.aabb, F.aabb);\n\n A.height = 1 + math_max(B.height, G.height);\n C.height = 1 + math_max(A.height, F.height);\n } else {\n C.child2 = G;\n A.child2 = F;\n F.parent = A;\n A.aabb.combine(B.aabb, F.aabb);\n C.aabb.combine(A.aabb, G.aabb);\n\n A.height = 1 + math_max(B.height, F.height);\n C.height = 1 + math_max(A.height, G.height);\n }\n\n return C;\n }\n\n // Rotate B up\n if (balance < -1) {\n const D = B.child1;\n const E = B.child2;\n\n // Swap A and B\n B.child1 = A;\n B.parent = A.parent;\n A.parent = B;\n\n // A's old parent should point to B\n if (B.parent != null) {\n if (B.parent.child1 === A) {\n B.parent.child1 = B;\n } else {\n B.parent.child2 = B;\n }\n } else {\n this.m_root = B;\n }\n\n // Rotate\n if (D.height > E.height) {\n B.child2 = D;\n A.child1 = E;\n E.parent = A;\n A.aabb.combine(C.aabb, E.aabb);\n B.aabb.combine(A.aabb, D.aabb);\n\n A.height = 1 + math_max(C.height, E.height);\n B.height = 1 + math_max(A.height, D.height);\n } else {\n B.child2 = E;\n A.child1 = D;\n D.parent = A;\n A.aabb.combine(C.aabb, D.aabb);\n B.aabb.combine(A.aabb, E.aabb);\n\n A.height = 1 + math_max(C.height, D.height);\n B.height = 1 + math_max(A.height, E.height);\n }\n\n return B;\n }\n\n return A;\n }\n\n /**\n * Compute the height of the binary tree in O(N) time. Should not be called\n * often.\n */\n getHeight(): number {\n if (this.m_root == null) {\n return 0;\n }\n\n return this.m_root.height;\n }\n\n /**\n * Get the ratio of the sum of the node areas to the root area.\n */\n getAreaRatio(): number {\n if (this.m_root == null) {\n return 0.0;\n }\n\n const root = this.m_root;\n const rootArea = root.aabb.getPerimeter();\n\n let totalArea = 0.0;\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height < 0) {\n // Free node in pool\n continue;\n }\n\n totalArea += node.aabb.getPerimeter();\n }\n\n this.iteratorPool.release(it);\n\n return totalArea / rootArea;\n }\n\n /**\n * Compute the height of a sub-tree.\n */\n computeHeight(id?: number): number {\n let node;\n if (typeof id !== \"undefined\") {\n node = this.m_nodes[id];\n } else {\n node = this.m_root;\n }\n\n // if (_ASSERT) console.assert(0 <= id && id < this.m_nodeCapacity);\n\n if (node.isLeaf()) {\n return 0;\n }\n\n const height1 = this.computeHeight(node.child1.id);\n const height2 = this.computeHeight(node.child2.id);\n return 1 + math_max(height1, height2);\n }\n\n validateStructure(node: TreeNode): void {\n if (node == null) {\n return;\n }\n\n if (node === this.m_root) {\n if (_ASSERT) console.assert(node.parent == null);\n }\n\n const child1 = node.child1;\n const child2 = node.child2;\n\n if (node.isLeaf()) {\n if (_ASSERT) console.assert(child1 == null);\n if (_ASSERT) console.assert(child2 == null);\n if (_ASSERT) console.assert(node.height === 0);\n return;\n }\n\n // if (_ASSERT) console.assert(0 <= child1 && child1 < this.m_nodeCapacity);\n // if (_ASSERT) console.assert(0 <= child2 && child2 < this.m_nodeCapacity);\n\n if (_ASSERT) console.assert(child1.parent === node);\n if (_ASSERT) console.assert(child2.parent === node);\n\n this.validateStructure(child1);\n this.validateStructure(child2);\n }\n\n validateMetrics(node: TreeNode): void {\n if (node == null) {\n return;\n }\n\n const child1 = node.child1;\n const child2 = node.child2;\n\n if (node.isLeaf()) {\n if (_ASSERT) console.assert(child1 == null);\n if (_ASSERT) console.assert(child2 == null);\n if (_ASSERT) console.assert(node.height === 0);\n return;\n }\n\n // if (_ASSERT) console.assert(0 <= child1 && child1 < this.m_nodeCapacity);\n // if (_ASSERT) console.assert(0 <= child2 && child2 < this.m_nodeCapacity);\n\n const height1 = child1.height;\n const height2 = child2.height;\n const height = 1 + math_max(height1, height2);\n if (_ASSERT) console.assert(node.height === height);\n\n const aabb = new AABB();\n aabb.combine(child1.aabb, child2.aabb);\n\n if (_ASSERT) console.assert(AABB.areEqual(aabb, node.aabb));\n\n this.validateMetrics(child1);\n this.validateMetrics(child2);\n }\n\n /**\n * Validate this tree. For testing.\n */\n validate(): void {\n if (!_ASSERT) return;\n this.validateStructure(this.m_root);\n this.validateMetrics(this.m_root);\n\n console.assert(this.getHeight() === this.computeHeight());\n }\n\n /**\n * Get the maximum balance of an node in the tree. The balance is the difference\n * in height of the two children of a node.\n */\n getMaxBalance(): number {\n let maxBalance = 0;\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height <= 1) {\n continue;\n }\n\n if (_ASSERT) console.assert(!node.isLeaf());\n\n const balance = math_abs(node.child2.height - node.child1.height);\n maxBalance = math_max(maxBalance, balance);\n }\n this.iteratorPool.release(it);\n\n return maxBalance;\n }\n\n /**\n * Build an optimal tree. Very expensive. For testing.\n */\n rebuildBottomUp(): void {\n const nodes = [];\n let count = 0;\n\n // Build array of leaves. Free the rest.\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height < 0) {\n // free node in pool\n continue;\n }\n\n if (node.isLeaf()) {\n node.parent = null;\n nodes[count] = node;\n ++count;\n } else {\n this.freeNode(node);\n }\n }\n this.iteratorPool.release(it);\n\n while (count > 1) {\n let minCost = Infinity;\n let iMin = -1;\n let jMin = -1;\n for (let i = 0; i < count; ++i) {\n const aabbi = nodes[i].aabb;\n for (let j = i + 1; j < count; ++j) {\n const aabbj = nodes[j].aabb;\n const cost = AABB.combinedPerimeter(aabbi, aabbj);\n if (cost < minCost) {\n iMin = i;\n jMin = j;\n minCost = cost;\n }\n }\n }\n\n const child1 = nodes[iMin];\n const child2 = nodes[jMin];\n\n const parent = this.allocateNode();\n parent.child1 = child1;\n parent.child2 = child2;\n parent.height = 1 + math_max(child1.height, child2.height);\n parent.aabb.combine(child1.aabb, child2.aabb);\n parent.parent = null;\n\n child1.parent = parent;\n child2.parent = parent;\n\n nodes[jMin] = nodes[count - 1];\n nodes[iMin] = parent;\n --count;\n }\n\n this.m_root = nodes[0];\n\n if (_ASSERT) this.validate();\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n // Build array of leaves. Free the rest.\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n const aabb = node.aabb;\n aabb.lowerBound.x -= newOrigin.x;\n aabb.lowerBound.y -= newOrigin.y;\n aabb.upperBound.x -= newOrigin.x;\n aabb.upperBound.y -= newOrigin.y;\n }\n this.iteratorPool.release(it);\n }\n\n /**\n * Query an AABB for overlapping proxies. The callback class is called for each\n * proxy that overlaps the supplied AABB.\n */\n query(aabb: AABBValue, queryCallback: DynamicTreeQueryCallback): void {\n if (_ASSERT) console.assert(typeof queryCallback === \"function\");\n const stack = this.stackPool.allocate();\n\n stack.push(this.m_root);\n while (stack.length > 0) {\n const node = stack.pop();\n if (node == null) {\n continue;\n }\n\n if (AABB.testOverlap(node.aabb, aabb)) {\n if (node.isLeaf()) {\n const proceed = queryCallback(node.id);\n if (proceed === false) {\n return;\n }\n } else {\n stack.push(node.child1);\n stack.push(node.child2);\n }\n }\n }\n\n this.stackPool.release(stack);\n }\n\n /**\n * Ray-cast against the proxies in the tree. This relies on the callback to\n * perform a exact ray-cast in the case were the proxy contains a shape. The\n * callback also performs the any collision filtering. This has performance\n * roughly equal to k * log(n), where k is the number of collisions and n is the\n * number of proxies in the tree.\n *\n * @param input The ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n * @param rayCastCallback A function that is called for each proxy that is hit by the ray. If the return value is a positive number it will update the maxFraction of the ray cast input, and if it is zero it will terminate they ray cast.\n */\n rayCast(input: RayCastInput, rayCastCallback: RayCastCallback): void {\n // TODO: GC\n if (_ASSERT) console.assert(typeof rayCastCallback === \"function\");\n const p1 = input.p1;\n const p2 = input.p2;\n const r = Vec2.sub(p2, p1);\n if (_ASSERT) console.assert(r.lengthSquared() > 0.0);\n r.normalize();\n\n // v is perpendicular to the segment.\n const v = Vec2.crossNumVec2(1.0, r);\n const abs_v = Vec2.abs(v);\n\n // Separating axis for segment (Gino, p80).\n // |dot(v, p1 - c)| > dot(|v|, h)\n\n let maxFraction = input.maxFraction;\n\n // Build a bounding box for the segment.\n const segmentAABB = new AABB();\n let t = Vec2.combine((1 - maxFraction), p1, maxFraction, p2);\n segmentAABB.combinePoints(p1, t);\n\n const stack = this.stackPool.allocate();\n const subInput = this.inputPool.allocate();\n\n stack.push(this.m_root);\n while (stack.length > 0) {\n const node = stack.pop();\n if (node == null) {\n continue;\n }\n\n if (AABB.testOverlap(node.aabb, segmentAABB) === false) {\n continue;\n }\n\n // Separating axis for segment (Gino, p80).\n // |dot(v, p1 - c)| > dot(|v|, h)\n const c = node.aabb.getCenter();\n const h = node.aabb.getExtents();\n const separation = math_abs(Vec2.dot(v, Vec2.sub(p1, c))) - Vec2.dot(abs_v, h);\n if (separation > 0.0) {\n continue;\n }\n\n if (node.isLeaf()) {\n subInput.p1 = Vec2.clone(input.p1);\n subInput.p2 = Vec2.clone(input.p2);\n subInput.maxFraction = maxFraction;\n\n const value = rayCastCallback(subInput, node.id);\n\n if (value === 0.0) {\n // The client has terminated the ray cast.\n break;\n } else if (value > 0.0) {\n // update segment bounding box.\n maxFraction = value;\n t = Vec2.combine((1 - maxFraction), p1, maxFraction, p2);\n segmentAABB.combinePoints(p1, t);\n }\n } else {\n stack.push(node.child1);\n stack.push(node.child2);\n }\n }\n this.stackPool.release(stack);\n this.inputPool.release(subInput);\n }\n\n private inputPool: Pool = new Pool({\n create(): RayCastInput {\n // tslint:disable-next-line:no-object-literal-type-assertion\n return {} as RayCastInput;\n },\n release(stack: RayCastInput): void {\n }\n });\n\n private stackPool: Pool>> = new Pool>>({\n create(): Array> {\n return [];\n },\n release(stack: Array>): void {\n stack.length = 0;\n }\n });\n\n private iteratorPool: Pool> = new Pool>({\n create(): Iterator {\n return new Iterator();\n },\n release(iterator: Iterator): void {\n iterator.close();\n }\n });\n\n}\n\n/** @internal */\nclass Iterator {\n parents: Array> = [];\n states: number[] = [];\n preorder(root: TreeNode): Iterator {\n this.parents.length = 0;\n this.parents.push(root);\n this.states.length = 0;\n this.states.push(0);\n return this;\n }\n next(): TreeNode {\n while (this.parents.length > 0) {\n const i = this.parents.length - 1;\n const node = this.parents[i];\n if (this.states[i] === 0) {\n this.states[i] = 1;\n return node;\n }\n if (this.states[i] === 1) {\n this.states[i] = 2;\n if (node.child1) {\n this.parents.push(node.child1);\n this.states.push(1);\n return node.child1;\n }\n }\n if (this.states[i] === 2) {\n this.states[i] = 3;\n if (node.child2) {\n this.parents.push(node.child2);\n this.states.push(1);\n return node.child2;\n }\n }\n this.parents.pop();\n this.states.pop();\n }\n }\n close(): void {\n this.parents.length = 0;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2Value } from \"../common/Vec2\";\nimport { AABB, AABBValue, RayCastCallback, RayCastInput } from \"./AABB\";\nimport { DynamicTree, DynamicTreeQueryCallback } from \"./DynamicTree\";\nimport { FixtureProxy } from \"../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/**\n * The broad-phase wraps and extends a dynamic-tree to keep track of moved\n * objects and query them on update.\n */\nexport class BroadPhase {\n m_tree: DynamicTree = new DynamicTree();\n m_moveBuffer: number[] = [];\n\n m_callback: (userDataA: any, userDataB: any) => void;\n m_queryProxyId: number;\n\n /**\n * Get user data from a proxy. Returns null if the id is invalid.\n */\n getUserData(proxyId: number): FixtureProxy {\n return this.m_tree.getUserData(proxyId);\n }\n\n /**\n * Test overlap of fat AABBs.\n */\n testOverlap(proxyIdA: number, proxyIdB: number): boolean {\n const aabbA = this.m_tree.getFatAABB(proxyIdA);\n const aabbB = this.m_tree.getFatAABB(proxyIdB);\n return AABB.testOverlap(aabbA, aabbB);\n }\n\n /**\n * Get the fat AABB for a proxy.\n */\n getFatAABB(proxyId: number): AABB {\n return this.m_tree.getFatAABB(proxyId);\n }\n\n /**\n * Get the number of proxies.\n */\n getProxyCount(): number {\n return this.m_moveBuffer.length;\n }\n\n /**\n * Get the height of the embedded tree.\n */\n getTreeHeight(): number {\n return this.m_tree.getHeight();\n }\n\n /**\n * Get the balance (integer) of the embedded tree.\n */\n getTreeBalance(): number {\n return this.m_tree.getMaxBalance();\n }\n\n /**\n * Get the quality metric of the embedded tree.\n */\n getTreeQuality(): number {\n return this.m_tree.getAreaRatio();\n }\n\n /**\n * Query an AABB for overlapping proxies. The callback class is called for each\n * proxy that overlaps the supplied AABB.\n */\n query = (aabb: AABBValue, queryCallback: DynamicTreeQueryCallback): void => {\n this.m_tree.query(aabb, queryCallback);\n };\n\n /**\n * Ray-cast against the proxies in the tree. This relies on the callback to\n * perform a exact ray-cast in the case were the proxy contains a shape. The\n * callback also performs the any collision filtering. This has performance\n * roughly equal to k * log(n), where k is the number of collisions and n is the\n * number of proxies in the tree.\n *\n * @param input The ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n * @param rayCastCallback A function that is called for each proxy that is hit by the ray. If the return value is a positive number it will update the maxFraction of the ray cast input, and if it is zero it will terminate they ray cast.\n */\n rayCast(input: RayCastInput, rayCastCallback: RayCastCallback): void {\n this.m_tree.rayCast(input, rayCastCallback);\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_tree.shiftOrigin(newOrigin);\n }\n\n /**\n * Create a proxy with an initial AABB. Pairs are not reported until UpdatePairs\n * is called.\n */\n createProxy(aabb: AABBValue, userData: FixtureProxy): number {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n const proxyId = this.m_tree.createProxy(aabb, userData);\n this.bufferMove(proxyId);\n return proxyId;\n }\n\n /**\n * Destroy a proxy. It is up to the client to remove any pairs.\n */\n destroyProxy(proxyId: number): void {\n this.unbufferMove(proxyId);\n this.m_tree.destroyProxy(proxyId);\n }\n\n /**\n * Call moveProxy as many times as you like, then when you are done call\n * UpdatePairs to finalized the proxy pairs (for your time step).\n */\n moveProxy(proxyId: number, aabb: AABB, displacement: Vec2Value): void {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n const changed = this.m_tree.moveProxy(proxyId, aabb, displacement);\n if (changed) {\n this.bufferMove(proxyId);\n }\n }\n\n /**\n * Call to trigger a re-processing of it's pairs on the next call to\n * UpdatePairs.\n */\n touchProxy(proxyId: number): void {\n this.bufferMove(proxyId);\n }\n\n bufferMove(proxyId: number): void {\n this.m_moveBuffer.push(proxyId);\n }\n\n unbufferMove(proxyId: number): void {\n for (let i = 0; i < this.m_moveBuffer.length; ++i) {\n if (this.m_moveBuffer[i] === proxyId) {\n this.m_moveBuffer[i] = null;\n }\n }\n }\n\n /**\n * Update the pairs. This results in pair callbacks. This can only add pairs.\n */\n updatePairs(addPairCallback: (userDataA: FixtureProxy, userDataB: FixtureProxy) => void): void {\n if (_ASSERT) console.assert(typeof addPairCallback === \"function\");\n this.m_callback = addPairCallback;\n\n // Perform tree queries for all moving proxies.\n while (this.m_moveBuffer.length > 0) {\n this.m_queryProxyId = this.m_moveBuffer.pop();\n if (this.m_queryProxyId === null) {\n continue;\n }\n\n // We have to query the tree with the fat AABB so that\n // we don't fail to create a pair that may touch later.\n const fatAABB = this.m_tree.getFatAABB(this.m_queryProxyId);\n\n // Query tree, create pairs and add them pair buffer.\n this.m_tree.query(fatAABB, this.queryCallback);\n }\n\n // Try to keep the tree balanced.\n // this.m_tree.rebalance(4);\n }\n\n queryCallback = (proxyId: number): boolean => {\n // A proxy cannot form a pair with itself.\n if (proxyId === this.m_queryProxyId) {\n return true;\n }\n\n const proxyIdA = math_min(proxyId, this.m_queryProxyId);\n const proxyIdB = math_max(proxyId, this.m_queryProxyId);\n\n // TODO: Skip any duplicate pairs.\n\n const userDataA = this.m_tree.getUserData(proxyIdA);\n const userDataB = this.m_tree.getUserData(proxyIdB);\n\n // Send the pairs back to the client.\n this.m_callback(userDataA, userDataB);\n\n return true;\n };\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n/** @internal */ const math_sqrt = Math.sqrt;\n\n\nimport { RotValue } from \"./Rot\";\nimport { TransformValue } from \"./Transform\";\nimport { Vec2Value } from \"./Vec2\";\nimport { Vec3Value } from \"./Vec3\";\n\nexport function vec2(x: number, y: number): Vec2Value {\n return { x, y };\n}\n\nexport function vec3(x: number, y: number, z: number): Vec3Value {\n return { x, y, z };\n}\n\nexport function rotation(angle: number): RotValue {\n return { s: math_sin(angle), c: math_cos(angle) };\n}\n\nexport function setVec2(out: Vec2Value, x: number, y: number): Vec2Value {\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function copyVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = w.x;\n out.y = w.y;\n return out;\n}\n\nexport function zeroVec2(out: Vec2Value): Vec2Value {\n out.x = 0;\n out.y = 0;\n return out;\n}\n\nexport function negVec2(out: Vec2Value): Vec2Value {\n out.x = -out.x;\n out.y = -out.y;\n return out;\n}\n\nexport function plusVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x += w.x;\n out.y += w.y;\n return out;\n}\n\nexport function addVec2(out: Vec2Value, v: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = v.x + w.x;\n out.y = v.x + w.y;\n return out;\n}\n\nexport function minusVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x -= w.x;\n out.y -= w.y;\n return out;\n}\n\nexport function subVec2(out: Vec2Value, v: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = v.x - w.x;\n out.y = v.y - w.y;\n return out;\n}\n\nexport function mulVec2(out: Vec2Value, m: number): Vec2Value {\n out.x *= m;\n out.y *= m;\n return out;\n}\n\nexport function scaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x = m * w.x;\n out.y = m * w.y;\n return out;\n}\n\nexport function plusScaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x += m * w.x;\n out.y += m * w.y;\n return out;\n}\n\nexport function minusScaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x -= m * w.x;\n out.y -= m * w.y;\n return out;\n}\n\nexport function combine2Vec2(out: Vec2Value, am: number, a: Vec2Value, bm: number, b: Vec2Value): Vec2Value {\n out.x = am * a.x + bm * b.x;\n out.y = am * a.y + bm * b.y;\n return out;\n}\n\nexport function combine3Vec2(out: Vec2Value, am: number, a: Vec2Value, bm: number, b: Vec2Value, cm: number, c: Vec2Value): Vec2Value {\n out.x = am * a.x + bm * b.x + cm * c.x;\n out.y = am * a.y + bm * b.y + cm * c.y;\n return out;\n}\n\nexport function normalizeVec2Length(out: Vec2Value): number {\n const length = math_sqrt(out.x * out.x + out.y * out.y);\n if (length !== 0) {\n const invLength = 1 / length;\n out.x *= invLength;\n out.y *= invLength;\n }\n return length;\n}\n\nexport function normalizeVec2(out: Vec2Value): Vec2Value {\n const length = math_sqrt(out.x * out.x + out.y * out.y);\n if (length > 0) {\n const invLength = 1 / length;\n out.x *= invLength;\n out.y *= invLength;\n }\n return out;\n}\n\nexport function crossVec2Num(out: Vec2Value, v: Vec2Value, w: number): Vec2Value {\n const x = w * v.y;\n const y = -w * v.x;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function crossNumVec2(out: Vec2Value, w: number, v: Vec2Value): Vec2Value {\n const x = -w * v.y;\n const y = w * v.x;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function crossVec2Vec2(a: Vec2Value, b: Vec2Value): number {\n return a.x * b.y - a.y * b.x;\n}\n\nexport function dotVec2(a: Vec2Value, b: Vec2Value): number {\n return a.x * b.x + a.y * b.y;\n}\n\nexport function lengthVec2(a: Vec2Value): number {\n return math_sqrt(a.x * a.x + a.y * a.y);\n}\n\nexport function lengthSqrVec2(a: Vec2Value): number {\n return a.x * a.x + a.y * a.y;\n}\n\nexport function distVec2(a: Vec2Value, b: Vec2Value): number {\n const dx = a.x - b.x;\n const dy = a.y - b.y;\n return math_sqrt(dx * dx + dy * dy);\n}\n\nexport function distSqrVec2(a: Vec2Value, b: Vec2Value): number {\n const dx = a.x - b.x;\n const dy = a.y - b.y;\n return dx * dx + dy * dy;\n}\n\nexport function dotVec3(v: Vec3Value, w: Vec3Value): number {\n return v.x * w.x + v.y * w.y + v.z * w.z;\n}\n\nexport function setRotAngle(out: RotValue, a: number): RotValue {\n out.c = math_cos(a);\n out.s = math_sin(a);\n return out;\n}\n\nexport function rotVec2(out: Vec2Value, q: RotValue, v: Vec2Value): Vec2Value {\n out.x = q.c * v.x - q.s * v.y;\n out.y = q.s * v.x + q.c * v.y;\n return out;\n}\n\nexport function derotVec2(out: Vec2Value, q: RotValue, v: Vec2Value): Vec2Value {\n const x = q.c * v.x + q.s * v.y;\n const y = -q.s * v.x + q.c * v.y;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function rerotVec2(out: Vec2Value, before: RotValue, after: RotValue, v: Vec2Value): Vec2Value {\n const x0 = before.c * v.x + before.s * v.y;\n const y0 = -before.s * v.x + before.c * v.y;\n const x = after.c * x0 - after.s * y0;\n const y = after.s * x0 + after.c * y0;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function transform(x: number, y: number, a: number): TransformValue {\n return { p: vec2(x, y), q: rotation(a) };\n}\n\nexport function copyTransform(out: TransformValue, transform: TransformValue): TransformValue {\n out.p.x = transform.p.x;\n out.p.y = transform.p.y;\n out.q.s = transform.q.s;\n out.q.c = transform.q.c;\n return out;\n}\n\nexport function transformVec2(out: Vec2Value, xf: TransformValue, v: Vec2Value): Vec2Value {\n const x = xf.q.c * v.x - xf.q.s * v.y + xf.p.x;\n const y = xf.q.s * v.x + xf.q.c * v.y + xf.p.y;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function detransformVec2(out: Vec2Value, xf: TransformValue, v: Vec2Value): Vec2Value {\n const px = v.x - xf.p.x;\n const py = v.y - xf.p.y;\n const x = (xf.q.c * px + xf.q.s * py);\n const y = (-xf.q.s * px + xf.q.c * py);\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function retransformVec2(out: Vec2Value, from: TransformValue, to: TransformValue, v: Vec2Value): Vec2Value {\n const x0 = from.q.c * v.x - from.q.s * v.y + from.p.x;\n const y0 = from.q.s * v.x + from.q.c * v.y + from.p.y;\n const px = x0 - to.p.x;\n const py = y0 - to.p.y;\n const x = to.q.c * px + to.q.s * py;\n const y = -to.q.s * px + to.q.c * py;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function detransformTransform(out: TransformValue, a: TransformValue, b: TransformValue): TransformValue {\n const c = a.q.c * b.q.c + a.q.s * b.q.s;\n const s = a.q.c * b.q.s - a.q.s * b.q.c;\n const x = a.q.c * (b.p.x - a.p.x) + a.q.s * (b.p.y - a.p.y);\n const y = -a.q.s * (b.p.x - a.p.x) + a.q.c * (b.p.y - a.p.y);\n out.q.c = c;\n out.q.s = s;\n out.p.x = x;\n out.p.y = y;\n return out;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n/** @internal */ const math_atan2 = Math.atan2;\n\nexport interface RotValue {\n /** sin(angle) */\n s: number;\n /** cos(angle) */\n c: number;\n}\n\ndeclare module \"./Rot\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(angle: number): Rot;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(obj: RotValue): Rot;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(): Rot;\n}\n\n/** Rotation */\n// @ts-expect-error\nexport class Rot {\n /** sin(angle) */\n s: number;\n /** cos(angle) */\n c: number;\n\n /** Initialize from an angle in radians. */\n constructor(angle?: number | RotValue) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Rot)) {\n return new Rot(angle);\n }\n if (typeof angle === \"number\") {\n this.setAngle(angle);\n } else if (typeof angle === \"object\") {\n this.setRot(angle);\n } else {\n this.setIdentity();\n }\n }\n\n /** @hidden */\n static neo(angle: number): Rot {\n const obj = Object.create(Rot.prototype);\n obj.setAngle(angle);\n return obj;\n }\n\n static clone(rot: RotValue): Rot {\n if (_ASSERT) Rot.assert(rot);\n const obj = Object.create(Rot.prototype);\n obj.s = rot.s;\n obj.c = rot.c;\n return obj;\n }\n\n static identity(): Rot {\n const obj = Object.create(Rot.prototype);\n obj.s = 0.0;\n obj.c = 1.0;\n return obj;\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.s) && Number.isFinite(obj.c);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Rot.isValid(o), \"Invalid Rot!\", o);\n }\n\n /** Set to the identity rotation. */\n setIdentity(): void {\n this.s = 0.0;\n this.c = 1.0;\n }\n\n set(angle: number | RotValue): void {\n if (typeof angle === \"object\") {\n if (_ASSERT) Rot.assert(angle);\n this.s = angle.s;\n this.c = angle.c;\n\n } else {\n if (_ASSERT) console.assert(Number.isFinite(angle));\n // TODO_ERIN optimize\n this.s = math_sin(angle);\n this.c = math_cos(angle);\n }\n }\n\n setRot(angle: RotValue): void {\n if (_ASSERT) Rot.assert(angle);\n this.s = angle.s;\n this.c = angle.c;\n }\n\n /** Set using an angle in radians. */\n setAngle(angle: number): void {\n if (_ASSERT) console.assert(Number.isFinite(angle));\n // TODO_ERIN optimize\n this.s = math_sin(angle);\n this.c = math_cos(angle);\n }\n\n /** Get the angle in radians. */\n getAngle(): number {\n return math_atan2(this.s, this.c);\n }\n\n /** Get the x-axis. */\n getXAxis(): Vec2 {\n return Vec2.neo(this.c, this.s);\n }\n\n /** Get the y-axis. */\n getYAxis(): Vec2 {\n return Vec2.neo(-this.s, this.c);\n }\n\n /** Multiply two rotations: q * r */\n static mul(rot: RotValue, m: RotValue): Rot;\n /** Rotate a vector */\n static mul(rot: RotValue, m: Vec2Value): Vec2;\n static mul(rot, m) {\n if (_ASSERT) Rot.assert(rot);\n if (\"c\" in m && \"s\" in m) {\n if (_ASSERT) Rot.assert(m);\n // [qc -qs] * [rc -rs] = [qc*rc-qs*rs -qc*rs-qs*rc]\n // [qs qc] [rs rc] [qs*rc+qc*rs -qs*rs+qc*rc]\n // s = qs * rc + qc * rs\n // c = qc * rc - qs * rs\n const qr = Rot.identity();\n qr.s = rot.s * m.c + rot.c * m.s;\n qr.c = rot.c * m.c - rot.s * m.s;\n return qr;\n\n } else if (\"x\" in m && \"y\" in m) {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x - rot.s * m.y, rot.s * m.x + rot.c * m.y);\n }\n }\n\n /** Multiply two rotations: q * r */\n static mulRot(rot: RotValue, m: RotValue): Rot {\n if (_ASSERT) Rot.assert(rot);\n if (_ASSERT) Rot.assert(m);\n // [qc -qs] * [rc -rs] = [qc*rc-qs*rs -qc*rs-qs*rc]\n // [qs qc] [rs rc] [qs*rc+qc*rs -qs*rs+qc*rc]\n // s = qs * rc + qc * rs\n // c = qc * rc - qs * rs\n const qr = Rot.identity();\n qr.s = rot.s * m.c + rot.c * m.s;\n qr.c = rot.c * m.c - rot.s * m.s;\n return qr;\n }\n\n /** Rotate a vector */\n static mulVec2(rot: RotValue, m: Vec2Value): Vec2 {\n if (_ASSERT) Rot.assert(rot);\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x - rot.s * m.y, rot.s * m.x + rot.c * m.y);\n }\n\n static mulSub(rot: RotValue, v: Vec2Value, w: Vec2Value): Vec2 {\n const x = rot.c * (v.x - w.x) - rot.s * (v.y - w.y);\n const y = rot.s * (v.x - w.x) + rot.c * (v.y - w.y);\n return Vec2.neo(x, y);\n }\n\n /** Transpose multiply two rotations: qT * r */\n static mulT(rot: RotValue, m: RotValue): Rot;\n /** Inverse rotate a vector */\n static mulT(rot: RotValue, m: Vec2Value): Vec2;\n static mulT(rot, m) {\n if (\"c\" in m && \"s\" in m) {\n if (_ASSERT) Rot.assert(m);\n // [ qc qs] * [rc -rs] = [qc*rc+qs*rs -qc*rs+qs*rc]\n // [-qs qc] [rs rc] [-qs*rc+qc*rs qs*rs+qc*rc]\n // s = qc * rs - qs * rc\n // c = qc * rc + qs * rs\n const qr = Rot.identity();\n qr.s = rot.c * m.s - rot.s * m.c;\n qr.c = rot.c * m.c + rot.s * m.s;\n return qr;\n\n } else if (\"x\" in m && \"y\" in m) {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x + rot.s * m.y, -rot.s * m.x + rot.c * m.y);\n }\n }\n\n /** Transpose multiply two rotations: qT * r */\n static mulTRot(rot: RotValue, m: RotValue): Rot {\n if (_ASSERT) Rot.assert(m);\n // [ qc qs] * [rc -rs] = [qc*rc+qs*rs -qc*rs+qs*rc]\n // [-qs qc] [rs rc] [-qs*rc+qc*rs qs*rs+qc*rc]\n // s = qc * rs - qs * rc\n // c = qc * rc + qs * rs\n const qr = Rot.identity();\n qr.s = rot.c * m.s - rot.s * m.c;\n qr.c = rot.c * m.c + rot.s * m.s;\n return qr;\n }\n\n /** Inverse rotate a vector */\n static mulTVec2(rot: RotValue, m: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x + rot.s * m.y, -rot.s * m.x + rot.c * m.y);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"./Matrix\";\nimport { mod } from \"./Math\";\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { TransformValue } from \"./Transform\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_atan2 = Math.atan2;\n/** @internal */ const math_PI = Math.PI;\n\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n\n/**\n * This describes the motion of a body/shape for TOI computation. Shapes are\n * defined with respect to the body origin, which may not coincide with the\n * center of mass. However, to support dynamics we must interpolate the center\n * of mass position.\n */\nexport class Sweep {\n /** Local center of mass position */\n localCenter = Vec2.zero();\n\n /** World center position */\n c = Vec2.zero();\n\n /** World angle */\n a = 0;\n\n /** Fraction of the current time step in the range [0,1], c0 and a0 are c and a at alpha0. */\n alpha0 = 0;\n\n c0 = Vec2.zero();\n a0 = 0;\n\n /** @internal */\n recycle() {\n matrix.zeroVec2(this.localCenter);\n matrix.zeroVec2(this.c);\n this.a = 0;\n this.alpha0 = 0;\n matrix.zeroVec2(this.c0);\n this.a0 = 0;\n }\n\n setTransform(xf: TransformValue): void {\n matrix.transformVec2(temp, xf, this.localCenter);\n matrix.copyVec2(this.c, temp);\n matrix.copyVec2(this.c0, temp);\n\n this.a = this.a0 = math_atan2(xf.q.s, xf.q.c);\n }\n\n setLocalCenter(localCenter: Vec2Value, xf: TransformValue): void {\n matrix.copyVec2(this.localCenter, localCenter);\n\n matrix.transformVec2(temp, xf, this.localCenter);\n matrix.copyVec2(this.c, temp);\n matrix.copyVec2(this.c0, temp);\n }\n\n /**\n * Get the interpolated transform at a specific time.\n *\n * @param xf\n * @param beta A factor in [0,1], where 0 indicates alpha0\n */\n getTransform(xf: TransformValue, beta: number = 0): void {\n matrix.setRotAngle(xf.q, (1.0 - beta) * this.a0 + beta * this.a);\n matrix.combine2Vec2(xf.p, (1.0 - beta), this.c0, beta, this.c);\n\n // shift to origin\n matrix.minusVec2(xf.p, matrix.rotVec2(temp, xf.q, this.localCenter));\n }\n\n /**\n * Advance the sweep forward, yielding a new initial state.\n *\n * @param alpha The new initial time\n */\n advance(alpha: number): void {\n if (_ASSERT) console.assert(this.alpha0 < 1.0);\n const beta = (alpha - this.alpha0) / (1.0 - this.alpha0);\n matrix.combine2Vec2(this.c0, beta, this.c, 1 - beta, this.c0);\n this.a0 = beta * this.a + (1 - beta) * this.a0;\n this.alpha0 = alpha;\n }\n\n forward(): void {\n this.a0 = this.a;\n matrix.copyVec2(this.c0, this.c);\n }\n\n /**\n * normalize the angles in radians to be between -pi and pi.\n */\n normalize(): void {\n const a0 = mod(this.a0, -math_PI, +math_PI);\n this.a -= this.a0 - a0;\n this.a0 = a0;\n }\n\n set(that: Sweep): void {\n matrix.copyVec2(this.localCenter, that.localCenter);\n matrix.copyVec2(this.c, that.c);\n this.a = that.a;\n this.alpha0 = that.alpha0;\n matrix.copyVec2(this.c0, that.c0);\n this.a0 = that.a0;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { Rot, RotValue } from \"./Rot\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\nexport type TransformValue = {\n p: Vec2Value;\n q: RotValue;\n};\n\ndeclare module \"./Transform\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Transform(position?: Vec2Value, rotation?: number): Transform;\n}\n\n/**\n * A transform contains translation and rotation. It is used to represent the\n * position and orientation of rigid frames. Initialize using a position vector\n * and a rotation.\n */\n// @ts-expect-error\nexport class Transform {\n /** position */\n p: Vec2;\n\n /** rotation */\n q: Rot;\n\n constructor(position?: Vec2Value, rotation?: number) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Transform)) {\n return new Transform(position, rotation);\n }\n this.p = Vec2.zero();\n this.q = Rot.identity();\n if (typeof position !== \"undefined\") {\n this.p.setVec2(position);\n }\n if (typeof rotation !== \"undefined\") {\n this.q.setAngle(rotation);\n }\n }\n\n static clone(xf: Transform): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.clone(xf.p);\n obj.q = Rot.clone(xf.q);\n return obj;\n }\n\n /** @hidden */\n static neo(position: Vec2Value, rotation: Rot): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.clone(position);\n obj.q = Rot.clone(rotation);\n return obj;\n }\n\n static identity(): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.zero();\n obj.q = Rot.identity();\n return obj;\n }\n\n /** Set this to the identity transform */\n setIdentity(): void {\n this.p.setZero();\n this.q.setIdentity();\n }\n\n /** Set position and angle */\n set(position: Vec2Value, rotation: number): void;\n /** Copy from another transform */\n set(xf: TransformValue): void;\n set(a: any, b?: any) {\n if (typeof b === \"undefined\") {\n this.p.set(a.p);\n this.q.set(a.q);\n } else {\n this.p.set(a);\n this.q.set(b);\n }\n }\n\n /** Set position and angle */\n setNum(position: Vec2Value, rotation: number) {\n this.p.setVec2(position);\n this.q.setAngle(rotation);\n }\n\n setTransform(xf: TransformValue): void {\n this.p.setVec2(xf.p);\n this.q.setRot(xf.q);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.p) && Rot.isValid(obj.q);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Transform.isValid(o), \"Invalid Transform!\", o);\n }\n\n static mul(a: TransformValue, b: Vec2Value): Vec2;\n static mul(a: TransformValue, b: TransformValue): Transform;\n // static mul(a: Transform, b: Vec2Value[]): Vec2[];\n // static mul(a: Transform, b: Transform[]): Transform[];\n static mul(a, b) {\n if (Array.isArray(b)) {\n // todo: this was used in examples, remove in the future\n if (_ASSERT) Transform.assert(a);\n const arr = [];\n for (let i = 0; i < b.length; i++) {\n arr[i] = Transform.mul(a, b[i]);\n }\n return arr;\n\n } else if (\"x\" in b && \"y\" in b) {\n return Transform.mulVec2(a, b);\n\n } else if (\"p\" in b && \"q\" in b) {\n return Transform.mulXf(a, b);\n }\n }\n\n static mulAll(a: Transform, b: Vec2Value[]): Vec2[];\n static mulAll(a: Transform, b: Transform[]): Transform[];\n static mulAll(a: TransformValue, b) {\n if (_ASSERT) Transform.assert(a);\n const arr = [];\n for (let i = 0; i < b.length; i++) {\n arr[i] = Transform.mul(a, b[i]);\n }\n return arr;\n }\n\n /** @hidden @deprecated */\n static mulFn(a: TransformValue) {\n // todo: this was used in examples, remove in the future\n if (_ASSERT) Transform.assert(a);\n return function(b: Vec2Value): Vec2 {\n return Transform.mul(a, b);\n };\n }\n\n static mulVec2(a: TransformValue, b: Vec2Value): Vec2 {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const x = (a.q.c * b.x - a.q.s * b.y) + a.p.x;\n const y = (a.q.s * b.x + a.q.c * b.y) + a.p.y;\n return Vec2.neo(x, y);\n }\n\n static mulXf(a: TransformValue, b: TransformValue): Transform {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Transform.assert(b);\n // v2 = A.q.Rot(B.q.Rot(v1) + B.p) + A.p\n // = (A.q * B.q).Rot(v1) + A.q.Rot(B.p) + A.p\n const xf = Transform.identity();\n xf.q = Rot.mulRot(a.q, b.q);\n xf.p = Vec2.add(Rot.mulVec2(a.q, b.p), a.p);\n return xf;\n }\n\n static mulT(a: TransformValue, b: Vec2Value): Vec2;\n static mulT(a: TransformValue, b: TransformValue): Transform;\n static mulT(a, b) {\n if (\"x\" in b && \"y\" in b) {\n return Transform.mulTVec2(a, b);\n\n } else if (\"p\" in b && \"q\" in b) {\n return Transform.mulTXf(a, b);\n }\n }\n\n static mulTVec2(a: TransformValue, b: Vec2Value): Vec2 {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const px = b.x - a.p.x;\n const py = b.y - a.p.y;\n const x = (a.q.c * px + a.q.s * py);\n const y = (-a.q.s * px + a.q.c * py);\n return Vec2.neo(x, y);\n }\n\n static mulTXf(a: TransformValue, b: TransformValue): Transform {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Transform.assert(b);\n // v2 = A.q' * (B.q * v1 + B.p - A.p)\n // = A.q' * B.q * v1 + A.q' * (B.p - A.p)\n const xf = Transform.identity();\n xf.q.setRot(Rot.mulTRot(a.q, b.q));\n xf.p.setVec2(Rot.mulTVec2(a.q, Vec2.sub(b.p, a.p)));\n return xf;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2 } from \"../common/Vec2\";\n\nexport class Velocity {\n /** linear */\n v = Vec2.zero();\n\n /** angular */\n w = 0;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { TransformValue } from \"../common/Transform\";\n\n\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n\n\nexport class Position {\n /** location */\n c = Vec2.zero();\n\n /** angle */\n a = 0;\n\n // todo: cache sin/cos\n getTransform(xf: TransformValue, p: Vec2Value): TransformValue {\n // xf.q = rotation(this.a);\n // xf.p = this.c - xf.q * p\n xf.q.c = math_cos(this.a);\n xf.q.s = math_sin(this.a);\n xf.p.x = this.c.x - (xf.q.c * p.x - xf.q.s * p.y);\n xf.p.y = this.c.y - (xf.q.s * p.x + xf.q.c * p.y);\n return xf;\n }\n}\n\nexport function getTransform(xf: TransformValue, p: Vec2Value, c: Vec2Value, a: number): TransformValue {\n // xf.q = rotation(a);\n // xf.p = this.c - xf.q * p\n xf.q.c = math_cos(a);\n xf.q.s = math_sin(a);\n xf.p.x = c.x - (xf.q.c * p.x - xf.q.s * p.y);\n xf.p.y = c.y - (xf.q.s * p.x + xf.q.c * p.y);\n return xf;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { MassData } from \"../dynamics/Body\";\nimport { RayCastOutput, RayCastInput, AABBValue } from \"./AABB\";\nimport { DistanceProxy } from \"./Distance\";\nimport type { Transform, TransformValue } from \"../common/Transform\";\nimport type { Vec2Value } from \"../common/Vec2\";\nimport { Style } from \"../util/Testbed\";\n\n// todo make shape an interface\n\n/**\n * A shape is used for collision detection. You can create a shape however you\n * like. Shapes used for simulation in World are created automatically when a\n * Fixture is created. Shapes may encapsulate one or more child shapes.\n */\nexport abstract class Shape {\n /** @hidden */ m_type: ShapeType;\n\n /**\n * @hidden\n * Radius of a shape. For polygonal shapes this must be b2_polygonRadius.\n * There is no support for making rounded polygons.\n */\n m_radius: number;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n /** @hidden */\n abstract _reset(): void;\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return typeof obj.m_type === \"string\" && typeof obj.m_radius === \"number\";\n }\n\n abstract getRadius(): number;\n\n /**\n * Get the type of this shape. You can use this to down cast to the concrete\n * shape.\n *\n * @return the shape type.\n */\n abstract getType(): ShapeType;\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n abstract _clone(): Shape;\n\n /**\n * Get the number of child primitives.\n */\n abstract getChildCount(): number;\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n abstract testPoint(xf: TransformValue, p: Vec2Value): boolean;\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n abstract rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean;\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n abstract computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void;\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n abstract computeMass(massData: MassData, density?: number): void;\n\n abstract computeDistanceProxy(proxy: DistanceProxy, childIndex: number): void;\n\n}\n\nexport type ShapeType = \"circle\" | \"edge\" | \"polygon\" | \"chain\";\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { options } from \"../util/options\";\nimport { Vec2Value } from \"../common/Vec2\";\nimport { AABB, RayCastInput, RayCastOutput } from \"../collision/AABB\";\nimport { Shape, ShapeType } from \"../collision/Shape\";\nimport { Body, MassData } from \"./Body\";\nimport { BroadPhase } from \"../collision/BroadPhase\";\nimport { TransformValue } from \"../common/Transform\";\nimport { Style } from \"../util/Testbed\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/** @internal */ const synchronize_aabb1 = new AABB();\n/** @internal */ const synchronize_aabb2 = new AABB();\n/** @internal */ const displacement = matrix.vec2(0, 0);\n\n/**\n * A fixture definition is used to create a fixture. This class defines an\n * abstract fixture definition. You can reuse fixture definitions safely.\n */\nexport interface FixtureOpt {\n userData?: unknown;\n /**\n * The friction coefficient, usually in the range [0,1]\n */\n friction?: number;\n /**\n * The restitution (elasticity) usually in the range [0,1]\n */\n restitution?: number;\n /**\n * The density, usually in kg/m^2\n */\n density?: number;\n /**\n * A sensor shape collects contact information but never generates a collision response.\n */\n isSensor?: boolean;\n /**\n * Zero, positive or negative collision group.\n * Fixtures with same positive groupIndex always collide and fixtures with same negative groupIndex never collide.\n */\n filterGroupIndex?: number;\n /**\n * Collision category bit or bits that this fixture belongs to.\n * If groupIndex is zero or not matching, then at least one bit in this fixture categoryBits should match other fixture maskBits and vice versa.\n */\n filterCategoryBits?: number;\n /**\n * Collision category bit or bits that this fixture accept for collision.\n */\n filterMaskBits?: number;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\nexport interface FixtureDef extends FixtureOpt {\n shape: Shape;\n}\n\n/** @internal */ const FixtureDefDefault: FixtureOpt = {\n userData : null,\n friction : 0.2,\n restitution : 0.0,\n density : 0.0,\n isSensor : false,\n\n filterGroupIndex : 0,\n filterCategoryBits : 0x0001,\n filterMaskBits : 0xFFFF\n};\n\n/**\n * This proxy is used internally to connect shape children to the broad-phase.\n */\nexport class FixtureProxy {\n aabb: AABB;\n fixture: Fixture;\n childIndex: number;\n proxyId: number;\n constructor(fixture: Fixture, childIndex: number) {\n this.aabb = new AABB();\n this.fixture = fixture;\n this.childIndex = childIndex;\n // this.proxyId;\n }\n}\n\n/**\n * A fixture is used to attach a shape to a body for collision detection. A\n * fixture inherits its transform from its parent. Fixtures hold additional\n * non-geometric data such as friction, collision filters, etc.\n *\n * To create a new Fixture use {@link Body.createFixture}.\n */\nexport class Fixture {\n /** @internal */ m_body: Body;\n /** @internal */ m_friction: number;\n /** @internal */ m_restitution: number;\n /** @internal */ m_density: number;\n /** @internal */ m_isSensor: boolean;\n /** @internal */ m_filterGroupIndex: number;\n /** @internal */ m_filterCategoryBits: number;\n /** @internal */ m_filterMaskBits: number;\n /** @internal */ m_shape: Shape;\n /** @internal */ m_next: Fixture | null;\n /** @internal */ m_proxies: FixtureProxy[];\n // 0 indicates inactive state, this is not the same as m_proxies.length\n /** @internal */ m_proxyCount: number;\n /** @internal */ m_userData: unknown;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n constructor(body: Body, def: FixtureDef);\n constructor(body: Body, shape: Shape, def?: FixtureOpt);\n constructor(body: Body, shape: Shape, density?: number);\n /** @internal */\n constructor(body: Body, shape?, def?) {\n if (shape.shape) {\n def = shape;\n shape = shape.shape;\n\n } else if (typeof def === \"number\") {\n def = {density : def};\n }\n\n def = options(def, FixtureDefDefault);\n\n this.m_body = body;\n\n this.m_friction = def.friction;\n this.m_restitution = def.restitution;\n this.m_density = def.density;\n this.m_isSensor = def.isSensor;\n\n this.m_filterGroupIndex = def.filterGroupIndex;\n this.m_filterCategoryBits = def.filterCategoryBits;\n this.m_filterMaskBits = def.filterMaskBits;\n\n // TODO validate shape\n this.m_shape = shape; // .clone();\n\n this.m_next = null;\n\n this.m_proxies = [];\n this.m_proxyCount = 0;\n\n // fixture proxies are created here,\n // but they are activate in when a fixture is added to body\n const childCount = this.m_shape.getChildCount();\n for (let i = 0; i < childCount; ++i) {\n this.m_proxies[i] = new FixtureProxy(this, i);\n }\n\n this.m_userData = def.userData;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /** @hidden Re-setup fixture. */\n _reset(): void {\n const body = this.getBody();\n const broadPhase = body.m_world.m_broadPhase;\n this.destroyProxies(broadPhase);\n if (this.m_shape._reset) {\n this.m_shape._reset();\n }\n const childCount = this.m_shape.getChildCount();\n for (let i = 0; i < childCount; ++i) {\n this.m_proxies[i] = new FixtureProxy(this, i);\n }\n this.createProxies(broadPhase, body.m_xf);\n body.resetMassData();\n }\n\n /** @internal */\n _serialize(): object {\n return {\n friction: this.m_friction,\n restitution: this.m_restitution,\n density: this.m_density,\n isSensor: this.m_isSensor,\n\n filterGroupIndex: this.m_filterGroupIndex,\n filterCategoryBits: this.m_filterCategoryBits,\n filterMaskBits: this.m_filterMaskBits,\n\n shape: this.m_shape,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, body: any, restore: any): Fixture {\n const shape = restore(Shape, data.shape);\n const fixture = shape && new Fixture(body, shape, data);\n return fixture;\n }\n\n /**\n * Get the type of the child shape. You can use this to down cast to the\n * concrete shape.\n */\n getType(): ShapeType {\n return this.m_shape.m_type;\n }\n\n /**\n * Get the child shape. You can modify the child shape, however you should not\n * change the number of vertices because this will crash some collision caching\n * mechanisms. Manipulating the shape may lead to non-physical behavior.\n */\n getShape(): Shape {\n return this.m_shape;\n }\n\n /**\n * A sensor shape collects contact information but never generates a collision\n * response.\n */\n isSensor(): boolean {\n return this.m_isSensor;\n }\n\n /**\n * Set if this fixture is a sensor.\n */\n setSensor(sensor: boolean): void {\n if (sensor != this.m_isSensor) {\n this.m_body.setAwake(true);\n this.m_isSensor = sensor;\n }\n }\n\n // /**\n // * Get the contact filtering data.\n // */\n // getFilterData() {\n // return this.m_filter;\n // }\n\n /**\n * Get the user data that was assigned in the fixture definition. Use this to\n * store your application specific data.\n */\n getUserData(): unknown {\n return this.m_userData;\n }\n\n /**\n * Set the user data. Use this to store your application specific data.\n */\n setUserData(data: unknown): void {\n this.m_userData = data;\n }\n\n /**\n * Get the parent body of this fixture. This is null if the fixture is not\n * attached.\n */\n getBody(): Body {\n return this.m_body;\n }\n\n /**\n * Get the next fixture in the parent body's fixture list.\n */\n getNext(): Fixture | null {\n return this.m_next;\n }\n\n /**\n * Get the density of this fixture.\n */\n getDensity(): number {\n return this.m_density;\n }\n\n /**\n * Set the density of this fixture. This will _not_ automatically adjust the\n * mass of the body. You must call Body.resetMassData to update the body's mass.\n */\n setDensity(density: number): void {\n if (_ASSERT) console.assert(Number.isFinite(density) && density >= 0.0);\n this.m_density = density;\n }\n\n /**\n * Get the coefficient of friction, usually in the range [0,1].\n */\n getFriction(): number {\n return this.m_friction;\n }\n\n /**\n * Set the coefficient of friction. This will not change the friction of\n * existing contacts.\n */\n setFriction(friction: number): void {\n this.m_friction = friction;\n }\n\n /**\n * Get the coefficient of restitution.\n */\n getRestitution(): number {\n return this.m_restitution;\n }\n\n /**\n * Set the coefficient of restitution. This will not change the restitution of\n * existing contacts.\n */\n setRestitution(restitution: number): void {\n this.m_restitution = restitution;\n }\n\n /**\n * Test a point in world coordinates for containment in this fixture.\n */\n testPoint(p: Vec2Value): boolean {\n return this.m_shape.testPoint(this.m_body.getTransform(), p);\n }\n\n /**\n * Cast a ray against this shape.\n */\n rayCast(output: RayCastOutput, input: RayCastInput, childIndex: number): boolean {\n return this.m_shape.rayCast(output, input, this.m_body.getTransform(), childIndex);\n }\n\n /**\n * Get the mass data for this fixture. The mass data is based on the density and\n * the shape. The rotational inertia is about the shape's origin. This operation\n * may be expensive.\n */\n getMassData(massData: MassData): void {\n this.m_shape.computeMass(massData, this.m_density);\n }\n\n /**\n * Get the fixture's AABB. This AABB may be enlarge and/or stale. If you need a\n * more accurate AABB, compute it using the shape and the body transform.\n */\n getAABB(childIndex: number): AABB {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_proxies.length);\n return this.m_proxies[childIndex].aabb;\n }\n\n /**\n * These support body activation/deactivation.\n */\n createProxies(broadPhase: BroadPhase, xf: TransformValue): void {\n if (_ASSERT) console.assert(this.m_proxyCount == 0);\n\n // Create proxies in the broad-phase.\n this.m_proxyCount = this.m_shape.getChildCount();\n\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n this.m_shape.computeAABB(proxy.aabb, xf, i);\n proxy.proxyId = broadPhase.createProxy(proxy.aabb, proxy);\n }\n }\n\n destroyProxies(broadPhase: BroadPhase): void {\n // Destroy proxies in the broad-phase.\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n broadPhase.destroyProxy(proxy.proxyId);\n proxy.proxyId = null;\n }\n\n this.m_proxyCount = 0;\n }\n\n /**\n * Updates this fixture proxy in broad-phase (with combined AABB of current and\n * next transformation).\n */\n synchronize(broadPhase: BroadPhase, xf1: TransformValue, xf2: TransformValue): void {\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n // Compute an AABB that covers the swept shape (may miss some rotation\n // effect).\n this.m_shape.computeAABB(synchronize_aabb1, xf1, proxy.childIndex);\n this.m_shape.computeAABB(synchronize_aabb2, xf2, proxy.childIndex);\n\n proxy.aabb.combine(synchronize_aabb1, synchronize_aabb2);\n\n matrix.subVec2(displacement, xf2.p, xf1.p);\n\n broadPhase.moveProxy(proxy.proxyId, proxy.aabb, displacement);\n }\n }\n\n /**\n * Set the contact filtering data. This will not update contacts until the next\n * time step when either parent body is active and awake. This automatically\n * calls refilter.\n */\n setFilterData(filter: { groupIndex: number, categoryBits: number, maskBits: number }): void {\n this.m_filterGroupIndex = filter.groupIndex;\n this.m_filterCategoryBits = filter.categoryBits;\n this.m_filterMaskBits = filter.maskBits;\n this.refilter();\n }\n\n getFilterGroupIndex(): number {\n return this.m_filterGroupIndex;\n }\n\n setFilterGroupIndex(groupIndex: number): void {\n this.m_filterGroupIndex = groupIndex;\n this.refilter();\n }\n\n getFilterCategoryBits(): number {\n return this.m_filterCategoryBits;\n }\n\n setFilterCategoryBits(categoryBits: number): void {\n this.m_filterCategoryBits = categoryBits;\n this.refilter();\n }\n\n getFilterMaskBits(): number {\n return this.m_filterMaskBits;\n }\n\n setFilterMaskBits(maskBits: number): void {\n this.m_filterMaskBits = maskBits;\n this.refilter();\n }\n\n /**\n * Call this if you want to establish collision that was previously disabled by\n * ContactFilter.\n */\n refilter(): void {\n if (this.m_body == null) {\n return;\n }\n\n // Flag associated contacts for filtering.\n let edge = this.m_body.getContactList();\n while (edge) {\n const contact = edge.contact;\n const fixtureA = contact.getFixtureA();\n const fixtureB = contact.getFixtureB();\n if (fixtureA == this || fixtureB == this) {\n contact.flagForFiltering();\n }\n\n edge = edge.next;\n }\n\n const world = this.m_body.getWorld();\n\n if (world == null) {\n return;\n }\n\n // Touch each proxy so that new pairs may be created\n const broadPhase = world.m_broadPhase;\n for (let i = 0; i < this.m_proxyCount; ++i) {\n broadPhase.touchProxy(this.m_proxies[i].proxyId);\n }\n }\n\n /**\n * Implement this method to provide collision filtering, if you want finer\n * control over contact creation.\n *\n * Return true if contact calculations should be performed between these two\n * fixtures.\n *\n * Warning: for performance reasons this is only called when the AABBs begin to\n * overlap.\n */\n shouldCollide(that: Fixture): boolean {\n\n if (that.m_filterGroupIndex === this.m_filterGroupIndex && that.m_filterGroupIndex !== 0) {\n return that.m_filterGroupIndex > 0;\n }\n\n const collideA = (that.m_filterMaskBits & this.m_filterCategoryBits) !== 0;\n const collideB = (that.m_filterCategoryBits & this.m_filterMaskBits) !== 0;\n const collide = collideA && collideB;\n return collide;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { options } from \"../util/options\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { Rot } from \"../common/Rot\";\nimport { Sweep } from \"../common/Sweep\";\nimport { Transform, TransformValue } from \"../common/Transform\";\nimport { Velocity } from \"./Velocity\";\nimport { Position } from \"./Position\";\nimport { Fixture, FixtureDef, FixtureOpt } from \"./Fixture\";\nimport { Shape } from \"../collision/Shape\";\nimport { JointEdge } from \"./Joint\";\nimport { World } from \"./World\";\nimport { ContactEdge } from \"./Contact\";\nimport { Style } from \"../util/Testbed\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A static body does not move under simulation and behaves as if it has infinite mass.\n * Internally, zero is stored for the mass and the inverse mass.\n * Static bodies can be moved manually by the user.\n * A static body has zero velocity.\n * Static bodies do not collide with other static or kinematic bodies.\n * \n * A kinematic body moves under simulation according to its velocity.\n * Kinematic bodies do not respond to forces.\n * They can be moved manually by the user, but normally a kinematic body is moved by setting its velocity.\n * A kinematic body behaves as if it has infinite mass, however, zero is stored for the mass and the inverse mass.\n * Kinematic bodies do not collide with other kinematic or static bodies.\n * \n * A dynamic body is fully simulated.\n * They can be moved manually by the user, but normally they move according to forces.\n * A dynamic body can collide with all body types.\n * A dynamic body always has finite, non-zero mass.\n * If you try to set the mass of a dynamic body to zero, it will automatically acquire a mass of one kilogram and it won't rotate.\n */\nexport type BodyType = \"static\" | \"kinematic\" | \"dynamic\";\n\n/** @internal */ const STATIC = \"static\";\n/** @internal */ const KINEMATIC = \"kinematic\";\n/** @internal */ const DYNAMIC = \"dynamic\";\n\n/** @internal */ const oldCenter = matrix.vec2(0, 0);\n/** @internal */ const localCenter = matrix.vec2(0, 0);\n/** @internal */ const shift = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n\nexport interface BodyDef {\n /**\n * Body types are static, kinematic, or dynamic. Note: if a dynamic\n * body would have zero mass, the mass is set to one.\n */\n type?: BodyType;\n /**\n * The world position of the body. Avoid creating bodies at the\n * origin since this can lead to many overlapping shapes.\n */\n position?: Vec2Value;\n /**\n * The world angle of the body in radians.\n */\n angle?: number;\n /**\n * The linear velocity of the body's origin in world co-ordinates.\n */\n linearVelocity?: Vec2Value;\n angularVelocity?: number;\n /**\n * Linear damping is use to reduce the linear velocity. The\n * damping parameter can be larger than 1.0 but the damping effect becomes\n * sensitive to the time step when the damping parameter is large.\n * Units are 1/time\n */\n linearDamping?: number;\n /**\n * Angular damping is use to reduce the angular velocity.\n * The damping parameter can be larger than 1.0 but the damping effect\n * becomes sensitive to the time step when the damping parameter is large.\n * Units are 1/time\n */\n angularDamping?: number;\n /**\n * Should this body be prevented from rotating? Useful for characters.\n */\n fixedRotation?: boolean;\n /**\n * Is this a fast moving body that should be prevented from\n * tunneling through other moving bodies? Note that all bodies are\n * prevented from tunneling through kinematic and static bodies. This\n * setting is only considered on dynamic bodies. Warning: You should use\n * this flag sparingly since it increases processing time.\n */\n bullet?: boolean;\n gravityScale?: number;\n /**\n * Set this flag to false if this body should never fall asleep. Note that this increases CPU usage.\n */\n allowSleep?: boolean;\n /**\n * Is this body initially awake or sleeping?\n */\n awake?: boolean;\n /**\n * Does this body start out active?\n */\n active?: boolean;\n userData?: any;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\n/** @internal */ const BodyDefDefault: BodyDef = {\n type : STATIC,\n position : Vec2.zero(),\n angle : 0.0,\n\n linearVelocity : Vec2.zero(),\n angularVelocity : 0.0,\n\n linearDamping : 0.0,\n angularDamping : 0.0,\n\n fixedRotation : false,\n bullet : false,\n gravityScale : 1.0,\n\n allowSleep : true,\n awake : true,\n active : true,\n\n userData : null\n};\n\n/**\n * MassData This holds the mass data computed for a shape.\n */\nexport interface MassData {\n /** The mass of the shape, usually in kilograms. */\n mass: number;\n /** The position of the shape's centroid relative to the shape's origin. */\n center: Vec2Value;\n /** The rotational inertia of the shape about the local origin. */\n I: number;\n}\n\n/**\n * A rigid body composed of one or more fixtures.\n *\n * To create a new Body use {@link World.createBody}.\n */\nexport class Body {\n /** @hidden */\n static readonly STATIC: BodyType = \"static\";\n /** @hidden */\n static readonly KINEMATIC: BodyType = \"kinematic\";\n /** @hidden */\n static readonly DYNAMIC: BodyType = \"dynamic\";\n\n /** @internal */ m_world: World;\n /** @internal */ m_awakeFlag: boolean;\n /** @internal */ m_autoSleepFlag: boolean;\n /** @internal */ m_bulletFlag: boolean;\n /** @internal */ m_fixedRotationFlag: boolean;\n /** @internal */ m_activeFlag: boolean;\n /** @internal */ m_islandFlag: boolean;\n /** @internal */ m_toiFlag: boolean;\n /** @internal */ m_userData: unknown;\n /** @internal */ m_type: BodyType;\n /** @internal */ m_mass: number;\n /** @internal */ m_invMass: number;\n /** @internal Rotational inertia about the center of mass. */\n m_I: number;\n /** @internal */ m_invI: number;\n /** @internal the body origin transform */\n m_xf: Transform;\n /** @internal the swept motion for CCD */\n m_sweep: Sweep;\n // position and velocity correction\n /** @internal */ c_velocity: Velocity;\n /** @internal */ c_position: Position;\n /** @internal */ m_force: Vec2;\n /** @internal */ m_torque: number;\n /** @internal */ m_linearVelocity: Vec2;\n /** @internal */ m_angularVelocity: number;\n /** @internal */ m_linearDamping: number;\n /** @internal */ m_angularDamping: number;\n /** @internal */ m_gravityScale: number;\n /** @internal */ m_sleepTime: number;\n /** @internal */ m_jointList: JointEdge | null;\n /** @internal */ m_contactList: ContactEdge | null;\n /** @internal */ m_fixtureList: Fixture | null;\n /** @internal */ m_prev: Body | null;\n /** @internal */ m_next: Body | null;\n /** @internal */ m_destroyed: boolean;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n /** @internal */\n constructor(world: World, def: BodyDef) {\n def = options(def, BodyDefDefault);\n\n if (_ASSERT) console.assert(Vec2.isValid(def.position));\n if (_ASSERT) console.assert(Vec2.isValid(def.linearVelocity));\n if (_ASSERT) console.assert(Number.isFinite(def.angle));\n if (_ASSERT) console.assert(Number.isFinite(def.angularVelocity));\n if (_ASSERT) console.assert(Number.isFinite(def.angularDamping) && def.angularDamping >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.linearDamping) && def.linearDamping >= 0.0);\n\n this.m_world = world;\n\n this.m_awakeFlag = def.awake;\n this.m_autoSleepFlag = def.allowSleep;\n this.m_bulletFlag = def.bullet;\n this.m_fixedRotationFlag = def.fixedRotation;\n this.m_activeFlag = def.active;\n\n this.m_islandFlag = false;\n this.m_toiFlag = false;\n\n this.m_userData = def.userData;\n this.m_type = def.type;\n\n if (this.m_type == DYNAMIC) {\n this.m_mass = 1.0;\n this.m_invMass = 1.0;\n } else {\n this.m_mass = 0.0;\n this.m_invMass = 0.0;\n }\n\n // Rotational inertia about the center of mass.\n this.m_I = 0.0;\n this.m_invI = 0.0;\n\n // the body origin transform\n this.m_xf = Transform.identity();\n this.m_xf.p.setVec2(def.position);\n this.m_xf.q.setAngle(def.angle);\n\n // the swept motion for CCD\n this.m_sweep = new Sweep();\n this.m_sweep.setTransform(this.m_xf);\n\n // position and velocity correction\n this.c_velocity = new Velocity();\n this.c_position = new Position();\n\n this.m_force = Vec2.zero();\n this.m_torque = 0.0;\n\n this.m_linearVelocity = Vec2.clone(def.linearVelocity);\n this.m_angularVelocity = def.angularVelocity;\n\n this.m_linearDamping = def.linearDamping;\n this.m_angularDamping = def.angularDamping;\n this.m_gravityScale = def.gravityScale;\n\n this.m_sleepTime = 0.0;\n\n this.m_jointList = null;\n this.m_contactList = null;\n this.m_fixtureList = null;\n\n this.m_prev = null;\n this.m_next = null;\n\n this.m_destroyed = false;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /** @internal */\n _serialize(): object {\n const fixtures = [];\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n fixtures.push(f);\n }\n return {\n type: this.m_type,\n bullet: this.m_bulletFlag,\n position: this.m_xf.p,\n angle: this.m_xf.q.getAngle(),\n linearVelocity: this.m_linearVelocity,\n angularVelocity: this.m_angularVelocity,\n fixtures,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): Body {\n const body = new Body(world, data);\n\n if (data.fixtures) {\n for (let i = data.fixtures.length - 1; i >= 0; i--) {\n const fixture = restore(Fixture, data.fixtures[i], body);\n body._addFixture(fixture);\n }\n }\n return body;\n }\n\n isWorldLocked(): boolean {\n return this.m_world && this.m_world.isLocked() ? true : false;\n }\n\n getWorld(): World {\n return this.m_world;\n }\n\n getNext(): Body | null {\n return this.m_next;\n }\n\n setUserData(data: any): void {\n this.m_userData = data;\n }\n\n getUserData(): unknown {\n return this.m_userData;\n }\n\n getFixtureList(): Fixture | null {\n return this.m_fixtureList;\n }\n\n getJointList(): JointEdge | null {\n return this.m_jointList;\n }\n\n /**\n * Warning: this list changes during the time step and you may miss some\n * collisions if you don't use ContactListener.\n */\n getContactList(): ContactEdge | null {\n return this.m_contactList;\n }\n\n isStatic(): boolean {\n return this.m_type == STATIC;\n }\n\n isDynamic(): boolean {\n return this.m_type == DYNAMIC;\n }\n\n isKinematic(): boolean {\n return this.m_type == KINEMATIC;\n }\n\n /**\n * This will alter the mass and velocity.\n */\n setStatic(): Body {\n this.setType(STATIC);\n return this;\n }\n\n setDynamic(): Body {\n this.setType(DYNAMIC);\n return this;\n }\n\n setKinematic(): Body {\n this.setType(KINEMATIC);\n return this;\n }\n\n /**\n * Get the type of the body.\n */\n getType(): BodyType {\n return this.m_type;\n }\n\n /**\n * Set the type of the body to \"static\", \"kinematic\" or \"dynamic\".\n * @param type The type of the body.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n setType(type: BodyType): void {\n if (_ASSERT) console.assert(type === STATIC || type === KINEMATIC || type === DYNAMIC);\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (this.m_type == type) {\n return;\n }\n\n this.m_type = type;\n\n this.resetMassData();\n\n if (this.m_type == STATIC) {\n this.m_linearVelocity.setZero();\n this.m_angularVelocity = 0.0;\n this.m_sweep.forward();\n this.synchronizeFixtures();\n }\n\n this.setAwake(true);\n\n this.m_force.setZero();\n this.m_torque = 0.0;\n\n // Delete the attached contacts.\n let ce = this.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n this.m_world.destroyContact(ce0.contact);\n }\n this.m_contactList = null;\n\n // Touch the proxies so that new contacts will be created (when appropriate)\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n for (let i = 0; i < f.m_proxyCount; ++i) {\n broadPhase.touchProxy(f.m_proxies[i].proxyId);\n }\n }\n }\n\n isBullet(): boolean {\n return this.m_bulletFlag;\n }\n\n /**\n * Should this body be treated like a bullet for continuous collision detection?\n */\n setBullet(flag: boolean): void {\n this.m_bulletFlag = !!flag;\n }\n\n isSleepingAllowed(): boolean {\n return this.m_autoSleepFlag;\n }\n\n setSleepingAllowed(flag: boolean): void {\n this.m_autoSleepFlag = !!flag;\n if (this.m_autoSleepFlag == false) {\n this.setAwake(true);\n }\n }\n\n isAwake(): boolean {\n return this.m_awakeFlag;\n }\n\n /**\n * Set the sleep state of the body. A sleeping body has very low CPU cost.\n *\n * @param flag Set to true to wake the body, false to put it to sleep.\n */\n setAwake(flag: boolean): void {\n if (flag) {\n this.m_awakeFlag = true;\n this.m_sleepTime = 0.0;\n } else {\n this.m_awakeFlag = false;\n this.m_sleepTime = 0.0;\n this.m_linearVelocity.setZero();\n this.m_angularVelocity = 0.0;\n this.m_force.setZero();\n this.m_torque = 0.0;\n }\n }\n\n isActive(): boolean {\n return this.m_activeFlag;\n }\n\n /**\n * Set the active state of the body. An inactive body is not simulated and\n * cannot be collided with or woken up. If you pass a flag of true, all fixtures\n * will be added to the broad-phase. If you pass a flag of false, all fixtures\n * will be removed from the broad-phase and all contacts will be destroyed.\n * Fixtures and joints are otherwise unaffected.\n *\n * You may continue to create/destroy fixtures and joints on inactive bodies.\n * Fixtures on an inactive body are implicitly inactive and will not participate\n * in collisions, ray-casts, or queries. Joints connected to an inactive body\n * are implicitly inactive. An inactive body is still owned by a World object\n * and remains\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n setActive(flag: boolean): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (flag == this.m_activeFlag) {\n return;\n }\n\n this.m_activeFlag = !!flag;\n\n if (this.m_activeFlag) {\n // Create all proxies.\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.createProxies(broadPhase, this.m_xf);\n }\n\t\t // Contacts are created at the beginning of the next\n\t\t this.m_world.m_newFixture = true;\n } else {\n // Destroy all proxies.\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.destroyProxies(broadPhase);\n }\n\n // Destroy the attached contacts.\n let ce = this.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n this.m_world.destroyContact(ce0.contact);\n }\n this.m_contactList = null;\n }\n }\n\n isFixedRotation(): boolean {\n return this.m_fixedRotationFlag;\n }\n\n /**\n * Set this body to have fixed rotation. This causes the mass to be reset.\n */\n setFixedRotation(flag: boolean): void {\n if (this.m_fixedRotationFlag == flag) {\n return;\n }\n\n this.m_fixedRotationFlag = !!flag;\n\n this.m_angularVelocity = 0.0;\n\n this.resetMassData();\n }\n\n /**\n * Get the world transform for the body's origin.\n */\n getTransform(): Transform {\n return this.m_xf;\n }\n\n /**\n * Set the position of the body's origin and rotation. Manipulating a body's\n * transform may cause non-physical behavior. Note: contacts are updated on the\n * next call to World.step.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n *\n * @param position The world position of the body's local origin.\n * @param angle The world rotation in radians.\n */\n setTransform(position: Vec2Value, angle: number): void;\n /**\n * Set the position of the body's origin and rotation. Manipulating a body's\n * transform may cause non-physical behavior. Note: contacts are updated on the\n * next call to World.step.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n setTransform(xf: Transform): void;\n setTransform(a: Vec2Value | Transform, b?: number): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return;\n }\n if (typeof b === \"number\") {\n this.m_xf.setNum(a as Vec2Value, b);\n } else {\n this.m_xf.setTransform(a as TransformValue);\n }\n\n this.m_sweep.setTransform(this.m_xf);\n\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.synchronize(broadPhase, this.m_xf, this.m_xf);\n }\n this.setAwake(true);\n }\n\n synchronizeTransform(): void {\n this.m_sweep.getTransform(this.m_xf, 1);\n }\n\n /**\n * Update fixtures in broad-phase.\n */\n synchronizeFixtures(): void {\n this.m_sweep.getTransform(xf, 0);\n\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.synchronize(broadPhase, xf, this.m_xf);\n }\n }\n\n /**\n * Used in TOI.\n */\n advance(alpha: number): void {\n // Advance to the new safe time. This doesn't sync the broad-phase.\n this.m_sweep.advance(alpha);\n matrix.copyVec2(this.m_sweep.c, this.m_sweep.c0);\n this.m_sweep.a = this.m_sweep.a0;\n this.m_sweep.getTransform(this.m_xf, 1);\n }\n\n /**\n * Get the world position for the body's origin.\n */\n getPosition(): Vec2 {\n return this.m_xf.p;\n }\n\n setPosition(p: Vec2Value): void {\n this.setTransform(p, this.m_sweep.a);\n }\n\n /**\n * Get the current world rotation angle in radians.\n */\n getAngle(): number {\n return this.m_sweep.a;\n }\n\n setAngle(angle: number): void {\n this.setTransform(this.m_xf.p, angle);\n }\n\n /**\n * Get the world position of the center of mass.\n */\n getWorldCenter(): Vec2 {\n return this.m_sweep.c;\n }\n\n /**\n * Get the local position of the center of mass.\n */\n getLocalCenter(): Vec2 {\n return this.m_sweep.localCenter;\n }\n\n /**\n * Get the linear velocity of the center of mass.\n *\n * @return the linear velocity of the center of mass.\n */\n getLinearVelocity(): Vec2 {\n return this.m_linearVelocity;\n }\n\n /**\n * Get the world linear velocity of a world point attached to this body.\n *\n * @param worldPoint A point in world coordinates.\n */\n getLinearVelocityFromWorldPoint(worldPoint: Vec2Value): Vec2 {\n const localCenter = Vec2.sub(worldPoint, this.m_sweep.c);\n return Vec2.add(this.m_linearVelocity, Vec2.crossNumVec2(this.m_angularVelocity,\n localCenter));\n }\n\n /**\n * Get the world velocity of a local point.\n *\n * @param localPoint A point in local coordinates.\n */\n getLinearVelocityFromLocalPoint(localPoint: Vec2Value): Vec2 {\n return this.getLinearVelocityFromWorldPoint(this.getWorldPoint(localPoint));\n }\n\n /**\n * Set the linear velocity of the center of mass.\n *\n * @param v The new linear velocity of the center of mass.\n */\n setLinearVelocity(v: Vec2Value): void {\n if (this.m_type == STATIC) {\n return;\n }\n if (Vec2.dot(v, v) > 0.0) {\n this.setAwake(true);\n }\n this.m_linearVelocity.setVec2(v);\n }\n\n /**\n * Get the angular velocity.\n *\n * @returns the angular velocity in radians/second.\n */\n getAngularVelocity(): number {\n return this.m_angularVelocity;\n }\n\n /**\n * Set the angular velocity.\n *\n * @param w The new angular velocity in radians/second.\n */\n setAngularVelocity(w: number): void {\n if (this.m_type == STATIC) {\n return;\n }\n if (w * w > 0.0) {\n this.setAwake(true);\n }\n this.m_angularVelocity = w;\n }\n\n getLinearDamping(): number {\n return this.m_linearDamping;\n }\n\n setLinearDamping(linearDamping: number): void {\n this.m_linearDamping = linearDamping;\n }\n\n getAngularDamping(): number {\n return this.m_angularDamping;\n }\n\n setAngularDamping(angularDamping: number): void {\n this.m_angularDamping = angularDamping;\n }\n\n getGravityScale(): number {\n return this.m_gravityScale;\n }\n\n /**\n * Scale the gravity applied to this body.\n */\n setGravityScale(scale: number): void {\n this.m_gravityScale = scale;\n }\n\n /**\n * Get the total mass of the body.\n *\n * @returns The mass, usually in kilograms (kg).\n */\n getMass(): number {\n return this.m_mass;\n }\n\n /**\n * Get the rotational inertia of the body about the local origin.\n *\n * @return the rotational inertia, usually in kg-m^2.\n */\n getInertia(): number {\n return this.m_I + this.m_mass\n * Vec2.dot(this.m_sweep.localCenter, this.m_sweep.localCenter);\n }\n\n /**\n * Copy the mass data of the body to data.\n */\n getMassData(data: MassData): void {\n data.mass = this.m_mass;\n data.I = this.getInertia();\n matrix.copyVec2(data.center, this.m_sweep.localCenter);\n }\n\n /**\n * This resets the mass properties to the sum of the mass properties of the\n * fixtures. This normally does not need to be called unless you called\n * SetMassData to override the mass and you later want to reset the mass.\n */\n resetMassData(): void {\n // Compute mass data from shapes. Each shape has its own density.\n this.m_mass = 0.0;\n this.m_invMass = 0.0;\n this.m_I = 0.0;\n this.m_invI = 0.0;\n matrix.zeroVec2(this.m_sweep.localCenter);\n\n // Static and kinematic bodies have zero mass.\n if (this.isStatic() || this.isKinematic()) {\n matrix.copyVec2(this.m_sweep.c0, this.m_xf.p);\n matrix.copyVec2(this.m_sweep.c, this.m_xf.p);\n this.m_sweep.a0 = this.m_sweep.a;\n return;\n }\n\n if (_ASSERT) console.assert(this.isDynamic());\n\n // Accumulate mass over all fixtures.\n matrix.zeroVec2(localCenter);\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n if (f.m_density == 0.0) {\n continue;\n }\n\n const massData: MassData = {\n mass: 0,\n center: matrix.vec2(0, 0),\n I: 0\n };\n f.getMassData(massData);\n this.m_mass += massData.mass;\n matrix.plusScaleVec2(localCenter, massData.mass, massData.center);\n this.m_I += massData.I;\n }\n\n // Compute center of mass.\n if (this.m_mass > 0.0) {\n this.m_invMass = 1.0 / this.m_mass;\n matrix.scaleVec2(localCenter, this.m_invMass, localCenter);\n\n } else {\n // Force all dynamic bodies to have a positive mass.\n this.m_mass = 1.0;\n this.m_invMass = 1.0;\n }\n\n if (this.m_I > 0.0 && this.m_fixedRotationFlag == false) {\n // Center the inertia about the center of mass.\n this.m_I -= this.m_mass * matrix.dotVec2(localCenter, localCenter);\n if (_ASSERT) console.assert(this.m_I > 0.0);\n this.m_invI = 1.0 / this.m_I;\n\n } else {\n this.m_I = 0.0;\n this.m_invI = 0.0;\n }\n\n // Move center of mass.\n matrix.copyVec2(oldCenter, this.m_sweep.c);\n this.m_sweep.setLocalCenter(localCenter, this.m_xf);\n\n // Update center of mass velocity.\n matrix.subVec2(shift, this.m_sweep.c, oldCenter);\n matrix.crossNumVec2(temp, this.m_angularVelocity, shift);\n matrix.plusVec2(this.m_linearVelocity, temp);\n }\n\n /**\n * Set the mass properties to override the mass properties of the fixtures. Note\n * that this changes the center of mass position. Note that creating or\n * destroying fixtures can also alter the mass. This function has no effect if\n * the body isn't dynamic.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n *\n * @param massData The mass properties.\n */\n setMassData(massData: MassData): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (this.m_type != DYNAMIC) {\n return;\n }\n\n this.m_invMass = 0.0;\n this.m_I = 0.0;\n this.m_invI = 0.0;\n\n this.m_mass = massData.mass;\n if (this.m_mass <= 0.0) {\n this.m_mass = 1.0;\n }\n\n this.m_invMass = 1.0 / this.m_mass;\n\n if (massData.I > 0.0 && this.m_fixedRotationFlag == false) {\n this.m_I = massData.I - this.m_mass * matrix.dotVec2(massData.center, massData.center);\n if (_ASSERT) console.assert(this.m_I > 0.0);\n this.m_invI = 1.0 / this.m_I;\n }\n\n // Move center of mass.\n matrix.copyVec2(oldCenter, this.m_sweep.c);\n this.m_sweep.setLocalCenter(massData.center, this.m_xf);\n\n // Update center of mass velocity.\n matrix.subVec2(shift, this.m_sweep.c, oldCenter);\n matrix.crossNumVec2(temp, this.m_angularVelocity, shift);\n matrix.plusVec2(this.m_linearVelocity, temp);\n }\n\n /**\n * Apply a force at a world point. If the force is not applied at the center of\n * mass, it will generate a torque and affect the angular velocity. This wakes\n * up the body.\n *\n * @param force The world force vector, usually in Newtons (N).\n * @param point The world position of the point of application.\n * @param wake Also wake up the body\n */\n applyForce(force: Vec2Value, point: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping.\n if (this.m_awakeFlag) {\n this.m_force.add(force);\n this.m_torque += Vec2.crossVec2Vec2(Vec2.sub(point, this.m_sweep.c), force);\n }\n }\n\n /**\n * Apply a force to the center of mass. This wakes up the body.\n *\n * @param force The world force vector, usually in Newtons (N).\n * @param wake Also wake up the body\n */\n applyForceToCenter(force: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_force.add(force);\n }\n }\n\n /**\n * Apply a torque. This affects the angular velocity without affecting the\n * linear velocity of the center of mass. This wakes up the body.\n *\n * @param torque About the z-axis (out of the screen), usually in N-m.\n * @param wake Also wake up the body\n */\n applyTorque(torque: number, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_torque += torque;\n }\n }\n\n /**\n * Apply an impulse at a point. This immediately modifies the velocity. It also\n * modifies the angular velocity if the point of application is not at the\n * center of mass. This wakes up the body.\n *\n * @param impulse The world impulse vector, usually in N-seconds or kg-m/s.\n * @param point The world position of the point of application.\n * @param wake Also wake up the body\n */\n applyLinearImpulse(impulse: Vec2Value, point: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n\n // Don't accumulate velocity if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_linearVelocity.addMul(this.m_invMass, impulse);\n this.m_angularVelocity += this.m_invI * Vec2.crossVec2Vec2(Vec2.sub(point, this.m_sweep.c), impulse);\n }\n }\n\n /**\n * Apply an angular impulse.\n *\n * @param impulse The angular impulse in units of kg*m*m/s\n * @param wake Also wake up the body\n */\n applyAngularImpulse(impulse: number, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate velocity if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_angularVelocity += this.m_invI * impulse;\n }\n }\n\n /**\n * This is used to test if two bodies should collide.\n * \n * Bodies do not collide when:\n * - Neither of them is dynamic\n * - They are connected by a joint with collideConnected == false\n */\n shouldCollide(that: Body): boolean {\n // At least one body should be dynamic.\n if (this.m_type != DYNAMIC && that.m_type != DYNAMIC) {\n return false;\n }\n // Does a joint prevent collision?\n for (let jn = this.m_jointList; jn; jn = jn.next) {\n if (jn.other == that) {\n if (jn.joint.m_collideConnected == false) {\n return false;\n }\n }\n }\n return true;\n }\n\n /** @internal Used for deserialize. */\n _addFixture(fixture: Fixture): Fixture {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return null;\n }\n\n if (this.m_activeFlag) {\n const broadPhase = this.m_world.m_broadPhase;\n fixture.createProxies(broadPhase, this.m_xf);\n }\n\n fixture.m_next = this.m_fixtureList;\n this.m_fixtureList = fixture;\n\n // Adjust mass properties if needed.\n if (fixture.m_density > 0.0) {\n this.resetMassData();\n }\n\n // Let the world know we have a new fixture. This will cause new contacts\n // to be created at the beginning of the next time step.\n this.m_world.m_newFixture = true;\n\n return fixture;\n }\n\n /**\n * Creates a fixture and attach it to this body.\n *\n * If the density is non-zero, this function automatically updates the mass of\n * the body.\n *\n * Contacts are not created until the next time step.\n *\n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n createFixture(def: FixtureDef): Fixture;\n createFixture(shape: Shape, opt?: FixtureOpt): Fixture;\n createFixture(shape: Shape, density?: number): Fixture;\n // tslint:disable-next-line:typedef\n createFixture(shape, fixdef?) {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return null;\n }\n\n const fixture = new Fixture(this, shape, fixdef);\n this._addFixture(fixture);\n return fixture;\n }\n\n /**\n * Destroy a fixture. This removes the fixture from the broad-phase and destroys\n * all contacts associated with this fixture. This will automatically adjust the\n * mass of the body if the body is dynamic and the fixture has positive density.\n * All fixtures attached to a body are implicitly destroyed when the body is\n * destroyed.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n *\n * @param fixture The fixture to be removed.\n */\n destroyFixture(fixture: Fixture): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (_ASSERT) console.assert(fixture.m_body == this);\n\n // Remove the fixture from this body's singly linked list.\n let found = false;\n if (this.m_fixtureList === fixture) {\n this.m_fixtureList = fixture.m_next;\n found = true;\n\n } else {\n let node = this.m_fixtureList;\n while (node != null) {\n if (node.m_next === fixture) {\n node.m_next = fixture.m_next;\n found = true;\n break;\n }\n node = node.m_next;\n }\n }\n\n // You tried to remove a shape that is not attached to this body.\n if (_ASSERT) console.assert(found);\n\n // Destroy any contacts associated with the fixture.\n let edge = this.m_contactList;\n while (edge) {\n const c = edge.contact;\n edge = edge.next;\n\n const fixtureA = c.getFixtureA();\n const fixtureB = c.getFixtureB();\n\n if (fixture == fixtureA || fixture == fixtureB) {\n // This destroys the contact and removes it from\n // this body's contact list.\n this.m_world.destroyContact(c);\n }\n }\n\n if (this.m_activeFlag) {\n const broadPhase = this.m_world.m_broadPhase;\n fixture.destroyProxies(broadPhase);\n }\n\n fixture.m_body = null;\n fixture.m_next = null;\n\n this.m_world.publish(\"remove-fixture\", fixture);\n\n // Reset the mass data.\n this.resetMassData();\n }\n\n /**\n * Get the corresponding world point of a local point.\n */\n getWorldPoint(localPoint: Vec2Value): Vec2 {\n return Transform.mulVec2(this.m_xf, localPoint);\n }\n\n /**\n * Get the corresponding world vector of a local vector.\n */\n getWorldVector(localVector: Vec2Value): Vec2 {\n return Rot.mulVec2(this.m_xf.q, localVector);\n }\n\n /**\n * Gets the corresponding local point of a world point.\n */\n getLocalPoint(worldPoint: Vec2Value): Vec2 {\n return Transform.mulTVec2(this.m_xf, worldPoint);\n }\n\n /**\n * Gets the corresponding local vector of a world vector.\n */\n getLocalVector(worldVector: Vec2Value): Vec2 {\n return Rot.mulTVec2(this.m_xf.q, worldVector);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { Vec2, Vec2Value } from \"../common/Vec2\";\nimport type { Body } from \"./Body\";\nimport { TimeStep } from \"./Solver\";\nimport { Style } from \"../util/Testbed\";\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/**\n * A joint edge is used to connect bodies and joints together in a joint graph\n * where each body is a node and each joint is an edge. A joint edge belongs to\n * a doubly linked list maintained in each attached body. Each joint has two\n * joint nodes, one for each attached body.\n */\nexport class JointEdge {\n /**\n * provides quick access to the other body attached.\n */\n other: Body | null = null;\n /**\n * the joint\n */\n joint: Joint | null = null;\n /**\n * prev the previous joint edge in the body's joint list\n */\n prev: JointEdge | null = null;\n /**\n * the next joint edge in the body's joint list\n */\n next: JointEdge | null = null;\n}\n\n/**\n * Joint definitions are used to construct joints.\n */\nexport interface JointOpt {\n /**\n * Use this to attach application specific data to your joints.\n */\n userData?: any;\n /**\n * Set this flag to true if the attached bodies\n * should collide.\n */\n collideConnected?: boolean;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\n/**\n * Joint definitions are used to construct joints.\n */\nexport interface JointDef extends JointOpt {\n /**\n * The first attached body.\n */\n bodyA: Body;\n /**\n * The second attached body.\n */\n bodyB: Body;\n}\n\n/** @internal */ const DEFAULTS = {\n userData : null,\n collideConnected : false\n};\n\n/**\n * The base joint class. Joints are used to constraint two bodies together in\n * various fashions. Some joints also feature limits and motors.\n */\nexport abstract class Joint {\n\n /** @internal */ m_type: string = \"unknown-joint\";\n\n /** @internal */ m_bodyA: Body;\n /** @internal */ m_bodyB: Body;\n\n /** @internal */ m_collideConnected: boolean;\n\n /** @internal */ m_prev: Joint | null = null;\n /** @internal */ m_next: Joint | null = null;\n\n /** @internal */ m_edgeA: JointEdge = new JointEdge();\n /** @internal */ m_edgeB: JointEdge = new JointEdge();\n\n /** @internal */ m_islandFlag: boolean = false;\n /** @internal */ m_userData: unknown;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n constructor(def: JointDef);\n constructor(def: JointOpt, bodyA: Body, bodyB: Body);\n constructor(def: JointDef | JointOpt, bodyA?: Body, bodyB?: Body) {\n bodyA = \"bodyA\" in def ? def.bodyA : bodyA;\n bodyB = \"bodyB\" in def ? def.bodyB : bodyB;\n\n if (_ASSERT) console.assert(!!bodyA);\n if (_ASSERT) console.assert(!!bodyB);\n if (_ASSERT) console.assert(bodyA != bodyB);\n\n this.m_bodyA = bodyA!;\n this.m_bodyB = bodyB!;\n\n this.m_collideConnected = !!def.collideConnected;\n this.m_userData = def.userData;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /**\n * Short-cut function to determine if either body is inactive.\n */\n isActive(): boolean {\n return this.m_bodyA.isActive() && this.m_bodyB.isActive();\n }\n\n /**\n * Get the type of the concrete joint.\n */\n getType(): string {\n return this.m_type;\n }\n\n /**\n * Get the first body attached to this joint.\n */\n getBodyA(): Body {\n return this.m_bodyA;\n }\n\n /**\n * Get the second body attached to this joint.\n */\n getBodyB(): Body {\n return this.m_bodyB;\n }\n\n /**\n * Get the next joint the world joint list.\n */\n getNext(): Joint {\n return this.m_next;\n }\n\n getUserData(): unknown {\n return this.m_userData;\n }\n\n setUserData(data: unknown): void {\n this.m_userData = data;\n }\n\n /**\n * Get collide connected. Note: modifying the collide connect flag won't work\n * correctly because the flag is only checked when fixture AABBs begin to\n * overlap.\n */\n getCollideConnected(): boolean {\n return this.m_collideConnected;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n abstract getAnchorA(): Vec2;\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n abstract getAnchorB(): Vec2;\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n abstract getReactionForce(inv_dt: number): Vec2;\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n abstract getReactionTorque(inv_dt: number): number;\n\n /**\n * Shift the origin for any points stored in world coordinates.\n */\n shiftOrigin(newOrigin: Vec2Value): void {}\n\n abstract initVelocityConstraints(step: TimeStep): void;\n\n abstract solveVelocityConstraints(step: TimeStep): void;\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n abstract solvePositionConstraints(step: TimeStep): boolean;\n\n /**\n * @hidden @experimental\n * Update joint with new props.\n */\n abstract _reset(def: Partial): void;\n\n /**\n * @internal @deprecated\n * Temporary for backward compatibility, will be removed.\n */\n _resetAnchors(def: any): void {\n return this._reset(def);\n }\n}\n","/** @hidden */\nexport const stats = {\n gjkCalls: 0,\n gjkIters: 0,\n gjkMaxIters: 0,\n\n toiTime: 0,\n toiMaxTime: 0,\n toiCalls: 0,\n toiIters: 0,\n toiMaxIters: 0,\n toiRootIters: 0,\n toiMaxRootIters: 0,\n\n toString(newline?: string): string {\n newline = typeof newline === \"string\" ? newline : \"\\n\";\n let string = \"\";\n // tslint:disable-next-line:no-for-in\n for (const name in this) {\n if (typeof this[name] !== \"function\" && typeof this[name] !== \"object\") {\n string += name + \": \" + this[name] + newline;\n }\n }\n return string;\n }\n};\n","/** @internal */\nexport const now = function(): number {\n return Date.now();\n};\n\n/** @internal */\nexport const diff = function(time: number): number {\n return Date.now() - time;\n};\n\n/** @internal */\nexport default {\n now,\n diff,\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { stats } from \"../util/stats\";\nimport { Shape } from \"./Shape\";\nimport { EPSILON } from \"../common/Math\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { Rot } from \"../common/Rot\";\nimport { Transform, TransformValue } from \"../common/Transform\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_max = Math.max;\n\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const e12 = matrix.vec2(0, 0);\n/** @internal */ const e13 = matrix.vec2(0, 0);\n/** @internal */ const e23 = matrix.vec2(0, 0);\n/** @internal */ const temp1 = matrix.vec2(0, 0);\n/** @internal */ const temp2 = matrix.vec2(0, 0);\n\n/**\n * GJK using Voronoi regions (Christer Ericson) and Barycentric coordinates.\n */\n\nstats.gjkCalls = 0;\nstats.gjkIters = 0;\nstats.gjkMaxIters = 0;\n\n/**\n * Input for Distance. You have to option to use the shape radii in the\n * computation. Even\n */\nexport class DistanceInput {\n readonly proxyA = new DistanceProxy();\n readonly proxyB = new DistanceProxy();\n readonly transformA = Transform.identity();\n readonly transformB = Transform.identity();\n useRadii = false;\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.transformA.setIdentity();\n this.transformB.setIdentity();\n this.useRadii = false;\n }\n}\n\n/**\n * Output for Distance.\n */\nexport class DistanceOutput {\n /** closest point on shapeA */\n pointA = matrix.vec2(0, 0);\n /** closest point on shapeB */\n pointB = matrix.vec2(0, 0);\n distance = 0;\n /** iterations number of GJK iterations used */\n iterations = 0;\n recycle() {\n matrix.zeroVec2(this.pointA);\n matrix.zeroVec2(this.pointB);\n this.distance = 0;\n this.iterations = 0;\n }\n}\n\n/**\n * Used to warm start Distance. Set count to zero on first call.\n */\nexport class SimplexCache {\n /** length or area */\n metric: number = 0;\n /** vertices on shape A */\n indexA: number[] = [];\n /** vertices on shape B */\n indexB: number[] = [];\n count: number = 0;\n recycle() {\n this.metric = 0;\n this.indexA.length = 0;\n this.indexB.length = 0;\n this.count = 0;\n }\n}\n\n/**\n * Compute the closest points between two shapes. Supports any combination of:\n * CircleShape, PolygonShape, EdgeShape. The simplex cache is input/output. On\n * the first call set SimplexCache.count to zero.\n */\nexport const Distance = function (output: DistanceOutput, cache: SimplexCache, input: DistanceInput): void {\n ++stats.gjkCalls;\n\n const proxyA = input.proxyA;\n const proxyB = input.proxyB;\n const xfA = input.transformA;\n const xfB = input.transformB;\n\n // Initialize the simplex.\n // const simplex = new Simplex();\n simplex.recycle();\n simplex.readCache(cache, proxyA, xfA, proxyB, xfB);\n\n // Get simplex vertices as an array.\n const vertices = simplex.m_v;\n const k_maxIters = Settings.maxDistanceIterations;\n\n // These store the vertices of the last simplex so that we\n // can check for duplicates and prevent cycling.\n const saveA = [];\n const saveB = []; // int[3]\n let saveCount = 0;\n\n // Main iteration loop.\n let iter = 0;\n while (iter < k_maxIters) {\n // Copy simplex so we can identify duplicates.\n saveCount = simplex.m_count;\n for (let i = 0; i < saveCount; ++i) {\n saveA[i] = vertices[i].indexA;\n saveB[i] = vertices[i].indexB;\n }\n\n simplex.solve();\n\n // If we have 3 points, then the origin is in the corresponding triangle.\n if (simplex.m_count === 3) {\n break;\n }\n\n // Get search direction.\n const d = simplex.getSearchDirection();\n\n // Ensure the search direction is numerically fit.\n if (matrix.lengthSqrVec2(d) < EPSILON * EPSILON) {\n // The origin is probably contained by a line segment\n // or triangle. Thus the shapes are overlapped.\n\n // We can't return zero here even though there may be overlap.\n // In case the simplex is a point, segment, or triangle it is difficult\n // to determine if the origin is contained in the CSO or very close to it.\n break;\n }\n\n // Compute a tentative new simplex vertex using support points.\n const vertex = vertices[simplex.m_count]; // SimplexVertex\n\n vertex.indexA = proxyA.getSupport(matrix.derotVec2(temp, xfA.q, matrix.scaleVec2(temp, -1, d)));\n matrix.transformVec2(vertex.wA, xfA, proxyA.getVertex(vertex.indexA));\n\n vertex.indexB = proxyB.getSupport(matrix.derotVec2(temp, xfB.q, d));\n matrix.transformVec2(vertex.wB, xfB, proxyB.getVertex(vertex.indexB));\n\n matrix.subVec2(vertex.w, vertex.wB, vertex.wA);\n\n // Iteration count is equated to the number of support point calls.\n ++iter;\n ++stats.gjkIters;\n\n // Check for duplicate support points. This is the main termination\n // criteria.\n let duplicate = false;\n for (let i = 0; i < saveCount; ++i) {\n if (vertex.indexA === saveA[i] && vertex.indexB === saveB[i]) {\n duplicate = true;\n break;\n }\n }\n\n // If we found a duplicate support point we must exit to avoid cycling.\n if (duplicate) {\n break;\n }\n\n // New vertex is ok and needed.\n ++simplex.m_count;\n }\n\n stats.gjkMaxIters = math_max(stats.gjkMaxIters, iter);\n\n // Prepare output.\n simplex.getWitnessPoints(output.pointA, output.pointB);\n output.distance = matrix.distVec2(output.pointA, output.pointB);\n output.iterations = iter;\n\n // Cache the simplex.\n simplex.writeCache(cache);\n\n // Apply radii if requested.\n if (input.useRadii) {\n const rA = proxyA.m_radius;\n const rB = proxyB.m_radius;\n\n if (output.distance > rA + rB && output.distance > EPSILON) {\n // Shapes are still no overlapped.\n // Move the witness points to the outer surface.\n output.distance -= rA + rB;\n matrix.subVec2(normal, output.pointB, output.pointA);\n matrix.normalizeVec2(normal);\n matrix.plusScaleVec2(output.pointA, rA, normal);\n matrix.minusScaleVec2(output.pointB, rB, normal);\n } else {\n // Shapes are overlapped when radii are considered.\n // Move the witness points to the middle.\n const p = matrix.subVec2(temp, output.pointA, output.pointB);\n matrix.copyVec2(output.pointA, p);\n matrix.copyVec2(output.pointB, p);\n output.distance = 0.0;\n }\n }\n};\n\n/**\n * A distance proxy is used by the GJK algorithm. It encapsulates any shape.\n */\nexport class DistanceProxy {\n /** @internal */ m_vertices: Vec2Value[] = [];\n // todo: remove this?\n /** @internal */ m_count = 0;\n /** @internal */ m_radius = 0;\n\n recycle() {\n this.m_vertices.length = 0;\n this.m_count = 0;\n this.m_radius = 0;\n }\n\n /**\n * Get the vertex count.\n */\n getVertexCount(): number {\n return this.m_count;\n }\n\n /**\n * Get a vertex by index. Used by Distance.\n */\n getVertex(index: number): Vec2Value {\n if (_ASSERT) console.assert(0 <= index && index < this.m_count);\n return this.m_vertices[index];\n }\n\n /**\n * Get the supporting vertex index in the given direction.\n */\n getSupport(d: Vec2Value): number {\n let bestIndex = -1;\n let bestValue = -Infinity;\n for (let i = 0; i < this.m_count; ++i) {\n const value = matrix.dotVec2(this.m_vertices[i], d);\n if (value > bestValue) {\n bestIndex = i;\n bestValue = value;\n }\n }\n return bestIndex;\n }\n\n /**\n * Get the supporting vertex in the given direction.\n */\n getSupportVertex(d: Vec2Value): Vec2Value {\n return this.m_vertices[this.getSupport(d)];\n }\n\n /**\n * Initialize the proxy using the given shape. The shape must remain in scope\n * while the proxy is in use.\n */\n set(shape: Shape, index: number): void {\n // TODO remove, use shape instead\n if (_ASSERT) console.assert(typeof shape.computeDistanceProxy === \"function\");\n shape.computeDistanceProxy(this, index);\n }\n\n /**\n * Initialize the proxy using a vertex cloud and radius. The vertices\n * must remain in scope while the proxy is in use.\n */\n setVertices(vertices: Vec2Value[], count: number, radius: number) {\n this.m_vertices = vertices;\n this.m_count = count;\n this.m_radius = radius;\n }\n}\n\nclass SimplexVertex {\n /** support point in proxyA */\n wA = matrix.vec2(0, 0);\n /** wA index */\n indexA = 0;\n\n /** support point in proxyB */\n wB = matrix.vec2(0, 0);\n /** wB index */\n indexB = 0;\n\n /** wB - wA; */\n w = matrix.vec2(0, 0);\n /** barycentric coordinate for closest point */\n a = 0;\n\n recycle() {\n this.indexA = 0;\n this.indexB = 0;\n matrix.zeroVec2(this.wA);\n matrix.zeroVec2(this.wB);\n matrix.zeroVec2(this.w);\n this.a = 0;\n }\n set(v: SimplexVertex): void {\n this.indexA = v.indexA;\n this.indexB = v.indexB;\n matrix.copyVec2(this.wA, v.wA);\n matrix.copyVec2(this.wB, v.wB);\n matrix.copyVec2(this.w, v.w);\n this.a = v.a;\n }\n}\n\n/** @internal */ const searchDirection_reuse = matrix.vec2(0, 0);\n/** @internal */ const closestPoint_reuse = matrix.vec2(0, 0); \n\nclass Simplex {\n m_v1 = new SimplexVertex();\n m_v2 = new SimplexVertex();\n m_v3 = new SimplexVertex();\n m_v = [this.m_v1, this.m_v2, this.m_v3];\n m_count: number;\n recycle() {\n this.m_v1.recycle();\n this.m_v2.recycle();\n this.m_v3.recycle();\n this.m_count = 0;\n }\n\n /** @internal */ toString(): string {\n if (this.m_count === 3) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y,\n this.m_v2.a, this.m_v2.wA.x, this.m_v2.wA.y, this.m_v2.wB.x, this.m_v2.wB.y,\n this.m_v3.a, this.m_v3.wA.x, this.m_v3.wA.y, this.m_v3.wB.x, this.m_v3.wB.y\n ].toString();\n\n } else if (this.m_count === 2) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y,\n this.m_v2.a, this.m_v2.wA.x, this.m_v2.wA.y, this.m_v2.wB.x, this.m_v2.wB.y\n ].toString();\n\n } else if (this.m_count === 1) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y\n ].toString();\n\n } else {\n return \"+\" + this.m_count;\n }\n }\n\n readCache(cache: SimplexCache, proxyA: DistanceProxy, transformA: TransformValue, proxyB: DistanceProxy, transformB: TransformValue): void {\n if (_ASSERT) console.assert(cache.count <= 3);\n\n // Copy data from cache.\n this.m_count = cache.count;\n for (let i = 0; i < this.m_count; ++i) {\n const v = this.m_v[i];\n v.indexA = cache.indexA[i];\n v.indexB = cache.indexB[i];\n const wALocal = proxyA.getVertex(v.indexA);\n const wBLocal = proxyB.getVertex(v.indexB);\n matrix.transformVec2(v.wA, transformA, wALocal);\n matrix.transformVec2(v.wB, transformB, wBLocal);\n matrix.subVec2(v.w,v.wB, v.wA);\n v.a = 0.0;\n }\n\n // Compute the new simplex metric, if it is substantially different than\n // old metric then flush the simplex.\n if (this.m_count > 1) {\n const metric1 = cache.metric;\n const metric2 = this.getMetric();\n if (metric2 < 0.5 * metric1 || 2.0 * metric1 < metric2 || metric2 < EPSILON) {\n // Reset the simplex.\n this.m_count = 0;\n }\n }\n\n // If the cache is empty or invalid...\n if (this.m_count === 0) {\n const v = this.m_v[0];\n v.indexA = 0;\n v.indexB = 0;\n const wALocal = proxyA.getVertex(0);\n const wBLocal = proxyB.getVertex(0);\n matrix.transformVec2(v.wA, transformA, wALocal);\n matrix.transformVec2(v.wB, transformB, wBLocal);\n matrix.subVec2(v.w,v.wB, v.wA);\n v.a = 1.0;\n this.m_count = 1;\n }\n }\n\n writeCache(cache: SimplexCache): void {\n cache.metric = this.getMetric();\n cache.count = this.m_count;\n for (let i = 0; i < this.m_count; ++i) {\n cache.indexA[i] = this.m_v[i].indexA;\n cache.indexB[i] = this.m_v[i].indexB;\n }\n }\n\n getSearchDirection(): Vec2Value {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 1:\n return matrix.setVec2(searchDirection_reuse, -v1.w.x, -v1.w.y);\n\n case 2: {\n matrix.subVec2(e12, v2.w, v1.w);\n const sgn = -matrix.crossVec2Vec2(e12, v1.w);\n if (sgn > 0.0) {\n // Origin is left of e12.\n return matrix.setVec2(searchDirection_reuse, -e12.y, e12.x);\n } else {\n // Origin is right of e12.\n return matrix.setVec2(searchDirection_reuse, e12.y, -e12.x);\n }\n }\n\n default:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(searchDirection_reuse);\n }\n }\n\n getClosestPoint(): Vec2Value {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(closestPoint_reuse);\n\n case 1:\n return matrix.copyVec2(closestPoint_reuse, v1.w);\n\n case 2:\n return matrix.combine2Vec2(closestPoint_reuse, v1.a, v1.w, v2.a, v2.w);\n\n case 3:\n return matrix.zeroVec2(closestPoint_reuse);\n\n default:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(closestPoint_reuse);\n }\n }\n\n getWitnessPoints(pA: Vec2Value, pB: Vec2Value): void {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n break;\n\n case 1:\n matrix.copyVec2(pA, v1.wA);\n matrix.copyVec2(pB, v1.wB);\n break;\n\n case 2:\n matrix.combine2Vec2(pA, v1.a, v1.wA, v2.a, v2.wA);\n matrix.combine2Vec2(pB, v1.a, v1.wB, v2.a, v2.wB);\n break;\n\n case 3:\n matrix.combine3Vec2(pA, v1.a, v1.wA, v2.a, v2.wA, v3.a, v3.wA);\n matrix.copyVec2(pB, pA);\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n break;\n }\n }\n\n getMetric(): number {\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n return 0.0;\n\n case 1:\n return 0.0;\n\n case 2:\n return matrix.distVec2(this.m_v1.w, this.m_v2.w);\n\n case 3:\n return matrix.crossVec2Vec2(\n matrix.subVec2(temp1, this.m_v2.w, this.m_v1.w),\n matrix.subVec2(temp2, this.m_v3.w, this.m_v1.w),\n );\n\n default:\n if (_ASSERT) console.assert(false);\n return 0.0;\n }\n }\n\n solve(): void {\n switch (this.m_count) {\n case 1:\n break;\n\n case 2:\n this.solve2();\n break;\n\n case 3:\n this.solve3();\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n }\n }\n\n// Solve a line segment using barycentric coordinates.\n//\n// p = a1 * w1 + a2 * w2\n// a1 + a2 = 1\n//\n// The vector from the origin to the closest point on the line is\n// perpendicular to the line.\n// e12 = w2 - w1\n// dot(p, e) = 0\n// a1 * dot(w1, e) + a2 * dot(w2, e) = 0\n//\n// 2-by-2 linear system\n// [1 1 ][a1] = [1]\n// [w1.e12 w2.e12][a2] = [0]\n//\n// Define\n// d12_1 = dot(w2, e12)\n// d12_2 = -dot(w1, e12)\n// d12 = d12_1 + d12_2\n//\n// Solution\n// a1 = d12_1 / d12\n// a2 = d12_2 / d12\n solve2(): void {\n const w1 = this.m_v1.w;\n const w2 = this.m_v2.w;\n matrix.subVec2(e12, w2, w1);\n\n // w1 region\n const d12_2 = -matrix.dotVec2(w1, e12);\n if (d12_2 <= 0.0) {\n // a2 <= 0, so we clamp it to 0\n this.m_v1.a = 1.0;\n this.m_count = 1;\n return;\n }\n\n // w2 region\n const d12_1 = matrix.dotVec2(w2, e12);\n if (d12_1 <= 0.0) {\n // a1 <= 0, so we clamp it to 0\n this.m_v2.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v2);\n return;\n }\n\n // Must be in e12 region.\n const inv_d12 = 1.0 / (d12_1 + d12_2);\n this.m_v1.a = d12_1 * inv_d12;\n this.m_v2.a = d12_2 * inv_d12;\n this.m_count = 2;\n }\n\n// Possible regions:\n// - points[2]\n// - edge points[0]-points[2]\n// - edge points[1]-points[2]\n// - inside the triangle\n solve3(): void {\n const w1 = this.m_v1.w;\n const w2 = this.m_v2.w;\n const w3 = this.m_v3.w;\n\n // Edge12\n // [1 1 ][a1] = [1]\n // [w1.e12 w2.e12][a2] = [0]\n // a3 = 0\n matrix.subVec2(e12, w2, w1);\n const w1e12 = matrix.dotVec2(w1, e12);\n const w2e12 = matrix.dotVec2(w2, e12);\n const d12_1 = w2e12;\n const d12_2 = -w1e12;\n\n // Edge13\n // [1 1 ][a1] = [1]\n // [w1.e13 w3.e13][a3] = [0]\n // a2 = 0\n matrix.subVec2(e13, w3, w1);\n const w1e13 = matrix.dotVec2(w1, e13);\n const w3e13 = matrix.dotVec2(w3, e13);\n const d13_1 = w3e13;\n const d13_2 = -w1e13;\n\n // Edge23\n // [1 1 ][a2] = [1]\n // [w2.e23 w3.e23][a3] = [0]\n // a1 = 0\n matrix.subVec2(e23, w3, w2);\n const w2e23 = matrix.dotVec2(w2, e23);\n const w3e23 = matrix.dotVec2(w3, e23);\n const d23_1 = w3e23;\n const d23_2 = -w2e23;\n\n // Triangle123\n const n123 = matrix.crossVec2Vec2(e12, e13);\n\n const d123_1 = n123 * matrix.crossVec2Vec2(w2, w3);\n const d123_2 = n123 * matrix.crossVec2Vec2(w3, w1);\n const d123_3 = n123 * matrix.crossVec2Vec2(w1, w2);\n\n // w1 region\n if (d12_2 <= 0.0 && d13_2 <= 0.0) {\n this.m_v1.a = 1.0;\n this.m_count = 1;\n return;\n }\n\n // e12\n if (d12_1 > 0.0 && d12_2 > 0.0 && d123_3 <= 0.0) {\n const inv_d12 = 1.0 / (d12_1 + d12_2);\n this.m_v1.a = d12_1 * inv_d12;\n this.m_v2.a = d12_2 * inv_d12;\n this.m_count = 2;\n return;\n }\n\n // e13\n if (d13_1 > 0.0 && d13_2 > 0.0 && d123_2 <= 0.0) {\n const inv_d13 = 1.0 / (d13_1 + d13_2);\n this.m_v1.a = d13_1 * inv_d13;\n this.m_v3.a = d13_2 * inv_d13;\n this.m_count = 2;\n this.m_v2.set(this.m_v3);\n return;\n }\n\n // w2 region\n if (d12_1 <= 0.0 && d23_2 <= 0.0) {\n this.m_v2.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v2);\n return;\n }\n\n // w3 region\n if (d13_1 <= 0.0 && d23_1 <= 0.0) {\n this.m_v3.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v3);\n return;\n }\n\n // e23\n if (d23_1 > 0.0 && d23_2 > 0.0 && d123_1 <= 0.0) {\n const inv_d23 = 1.0 / (d23_1 + d23_2);\n this.m_v2.a = d23_1 * inv_d23;\n this.m_v3.a = d23_2 * inv_d23;\n this.m_count = 2;\n this.m_v1.set(this.m_v3);\n return;\n }\n\n // Must be in triangle123\n const inv_d123 = 1.0 / (d123_1 + d123_2 + d123_3);\n this.m_v1.a = d123_1 * inv_d123;\n this.m_v2.a = d123_2 * inv_d123;\n this.m_v3.a = d123_3 * inv_d123;\n this.m_count = 3;\n }\n}\n\n/** @internal */ const simplex = new Simplex();\n\n/** @internal */ const input = new DistanceInput();\n/** @internal */ const cache = new SimplexCache();\n/** @internal */ const output = new DistanceOutput();\n\n/**\n * Determine if two generic shapes overlap.\n */\nexport const testOverlap = function (shapeA: Shape, indexA: number, shapeB: Shape, indexB: number, xfA: TransformValue, xfB: TransformValue): boolean {\n input.recycle();\n input.proxyA.set(shapeA, indexA);\n input.proxyB.set(shapeB, indexB);\n matrix.copyTransform(input.transformA, xfA);\n matrix.copyTransform(input.transformB, xfB);\n input.useRadii = true;\n\n output.recycle();\n cache.recycle();\n\n Distance(output, cache, input);\n\n return output.distance < 10.0 * EPSILON;\n};\n\n// legacy exports\nDistance.testOverlap = testOverlap;\nDistance.Input = DistanceInput;\nDistance.Output = DistanceOutput;\nDistance.Proxy = DistanceProxy;\nDistance.Cache = SimplexCache;\n\n/**\n * Input parameters for ShapeCast\n */\nexport class ShapeCastInput {\n readonly proxyA = new DistanceProxy();\n readonly proxyB = new DistanceProxy();\n readonly transformA = Transform.identity();\n readonly transformB = Transform.identity();\n readonly translationB = Vec2.zero();\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.transformA.setIdentity();\n this.transformB.setIdentity();\n matrix.zeroVec2(this.translationB);\n }\n}\n\n/**\n * Output results for b2ShapeCast\n */\nexport class ShapeCastOutput {\n point: Vec2 = Vec2.zero();\n normal: Vec2 = Vec2.zero();\n lambda = 1.0;\n iterations = 0;\n}\n\n/**\n * Perform a linear shape cast of shape B moving and shape A fixed. Determines\n * the hit point, normal, and translation fraction.\n * \n * @returns true if hit, false if there is no hit or an initial overlap\n */\n//\n// GJK-raycast\n// Algorithm by Gino van den Bergen.\n// \"Smooth Mesh Contacts with GJK\" in Game Physics Pearls. 2010\nexport const ShapeCast = function(output: ShapeCastOutput, input: ShapeCastInput): boolean {\n output.iterations = 0;\n output.lambda = 1.0;\n output.normal.setZero();\n output.point.setZero();\n\n const proxyA = input.proxyA;\n const proxyB = input.proxyB;\n\n const radiusA = math_max(proxyA.m_radius, Settings.polygonRadius);\n const radiusB = math_max(proxyB.m_radius, Settings.polygonRadius);\n const radius = radiusA + radiusB;\n\n const xfA = input.transformA;\n const xfB = input.transformB;\n\n const r = input.translationB;\n const n = Vec2.zero();\n let lambda = 0.0;\n\n // Initial simplex\n const simplex = new Simplex();\n simplex.m_count = 0;\n\n // Get simplex vertices as an array.\n const vertices = simplex.m_v;\n\n // Get support point in -r direction\n let indexA = proxyA.getSupport(Rot.mulTVec2(xfA.q, Vec2.neg(r)));\n let wA = Transform.mulVec2(xfA, proxyA.getVertex(indexA));\n let indexB = proxyB.getSupport(Rot.mulTVec2(xfB.q, r));\n let wB = Transform.mulVec2(xfB, proxyB.getVertex(indexB));\n const v = Vec2.sub(wA, wB);\n\n // Sigma is the target distance between polygons\n const sigma = math_max(Settings.polygonRadius, radius - Settings.polygonRadius);\n const tolerance = 0.5 * Settings.linearSlop;\n\n // Main iteration loop.\n const k_maxIters = 20;\n let iter = 0;\n while (iter < k_maxIters && v.length() - sigma > tolerance) {\n if (_ASSERT) console.assert(simplex.m_count < 3);\n\n output.iterations += 1;\n\n // Support in direction -v (A - B)\n indexA = proxyA.getSupport(Rot.mulTVec2(xfA.q, Vec2.neg(v)));\n wA = Transform.mulVec2(xfA, proxyA.getVertex(indexA));\n indexB = proxyB.getSupport(Rot.mulTVec2(xfB.q, v));\n wB = Transform.mulVec2(xfB, proxyB.getVertex(indexB));\n const p = Vec2.sub(wA, wB);\n\n // -v is a normal at p\n v.normalize();\n\n // Intersect ray with plane\n const vp = Vec2.dot(v, p);\n const vr = Vec2.dot(v, r);\n if (vp - sigma > lambda * vr) {\n if (vr <= 0.0) {\n return false;\n }\n\n lambda = (vp - sigma) / vr;\n if (lambda > 1.0) {\n return false;\n }\n\n n.setMul(-1, v);\n simplex.m_count = 0;\n }\n\n // Reverse simplex since it works with B - A.\n // Shift by lambda * r because we want the closest point to the current clip point.\n // Note that the support point p is not shifted because we want the plane equation\n // to be formed in unshifted space.\n const vertex = vertices[simplex.m_count];\n vertex.indexA = indexB;\n vertex.wA = Vec2.combine(1, wB, lambda, r);\n vertex.indexB = indexA;\n vertex.wB = wA;\n vertex.w = Vec2.sub(vertex.wB, vertex.wA);\n vertex.a = 1.0;\n simplex.m_count += 1;\n\n switch (simplex.m_count) {\n case 1:\n break;\n\n case 2:\n simplex.solve2();\n break;\n\n case 3:\n simplex.solve3();\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n }\n \n // If we have 3 points, then the origin is in the corresponding triangle.\n if (simplex.m_count == 3) {\n // Overlap\n return false;\n }\n\n // Get search direction.\n v.setVec2(simplex.getClosestPoint());\n\n // Iteration count is equated to the number of support point calls.\n ++iter;\n }\n\n if (iter == 0) {\n // Initial overlap\n return false;\n\t}\n\n // Prepare output.\n const pointA = Vec2.zero();\n const pointB = Vec2.zero();\n simplex.getWitnessPoints(pointB, pointA);\n\n if (v.lengthSquared() > 0.0) {\n n.setMul(-1, v);\n n.normalize();\n }\n\n output.point = Vec2.combine(1, pointA, radiusA, n);\n output.normal = n;\n output.lambda = lambda;\n output.iterations = iter;\n return true;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { stats } from \"../util/stats\";\nimport Timer from \"../util/Timer\";\nimport { Sweep } from \"../common/Sweep\";\nimport { Transform } from \"../common/Transform\";\nimport { Distance, DistanceInput, DistanceOutput, DistanceProxy, SimplexCache } from \"./Distance\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n\n\n/**\n * Input parameters for TimeOfImpact.\n */\nexport class TOIInput {\n proxyA = new DistanceProxy();\n proxyB = new DistanceProxy();\n sweepA = new Sweep();\n sweepB = new Sweep();\n /** defines sweep interval [0, tMax] */\n tMax: number;\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.sweepA.recycle();\n this.sweepB.recycle();\n this.tMax = -1;\n }\n}\n\nexport enum TOIOutputState {\n e_unset = -1,\n e_unknown = 0,\n e_failed = 1,\n e_overlapped = 2,\n e_touching = 3,\n e_separated = 4,\n}\n\n/**\n * Output parameters for TimeOfImpact.\n */\nexport class TOIOutput {\n state = TOIOutputState.e_unset;\n t = -1;\n recycle() {\n this.state = TOIOutputState.e_unset;\n this.t = -1;\n }\n}\n\nstats.toiTime = 0;\nstats.toiMaxTime = 0;\nstats.toiCalls = 0;\nstats.toiIters = 0;\nstats.toiMaxIters = 0;\nstats.toiRootIters = 0;\nstats.toiMaxRootIters = 0;\n\n/** @internal */ const distanceInput = new DistanceInput();\n/** @internal */ const distanceOutput = new DistanceOutput();\n// this is passed to Distance and SeparationFunction\n/** @internal */ const cache = new SimplexCache();\n\n/** @internal */ const xfA = matrix.transform(0, 0, 0);\n/** @internal */ const xfB = matrix.transform(0, 0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const axisA = matrix.vec2(0, 0);\n/** @internal */ const axisB = matrix.vec2(0, 0);\n/** @internal */ const localPointA = matrix.vec2(0, 0);\n/** @internal */ const localPointB = matrix.vec2(0, 0);\n\n\n/**\n * Compute the upper bound on time before two shapes penetrate. Time is\n * represented as a fraction between [0,tMax]. This uses a swept separating axis\n * and may miss some intermediate, non-tunneling collisions. If you change the\n * time interval, you should call this function again.\n *\n * Note: use Distance to compute the contact point and normal at the time of\n * impact.\n *\n * CCD via the local separating axis method. This seeks progression by computing\n * the largest time at which separation is maintained.\n */\nexport const TimeOfImpact = function (output: TOIOutput, input: TOIInput): void {\n const timer = Timer.now();\n\n ++stats.toiCalls;\n\n output.state = TOIOutputState.e_unknown;\n output.t = input.tMax;\n\n const proxyA = input.proxyA; // DistanceProxy\n const proxyB = input.proxyB; // DistanceProxy\n\n const sweepA = input.sweepA; // Sweep\n const sweepB = input.sweepB; // Sweep\n\n // Large rotations can make the root finder fail, so we normalize the\n // sweep angles.\n sweepA.normalize();\n sweepB.normalize();\n\n const tMax = input.tMax;\n\n const totalRadius = proxyA.m_radius + proxyB.m_radius;\n const target = math_max(Settings.linearSlop, totalRadius - 3.0 * Settings.linearSlop);\n const tolerance = 0.25 * Settings.linearSlop;\n if (_ASSERT) console.assert(target > tolerance);\n\n let t1 = 0.0;\n const k_maxIterations = Settings.maxTOIIterations;\n let iter = 0;\n\n // Prepare input for distance query.\n // const cache = new SimplexCache();\n cache.recycle();\n\n distanceInput.proxyA.setVertices(proxyA.m_vertices, proxyA.m_count, proxyA.m_radius);\n distanceInput.proxyB.setVertices(proxyB.m_vertices, proxyB.m_count, proxyB.m_radius);\n distanceInput.useRadii = false;\n\n // The outer loop progressively attempts to compute new separating axes.\n // This loop terminates when an axis is repeated (no progress is made).\n while (true) {\n sweepA.getTransform(xfA, t1);\n sweepB.getTransform(xfB, t1);\n\n // Get the distance between shapes. We can also use the results\n // to get a separating axis.\n matrix.copyTransform(distanceInput.transformA, xfA);\n matrix.copyTransform(distanceInput.transformB, xfB);\n Distance(distanceOutput, cache, distanceInput);\n\n // If the shapes are overlapped, we give up on continuous collision.\n if (distanceOutput.distance <= 0.0) {\n // Failure!\n output.state = TOIOutputState.e_overlapped;\n output.t = 0.0;\n break;\n }\n\n if (distanceOutput.distance < target + tolerance) {\n // Victory!\n output.state = TOIOutputState.e_touching;\n output.t = t1;\n break;\n }\n\n // Initialize the separating axis.\n separationFunction.initialize(cache, proxyA, sweepA, proxyB, sweepB, t1);\n\n // if (false) {\n // // Dump the curve seen by the root finder\n // const N = 100;\n // const dx = 1.0 / N;\n // const xs = []; // [ N + 1 ];\n // const fs = []; // [ N + 1 ];\n // const x = 0.0;\n // for (const i = 0; i <= N; ++i) {\n // sweepA.getTransform(xfA, x);\n // sweepB.getTransform(xfB, x);\n // const f = fcn.evaluate(xfA, xfB) - target;\n // printf(\"%g %g\\n\", x, f);\n // xs[i] = x;\n // fs[i] = f;\n // x += dx;\n // }\n // }\n\n // Compute the TOI on the separating axis. We do this by successively\n // resolving the deepest point. This loop is bounded by the number of\n // vertices.\n let done = false;\n let t2 = tMax;\n let pushBackIter = 0;\n while (true) {\n // Find the deepest point at t2. Store the witness point indices.\n let s2 = separationFunction.findMinSeparation(t2);\n\n // Is the final configuration separated?\n if (s2 > target + tolerance) {\n // Victory!\n output.state = TOIOutputState.e_separated;\n output.t = tMax;\n done = true;\n break;\n }\n\n // Has the separation reached tolerance?\n if (s2 > target - tolerance) {\n // Advance the sweeps\n t1 = t2;\n break;\n }\n\n // Compute the initial separation of the witness points.\n let s1 = separationFunction.evaluate(t1);\n\n // Check for initial overlap. This might happen if the root finder\n // runs out of iterations.\n if (s1 < target - tolerance) {\n output.state = TOIOutputState.e_failed;\n output.t = t1;\n done = true;\n break;\n }\n\n // Check for touching\n if (s1 <= target + tolerance) {\n // Victory! t1 should hold the TOI (could be 0.0).\n output.state = TOIOutputState.e_touching;\n output.t = t1;\n done = true;\n break;\n }\n\n // Compute 1D root of: f(x) - target = 0\n let rootIterCount = 0;\n let a1 = t1;\n let a2 = t2;\n while (true) {\n // Use a mix of the secant rule and bisection.\n let t;\n if (rootIterCount & 1) {\n // Secant rule to improve convergence.\n t = a1 + (target - s1) * (a2 - a1) / (s2 - s1);\n } else {\n // Bisection to guarantee progress.\n t = 0.5 * (a1 + a2);\n }\n\n ++rootIterCount;\n ++stats.toiRootIters;\n\n const s = separationFunction.evaluate(t);\n\n if (math_abs(s - target) < tolerance) {\n // t2 holds a tentative value for t1\n t2 = t;\n break;\n }\n\n // Ensure we continue to bracket the root.\n if (s > target) {\n a1 = t;\n s1 = s;\n } else {\n a2 = t;\n s2 = s;\n }\n\n if (rootIterCount === 50) {\n break;\n }\n }\n\n stats.toiMaxRootIters = math_max(stats.toiMaxRootIters, rootIterCount);\n\n ++pushBackIter;\n\n if (pushBackIter === Settings.maxPolygonVertices) {\n break;\n }\n }\n\n ++iter;\n ++stats.toiIters;\n\n if (done) {\n break;\n }\n\n if (iter === k_maxIterations) {\n // Root finder got stuck. Semi-victory.\n output.state = TOIOutputState.e_failed;\n output.t = t1;\n break;\n }\n }\n\n stats.toiMaxIters = math_max(stats.toiMaxIters, iter);\n\n const time = Timer.diff(timer);\n stats.toiMaxTime = math_max(stats.toiMaxTime, time);\n stats.toiTime += time;\n\n separationFunction.recycle();\n};\n\nenum SeparationFunctionType {\n e_unset = -1,\n e_points = 1,\n e_faceA = 2,\n e_faceB = 3,\n}\n\nclass SeparationFunction {\n // input cache\n // todo: maybe assign by copy instead of reference?\n m_proxyA: DistanceProxy = null;\n m_proxyB: DistanceProxy = null;\n m_sweepA: Sweep = null;\n m_sweepB: Sweep = null;\n\n // initialize cache\n m_type = SeparationFunctionType.e_unset;\n m_localPoint = matrix.vec2(0, 0);\n m_axis = matrix.vec2(0, 0);\n\n // compute output\n indexA = -1;\n indexB = -1;\n\n recycle() {\n this.m_proxyA = null;\n this.m_proxyB = null;\n this.m_sweepA = null;\n this.m_sweepB = null;\n\n this.m_type = SeparationFunctionType.e_unset;\n matrix.zeroVec2(this.m_localPoint);\n matrix.zeroVec2(this.m_axis);\n\n this.indexA = -1;\n this.indexB = -1;\n }\n\n // TODO_ERIN might not need to return the separation\n\n initialize(cache: SimplexCache, proxyA: DistanceProxy, sweepA: Sweep, proxyB: DistanceProxy, sweepB: Sweep, t1: number): number {\n const count = cache.count;\n if (_ASSERT) console.assert(0 < count && count < 3);\n\n this.m_proxyA = proxyA;\n this.m_proxyB = proxyB;\n this.m_sweepA = sweepA;\n this.m_sweepB = sweepB;\n\n this.m_sweepA.getTransform(xfA, t1);\n this.m_sweepB.getTransform(xfB, t1);\n\n if (count === 1) {\n this.m_type = SeparationFunctionType.e_points;\n const localPointA = this.m_proxyA.getVertex(cache.indexA[0]);\n const localPointB = this.m_proxyB.getVertex(cache.indexB[0]);\n matrix.transformVec2(pointA, xfA, localPointA);\n matrix.transformVec2(pointB, xfB, localPointB);\n matrix.subVec2(this.m_axis, pointB, pointA);\n const s = matrix.normalizeVec2Length(this.m_axis);\n return s;\n\n } else if (cache.indexA[0] === cache.indexA[1]) {\n // Two points on B and one on A.\n this.m_type = SeparationFunctionType.e_faceB;\n const localPointB1 = proxyB.getVertex(cache.indexB[0]);\n const localPointB2 = proxyB.getVertex(cache.indexB[1]);\n\n matrix.crossVec2Num(this.m_axis, matrix.subVec2(temp, localPointB2, localPointB1), 1.0);\n matrix.normalizeVec2(this.m_axis);\n matrix.rotVec2(normal, xfB.q, this.m_axis);\n\n matrix.combine2Vec2(this.m_localPoint, 0.5, localPointB1, 0.5, localPointB2);\n matrix.transformVec2(pointB, xfB, this.m_localPoint);\n\n const localPointA = proxyA.getVertex(cache.indexA[0]);\n const pointA = Transform.mulVec2(xfA, localPointA);\n\n let s = matrix.dotVec2(pointA, normal) - matrix.dotVec2(pointB, normal);\n if (s < 0.0) {\n matrix.negVec2(this.m_axis);\n s = -s;\n }\n return s;\n\n } else {\n // Two points on A and one or two points on B.\n this.m_type = SeparationFunctionType.e_faceA;\n const localPointA1 = this.m_proxyA.getVertex(cache.indexA[0]);\n const localPointA2 = this.m_proxyA.getVertex(cache.indexA[1]);\n\n matrix.crossVec2Num(this.m_axis, matrix.subVec2(temp, localPointA2, localPointA1), 1.0);\n matrix.normalizeVec2(this.m_axis);\n matrix.rotVec2(normal, xfA.q, this.m_axis);\n\n matrix.combine2Vec2(this.m_localPoint, 0.5, localPointA1, 0.5, localPointA2);\n matrix.transformVec2(pointA, xfA, this.m_localPoint);\n\n const localPointB = this.m_proxyB.getVertex(cache.indexB[0]);\n matrix.transformVec2(pointB, xfB, localPointB);\n\n let s = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal);\n if (s < 0.0) {\n matrix.negVec2(this.m_axis);\n s = -s;\n }\n return s;\n }\n }\n\n compute(find: boolean, t: number): number {\n // It was findMinSeparation and evaluate\n this.m_sweepA.getTransform(xfA, t);\n this.m_sweepB.getTransform(xfB, t);\n\n switch (this.m_type) {\n case SeparationFunctionType.e_points: {\n if (find) {\n matrix.derotVec2(axisA, xfA.q, this.m_axis);\n matrix.derotVec2(axisB, xfB.q, matrix.scaleVec2(temp, -1, this.m_axis));\n\n this.indexA = this.m_proxyA.getSupport(axisA);\n this.indexB = this.m_proxyB.getSupport(axisB);\n }\n\n matrix.copyVec2(localPointA, this.m_proxyA.getVertex(this.indexA));\n matrix.copyVec2(localPointB, this.m_proxyB.getVertex(this.indexB));\n\n matrix.transformVec2(pointA, xfA, localPointA);\n matrix.transformVec2(pointB, xfB, localPointB);\n\n const sep = matrix.dotVec2(pointB, this.m_axis) - matrix.dotVec2(pointA, this.m_axis);\n return sep;\n }\n\n case SeparationFunctionType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.m_axis);\n matrix.transformVec2(pointA, xfA, this.m_localPoint);\n\n if (find) {\n matrix.derotVec2(axisB, xfB.q, matrix.scaleVec2(temp, -1, normal));\n\n this.indexA = -1;\n this.indexB = this.m_proxyB.getSupport(axisB);\n }\n\n matrix.copyVec2(localPointB, this.m_proxyB.getVertex(this.indexB));\n matrix.transformVec2(pointB, xfB, localPointB);\n\n const sep = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal);\n return sep;\n }\n\n case SeparationFunctionType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.m_axis);\n matrix.transformVec2(pointB, xfB, this.m_localPoint);\n\n if (find) {\n matrix.derotVec2(axisA, xfA.q, matrix.scaleVec2(temp, -1, normal));\n\n this.indexB = -1;\n this.indexA = this.m_proxyA.getSupport(axisA);\n }\n\n matrix.copyVec2(localPointA, this.m_proxyA.getVertex(this.indexA));\n matrix.transformVec2(pointA, xfA, localPointA);\n\n const sep = matrix.dotVec2(pointA, normal) - matrix.dotVec2(pointB, normal);\n return sep;\n }\n\n default:\n if (_ASSERT) console.assert(false);\n if (find) {\n this.indexA = -1;\n this.indexB = -1;\n }\n return 0.0;\n }\n }\n\n findMinSeparation(t: number): number {\n return this.compute(true, t);\n }\n\n evaluate(t: number): number {\n return this.compute(false, t);\n }\n}\n\n/** @internal */ const separationFunction = new SeparationFunction();\n\n// legacy exports\nTimeOfImpact.Input = TOIInput;\nTimeOfImpact.Output = TOIOutput;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { EPSILON } from \"../common/Math\";\nimport { Body } from \"./Body\";\nimport type { Contact } from \"./Contact\";\nimport { Joint } from \"./Joint\";\nimport { TimeOfImpact, TOIInput, TOIOutput, TOIOutputState } from \"../collision/TimeOfImpact\";\nimport { Distance, DistanceInput, DistanceOutput, SimplexCache } from \"../collision/Distance\";\nimport { World } from \"./World\";\nimport { Sweep } from \"../common/Sweep\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_min = Math.min;\n\n\nexport class TimeStep {\n /** time step */\n dt: number = 0;\n /** inverse time step (0 if dt == 0) */\n inv_dt: number = 0;\n velocityIterations: number = 0;\n positionIterations: number = 0;\n warmStarting: boolean = false;\n blockSolve: boolean = true;\n\n /** timestep ratio for variable timestep */\n inv_dt0: number = 0.0;\n /** dt * inv_dt0 */\n dtRatio: number = 1;\n\n reset(dt: number): void {\n if (this.dt > 0.0) {\n this.inv_dt0 = this.inv_dt;\n }\n this.dt = dt;\n this.inv_dt = dt == 0 ? 0 : 1 / dt;\n this.dtRatio = dt * this.inv_dt0;\n }\n}\n\n// reuse\n/** @internal */ const s_subStep = new TimeStep();\n/** @internal */ const c = matrix.vec2(0, 0);\n/** @internal */ const v = matrix.vec2(0, 0);\n/** @internal */ const translation = matrix.vec2(0, 0);\n/** @internal */ const input = new TOIInput();\n/** @internal */ const output = new TOIOutput();\n/** @internal */ const backup = new Sweep();\n/** @internal */ const backup1 = new Sweep();\n/** @internal */ const backup2 = new Sweep();\n\n/**\n * Contact impulses for reporting. Impulses are used instead of forces because\n * sub-step forces may approach infinity for rigid body collisions. These match\n * up one-to-one with the contact points in Manifold.\n */\nexport class ContactImpulse {\n // TODO: merge with Contact class?\n\n private readonly contact: Contact;\n private readonly normals: number[];\n private readonly tangents: number[];\n\n constructor(contact: Contact) {\n this.contact = contact;\n this.normals = [];\n this.tangents = [];\n }\n\n recycle() {\n this.normals.length = 0;\n this.tangents.length = 0;\n }\n\n get normalImpulses(): number[] {\n const contact = this.contact;\n const normals = this.normals;\n normals.length = 0;\n for (let p = 0; p < contact.v_points.length; ++p) {\n normals.push(contact.v_points[p].normalImpulse);\n }\n return normals;\n }\n\n get tangentImpulses(): number[] {\n const contact = this.contact;\n const tangents = this.tangents;\n tangents.length = 0;\n for (let p = 0; p < contact.v_points.length; ++p) {\n tangents.push(contact.v_points[p].tangentImpulse);\n }\n return tangents;\n }\n}\n\n/**\n * Finds and solves islands. An island is a connected subset of the world.\n */\nexport class Solver {\n m_world: World;\n m_stack: Body[];\n m_bodies: Body[];\n m_contacts: Contact[];\n m_joints: Joint[];\n\n constructor(world: World) {\n this.m_world = world;\n this.m_stack = [];\n this.m_bodies = [];\n this.m_contacts = [];\n this.m_joints = [];\n }\n\n clear(): void {\n this.m_stack.length = 0;\n this.m_bodies.length = 0;\n this.m_contacts.length = 0;\n this.m_joints.length = 0;\n }\n\n addBody(body: Body): void {\n if (_ASSERT) console.assert(body instanceof Body, \"Not a Body!\", body);\n this.m_bodies.push(body);\n // why?\n // body.c_position.c.setZero();\n // body.c_position.a = 0;\n // body.c_velocity.v.setZero();\n // body.c_velocity.w = 0;\n }\n\n addContact(contact: Contact): void {\n // if (_ASSERT) console.assert(contact instanceof Contact, 'Not a Contact!', contact);\n this.m_contacts.push(contact);\n }\n\n addJoint(joint: Joint): void {\n if (_ASSERT) console.assert(joint instanceof Joint, \"Not a Joint!\", joint);\n this.m_joints.push(joint);\n }\n\n solveWorld(step: TimeStep): void {\n const world = this.m_world;\n\n // Clear all the island flags.\n for (let b = world.m_bodyList; b; b = b.m_next) {\n b.m_islandFlag = false;\n }\n for (let c = world.m_contactList; c; c = c.m_next) {\n c.m_islandFlag = false;\n }\n for (let j = world.m_jointList; j; j = j.m_next) {\n j.m_islandFlag = false;\n }\n\n // Build and simulate all awake islands.\n const stack = this.m_stack;\n let loop = -1;\n for (let seed = world.m_bodyList; seed; seed = seed.m_next) {\n loop++;\n if (seed.m_islandFlag) {\n continue;\n }\n\n if (seed.isAwake() == false || seed.isActive() == false) {\n continue;\n }\n\n // The seed can be dynamic or kinematic.\n if (seed.isStatic()) {\n continue;\n }\n\n // Reset island and stack.\n this.clear();\n\n stack.push(seed);\n\n seed.m_islandFlag = true;\n\n // Perform a depth first search (DFS) on the constraint graph.\n while (stack.length > 0) {\n // Grab the next body off the stack and add it to the island.\n const b = stack.pop();\n if (_ASSERT) console.assert(b.isActive() == true);\n this.addBody(b);\n\n // Make sure the body is awake (without resetting sleep timer).\n b.m_awakeFlag = true;\n\n // To keep islands as small as possible, we don't\n // propagate islands across static bodies.\n if (b.isStatic()) {\n continue;\n }\n\n // Search all contacts connected to this body.\n for (let ce = b.m_contactList; ce; ce = ce.next) {\n const contact = ce.contact;\n\n // Has this contact already been added to an island?\n if (contact.m_islandFlag) {\n continue;\n }\n\n // Is this contact solid and touching?\n if (contact.isEnabled() == false || contact.isTouching() == false) {\n continue;\n }\n\n // Skip sensors.\n const sensorA = contact.m_fixtureA.m_isSensor;\n const sensorB = contact.m_fixtureB.m_isSensor;\n if (sensorA || sensorB) {\n continue;\n }\n\n this.addContact(contact);\n contact.m_islandFlag = true;\n\n const other = ce.other;\n\n // Was the other body already added to this island?\n if (other.m_islandFlag) {\n continue;\n }\n\n // if (_ASSERT) console.assert(stack.length < world.m_bodyCount);\n stack.push(other);\n other.m_islandFlag = true;\n }\n\n // Search all joints connect to this body.\n for (let je = b.m_jointList; je; je = je.next) {\n if (je.joint.m_islandFlag == true) {\n continue;\n }\n\n const other = je.other;\n\n // Don't simulate joints connected to inactive bodies.\n if (other.isActive() == false) {\n continue;\n }\n\n this.addJoint(je.joint);\n je.joint.m_islandFlag = true;\n\n if (other.m_islandFlag) {\n continue;\n }\n\n // if (_ASSERT) console.assert(stack.length < world.m_bodyCount);\n stack.push(other);\n other.m_islandFlag = true;\n }\n }\n\n this.solveIsland(step);\n\n // Post solve cleanup.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n // Allow static bodies to participate in other islands.\n // TODO: are they added at all?\n const b = this.m_bodies[i];\n if (b.isStatic()) {\n b.m_islandFlag = false;\n }\n }\n }\n }\n\n solveIsland(step: TimeStep): void {\n // B2: Island Solve\n const world = this.m_world;\n const gravity = world.m_gravity;\n const allowSleep = world.m_allowSleep;\n\n const h = step.dt;\n\n // Integrate velocities and apply damping. Initialize the body state.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.m_sweep.c);\n const a = body.m_sweep.a;\n matrix.copyVec2(v, body.m_linearVelocity);\n let w = body.m_angularVelocity;\n\n // Store positions for continuous collision.\n matrix.copyVec2(body.m_sweep.c0, body.m_sweep.c);\n body.m_sweep.a0 = body.m_sweep.a;\n\n if (body.isDynamic()) {\n // Integrate velocities.\n matrix.plusScaleVec2(v, h * body.m_gravityScale, gravity);\n matrix.plusScaleVec2(v, h * body.m_invMass, body.m_force);\n w += h * body.m_invI * body.m_torque;\n /**\n *
\n         * Apply damping.\n         * ODE: dv/dt + c * v = 0\n         * Solution: v(t) = v0 * exp(-c * t)\n         * Time step: v(t + dt) = v0 * exp(-c * (t + dt)) = v0 * exp(-c * t) * exp(-c * dt) = v * exp(-c * dt)\n         * v2 = exp(-c * dt) * v1\n         * Pade approximation:\n         * v2 = v1 * 1 / (1 + c * dt)\n         * 
\n */\n matrix.scaleVec2(v, 1.0 / (1.0 + h * body.m_linearDamping), v);\n w *= 1.0 / (1.0 + h * body.m_angularDamping);\n }\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initConstraint(step);\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initVelocityConstraint(step);\n }\n\n if (step.warmStarting) {\n // Warm start.\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.warmStartConstraint(step);\n }\n }\n\n for (let i = 0; i < this.m_joints.length; ++i) {\n const joint = this.m_joints[i];\n joint.initVelocityConstraints(step);\n }\n\n // Solve velocity constraints\n for (let i = 0; i < step.velocityIterations; ++i) {\n for (let j = 0; j < this.m_joints.length; ++j) {\n const joint = this.m_joints[j];\n joint.solveVelocityConstraints(step);\n }\n\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n contact.solveVelocityConstraint(step);\n }\n }\n\n // Store impulses for warm starting\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.storeConstraintImpulses(step);\n }\n\n // Integrate positions\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.c_position.c);\n let a = body.c_position.a;\n matrix.copyVec2(v, body.c_velocity.v);\n let w = body.c_velocity.w;\n\n // Check for large velocities\n matrix.scaleVec2(translation, h, v);\n const translationLengthSqr = matrix.lengthSqrVec2(translation);\n if (translationLengthSqr > Settings.maxTranslationSquared) {\n const ratio = Settings.maxTranslation / math_sqrt(translationLengthSqr);\n matrix.mulVec2(v, ratio);\n }\n\n const rotation = h * w;\n if (rotation * rotation > Settings.maxRotationSquared) {\n const ratio = Settings.maxRotation / math_abs(rotation);\n w *= ratio;\n }\n\n // Integrate\n matrix.plusScaleVec2(c, h, v);\n a += h * w;\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n }\n\n // Solve position constraints\n let positionSolved = false;\n for (let i = 0; i < step.positionIterations; ++i) {\n let minSeparation = 0.0;\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n const separation = contact.solvePositionConstraint(step);\n minSeparation = math_min(minSeparation, separation);\n }\n // We can't expect minSpeparation >= -Settings.linearSlop because we don't\n // push the separation above -Settings.linearSlop.\n const contactsOkay = minSeparation >= -3.0 * Settings.linearSlop;\n\n let jointsOkay = true;\n for (let j = 0; j < this.m_joints.length; ++j) {\n const joint = this.m_joints[j];\n const jointOkay = joint.solvePositionConstraints(step);\n jointsOkay = jointsOkay && jointOkay;\n }\n\n if (contactsOkay && jointsOkay) {\n // Exit early if the position errors are small.\n positionSolved = true;\n break;\n }\n }\n\n // Copy state buffers back to the bodies\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(body.m_sweep.c, body.c_position.c);\n body.m_sweep.a = body.c_position.a;\n matrix.copyVec2(body.m_linearVelocity, body.c_velocity.v);\n body.m_angularVelocity = body.c_velocity.w;\n body.synchronizeTransform();\n }\n\n this.postSolveIsland();\n\n if (allowSleep) {\n let minSleepTime = Infinity;\n\n const linTolSqr = Settings.linearSleepToleranceSqr;\n const angTolSqr = Settings.angularSleepToleranceSqr;\n\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n if (body.isStatic()) {\n continue;\n }\n\n if ((body.m_autoSleepFlag == false)\n || (body.m_angularVelocity * body.m_angularVelocity > angTolSqr)\n || (matrix.lengthSqrVec2(body.m_linearVelocity) > linTolSqr)) {\n body.m_sleepTime = 0.0;\n minSleepTime = 0.0;\n } else {\n body.m_sleepTime += h;\n minSleepTime = math_min(minSleepTime, body.m_sleepTime);\n }\n }\n\n if (minSleepTime >= Settings.timeToSleep && positionSolved) {\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n body.setAwake(false);\n }\n }\n }\n }\n\n /**\n * Find TOI contacts and solve them.\n */\n solveWorldTOI(step: TimeStep): void {\n const world = this.m_world;\n\n if (world.m_stepComplete) {\n for (let b = world.m_bodyList; b; b = b.m_next) {\n b.m_islandFlag = false;\n b.m_sweep.alpha0 = 0.0;\n }\n\n for (let c = world.m_contactList; c; c = c.m_next) {\n // Invalidate TOI\n c.m_toiFlag = false;\n c.m_islandFlag = false;\n c.m_toiCount = 0;\n c.m_toi = 1.0;\n }\n }\n\n // Find TOI events and solve them.\n while (true) {\n // Find the first TOI.\n let minContact: Contact | null = null;\n let minAlpha = 1.0;\n\n for (let c = world.m_contactList; c; c = c.m_next) {\n // Is this contact disabled?\n if (c.isEnabled() == false) {\n continue;\n }\n\n // Prevent excessive sub-stepping.\n if (c.m_toiCount > Settings.maxSubSteps) {\n continue;\n }\n\n let alpha = 1.0;\n if (c.m_toiFlag) {\n // This contact has a valid cached TOI.\n alpha = c.m_toi;\n } else {\n const fA = c.getFixtureA();\n const fB = c.getFixtureB();\n\n // Is there a sensor?\n if (fA.isSensor() || fB.isSensor()) {\n continue;\n }\n\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n if (_ASSERT) console.assert(bA.isDynamic() || bB.isDynamic());\n\n const activeA = bA.isAwake() && !bA.isStatic();\n const activeB = bB.isAwake() && !bB.isStatic();\n\n // Is at least one body active (awake and dynamic or kinematic)?\n if (activeA == false && activeB == false) {\n continue;\n }\n\n const collideA = bA.isBullet() || !bA.isDynamic();\n const collideB = bB.isBullet() || !bB.isDynamic();\n\n // Are these two non-bullet dynamic bodies?\n if (collideA == false && collideB == false) {\n continue;\n }\n\n // Compute the TOI for this contact.\n // Put the sweeps onto the same time interval.\n let alpha0 = bA.m_sweep.alpha0;\n\n if (bA.m_sweep.alpha0 < bB.m_sweep.alpha0) {\n alpha0 = bB.m_sweep.alpha0;\n bA.m_sweep.advance(alpha0);\n } else if (bB.m_sweep.alpha0 < bA.m_sweep.alpha0) {\n alpha0 = bA.m_sweep.alpha0;\n bB.m_sweep.advance(alpha0);\n }\n\n if (_ASSERT) console.assert(alpha0 < 1.0);\n\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n\n const sweepA = bA.m_sweep;\n const sweepB = bB.m_sweep;\n\n // Compute the time of impact in interval [0, minTOI]\n input.proxyA.set(fA.getShape(), indexA);\n input.proxyB.set(fB.getShape(), indexB);\n input.sweepA.set(bA.m_sweep);\n input.sweepB.set(bB.m_sweep);\n input.tMax = 1.0;\n\n TimeOfImpact(output, input);\n\n // Beta is the fraction of the remaining portion of the [time?].\n const beta = output.t;\n if (output.state == TOIOutputState.e_touching) {\n alpha = math_min(alpha0 + (1.0 - alpha0) * beta, 1.0);\n } else {\n alpha = 1.0;\n }\n\n c.m_toi = alpha;\n c.m_toiFlag = true;\n }\n\n if (alpha < minAlpha) {\n // This is the minimum TOI found so far.\n minContact = c;\n minAlpha = alpha;\n }\n }\n\n if (minContact == null || 1.0 - 10.0 * EPSILON < minAlpha) {\n // No more TOI events. Done!\n world.m_stepComplete = true;\n break;\n }\n\n // Advance the bodies to the TOI.\n const fA = minContact.getFixtureA();\n const fB = minContact.getFixtureB();\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n backup1.set(bA.m_sweep);\n backup2.set(bB.m_sweep);\n\n bA.advance(minAlpha);\n bB.advance(minAlpha);\n\n // The TOI contact likely has some new contact points.\n minContact.update(world);\n minContact.m_toiFlag = false;\n ++minContact.m_toiCount;\n\n // Is the contact solid?\n if (minContact.isEnabled() == false || minContact.isTouching() == false) {\n // Restore the sweeps.\n minContact.setEnabled(false);\n bA.m_sweep.set(backup1);\n bB.m_sweep.set(backup2);\n bA.synchronizeTransform();\n bB.synchronizeTransform();\n continue;\n }\n\n bA.setAwake(true);\n bB.setAwake(true);\n\n // Build the island\n this.clear();\n this.addBody(bA);\n this.addBody(bB);\n this.addContact(minContact);\n\n bA.m_islandFlag = true;\n bB.m_islandFlag = true;\n minContact.m_islandFlag = true;\n\n // Get contacts on bodyA and bodyB.\n const bodies = [ bA, bB ];\n for (let i = 0; i < bodies.length; ++i) {\n const body = bodies[i];\n if (body.isDynamic()) {\n for (let ce = body.m_contactList; ce; ce = ce.next) {\n // if (this.m_bodyCount == this.m_bodyCapacity) { break; }\n // if (this.m_contactCount == this.m_contactCapacity) { break; }\n\n const contact = ce.contact;\n\n // Has this contact already been added to the island?\n if (contact.m_islandFlag) {\n continue;\n }\n\n // Only add if either is static, kinematic or bullet.\n const other = ce.other;\n if (other.isDynamic() && !body.isBullet() && !other.isBullet()) {\n continue;\n }\n\n // Skip sensors.\n const sensorA = contact.m_fixtureA.m_isSensor;\n const sensorB = contact.m_fixtureB.m_isSensor;\n if (sensorA || sensorB) {\n continue;\n }\n\n // Tentatively advance the body to the TOI.\n backup.set(other.m_sweep);\n if (other.m_islandFlag == false) {\n other.advance(minAlpha);\n }\n\n // Update the contact points\n contact.update(world);\n\n // Was the contact disabled by the user?\n // Are there contact points?\n if (contact.isEnabled() == false || contact.isTouching() == false) {\n other.m_sweep.set(backup);\n other.synchronizeTransform();\n continue;\n }\n\n // Add the contact to the island\n contact.m_islandFlag = true;\n this.addContact(contact);\n\n // Has the other body already been added to the island?\n if (other.m_islandFlag) {\n continue;\n }\n\n // Add the other body to the island.\n other.m_islandFlag = true;\n\n if (!other.isStatic()) {\n other.setAwake(true);\n }\n\n this.addBody(other);\n }\n }\n }\n\n s_subStep.reset((1.0 - minAlpha) * step.dt);\n s_subStep.dtRatio = 1.0;\n s_subStep.positionIterations = 20;\n s_subStep.velocityIterations = step.velocityIterations;\n s_subStep.warmStarting = false;\n\n this.solveIslandTOI(s_subStep, bA, bB);\n\n // Reset island flags and synchronize broad-phase proxies.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n body.m_islandFlag = false;\n\n if (!body.isDynamic()) {\n continue;\n }\n\n body.synchronizeFixtures();\n\n // Invalidate all contact TOIs on this displaced body.\n for (let ce = body.m_contactList; ce; ce = ce.next) {\n ce.contact.m_toiFlag = false;\n ce.contact.m_islandFlag = false;\n }\n }\n\n // Commit fixture proxy movements to the broad-phase so that new contacts\n // are created.\n // Also, some contacts can be destroyed.\n world.findNewContacts();\n\n if (world.m_subStepping) {\n world.m_stepComplete = false;\n break;\n }\n }\n }\n\n solveIslandTOI(subStep: TimeStep, toiA: Body, toiB: Body): void {\n\n // Initialize the body state.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n matrix.copyVec2(body.c_position.c, body.m_sweep.c);\n body.c_position.a = body.m_sweep.a;\n matrix.copyVec2(body.c_velocity.v, body.m_linearVelocity);\n body.c_velocity.w = body.m_angularVelocity;\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initConstraint(subStep);\n }\n\n // Solve position constraints.\n for (let i = 0; i < subStep.positionIterations; ++i) {\n let minSeparation = 0.0;\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n const separation = contact.solvePositionConstraintTOI(subStep, toiA, toiB);\n minSeparation = math_min(minSeparation, separation);\n }\n // We can't expect minSpeparation >= -Settings.linearSlop because we don't\n // push the separation above -Settings.linearSlop.\n const contactsOkay = minSeparation >= -1.5 * Settings.linearSlop;\n if (contactsOkay) {\n break;\n }\n }\n\n if (false) {\n // Is the new position really safe?\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const c = this.m_contacts[i];\n const fA = c.getFixtureA();\n const fB = c.getFixtureB();\n\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n\n const input = new DistanceInput();\n input.proxyA.set(fA.getShape(), indexA);\n input.proxyB.set(fB.getShape(), indexB);\n input.transformA.set(bA.getTransform());\n input.transformB.set(bB.getTransform());\n input.useRadii = false;\n\n const output = new DistanceOutput();\n const cache = new SimplexCache();\n Distance(output, cache, input);\n\n if (output.distance == 0 || cache.count == 3) {\n cache.count += 0;\n }\n }\n }\n\n // Leap of faith to new safe state.\n matrix.copyVec2(toiA.m_sweep.c0, toiA.c_position.c);\n toiA.m_sweep.a0 = toiA.c_position.a;\n matrix.copyVec2(toiB.m_sweep.c0, toiB.c_position.c);\n toiB.m_sweep.a0 = toiB.c_position.a;\n\n // No warm starting is needed for TOI events because warm\n // starting impulses were applied in the discrete solver.\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initVelocityConstraint(subStep);\n }\n\n // Solve velocity constraints.\n for (let i = 0; i < subStep.velocityIterations; ++i) {\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n contact.solveVelocityConstraint(subStep);\n }\n }\n\n // Don't store the TOI contact forces for warm starting\n // because they can be quite large.\n\n const h = subStep.dt;\n\n // Integrate positions\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.c_position.c);\n let a = body.c_position.a;\n matrix.copyVec2(v, body.c_velocity.v);\n let w = body.c_velocity.w;\n\n // Check for large velocities\n matrix.scaleVec2(translation, h, v);\n const translationLengthSqr = matrix.lengthSqrVec2(translation);\n if (translationLengthSqr > Settings.maxTranslationSquared) {\n const ratio = Settings.maxTranslation / math_sqrt(translationLengthSqr);\n matrix.mulVec2(v, ratio);\n }\n\n const rotation = h * w;\n if (rotation * rotation > Settings.maxRotationSquared) {\n const ratio = Settings.maxRotation / math_abs(rotation);\n w *= ratio;\n }\n\n // Integrate\n matrix.plusScaleVec2(c, h, v);\n a += h * w;\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n\n // Sync bodies\n matrix.copyVec2(body.m_sweep.c, c);\n body.m_sweep.a = a;\n matrix.copyVec2(body.m_linearVelocity, v);\n body.m_angularVelocity = w;\n body.synchronizeTransform();\n }\n\n this.postSolveIsland();\n }\n\n /** @internal */\n postSolveIsland(): void {\n for (let c = 0; c < this.m_contacts.length; ++c) {\n const contact = this.m_contacts[c];\n this.m_world.postSolve(contact, contact.m_impulse);\n }\n }\n}\n\n// @ts-ignore\nSolver.TimeStep = TimeStep;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A 2-by-2 matrix. Stored in column-major order.\n */\nexport class Mat22 {\n ex: Vec2;\n ey: Vec2;\n\n constructor(a: number, b: number, c: number, d: number);\n constructor(a: { x: number; y: number }, b: { x: number; y: number });\n constructor();\n constructor(a?, b?, c?, d?) {\n if (typeof a === \"object\" && a !== null) {\n this.ex = Vec2.clone(a);\n this.ey = Vec2.clone(b);\n } else if (typeof a === \"number\") {\n this.ex = Vec2.neo(a, c);\n this.ey = Vec2.neo(b, d);\n } else {\n this.ex = Vec2.zero();\n this.ey = Vec2.zero();\n }\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.ex) && Vec2.isValid(obj.ey);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Mat22.isValid(o), \"Invalid Mat22!\", o);\n }\n\n set(a: Mat22): void;\n set(a: Vec2Value, b: Vec2Value): void;\n set(a: number, b: number, c: number, d: number): void;\n set(a, b?, c?, d?): void {\n if (typeof a === \"number\" && typeof b === \"number\" && typeof c === \"number\"\n && typeof d === \"number\") {\n this.ex.setNum(a, c);\n this.ey.setNum(b, d);\n\n } else if (typeof a === \"object\" && typeof b === \"object\") {\n this.ex.setVec2(a);\n this.ey.setVec2(b);\n\n } else if (typeof a === \"object\") {\n if (_ASSERT) Mat22.assert(a);\n this.ex.setVec2(a.ex);\n this.ey.setVec2(a.ey);\n\n } else {\n if (_ASSERT) console.assert(false);\n }\n }\n\n setIdentity(): void {\n this.ex.x = 1.0;\n this.ey.x = 0.0;\n this.ex.y = 0.0;\n this.ey.y = 1.0;\n }\n\n setZero(): void {\n this.ex.x = 0.0;\n this.ey.x = 0.0;\n this.ex.y = 0.0;\n this.ey.y = 0.0;\n }\n\n getInverse(): Mat22 {\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const imx = new Mat22();\n imx.ex.x = det * d;\n imx.ey.x = -det * b;\n imx.ex.y = -det * c;\n imx.ey.y = det * a;\n return imx;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases.\n */\n solve(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const w = Vec2.zero();\n w.x = det * (d * v.x - b * v.y);\n w.y = det * (a * v.y - c * v.x);\n return w;\n }\n\n /**\n * Multiply a matrix times a vector. If a rotation matrix is provided, then this\n * transforms the vector from one frame to another.\n */\n static mul(mx: Mat22, my: Mat22): Mat22;\n static mul(mx: Mat22, v: Vec2Value): Vec2;\n static mul(mx, v) {\n if (v && \"x\" in v && \"y\" in v) {\n if (_ASSERT) Vec2.assert(v);\n const x = mx.ex.x * v.x + mx.ey.x * v.y;\n const y = mx.ex.y * v.x + mx.ey.y * v.y;\n return Vec2.neo(x, y);\n\n } else if (v && \"ex\" in v && \"ey\" in v) { // Mat22\n if (_ASSERT) Mat22.assert(v);\n // return new Mat22(Vec2.mul(mx, v.ex), Vec2.mul(mx, v.ey));\n const a = mx.ex.x * v.ex.x + mx.ey.x * v.ex.y;\n const b = mx.ex.x * v.ey.x + mx.ey.x * v.ey.y;\n const c = mx.ex.y * v.ex.x + mx.ey.y * v.ex.y;\n const d = mx.ex.y * v.ey.x + mx.ey.y * v.ey.y;\n return new Mat22(a, b, c, d);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulVec2(mx: Mat22, v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n const x = mx.ex.x * v.x + mx.ey.x * v.y;\n const y = mx.ex.y * v.x + mx.ey.y * v.y;\n return Vec2.neo(x, y);\n }\n\n static mulMat22(mx: Mat22, v: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(v);\n // return new Mat22(Vec2.mul(mx, v.ex), Vec2.mul(mx, v.ey));\n const a = mx.ex.x * v.ex.x + mx.ey.x * v.ex.y;\n const b = mx.ex.x * v.ey.x + mx.ey.x * v.ey.y;\n const c = mx.ex.y * v.ex.x + mx.ey.y * v.ex.y;\n const d = mx.ex.y * v.ey.x + mx.ey.y * v.ey.y;\n return new Mat22(a, b, c, d);\n }\n\n /**\n * Multiply a matrix transpose times a vector. If a rotation matrix is provided,\n * then this transforms the vector from one frame to another (inverse\n * transform).\n */\n static mulT(mx: Mat22, my: Mat22): Mat22;\n static mulT(mx: Mat22, v: Vec2Value): Vec2;\n static mulT(mx, v) {\n if (v && \"x\" in v && \"y\" in v) { // Vec2\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(Vec2.dot(v, mx.ex), Vec2.dot(v, mx.ey));\n\n } else if (v && \"ex\" in v && \"ey\" in v) { // Mat22\n if (_ASSERT) Mat22.assert(v);\n const c1 = Vec2.neo(Vec2.dot(mx.ex, v.ex), Vec2.dot(mx.ey, v.ex));\n const c2 = Vec2.neo(Vec2.dot(mx.ex, v.ey), Vec2.dot(mx.ey, v.ey));\n return new Mat22(c1, c2);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulTVec2(mx: Mat22, v: Vec2Value): Vec2 {\n if (_ASSERT) Mat22.assert(mx);\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(Vec2.dot(v, mx.ex), Vec2.dot(v, mx.ey));\n }\n\n static mulTMat22(mx: Mat22, v: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx);\n if (_ASSERT) Mat22.assert(v);\n const c1 = Vec2.neo(Vec2.dot(mx.ex, v.ex), Vec2.dot(mx.ey, v.ex));\n const c2 = Vec2.neo(Vec2.dot(mx.ex, v.ey), Vec2.dot(mx.ey, v.ey));\n return new Mat22(c1, c2);\n }\n\n static abs(mx: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx);\n return new Mat22(Vec2.abs(mx.ex), Vec2.abs(mx.ey));\n }\n\n static add(mx1: Mat22, mx2: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx1);\n if (_ASSERT) Mat22.assert(mx2);\n return new Mat22(Vec2.add(mx1.ex, mx2.ex), Vec2.add(mx1.ey, mx2.ey));\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { Vec2Value } from \"../common/Vec2\";\nimport { TransformValue } from \"../common/Transform\";\nimport { EPSILON } from \"../common/Math\";\n\n\n/** @internal */ const math_sqrt = Math.sqrt;\n\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const cA = matrix.vec2(0, 0);\n/** @internal */ const cB = matrix.vec2(0, 0);\n/** @internal */ const dist = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const clipPoint = matrix.vec2(0, 0);\n\nexport enum ManifoldType {\n e_unset = -1,\n e_circles = 0,\n e_faceA = 1,\n e_faceB = 2\n}\n\nexport enum ContactFeatureType {\n e_unset = -1,\n e_vertex = 0,\n e_face = 1\n}\n\n/**\n * This is used for determining the state of contact points.\n */\n export enum PointState {\n /** Point does not exist */\n nullState = 0,\n /** Point was added in the update */\n addState = 1,\n /** Point persisted across the update */\n persistState = 2,\n /** Point was removed in the update */\n removeState = 3\n}\n\n/**\n * Used for computing contact manifolds.\n */\n export class ClipVertex {\n v = matrix.vec2(0, 0);\n id: ContactID = new ContactID();\n\n set(o: ClipVertex): void {\n matrix.copyVec2(this.v, o.v);\n this.id.set(o.id);\n }\n recycle() {\n matrix.zeroVec2(this.v);\n this.id.recycle();\n }\n}\n\n/**\n * A manifold for two touching convex shapes. Manifolds are created in `evaluate`\n * method of Contact subclasses.\n *\n * Supported manifold types are e_faceA or e_faceB for clip point versus plane\n * with radius and e_circles point versus point with radius.\n *\n * We store contacts in this way so that position correction can account for\n * movement, which is critical for continuous physics. All contact scenarios\n * must be expressed in one of these types. This structure is stored across time\n * steps, so we keep it small.\n */\nexport class Manifold {\n type: ManifoldType;\n\n /**\n * Usage depends on manifold type:\n * - circles: not used\n * - faceA: the normal on polygonA\n * - faceB: the normal on polygonB\n */\n localNormal = matrix.vec2(0, 0);\n\n /**\n * Usage depends on manifold type:\n * - circles: the local center of circleA\n * - faceA: the center of faceA\n * - faceB: the center of faceB\n */\n localPoint = matrix.vec2(0, 0);\n\n /** The points of contact */\n points: ManifoldPoint[] = [ new ManifoldPoint(), new ManifoldPoint() ];\n\n /** The number of manifold points */\n pointCount: number = 0;\n\n set(that: Manifold): void {\n this.type = that.type;\n matrix.copyVec2(this.localNormal, that.localNormal);\n matrix.copyVec2(this.localPoint, that.localPoint);\n this.pointCount = that.pointCount;\n this.points[0].set(that.points[0]);\n this.points[1].set(that.points[1]);\n }\n\n recycle(): void {\n this.type = ManifoldType.e_unset;\n matrix.zeroVec2(this.localNormal);\n matrix.zeroVec2(this.localPoint);\n this.pointCount = 0;\n this.points[0].recycle();\n this.points[1].recycle();\n }\n\n /**\n * Evaluate the manifold with supplied transforms. This assumes modest motion\n * from the original state. This does not change the point count, impulses, etc.\n * The radii must come from the shapes that generated the manifold.\n */\n getWorldManifold(wm: WorldManifold | null, xfA: TransformValue, radiusA: number, xfB: TransformValue, radiusB: number): WorldManifold {\n if (this.pointCount == 0) {\n return wm;\n }\n\n wm = wm || new WorldManifold();\n\n wm.pointCount = this.pointCount;\n\n const normal = wm.normal;\n const points = wm.points;\n const separations = wm.separations;\n\n switch (this.type) {\n case ManifoldType.e_circles: {\n matrix.setVec2(normal, 1.0, 0.0);\n const manifoldPoint = this.points[0];\n matrix.transformVec2(pointA, xfA, this.localPoint);\n matrix.transformVec2(pointB, xfB, manifoldPoint.localPoint);\n matrix.subVec2(dist, pointB, pointA);\n const lengthSqr = matrix.lengthSqrVec2(dist);\n if (lengthSqr > EPSILON * EPSILON) {\n const length = math_sqrt(lengthSqr);\n matrix.scaleVec2(normal, 1 / length, dist);\n }\n matrix.combine2Vec2(cA, 1, pointA, radiusA, normal);\n matrix.combine2Vec2(cB, 1, pointB, -radiusB, normal);\n matrix.combine2Vec2(points[0], 0.5, cA, 0.5, cB);\n separations[0] = matrix.dotVec2(matrix.subVec2(temp, cB, cA), normal);\n break;\n }\n\n case ManifoldType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.localNormal);\n matrix.transformVec2(planePoint, xfA, this.localPoint);\n\n for (let i = 0; i < this.pointCount; ++i) {\n const manifoldPoint = this.points[i];\n matrix.transformVec2(clipPoint, xfB, manifoldPoint.localPoint);\n matrix.combine2Vec2(cA, 1, clipPoint, radiusA - matrix.dotVec2(matrix.subVec2(temp, clipPoint, planePoint), normal), normal);\n matrix.combine2Vec2(cB, 1, clipPoint, -radiusB, normal);\n matrix.combine2Vec2(points[i], 0.5, cA, 0.5, cB);\n separations[i] = matrix.dotVec2(matrix.subVec2(temp, cB, cA), normal);\n }\n break;\n }\n\n case ManifoldType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.localNormal);\n matrix.transformVec2(planePoint, xfB, this.localPoint);\n\n for (let i = 0; i < this.pointCount; ++i) {\n const manifoldPoint = this.points[i];\n matrix.transformVec2(clipPoint, xfA, manifoldPoint.localPoint);\n matrix.combine2Vec2(cB, 1, clipPoint, radiusB - matrix.dotVec2(matrix.subVec2(temp, clipPoint, planePoint), normal), normal);\n matrix.combine2Vec2(cA, 1, clipPoint, -radiusA, normal);\n matrix.combine2Vec2(points[i], 0.5, cA, 0.5, cB);\n separations[i] = matrix.dotVec2(matrix.subVec2(temp, cA, cB), normal);\n }\n // Ensure normal points from A to B.\n matrix.negVec2(normal);\n break;\n }\n }\n\n return wm;\n }\n\n static clipSegmentToLine = clipSegmentToLine;\n static ClipVertex = ClipVertex;\n static getPointStates = getPointStates;\n static PointState = PointState;\n}\n\n/**\n * A manifold point is a contact point belonging to a contact manifold. It holds\n * details related to the geometry and dynamics of the contact points.\n *\n * This structure is stored across time steps, so we keep it small.\n *\n * Note: impulses are used for internal caching and may not provide reliable\n * contact forces, especially for high speed collisions.\n */\nexport class ManifoldPoint {\n /**\n * Usage depends on manifold type:\n * - circles: the local center of circleB\n * - faceA: the local center of circleB or the clip point of polygonB\n * - faceB: the clip point of polygonA\n */\n localPoint = matrix.vec2(0, 0);\n /**\n * The non-penetration impulse\n */\n normalImpulse = 0;\n /**\n * The friction impulse\n */\n tangentImpulse = 0;\n /**\n * Uniquely identifies a contact point between two shapes to facilitate warm starting\n */\n readonly id = new ContactID();\n\n set(that: ManifoldPoint): void {\n matrix.copyVec2(this.localPoint, that.localPoint);\n this.normalImpulse = that.normalImpulse;\n this.tangentImpulse = that.tangentImpulse;\n this.id.set(that.id);\n }\n\n recycle(): void {\n matrix.zeroVec2(this.localPoint);\n this.normalImpulse = 0;\n this.tangentImpulse = 0;\n this.id.recycle();\n }\n}\n\n/**\n * Contact ids to facilitate warm starting.\n * \n * ContactFeature: The features that intersect to form the contact point.\n */\nexport class ContactID {\n\n /**\n * Used to quickly compare contact ids.\n */\n key = -1;\n\n /** ContactFeature index on shapeA */\n indexA = -1;\n\n /** ContactFeature index on shapeB */\n indexB = -1;\n\n /** ContactFeature type on shapeA */\n typeA = ContactFeatureType.e_unset;\n\n /** ContactFeature type on shapeB */\n typeB = ContactFeatureType.e_unset;\n\n setFeatures(indexA: number, typeA: ContactFeatureType, indexB: number, typeB: ContactFeatureType): void {\n this.indexA = indexA;\n this.indexB = indexB;\n this.typeA = typeA;\n this.typeB = typeB;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n set(that: ContactID): void {\n this.indexA = that.indexA;\n this.indexB = that.indexB;\n this.typeA = that.typeA;\n this.typeB = that.typeB;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n swapFeatures(): void {\n const indexA = this.indexA;\n const indexB = this.indexB;\n const typeA = this.typeA;\n const typeB = this.typeB;\n this.indexA = indexB;\n this.indexB = indexA;\n this.typeA = typeB;\n this.typeB = typeA;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n recycle(): void {\n this.indexA = 0;\n this.indexB = 0;\n this.typeA = ContactFeatureType.e_unset;\n this.typeB = ContactFeatureType.e_unset;\n this.key = -1;\n }\n}\n\n/**\n * This is used to compute the current state of a contact manifold.\n */\nexport class WorldManifold {\n /** World vector pointing from A to B */\n normal = matrix.vec2(0, 0);\n\n /** World contact point (point of intersection) */\n points = [matrix.vec2(0, 0), matrix.vec2(0, 0)]; // [maxManifoldPoints]\n\n /** A negative value indicates overlap, in meters */\n separations = [0, 0]; // [maxManifoldPoints]\n\n /** The number of manifold points */\n pointCount = 0;\n\n recycle() {\n matrix.zeroVec2(this.normal);\n matrix.zeroVec2(this.points[0]);\n matrix.zeroVec2(this.points[1]);\n this.separations[0] = 0;\n this.separations[1] = 0;\n this.pointCount = 0;\n }\n}\n\n/**\n * Compute the point states given two manifolds. The states pertain to the\n * transition from manifold1 to manifold2. So state1 is either persist or remove\n * while state2 is either add or persist.\n */\nexport function getPointStates(\n state1: PointState[],\n state2: PointState[],\n manifold1: Manifold,\n manifold2: Manifold\n): void {\n // state1, state2: PointState[Settings.maxManifoldPoints]\n\n // for (var i = 0; i < Settings.maxManifoldPoints; ++i) {\n // state1[i] = PointState.nullState;\n // state2[i] = PointState.nullState;\n // }\n\n // Detect persists and removes.\n for (let i = 0; i < manifold1.pointCount; ++i) {\n const id = manifold1.points[i].id;\n\n state1[i] = PointState.removeState;\n\n for (let j = 0; j < manifold2.pointCount; ++j) {\n if (manifold2.points[j].id.key === id.key) {\n state1[i] = PointState.persistState;\n break;\n }\n }\n }\n\n // Detect persists and adds.\n for (let i = 0; i < manifold2.pointCount; ++i) {\n const id = manifold2.points[i].id;\n\n state2[i] = PointState.addState;\n\n for (let j = 0; j < manifold1.pointCount; ++j) {\n if (manifold1.points[j].id.key === id.key) {\n state2[i] = PointState.persistState;\n break;\n }\n }\n }\n}\n\n/**\n * Clipping for contact manifolds. Sutherland-Hodgman clipping.\n */\nexport function clipSegmentToLine(\n vOut: ClipVertex[],\n vIn: ClipVertex[],\n normal: Vec2Value,\n offset: number,\n vertexIndexA: number\n): number {\n // Start with no output points\n let numOut = 0;\n\n // Calculate the distance of end points to the line\n const distance0 = matrix.dotVec2(normal, vIn[0].v) - offset;\n const distance1 = matrix.dotVec2(normal, vIn[1].v) - offset;\n\n // If the points are behind the plane\n if (distance0 <= 0.0)\n vOut[numOut++].set(vIn[0]);\n if (distance1 <= 0.0)\n vOut[numOut++].set(vIn[1]);\n\n // If the points are on different sides of the plane\n if (distance0 * distance1 < 0.0) {\n // Find intersection point of edge and plane\n const interp = distance0 / (distance0 - distance1);\n matrix.combine2Vec2(vOut[numOut].v, 1 - interp, vIn[0].v, interp, vIn[1].v);\n\n // VertexA is hitting edgeB.\n vOut[numOut].id.setFeatures(vertexIndexA, ContactFeatureType.e_vertex, vIn[0].id.indexB, ContactFeatureType.e_face);\n ++numOut;\n }\n\n return numOut;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { ShapeType } from \"../collision/Shape\";\nimport { clamp } from \"../common/Math\";\nimport { TransformValue } from \"../common/Transform\";\nimport { Mat22 } from \"../common/Mat22\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { Manifold, ManifoldType, WorldManifold } from \"../collision/Manifold\";\nimport { testOverlap } from \"../collision/Distance\";\nimport { Fixture } from \"./Fixture\";\nimport { Body } from \"./Body\";\nimport { ContactImpulse, TimeStep } from \"./Solver\";\nimport { Pool } from \"../util/Pool\";\nimport { getTransform } from \"./Position\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n// Solver debugging is normally disabled because the block solver sometimes has to deal with a poorly conditioned effective mass matrix.\n/** @internal */ const DEBUG_SOLVER = false;\n\n/** @internal */ const contactPool = new Pool({\n create() {\n return new Contact();\n },\n release(contact: Contact) {\n contact.recycle();\n }\n});\n\n/** @internal */ const oldManifold = new Manifold();\n\n/** @internal */ const worldManifold = new WorldManifold();\n\n/**\n * A contact edge is used to connect bodies and contacts together in a contact\n * graph where each body is a node and each contact is an edge. A contact edge\n * belongs to a doubly linked list maintained in each attached body. Each\n * contact has two contact nodes, one for each attached body.\n */\nexport class ContactEdge {\n contact: Contact;\n prev: ContactEdge | null = null;\n next: ContactEdge | null = null;\n other: Body | null = null;\n constructor(contact: Contact) {\n this.contact = contact;\n }\n\n /** @internal */\n recycle() {\n this.prev = null;\n this.next = null;\n this.other = null;\n }\n}\n\nexport type EvaluateFunction = (\n manifold: Manifold,\n xfA: TransformValue,\n fixtureA: Fixture,\n indexA: number,\n xfB: TransformValue,\n fixtureB: Fixture,\n indexB: number\n) => void;\n\n/**\n * Friction mixing law. The idea is to allow either fixture to drive the\n * friction to zero. For example, anything slides on ice.\n */\nexport function mixFriction(friction1: number, friction2: number): number {\n return math_sqrt(friction1 * friction2);\n}\n\n/**\n * Restitution mixing law. The idea is allow for anything to bounce off an\n * inelastic surface. For example, a superball bounces on anything.\n */\nexport function mixRestitution(restitution1: number, restitution2: number): number {\n return restitution1 > restitution2 ? restitution1 : restitution2;\n}\n\n// TODO: move this to Settings?\n/** @internal */ const s_registers = [];\n\n// TODO: merge with ManifoldPoint?\nexport class VelocityConstraintPoint {\n rA = matrix.vec2(0, 0);\n rB = matrix.vec2(0, 0);\n normalImpulse = 0;\n tangentImpulse = 0;\n normalMass = 0;\n tangentMass = 0;\n velocityBias = 0;\n\n recycle() {\n matrix.zeroVec2(this.rA);\n matrix.zeroVec2(this.rB);\n this.normalImpulse = 0;\n this.tangentImpulse = 0;\n this.normalMass = 0;\n this.tangentMass = 0;\n this.velocityBias = 0;\n }\n}\n\n/** @internal */ const cA = matrix.vec2(0, 0);\n/** @internal */ const vA = matrix.vec2(0, 0);\n/** @internal */ const cB = matrix.vec2(0, 0);\n/** @internal */ const vB = matrix.vec2(0, 0);\n/** @internal */ const tangent = matrix.vec2(0, 0);\n/** @internal */ const xfA = matrix.transform(0, 0, 0);\n/** @internal */ const xfB = matrix.transform(0, 0, 0);\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const clipPoint = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const rA = matrix.vec2(0, 0);\n/** @internal */ const rB = matrix.vec2(0, 0);\n/** @internal */ const P = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const point = matrix.vec2(0, 0);\n/** @internal */ const dv = matrix.vec2(0, 0);\n/** @internal */ const dv1 = matrix.vec2(0, 0);\n/** @internal */ const dv2 = matrix.vec2(0, 0);\n/** @internal */ const b = matrix.vec2(0, 0);\n/** @internal */ const a = matrix.vec2(0, 0);\n/** @internal */ const x = matrix.vec2(0, 0);\n/** @internal */ const d = matrix.vec2(0, 0);\n/** @internal */ const P1 = matrix.vec2(0, 0);\n/** @internal */ const P2 = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n\n/**\n * The class manages contact between two shapes. A contact exists for each\n * overlapping AABB in the broad-phase (except if filtered). Therefore a contact\n * object may exist that has no contact points.\n */\nexport class Contact {\n // Nodes for connecting bodies.\n /** @internal */ m_nodeA = new ContactEdge(this);\n /** @internal */ m_nodeB = new ContactEdge(this);\n /** @internal */ m_fixtureA: Fixture | null = null;\n /** @internal */ m_fixtureB: Fixture | null = null;\n /** @internal */ m_indexA = -1;\n /** @internal */ m_indexB = -1;\n /** @internal */ m_evaluateFcn: EvaluateFunction | null = null;\n /** @internal */ m_manifold: Manifold = new Manifold();\n /** @internal */ m_prev: Contact | null = null;\n /** @internal */ m_next: Contact | null = null;\n /** @internal */ m_toi = 1.0;\n /** @internal */ m_toiCount = 0;\n // This contact has a valid TOI in m_toi\n /** @internal */ m_toiFlag = false;\n /** @internal */ m_friction = 0.0;\n /** @internal */ m_restitution = 0.0;\n /** @internal */ m_tangentSpeed = 0.0;\n /** @internal This contact can be disabled (by user) */\n m_enabledFlag = true;\n /** @internal Used when crawling contact graph when forming islands. */\n m_islandFlag = false;\n /** @internal Set when the shapes are touching. */\n m_touchingFlag = false;\n /** @internal This contact needs filtering because a fixture filter was changed. */\n m_filterFlag = false;\n /** @internal This bullet contact had a TOI event */\n m_bulletHitFlag = false;\n\n /** @internal Contact reporting impulse object cache */\n m_impulse: ContactImpulse = new ContactImpulse(this);\n\n // VelocityConstraint\n /** @internal */ v_points = [new VelocityConstraintPoint(), new VelocityConstraintPoint()]; // [maxManifoldPoints];\n /** @internal */ v_normal = matrix.vec2(0, 0);\n /** @internal */ v_normalMass: Mat22 = new Mat22();\n /** @internal */ v_K: Mat22 = new Mat22();\n /** @internal */ v_pointCount = 0;\n /** @internal */ v_tangentSpeed = 0;\n /** @internal */ v_friction = 0;\n /** @internal */ v_restitution = 0;\n /** @internal */ v_invMassA = 0;\n /** @internal */ v_invMassB = 0;\n /** @internal */ v_invIA = 0;\n /** @internal */ v_invIB = 0;\n\n // PositionConstraint\n /** @internal */ p_localPoints = [matrix.vec2(0, 0), matrix.vec2(0, 0)]; // [maxManifoldPoints];\n /** @internal */ p_localNormal = matrix.vec2(0, 0);\n /** @internal */ p_localPoint = matrix.vec2(0, 0);\n /** @internal */ p_localCenterA = matrix.vec2(0, 0);\n /** @internal */ p_localCenterB = matrix.vec2(0, 0);\n /** @internal */ p_type = ManifoldType.e_unset;\n /** @internal */ p_radiusA = 0;\n /** @internal */ p_radiusB = 0;\n /** @internal */ p_pointCount = 0;\n /** @internal */ p_invMassA = 0;\n /** @internal */ p_invMassB = 0;\n /** @internal */ p_invIA = 0;\n /** @internal */ p_invIB = 0;\n\n /** @internal */ \n initialize(fA: Fixture, indexA: number, fB: Fixture, indexB: number, evaluateFcn: EvaluateFunction) {\n this.m_fixtureA = fA;\n this.m_fixtureB = fB;\n\n this.m_indexA = indexA;\n this.m_indexB = indexB;\n\n this.m_evaluateFcn = evaluateFcn;\n\n this.m_friction = mixFriction(this.m_fixtureA.m_friction, this.m_fixtureB.m_friction);\n this.m_restitution = mixRestitution(this.m_fixtureA.m_restitution, this.m_fixtureB.m_restitution);\n }\n\n /** @internal */ \n recycle() {\n this.m_nodeA.recycle();\n this.m_nodeB.recycle();\n this.m_fixtureA = null;\n this.m_fixtureB = null;\n this.m_indexA = -1;\n this.m_indexB = -1;\n this.m_evaluateFcn = null;\n this.m_manifold.recycle();\n this.m_prev = null;\n this.m_next = null;\n this.m_toi = 1;\n this.m_toiCount = 0;\n this.m_toiFlag = false;\n this.m_friction = 0;\n this.m_restitution = 0;\n this.m_tangentSpeed = 0;\n this.m_enabledFlag = true;\n this.m_islandFlag = false;\n this.m_touchingFlag = false;\n this.m_filterFlag = false;\n this.m_bulletHitFlag = false;\n\n this.m_impulse.recycle();\n\n // VelocityConstraint\n for(const point of this.v_points) {\n point.recycle();\n }\n matrix.zeroVec2(this.v_normal);\n this.v_normalMass.setZero();\n this.v_K.setZero();\n this.v_pointCount = 0;\n this.v_tangentSpeed = 0;\n this.v_friction = 0;\n this.v_restitution = 0;\n this.v_invMassA = 0;\n this.v_invMassB = 0;\n this.v_invIA = 0;\n this.v_invIB = 0;\n\n // PositionConstraint\n for(const point of this.p_localPoints) {\n matrix.zeroVec2(point);\n }\n matrix.zeroVec2(this.p_localNormal);\n matrix.zeroVec2(this.p_localPoint);\n matrix.zeroVec2(this.p_localCenterA);\n matrix.zeroVec2(this.p_localCenterB);\n this.p_type = ManifoldType.e_unset;\n this.p_radiusA = 0;\n this.p_radiusB = 0;\n this.p_pointCount = 0;\n this.p_invMassA = 0;\n this.p_invMassB = 0;\n this.p_invIA = 0;\n this.p_invIB = 0;\n }\n\n initConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n const manifold = this.m_manifold;\n\n const pointCount = manifold.pointCount;\n if (_ASSERT) console.assert(pointCount > 0);\n\n this.v_invMassA = bodyA.m_invMass;\n this.v_invMassB = bodyB.m_invMass;\n this.v_invIA = bodyA.m_invI;\n this.v_invIB = bodyB.m_invI;\n\n this.v_friction = this.m_friction;\n this.v_restitution = this.m_restitution;\n this.v_tangentSpeed = this.m_tangentSpeed;\n\n this.v_pointCount = pointCount;\n\n this.v_K.setZero();\n this.v_normalMass.setZero();\n\n this.p_invMassA = bodyA.m_invMass;\n this.p_invMassB = bodyB.m_invMass;\n this.p_invIA = bodyA.m_invI;\n this.p_invIB = bodyB.m_invI;\n matrix.copyVec2(this.p_localCenterA, bodyA.m_sweep.localCenter);\n matrix.copyVec2(this.p_localCenterB, bodyB.m_sweep.localCenter);\n\n this.p_radiusA = shapeA.m_radius;\n this.p_radiusB = shapeB.m_radius;\n\n this.p_type = manifold.type;\n matrix.copyVec2(this.p_localNormal, manifold.localNormal);\n matrix.copyVec2(this.p_localPoint, manifold.localPoint);\n this.p_pointCount = pointCount;\n\n for (let j = 0; j < Settings.maxManifoldPoints; ++j) {\n this.v_points[j].recycle();\n matrix.zeroVec2(this.p_localPoints[j]);\n }\n\n for (let j = 0; j < pointCount; ++j) {\n const cp = manifold.points[j];\n const vcp = this.v_points[j];\n if (step.warmStarting) {\n vcp.normalImpulse = step.dtRatio * cp.normalImpulse;\n vcp.tangentImpulse = step.dtRatio * cp.tangentImpulse;\n }\n matrix.copyVec2(this.p_localPoints[j], cp.localPoint);\n }\n }\n\n /**\n * Get the contact manifold. Do not modify the manifold unless you understand\n * the internals of the library.\n */\n getManifold(): Manifold {\n return this.m_manifold;\n }\n\n /**\n * Get the world manifold.\n */\n getWorldManifold(worldManifold: WorldManifold | null): WorldManifold | undefined {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n return this.m_manifold.getWorldManifold(\n worldManifold,\n bodyA.getTransform(), shapeA.m_radius,\n bodyB.getTransform(), shapeB.m_radius\n );\n }\n\n /**\n * Enable/disable this contact. This can be used inside the pre-solve contact\n * listener. The contact is only disabled for the current time step (or sub-step\n * in continuous collisions).\n */\n setEnabled(flag: boolean): void {\n this.m_enabledFlag = !!flag;\n }\n\n /**\n * Has this contact been disabled?\n */\n isEnabled(): boolean {\n return this.m_enabledFlag;\n }\n\n /**\n * Is this contact touching?\n */\n isTouching(): boolean {\n return this.m_touchingFlag;\n }\n\n /**\n * Get the next contact in the world's contact list.\n */\n getNext(): Contact | null {\n return this.m_next;\n }\n\n /**\n * Get fixture A in this contact.\n */\n getFixtureA(): Fixture {\n return this.m_fixtureA;\n }\n\n /**\n * Get fixture B in this contact.\n */\n getFixtureB(): Fixture {\n return this.m_fixtureB;\n }\n\n /**\n * Get the child primitive index for fixture A.\n */\n getChildIndexA(): number {\n return this.m_indexA;\n }\n\n /**\n * Get the child primitive index for fixture B.\n */\n getChildIndexB(): number {\n return this.m_indexB;\n }\n\n /**\n * Flag this contact for filtering. Filtering will occur the next time step.\n */\n flagForFiltering(): void {\n this.m_filterFlag = true;\n }\n\n /**\n * Override the default friction mixture. You can call this in\n * \"pre-solve\" callback. This value persists until set or reset.\n */\n setFriction(friction: number): void {\n this.m_friction = friction;\n }\n\n /**\n * Get the friction.\n */\n getFriction(): number {\n return this.m_friction;\n }\n\n /**\n * Reset the friction mixture to the default value.\n */\n resetFriction(): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_friction = mixFriction(fixtureA.m_friction, fixtureB.m_friction);\n }\n\n /**\n * Override the default restitution mixture. You can call this in\n * \"pre-solve\" callback. The value persists until you set or reset.\n */\n setRestitution(restitution: number): void {\n this.m_restitution = restitution;\n }\n\n /**\n * Get the restitution.\n */\n getRestitution(): number {\n return this.m_restitution;\n }\n\n /**\n * Reset the restitution to the default value.\n */\n resetRestitution(): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_restitution = mixRestitution(fixtureA.m_restitution, fixtureB.m_restitution);\n }\n\n /**\n * Set the desired tangent speed for a conveyor belt behavior. In meters per\n * second.\n */\n setTangentSpeed(speed: number): void {\n this.m_tangentSpeed = speed;\n }\n\n /**\n * Get the desired tangent speed. In meters per second.\n */\n getTangentSpeed(): number {\n return this.m_tangentSpeed;\n }\n\n /**\n * Called by Update method, and implemented by subclasses.\n */\n evaluate(manifold: Manifold, xfA: TransformValue, xfB: TransformValue): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_evaluateFcn(manifold, xfA, fixtureA, this.m_indexA, xfB, fixtureB, this.m_indexB);\n }\n\n /**\n * Updates the contact manifold and touching status.\n *\n * Note: do not assume the fixture AABBs are overlapping or are valid.\n *\n * @param listener.beginContact\n * @param listener.endContact\n * @param listener.preSolve\n */\n update(listener?: {\n beginContact(contact: Contact): void,\n endContact(contact: Contact): void,\n preSolve(contact: Contact, oldManifold: Manifold): void\n }): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n // Re-enable this contact.\n this.m_enabledFlag = true;\n\n let touching = false;\n const wasTouching = this.m_touchingFlag;\n\n const sensorA = fixtureA.m_isSensor;\n const sensorB = fixtureB.m_isSensor;\n const sensor = sensorA || sensorB;\n\n const xfA = bodyA.m_xf;\n const xfB = bodyB.m_xf;\n\n // Is this contact a sensor?\n if (sensor) {\n touching = testOverlap(shapeA, this.m_indexA, shapeB, this.m_indexB, xfA, xfB);\n\n // Sensors don't generate manifolds.\n this.m_manifold.pointCount = 0;\n } else {\n\n oldManifold.recycle();\n oldManifold.set(this.m_manifold);\n this.m_manifold.recycle();\n\n this.evaluate(this.m_manifold, xfA, xfB);\n touching = this.m_manifold.pointCount > 0;\n\n // Match old contact ids to new contact ids and copy the\n // stored impulses to warm start the solver.\n for (let i = 0; i < this.m_manifold.pointCount; ++i) {\n const nmp = this.m_manifold.points[i];\n nmp.normalImpulse = 0.0;\n nmp.tangentImpulse = 0.0;\n\n for (let j = 0; j < oldManifold.pointCount; ++j) {\n const omp = oldManifold.points[j];\n if (omp.id.key === nmp.id.key) {\n nmp.normalImpulse = omp.normalImpulse;\n nmp.tangentImpulse = omp.tangentImpulse;\n break;\n }\n }\n }\n\n if (touching !== wasTouching) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n }\n\n this.m_touchingFlag = touching;\n\n const hasListener = typeof listener === \"object\" && listener !== null;\n\n if (!wasTouching && touching && hasListener) {\n listener.beginContact(this);\n }\n\n if (wasTouching && !touching && hasListener) {\n listener.endContact(this);\n }\n\n if (!sensor && touching && hasListener && oldManifold) {\n listener.preSolve(this, oldManifold);\n }\n }\n\n solvePositionConstraint(step: TimeStep): number {\n return this._solvePositionConstraint(step, null, null);\n }\n\n solvePositionConstraintTOI(step: TimeStep, toiA: Body, toiB: Body): number {\n return this._solvePositionConstraint(step, toiA, toiB);\n }\n\n private _solvePositionConstraint(step: TimeStep, toiA: Body | null, toiB: Body | null): number {\n const toi = toiA !== null && toiB !== null ? true : false;\n let minSeparation = 0.0;\n\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return minSeparation;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return minSeparation;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const localCenterA = this.p_localCenterA;\n const localCenterB = this.p_localCenterB;\n\n let mA = 0.0;\n let iA = 0.0;\n if (!toi || (bodyA === toiA || bodyA === toiB)) {\n mA = this.p_invMassA;\n iA = this.p_invIA;\n }\n\n let mB = 0.0;\n let iB = 0.0;\n if (!toi || (bodyB === toiA || bodyB === toiB)) {\n mB = this.p_invMassB;\n iB = this.p_invIB;\n }\n\n matrix.copyVec2(cA, positionA.c);\n let aA = positionA.a;\n\n matrix.copyVec2(cB, positionB.c);\n let aB = positionB.a;\n\n // Solve normal constraints\n for (let j = 0; j < this.p_pointCount; ++j) {\n getTransform(xfA, localCenterA, cA, aA);\n getTransform(xfB, localCenterB, cB, aB);\n\n // PositionSolverManifold\n let separation: number;\n switch (this.p_type) {\n case ManifoldType.e_circles: {\n matrix.transformVec2(pointA, xfA, this.p_localPoint);\n matrix.transformVec2(pointB, xfB, this.p_localPoints[0]);\n matrix.subVec2(normal, pointB, pointA);\n matrix.normalizeVec2(normal);\n\n matrix.combine2Vec2(point, 0.5, pointA, 0.5, pointB);\n separation = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal) - this.p_radiusA - this.p_radiusB;\n break;\n }\n\n case ManifoldType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.p_localNormal);\n matrix.transformVec2(planePoint, xfA, this.p_localPoint);\n matrix.transformVec2(clipPoint, xfB, this.p_localPoints[j]);\n separation = matrix.dotVec2(clipPoint, normal) - matrix.dotVec2(planePoint, normal) - this.p_radiusA - this.p_radiusB;\n matrix.copyVec2(point, clipPoint);\n break;\n }\n\n case ManifoldType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.p_localNormal);\n matrix.transformVec2(planePoint, xfB, this.p_localPoint);\n matrix.transformVec2(clipPoint, xfA, this.p_localPoints[j]);\n separation = matrix.dotVec2(clipPoint, normal) - matrix.dotVec2(planePoint, normal) - this.p_radiusA - this.p_radiusB;\n matrix.copyVec2(point, clipPoint);\n\n // Ensure normal points from A to B\n matrix.negVec2(normal);\n break;\n }\n // todo: what should we do here?\n default: {\n return minSeparation;\n }\n }\n\n matrix.subVec2(rA, point, cA);\n matrix.subVec2(rB, point, cB);\n\n // Track max constraint error.\n minSeparation = math_min(minSeparation, separation);\n\n const baumgarte = toi ? Settings.toiBaugarte : Settings.baumgarte;\n const linearSlop = Settings.linearSlop;\n const maxLinearCorrection = Settings.maxLinearCorrection;\n\n // Prevent large corrections and allow slop.\n const C = clamp(baumgarte * (separation + linearSlop), -maxLinearCorrection, 0.0);\n\n // Compute the effective mass.\n const rnA = matrix.crossVec2Vec2(rA, normal);\n const rnB = matrix.crossVec2Vec2(rB, normal);\n const K = mA + mB + iA * rnA * rnA + iB * rnB * rnB;\n\n // Compute normal impulse\n const impulse = K > 0.0 ? -C / K : 0.0;\n\n matrix.scaleVec2(P, impulse, normal);\n\n matrix.minusScaleVec2(cA, mA, P);\n aA -= iA * matrix.crossVec2Vec2(rA, P);\n\n matrix.plusScaleVec2(cB, mB, P);\n aB += iB * matrix.crossVec2Vec2(rB, P);\n }\n\n matrix.copyVec2(positionA.c, cA);\n positionA.a = aA;\n\n matrix.copyVec2(positionB.c, cB);\n positionB.a = aB;\n\n return minSeparation;\n }\n\n initVelocityConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const radiusA = this.p_radiusA;\n const radiusB = this.p_radiusB;\n const manifold = this.m_manifold;\n\n const mA = this.v_invMassA;\n const mB = this.v_invMassB;\n const iA = this.v_invIA;\n const iB = this.v_invIB;\n const localCenterA = this.p_localCenterA;\n const localCenterB = this.p_localCenterB;\n\n matrix.copyVec2(cA, positionA.c);\n const aA = positionA.a;\n matrix.copyVec2(vA, velocityA.v);\n const wA = velocityA.w;\n\n matrix.copyVec2(cB, positionB.c);\n const aB = positionB.a;\n matrix.copyVec2(vB, velocityB.v);\n const wB = velocityB.w;\n\n if (_ASSERT) console.assert(manifold.pointCount > 0);\n\n getTransform(xfA, localCenterA, cA, aA);\n getTransform(xfB, localCenterB, cB, aB);\n\n worldManifold.recycle();\n manifold.getWorldManifold(worldManifold, xfA, radiusA, xfB, radiusB);\n\n matrix.copyVec2(this.v_normal, worldManifold.normal);\n\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n const wmp = worldManifold.points[j];\n\n matrix.subVec2(vcp.rA, wmp, cA);\n matrix.subVec2(vcp.rB, wmp, cB);\n\n const rnA = matrix.crossVec2Vec2(vcp.rA, this.v_normal);\n const rnB = matrix.crossVec2Vec2(vcp.rB, this.v_normal);\n\n const kNormal = mA + mB + iA * rnA * rnA + iB * rnB * rnB;\n\n vcp.normalMass = kNormal > 0.0 ? 1.0 / kNormal : 0.0;\n\n matrix.crossVec2Num(tangent, this.v_normal, 1.0);\n\n const rtA = matrix.crossVec2Vec2(vcp.rA, tangent);\n const rtB = matrix.crossVec2Vec2(vcp.rB, tangent);\n\n const kTangent = mA + mB + iA * rtA * rtA + iB * rtB * rtB;\n\n vcp.tangentMass = kTangent > 0.0 ? 1.0 / kTangent : 0.0;\n\n // Setup a velocity bias for restitution.\n vcp.velocityBias = 0.0;\n let vRel = 0;\n vRel += matrix.dotVec2(this.v_normal, vB);\n vRel += matrix.dotVec2(this.v_normal, matrix.crossNumVec2(temp, wB, vcp.rB));\n vRel -= matrix.dotVec2(this.v_normal, vA);\n vRel -= matrix.dotVec2(this.v_normal, matrix.crossNumVec2(temp, wA, vcp.rA));\n if (vRel < -Settings.velocityThreshold) {\n vcp.velocityBias = -this.v_restitution * vRel;\n }\n }\n\n // If we have two points, then prepare the block solver.\n if (this.v_pointCount == 2 && step.blockSolve) {\n const vcp1 = this.v_points[0]; // VelocityConstraintPoint\n const vcp2 = this.v_points[1]; // VelocityConstraintPoint\n\n const rn1A = matrix.crossVec2Vec2(vcp1.rA, this.v_normal);\n const rn1B = matrix.crossVec2Vec2(vcp1.rB, this.v_normal);\n const rn2A = matrix.crossVec2Vec2(vcp2.rA, this.v_normal);\n const rn2B = matrix.crossVec2Vec2(vcp2.rB, this.v_normal);\n\n const k11 = mA + mB + iA * rn1A * rn1A + iB * rn1B * rn1B;\n const k22 = mA + mB + iA * rn2A * rn2A + iB * rn2B * rn2B;\n const k12 = mA + mB + iA * rn1A * rn2A + iB * rn1B * rn2B;\n\n // Ensure a reasonable condition number.\n const k_maxConditionNumber = 1000.0;\n if (k11 * k11 < k_maxConditionNumber * (k11 * k22 - k12 * k12)) {\n // K is safe to invert.\n this.v_K.ex.setNum(k11, k12);\n this.v_K.ey.setNum(k12, k22);\n // this.v_normalMass.set(this.v_K.getInverse());\n const a = this.v_K.ex.x;\n const b = this.v_K.ey.x;\n const c = this.v_K.ex.y;\n const d = this.v_K.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n this.v_normalMass.ex.x = det * d;\n this.v_normalMass.ey.x = -det * b;\n this.v_normalMass.ex.y = -det * c;\n this.v_normalMass.ey.y = det * a;\n\n } else {\n // The constraints are redundant, just use one.\n // TODO_ERIN use deepest?\n this.v_pointCount = 1;\n }\n }\n\n matrix.copyVec2(positionA.c, cA);\n positionA.a = aA;\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n\n matrix.copyVec2(positionB.c, cB);\n positionB.a = aB;\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n warmStartConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const mA = this.v_invMassA;\n const iA = this.v_invIA;\n const mB = this.v_invMassB;\n const iB = this.v_invIB;\n\n matrix.copyVec2(vA, velocityA.v);\n let wA = velocityA.w;\n matrix.copyVec2(vB, velocityB.v);\n let wB = velocityB.w;\n\n matrix.copyVec2(normal, this.v_normal);\n matrix.crossVec2Num(tangent, normal, 1.0);\n\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n\n matrix.combine2Vec2(P, vcp.normalImpulse, normal, vcp.tangentImpulse, tangent);\n\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n matrix.minusScaleVec2(vA, mA, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n matrix.plusScaleVec2(vB, mB, P);\n }\n\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n storeConstraintImpulses(step: TimeStep): void {\n const manifold = this.m_manifold;\n for (let j = 0; j < this.v_pointCount; ++j) {\n manifold.points[j].normalImpulse = this.v_points[j].normalImpulse;\n manifold.points[j].tangentImpulse = this.v_points[j].tangentImpulse;\n }\n }\n\n solveVelocityConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const positionA = bodyA.c_position;\n\n const velocityB = bodyB.c_velocity;\n const positionB = bodyB.c_position;\n\n const mA = this.v_invMassA;\n const iA = this.v_invIA;\n const mB = this.v_invMassB;\n const iB = this.v_invIB;\n\n matrix.copyVec2(vA, velocityA.v);\n let wA = velocityA.w;\n matrix.copyVec2(vB, velocityB.v);\n let wB = velocityB.w;\n\n matrix.copyVec2(normal, this.v_normal);\n matrix.crossVec2Num(tangent, normal, 1.0);\n const friction = this.v_friction;\n\n if (_ASSERT) console.assert(this.v_pointCount == 1 || this.v_pointCount == 2);\n\n // Solve tangent constraints first because non-penetration is more important\n // than friction.\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n\n // Relative velocity at contact\n matrix.zeroVec2(dv);\n matrix.plusVec2(dv, vB);\n matrix.plusVec2(dv, matrix.crossNumVec2(temp, wB, vcp.rB));\n matrix.minusVec2(dv, vA);\n matrix.minusVec2(dv, matrix.crossNumVec2(temp, wA, vcp.rA));\n\n // Compute tangent force\n const vt = matrix.dotVec2(dv, tangent) - this.v_tangentSpeed;\n let lambda = vcp.tangentMass * (-vt);\n\n // Clamp the accumulated force\n const maxFriction = friction * vcp.normalImpulse;\n const newImpulse = clamp(vcp.tangentImpulse + lambda, -maxFriction, maxFriction);\n lambda = newImpulse - vcp.tangentImpulse;\n vcp.tangentImpulse = newImpulse;\n\n // Apply contact impulse\n matrix.scaleVec2(P, lambda, tangent);\n\n matrix.minusScaleVec2(vA, mA, P);\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n\n matrix.plusScaleVec2(vB, mB, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n }\n\n // Solve normal constraints\n if (this.v_pointCount == 1 || step.blockSolve == false) {\n for (let i = 0; i < this.v_pointCount; ++i) {\n const vcp = this.v_points[i]; // VelocityConstraintPoint\n\n // Relative velocity at contact\n matrix.zeroVec2(dv);\n matrix.plusVec2(dv, vB);\n matrix.plusVec2(dv, matrix.crossNumVec2(temp, wB, vcp.rB));\n matrix.minusVec2(dv, vA);\n matrix.minusVec2(dv, matrix.crossNumVec2(temp, wA, vcp.rA));\n\n // Compute normal impulse\n const vn = matrix.dotVec2(dv, normal);\n let lambda = -vcp.normalMass * (vn - vcp.velocityBias);\n\n // Clamp the accumulated impulse\n const newImpulse = math_max(vcp.normalImpulse + lambda, 0.0);\n lambda = newImpulse - vcp.normalImpulse;\n vcp.normalImpulse = newImpulse;\n\n // Apply contact impulse\n matrix.scaleVec2(P, lambda, normal);\n\n matrix.minusScaleVec2(vA, mA, P);\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n\n matrix.plusScaleVec2(vB, mB, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n }\n } else {\n // Block solver developed in collaboration with Dirk Gregorius (back in\n // 01/07 on Box2D_Lite).\n // Build the mini LCP for this contact patch\n //\n // vn = A * x + b, vn >= 0, x >= 0 and vn_i * x_i = 0 with i = 1..2\n //\n // A = J * W * JT and J = ( -n, -r1 x n, n, r2 x n )\n // b = vn0 - velocityBias\n //\n // The system is solved using the \"Total enumeration method\" (s. Murty).\n // The complementary constraint vn_i * x_i\n // implies that we must have in any solution either vn_i = 0 or x_i = 0.\n // So for the 2D contact problem the cases\n // vn1 = 0 and vn2 = 0, x1 = 0 and x2 = 0, x1 = 0 and vn2 = 0, x2 = 0 and\n // vn1 = 0 need to be tested. The first valid\n // solution that satisfies the problem is chosen.\n //\n // In order to account of the accumulated impulse 'a' (because of the\n // iterative nature of the solver which only requires\n // that the accumulated impulse is clamped and not the incremental\n // impulse) we change the impulse variable (x_i).\n //\n // Substitute:\n //\n // x = a + d\n //\n // a := old total impulse\n // x := new total impulse\n // d := incremental impulse\n //\n // For the current iteration we extend the formula for the incremental\n // impulse\n // to compute the new total impulse:\n //\n // vn = A * d + b\n // = A * (x - a) + b\n // = A * x + b - A * a\n // = A * x + b'\n // b' = b - A * a;\n\n const vcp1 = this.v_points[0]; // VelocityConstraintPoint\n const vcp2 = this.v_points[1]; // VelocityConstraintPoint\n\n matrix.setVec2(a, vcp1.normalImpulse, vcp2.normalImpulse);\n if (_ASSERT) console.assert(a.x >= 0.0 && a.y >= 0.0);\n\n // Relative velocity at contact\n // let dv1 = Vec2.zero().add(vB).add(Vec2.crossNumVec2(wB, vcp1.rB)).sub(vA).sub(Vec2.crossNumVec2(wA, vcp1.rA));\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n // let dv2 = Vec2.zero().add(vB).add(Vec2.crossNumVec2(wB, vcp2.rB)).sub(vA).sub(Vec2.crossNumVec2(wA, vcp2.rA));\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n let vn1 = matrix.dotVec2(dv1, normal);\n let vn2 = matrix.dotVec2(dv2, normal);\n\n matrix.setVec2(b, vn1 - vcp1.velocityBias, vn2 - vcp2.velocityBias);\n\n // Compute b'\n // b.sub(Mat22.mulVec2(this.v_K, a));\n b.x -= this.v_K.ex.x * a.x + this.v_K.ey.x * a.y;\n b.y -= this.v_K.ex.y * a.x + this.v_K.ey.y * a.y;\n\n const k_errorTol = 1e-3;\n // NOT_USED(k_errorTol);\n\n while (true) {\n //\n // Case 1: vn = 0\n //\n // 0 = A * x + b'\n //\n // Solve for x:\n //\n // x = - inv(A) * b'\n //\n // const x = Mat22.mulVec2(this.v_normalMass, b).neg();\n matrix.zeroVec2(x);\n x.x = -(this.v_normalMass.ex.x * b.x + this.v_normalMass.ey.x * b.y);\n x.y = -(this.v_normalMass.ex.y * b.x + this.v_normalMass.ey.y * b.y);\n\n if (x.x >= 0.0 && x.y >= 0.0) {\n // Get the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n vn1 = matrix.dotVec2(dv1, normal);\n vn2 = matrix.dotVec2(dv2, normal);\n\n if (_ASSERT) console.assert(math_abs(vn1 - vcp1.velocityBias) < k_errorTol);\n if (_ASSERT) console.assert(math_abs(vn2 - vcp2.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 2: vn1 = 0 and x2 = 0\n //\n // 0 = a11 * x1 + a12 * 0 + b1'\n // vn2 = a21 * x1 + a22 * 0 + b2'\n //\n x.x = -vcp1.normalMass * b.x;\n x.y = 0.0;\n vn1 = 0.0;\n vn2 = this.v_K.ex.y * x.x + b.y;\n\n if (x.x >= 0.0 && vn2 >= 0.0) {\n // Get the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n // Compute normal velocity\n vn1 = matrix.dotVec2(dv1, normal);\n\n if (_ASSERT) console.assert(math_abs(vn1 - vcp1.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 3: vn2 = 0 and x1 = 0\n //\n // vn1 = a11 * 0 + a12 * x2 + b1'\n // 0 = a21 * 0 + a22 * x2 + b2'\n //\n x.x = 0.0;\n x.y = -vcp2.normalMass * b.y;\n vn1 = this.v_K.ey.x * x.y + b.x;\n vn2 = 0.0;\n\n if (x.y >= 0.0 && vn1 >= 0.0) {\n // Resubstitute for the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n vn2 = matrix.dotVec2(dv2, normal);\n\n if (_ASSERT) console.assert(math_abs(vn2 - vcp2.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 4: x1 = 0 and x2 = 0\n //\n // vn1 = b1\n // vn2 = b2;\n //\n x.x = 0.0;\n x.y = 0.0;\n vn1 = b.x;\n vn2 = b.y;\n\n if (vn1 >= 0.0 && vn2 >= 0.0) {\n // Resubstitute for the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n break;\n }\n\n // No solution, give up. This is hit sometimes, but it doesn't seem to\n // matter.\n break;\n }\n }\n\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n /** @internal */\n static addType(type1: ShapeType, type2: ShapeType, callback: EvaluateFunction): void {\n s_registers[type1] = s_registers[type1] || {};\n s_registers[type1][type2] = callback;\n }\n\n /** @internal */\n static create(fixtureA: Fixture, indexA: number, fixtureB: Fixture, indexB: number): Contact | null {\n const typeA = fixtureA.m_shape.m_type;\n const typeB = fixtureB.m_shape.m_type;\n\n const contact = contactPool.allocate();\n let evaluateFcn;\n if (evaluateFcn = s_registers[typeA] && s_registers[typeA][typeB]) {\n contact.initialize(fixtureA, indexA, fixtureB, indexB, evaluateFcn);\n } else if (evaluateFcn = s_registers[typeB] && s_registers[typeB][typeA]) {\n contact.initialize(fixtureB, indexB, fixtureA, indexA, evaluateFcn);\n } else {\n return null;\n }\n\n // Contact creation may swap fixtures.\n fixtureA = contact.m_fixtureA;\n fixtureB = contact.m_fixtureB;\n indexA = contact.getChildIndexA();\n indexB = contact.getChildIndexB();\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n\n // Connect to body A\n contact.m_nodeA.contact = contact;\n contact.m_nodeA.other = bodyB;\n\n contact.m_nodeA.prev = null;\n contact.m_nodeA.next = bodyA.m_contactList;\n if (bodyA.m_contactList != null) {\n bodyA.m_contactList.prev = contact.m_nodeA;\n }\n bodyA.m_contactList = contact.m_nodeA;\n\n // Connect to body B\n contact.m_nodeB.contact = contact;\n contact.m_nodeB.other = bodyA;\n\n contact.m_nodeB.prev = null;\n contact.m_nodeB.next = bodyB.m_contactList;\n if (bodyB.m_contactList != null) {\n bodyB.m_contactList.prev = contact.m_nodeB;\n }\n bodyB.m_contactList = contact.m_nodeB;\n\n // Wake up the bodies\n if (fixtureA.isSensor() == false && fixtureB.isSensor() == false) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n\n return contact;\n }\n\n /** @internal */\n static destroy(contact: Contact, listener: { endContact: (contact: Contact) => void }): void {\n const fixtureA = contact.m_fixtureA;\n const fixtureB = contact.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n if (contact.isTouching()) {\n listener.endContact(contact);\n }\n\n // Remove from body 1\n if (contact.m_nodeA.prev) {\n contact.m_nodeA.prev.next = contact.m_nodeA.next;\n }\n\n if (contact.m_nodeA.next) {\n contact.m_nodeA.next.prev = contact.m_nodeA.prev;\n }\n\n if (contact.m_nodeA == bodyA.m_contactList) {\n bodyA.m_contactList = contact.m_nodeA.next;\n }\n\n // Remove from body 2\n if (contact.m_nodeB.prev) {\n contact.m_nodeB.prev.next = contact.m_nodeB.next;\n }\n\n if (contact.m_nodeB.next) {\n contact.m_nodeB.next.prev = contact.m_nodeB.prev;\n }\n\n if (contact.m_nodeB == bodyB.m_contactList) {\n bodyB.m_contactList = contact.m_nodeB.next;\n }\n\n if (contact.m_manifold.pointCount > 0 && !fixtureA.m_isSensor && !fixtureB.m_isSensor) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n\n // const typeA = fixtureA.getType();\n // const typeB = fixtureB.getType();\n\n // const destroyFcn = s_registers[typeA][typeB].destroyFcn;\n // if (typeof destroyFcn === 'function') {\n // destroyFcn(contact);\n // }\n\n contactPool.release(contact);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../util/options\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { BroadPhase } from \"../collision/BroadPhase\";\nimport { Solver, ContactImpulse, TimeStep } from \"./Solver\";\nimport { Body, BodyDef } from \"./Body\";\nimport { Joint } from \"./Joint\";\nimport { Contact } from \"./Contact\";\nimport { AABBValue, RayCastInput, RayCastOutput } from \"../collision/AABB\";\nimport { Fixture, FixtureProxy } from \"./Fixture\";\nimport { Manifold } from \"../collision/Manifold\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\nexport interface WorldDef {\n /** [default: { x : 0, y : 0}] */\n gravity?: Vec2Value;\n\n /** [default: true] */\n allowSleep?: boolean;\n\n /** [default: true] */\n warmStarting?: boolean;\n\n /** [default: true] */\n continuousPhysics?: boolean;\n\n /** [default: false] */\n subStepping?: boolean;\n\n /** [default: true] */\n blockSolve?: boolean;\n\n /** @internal [8] For the velocity constraint solver. */\n velocityIterations?: number;\n\n /** @internal [3] For the position constraint solver. */\n positionIterations?: number;\n}\n\n/** @internal */ const DEFAULTS: WorldDef = {\n gravity : Vec2.zero(),\n allowSleep : true,\n warmStarting : true,\n continuousPhysics : true,\n subStepping : false,\n blockSolve : true,\n velocityIterations : 8,\n positionIterations : 3\n};\n\n/**\n * Callback function for ray casts, see {@link World.rayCast}.\n *\n * Called for each fixture found in the query.\n * The returned value replaces the ray-cast input maxFraction.\n * You control how the ray cast proceeds by returning a numeric/float value.\n * \n * - `0` to terminate the ray cast\n * - `fraction` to clip the ray cast at current point\n * - `1` don't clip the ray and continue\n * - `-1` (or anything else) to continue\n *\n * @param fixture The fixture hit by the ray\n * @param point The point of initial intersection\n * @param normal The normal vector at the point of intersection\n * @param fraction The fraction along the ray at the point of intersection\n *\n * @returns A number to update the maxFraction\n */\nexport type WorldRayCastCallback = (fixture: Fixture, point: Vec2, normal: Vec2, fraction: number) => number;\n\n/**\n * Called for each fixture found in the query AABB. It may return `false` to terminate the query.\n */\nexport type WorldAABBQueryCallback = (fixture: Fixture) => boolean;\n\ndeclare module \"./World\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(deg: WorldDef): World;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(gravity: Vec2): World;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(): World;\n}\n\n/**\n * The `World` class contains the bodies and joints. It manages all aspects\n * of the simulation and allows for asynchronous queries (like AABB queries\n * and ray-casts). Much of your interactions with Planck.js will be with a\n * World object.\n */\n// @ts-expect-error\nexport class World {\n /** @internal */ m_solver: Solver;\n /** @internal */ m_broadPhase: BroadPhase;\n /** @internal */ m_contactList: Contact | null;\n /** @internal */ m_contactCount: number;\n /** @internal */ m_bodyList: Body | null;\n /** @internal */ m_bodyCount: number;\n /** @internal */ m_jointList: Joint | null;\n /** @internal */ m_jointCount: number;\n /** @internal */ m_stepComplete: boolean;\n /** @internal */ m_allowSleep: boolean;\n /** @internal */ m_gravity: Vec2;\n /** @internal */ m_clearForces: boolean;\n /** @internal */ m_newFixture: boolean;\n /** @internal */ m_locked: boolean;\n /** @internal */ m_warmStarting: boolean;\n /** @internal */ m_continuousPhysics: boolean;\n /** @internal */ m_subStepping: boolean;\n /** @internal */ m_blockSolve: boolean;\n /** @internal */ m_velocityIterations: number;\n /** @internal */ m_positionIterations: number;\n /** @internal */ m_t: number;\n\n /** @internal */ m_step_callback: ((world: World) => unknown)[];\n\n // TODO\n /** @internal */ _listeners: {\n [key: string]: any[]\n };\n\n /**\n * @param def World definition or gravity vector.\n */\n constructor(def?: WorldDef | Vec2Value) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof World)) {\n return new World(def);\n }\n\n this.s_step = new TimeStep();\n\n\n if (!def) {\n def = {};\n } else if (Vec2.isValid(def)) {\n def = { gravity: def as Vec2 };\n }\n\n def = options(def, DEFAULTS) as WorldDef;\n\n this.m_solver = new Solver(this);\n\n this.m_broadPhase = new BroadPhase();\n\n this.m_contactList = null;\n this.m_contactCount = 0;\n\n this.m_bodyList = null;\n this.m_bodyCount = 0;\n\n this.m_jointList = null;\n this.m_jointCount = 0;\n\n this.m_stepComplete = true;\n\n this.m_allowSleep = def.allowSleep;\n this.m_gravity = Vec2.clone(def.gravity);\n\n this.m_clearForces = true;\n this.m_newFixture = false;\n this.m_locked = false;\n\n // These are for debugging the solver.\n this.m_warmStarting = def.warmStarting;\n this.m_continuousPhysics = def.continuousPhysics;\n this.m_subStepping = def.subStepping;\n\n this.m_blockSolve = def.blockSolve;\n this.m_velocityIterations = def.velocityIterations;\n this.m_positionIterations = def.positionIterations;\n\n this.m_t = 0;\n\n this.m_step_callback = [];\n }\n\n /** @internal */\n _serialize(): object {\n const bodies = [];\n const joints = [];\n\n for (let b = this.getBodyList(); b; b = b.getNext()) {\n bodies.push(b);\n }\n\n for (let j = this.getJointList(); j; j = j.getNext()) {\n // @ts-ignore\n if (typeof j._serialize === \"function\") {\n joints.push(j);\n }\n }\n\n return {\n gravity: this.m_gravity,\n bodies,\n joints,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, context: any, restore: any): World {\n if (!data) {\n return new World();\n }\n\n const world = new World(data.gravity);\n\n if (data.bodies) {\n for (let i = data.bodies.length - 1; i >= 0; i -= 1) {\n world._addBody(restore(Body, data.bodies[i], world));\n }\n }\n\n if (data.joints) {\n for (let i = data.joints.length - 1; i >= 0; i--) {\n world.createJoint(restore(Joint, data.joints[i], world));\n }\n }\n\n return world;\n }\n\n /**\n * Get the world body list. With the returned body, use Body.getNext to get the\n * next body in the world list. A null body indicates the end of the list.\n *\n * @return the head of the world body list.\n */\n getBodyList(): Body | null {\n return this.m_bodyList;\n }\n\n /**\n * Get the world joint list. With the returned joint, use Joint.getNext to get\n * the next joint in the world list. A null joint indicates the end of the list.\n *\n * @return the head of the world joint list.\n */\n getJointList(): Joint | null {\n return this.m_jointList;\n }\n\n /**\n * Get the world contact list. With the returned contact, use Contact.getNext to\n * get the next contact in the world list. A null contact indicates the end of\n * the list.\n *\n * Warning: contacts are created and destroyed in the middle of a time step.\n * Use ContactListener to avoid missing contacts.\n *\n * @return the head of the world contact list.\n */\n getContactList(): Contact | null {\n return this.m_contactList;\n }\n\n getBodyCount(): number {\n return this.m_bodyCount;\n }\n\n getJointCount(): number {\n return this.m_jointCount;\n }\n\n /**\n * Get the number of contacts (each may have 0 or more contact points).\n */\n getContactCount(): number {\n return this.m_contactCount;\n }\n\n /**\n * Change the global gravity vector.\n */\n setGravity(gravity: Vec2Value): void {\n this.m_gravity.set(gravity);\n }\n\n /**\n * Get the global gravity vector.\n */\n getGravity(): Vec2 {\n return this.m_gravity;\n }\n\n /**\n * Is the world locked (in the middle of a time step).\n */\n isLocked(): boolean {\n return this.m_locked;\n }\n\n /**\n * Enable/disable sleep.\n */\n setAllowSleeping(flag: boolean): void {\n if (flag == this.m_allowSleep) {\n return;\n }\n\n this.m_allowSleep = flag;\n if (this.m_allowSleep == false) {\n for (let b = this.m_bodyList; b; b = b.m_next) {\n b.setAwake(true);\n }\n }\n }\n\n getAllowSleeping(): boolean {\n return this.m_allowSleep;\n }\n\n /**\n * Enable/disable warm starting. For testing.\n */\n setWarmStarting(flag: boolean): void {\n this.m_warmStarting = flag;\n }\n\n getWarmStarting(): boolean {\n return this.m_warmStarting;\n }\n\n /**\n * Enable/disable continuous physics. For testing.\n */\n setContinuousPhysics(flag: boolean): void {\n this.m_continuousPhysics = flag;\n }\n\n getContinuousPhysics(): boolean {\n return this.m_continuousPhysics;\n }\n\n /**\n * Enable/disable single stepped continuous physics. For testing.\n */\n setSubStepping(flag: boolean): void {\n this.m_subStepping = flag;\n }\n\n getSubStepping(): boolean {\n return this.m_subStepping;\n }\n\n /**\n * Set flag to control automatic clearing of forces after each time step.\n */\n setAutoClearForces(flag: boolean): void {\n this.m_clearForces = flag;\n }\n\n /**\n * Get the flag that controls automatic clearing of forces after each time step.\n */\n getAutoClearForces(): boolean {\n return this.m_clearForces;\n }\n\n /**\n * Manually clear the force buffer on all bodies. By default, forces are cleared\n * automatically after each call to step. The default behavior is modified by\n * calling setAutoClearForces. The purpose of this function is to support\n * sub-stepping. Sub-stepping is often used to maintain a fixed sized time step\n * under a variable frame-rate. When you perform sub-stepping you will disable\n * auto clearing of forces and instead call clearForces after all sub-steps are\n * complete in one pass of your game loop.\n *\n * See {@link World.setAutoClearForces}\n */\n clearForces(): void {\n for (let body = this.m_bodyList; body; body = body.getNext()) {\n body.m_force.setZero();\n body.m_torque = 0.0;\n }\n }\n\n /**\n * Query the world for all fixtures that potentially overlap the provided AABB.\n *\n * @param aabb The query box.\n * @param callback Called for each fixture found in the query AABB. It may return `false` to terminate the query.\n */\n queryAABB(aabb: AABBValue, callback: WorldAABBQueryCallback): void {\n if (_ASSERT) console.assert(typeof callback === \"function\");\n const broadPhase = this.m_broadPhase;\n this.m_broadPhase.query(aabb, function(proxyId: number): boolean { // TODO GC\n const proxy = broadPhase.getUserData(proxyId);\n return callback(proxy.fixture);\n });\n }\n\n /**\n * Ray-cast the world for all fixtures in the path of the ray. Your callback\n * controls whether you get the closest point, any point, or n-points. The\n * ray-cast ignores shapes that contain the starting point.\n *\n * @param point1 The ray starting point\n * @param point2 The ray ending point\n * @param callback A function that is called for each fixture that is hit by the ray. You control how the ray cast proceeds by returning a numeric/float value.\n */\n rayCast(point1: Vec2Value, point2: Vec2Value, callback: WorldRayCastCallback): void {\n if (_ASSERT) console.assert(typeof callback === \"function\");\n const broadPhase = this.m_broadPhase;\n\n this.m_broadPhase.rayCast({\n maxFraction : 1.0,\n p1 : point1,\n p2 : point2\n }, function(input: RayCastInput, proxyId: number): number { // TODO GC\n const proxy = broadPhase.getUserData(proxyId);\n const fixture = proxy.fixture;\n const index = proxy.childIndex;\n // @ts-ignore\n const output: RayCastOutput = {}; // TODO GC\n const hit = fixture.rayCast(output, input, index);\n if (hit) {\n const fraction = output.fraction;\n const point = Vec2.add(Vec2.mulNumVec2((1.0 - fraction), input.p1), Vec2.mulNumVec2(fraction, input.p2));\n return callback(fixture, point, output.normal, fraction);\n }\n return input.maxFraction;\n });\n }\n\n /**\n * Get the number of broad-phase proxies.\n */\n getProxyCount(): number {\n return this.m_broadPhase.getProxyCount();\n }\n\n /**\n * Get the height of broad-phase dynamic tree.\n */\n getTreeHeight(): number {\n return this.m_broadPhase.getTreeHeight();\n }\n\n /**\n * Get the balance of broad-phase dynamic tree.\n */\n getTreeBalance(): number {\n return this.m_broadPhase.getTreeBalance();\n }\n\n /**\n * Get the quality metric of broad-phase dynamic tree. The smaller the better.\n * The minimum is 1.\n */\n getTreeQuality(): number {\n return this.m_broadPhase.getTreeQuality();\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The body shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return;\n }\n\n for (let b = this.m_bodyList; b; b = b.m_next) {\n b.m_xf.p.sub(newOrigin);\n b.m_sweep.c0.sub(newOrigin);\n b.m_sweep.c.sub(newOrigin);\n }\n\n for (let j = this.m_jointList; j; j = j.m_next) {\n j.shiftOrigin(newOrigin);\n }\n\n this.m_broadPhase.shiftOrigin(newOrigin);\n }\n\n /** @internal Used for deserialize. */\n _addBody(body: Body): void {\n if (_ASSERT) console.assert(this.isLocked() === false);\n if (this.isLocked()) {\n return;\n }\n\n // Add to world doubly linked list.\n body.m_prev = null;\n body.m_next = this.m_bodyList;\n if (this.m_bodyList) {\n this.m_bodyList.m_prev = body;\n }\n this.m_bodyList = body;\n ++this.m_bodyCount;\n }\n\n /**\n * Create a rigid body given a definition. No reference to the definition is\n * retained.\n *\n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n createBody(def?: BodyDef): Body;\n createBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createBody(arg1?, arg2?) {\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return null;\n }\n\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n\n const body = new Body(this, def);\n this._addBody(body);\n return body;\n }\n\n createDynamicBody(def?: BodyDef): Body;\n createDynamicBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createDynamicBody(arg1?, arg2?) {\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n def.type = \"dynamic\";\n return this.createBody(def);\n }\n\n createKinematicBody(def?: BodyDef): Body;\n createKinematicBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createKinematicBody(arg1?, arg2?) {\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n def.type = \"kinematic\";\n return this.createBody(def);\n }\n\n /**\n * Destroy a body from the world.\n *\n * Warning: This automatically deletes all associated shapes and joints.\n *\n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n destroyBody(b: Body): boolean {\n if (_ASSERT) console.assert(this.m_bodyCount > 0);\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return;\n }\n\n if (b.m_destroyed) {\n return false;\n }\n\n // Delete the attached joints.\n let je = b.m_jointList;\n while (je) {\n const je0 = je;\n je = je.next;\n\n this.publish(\"remove-joint\", je0.joint);\n this.destroyJoint(je0.joint);\n\n b.m_jointList = je;\n }\n b.m_jointList = null;\n\n // Delete the attached contacts.\n let ce = b.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n\n this.destroyContact(ce0.contact);\n\n b.m_contactList = ce;\n }\n b.m_contactList = null;\n\n // Delete the attached fixtures. This destroys broad-phase proxies.\n let f = b.m_fixtureList;\n while (f) {\n const f0 = f;\n f = f.m_next;\n\n this.publish(\"remove-fixture\", f0);\n f0.destroyProxies(this.m_broadPhase);\n\n b.m_fixtureList = f;\n }\n b.m_fixtureList = null;\n\n // Remove world body list.\n if (b.m_prev) {\n b.m_prev.m_next = b.m_next;\n }\n\n if (b.m_next) {\n b.m_next.m_prev = b.m_prev;\n }\n\n if (b == this.m_bodyList) {\n this.m_bodyList = b.m_next;\n }\n\n b.m_destroyed = true;\n\n --this.m_bodyCount;\n\n this.publish(\"remove-body\", b);\n\n return true;\n }\n\n /**\n * Create a joint to constrain bodies together. No reference to the definition\n * is retained. This may cause the connected bodies to cease colliding.\n *\n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n createJoint(joint: T): T | null {\n if (_ASSERT) console.assert(!!joint.m_bodyA);\n if (_ASSERT) console.assert(!!joint.m_bodyB);\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return null;\n }\n\n // Connect to the world list.\n joint.m_prev = null;\n joint.m_next = this.m_jointList;\n if (this.m_jointList) {\n this.m_jointList.m_prev = joint;\n }\n this.m_jointList = joint;\n ++this.m_jointCount;\n\n // Connect to the bodies' doubly linked lists.\n joint.m_edgeA.joint = joint;\n joint.m_edgeA.other = joint.m_bodyB;\n joint.m_edgeA.prev = null;\n joint.m_edgeA.next = joint.m_bodyA.m_jointList;\n if (joint.m_bodyA.m_jointList)\n joint.m_bodyA.m_jointList.prev = joint.m_edgeA;\n joint.m_bodyA.m_jointList = joint.m_edgeA;\n\n joint.m_edgeB.joint = joint;\n joint.m_edgeB.other = joint.m_bodyA;\n joint.m_edgeB.prev = null;\n joint.m_edgeB.next = joint.m_bodyB.m_jointList;\n if (joint.m_bodyB.m_jointList)\n joint.m_bodyB.m_jointList.prev = joint.m_edgeB;\n joint.m_bodyB.m_jointList = joint.m_edgeB;\n\n // If the joint prevents collisions, then flag any contacts for filtering.\n if (joint.m_collideConnected == false) {\n for (let edge = joint.m_bodyB.getContactList(); edge; edge = edge.next) {\n if (edge.other == joint.m_bodyA) {\n // Flag the contact for filtering at the next time step (where either\n // body is awake).\n edge.contact.flagForFiltering();\n }\n }\n }\n\n // Note: creating a joint doesn't wake the bodies.\n\n return joint;\n }\n\n /**\n * Destroy a joint.\n * \n * Warning: This may cause the connected bodies to begin colliding.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n destroyJoint(joint: Joint): void {\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return;\n }\n\n // Remove from the doubly linked list.\n if (joint.m_prev) {\n joint.m_prev.m_next = joint.m_next;\n }\n\n if (joint.m_next) {\n joint.m_next.m_prev = joint.m_prev;\n }\n\n if (joint == this.m_jointList) {\n this.m_jointList = joint.m_next;\n }\n\n // Disconnect from bodies.\n const bodyA = joint.m_bodyA;\n const bodyB = joint.m_bodyB;\n\n // Wake up connected bodies.\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n\n // Remove from body 1.\n if (joint.m_edgeA.prev) {\n joint.m_edgeA.prev.next = joint.m_edgeA.next;\n }\n\n if (joint.m_edgeA.next) {\n joint.m_edgeA.next.prev = joint.m_edgeA.prev;\n }\n\n if (joint.m_edgeA == bodyA.m_jointList) {\n bodyA.m_jointList = joint.m_edgeA.next;\n }\n\n joint.m_edgeA.prev = null;\n joint.m_edgeA.next = null;\n\n // Remove from body 2\n if (joint.m_edgeB.prev) {\n joint.m_edgeB.prev.next = joint.m_edgeB.next;\n }\n\n if (joint.m_edgeB.next) {\n joint.m_edgeB.next.prev = joint.m_edgeB.prev;\n }\n\n if (joint.m_edgeB == bodyB.m_jointList) {\n bodyB.m_jointList = joint.m_edgeB.next;\n }\n\n joint.m_edgeB.prev = null;\n joint.m_edgeB.next = null;\n\n if (_ASSERT) console.assert(this.m_jointCount > 0);\n --this.m_jointCount;\n\n // If the joint prevents collisions, then flag any contacts for filtering.\n if (joint.m_collideConnected == false) {\n let edge = bodyB.getContactList();\n while (edge) {\n if (edge.other == bodyA) {\n // Flag the contact for filtering at the next time step (where either\n // body is awake).\n edge.contact.flagForFiltering();\n }\n\n edge = edge.next;\n }\n }\n\n this.publish(\"remove-joint\", joint);\n }\n\n /** @internal */\n s_step: TimeStep; // reuse\n\n /**\n * Take a time step. This performs collision detection, integration, and\n * constraint solution.\n *\n * Broad-phase, narrow-phase, solve and solve time of impacts.\n *\n * @param timeStep Time step, this should not vary.\n */\n step(timeStep: number, velocityIterations?: number, positionIterations?: number): void {\n this.publish(\"pre-step\", timeStep);\n\n if ((velocityIterations | 0) !== velocityIterations) {\n // TODO: remove this in future\n velocityIterations = 0;\n }\n\n velocityIterations = velocityIterations || this.m_velocityIterations;\n positionIterations = positionIterations || this.m_positionIterations;\n\n // If new fixtures were added, we need to find the new contacts.\n if (this.m_newFixture) {\n this.findNewContacts();\n this.m_newFixture = false;\n }\n\n this.m_locked = true;\n\n this.s_step.reset(timeStep);\n this.s_step.velocityIterations = velocityIterations;\n this.s_step.positionIterations = positionIterations;\n this.s_step.warmStarting = this.m_warmStarting;\n this.s_step.blockSolve = this.m_blockSolve;\n\n // Update contacts. This is where some contacts are destroyed.\n this.updateContacts();\n\n // Integrate velocities, solve velocity constraints, and integrate positions.\n if (this.m_stepComplete && timeStep > 0.0) {\n this.m_solver.solveWorld(this.s_step);\n\n // Synchronize fixtures, check for out of range bodies.\n for (let b = this.m_bodyList; b; b = b.getNext()) {\n // If a body was not in an island then it did not move.\n if (b.m_islandFlag == false) {\n continue;\n }\n\n if (b.isStatic()) {\n continue;\n }\n\n // Update fixtures (for broad-phase).\n b.synchronizeFixtures();\n }\n // Look for new contacts.\n this.findNewContacts();\n }\n\n // Handle TOI events.\n if (this.m_continuousPhysics && timeStep > 0.0) {\n this.m_solver.solveWorldTOI(this.s_step);\n }\n\n if (this.m_clearForces) {\n this.clearForces();\n }\n\n this.m_locked = false;\n\n let callback: (world: World) => unknown;\n while(callback = this.m_step_callback.shift()) {\n callback(this);\n }\n\n this.publish(\"post-step\", timeStep);\n }\n\n /**\n * Queue a function to be called after ongoing simulation step. If no simulation is in progress call it immediately.\n */\n queueUpdate(callback: (world: World) => unknown): void {\n if (!this.isLocked()) {\n callback(this);\n } else {\n this.m_step_callback.push(callback);\n }\n }\n\n /**\n * @internal\n * Call this method to find new contacts.\n */\n findNewContacts(): void {\n this.m_broadPhase.updatePairs(\n (proxyA: FixtureProxy, proxyB: FixtureProxy) => this.createContact(proxyA, proxyB)\n );\n }\n\n /**\n * @internal\n * Callback for broad-phase.\n */\n createContact(proxyA: FixtureProxy, proxyB: FixtureProxy): void {\n const fixtureA = proxyA.fixture;\n const fixtureB = proxyB.fixture;\n\n const indexA = proxyA.childIndex;\n const indexB = proxyB.childIndex;\n\n const bodyA = fixtureA.getBody();\n const bodyB = fixtureB.getBody();\n\n // Are the fixtures on the same body?\n if (bodyA == bodyB) {\n return;\n }\n\n // TODO_ERIN use a hash table to remove a potential bottleneck when both\n // bodies have a lot of contacts.\n // Does a contact already exist?\n let edge = bodyB.getContactList(); // ContactEdge\n while (edge) {\n if (edge.other == bodyA) {\n const fA = edge.contact.getFixtureA();\n const fB = edge.contact.getFixtureB();\n const iA = edge.contact.getChildIndexA();\n const iB = edge.contact.getChildIndexB();\n\n if (fA == fixtureA && fB == fixtureB && iA == indexA && iB == indexB) {\n // A contact already exists.\n return;\n }\n\n if (fA == fixtureB && fB == fixtureA && iA == indexB && iB == indexA) {\n // A contact already exists.\n return;\n }\n }\n\n edge = edge.next;\n }\n\n if (bodyB.shouldCollide(bodyA) == false) {\n return;\n }\n if (fixtureB.shouldCollide(fixtureA) == false) {\n return;\n }\n\n // Call the factory.\n const contact = Contact.create(fixtureA, indexA, fixtureB, indexB);\n if (contact == null) {\n return;\n }\n\n // Insert into the world.\n contact.m_prev = null;\n if (this.m_contactList != null) {\n contact.m_next = this.m_contactList;\n this.m_contactList.m_prev = contact;\n }\n this.m_contactList = contact;\n\n ++this.m_contactCount;\n }\n\n /**\n * @internal\n * Removes old non-overlapping contacts, applies filters and updates contacts.\n */\n updateContacts(): void {\n // Update awake contacts.\n let c: Contact;\n let next_c = this.m_contactList;\n while (c = next_c) {\n next_c = c.getNext();\n const fixtureA = c.getFixtureA();\n const fixtureB = c.getFixtureB();\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n const bodyA = fixtureA.getBody();\n const bodyB = fixtureB.getBody();\n\n // Is this contact flagged for filtering?\n if (c.m_filterFlag) {\n if (bodyB.shouldCollide(bodyA) == false) {\n this.destroyContact(c);\n continue;\n }\n\n if (fixtureB.shouldCollide(fixtureA) == false) {\n this.destroyContact(c);\n continue;\n }\n\n // Clear the filtering flag.\n c.m_filterFlag = false;\n }\n\n const activeA = bodyA.isAwake() && !bodyA.isStatic();\n const activeB = bodyB.isAwake() && !bodyB.isStatic();\n\n // At least one body must be awake and it must be dynamic or kinematic.\n if (activeA == false && activeB == false) {\n continue;\n }\n\n const proxyIdA = fixtureA.m_proxies[indexA].proxyId;\n const proxyIdB = fixtureB.m_proxies[indexB].proxyId;\n const overlap = this.m_broadPhase.testOverlap(proxyIdA, proxyIdB);\n\n // Here we destroy contacts that cease to overlap in the broad-phase.\n if (overlap == false) {\n this.destroyContact(c);\n continue;\n }\n\n // The contact persists.\n c.update(this);\n }\n }\n\n /** @internal */\n destroyContact(contact: Contact): void {\n // Remove from the world.\n if (contact.m_prev) {\n contact.m_prev.m_next = contact.m_next;\n }\n if (contact.m_next) {\n contact.m_next.m_prev = contact.m_prev;\n }\n if (contact == this.m_contactList) {\n this.m_contactList = contact.m_next;\n }\n\n Contact.destroy(contact, this);\n\n --this.m_contactCount;\n }\n\n\n /**\n * Called when two fixtures begin to touch.\n *\n * Implement contact callbacks to get contact information. You can use these\n * results for things like sounds and game logic. You can also get contact\n * results by traversing the contact lists after the time step. However, you\n * might miss some contacts because continuous physics leads to sub-stepping.\n * Additionally you may receive multiple callbacks for the same contact in a\n * single time step. You should strive to make your callbacks efficient because\n * there may be many callbacks per time step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"begin-contact\", listener: (contact: Contact) => void): World;\n /**\n * Called when two fixtures cease to touch.\n *\n * Implement contact callbacks to get contact information. You can use these\n * results for things like sounds and game logic. You can also get contact\n * results by traversing the contact lists after the time step. However, you\n * might miss some contacts because continuous physics leads to sub-stepping.\n * Additionally you may receive multiple callbacks for the same contact in a\n * single time step. You should strive to make your callbacks efficient because\n * there may be many callbacks per time step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"end-contact\", listener: (contact: Contact) => void): World;\n /**\n * This is called after a contact is updated. This allows you to inspect a\n * contact before it goes to the solver. If you are careful, you can modify the\n * contact manifold (e.g. disable contact). A copy of the old manifold is\n * provided so that you can detect changes. Note: this is called only for awake\n * bodies. Note: this is called even when the number of contact points is zero.\n * Note: this is not called for sensors. Note: if you set the number of contact\n * points to zero, you will not get an end-contact callback. However, you may get\n * a begin-contact callback the next step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"pre-solve\", listener: (contact: Contact, oldManifold: Manifold) => void): World;\n /**\n * This lets you inspect a contact after the solver is finished. This is useful\n * for inspecting impulses. Note: the contact manifold does not include time of\n * impact impulses, which can be arbitrarily large if the sub-step is small.\n * Hence the impulse is provided explicitly in a separate data structure. Note:\n * this is only called for contacts that are touching, solid, and awake.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"post-solve\", listener: (contact: Contact, impulse: ContactImpulse) => void): World;\n /** Listener is called whenever a body is removed. */\n on(name: \"remove-body\", listener: (body: Body) => void): World;\n /** Listener is called whenever a joint is removed implicitly or explicitly. */\n on(name: \"remove-joint\", listener: (joint: Joint) => void): World;\n /** Listener is called whenever a fixture is removed implicitly or explicitly. */\n on(name: \"remove-fixture\", listener: (fixture: Fixture) => void): World;\n /**\n * Register an event listener.\n */\n // tslint:disable-next-line:typedef\n on(name, listener) {\n if (typeof name !== \"string\" || typeof listener !== \"function\") {\n return this;\n }\n if (!this._listeners) {\n this._listeners = {};\n }\n if (!this._listeners[name]) {\n this._listeners[name] = [];\n }\n this._listeners[name].push(listener);\n return this;\n }\n\n off(name: \"begin-contact\", listener: (contact: Contact) => void): World;\n off(name: \"end-contact\", listener: (contact: Contact) => void): World;\n off(name: \"pre-solve\", listener: (contact: Contact, oldManifold: Manifold) => void): World;\n off(name: \"post-solve\", listener: (contact: Contact, impulse: ContactImpulse) => void): World;\n off(name: \"remove-body\", listener: (body: Body) => void): World;\n off(name: \"remove-joint\", listener: (joint: Joint) => void): World;\n off(name: \"remove-fixture\", listener: (fixture: Fixture) => void): World;\n /**\n * Remove an event listener.\n */\n // tslint:disable-next-line:typedef\n off(name, listener) {\n if (typeof name !== \"string\" || typeof listener !== \"function\") {\n return this;\n }\n const listeners = this._listeners && this._listeners[name];\n if (!listeners || !listeners.length) {\n return this;\n }\n const index = listeners.indexOf(listener);\n if (index >= 0) {\n listeners.splice(index, 1);\n }\n return this;\n }\n\n publish(name: string, arg1?: any, arg2?: any, arg3?: any): number {\n const listeners = this._listeners && this._listeners[name];\n if (!listeners || !listeners.length) {\n return 0;\n }\n for (let l = 0; l < listeners.length; l++) {\n listeners[l].call(this, arg1, arg2, arg3);\n }\n return listeners.length;\n }\n\n /** @internal */\n beginContact(contact: Contact): void {\n this.publish(\"begin-contact\", contact);\n }\n\n /** @internal */\n endContact(contact: Contact): void {\n this.publish(\"end-contact\", contact);\n }\n\n /** @internal */\n preSolve(contact: Contact, oldManifold: Manifold): void {\n this.publish(\"pre-solve\", contact, oldManifold);\n }\n\n /** @internal */\n postSolve(contact: Contact, impulse: ContactImpulse): void {\n this.publish(\"post-solve\", contact, impulse);\n }\n\n /**\n * Joints and fixtures are destroyed when their associated body is destroyed.\n * Register a destruction listener so that you may nullify references to these\n * joints and shapes.\n *\n * `function(object)` is called when any joint or fixture is about to\n * be destroyed due to the destruction of one of its attached or parent bodies.\n */\n\n /**\n * Register a contact filter to provide specific control over collision.\n * Otherwise the default filter is used (defaultFilter). The listener is owned\n * by you and must remain in scope.\n *\n * Moved to Fixture.\n */\n}","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/** 3D vector */\nexport interface Vec3Value {\n x: number;\n y: number;\n z: number;\n}\n\ndeclare module \"./Vec3\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(x: number, y: number, z: number): Vec3;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(obj: Vec3Value): Vec3;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(): Vec3;\n}\n\n/** 3D vector */\n// @ts-expect-error\nexport class Vec3 {\n x: number;\n y: number;\n z: number;\n\n constructor(x: number, y: number, z: number);\n constructor(obj: Vec3Value);\n constructor();\n constructor(x?, y?, z?) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Vec3)) {\n return new Vec3(x, y, z);\n }\n if (typeof x === \"undefined\") {\n this.x = 0;\n this.y = 0;\n this.z = 0;\n } else if (typeof x === \"object\") {\n this.x = x.x;\n this.y = x.y;\n this.z = x.z;\n } else {\n this.x = x;\n this.y = y;\n this.z = z;\n }\n if (_ASSERT) Vec3.assert(this);\n }\n\n /** @internal */\n _serialize(): object {\n return {\n x: this.x,\n y: this.y,\n z: this.z\n };\n }\n\n /** @internal */\n static _deserialize(data: any): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = data.x;\n obj.y = data.y;\n obj.z = data.z;\n return obj;\n }\n\n /** @hidden */\n static neo(x: number, y: number, z: number): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = x;\n obj.y = y;\n obj.z = z;\n return obj;\n }\n\n static zero(): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = 0;\n obj.y = 0;\n obj.z = 0;\n return obj;\n }\n\n static clone(v: Vec3Value): Vec3 {\n if (_ASSERT) Vec3.assert(v);\n return Vec3.neo(v.x, v.y, v.z);\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n /** Does this vector contain finite coordinates? */\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.x) && Number.isFinite(obj.y) && Number.isFinite(obj.z);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Vec3.isValid(o), \"Invalid Vec3!\", o);\n }\n\n setZero(): Vec3 {\n this.x = 0.0;\n this.y = 0.0;\n this.z = 0.0;\n return this;\n }\n\n set(x: number, y: number, z: number): Vec3 {\n this.x = x;\n this.y = y;\n this.z = z;\n return this;\n }\n\n add(w: Vec3Value): Vec3 {\n this.x += w.x;\n this.y += w.y;\n this.z += w.z;\n return this;\n }\n\n sub(w: Vec3Value): Vec3 {\n this.x -= w.x;\n this.y -= w.y;\n this.z -= w.z;\n return this;\n }\n\n mul(m: number): Vec3 {\n this.x *= m;\n this.y *= m;\n this.z *= m;\n return this;\n }\n\n static areEqual(v: Vec3Value, w: Vec3Value): boolean {\n if (_ASSERT) Vec3.assert(v);\n if (_ASSERT) Vec3.assert(w);\n return v === w ||\n typeof v === \"object\" && v !== null &&\n typeof w === \"object\" && w !== null &&\n v.x === w.x && v.y === w.y && v.z === w.z;\n }\n\n /** Dot product on two vectors */\n static dot(v: Vec3Value, w: Vec3Value): number {\n return v.x * w.x + v.y * w.y + v.z * w.z;\n }\n\n /** Cross product on two vectors */\n static cross(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(\n v.y * w.z - v.z * w.y,\n v.z * w.x - v.x * w.z,\n v.x * w.y - v.y * w.x\n );\n }\n\n static add(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(v.x + w.x, v.y + w.y, v.z + w.z);\n }\n\n static sub(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(v.x - w.x, v.y - w.y, v.z - w.z);\n }\n\n static mul(v: Vec3Value, m: number): Vec3 {\n return new Vec3(m * v.x, m * v.y, m * v.z);\n }\n\n neg(): Vec3 {\n this.x = -this.x;\n this.y = -this.y;\n this.z = -this.z;\n return this;\n }\n\n static neg(v: Vec3Value): Vec3 {\n return new Vec3(-v.x, -v.y, -v.z);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport * as matrix from \"../../common/Matrix\";\nimport { Shape } from \"../Shape\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { AABB, AABBValue, RayCastInput, RayCastOutput } from \"../AABB\";\nimport { MassData } from \"../../dynamics/Body\";\nimport { DistanceProxy } from \"../Distance\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const v2 = matrix.vec2(0, 0);\n\ndeclare module \"./EdgeShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function EdgeShape(v1?: Vec2Value, v2?: Vec2Value): EdgeShape;\n}\n\n/**\n * A line segment (edge) shape. These can be connected in chains or loops to\n * other edge shapes. The connectivity information is used to ensure correct\n * contact normals.\n */\n// @ts-expect-error\nexport class EdgeShape extends Shape {\n static TYPE = \"edge\" as const;\n /** @hidden */ m_type: \"edge\";\n\n /** @hidden */ m_radius: number;\n\n // These are the edge vertices\n /** @hidden */ m_vertex1: Vec2;\n /** @hidden */ m_vertex2: Vec2;\n\n // Optional adjacent vertices. These are used for smooth collision.\n // Used by chain shape.\n /** @hidden */ m_vertex0: Vec2;\n /** @hidden */ m_vertex3: Vec2;\n /** @hidden */ m_hasVertex0: boolean;\n /** @hidden */ m_hasVertex3: boolean;\n\n constructor(v1?: Vec2Value, v2?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof EdgeShape)) {\n return new EdgeShape(v1, v2);\n }\n\n super();\n\n this.m_type = EdgeShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n\n this.m_vertex1 = v1 ? Vec2.clone(v1) : Vec2.zero();\n this.m_vertex2 = v2 ? Vec2.clone(v2) : Vec2.zero();\n\n this.m_vertex0 = Vec2.zero();\n this.m_vertex3 = Vec2.zero();\n this.m_hasVertex0 = false;\n this.m_hasVertex3 = false;\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n vertex1: this.m_vertex1,\n vertex2: this.m_vertex2,\n\n vertex0: this.m_vertex0,\n vertex3: this.m_vertex3,\n hasVertex0: this.m_hasVertex0,\n hasVertex3: this.m_hasVertex3,\n };\n }\n\n /** @internal */\n static _deserialize(data: any): EdgeShape {\n const shape = new EdgeShape(data.vertex1, data.vertex2);\n if (shape.m_hasVertex0) {\n shape.setPrevVertex(data.vertex0);\n }\n if (shape.m_hasVertex3) {\n shape.setNextVertex(data.vertex3);\n }\n return shape;\n }\n\n /** @hidden */\n _reset(): void {\n // noop\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n getType(): \"edge\" {\n return this.m_type;\n }\n\n /** @internal @deprecated */\n setNext(v?: Vec2Value): EdgeShape {\n return this.setNextVertex(v);\n }\n\n /**\n * Optional next vertex, used for smooth collision.\n */\n setNextVertex(v?: Vec2Value): EdgeShape {\n if (v) {\n this.m_vertex3.setVec2(v);\n this.m_hasVertex3 = true;\n } else {\n this.m_vertex3.setZero();\n this.m_hasVertex3 = false;\n }\n return this;\n }\n\n /**\n * Optional next vertex, used for smooth collision.\n */\n getNextVertex(): Vec2 {\n return this.m_vertex3;\n }\n\n /** @internal @deprecated */\n setPrev(v?: Vec2Value): EdgeShape {\n return this.setPrevVertex(v);\n }\n\n /**\n * Optional prev vertex, used for smooth collision.\n */\n setPrevVertex(v?: Vec2Value): EdgeShape {\n if (v) {\n this.m_vertex0.setVec2(v);\n this.m_hasVertex0 = true;\n } else {\n this.m_vertex0.setZero();\n this.m_hasVertex0 = false;\n }\n return this;\n }\n\n /**\n * Optional prev vertex, used for smooth collision.\n */\n getPrevVertex(): Vec2 {\n return this.m_vertex0;\n }\n\n /**\n * Set this as an isolated edge.\n */\n _set(v1: Vec2Value, v2: Vec2Value): EdgeShape {\n this.m_vertex1.setVec2(v1);\n this.m_vertex2.setVec2(v2);\n this.m_hasVertex0 = false;\n this.m_hasVertex3 = false;\n return this;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): EdgeShape {\n const clone = new EdgeShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_vertex1.setVec2(this.m_vertex1);\n clone.m_vertex2.setVec2(this.m_vertex2);\n clone.m_vertex0.setVec2(this.m_vertex0);\n clone.m_vertex3.setVec2(this.m_vertex3);\n clone.m_hasVertex0 = this.m_hasVertex0;\n clone.m_hasVertex3 = this.m_hasVertex3;\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): false {\n return false;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n // p = p1 + t * d\n // v = v1 + s * e\n // p1 + t * d = v1 + s * e\n // s * e - t * d = p1 - v1\n\n // NOT_USED(childIndex);\n\n // Put the ray into the edge's frame of reference.\n const p1 = Rot.mulTVec2(xf.q, Vec2.sub(input.p1, xf.p));\n const p2 = Rot.mulTVec2(xf.q, Vec2.sub(input.p2, xf.p));\n const d = Vec2.sub(p2, p1);\n\n const v1 = this.m_vertex1;\n const v2 = this.m_vertex2;\n const e = Vec2.sub(v2, v1);\n const normal = Vec2.neo(e.y, -e.x);\n normal.normalize();\n\n // q = p1 + t * d\n // dot(normal, q - v1) = 0\n // dot(normal, p1 - v1) + t * dot(normal, d) = 0\n const numerator = Vec2.dot(normal, Vec2.sub(v1, p1));\n const denominator = Vec2.dot(normal, d);\n\n if (denominator == 0.0) {\n return false;\n }\n\n const t = numerator / denominator;\n if (t < 0.0 || input.maxFraction < t) {\n return false;\n }\n\n const q = Vec2.add(p1, Vec2.mulNumVec2(t, d));\n\n // q = v1 + s * r\n // s = dot(q - v1, r) / dot(r, r)\n const r = Vec2.sub(v2, v1);\n const rr = Vec2.dot(r, r);\n if (rr == 0.0) {\n return false;\n }\n\n const s = Vec2.dot(Vec2.sub(q, v1), r) / rr;\n if (s < 0.0 || 1.0 < s) {\n return false;\n }\n\n output.fraction = t;\n if (numerator > 0.0) {\n output.normal = Rot.mulVec2(xf.q, normal).neg();\n } else {\n output.normal = Rot.mulVec2(xf.q, normal);\n }\n return true;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n matrix.transformVec2(v1, xf, this.m_vertex1);\n matrix.transformVec2(v2, xf, this.m_vertex2);\n\n AABB.combinePoints(aabb, v1, v2);\n AABB.extend(aabb, this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density?: number): void {\n massData.mass = 0.0;\n matrix.combine2Vec2(massData.center, 0.5, this.m_vertex1, 0.5, this.m_vertex2);\n massData.I = 0.0;\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n proxy.m_vertices[0] = this.m_vertex1;\n proxy.m_vertices[1] = this.m_vertex2;\n proxy.m_vertices.length = 2;\n proxy.m_count = 2;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Edge = EdgeShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport type { MassData } from \"../../dynamics/Body\";\nimport { AABBValue, RayCastOutput, RayCastInput, AABB } from \"../AABB\";\nimport { DistanceProxy } from \"../Distance\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Shape } from \"../Shape\";\nimport { EdgeShape } from \"./EdgeShape\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const v2 = matrix.vec2(0, 0);\n\ndeclare module \"./ChainShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function ChainShape(vertices?: Vec2Value[], loop?: boolean): ChainShape;\n}\n\n/**\n * A chain shape is a free form sequence of line segments. The chain has\n * two-sided collision, so you can use inside and outside collision. Therefore,\n * you may use any winding order. Connectivity information is used to create\n * smooth collisions.\n *\n * WARNING: The chain will not collide properly if there are self-intersections.\n */\n// @ts-expect-error\nexport class ChainShape extends Shape {\n static TYPE = \"chain\" as const;\n /** @hidden */ m_type: \"chain\";\n\n /** @hidden */ m_radius: number;\n\n /** @hidden */ m_vertices: Vec2[];\n /** @hidden */ m_count: number;\n /** @hidden */ m_prevVertex: Vec2 | null;\n /** @hidden */ m_nextVertex: Vec2 | null;\n /** @hidden */ m_hasPrevVertex: boolean;\n /** @hidden */ m_hasNextVertex: boolean;\n\n /** @hidden */ m_isLoop: boolean;\n\n constructor(vertices?: Vec2Value[], loop?: boolean) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof ChainShape)) {\n return new ChainShape(vertices, loop);\n }\n\n super();\n\n this.m_type = ChainShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n this.m_vertices = [];\n this.m_count = 0;\n this.m_prevVertex = null;\n this.m_nextVertex = null;\n this.m_hasPrevVertex = false;\n this.m_hasNextVertex = false;\n\n this.m_isLoop = !!loop;\n\n if (vertices && vertices.length) {\n if (loop) {\n this._createLoop(vertices);\n } else {\n this._createChain(vertices);\n }\n }\n }\n\n /** @internal */\n _serialize(): object {\n const data = {\n type: this.m_type,\n vertices: this.m_isLoop ? this.m_vertices.slice(0, this.m_vertices.length - 1) : this.m_vertices,\n isLoop: this.m_isLoop,\n hasPrevVertex: this.m_hasPrevVertex,\n hasNextVertex: this.m_hasNextVertex,\n prevVertex: null as Vec2 | null,\n nextVertex: null as Vec2 | null,\n };\n if (this.m_prevVertex) {\n data.prevVertex = this.m_prevVertex;\n }\n if (this.m_nextVertex) {\n data.nextVertex = this.m_nextVertex;\n }\n return data;\n }\n\n /** @internal */\n static _deserialize(data: any, fixture: any, restore: any): ChainShape {\n const vertices: Vec2[] = [];\n if (data.vertices) {\n for (let i = 0; i < data.vertices.length; i++) {\n vertices.push(restore(Vec2, data.vertices[i]));\n }\n }\n const shape = new ChainShape(vertices, data.isLoop);\n if (data.prevVertex) {\n shape.setPrevVertex(data.prevVertex);\n }\n if (data.nextVertex) {\n shape.setNextVertex(data.nextVertex);\n }\n return shape;\n }\n\n // clear() {\n // this.m_vertices.length = 0;\n // this.m_count = 0;\n // }\n\n getType(): \"chain\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n /**\n * @internal\n * Create a loop. This automatically adjusts connectivity.\n *\n * @param vertices an array of vertices, these are copied\n */\n _createLoop(vertices: Vec2Value[]): ChainShape {\n if (_ASSERT) console.assert(this.m_vertices.length == 0 && this.m_count == 0);\n if (_ASSERT) console.assert(vertices.length >= 3);\n if (vertices.length < 3) {\n return;\n }\n\n for (let i = 1; i < vertices.length; ++i) {\n const v1 = vertices[i - 1];\n const v2 = vertices[i];\n // If the code crashes here, it means your vertices are too close together.\n if (_ASSERT) console.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);\n }\n\n this.m_vertices = [];\n this.m_count = vertices.length + 1;\n for (let i = 0; i < vertices.length; ++i) {\n this.m_vertices[i] = Vec2.clone(vertices[i]);\n }\n this.m_vertices[vertices.length] = Vec2.clone(vertices[0]);\n\n this.m_prevVertex = this.m_vertices[this.m_count - 2];\n this.m_nextVertex = this.m_vertices[1];\n this.m_hasPrevVertex = true;\n this.m_hasNextVertex = true;\n return this;\n }\n\n /**\n * @internal\n * Create a chain with isolated end vertices.\n *\n * @param vertices an array of vertices, these are copied\n */\n _createChain(vertices: Vec2Value[]): ChainShape {\n if (_ASSERT) console.assert(this.m_vertices.length == 0 && this.m_count == 0);\n if (_ASSERT) console.assert(vertices.length >= 2);\n for (let i = 1; i < vertices.length; ++i) {\n const v1 = vertices[i - 1];\n const v2 = vertices[i];\n // If the code crashes here, it means your vertices are too close together.\n if (_ASSERT) console.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);\n }\n\n this.m_vertices = [];\n this.m_count = vertices.length;\n for (let i = 0; i < vertices.length; ++i) {\n this.m_vertices[i] = Vec2.clone(vertices[i]);\n }\n\n this.m_prevVertex = null;\n this.m_nextVertex = null;\n this.m_hasPrevVertex = false;\n this.m_hasNextVertex = false;\n return this;\n }\n\n /** @hidden */\n _reset(): void {\n if (this.m_isLoop) {\n this._createLoop(this.m_vertices.slice(0, this.m_vertices.length - 1));\n } else {\n this._createChain(this.m_vertices);\n }\n }\n\n /**\n * Establish connectivity to a vertex that precedes the first vertex. Don't call\n * this for loops.\n */\n setPrevVertex(prevVertex: Vec2): void {\n // todo: copy or reference\n this.m_prevVertex = prevVertex;\n this.m_hasPrevVertex = true;\n }\n\n getPrevVertex(): Vec2 {\n return this.m_prevVertex;\n }\n\n /**\n * Establish connectivity to a vertex that follows the last vertex. Don't call\n * this for loops.\n */\n setNextVertex(nextVertex: Vec2): void {\n // todo: copy or reference\n this.m_nextVertex = nextVertex;\n this.m_hasNextVertex = true;\n }\n\n getNextVertex(): Vec2 {\n return this.m_nextVertex;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): ChainShape {\n const clone = new ChainShape();\n clone._createChain(this.m_vertices);\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_prevVertex = this.m_prevVertex;\n clone.m_nextVertex = this.m_nextVertex;\n clone.m_hasPrevVertex = this.m_hasPrevVertex;\n clone.m_hasNextVertex = this.m_hasNextVertex;\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): number {\n // edge count = vertex count - 1\n return this.m_count - 1;\n }\n\n // Get a child edge.\n getChildEdge(edge: EdgeShape, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count - 1);\n edge.m_type = EdgeShape.TYPE;\n edge.m_radius = this.m_radius;\n\n edge.m_vertex1 = this.m_vertices[childIndex];\n edge.m_vertex2 = this.m_vertices[childIndex + 1];\n\n if (childIndex > 0) {\n edge.m_vertex0 = this.m_vertices[childIndex - 1];\n edge.m_hasVertex0 = true;\n } else {\n edge.m_vertex0 = this.m_prevVertex;\n edge.m_hasVertex0 = this.m_hasPrevVertex;\n }\n\n if (childIndex < this.m_count - 2) {\n edge.m_vertex3 = this.m_vertices[childIndex + 2];\n edge.m_hasVertex3 = true;\n } else {\n edge.m_vertex3 = this.m_nextVertex;\n edge.m_hasVertex3 = this.m_hasNextVertex;\n }\n }\n\n getVertex(index: number): Vec2 {\n if (_ASSERT) console.assert(0 <= index && index <= this.m_count);\n if (index < this.m_count) {\n return this.m_vertices[index];\n } else {\n return this.m_vertices[0];\n }\n }\n\n isLoop(): boolean {\n return this.m_isLoop;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * This always return false.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): false {\n return false;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n\n const edgeShape = new EdgeShape(this.getVertex(childIndex), this.getVertex(childIndex + 1));\n return edgeShape.rayCast(output, input, xf, 0);\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n\n matrix.transformVec2(v1, xf, this.getVertex(childIndex));\n matrix.transformVec2(v2, xf, this.getVertex(childIndex + 1));\n\n AABB.combinePoints(aabb, v1, v2);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * Chains have zero mass.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density?: number): void {\n massData.mass = 0.0;\n matrix.zeroVec2(massData.center);\n massData.I = 0.0;\n }\n\n computeDistanceProxy(proxy: DistanceProxy, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n proxy.m_vertices[0] = this.getVertex(childIndex);\n proxy.m_vertices[1] = this.getVertex(childIndex + 1);\n proxy.m_count = 2;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Chain = ChainShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport type { MassData } from \"../../dynamics/Body\";\nimport { RayCastOutput, RayCastInput, AABBValue } from \"../AABB\";\nimport { DistanceProxy } from \"../Distance\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Shape } from \"../Shape\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const e = matrix.vec2(0, 0);\n/** @internal */ const e1 = matrix.vec2(0, 0);\n/** @internal */ const e2 = matrix.vec2(0, 0);\n/** @internal */ const center = matrix.vec2(0, 0);\n/** @internal */ const s = matrix.vec2(0, 0);\n\ndeclare module \"./PolygonShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PolygonShape(vertices?: Vec2Value[]): PolygonShape;\n}\n\n/**\n * A convex polygon. It is assumed that the interior of the polygon is to the\n * left of each edge. Polygons have a maximum number of vertices equal to\n * Settings.maxPolygonVertices. In most cases you should not need many vertices\n * for a convex polygon. extends Shape\n */\n// @ts-expect-error\nexport class PolygonShape extends Shape {\n static TYPE = \"polygon\" as const;\n /** @hidden */ m_type: \"polygon\";\n\n /** @hidden */ m_centroid: Vec2;\n /** @hidden */ m_vertices: Vec2[]; // [Settings.maxPolygonVertices]\n /** @hidden */ m_normals: Vec2[]; // [Settings.maxPolygonVertices]\n /** @hidden */ m_count: number;\n /** @hidden */ m_radius: number;\n\n constructor(vertices?: Vec2Value[]) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PolygonShape)) {\n return new PolygonShape(vertices);\n }\n\n super();\n\n this.m_type = PolygonShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n this.m_centroid = Vec2.zero();\n this.m_vertices = [];\n this.m_normals = [];\n this.m_count = 0;\n\n if (vertices && vertices.length) {\n this._set(vertices);\n }\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n vertices: this.m_vertices,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, fixture: any, restore: any): PolygonShape {\n const vertices: Vec2[] = [];\n if (data.vertices) {\n for (let i = 0; i < data.vertices.length; i++) {\n vertices.push(restore(Vec2, data.vertices[i]));\n }\n }\n\n const shape = new PolygonShape(vertices);\n return shape;\n }\n\n getType(): \"polygon\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): PolygonShape {\n const clone = new PolygonShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_count = this.m_count;\n clone.m_centroid.setVec2(this.m_centroid);\n for (let i = 0; i < this.m_count; i++) {\n clone.m_vertices.push(this.m_vertices[i].clone());\n }\n for (let i = 0; i < this.m_normals.length; i++) {\n clone.m_normals.push(this.m_normals[i].clone());\n }\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /** @hidden */\n _reset(): void {\n this._set(this.m_vertices);\n }\n\n /**\n * @internal\n *\n * Create a convex hull from the given array of local points. The count must be\n * in the range [3, Settings.maxPolygonVertices].\n *\n * Warning: the points may be re-ordered, even if they form a convex polygon\n * Warning: collinear points are handled but not removed. Collinear points may\n * lead to poor stacking behavior.\n */\n _set(vertices: Vec2Value[]): void {\n if (_ASSERT) console.assert(3 <= vertices.length && vertices.length <= Settings.maxPolygonVertices);\n if (vertices.length < 3) {\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n let n = math_min(vertices.length, Settings.maxPolygonVertices);\n\n // Perform welding and copy vertices into local buffer.\n const ps: Vec2[] = []; // [Settings.maxPolygonVertices];\n for (let i = 0; i < n; ++i) {\n const v = vertices[i];\n\n let unique = true;\n for (let j = 0; j < ps.length; ++j) {\n if (Vec2.distanceSquared(v, ps[j]) < 0.25 * Settings.linearSlopSquared) {\n unique = false;\n break;\n }\n }\n\n if (unique) {\n ps.push(Vec2.clone(v));\n }\n }\n\n n = ps.length;\n if (n < 3) {\n // Polygon is degenerate.\n if (_ASSERT) console.assert(false);\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n // Create the convex hull using the Gift wrapping algorithm\n // http://en.wikipedia.org/wiki/Gift_wrapping_algorithm\n\n // Find the right most point on the hull (in case of multiple points bottom most is used)\n let i0 = 0;\n let x0 = ps[0].x;\n for (let i = 1; i < n; ++i) {\n const x = ps[i].x;\n if (x > x0 || (x === x0 && ps[i].y < ps[i0].y)) {\n i0 = i;\n x0 = x;\n }\n }\n\n const hull = [] as number[]; // [Settings.maxPolygonVertices];\n let m = 0;\n let ih = i0;\n\n while (true) {\n if (_ASSERT) console.assert(m < Settings.maxPolygonVertices);\n hull[m] = ih;\n\n let ie = 0;\n for (let j = 1; j < n; ++j) {\n if (ie === ih) {\n ie = j;\n continue;\n }\n\n const r = Vec2.sub(ps[ie], ps[hull[m]]);\n const v = Vec2.sub(ps[j], ps[hull[m]]);\n const c = Vec2.crossVec2Vec2(r, v);\n // c < 0 means counter-clockwise wrapping, c > 0 means clockwise wrapping\n if (c < 0.0) {\n ie = j;\n }\n\n // Collinearity check\n if (c === 0.0 && v.lengthSquared() > r.lengthSquared()) {\n ie = j;\n }\n }\n\n ++m;\n ih = ie;\n\n if (ie === i0) {\n break;\n }\n }\n\n if (m < 3) {\n // Polygon is degenerate.\n if (_ASSERT) console.assert(false);\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n this.m_count = m;\n\n // Copy vertices.\n this.m_vertices = [];\n for (let i = 0; i < m; ++i) {\n this.m_vertices[i] = ps[hull[i]];\n }\n\n // Compute normals. Ensure the edges have non-zero length.\n for (let i = 0; i < m; ++i) {\n const i1 = i;\n const i2 = i + 1 < m ? i + 1 : 0;\n const edge = Vec2.sub(this.m_vertices[i2], this.m_vertices[i1]);\n if (_ASSERT) console.assert(edge.lengthSquared() > EPSILON * EPSILON);\n this.m_normals[i] = Vec2.crossVec2Num(edge, 1.0);\n this.m_normals[i].normalize();\n }\n\n // Compute the polygon centroid.\n this.m_centroid = computeCentroid(this.m_vertices, m);\n }\n\n /** @internal */ _setAsBox(hx: number, hy: number, center?: Vec2Value, angle?: number): void {\n // start with right-bottom, counter-clockwise, as in Gift wrapping algorithm in PolygonShape._set()\n this.m_vertices[0] = Vec2.neo(hx, -hy);\n this.m_vertices[1] = Vec2.neo(hx, hy);\n this.m_vertices[2] = Vec2.neo(-hx, hy);\n this.m_vertices[3] = Vec2.neo(-hx, -hy);\n\n this.m_normals[0] = Vec2.neo(1.0, 0.0);\n this.m_normals[1] = Vec2.neo(0.0, 1.0);\n this.m_normals[2] = Vec2.neo(-1.0, 0.0);\n this.m_normals[3] = Vec2.neo(0.0, -1.0);\n\n this.m_count = 4;\n\n if (center && Vec2.isValid(center)) {\n angle = angle || 0;\n\n matrix.copyVec2(this.m_centroid, center);\n\n const xf = Transform.identity();\n xf.p.setVec2(center);\n xf.q.setAngle(angle);\n\n // Transform vertices and normals.\n for (let i = 0; i < this.m_count; ++i) {\n this.m_vertices[i] = Transform.mulVec2(xf, this.m_vertices[i]);\n this.m_normals[i] = Rot.mulVec2(xf.q, this.m_normals[i]);\n }\n }\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): boolean {\n const pLocal = matrix.detransformVec2(temp, xf, p);\n\n for (let i = 0; i < this.m_count; ++i) {\n const dot = matrix.dotVec2(this.m_normals[i], pLocal) - matrix.dotVec2(this.m_normals[i], this.m_vertices[i]);\n if (dot > 0.0) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n\n // Put the ray into the polygon's frame of reference.\n const p1 = Rot.mulTVec2(xf.q, Vec2.sub(input.p1, xf.p));\n const p2 = Rot.mulTVec2(xf.q, Vec2.sub(input.p2, xf.p));\n const d = Vec2.sub(p2, p1);\n\n let lower = 0.0;\n let upper = input.maxFraction;\n\n let index = -1;\n\n for (let i = 0; i < this.m_count; ++i) {\n // p = p1 + a * d\n // dot(normal, p - v) = 0\n // dot(normal, p1 - v) + a * dot(normal, d) = 0\n const numerator = Vec2.dot(this.m_normals[i], Vec2.sub(this.m_vertices[i], p1));\n const denominator = Vec2.dot(this.m_normals[i], d);\n\n if (denominator == 0.0) {\n if (numerator < 0.0) {\n return false;\n }\n } else {\n // Note: we want this predicate without division:\n // lower < numerator / denominator, where denominator < 0\n // Since denominator < 0, we have to flip the inequality:\n // lower < numerator / denominator <==> denominator * lower > numerator.\n if (denominator < 0.0 && numerator < lower * denominator) {\n // Increase lower.\n // The segment enters this half-space.\n lower = numerator / denominator;\n index = i;\n } else if (denominator > 0.0 && numerator < upper * denominator) {\n // Decrease upper.\n // The segment exits this half-space.\n upper = numerator / denominator;\n }\n }\n\n // The use of epsilon here causes the assert on lower to trip\n // in some cases. Apparently the use of epsilon was to make edge\n // shapes work, but now those are handled separately.\n // if (upper < lower - matrix.EPSILON)\n if (upper < lower) {\n return false;\n }\n }\n\n if (_ASSERT) console.assert(0.0 <= lower && lower <= input.maxFraction);\n\n if (index >= 0) {\n output.fraction = lower;\n output.normal = Rot.mulVec2(xf.q, this.m_normals[index]);\n return true;\n }\n\n return false;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (let i = 0; i < this.m_count; ++i) {\n const v = matrix.transformVec2(temp, xf, this.m_vertices[i]);\n minX = math_min(minX, v.x);\n maxX = math_max(maxX, v.x);\n minY = math_min(minY, v.y);\n maxY = math_max(maxY, v.y);\n }\n\n matrix.setVec2(aabb.lowerBound, minX - this.m_radius, minY - this.m_radius);\n matrix.setVec2(aabb.upperBound, maxX + this.m_radius, maxY + this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density: number): void {\n // Polygon mass, centroid, and inertia.\n // Let rho be the polygon density in mass per unit area.\n // Then:\n // mass = rho * int(dA)\n // centroid.x = (1/mass) * rho * int(x * dA)\n // centroid.y = (1/mass) * rho * int(y * dA)\n // I = rho * int((x*x + y*y) * dA)\n //\n // We can compute these integrals by summing all the integrals\n // for each triangle of the polygon. To evaluate the integral\n // for a single triangle, we make a change of variables to\n // the (u,v) coordinates of the triangle:\n // x = x0 + e1x * u + e2x * v\n // y = y0 + e1y * u + e2y * v\n // where 0 <= u && 0 <= v && u + v <= 1.\n //\n // We integrate u from [0,1-v] and then v from [0,1].\n // We also need to use the Jacobian of the transformation:\n // D = cross(e1, e2)\n //\n // Simplification: triangle centroid = (1/3) * (p1 + p2 + p3)\n //\n // The rest of the derivation is handled by computer algebra.\n\n if (_ASSERT) console.assert(this.m_count >= 3);\n\n matrix.zeroVec2(center);\n let area = 0.0;\n let I = 0.0;\n\n // s is the reference point for forming triangles.\n // It's location doesn't change the result (except for rounding error).\n matrix.zeroVec2(s);\n\n // This code would put the reference point inside the polygon.\n for (let i = 0; i < this.m_count; ++i) {\n matrix.plusVec2(s, this.m_vertices[i]);\n }\n matrix.scaleVec2(s, 1.0 / this.m_count, s);\n\n const k_inv3 = 1.0 / 3.0;\n\n for (let i = 0; i < this.m_count; ++i) {\n // Triangle vertices.\n matrix.subVec2(e1, this.m_vertices[i], s);\n if ( i + 1 < this.m_count) {\n matrix.subVec2(e2, this.m_vertices[i + 1], s);\n } else {\n matrix.subVec2(e2, this.m_vertices[0], s);\n }\n\n const D = matrix.crossVec2Vec2(e1, e2);\n\n const triangleArea = 0.5 * D;\n area += triangleArea;\n\n // Area weighted centroid\n matrix.combine2Vec2(temp, triangleArea * k_inv3, e1, triangleArea * k_inv3, e2);\n matrix.plusVec2(center, temp);\n\n const ex1 = e1.x;\n const ey1 = e1.y;\n const ex2 = e2.x;\n const ey2 = e2.y;\n\n const intx2 = ex1 * ex1 + ex2 * ex1 + ex2 * ex2;\n const inty2 = ey1 * ey1 + ey2 * ey1 + ey2 * ey2;\n\n I += (0.25 * k_inv3 * D) * (intx2 + inty2);\n }\n\n // Total mass\n massData.mass = density * area;\n\n // Center of mass\n if (_ASSERT) console.assert(area > EPSILON);\n matrix.scaleVec2(center, 1.0 / area, center);\n matrix.addVec2(massData.center, center, s);\n\n // Inertia tensor relative to the local origin (point s).\n massData.I = density * I;\n\n // Shift to center of mass then to original body origin.\n massData.I += massData.mass * (matrix.dotVec2(massData.center, massData.center) - matrix.dotVec2(center, center));\n }\n\n /**\n * Validate convexity. This is a very time consuming operation.\n * @returns true if valid\n */\n validate(): boolean {\n for (let i = 0; i < this.m_count; ++i) {\n const i1 = i;\n const i2 = i < this.m_count - 1 ? i1 + 1 : 0;\n const p = this.m_vertices[i1];\n matrix.subVec2(e, this.m_vertices[i2], p);\n\n for (let j = 0; j < this.m_count; ++j) {\n if (j == i1 || j == i2) {\n continue;\n }\n\n const c = matrix.crossVec2Vec2(e, matrix.subVec2(temp, this.m_vertices[j], p));\n if (c < 0.0) {\n return false;\n }\n }\n }\n\n return true;\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n for (let i = 0; i < this.m_count; ++i) {\n proxy.m_vertices[i] = this.m_vertices[i];\n }\n proxy.m_vertices.length = this.m_count;\n proxy.m_count = this.m_count;\n proxy.m_radius = this.m_radius;\n }\n}\n\n/** @internal */ function computeCentroid(vs: Vec2[], count: number): Vec2 {\n if (_ASSERT) console.assert(count >= 3);\n\n const c = Vec2.zero();\n let area = 0.0;\n\n // pRef is the reference point for forming triangles.\n // It's location doesn't change the result (except for rounding error).\n const pRef = Vec2.zero();\n if (false) {\n // This code would put the reference point inside the polygon.\n for (let i = 0; i < count; ++i) {\n pRef.add(vs[i]);\n }\n pRef.mul(1.0 / count);\n }\n\n const inv3 = 1.0 / 3.0;\n\n for (let i = 0; i < count; ++i) {\n // Triangle vertices.\n const p1 = pRef;\n const p2 = vs[i];\n const p3 = i + 1 < count ? vs[i + 1] : vs[0];\n\n const e1 = Vec2.sub(p2, p1);\n const e2 = Vec2.sub(p3, p1);\n\n const D = Vec2.crossVec2Vec2(e1, e2);\n\n const triangleArea = 0.5 * D;\n area += triangleArea;\n\n // Area weighted centroid\n matrix.combine3Vec2(temp, 1, p1, 1, p2, 1, p3);\n matrix.plusScaleVec2(c, triangleArea * inv3, temp);\n }\n\n // Centroid\n if (_ASSERT) console.assert(area > EPSILON);\n c.mul(1.0 / area);\n return c;\n}\n\nexport const Polygon = PolygonShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Shape } from \"../Shape\";\nimport { AABBValue, RayCastInput, RayCastOutput } from \"../AABB\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { MassData } from \"../../dynamics/Body\";\nimport { DistanceProxy } from \"../Distance\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_PI = Math.PI;\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n\ndeclare module \"./CircleShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function CircleShape(position: Vec2Value, radius?: number): CircleShape;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function CircleShape(radius?: number): CircleShape;\n}\n\n/** Circle shape. */\n// @ts-expect-error\nexport class CircleShape extends Shape {\n static TYPE = \"circle\" as const;\n /** @hidden */ m_type: \"circle\";\n\n /** @hidden */ m_p: Vec2;\n /** @hidden */ m_radius: number;\n\n constructor(position: Vec2Value, radius?: number);\n constructor(radius?: number);\n constructor(a: any, b?: any) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof CircleShape)) {\n return new CircleShape(a, b);\n }\n\n super();\n\n this.m_type = CircleShape.TYPE;\n this.m_p = Vec2.zero();\n this.m_radius = 1;\n\n if (typeof a === \"object\" && Vec2.isValid(a)) {\n this.m_p.setVec2(a);\n\n if (typeof b === \"number\") {\n this.m_radius = b;\n }\n\n } else if (typeof a === \"number\") {\n this.m_radius = a;\n }\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n p: this.m_p,\n radius: this.m_radius,\n };\n }\n\n /** @internal */\n static _deserialize(data: any): CircleShape {\n return new CircleShape(data.p, data.radius);\n }\n\n /** @hidden */\n _reset(): void {\n // noop\n }\n\n getType(): \"circle\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n getCenter(): Vec2 {\n return this.m_p;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): CircleShape {\n const clone = new CircleShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_p = this.m_p.clone();\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): boolean {\n const center = matrix.transformVec2(temp, xf, this.m_p);\n return matrix.distSqrVec2(p, center) <= this.m_radius * this.m_radius;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n // Collision Detection in Interactive 3D Environments by Gino van den Bergen\n // From Section 3.1.2\n // x = s + a * r\n // norm(x) = radius\n\n const position = Vec2.add(xf.p, Rot.mulVec2(xf.q, this.m_p));\n const s = Vec2.sub(input.p1, position);\n const b = Vec2.dot(s, s) - this.m_radius * this.m_radius;\n\n // Solve quadratic equation.\n const r = Vec2.sub(input.p2, input.p1);\n const c = Vec2.dot(s, r);\n const rr = Vec2.dot(r, r);\n const sigma = c * c - rr * b;\n\n // Check for negative discriminant and short segment.\n if (sigma < 0.0 || rr < EPSILON) {\n return false;\n }\n\n // Find the point of intersection of the line with the circle.\n let a = -(c + math_sqrt(sigma));\n\n // Is the intersection point on the segment?\n if (0.0 <= a && a <= input.maxFraction * rr) {\n a /= rr;\n output.fraction = a;\n output.normal = Vec2.add(s, Vec2.mulNumVec2(a, r));\n output.normal.normalize();\n return true;\n }\n\n return false;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n const p = matrix.transformVec2(temp, xf, this.m_p);\n\n matrix.setVec2(aabb.lowerBound, p.x - this.m_radius, p.y - this.m_radius);\n matrix.setVec2(aabb.upperBound, p.x + this.m_radius, p.y + this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density: number): void {\n massData.mass = density * math_PI * this.m_radius * this.m_radius;\n matrix.copyVec2(massData.center, this.m_p);\n // inertia about the local origin\n massData.I = massData.mass * (0.5 * this.m_radius * this.m_radius + matrix.lengthSqrVec2(this.m_p));\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n proxy.m_vertices[0] = this.m_p;\n proxy.m_vertices.length = 1;\n proxy.m_count = 1;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Circle = CircleShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Distance joint definition. This requires defining an anchor point on both\n * bodies and the non-zero length of the distance joint. The definition uses\n * local anchor points so that the initial configuration can violate the\n * constraint slightly. This helps when saving and loading a game. Warning: Do\n * not use a zero or short length.\n */\nexport interface DistanceJointOpt extends JointOpt {\n /**\n * The mass-spring-damper frequency in Hertz. A value of 0 disables softness.\n */\n frequencyHz?: number;\n /**\n * The damping ratio. 0 = no damping, 1 = critical damping.\n */\n dampingRatio?: number;\n /**\n * Distance length.\n */\n length?: number;\n}\n/**\n * Distance joint definition. This requires defining an anchor point on both\n * bodies and the non-zero length of the distance joint. The definition uses\n * local anchor points so that the initial configuration can violate the\n * constraint slightly. This helps when saving and loading a game. Warning: Do\n * not use a zero or short length.\n */\nexport interface DistanceJointDef extends JointDef, DistanceJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n frequencyHz : 0.0,\n dampingRatio : 0.0\n};\n\ndeclare module \"./DistanceJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function DistanceJoint(def: DistanceJointDef): DistanceJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function DistanceJoint(def: DistanceJointOpt, bodyA: Body, bodyB: Body, anchorA: Vec2Value, anchorB: Vec2Value): DistanceJoint;\n}\n\n/**\n * A distance joint constrains two points on two bodies to remain at a fixed\n * distance from each other. You can view this as a massless, rigid rod.\n */\n// @ts-expect-error\nexport class DistanceJoint extends Joint {\n static TYPE = \"distance-joint\" as const;\n\n // Solver shared\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_length: number;\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_gamma: number;\n /** @internal */ m_bias: number;\n\n // Solver temp\n /** @internal */ m_u: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: number;\n\n /**\n * @param def DistanceJoint definition.\n */\n constructor(def: DistanceJointDef);\n /**\n * @param anchorA Anchor A in global coordination.\n * @param anchorB Anchor B in global coordination.\n */\n constructor(def: DistanceJointOpt, bodyA: Body, bodyB: Body, anchorA?: Vec2Value, anchorB?: Vec2Value);\n constructor(def: DistanceJointDef, bodyA?: Body, bodyB?: Body, anchorA?: Vec2Value, anchorB?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof DistanceJoint)) {\n return new DistanceJoint(def, bodyA, bodyB, anchorA, anchorB);\n }\n\n // order of constructor arguments is changed in v0.2\n if (bodyB && anchorA && (\"m_type\" in anchorA) && (\"x\" in bodyB) && (\"y\" in bodyB)) {\n const temp = bodyB;\n bodyB = anchorA as any as Body;\n anchorA = temp as any as Vec2;\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = DistanceJoint.TYPE;\n\n // Solver shared\n this.m_localAnchorA = Vec2.clone(anchorA ? bodyA.getLocalPoint(anchorA) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchorB ? bodyB.getLocalPoint(anchorB) : def.localAnchorB || Vec2.zero());\n this.m_length = Number.isFinite(def.length) ? def.length :\n Vec2.distance(bodyA.getWorldPoint(this.m_localAnchorA), bodyB.getWorldPoint(this.m_localAnchorB));\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n this.m_impulse = 0.0;\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n\n // 1-D constrained system\n // m (v2 - v1) = lambda\n // v2 + (beta/h) * x1 + gamma * lambda = 0, gamma has units of inverse mass.\n // x2 = x1 + h * v2\n\n // 1-D mass-damper-spring system\n // m (v2 - v1) + h * d * v2 + h * k *\n\n // C = norm(p2 - p1) - L\n // u = (p2 - p1) / norm(p2 - p1)\n // Cdot = dot(u, v2 + cross(w2, r2) - v1 - cross(w1, r1))\n // J = [-u -cross(r1, u) u cross(r2, u)]\n // K = J * invM * JT\n // = invMass1 + invI1 * cross(r1, u)^2 + invMass2 + invI2 * cross(r2, u)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n length: this.m_length,\n\n impulse: this.m_impulse,\n gamma: this.m_gamma,\n bias: this.m_bias,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): DistanceJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new DistanceJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n\n if (def.length > 0) {\n this.m_length = +def.length;\n } else if (def.length < 0) { // don't change length\n } else if (def.anchorA || def.anchorA || def.anchorA || def.anchorA) {\n this.m_length = Vec2.distance(\n this.m_bodyA.getWorldPoint(this.m_localAnchorA),\n this.m_bodyB.getWorldPoint(this.m_localAnchorB)\n );\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the natural length. Manipulating the length can lead to non-physical\n * behavior when the frequency is zero.\n */\n setLength(length: number): void {\n this.m_length = length;\n }\n\n /**\n * Get the natural length.\n */\n getLength(): number {\n return this.m_length;\n }\n\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_u).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n this.m_u = Vec2.sub(Vec2.add(cB, this.m_rB), Vec2.add(cA, this.m_rA));\n\n // Handle singularity.\n const length = this.m_u.length();\n if (length > Settings.linearSlop) {\n this.m_u.mul(1.0 / length);\n } else {\n this.m_u.setNum(0.0, 0.0);\n }\n\n const crAu = Vec2.crossVec2Vec2(this.m_rA, this.m_u);\n const crBu = Vec2.crossVec2Vec2(this.m_rB, this.m_u);\n let invMass = this.m_invMassA + this.m_invIA * crAu * crAu + this.m_invMassB + this.m_invIB * crBu * crBu;\n\n // Compute the effective mass matrix.\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n\n if (this.m_frequencyHz > 0.0) {\n const C = length - this.m_length;\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * this.m_mass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = this.m_mass * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (d + h * k);\n this.m_gamma = this.m_gamma != 0.0 ? 1.0 / this.m_gamma : 0.0;\n this.m_bias = C * h * k * this.m_gamma;\n\n invMass += this.m_gamma;\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n } else {\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n }\n\n if (step.warmStarting) {\n // Scale the impulse to support a variable time step.\n this.m_impulse *= step.dtRatio;\n\n const P = Vec2.mulNumVec2(this.m_impulse, this.m_u);\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Cdot = dot(u, v + cross(w, r))\n const vpA = Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA));\n const vpB = Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB));\n const Cdot = Vec2.dot(this.m_u, vpB) - Vec2.dot(this.m_u, vpA);\n\n const impulse = -this.m_mass * (Cdot + this.m_bias + this.m_gamma * this.m_impulse);\n this.m_impulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_u);\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n if (this.m_frequencyHz > 0.0) {\n // There is no position correction for soft distance constraints.\n return true;\n }\n\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n const u = Vec2.sub(Vec2.add(cB, rB), Vec2.add(cA, rA));\n\n const length = u.normalize();\n const C = clamp(length - this.m_length, -Settings.maxLinearCorrection, Settings.maxLinearCorrection);\n\n const impulse = -this.m_mass * C;\n const P = Vec2.mulNumVec2(impulse, u);\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * Vec2.crossVec2Vec2(rA, P);\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, P);\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return math_abs(C) < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Friction joint definition.\n */\nexport interface FrictionJointOpt extends JointOpt {\n /**\n * The maximum friction force in N.\n */\n maxForce?: number;\n /**\n * The maximum friction torque in N-m.\n */\n maxTorque?: number;\n}\n\n/**\n * Friction joint definition.\n */\nexport interface FrictionJointDef extends JointDef, FrictionJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 0.0,\n maxTorque : 0.0,\n};\n\ndeclare module \"./FrictionJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function FrictionJoint(def: FrictionJointDef): FrictionJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function FrictionJoint(def: FrictionJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): FrictionJoint;\n}\n\n/**\n * Friction joint. This is used for top-down friction. It provides 2D\n * translational friction and angular friction.\n */\n// @ts-expect-error\nexport class FrictionJoint extends Joint {\n static TYPE = \"friction-joint\" as const;\n\n /** @internal */ m_type: \"friction-joint\";\n\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n\n // Solver shared\n /** @internal */ m_linearImpulse: Vec2;\n /** @internal */ m_angularImpulse: number;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_maxTorque: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_linearMass: Mat22;\n /** @internal */ m_angularMass: number;\n\n constructor(def: FrictionJointDef);\n /**\n * @param anchor Anchor in global coordination.\n */\n constructor(def: FrictionJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: FrictionJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof FrictionJoint)) {\n return new FrictionJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = FrictionJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n\n // Solver shared\n this.m_linearImpulse = Vec2.zero();\n this.m_angularImpulse = 0.0;\n this.m_maxForce = def.maxForce;\n this.m_maxTorque = def.maxTorque;\n\n // Point-to-point constraint\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Angle constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n maxForce: this.m_maxForce,\n maxTorque: this.m_maxTorque,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): FrictionJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new FrictionJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.maxTorque)) {\n this.m_maxTorque = def.maxTorque;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the maximum friction force in N.\n */\n setMaxForce(force: number): void {\n if (_ASSERT) console.assert(Number.isFinite(force) && force >= 0.0);\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum friction force in N.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the maximum friction torque in N*m.\n */\n setMaxTorque(torque: number): void {\n if (_ASSERT) console.assert(Number.isFinite(torque) && torque >= 0.0);\n this.m_maxTorque = torque;\n }\n\n /**\n * Get the maximum friction torque in N*m.\n */\n getMaxTorque(): number {\n return this.m_maxTorque;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_linearImpulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_angularImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective mass matrix.\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat22();\n K.ex.x = mA + mB + iA * this.m_rA.y * this.m_rA.y + iB * this.m_rB.y\n * this.m_rB.y;\n K.ex.y = -iA * this.m_rA.x * this.m_rA.y - iB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * this.m_rA.x * this.m_rA.x + iB * this.m_rB.x\n * this.m_rB.x;\n\n this.m_linearMass = K.getInverse();\n\n this.m_angularMass = iA + iB;\n if (this.m_angularMass > 0.0) {\n this.m_angularMass = 1.0 / this.m_angularMass;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_linearImpulse.mul(step.dtRatio);\n this.m_angularImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_linearImpulse.x, this.m_linearImpulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_angularImpulse);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_angularImpulse);\n\n } else {\n this.m_linearImpulse.setZero();\n this.m_angularImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const h = step.dt;\n\n // Solve angular friction\n {\n const Cdot = wB - wA;\n let impulse = -this.m_angularMass * Cdot;\n\n const oldImpulse = this.m_angularImpulse;\n const maxImpulse = h * this.m_maxTorque;\n this.m_angularImpulse = clamp(this.m_angularImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_angularImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve linear friction\n {\n const Cdot = Vec2.sub(\n Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB)),\n Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA))\n );\n\n let impulse = Vec2.neg(Mat22.mulVec2(this.m_linearMass, Cdot));\n const oldImpulse = this.m_linearImpulse;\n this.m_linearImpulse.add(impulse);\n\n const maxImpulse = h * this.m_maxForce;\n\n if (this.m_linearImpulse.lengthSquared() > maxImpulse * maxImpulse) {\n this.m_linearImpulse.normalize();\n this.m_linearImpulse.mul(maxImpulse);\n }\n\n impulse = Vec2.sub(this.m_linearImpulse, oldImpulse);\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { Vec3, Vec3Value } from \"./Vec3\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A 3-by-3 matrix. Stored in column-major order.\n */\nexport class Mat33 {\n ex: Vec3;\n ey: Vec3;\n ez: Vec3;\n\n constructor(a: Vec3Value, b: Vec3Value, c: Vec3Value);\n constructor();\n constructor(a?: Vec3Value, b?: Vec3Value, c?: Vec3Value) {\n if (typeof a === \"object\" && a !== null) {\n this.ex = Vec3.clone(a);\n this.ey = Vec3.clone(b);\n this.ez = Vec3.clone(c);\n } else {\n this.ex = Vec3.zero();\n this.ey = Vec3.zero();\n this.ez = Vec3.zero();\n }\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec3.isValid(obj.ex) && Vec3.isValid(obj.ey) && Vec3.isValid(obj.ez);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Mat33.isValid(o), \"Invalid Mat33!\", o);\n }\n\n /**\n * Set this matrix to all zeros.\n */\n setZero(): Mat33 {\n this.ex.setZero();\n this.ey.setZero();\n this.ez.setZero();\n return this;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases.\n */\n solve33(v: Vec3Value): Vec3 {\n // let det = matrix.dotVec3(this.ex, matrix.newCrossVec3(this.ey, this.ez));\n let cross_x = this.ey.y * this.ez.z - this.ey.z * this.ez.y;\n let cross_y = this.ey.z * this.ez.x - this.ey.x * this.ez.z;\n let cross_z = this.ey.x * this.ez.y - this.ey.y * this.ez.x;\n let det = this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const r = new Vec3();\n // r.x = det * matrix.dotVec3(v, matrix.newCrossVec3(this.ey, this.ez));\n cross_x = this.ey.y * this.ez.z - this.ey.z * this.ez.y;\n cross_y = this.ey.z * this.ez.x - this.ey.x * this.ez.z;\n cross_z = this.ey.x * this.ez.y - this.ey.y * this.ez.x;\n r.x = det * (v.x * cross_x + v.y * cross_y + v.z * cross_z);\n\n // r.y = det * matrix.dotVec3(this.ex, matrix.newCrossVec3(v, this.ez));\n cross_x = v.y * this.ez.z - v.z * this.ez.y;\n cross_y = v.z * this.ez.x - v.x * this.ez.z;\n cross_z = v.x * this.ez.y - v.y * this.ez.x;\n r.y = det * (this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z);\n\n // r.z = det * matrix.dotVec3(this.ex, matrix.newCrossVec3(this.ey, v));\n cross_x = this.ey.y * v.z - this.ey.z * v.y;\n cross_y = this.ey.z * v.x - this.ey.x * v.z;\n cross_z = this.ey.x * v.y - this.ey.y * v.x;\n r.z = det * (this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z);\n return r;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases. Solve only the upper 2-by-2 matrix\n * equation.\n */\n solve22(v: Vec2Value): Vec2 {\n const a11 = this.ex.x;\n const a12 = this.ey.x;\n const a21 = this.ex.y;\n const a22 = this.ey.y;\n let det = a11 * a22 - a12 * a21;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const r = Vec2.zero();\n r.x = det * (a22 * v.x - a12 * v.y);\n r.y = det * (a11 * v.y - a21 * v.x);\n return r;\n }\n\n /**\n * Get the inverse of this matrix as a 2-by-2. Returns the zero matrix if\n * singular.\n */\n getInverse22(M: Mat33): void {\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n M.ex.x = det * d;\n M.ey.x = -det * b;\n M.ex.z = 0.0;\n M.ex.y = -det * c;\n M.ey.y = det * a;\n M.ey.z = 0.0;\n M.ez.x = 0.0;\n M.ez.y = 0.0;\n M.ez.z = 0.0;\n }\n\n /**\n * Get the symmetric inverse of this matrix as a 3-by-3. Returns the zero matrix\n * if singular.\n */\n getSymInverse33(M: Mat33): void {\n let det = Vec3.dot(this.ex, Vec3.cross(this.ey, this.ez));\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const a11 = this.ex.x;\n const a12 = this.ey.x;\n const a13 = this.ez.x;\n const a22 = this.ey.y;\n const a23 = this.ez.y;\n const a33 = this.ez.z;\n\n M.ex.x = det * (a22 * a33 - a23 * a23);\n M.ex.y = det * (a13 * a23 - a12 * a33);\n M.ex.z = det * (a12 * a23 - a13 * a22);\n\n M.ey.x = M.ex.y;\n M.ey.y = det * (a11 * a33 - a13 * a13);\n M.ey.z = det * (a13 * a12 - a11 * a23);\n\n M.ez.x = M.ex.z;\n M.ez.y = M.ey.z;\n M.ez.z = det * (a11 * a22 - a12 * a12);\n }\n\n /**\n * Multiply a matrix times a vector.\n */\n static mul(a: Mat33, b: Vec2Value): Vec2;\n static mul(a: Mat33, b: Vec3Value): Vec3;\n static mul(a, b) {\n if (_ASSERT) Mat33.assert(a);\n if (b && \"z\" in b && \"y\" in b && \"x\" in b) {\n if (_ASSERT) Vec3.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y + a.ez.x * b.z;\n const y = a.ex.y * b.x + a.ey.y * b.y + a.ez.y * b.z;\n const z = a.ex.z * b.x + a.ey.z * b.y + a.ez.z * b.z;\n return new Vec3(x, y, z);\n\n } else if (b && \"y\" in b && \"x\" in b) {\n if (_ASSERT) Vec2.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y;\n const y = a.ex.y * b.x + a.ey.y * b.y;\n return Vec2.neo(x, y);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulVec3(a: Mat33, b: Vec3Value): Vec3 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Vec3.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y + a.ez.x * b.z;\n const y = a.ex.y * b.x + a.ey.y * b.y + a.ez.y * b.z;\n const z = a.ex.z * b.x + a.ey.z * b.y + a.ez.z * b.z;\n return new Vec3(x, y, z);\n }\n\n static mulVec2(a: Mat33, b: Vec2Value): Vec2 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y;\n const y = a.ex.y * b.x + a.ey.y * b.y;\n return Vec2.neo(x, y);\n }\n\n static add(a: Mat33, b: Mat33): Mat33 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Mat33.assert(b);\n return new Mat33(\n Vec3.add(a.ex, b.ex),\n Vec3.add(a.ey, b.ey),\n Vec3.add(a.ez, b.ez)\n );\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n\n\n// todo: use string?\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3,\n} \n\n/**\n * Revolute joint definition. This requires defining an anchor point where the\n * bodies are joined. The definition uses local anchor points so that the\n * initial configuration can violate the constraint slightly. You also need to\n * specify the initial relative angle for joint limits. This helps when saving\n * and loading a game.\n *\n * The local anchor points are measured from the body's origin rather than the\n * center of mass because: 1. you might not know where the center of mass will\n * be. 2. if you add/remove shapes from a body and recompute the mass, the\n * joints will be broken.\n */\nexport interface RevoluteJointOpt extends JointOpt {\n /**\n * The lower angle for the joint limit (radians).\n */\n lowerAngle?: number;\n /**\n * The upper angle for the joint limit (radians).\n */\n upperAngle?: number;\n /**\n * The maximum motor torque used to achieve the desired motor speed. Usually\n * in N-m.\n */\n maxMotorTorque?: number;\n /**\n * The desired motor speed. Usually in radians per second.\n */\n motorSpeed?: number;\n /**\n * A flag to enable joint limits.\n */\n enableLimit?: boolean;\n /**\n * A flag to enable the joint motor.\n */\n enableMotor?: boolean;\n}\n\n/**\n * Revolute joint definition. This requires defining an anchor point where the\n * bodies are joined. The definition uses local anchor points so that the\n * initial configuration can violate the constraint slightly. You also need to\n * specify the initial relative angle for joint limits. This helps when saving\n * and loading a game.\n *\n * The local anchor points are measured from the body's origin rather than the\n * center of mass because: 1. you might not know where the center of mass will\n * be. 2. if you add/remove shapes from a body and recompute the mass, the\n * joints will be broken.\n */\nexport interface RevoluteJointDef extends JointDef, RevoluteJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The bodyB angle minus bodyA angle in the reference state (radians).\n */\n referenceAngle?: number;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n lowerAngle : 0.0,\n upperAngle : 0.0,\n maxMotorTorque : 0.0,\n motorSpeed : 0.0,\n enableLimit : false,\n enableMotor : false\n};\n\ndeclare module \"./RevoluteJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RevoluteJoint(def: RevoluteJointDef): RevoluteJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RevoluteJoint(def: RevoluteJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): RevoluteJoint;\n}\n\n/**\n * A revolute joint constrains two bodies to share a common point while they are\n * free to rotate about the point. The relative rotation about the shared point\n * is the joint angle. You can limit the relative rotation with a joint limit\n * that specifies a lower and upper angle. You can use a motor to drive the\n * relative rotation about the shared point. A maximum motor torque is provided\n * so that infinite forces are not generated.\n */\n// @ts-expect-error\nexport class RevoluteJoint extends Joint {\n static TYPE = \"revolute-joint\" as const;\n\n /** @internal */ m_type: \"revolute-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngle: number;\n /** @internal */ m_impulse: Vec3;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_lowerAngle: number;\n /** @internal */ m_upperAngle: number;\n /** @internal */ m_maxMotorTorque: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableLimit: boolean;\n /** @internal */ m_enableMotor: boolean;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n // effective mass for point-to-point constraint.\n /** @internal */ m_mass: Mat33;\n // effective mass for motor/limit angular constraint.\n /** @internal */ m_motorMass: number;\n /** @internal */ m_limitState: number;\n\n constructor(def: RevoluteJointDef);\n constructor(def: RevoluteJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: RevoluteJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof RevoluteJoint)) {\n return new RevoluteJoint(def, bodyA, bodyB, anchor);\n }\n\n def = def ?? {} as RevoluteJointDef;\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_mass = new Mat33();\n this.m_limitState = LimitState.inactiveLimit;\n\n this.m_type = RevoluteJoint.TYPE;\n\n if (Vec2.isValid(anchor)) {\n this.m_localAnchorA = bodyA.getLocalPoint(anchor);\n } else if (Vec2.isValid(def.localAnchorA)) {\n this.m_localAnchorA = Vec2.clone(def.localAnchorA);\n } else {\n this.m_localAnchorA = Vec2.zero();\n }\n\n if (Vec2.isValid(anchor)) {\n this.m_localAnchorB = bodyB.getLocalPoint(anchor);\n } else if (Vec2.isValid(def.localAnchorB)) {\n this.m_localAnchorB = Vec2.clone(def.localAnchorB);\n } else {\n this.m_localAnchorB = Vec2.zero();\n }\n\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n } else {\n this.m_referenceAngle = bodyB.getAngle() - bodyA.getAngle();\n }\n\n this.m_impulse = new Vec3();\n this.m_motorImpulse = 0.0;\n\n this.m_lowerAngle = def.lowerAngle ?? DEFAULTS.lowerAngle;\n this.m_upperAngle = def.upperAngle ?? DEFAULTS.upperAngle;\n this.m_maxMotorTorque = def.maxMotorTorque ?? DEFAULTS.maxMotorTorque;\n this.m_motorSpeed = def.motorSpeed ?? DEFAULTS.motorSpeed;\n this.m_enableLimit = def.enableLimit ?? DEFAULTS.enableLimit;\n this.m_enableMotor = def.enableMotor ?? DEFAULTS.enableMotor;\n\n // Point-to-point constraint\n // C = p2 - p1\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Motor constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n lowerAngle: this.m_lowerAngle,\n upperAngle: this.m_upperAngle,\n maxMotorTorque: this.m_maxMotorTorque,\n motorSpeed: this.m_motorSpeed,\n enableLimit: this.m_enableLimit,\n enableMotor: this.m_enableMotor,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any):RevoluteJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new RevoluteJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n }\n if (def.enableLimit !== undefined) {\n this.m_enableLimit = def.enableLimit;\n }\n if (Number.isFinite(def.lowerAngle)) {\n this.m_lowerAngle = def.lowerAngle;\n }\n if (Number.isFinite(def.upperAngle)) {\n this.m_upperAngle = def.upperAngle;\n }\n if (Number.isFinite(def.maxMotorTorque)) {\n this.m_maxMotorTorque = def.maxMotorTorque;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n if (def.enableMotor !== undefined) {\n this.m_enableMotor = def.enableMotor;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Get the current joint angle in radians.\n */\n getJointAngle(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n return bB.m_sweep.a - bA.m_sweep.a - this.m_referenceAngle;\n }\n\n /**\n * Get the current joint angle speed in radians per second.\n */\n getJointSpeed(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n return bB.m_angularVelocity - bA.m_angularVelocity;\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Get the current motor torque given the inverse time step. Unit is N*m.\n */\n getMotorTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Set the motor speed in radians per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Get the motor speed in radians per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Set the maximum motor torque, usually in N-m.\n */\n setMaxMotorTorque(torque: number): void {\n if (torque == this.m_maxMotorTorque) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorTorque = torque;\n }\n\n getMaxMotorTorque(): number {\n return this.m_maxMotorTorque;\n }\n\n /**\n * Is the joint limit enabled?\n */\n isLimitEnabled(): boolean {\n return this.m_enableLimit;\n }\n\n /**\n * Enable/disable the joint limit.\n */\n enableLimit(flag: boolean): void {\n if (flag != this.m_enableLimit) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableLimit = flag;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Get the lower joint limit in radians.\n */\n getLowerLimit(): number {\n return this.m_lowerAngle;\n }\n\n /**\n * Get the upper joint limit in radians.\n */\n getUpperLimit(): number {\n return this.m_upperAngle;\n }\n\n /**\n * Set the joint limits in radians.\n */\n setLimits(lower: number, upper: number): void {\n if (_ASSERT) console.assert(lower <= upper);\n\n if (lower != this.m_lowerAngle || upper != this.m_upperAngle) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_impulse.z = 0.0;\n this.m_lowerAngle = lower;\n this.m_upperAngle = upper;\n }\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force given the inverse time step. Unit is N.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.neo(this.m_impulse.x, this.m_impulse.y).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque due to the joint limit given the inverse time step.\n * Unit is N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.z;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const fixedRotation = (iA + iB === 0.0);\n\n this.m_mass.ex.x = mA + mB + this.m_rA.y * this.m_rA.y * iA + this.m_rB.y * this.m_rB.y * iB;\n this.m_mass.ey.x = -this.m_rA.y * this.m_rA.x * iA - this.m_rB.y * this.m_rB.x * iB;\n this.m_mass.ez.x = -this.m_rA.y * iA - this.m_rB.y * iB;\n this.m_mass.ex.y = this.m_mass.ey.x;\n this.m_mass.ey.y = mA + mB + this.m_rA.x * this.m_rA.x * iA + this.m_rB.x * this.m_rB.x * iB;\n this.m_mass.ez.y = this.m_rA.x * iA + this.m_rB.x * iB;\n this.m_mass.ex.z = this.m_mass.ez.x;\n this.m_mass.ey.z = this.m_mass.ez.y;\n this.m_mass.ez.z = iA + iB;\n\n this.m_motorMass = iA + iB;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n\n if (this.m_enableMotor == false || fixedRotation) {\n this.m_motorImpulse = 0.0;\n }\n\n if (this.m_enableLimit && fixedRotation == false) {\n const jointAngle = aB - aA - this.m_referenceAngle;\n\n if (math_abs(this.m_upperAngle - this.m_lowerAngle) < 2.0 * Settings.angularSlop) {\n this.m_limitState = LimitState.equalLimits;\n\n } else if (jointAngle <= this.m_lowerAngle) {\n if (this.m_limitState != LimitState.atLowerLimit) {\n this.m_impulse.z = 0.0;\n }\n this.m_limitState = LimitState.atLowerLimit;\n\n } else if (jointAngle >= this.m_upperAngle) {\n if (this.m_limitState != LimitState.atUpperLimit) {\n this.m_impulse.z = 0.0;\n }\n this.m_limitState = LimitState.atUpperLimit;\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_impulse.mul(step.dtRatio);\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_impulse.x, this.m_impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_motorImpulse + this.m_impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_motorImpulse + this.m_impulse.z);\n\n } else {\n this.m_impulse.setZero();\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const fixedRotation = (iA + iB === 0.0);\n\n // Solve motor constraint.\n if (this.m_enableMotor && this.m_limitState != LimitState.equalLimits && fixedRotation == false) {\n const Cdot = wB - wA - this.m_motorSpeed;\n let impulse = -this.m_motorMass * Cdot;\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorTorque;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve limit constraint.\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit && fixedRotation == false) {\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const Cdot2 = wB - wA;\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const impulse = Vec3.neg(this.m_mass.solve33(Cdot));\n\n if (this.m_limitState == LimitState.equalLimits) {\n this.m_impulse.add(impulse);\n\n } else if (this.m_limitState == LimitState.atLowerLimit) {\n const newImpulse = this.m_impulse.z + impulse.z;\n\n if (newImpulse < 0.0) {\n const rhs = Vec2.combine(-1, Cdot1, this.m_impulse.z, Vec2.neo(this.m_mass.ez.x, this.m_mass.ez.y));\n const reduced = this.m_mass.solve22(rhs);\n impulse.x = reduced.x;\n impulse.y = reduced.y;\n impulse.z = -this.m_impulse.z;\n this.m_impulse.x += reduced.x;\n this.m_impulse.y += reduced.y;\n this.m_impulse.z = 0.0;\n\n } else {\n this.m_impulse.add(impulse);\n }\n\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n const newImpulse = this.m_impulse.z + impulse.z;\n\n if (newImpulse > 0.0) {\n const rhs = Vec2.combine(-1, Cdot1, this.m_impulse.z, Vec2.neo(this.m_mass.ez.x, this.m_mass.ez.y));\n const reduced = this.m_mass.solve22(rhs);\n impulse.x = reduced.x;\n impulse.y = reduced.y;\n impulse.z = -this.m_impulse.z;\n this.m_impulse.x += reduced.x;\n this.m_impulse.y += reduced.y;\n this.m_impulse.z = 0.0;\n\n } else {\n this.m_impulse.add(impulse);\n }\n }\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + impulse.z);\n\n } else {\n // Solve point-to-point constraint\n const Cdot = Vec2.zero();\n Cdot.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const impulse = this.m_mass.solve22(Vec2.neg(Cdot));\n\n this.m_impulse.x += impulse.x;\n this.m_impulse.y += impulse.y;\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n let angularError = 0.0;\n let positionError = 0.0;\n\n const fixedRotation = (this.m_invIA + this.m_invIB == 0.0);\n\n // Solve angular limit constraint.\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit && fixedRotation == false) {\n const angle = aB - aA - this.m_referenceAngle;\n let limitImpulse = 0.0;\n\n if (this.m_limitState == LimitState.equalLimits) {\n // Prevent large angular corrections\n const C = clamp(angle - this.m_lowerAngle, -Settings.maxAngularCorrection, Settings.maxAngularCorrection);\n limitImpulse = -this.m_motorMass * C;\n angularError = math_abs(C);\n\n } else if (this.m_limitState == LimitState.atLowerLimit) {\n let C = angle - this.m_lowerAngle;\n angularError = -C;\n\n // Prevent large angular corrections and allow some slop.\n C = clamp(C + Settings.angularSlop, -Settings.maxAngularCorrection, 0.0);\n limitImpulse = -this.m_motorMass * C;\n\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n let C = angle - this.m_upperAngle;\n angularError = C;\n\n // Prevent large angular corrections and allow some slop.\n C = clamp(C - Settings.angularSlop, 0.0, Settings.maxAngularCorrection);\n limitImpulse = -this.m_motorMass * C;\n }\n\n aA -= this.m_invIA * limitImpulse;\n aB += this.m_invIB * limitImpulse;\n }\n\n // Solve point-to-point constraint.\n {\n qA.setAngle(aA);\n qB.setAngle(aB);\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n const C = Vec2.zero();\n C.addCombine(1, cB, 1, rB);\n C.subCombine(1, cA, 1, rA);\n positionError = C.length();\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat22();\n K.ex.x = mA + mB + iA * rA.y * rA.y + iB * rB.y * rB.y;\n K.ex.y = -iA * rA.x * rA.y - iB * rB.x * rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * rA.x * rA.x + iB * rB.x * rB.x;\n\n const impulse = Vec2.neg(K.solve(C));\n\n cA.subMul(mA, impulse);\n aA -= iA * Vec2.crossVec2Vec2(rA, impulse);\n\n cB.addMul(mB, impulse);\n aB += iB * Vec2.crossVec2Vec2(rB, impulse);\n }\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return positionError <= Settings.linearSlop && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3, \n}\n\n/**\n * Prismatic joint definition. This requires defining a line of motion using an\n * axis and an anchor point. The definition uses local anchor points and a local\n * axis so that the initial configuration can violate the constraint slightly.\n * The joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface PrismaticJointOpt extends JointOpt {\n /**\n * Enable/disable the joint limit.\n */\n enableLimit?: boolean;\n /**\n * The lower translation limit, usually in meters.\n */\n lowerTranslation?: number;\n /**\n * The upper translation limit, usually in meters.\n */\n upperTranslation?: number;\n /**\n * Enable/disable the joint motor.\n */\n enableMotor?: boolean;\n /**\n * The maximum motor torque, usually in N-m.\n */\n maxMotorForce?: number;\n /**\n * The desired motor speed in radians per second.\n */\n motorSpeed?: number;\n}\n\n/**\n * Prismatic joint definition. This requires defining a line of motion using an\n * axis and an anchor point. The definition uses local anchor points and a local\n * axis so that the initial configuration can violate the constraint slightly.\n * The joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface PrismaticJointDef extends JointDef, PrismaticJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The local translation unit axis in bodyA.\n */\n localAxisA: Vec2Value;\n /**\n * referenceAngle The constrained angle between the bodies:\n * bodyB_angle - bodyA_angle.\n */\n referenceAngle?: number;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n enableLimit : false,\n lowerTranslation : 0.0,\n upperTranslation : 0.0,\n enableMotor : false,\n maxMotorForce : 0.0,\n motorSpeed : 0.0\n};\n\ndeclare module \"./PrismaticJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PrismaticJoint(def: PrismaticJointDef): PrismaticJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PrismaticJoint(def: PrismaticJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value, axis: Vec2Value): PrismaticJoint;\n}\n\n/**\n * A prismatic joint. This joint provides one degree of freedom: translation\n * along an axis fixed in bodyA. Relative rotation is prevented. You can use a\n * joint limit to restrict the range of motion and a joint motor to drive the\n * motion or to model joint friction.\n */\n// @ts-expect-error\nexport class PrismaticJoint extends Joint {\n static TYPE = \"prismatic-joint\" as const;\n\n /** @internal */ m_type: \"prismatic-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_localXAxisA: Vec2;\n /** @internal */ m_localYAxisA: Vec2;\n /** @internal */ m_referenceAngle: number;\n /** @internal */ m_impulse: Vec3;\n /** @internal */ m_motorMass: number;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_lowerTranslation: number;\n /** @internal */ m_upperTranslation: number;\n /** @internal */ m_maxMotorForce: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableLimit: boolean;\n /** @internal */ m_enableMotor: boolean;\n /** @internal */ m_limitState: number; // TODO enum\n /** @internal */ m_axis: Vec2;\n /** @internal */ m_perp: Vec2;\n // Solver temp\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_s1: number;\n /** @internal */ m_s2: number;\n /** @internal */ m_a1: number;\n /** @internal */ m_a2: number;\n /** @internal */ m_K: Mat33;\n\n constructor(def: PrismaticJointDef);\n constructor(def: PrismaticJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value, axis?: Vec2Value);\n constructor(def: PrismaticJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value, axis?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PrismaticJoint)) {\n return new PrismaticJoint(def, bodyA, bodyB, anchor, axis);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = PrismaticJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n this.m_localXAxisA = Vec2.clone(axis ? bodyA.getLocalVector(axis) : def.localAxisA || Vec2.neo(1.0, 0.0));\n this.m_localXAxisA.normalize();\n this.m_localYAxisA = Vec2.crossNumVec2(1.0, this.m_localXAxisA);\n this.m_referenceAngle = Number.isFinite(def.referenceAngle) ? def.referenceAngle : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_impulse = new Vec3();\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n\n this.m_lowerTranslation = def.lowerTranslation;\n this.m_upperTranslation = def.upperTranslation;\n this.m_maxMotorForce = def.maxMotorForce;\n this.m_motorSpeed = def.motorSpeed;\n this.m_enableLimit = def.enableLimit;\n this.m_enableMotor = def.enableMotor;\n this.m_limitState = LimitState.inactiveLimit;\n\n this.m_axis = Vec2.zero();\n this.m_perp = Vec2.zero();\n\n this.m_K = new Mat33();\n\n // Linear constraint (point-to-line)\n // d = p2 - p1 = x2 + r2 - x1 - r1\n // C = dot(perp, d)\n // Cdot = dot(d, cross(w1, perp)) + dot(perp, v2 + cross(w2, r2) - v1 -\n // cross(w1, r1))\n // = -dot(perp, v1) - dot(cross(d + r1, perp), w1) + dot(perp, v2) +\n // dot(cross(r2, perp), v2)\n // J = [-perp, -cross(d + r1, perp), perp, cross(r2,perp)]\n //\n // Angular constraint\n // C = a2 - a1 + a_initial\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n //\n // K = J * invM * JT\n //\n // J = [-a -s1 a s2]\n // [0 -1 0 1]\n // a = perp\n // s1 = cross(d + r1, a) = cross(p2 - x1, a)\n // s2 = cross(r2, a) = cross(p2 - x2, a)\n\n // Motor/Limit linear constraint\n // C = dot(ax1, d)\n // Cdot = = -dot(ax1, v1) - dot(cross(d + r1, ax1), w1) + dot(ax1, v2) +\n // dot(cross(r2, ax1), v2)\n // J = [-ax1 -cross(d+r1,ax1) ax1 cross(r2,ax1)]\n\n // Block Solver\n // We develop a block solver that includes the joint limit. This makes the\n // limit stiff (inelastic) even\n // when the mass has poor distribution (leading to large torques about the\n // joint anchor points).\n //\n // The Jacobian has 3 rows:\n // J = [-uT -s1 uT s2] // linear\n // [0 -1 0 1] // angular\n // [-vT -a1 vT a2] // limit\n //\n // u = perp\n // v = axis\n // s1 = cross(d + r1, u), s2 = cross(r2, u)\n // a1 = cross(d + r1, v), a2 = cross(r2, v)\n\n // M * (v2 - v1) = JT * df\n // J * v2 = bias\n //\n // v2 = v1 + invM * JT * df\n // J * (v1 + invM * JT * df) = bias\n // K * df = bias - J * v1 = -Cdot\n // K = J * invM * JT\n // Cdot = J * v1 - bias\n //\n // Now solve for f2.\n // df = f2 - f1\n // K * (f2 - f1) = -Cdot\n // f2 = invK * (-Cdot) + f1\n //\n // Clamp accumulated limit impulse.\n // lower: f2(3) = max(f2(3), 0)\n // upper: f2(3) = min(f2(3), 0)\n //\n // Solve for correct f2(1:2)\n // K(1:2, 1:2) * f2(1:2) = -Cdot(1:2) - K(1:2,3) * f2(3) + K(1:2,1:3) * f1\n // = -Cdot(1:2) - K(1:2,3) * f2(3) + K(1:2,1:2) * f1(1:2) + K(1:2,3) * f1(3)\n // K(1:2, 1:2) * f2(1:2) = -Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3)) +\n // K(1:2,1:2) * f1(1:2)\n // f2(1:2) = invK(1:2,1:2) * (-Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3))) +\n // f1(1:2)\n //\n // Now compute impulse to be applied:\n // df = f2 - f1\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n lowerTranslation: this.m_lowerTranslation,\n upperTranslation: this.m_upperTranslation,\n maxMotorForce: this.m_maxMotorForce,\n motorSpeed: this.m_motorSpeed,\n enableLimit: this.m_enableLimit,\n enableMotor: this.m_enableMotor,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n localAxisA: this.m_localXAxisA,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): PrismaticJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.localAxisA = Vec2.clone(data.localAxisA);\n const joint = new PrismaticJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (def.localAxisA) {\n this.m_localXAxisA.setVec2(def.localAxisA);\n this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1.0, def.localAxisA));\n }\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n }\n if (typeof def.enableLimit !== \"undefined\") {\n this.m_enableLimit = !!def.enableLimit;\n }\n if (Number.isFinite(def.lowerTranslation)) {\n this.m_lowerTranslation = def.lowerTranslation;\n }\n if (Number.isFinite(def.upperTranslation)) {\n this.m_upperTranslation = def.upperTranslation;\n }\n if (typeof def.enableMotor !== \"undefined\") {\n this.m_enableMotor = !!def.enableMotor;\n }\n if (Number.isFinite(def.maxMotorForce)) {\n this.m_maxMotorForce = def.maxMotorForce;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * The local joint axis relative to bodyA.\n */\n getLocalAxisA(): Vec2 {\n return this.m_localXAxisA;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Get the current joint translation, usually in meters.\n */\n getJointTranslation(): number {\n const pA = this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n const pB = this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n const d = Vec2.sub(pB, pA);\n const axis = this.m_bodyA.getWorldVector(this.m_localXAxisA);\n\n const translation = Vec2.dot(d, axis);\n return translation;\n }\n\n /**\n * Get the current joint translation speed, usually in meters per second.\n */\n getJointSpeed(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n\n const rA = Rot.mulVec2(bA.m_xf.q, Vec2.sub(this.m_localAnchorA, bA.m_sweep.localCenter));\n const rB = Rot.mulVec2(bB.m_xf.q, Vec2.sub(this.m_localAnchorB, bB.m_sweep.localCenter));\n const p1 = Vec2.add(bA.m_sweep.c, rA);\n const p2 = Vec2.add(bB.m_sweep.c, rB);\n const d = Vec2.sub(p2, p1);\n const axis = Rot.mulVec2(bA.m_xf.q, this.m_localXAxisA);\n\n const vA = bA.m_linearVelocity;\n const vB = bB.m_linearVelocity;\n const wA = bA.m_angularVelocity;\n const wB = bB.m_angularVelocity;\n\n const speed = Vec2.dot(d, Vec2.crossNumVec2(wA, axis)) + Vec2.dot(axis, Vec2.sub(Vec2.addCrossNumVec2(vB, wB, rB), Vec2.addCrossNumVec2(vA, wA, rA)));\n return speed;\n }\n\n /**\n * Is the joint limit enabled?\n */\n isLimitEnabled(): boolean {\n return this.m_enableLimit;\n }\n\n /**\n * Enable/disable the joint limit.\n */\n enableLimit(flag: boolean): void {\n if (flag != this.m_enableLimit) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableLimit = flag;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Get the lower joint limit, usually in meters.\n */\n getLowerLimit(): number {\n return this.m_lowerTranslation;\n }\n\n /**\n * Get the upper joint limit, usually in meters.\n */\n getUpperLimit(): number {\n return this.m_upperTranslation;\n }\n\n /**\n * Set the joint limits, usually in meters.\n */\n setLimits(lower: number, upper: number): void {\n if (_ASSERT) console.assert(lower <= upper);\n if (lower != this.m_lowerTranslation || upper != this.m_upperTranslation) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_lowerTranslation = lower;\n this.m_upperTranslation = upper;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Set the motor speed, usually in meters per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Set the maximum motor force, usually in N.\n */\n setMaxMotorForce(force: number): void {\n if (force == this.m_maxMotorForce) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorForce = force;\n }\n\n getMaxMotorForce(): number {\n return this.m_maxMotorForce;\n }\n\n /**\n * Get the motor speed, usually in meters per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Get the current motor force given the inverse time step, usually in N.\n */\n getMotorForce(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.combine(this.m_impulse.x, this.m_perp, this.m_motorImpulse + this.m_impulse.z, this.m_axis).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.y;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective masses.\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Compute motor Jacobian and effective mass.\n {\n this.m_axis = Rot.mulVec2(qA, this.m_localXAxisA);\n this.m_a1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_axis);\n this.m_a2 = Vec2.crossVec2Vec2(rB, this.m_axis);\n\n this.m_motorMass = mA + mB + iA * this.m_a1 * this.m_a1 + iB * this.m_a2\n * this.m_a2;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n }\n\n // Prismatic constraint.\n {\n this.m_perp = Rot.mulVec2(qA, this.m_localYAxisA);\n\n this.m_s1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_perp);\n this.m_s2 = Vec2.crossVec2Vec2(rB, this.m_perp);\n\n const s1test = Vec2.crossVec2Vec2(rA, this.m_perp);\n\n const k11 = mA + mB + iA * this.m_s1 * this.m_s1 + iB * this.m_s2 * this.m_s2;\n const k12 = iA * this.m_s1 + iB * this.m_s2;\n const k13 = iA * this.m_s1 * this.m_a1 + iB * this.m_s2 * this.m_a2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n // For bodies with fixed rotation.\n k22 = 1.0;\n }\n const k23 = iA * this.m_a1 + iB * this.m_a2;\n const k33 = mA + mB + iA * this.m_a1 * this.m_a1 + iB * this.m_a2 * this.m_a2;\n\n this.m_K.ex.set(k11, k12, k13);\n this.m_K.ey.set(k12, k22, k23);\n this.m_K.ez.set(k13, k23, k33);\n }\n\n // Compute motor and limit terms.\n if (this.m_enableLimit) {\n\n const jointTranslation = Vec2.dot(this.m_axis, d);\n if (math_abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * Settings.linearSlop) {\n this.m_limitState = LimitState.equalLimits;\n\n } else if (jointTranslation <= this.m_lowerTranslation) {\n if (this.m_limitState != LimitState.atLowerLimit) {\n this.m_limitState = LimitState.atLowerLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else if (jointTranslation >= this.m_upperTranslation) {\n if (this.m_limitState != LimitState.atUpperLimit) {\n this.m_limitState = LimitState.atUpperLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n if (this.m_enableMotor == false) {\n this.m_motorImpulse = 0.0;\n }\n\n if (step.warmStarting) {\n // Account for variable time step.\n this.m_impulse.mul(step.dtRatio);\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.combine(this.m_impulse.x, this.m_perp, this.m_motorImpulse\n + this.m_impulse.z, this.m_axis);\n const LA = this.m_impulse.x * this.m_s1 + this.m_impulse.y\n + (this.m_motorImpulse + this.m_impulse.z) * this.m_a1;\n const LB = this.m_impulse.x * this.m_s2 + this.m_impulse.y\n + (this.m_motorImpulse + this.m_impulse.z) * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n } else {\n this.m_impulse.setZero();\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Solve linear motor constraint.\n if (this.m_enableMotor && this.m_limitState != LimitState.equalLimits) {\n const Cdot = Vec2.dot(this.m_axis, Vec2.sub(vB, vA)) + this.m_a2 * wB\n - this.m_a1 * wA;\n let impulse = this.m_motorMass * (this.m_motorSpeed - Cdot);\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorForce;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse,\n -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_axis);\n const LA = impulse * this.m_a1;\n const LB = impulse * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n const Cdot1 = Vec2.zero();\n Cdot1.x += Vec2.dot(this.m_perp, vB) + this.m_s2 * wB;\n Cdot1.x -= Vec2.dot(this.m_perp, vA) + this.m_s1 * wA;\n Cdot1.y = wB - wA;\n\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit) {\n // Solve prismatic and limit constraint in block form.\n let Cdot2 = 0;\n Cdot2 += Vec2.dot(this.m_axis, vB) + this.m_a2 * wB;\n Cdot2 -= Vec2.dot(this.m_axis, vA) + this.m_a1 * wA;\n\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const f1 = Vec3.clone(this.m_impulse);\n let df = this.m_K.solve33(Vec3.neg(Cdot));\n this.m_impulse.add(df);\n\n if (this.m_limitState == LimitState.atLowerLimit) {\n this.m_impulse.z = math_max(this.m_impulse.z, 0.0);\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n this.m_impulse.z = math_min(this.m_impulse.z, 0.0);\n }\n\n // f2(1:2) = invK(1:2,1:2) * (-Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3))) +\n // f1(1:2)\n const b = Vec2.combine(-1, Cdot1, -(this.m_impulse.z - f1.z), Vec2.neo(this.m_K.ez.x, this.m_K.ez.y));\n const f2r = Vec2.add(this.m_K.solve22(b), Vec2.neo(f1.x, f1.y));\n this.m_impulse.x = f2r.x;\n this.m_impulse.y = f2r.y;\n\n df = Vec3.sub(this.m_impulse, f1);\n\n const P = Vec2.combine(df.x, this.m_perp, df.z, this.m_axis);\n const LA = df.x * this.m_s1 + df.y + df.z * this.m_a1;\n const LB = df.x * this.m_s2 + df.y + df.z * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n } else {\n // Limit is inactive, just solve the prismatic constraint in block form.\n const df = this.m_K.solve22(Vec2.neg(Cdot1));\n this.m_impulse.x += df.x;\n this.m_impulse.y += df.y;\n\n const P = Vec2.mulNumVec2(df.x, this.m_perp);\n const LA = df.x * this.m_s1 + df.y;\n const LB = df.x * this.m_s2 + df.y;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Compute fresh Jacobians\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.sub(Vec2.add(cB, rB), Vec2.add(cA, rA));\n\n const axis = Rot.mulVec2(qA, this.m_localXAxisA);\n const a1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), axis);\n const a2 = Vec2.crossVec2Vec2(rB, axis);\n const perp = Rot.mulVec2(qA, this.m_localYAxisA);\n\n const s1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), perp);\n const s2 = Vec2.crossVec2Vec2(rB, perp);\n\n let impulse = new Vec3();\n const C1 = Vec2.zero();\n C1.x = Vec2.dot(perp, d);\n C1.y = aB - aA - this.m_referenceAngle;\n\n let linearError = math_abs(C1.x);\n const angularError = math_abs(C1.y);\n\n const linearSlop = Settings.linearSlop;\n const maxLinearCorrection = Settings.maxLinearCorrection;\n\n let active = false; // bool\n let C2 = 0.0;\n if (this.m_enableLimit) {\n\n const translation = Vec2.dot(axis, d);\n if (math_abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * linearSlop) {\n // Prevent large angular corrections\n C2 = clamp(translation, -maxLinearCorrection, maxLinearCorrection);\n linearError = math_max(linearError, math_abs(translation));\n active = true;\n\n } else if (translation <= this.m_lowerTranslation) {\n // Prevent large linear corrections and allow some slop.\n C2 = clamp(translation - this.m_lowerTranslation + linearSlop,\n -maxLinearCorrection, 0.0);\n linearError = Math\n .max(linearError, this.m_lowerTranslation - translation);\n active = true;\n\n } else if (translation >= this.m_upperTranslation) {\n // Prevent large linear corrections and allow some slop.\n C2 = clamp(translation - this.m_upperTranslation - linearSlop, 0.0,\n maxLinearCorrection);\n linearError = Math\n .max(linearError, translation - this.m_upperTranslation);\n active = true;\n }\n }\n\n if (active) {\n const k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2;\n const k12 = iA * s1 + iB * s2;\n const k13 = iA * s1 * a1 + iB * s2 * a2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n // For fixed rotation\n k22 = 1.0;\n }\n const k23 = iA * a1 + iB * a2;\n const k33 = mA + mB + iA * a1 * a1 + iB * a2 * a2;\n\n const K = new Mat33();\n K.ex.set(k11, k12, k13);\n K.ey.set(k12, k22, k23);\n K.ez.set(k13, k23, k33);\n\n const C = new Vec3();\n C.x = C1.x;\n C.y = C1.y;\n C.z = C2;\n\n impulse = K.solve33(Vec3.neg(C));\n } else {\n const k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2;\n const k12 = iA * s1 + iB * s2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n k22 = 1.0;\n }\n\n const K = new Mat22();\n K.ex.setNum(k11, k12);\n K.ey.setNum(k12, k22);\n\n const impulse1 = K.solve(Vec2.neg(C1));\n impulse.x = impulse1.x;\n impulse.y = impulse1.y;\n impulse.z = 0.0;\n }\n\n const P = Vec2.combine(impulse.x, perp, impulse.z, axis);\n const LA = impulse.x * s1 + impulse.y + impulse.z * a1;\n const LB = impulse.x * s2 + impulse.y + impulse.z * a2;\n\n cA.subMul(mA, P);\n aA -= iA * LA;\n cB.addMul(mB, P);\n aB += iB * LB;\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return linearError <= Settings.linearSlop\n && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { } from \"../../common/Math\";\nimport { Vec2 } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { RevoluteJoint } from \"./RevoluteJoint\";\nimport { PrismaticJoint } from \"./PrismaticJoint\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Gear joint definition.\n */\nexport interface GearJointOpt extends JointOpt {\n /**\n * The gear ratio. See {@link GearJoint} for explanation.\n */\n ratio?: number;\n}\n\n/**\n * Gear joint definition.\n */\nexport interface GearJointDef extends JointDef, GearJointOpt {\n /**\n * The first revolute/prismatic joint attached to the gear joint.\n */\n joint1: RevoluteJoint | PrismaticJoint;\n /**\n * The second prismatic/revolute joint attached to the gear joint.\n */\n joint2: RevoluteJoint | PrismaticJoint;\n}\n\n/** @internal */ const DEFAULTS = {\n ratio : 1.0\n};\n\ndeclare module \"./GearJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function GearJoint(def: GearJointDef): GearJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function GearJoint(def: GearJointOpt, bodyA: Body, bodyB: Body, joint1: RevoluteJoint | PrismaticJoint, joint2: RevoluteJoint | PrismaticJoint, ratio?: number): GearJoint;\n}\n\n/**\n * A gear joint is used to connect two joints together. Either joint can be a\n * revolute or prismatic joint. You specify a gear ratio to bind the motions\n * together: coordinate1 + ratio * coordinate2 = constant\n *\n * The ratio can be negative or positive. If one joint is a revolute joint and\n * the other joint is a prismatic joint, then the ratio will have units of\n * length or units of 1/length. Warning: You have to manually destroy the gear\n * joint if joint1 or joint2 is destroyed.\n *\n * This definition requires two existing revolute or prismatic joints (any\n * combination will work).\n */\n// @ts-expect-error\nexport class GearJoint extends Joint {\n static TYPE = \"gear-joint\" as const;\n\n /** @internal */ m_type: \"gear-joint\";\n /** @internal */ m_joint1: RevoluteJoint | PrismaticJoint;\n /** @internal */ m_joint2: RevoluteJoint | PrismaticJoint;\n /** @internal */ m_type1: \"revolute-joint\" | \"prismatic-joint\";\n /** @internal */ m_type2: \"revolute-joint\" | \"prismatic-joint\";\n /** @internal */ m_bodyC: Body;\n /** @internal */ m_localAnchorC: Vec2;\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_referenceAngleA: number;\n /** @internal */ m_localAxisC: Vec2;\n /** @internal */ m_bodyD: Body;\n /** @internal */ m_localAnchorD: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngleB: number;\n /** @internal */ m_localAxisD: Vec2;\n /** @internal */ m_ratio: number;\n /** @internal */ m_constant: number;\n /** @internal */ m_impulse: number;\n\n // Solver temp\n /** @internal */ m_lcA: Vec2;\n /** @internal */ m_lcB: Vec2;\n /** @internal */ m_lcC: Vec2;\n /** @internal */ m_lcD: Vec2;\n /** @internal */ m_mA: number;\n /** @internal */ m_mB: number;\n /** @internal */ m_mC: number;\n /** @internal */ m_mD: number;\n /** @internal */ m_iA: number;\n /** @internal */ m_iB: number;\n /** @internal */ m_iC: number;\n /** @internal */ m_iD: number;\n /** @internal */ m_JvAC: Vec2;\n /** @internal */ m_JvBD: Vec2;\n /** @internal */ m_JwA: number;\n /** @internal */ m_JwB: number;\n /** @internal */ m_JwC: number;\n /** @internal */ m_JwD: number;\n /** @internal */ m_mass: number;\n\n constructor(def: GearJointDef);\n constructor(def: GearJointOpt, bodyA: Body, bodyB: Body, joint1: RevoluteJoint | PrismaticJoint, joint2: RevoluteJoint | PrismaticJoint, ratio?: number);\n constructor(def: GearJointDef, bodyA?: Body, bodyB?: Body, joint1?: RevoluteJoint | PrismaticJoint, joint2?: RevoluteJoint | PrismaticJoint, ratio?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof GearJoint)) {\n return new GearJoint(def, bodyA, bodyB, joint1, joint2, ratio);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = GearJoint.TYPE;\n\n if (_ASSERT) console.assert(joint1.m_type === RevoluteJoint.TYPE || joint1.m_type === PrismaticJoint.TYPE);\n if (_ASSERT) console.assert(joint2.m_type === RevoluteJoint.TYPE || joint2.m_type === PrismaticJoint.TYPE);\n\n this.m_joint1 = joint1 ? joint1 : def.joint1;\n this.m_joint2 = joint2 ? joint2 : def.joint2;\n this.m_ratio = Number.isFinite(ratio) ? ratio : def.ratio;\n\n this.m_type1 = this.m_joint1.getType() as \"revolute-joint\" | \"prismatic-joint\";\n this.m_type2 = this.m_joint2.getType() as \"revolute-joint\" | \"prismatic-joint\";\n\n // joint1 connects body A to body C\n // joint2 connects body B to body D\n\n let coordinateA: number;\n let coordinateB: number;\n\n // TODO_ERIN there might be some problem with the joint edges in Joint.\n\n this.m_bodyC = this.m_joint1.getBodyA();\n this.m_bodyA = this.m_joint1.getBodyB();\n\n // Get geometry of joint1\n const xfA = this.m_bodyA.m_xf;\n const aA = this.m_bodyA.m_sweep.a;\n const xfC = this.m_bodyC.m_xf;\n const aC = this.m_bodyC.m_sweep.a;\n\n if (this.m_type1 === RevoluteJoint.TYPE) {\n const revolute = this.m_joint1 as RevoluteJoint;\n this.m_localAnchorC = revolute.m_localAnchorA;\n this.m_localAnchorA = revolute.m_localAnchorB;\n this.m_referenceAngleA = revolute.m_referenceAngle;\n this.m_localAxisC = Vec2.zero();\n\n coordinateA = aA - aC - this.m_referenceAngleA;\n } else {\n const prismatic = this.m_joint1 as PrismaticJoint;\n this.m_localAnchorC = prismatic.m_localAnchorA;\n this.m_localAnchorA = prismatic.m_localAnchorB;\n this.m_referenceAngleA = prismatic.m_referenceAngle;\n this.m_localAxisC = prismatic.m_localXAxisA;\n\n const pC = this.m_localAnchorC;\n const pA = Rot.mulTVec2(xfC.q, Vec2.add(Rot.mulVec2(xfA.q, this.m_localAnchorA), Vec2.sub(xfA.p, xfC.p)));\n coordinateA = Vec2.dot(pA, this.m_localAxisC) - Vec2.dot(pC, this.m_localAxisC);\n }\n\n this.m_bodyD = this.m_joint2.getBodyA();\n this.m_bodyB = this.m_joint2.getBodyB();\n\n // Get geometry of joint2\n const xfB = this.m_bodyB.m_xf;\n const aB = this.m_bodyB.m_sweep.a;\n const xfD = this.m_bodyD.m_xf;\n const aD = this.m_bodyD.m_sweep.a;\n\n if (this.m_type2 === RevoluteJoint.TYPE) {\n const revolute = this.m_joint2 as RevoluteJoint;\n this.m_localAnchorD = revolute.m_localAnchorA;\n this.m_localAnchorB = revolute.m_localAnchorB;\n this.m_referenceAngleB = revolute.m_referenceAngle;\n this.m_localAxisD = Vec2.zero();\n\n coordinateB = aB - aD - this.m_referenceAngleB;\n } else {\n const prismatic = this.m_joint2 as PrismaticJoint;\n this.m_localAnchorD = prismatic.m_localAnchorA;\n this.m_localAnchorB = prismatic.m_localAnchorB;\n this.m_referenceAngleB = prismatic.m_referenceAngle;\n this.m_localAxisD = prismatic.m_localXAxisA;\n\n const pD = this.m_localAnchorD;\n const pB = Rot.mulTVec2(xfD.q, Vec2.add(Rot.mulVec2(xfB.q, this.m_localAnchorB), Vec2.sub(xfB.p, xfD.p)));\n coordinateB = Vec2.dot(pB, this.m_localAxisD) - Vec2.dot(pD, this.m_localAxisD);\n }\n\n this.m_constant = coordinateA + this.m_ratio * coordinateB;\n\n this.m_impulse = 0.0;\n\n // Gear Joint:\n // C0 = (coordinate1 + ratio * coordinate2)_initial\n // C = (coordinate1 + ratio * coordinate2) - C0 = 0\n // J = [J1 ratio * J2]\n // K = J * invM * JT\n // = J1 * invM1 * J1T + ratio * ratio * J2 * invM2 * J2T\n //\n // Revolute:\n // coordinate = rotation\n // Cdot = angularVelocity\n // J = [0 0 1]\n // K = J * invM * JT = invI\n //\n // Prismatic:\n // coordinate = dot(p - pg, ug)\n // Cdot = dot(v + cross(w, r), ug)\n // J = [ug cross(r, ug)]\n // K = J * invM * JT = invMass + invI * cross(r, ug)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n joint1: this.m_joint1,\n joint2: this.m_joint2,\n ratio: this.m_ratio,\n\n // _constant: this.m_constant,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): GearJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.joint1 = restore(Joint, data.joint1, world);\n data.joint2 = restore(Joint, data.joint2, world);\n const joint = new GearJoint(data);\n // if (data._constant) joint.m_constant = data._constant;\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n // todo: implement other fields\n if (Number.isFinite(def.ratio)) {\n this.m_ratio = def.ratio;\n }\n }\n\n /**\n * Get the first joint.\n */\n getJoint1(): Joint {\n return this.m_joint1;\n }\n\n /**\n * Get the second joint.\n */\n getJoint2(): Joint {\n return this.m_joint2;\n }\n\n /**\n * Set the gear ratio.\n */\n setRatio(ratio: number): void {\n if (_ASSERT) console.assert(Number.isFinite(ratio));\n this.m_ratio = ratio;\n }\n\n /**\n * Get the gear ratio.\n */\n getRatio(): number {\n return this.m_ratio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_JvAC).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n const L = this.m_impulse * this.m_JwA;\n return inv_dt * L;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_lcA = this.m_bodyA.m_sweep.localCenter;\n this.m_lcB = this.m_bodyB.m_sweep.localCenter;\n this.m_lcC = this.m_bodyC.m_sweep.localCenter;\n this.m_lcD = this.m_bodyD.m_sweep.localCenter;\n this.m_mA = this.m_bodyA.m_invMass;\n this.m_mB = this.m_bodyB.m_invMass;\n this.m_mC = this.m_bodyC.m_invMass;\n this.m_mD = this.m_bodyD.m_invMass;\n this.m_iA = this.m_bodyA.m_invI;\n this.m_iB = this.m_bodyB.m_invI;\n this.m_iC = this.m_bodyC.m_invI;\n this.m_iD = this.m_bodyD.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const aC = this.m_bodyC.c_position.a;\n const vC = this.m_bodyC.c_velocity.v;\n let wC = this.m_bodyC.c_velocity.w;\n\n const aD = this.m_bodyD.c_position.a;\n const vD = this.m_bodyD.c_velocity.v;\n let wD = this.m_bodyD.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n const qC = Rot.neo(aC);\n const qD = Rot.neo(aD);\n\n this.m_mass = 0.0;\n\n if (this.m_type1 == RevoluteJoint.TYPE) {\n this.m_JvAC = Vec2.zero();\n this.m_JwA = 1.0;\n this.m_JwC = 1.0;\n this.m_mass += this.m_iA + this.m_iC;\n } else {\n const u = Rot.mulVec2(qC, this.m_localAxisC);\n const rC = Rot.mulSub(qC, this.m_localAnchorC, this.m_lcC);\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_lcA);\n this.m_JvAC = u;\n this.m_JwC = Vec2.crossVec2Vec2(rC, u);\n this.m_JwA = Vec2.crossVec2Vec2(rA, u);\n this.m_mass += this.m_mC + this.m_mA + this.m_iC * this.m_JwC * this.m_JwC + this.m_iA * this.m_JwA * this.m_JwA;\n }\n\n if (this.m_type2 == RevoluteJoint.TYPE) {\n this.m_JvBD = Vec2.zero();\n this.m_JwB = this.m_ratio;\n this.m_JwD = this.m_ratio;\n this.m_mass += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD);\n } else {\n const u = Rot.mulVec2(qD, this.m_localAxisD);\n const rD = Rot.mulSub(qD, this.m_localAnchorD, this.m_lcD);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_lcB);\n this.m_JvBD = Vec2.mulNumVec2(this.m_ratio, u);\n this.m_JwD = this.m_ratio * Vec2.crossVec2Vec2(rD, u);\n this.m_JwB = this.m_ratio * Vec2.crossVec2Vec2(rB, u);\n this.m_mass += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * this.m_JwD * this.m_JwD + this.m_iB * this.m_JwB * this.m_JwB;\n }\n\n // Compute effective mass.\n this.m_mass = this.m_mass > 0.0 ? 1.0 / this.m_mass : 0.0;\n\n if (step.warmStarting) {\n vA.addMul(this.m_mA * this.m_impulse, this.m_JvAC);\n wA += this.m_iA * this.m_impulse * this.m_JwA;\n\n vB.addMul(this.m_mB * this.m_impulse, this.m_JvBD);\n wB += this.m_iB * this.m_impulse * this.m_JwB;\n\n vC.subMul(this.m_mC * this.m_impulse, this.m_JvAC);\n wC -= this.m_iC * this.m_impulse * this.m_JwC;\n\n vD.subMul(this.m_mD * this.m_impulse, this.m_JvBD);\n wD -= this.m_iD * this.m_impulse * this.m_JwD;\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n this.m_bodyC.c_velocity.v.setVec2(vC);\n this.m_bodyC.c_velocity.w = wC;\n this.m_bodyD.c_velocity.v.setVec2(vD);\n this.m_bodyD.c_velocity.w = wD;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n const vC = this.m_bodyC.c_velocity.v;\n let wC = this.m_bodyC.c_velocity.w;\n const vD = this.m_bodyD.c_velocity.v;\n let wD = this.m_bodyD.c_velocity.w;\n\n let Cdot = Vec2.dot(this.m_JvAC, vA) - Vec2.dot(this.m_JvAC, vC) + Vec2.dot(this.m_JvBD, vB) - Vec2.dot(this.m_JvBD, vD);\n Cdot += (this.m_JwA * wA - this.m_JwC * wC) + (this.m_JwB * wB - this.m_JwD * wD);\n\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n vA.addMul(this.m_mA * impulse, this.m_JvAC);\n wA += this.m_iA * impulse * this.m_JwA;\n vB.addMul(this.m_mB * impulse, this.m_JvBD);\n wB += this.m_iB * impulse * this.m_JwB;\n vC.subMul(this.m_mC * impulse, this.m_JvAC);\n wC -= this.m_iC * impulse * this.m_JwC;\n vD.subMul(this.m_mD * impulse, this.m_JvBD);\n wD -= this.m_iD * impulse * this.m_JwD;\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n this.m_bodyC.c_velocity.v.setVec2(vC);\n this.m_bodyC.c_velocity.w = wC;\n this.m_bodyD.c_velocity.v.setVec2(vD);\n this.m_bodyD.c_velocity.w = wD;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n const cC = this.m_bodyC.c_position.c;\n let aC = this.m_bodyC.c_position.a;\n const cD = this.m_bodyD.c_position.c;\n let aD = this.m_bodyD.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n const qC = Rot.neo(aC);\n const qD = Rot.neo(aD);\n\n const linearError = 0.0;\n\n let coordinateA: number;\n let coordinateB: number;\n\n let JvAC: Vec2;\n let JvBD: Vec2;\n let JwA: number;\n let JwB: number;\n let JwC: number;\n let JwD: number;\n let mass = 0.0;\n\n if (this.m_type1 == RevoluteJoint.TYPE) {\n JvAC = Vec2.zero();\n JwA = 1.0;\n JwC = 1.0;\n mass += this.m_iA + this.m_iC;\n\n coordinateA = aA - aC - this.m_referenceAngleA;\n } else {\n const u = Rot.mulVec2(qC, this.m_localAxisC);\n const rC = Rot.mulSub(qC, this.m_localAnchorC, this.m_lcC);\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_lcA);\n JvAC = u;\n JwC = Vec2.crossVec2Vec2(rC, u);\n JwA = Vec2.crossVec2Vec2(rA, u);\n mass += this.m_mC + this.m_mA + this.m_iC * JwC * JwC + this.m_iA * JwA * JwA;\n\n const pC = Vec2.sub(this.m_localAnchorC, this.m_lcC);\n const pA = Rot.mulTVec2(qC, Vec2.add(rA, Vec2.sub(cA, cC)));\n coordinateA = Vec2.dot(Vec2.sub(pA, pC), this.m_localAxisC);\n }\n\n if (this.m_type2 == RevoluteJoint.TYPE) {\n JvBD = Vec2.zero();\n JwB = this.m_ratio;\n JwD = this.m_ratio;\n mass += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD);\n\n coordinateB = aB - aD - this.m_referenceAngleB;\n } else {\n const u = Rot.mulVec2(qD, this.m_localAxisD);\n const rD = Rot.mulSub(qD, this.m_localAnchorD, this.m_lcD);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_lcB);\n JvBD = Vec2.mulNumVec2(this.m_ratio, u);\n JwD = this.m_ratio * Vec2.crossVec2Vec2(rD, u);\n JwB = this.m_ratio * Vec2.crossVec2Vec2(rB, u);\n mass += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * JwD * JwD + this.m_iB * JwB * JwB;\n\n const pD = Vec2.sub(this.m_localAnchorD, this.m_lcD);\n const pB = Rot.mulTVec2(qD, Vec2.add(rB, Vec2.sub(cB, cD)));\n coordinateB = Vec2.dot(pB, this.m_localAxisD) - Vec2.dot(pD, this.m_localAxisD);\n }\n\n const C = (coordinateA + this.m_ratio * coordinateB) - this.m_constant;\n\n let impulse = 0.0;\n if (mass > 0.0) {\n impulse = -C / mass;\n }\n\n cA.addMul(this.m_mA * impulse, JvAC);\n aA += this.m_iA * impulse * JwA;\n cB.addMul(this.m_mB * impulse, JvBD);\n aB += this.m_iB * impulse * JwB;\n cC.subMul(this.m_mC * impulse, JvAC);\n aC -= this.m_iC * impulse * JwC;\n cD.subMul(this.m_mD * impulse, JvBD);\n aD -= this.m_iD * impulse * JwD;\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n this.m_bodyC.c_position.c.setVec2(cC);\n this.m_bodyC.c_position.a = aC;\n this.m_bodyD.c_position.c.setVec2(cD);\n this.m_bodyD.c_position.a = aD;\n\n // TODO_ERIN not implemented\n return linearError < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Motor joint definition.\n */\nexport interface MotorJointOpt extends JointOpt {\n /**\n * The bodyB angle minus bodyA angle in radians.\n */\n angularOffset?: number;\n /**\n * The maximum motor force in N.\n */\n maxForce?: number;\n /**\n * The maximum motor torque in N-m.\n */\n maxTorque?: number;\n /**\n * Position correction factor in the range [0,1].\n */\n correctionFactor?: number;\n /**\n * Position of bodyB minus the position of bodyA, in bodyA's frame, in meters.\n */\n linearOffset?: Vec2Value;\n}\n\n/**\n * Motor joint definition.\n */\nexport interface MotorJointDef extends JointDef, MotorJointOpt {\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 1.0,\n maxTorque : 1.0,\n correctionFactor : 0.3\n};\n\ndeclare module \"./MotorJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MotorJoint(def: MotorJointDef): MotorJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MotorJoint(def: MotorJointOpt, bodyA: Body, bodyB: Body): MotorJoint;\n}\n\n/**\n * A motor joint is used to control the relative motion between two bodies. A\n * typical usage is to control the movement of a dynamic body with respect to\n * the ground.\n */\n// @ts-expect-error\nexport class MotorJoint extends Joint {\n static TYPE = \"motor-joint\" as const;\n\n /** @internal */ m_type: \"motor-joint\";\n /** @internal */ m_linearOffset: Vec2;\n /** @internal */ m_angularOffset: number;\n /** @internal */ m_linearImpulse: Vec2;\n /** @internal */ m_angularImpulse: number;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_maxTorque: number;\n /** @internal */ m_correctionFactor: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_linearError: Vec2;\n /** @internal */ m_angularError: number;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_linearMass: Mat22;\n /** @internal */ m_angularMass: number;\n\n constructor(def: MotorJointDef);\n constructor(def: MotorJointOpt, bodyA: Body, bodyB: Body);\n constructor(def: MotorJointDef | MotorJointOpt, bodyA?: Body, bodyB?: Body) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof MotorJoint)) {\n return new MotorJoint(def, bodyA, bodyB);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = MotorJoint.TYPE;\n\n this.m_linearOffset = Vec2.isValid(def.linearOffset) ? Vec2.clone(def.linearOffset) : bodyA.getLocalPoint(bodyB.getPosition());\n this.m_angularOffset = Number.isFinite(def.angularOffset) ? def.angularOffset : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_linearImpulse = Vec2.zero();\n this.m_angularImpulse = 0.0;\n\n this.m_maxForce = def.maxForce;\n this.m_maxTorque = def.maxTorque;\n this.m_correctionFactor = def.correctionFactor;\n\n // Point-to-point constraint\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n //\n // r1 = offset - c1\n // r2 = -c2\n\n // Angle constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n maxForce: this.m_maxForce,\n maxTorque: this.m_maxTorque,\n correctionFactor: this.m_correctionFactor,\n\n linearOffset: this.m_linearOffset,\n angularOffset: this.m_angularOffset,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): MotorJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new MotorJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.angularOffset)) {\n this.m_angularOffset = def.angularOffset;\n }\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.maxTorque)) {\n this.m_maxTorque = def.maxTorque;\n }\n if (Number.isFinite(def.correctionFactor)) {\n this.m_correctionFactor = def.correctionFactor;\n }\n if (Vec2.isValid(def.linearOffset)) {\n this.m_linearOffset.set(def.linearOffset); \n }\n }\n\n /**\n * Set the maximum friction force in N.\n */\n setMaxForce(force: number): void {\n if (_ASSERT) console.assert(Number.isFinite(force) && force >= 0.0);\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum friction force in N.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the maximum friction torque in N*m.\n */\n setMaxTorque(torque: number): void {\n if (_ASSERT) console.assert(Number.isFinite(torque) && torque >= 0.0);\n this.m_maxTorque = torque;\n }\n\n /**\n * Get the maximum friction torque in N*m.\n */\n getMaxTorque(): number {\n return this.m_maxTorque;\n }\n\n /**\n * Set the position correction factor in the range [0,1].\n */\n setCorrectionFactor(factor: number): void {\n if (_ASSERT) console.assert(Number.isFinite(factor) && 0.0 <= factor && factor <= 1.0);\n this.m_correctionFactor = factor;\n }\n\n /**\n * Get the position correction factor in the range [0,1].\n */\n getCorrectionFactor(): number {\n return this.m_correctionFactor;\n }\n\n /**\n * Set/get the target linear offset, in frame A, in meters.\n */\n setLinearOffset(linearOffset: Vec2Value): void {\n if (linearOffset.x != this.m_linearOffset.x || linearOffset.y != this.m_linearOffset.y) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_linearOffset.set(linearOffset);\n }\n }\n\n getLinearOffset(): Vec2 {\n return this.m_linearOffset;\n }\n\n /**\n * Set/get the target angular offset, in radians.\n */\n setAngularOffset(angularOffset: number): void {\n if (angularOffset != this.m_angularOffset) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_angularOffset = angularOffset;\n }\n }\n\n getAngularOffset(): number {\n return this.m_angularOffset;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getPosition();\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getPosition();\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_linearImpulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_angularImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective mass matrix.\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_linearOffset, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.neg(this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Upper 2 by 2 of K for point to point\n const K = new Mat22();\n K.ex.x = mA + mB + iA * this.m_rA.y * this.m_rA.y + iB * this.m_rB.y * this.m_rB.y;\n K.ex.y = -iA * this.m_rA.x * this.m_rA.y - iB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * this.m_rA.x * this.m_rA.x + iB * this.m_rB.x * this.m_rB.x;\n\n this.m_linearMass = K.getInverse();\n\n this.m_angularMass = iA + iB;\n if (this.m_angularMass > 0.0) {\n this.m_angularMass = 1.0 / this.m_angularMass;\n }\n\n this.m_linearError = Vec2.zero();\n this.m_linearError.addCombine(1, cB, 1, this.m_rB);\n this.m_linearError.subCombine(1, cA, 1, this.m_rA);\n\n this.m_angularError = aB - aA - this.m_angularOffset;\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_linearImpulse.mul(step.dtRatio);\n this.m_angularImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_linearImpulse.x, this.m_linearImpulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_angularImpulse);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_angularImpulse);\n\n } else {\n this.m_linearImpulse.setZero();\n this.m_angularImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const h = step.dt;\n const inv_h = step.inv_dt;\n\n // Solve angular friction\n {\n const Cdot = wB - wA + inv_h * this.m_correctionFactor * this.m_angularError;\n let impulse = -this.m_angularMass * Cdot;\n\n const oldImpulse = this.m_angularImpulse;\n const maxImpulse = h * this.m_maxTorque;\n this.m_angularImpulse = clamp(this.m_angularImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_angularImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve linear friction\n {\n const Cdot = Vec2.zero();\n Cdot.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n Cdot.addMul(inv_h * this.m_correctionFactor, this.m_linearError);\n\n let impulse = Vec2.neg(Mat22.mulVec2(this.m_linearMass, Cdot));\n const oldImpulse = Vec2.clone(this.m_linearImpulse);\n this.m_linearImpulse.add(impulse);\n\n const maxImpulse = h * this.m_maxForce;\n\n this.m_linearImpulse.clamp(maxImpulse);\n\n impulse = Vec2.sub(this.m_linearImpulse, oldImpulse);\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Transform } from \"../../common/Transform\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Mouse joint definition. This requires a world target point, tuning\n * parameters, and the time step.\n */\nexport interface MouseJointOpt extends JointOpt {\n /**\n * [maxForce = 0.0] The maximum constraint force that can be exerted to move\n * the candidate body. Usually you will express as some multiple of the\n * weight (multiplier * mass * gravity).\n */\n maxForce?: number;\n /**\n * [frequencyHz = 5.0] The response speed.\n */\n frequencyHz?: number;\n /**\n * [dampingRatio = 0.7] The damping ratio. 0 = no damping, 1 = critical\n * damping.\n */\n dampingRatio?: number;\n}\n\n/**\n * Mouse joint definition. This requires a world target point, tuning\n * parameters, and the time step.\n */\nexport interface MouseJointDef extends JointDef, MouseJointOpt {\n /**\n * The initial world target point. This is assumed to coincide with the body\n * anchor initially.\n */\n target: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 0.0,\n frequencyHz : 5.0,\n dampingRatio : 0.7\n};\n\ndeclare module \"./MouseJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MouseJoint(def: MouseJointDef): MouseJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MouseJoint(def: MouseJointOpt, bodyA: Body, bodyB: Body, target: Vec2Value): MouseJoint;\n}\n\n/**\n * A mouse joint is used to make a point on a body track a specified world\n * point. This a soft constraint with a maximum force. This allows the\n * constraint to stretch and without applying huge forces.\n *\n * You need to call setTarget(target) every time that mouse is \n * moved, to track the new location of the mouse.\n *\n * NOTE: this joint is not documented in the manual because it was developed to\n * be used in the testbed. If you want to learn how to use the mouse joint, look\n * at the testbed.\n */\n// @ts-expect-error\nexport class MouseJoint extends Joint {\n static TYPE = \"mouse-joint\" as const;\n\n /** @internal */ m_type: \"mouse-joint\";\n /** @internal */ m_targetA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_impulse: Vec2;\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n /** @internal */ m_beta: number;\n /** @internal */ m_gamma: number;\n // Solver temp\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: Mat22;\n /** @internal */ m_C: Vec2;\n\n constructor(def: MouseJointDef);\n constructor(def: MouseJointOpt, bodyA: Body, bodyB: Body, target?: Vec2Value);\n constructor(def: MouseJointDef, bodyA?: Body, bodyB?: Body, target?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof MouseJoint)) {\n return new MouseJoint(def, bodyA, bodyB, target);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = MouseJoint.TYPE;\n\n if (_ASSERT) console.assert(Number.isFinite(def.maxForce) && def.maxForce >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.frequencyHz) && def.frequencyHz >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.dampingRatio) && def.dampingRatio >= 0.0);\n\n if (Vec2.isValid(target)) {\n this.m_targetA = Vec2.clone(target);\n } else if (Vec2.isValid(def.target)) {\n this.m_targetA = Vec2.clone(def.target);\n } else {\n this.m_targetA = Vec2.zero();\n }\n\n this.m_localAnchorB = Transform.mulTVec2(bodyB.getTransform(), this.m_targetA);\n\n this.m_maxForce = def.maxForce;\n this.m_impulse = Vec2.zero();\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_beta = 0.0;\n this.m_gamma = 0.0;\n\n // Solver temp\n this.m_rB = Vec2.zero();\n this.m_localCenterB = Vec2.zero();\n this.m_invMassB = 0.0;\n this.m_invIB = 0.0;\n this.m_mass = new Mat22();\n this.m_C = Vec2.zero();\n\n // p = attached point, m = mouse point\n // C = p - m\n // Cdot = v\n // = v + cross(w, r)\n // J = [I r_skew]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n target: this.m_targetA,\n maxForce: this.m_maxForce,\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n _localAnchorB: this.m_localAnchorB,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): MouseJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.target = Vec2.clone(data.target);\n const joint = new MouseJoint(data);\n if (data._localAnchorB) {\n joint.m_localAnchorB = data._localAnchorB;\n }\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * Use this to update the target point.\n */\n setTarget(target: Vec2Value): void {\n if (Vec2.areEqual(target, this.m_targetA)) return;\n this.m_bodyB.setAwake(true);\n this.m_targetA.set(target);\n }\n\n getTarget(): Vec2 {\n return this.m_targetA;\n }\n\n /**\n * Set the maximum force in Newtons.\n */\n setMaxForce(force: number): void {\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum force in Newtons.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the frequency in Hertz.\n */\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n /**\n * Get the frequency in Hertz.\n */\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set the damping ratio (dimensionless).\n */\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n /**\n * Get the damping ratio (dimensionless).\n */\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return Vec2.clone(this.m_targetA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_impulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * 0.0;\n }\n\n /**\n * Shift the origin for any points stored in world coordinates.\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_targetA.sub(newOrigin);\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const position = this.m_bodyB.c_position;\n const velocity = this.m_bodyB.c_velocity;\n\n const cB = position.c;\n const aB = position.a;\n const vB = velocity.v;\n let wB = velocity.w;\n\n const qB = Rot.neo(aB);\n\n const mass = this.m_bodyB.getMass();\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * mass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = mass * (omega * omega);\n\n // magic formulas\n // gamma has units of inverse mass.\n // beta has units of inverse time.\n const h = step.dt;\n if (_ASSERT) console.assert(d + h * k > EPSILON);\n this.m_gamma = h * (d + h * k);\n if (this.m_gamma != 0.0) {\n this.m_gamma = 1.0 / this.m_gamma;\n }\n this.m_beta = h * k * this.m_gamma;\n\n // Compute the effective mass matrix.\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // K = [(1/m1 + 1/m2) * eye(2) - skew(r1) * invI1 * skew(r1) - skew(r2) *\n // invI2 * skew(r2)]\n // = [1/m1+1/m2 0 ] + invI1 * [r1.y*r1.y -r1.x*r1.y] + invI2 * [r1.y*r1.y\n // -r1.x*r1.y]\n // [ 0 1/m1+1/m2] [-r1.x*r1.y r1.x*r1.x] [-r1.x*r1.y r1.x*r1.x]\n const K = new Mat22();\n K.ex.x = this.m_invMassB + this.m_invIB * this.m_rB.y * this.m_rB.y\n + this.m_gamma;\n K.ex.y = -this.m_invIB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = this.m_invMassB + this.m_invIB * this.m_rB.x * this.m_rB.x\n + this.m_gamma;\n\n this.m_mass = K.getInverse();\n\n this.m_C.setVec2(cB);\n this.m_C.addCombine(1, this.m_rB, -1, this.m_targetA);\n this.m_C.mul(this.m_beta);\n\n // Cheat with some damping\n wB *= 0.98;\n\n if (step.warmStarting) {\n this.m_impulse.mul(step.dtRatio);\n vB.addMul(this.m_invMassB, this.m_impulse);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, this.m_impulse);\n\n } else {\n this.m_impulse.setZero();\n }\n\n velocity.v.setVec2(vB);\n velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const velocity = this.m_bodyB.c_velocity;\n const vB = Vec2.clone(velocity.v);\n let wB = velocity.w;\n\n // Cdot = v + cross(w, r)\n\n const Cdot = Vec2.crossNumVec2(wB, this.m_rB);\n Cdot.add(vB);\n\n Cdot.addCombine(1, this.m_C, this.m_gamma, this.m_impulse);\n Cdot.neg();\n\n let impulse = Mat22.mulVec2(this.m_mass, Cdot);\n\n const oldImpulse = Vec2.clone(this.m_impulse);\n this.m_impulse.add(impulse);\n const maxImpulse = step.dt * this.m_maxForce;\n this.m_impulse.clamp(maxImpulse);\n impulse = Vec2.sub(this.m_impulse, oldImpulse);\n\n vB.addMul(this.m_invMassB, impulse);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n\n velocity.v.setVec2(vB);\n velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n\n\n/**\n * Pulley joint definition. This requires two ground anchors, two dynamic body\n * anchor points, and a pulley ratio.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface PulleyJointOpt extends JointOpt {\n}\n\n/**\n * Pulley joint definition. This requires two ground anchors, two dynamic body\n * anchor points, and a pulley ratio.\n */\nexport interface PulleyJointDef extends JointDef, PulleyJointOpt {\n /**\n * The first ground anchor in world coordinates. This point never moves.\n */\n groundAnchorA: Vec2Value;\n /**\n * The second ground anchor in world coordinates. This point never moves.\n */\n groundAnchorB: Vec2Value;\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The reference length for the segment attached to bodyA.\n */\n lengthA: number;\n /**\n * The reference length for the segment attached to bodyB.\n */\n lengthB: number;\n /**\n * The pulley ratio, used to simulate a block-and-tackle.\n */\n ratio: number;\n\n /** @hidden */ anchorA?: Vec2Value;\n /** @hidden */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n collideConnected : true\n};\n\ndeclare module \"./PulleyJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PulleyJoint(def: PulleyJointDef): PulleyJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PulleyJoint(def: PulleyJointOpt, bodyA: Body, bodyB: Body, groundA: Vec2Value, groundB: Vec2Value, anchorA: Vec2Value, anchorB: Vec2Value, ratio: number): PulleyJoint;\n}\n\n/**\n * The pulley joint is connected to two bodies and two fixed ground points. The\n * pulley supports a ratio such that: length1 + ratio * length2 <= constant\n *\n * Yes, the force transmitted is scaled by the ratio.\n *\n * Warning: the pulley joint can get a bit squirrelly by itself. They often work\n * better when combined with prismatic joints. You should also cover the the\n * anchor points with static shapes to prevent one side from going to zero\n * length.\n */\n// @ts-expect-error\nexport class PulleyJoint extends Joint {\n static TYPE = \"pulley-joint\" as const;\n // static MIN_PULLEY_LENGTH: number = 2.0; // TODO where this is used?\n\n /** @internal */ m_type: \"pulley-joint\";\n /** @internal */ m_groundAnchorA: Vec2;\n /** @internal */ m_groundAnchorB: Vec2;\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_lengthA: number;\n /** @internal */ m_lengthB: number;\n /** @internal */ m_ratio: number;\n /** @internal */ m_constant: number;\n /** @internal */ m_impulse: number;\n\n // Solver temp\n /** @internal */ m_uA: Vec2;\n /** @internal */ m_uB: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: number;\n\n constructor(def: PulleyJointDef);\n constructor(def: PulleyJointOpt, bodyA: Body, bodyB: Body, groundA?: Vec2Value, groundB?: Vec2Value, anchorA?: Vec2Value, anchorB?: Vec2Value, ratio?: number);\n constructor(def: PulleyJointDef, bodyA?: Body, bodyB?: Body, groundA?: Vec2Value, groundB?: Vec2Value, anchorA?: Vec2Value, anchorB?: Vec2Value, ratio?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PulleyJoint)) {\n return new PulleyJoint(def, bodyA, bodyB, groundA, groundB, anchorA, anchorB, ratio);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = PulleyJoint.TYPE;\n this.m_groundAnchorA = Vec2.clone(groundA ? groundA : def.groundAnchorA || Vec2.neo(-1.0, 1.0));\n this.m_groundAnchorB = Vec2.clone(groundB ? groundB : def.groundAnchorB || Vec2.neo(1.0, 1.0));\n this.m_localAnchorA = Vec2.clone(anchorA ? bodyA.getLocalPoint(anchorA) : def.localAnchorA || Vec2.neo(-1.0, 0.0));\n this.m_localAnchorB = Vec2.clone(anchorB ? bodyB.getLocalPoint(anchorB) : def.localAnchorB || Vec2.neo(1.0, 0.0));\n this.m_lengthA = Number.isFinite(def.lengthA) ? def.lengthA : Vec2.distance(anchorA, groundA);\n this.m_lengthB = Number.isFinite(def.lengthB) ? def.lengthB : Vec2.distance(anchorB, groundB);\n this.m_ratio = Number.isFinite(ratio) ? ratio : def.ratio;\n\n if (_ASSERT) console.assert(ratio > EPSILON);\n\n this.m_constant = this.m_lengthA + this.m_ratio * this.m_lengthB;\n\n this.m_impulse = 0.0;\n\n // Pulley:\n // length1 = norm(p1 - s1)\n // length2 = norm(p2 - s2)\n // C0 = (length1 + ratio * length2)_initial\n // C = C0 - (length1 + ratio * length2)\n // u1 = (p1 - s1) / norm(p1 - s1)\n // u2 = (p2 - s2) / norm(p2 - s2)\n // Cdot = -dot(u1, v1 + cross(w1, r1)) - ratio * dot(u2, v2 + cross(w2, r2))\n // J = -[u1 cross(r1, u1) ratio * u2 ratio * cross(r2, u2)]\n // K = J * invM * JT\n // = invMass1 + invI1 * cross(r1, u1)^2 + ratio^2 * (invMass2 + invI2 *\n // cross(r2, u2)^2)\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n groundAnchorA: this.m_groundAnchorA,\n groundAnchorB: this.m_groundAnchorB,\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n lengthA: this.m_lengthA,\n lengthB: this.m_lengthB,\n ratio: this.m_ratio,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): PulleyJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new PulleyJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Vec2.isValid(def.groundAnchorA)) {\n this.m_groundAnchorA.set(def.groundAnchorA);\n }\n if (Vec2.isValid(def.groundAnchorB)) {\n this.m_groundAnchorB.set(def.groundAnchorB);\n }\n if (Vec2.isValid(def.localAnchorA)) {\n this.m_localAnchorA.set(def.localAnchorA);\n } else if (Vec2.isValid(def.anchorA)) {\n this.m_localAnchorA.set(this.m_bodyA.getLocalPoint(def.anchorA));\n }\n if (Vec2.isValid(def.localAnchorB)) {\n this.m_localAnchorB.set(def.localAnchorB);\n } else if (Vec2.isValid(def.anchorB)) {\n this.m_localAnchorB.set(this.m_bodyB.getLocalPoint(def.anchorB));\n }\n if (Number.isFinite(def.lengthA)) {\n this.m_lengthA = def.lengthA;\n }\n if (Number.isFinite(def.lengthB)) {\n this.m_lengthB = def.lengthB;\n }\n if (Number.isFinite(def.ratio)) {\n this.m_ratio = def.ratio;\n }\n }\n\n /**\n * Get the first ground anchor.\n */\n getGroundAnchorA(): Vec2 {\n return this.m_groundAnchorA;\n }\n\n /**\n * Get the second ground anchor.\n */\n getGroundAnchorB(): Vec2 {\n return this.m_groundAnchorB;\n }\n\n /**\n * Get the current length of the segment attached to bodyA.\n */\n getLengthA(): number {\n return this.m_lengthA;\n }\n\n /**\n * Get the current length of the segment attached to bodyB.\n */\n getLengthB(): number {\n return this.m_lengthB;\n }\n\n /**\n * Get the pulley ratio.\n */\n getRatio(): number {\n return this.m_ratio;\n }\n\n /**\n * Get the current length of the segment attached to bodyA.\n */\n getCurrentLengthA(): number {\n const p = this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n const s = this.m_groundAnchorA;\n return Vec2.distance(p, s);\n }\n\n /**\n * Get the current length of the segment attached to bodyB.\n */\n getCurrentLengthB(): number {\n const p = this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n const s = this.m_groundAnchorB;\n return Vec2.distance(p, s);\n }\n\n /**\n * Shift the origin for any points stored in world coordinates.\n *\n * @param newOrigin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_groundAnchorA.sub(newOrigin);\n this.m_groundAnchorB.sub(newOrigin);\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_uB).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // Get the pulley axes.\n this.m_uA = Vec2.sub(Vec2.add(cA, this.m_rA), this.m_groundAnchorA);\n this.m_uB = Vec2.sub(Vec2.add(cB, this.m_rB), this.m_groundAnchorB);\n\n const lengthA = this.m_uA.length();\n const lengthB = this.m_uB.length();\n\n if (lengthA > 10.0 * Settings.linearSlop) {\n this.m_uA.mul(1.0 / lengthA);\n } else {\n this.m_uA.setZero();\n }\n\n if (lengthB > 10.0 * Settings.linearSlop) {\n this.m_uB.mul(1.0 / lengthB);\n } else {\n this.m_uB.setZero();\n }\n\n // Compute effective mass.\n const ruA = Vec2.crossVec2Vec2(this.m_rA, this.m_uA);\n const ruB = Vec2.crossVec2Vec2(this.m_rB, this.m_uB);\n\n const mA = this.m_invMassA + this.m_invIA * ruA * ruA;\n const mB = this.m_invMassB + this.m_invIB * ruB * ruB;\n\n this.m_mass = mA + this.m_ratio * this.m_ratio * mB;\n\n if (this.m_mass > 0.0) {\n this.m_mass = 1.0 / this.m_mass;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support variable time steps.\n this.m_impulse *= step.dtRatio;\n\n // Warm starting.\n const PA = Vec2.mulNumVec2(-this.m_impulse, this.m_uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * this.m_impulse, this.m_uB);\n\n vA.addMul(this.m_invMassA, PA);\n wA += this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, PA);\n\n vB.addMul(this.m_invMassB, PB);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, PB);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const vpA = Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA));\n const vpB = Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB));\n\n const Cdot = -Vec2.dot(this.m_uA, vpA) - this.m_ratio * Vec2.dot(this.m_uB, vpB);\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n const PA = Vec2.mulNumVec2(-impulse, this.m_uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * impulse, this.m_uB);\n vA.addMul(this.m_invMassA, PA);\n wA += this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, PA);\n vB.addMul(this.m_invMassB, PB);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, PB);\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // Get the pulley axes.\n const uA = Vec2.sub(Vec2.add(cA, this.m_rA), this.m_groundAnchorA);\n const uB = Vec2.sub(Vec2.add(cB, this.m_rB), this.m_groundAnchorB);\n\n const lengthA = uA.length();\n const lengthB = uB.length();\n\n if (lengthA > 10.0 * Settings.linearSlop) {\n uA.mul(1.0 / lengthA);\n } else {\n uA.setZero();\n }\n\n if (lengthB > 10.0 * Settings.linearSlop) {\n uB.mul(1.0 / lengthB);\n } else {\n uB.setZero();\n }\n\n // Compute effective mass.\n const ruA = Vec2.crossVec2Vec2(rA, uA);\n const ruB = Vec2.crossVec2Vec2(rB, uB);\n\n const mA = this.m_invMassA + this.m_invIA * ruA * ruA;\n const mB = this.m_invMassB + this.m_invIB * ruB * ruB;\n\n let mass = mA + this.m_ratio * this.m_ratio * mB;\n\n if (mass > 0.0) {\n mass = 1.0 / mass;\n }\n\n const C = this.m_constant - lengthA - this.m_ratio * lengthB;\n const linearError = math_abs(C);\n\n const impulse = -mass * C;\n\n const PA = Vec2.mulNumVec2(-impulse, uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * impulse, uB);\n\n cA.addMul(this.m_invMassA, PA);\n aA += this.m_invIA * Vec2.crossVec2Vec2(rA, PA);\n cB.addMul(this.m_invMassB, PB);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, PB);\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return linearError < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_min = Math.min;\n\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3,\n}\n\n/**\n * Rope joint definition. This requires two body anchor points and a maximum\n * lengths. Note: by default the connected objects will not collide. see\n * collideConnected in JointDef.\n */\nexport interface RopeJointOpt extends JointOpt {\n /**\n * The maximum length of the rope.\n * Warning: this must be larger than linearSlop or the joint will have no effect.\n */\n maxLength?: number;\n}\n\n/**\n * Rope joint definition. This requires two body anchor points and a maximum\n * lengths. Note: by default the connected objects will not collide. see\n * collideConnected in JointDef.\n */\nexport interface RopeJointDef extends JointDef, RopeJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxLength : 0.0,\n};\n\ndeclare module \"./RopeJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RopeJoint(def: RopeJointDef): RopeJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RopeJoint(def: RopeJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): RopeJoint;\n}\n\n/**\n * A rope joint enforces a maximum distance between two points on two bodies. It\n * has no other effect.\n *\n * Warning: if you attempt to change the maximum length during the simulation\n * you will get some non-physical behavior.\n *\n * A model that would allow you to dynamically modify the length would have some\n * sponginess, so I chose not to implement it that way. See {@link DistanceJoint} if you\n * want to dynamically control length.\n */\n// @ts-expect-error\nexport class RopeJoint extends Joint {\n static TYPE = \"rope-joint\" as const;\n\n /** @internal */ m_type: \"rope-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n\n /** @internal */ m_maxLength: number;\n\n /** @internal */ m_mass: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_length: number;\n /** @internal */ m_state: number; // TODO enum\n\n // Solver temp\n /** @internal */ m_u: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n\n constructor(def: RopeJointDef);\n constructor(def: RopeJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: RopeJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof RopeJoint)) {\n return new RopeJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = RopeJoint.TYPE;\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.neo(-1.0, 0.0));\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.neo(1.0, 0.0));\n\n this.m_maxLength = def.maxLength;\n\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n this.m_length = 0.0;\n this.m_state = LimitState.inactiveLimit;\n\n // Limit:\n // C = norm(pB - pA) - L\n // u = (pB - pA) / norm(pB - pA)\n // Cdot = dot(u, vB + cross(wB, rB) - vA - cross(wA, rA))\n // J = [-u -cross(rA, u) u cross(rB, u)]\n // K = J * invM * JT\n // = invMassA + invIA * cross(rA, u)^2 + invMassB + invIB * cross(rB, u)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n maxLength: this.m_maxLength,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): RopeJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new RopeJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.maxLength)) {\n this.m_maxLength = def.maxLength;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the maximum length of the rope.\n */\n setMaxLength(length: number): void {\n this.m_maxLength = length;\n }\n\n /**\n * Get the maximum length of the rope.\n */\n getMaxLength(): number {\n return this.m_maxLength;\n }\n\n getLimitState(): number {\n // TODO LimitState\n return this.m_state;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_u).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n this.m_rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n this.m_u = Vec2.zero();\n this.m_u.addCombine(1, cB, 1, this.m_rB);\n this.m_u.subCombine(1, cA, 1, this.m_rA);\n\n this.m_length = this.m_u.length();\n\n const C = this.m_length - this.m_maxLength;\n if (C > 0.0) {\n this.m_state = LimitState.atUpperLimit;\n } else {\n this.m_state = LimitState.inactiveLimit;\n }\n\n if (this.m_length > Settings.linearSlop) {\n this.m_u.mul(1.0 / this.m_length);\n } else {\n this.m_u.setZero();\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n return;\n }\n\n // Compute effective mass.\n const crA = Vec2.crossVec2Vec2(this.m_rA, this.m_u);\n const crB = Vec2.crossVec2Vec2(this.m_rB, this.m_u);\n const invMass = this.m_invMassA + this.m_invIA * crA * crA + this.m_invMassB + this.m_invIB * crB * crB;\n\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n\n if (step.warmStarting) {\n // Scale the impulse to support a variable time step.\n this.m_impulse *= step.dtRatio;\n\n const P = Vec2.mulNumVec2(this.m_impulse, this.m_u);\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Cdot = dot(u, v + cross(w, r))\n const vpA = Vec2.addCrossNumVec2(vA, wA, this.m_rA);\n const vpB = Vec2.addCrossNumVec2(vB, wB, this.m_rB);\n const C = this.m_length - this.m_maxLength;\n let Cdot = Vec2.dot(this.m_u, Vec2.sub(vpB, vpA));\n\n // Predictive constraint.\n if (C < 0.0) {\n Cdot += step.inv_dt * C;\n }\n\n let impulse = -this.m_mass * Cdot;\n const oldImpulse = this.m_impulse;\n this.m_impulse = math_min(0.0, this.m_impulse + impulse);\n impulse = this.m_impulse - oldImpulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_u);\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n const u = Vec2.zero();\n u.addCombine(1, cB, 1, rB);\n u.subCombine(1, cA, 1, rA);\n\n const length = u.normalize();\n let C = length - this.m_maxLength;\n\n C = clamp(C, 0.0, Settings.maxLinearCorrection);\n\n const impulse = -this.m_mass * C;\n const P = Vec2.mulNumVec2(impulse, u);\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * Vec2.crossVec2Vec2(rA, P);\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, P);\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return length - this.m_maxLength < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Weld joint definition. You need to specify local anchor points where they are\n * attached and the relative body angle. The position of the anchor points is\n * important for computing the reaction torque.\n */\nexport interface WeldJointOpt extends JointOpt {\n /**\n * The mass-spring-damper frequency in Hertz. Rotation only. Disable softness\n * with a value of 0.\n */\n frequencyHz?: number;\n /**\n * The damping ratio. 0 = no damping, 1 = critical damping.\n */\n dampingRatio?: number;\n /**\n * The bodyB angle minus bodyA angle in the reference state (radians).\n */\n referenceAngle?: number;\n}\n\n/**\n * Weld joint definition. You need to specify local anchor points where they are\n * attached and the relative body angle. The position of the anchor points is\n * important for computing the reaction torque.\n */\nexport interface WeldJointDef extends JointDef, WeldJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n frequencyHz : 0.0,\n dampingRatio : 0.0,\n};\n\ndeclare module \"./WeldJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WeldJoint(def: WeldJointDef): WeldJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WeldJoint(def: WeldJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): WeldJoint;\n}\n\n/**\n * A weld joint essentially glues two bodies together. A weld joint may distort\n * somewhat because the island constraint solver is approximate.\n */\n// @ts-expect-error\nexport class WeldJoint extends Joint {\n static TYPE = \"weld-joint\" as const;\n\n /** @internal */ m_type: \"weld-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngle: number;\n\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n\n /** @internal */ m_impulse: Vec3;\n\n /** @internal */ m_bias: number;\n /** @internal */ m_gamma: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: Mat33;\n\n constructor(def: WeldJointDef);\n constructor(def: WeldJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: WeldJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof WeldJoint)) {\n return new WeldJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = WeldJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n this.m_referenceAngle = Number.isFinite(def.referenceAngle) ? def.referenceAngle : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_impulse = new Vec3();\n\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n\n // Solver temp\n // todo: do we need to initialize?\n // this.m_rA;\n // this.m_rB;\n // this.m_localCenterA;\n // this.m_localCenterB;\n // this.m_invMassA;\n // this.m_invMassB;\n // this.m_invIA;\n // this.m_invIB;\n this.m_mass = new Mat33();\n\n // Point-to-point constraint\n // C = p2 - p1\n // Cdot = v2 - v1\n // / = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Angle constraint\n // C = angle2 - angle1 - referenceAngle\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): WeldJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new WeldJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Set frequency in Hz.\n */\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n /**\n * Get frequency in Hz.\n */\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set damping ratio.\n */\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n /**\n * Get damping ratio.\n */\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.neo(this.m_impulse.x, this.m_impulse.y).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.z;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat33();\n K.ex.x = mA + mB + this.m_rA.y * this.m_rA.y * iA + this.m_rB.y * this.m_rB.y\n * iB;\n K.ey.x = -this.m_rA.y * this.m_rA.x * iA - this.m_rB.y * this.m_rB.x * iB;\n K.ez.x = -this.m_rA.y * iA - this.m_rB.y * iB;\n K.ex.y = K.ey.x;\n K.ey.y = mA + mB + this.m_rA.x * this.m_rA.x * iA + this.m_rB.x * this.m_rB.x\n * iB;\n K.ez.y = this.m_rA.x * iA + this.m_rB.x * iB;\n K.ex.z = K.ez.x;\n K.ey.z = K.ez.y;\n K.ez.z = iA + iB;\n\n if (this.m_frequencyHz > 0.0) {\n K.getInverse22(this.m_mass);\n\n let invM = iA + iB;\n const m = invM > 0.0 ? 1.0 / invM : 0.0;\n\n const C = aB - aA - this.m_referenceAngle;\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * m * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = m * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (d + h * k);\n this.m_gamma = this.m_gamma != 0.0 ? 1.0 / this.m_gamma : 0.0;\n this.m_bias = C * h * k * this.m_gamma;\n\n invM += this.m_gamma;\n this.m_mass.ez.z = invM != 0.0 ? 1.0 / invM : 0.0;\n } else if (K.ez.z == 0.0) {\n K.getInverse22(this.m_mass);\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n } else {\n K.getSymInverse33(this.m_mass);\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_impulse.mul(step.dtRatio);\n\n const P = Vec2.neo(this.m_impulse.x, this.m_impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_impulse.z);\n\n } else {\n this.m_impulse.setZero();\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n if (this.m_frequencyHz > 0.0) {\n const Cdot2 = wB - wA;\n\n const impulse2 = -this.m_mass.ez.z * (Cdot2 + this.m_bias + this.m_gamma * this.m_impulse.z);\n this.m_impulse.z += impulse2;\n\n wA -= iA * impulse2;\n wB += iB * impulse2;\n\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n\n const impulse1 = Vec2.neg(Mat33.mulVec2(this.m_mass, Cdot1));\n this.m_impulse.x += impulse1.x;\n this.m_impulse.y += impulse1.y;\n\n const P = Vec2.clone(impulse1);\n\n vA.subMul(mA, P);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(mB, P);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, P);\n } else {\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const Cdot2 = wB - wA;\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const impulse = Vec3.neg(Mat33.mulVec3(this.m_mass, Cdot));\n this.m_impulse.add(impulse);\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + impulse.z);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n let positionError: number;\n let angularError: number;\n\n const K = new Mat33();\n K.ex.x = mA + mB + rA.y * rA.y * iA + rB.y * rB.y * iB;\n K.ey.x = -rA.y * rA.x * iA - rB.y * rB.x * iB;\n K.ez.x = -rA.y * iA - rB.y * iB;\n K.ex.y = K.ey.x;\n K.ey.y = mA + mB + rA.x * rA.x * iA + rB.x * rB.x * iB;\n K.ez.y = rA.x * iA + rB.x * iB;\n K.ex.z = K.ez.x;\n K.ey.z = K.ez.y;\n K.ez.z = iA + iB;\n\n if (this.m_frequencyHz > 0.0) {\n const C1 = Vec2.zero();\n C1.addCombine(1, cB, 1, rB);\n C1.subCombine(1, cA, 1, rA);\n\n positionError = C1.length();\n angularError = 0.0;\n\n const P = Vec2.neg(K.solve22(C1));\n\n cA.subMul(mA, P);\n aA -= iA * Vec2.crossVec2Vec2(rA, P);\n\n cB.addMul(mB, P);\n aB += iB * Vec2.crossVec2Vec2(rB, P);\n } else {\n const C1 = Vec2.zero();\n C1.addCombine(1, cB, 1, rB);\n C1.subCombine(1, cA, 1, rA);\n\n const C2 = aB - aA - this.m_referenceAngle;\n\n positionError = C1.length();\n angularError = math_abs(C2);\n\n const C = new Vec3(C1.x, C1.y, C2);\n\n let impulse = new Vec3();\n if (K.ez.z > 0.0) {\n impulse = Vec3.neg(K.solve33(C));\n } else {\n const impulse2 = Vec2.neg(K.solve22(C1));\n impulse.set(impulse2.x, impulse2.y, 0.0);\n }\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n cA.subMul(mA, P);\n aA -= iA * (Vec2.crossVec2Vec2(rA, P) + impulse.z);\n\n cB.addMul(mB, P);\n aB += iB * (Vec2.crossVec2Vec2(rB, P) + impulse.z);\n }\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return positionError <= Settings.linearSlop && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Wheel joint definition. This requires defining a line of motion using an axis\n * and an anchor point. The definition uses local anchor points and a local axis\n * so that the initial configuration can violate the constraint slightly. The\n * joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface WheelJointOpt extends JointOpt {\n /**\n * Enable/disable the joint motor.\n */\n enableMotor?: boolean;\n /**\n * The maximum motor torque, usually in N-m.\n */\n maxMotorTorque?: number;\n /**\n * The desired motor speed in radians per second.\n */\n motorSpeed?: number;\n /**\n * Suspension frequency, zero indicates no suspension.\n */\n frequencyHz?: number;\n /**\n * Suspension damping ratio, one indicates critical damping.\n */\n dampingRatio?: number;\n}\n\n/**\n * Wheel joint definition. This requires defining a line of motion using an axis\n * and an anchor point. The definition uses local anchor points and a local axis\n * so that the initial configuration can violate the constraint slightly. The\n * joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface WheelJointDef extends JointDef, WheelJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The local translation axis in bodyA.\n */\n localAxisA: Vec2Value;\n\n /** @internal renamed to localAxisA */\n localAxis?: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n enableMotor : false,\n maxMotorTorque : 0.0,\n motorSpeed : 0.0,\n frequencyHz : 2.0,\n dampingRatio : 0.7,\n};\n\ndeclare module \"./WheelJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WheelJoint(def: WheelJointDef): WheelJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WheelJoint(def: WheelJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value, axis: Vec2Value): WheelJoint;\n}\n\n/**\n * A wheel joint. This joint provides two degrees of freedom: translation along\n * an axis fixed in bodyA and rotation in the plane. In other words, it is a\n * point to line constraint with a rotational motor and a linear spring/damper.\n * This joint is designed for vehicle suspensions.\n */\n// @ts-expect-error\nexport class WheelJoint extends Joint {\n static TYPE = \"wheel-joint\" as const;\n\n /** @internal */ m_type: \"wheel-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_localXAxisA: Vec2;\n /** @internal */ m_localYAxisA: Vec2;\n\n /** @internal */ m_mass: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_motorMass: number;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_springMass: number;\n /** @internal */ m_springImpulse: number;\n\n /** @internal */ m_maxMotorTorque: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableMotor: boolean;\n\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n\n /** @internal */ m_bias: number;\n /** @internal */ m_gamma: number;\n\n // Solver temp\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n\n /** @internal */ m_ax: Vec2;\n /** @internal */ m_ay: Vec2;\n /** @internal */ m_sAx: number;\n /** @internal */ m_sBx: number;\n /** @internal */ m_sAy: number;\n /** @internal */ m_sBy: number;\n\n constructor(def: WheelJointDef);\n constructor(def: WheelJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value, axis?: Vec2Value);\n constructor(def: WheelJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value, axis?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof WheelJoint)) {\n return new WheelJoint(def, bodyA, bodyB, anchor, axis);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_ax = Vec2.zero();\n this.m_ay = Vec2.zero();\n\n this.m_type = WheelJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n\n if (Vec2.isValid(axis)) {\n this.m_localXAxisA = bodyA.getLocalVector(axis);\n } else if (Vec2.isValid(def.localAxisA)) {\n this.m_localXAxisA = Vec2.clone(def.localAxisA);\n } else if (Vec2.isValid(def.localAxis)) {\n // localAxis is renamed to localAxisA, this is for backward compatibility\n this.m_localXAxisA = Vec2.clone(def.localAxis);\n } else {\n this.m_localXAxisA = Vec2.neo(1.0, 0.0);\n }\n\n this.m_localYAxisA = Vec2.crossNumVec2(1.0, this.m_localXAxisA);\n\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n this.m_springMass = 0.0;\n this.m_springImpulse = 0.0;\n\n this.m_maxMotorTorque = def.maxMotorTorque;\n this.m_motorSpeed = def.motorSpeed;\n this.m_enableMotor = def.enableMotor;\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n\n // Linear constraint (point-to-line)\n // d = pB - pA = xB + rB - xA - rA\n // C = dot(ay, d)\n // Cdot = dot(d, cross(wA, ay)) + dot(ay, vB + cross(wB, rB) - vA - cross(wA,\n // rA))\n // = -dot(ay, vA) - dot(cross(d + rA, ay), wA) + dot(ay, vB) + dot(cross(rB,\n // ay), vB)\n // J = [-ay, -cross(d + rA, ay), ay, cross(rB, ay)]\n\n // Spring linear constraint\n // C = dot(ax, d)\n // Cdot = = -dot(ax, vA) - dot(cross(d + rA, ax), wA) + dot(ax, vB) +\n // dot(cross(rB, ax), vB)\n // J = [-ax -cross(d+rA, ax) ax cross(rB, ax)]\n\n // Motor rotational constraint\n // Cdot = wB - wA\n // J = [0 0 -1 0 0 1]\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n enableMotor: this.m_enableMotor,\n maxMotorTorque: this.m_maxMotorTorque,\n motorSpeed: this.m_motorSpeed,\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n localAxisA: this.m_localXAxisA,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): WheelJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new WheelJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (def.localAxisA) {\n this.m_localXAxisA.setVec2(def.localAxisA);\n this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1.0, def.localAxisA));\n }\n if (def.enableMotor !== undefined) {\n this.m_enableMotor = def.enableMotor;\n }\n if (Number.isFinite(def.maxMotorTorque)) {\n this.m_maxMotorTorque = def.maxMotorTorque;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * The local joint axis relative to bodyA.\n */\n getLocalAxisA(): Vec2 {\n return this.m_localXAxisA;\n }\n\n /**\n * Get the current joint translation, usually in meters.\n */\n getJointTranslation(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n\n const pA = bA.getWorldPoint(this.m_localAnchorA);\n const pB = bB.getWorldPoint(this.m_localAnchorB);\n const d = Vec2.sub(pB, pA);\n const axis = bA.getWorldVector(this.m_localXAxisA);\n\n const translation = Vec2.dot(d, axis);\n return translation;\n }\n\n /**\n * Get the current joint translation speed, usually in meters per second.\n */\n getJointSpeed(): number {\n const wA = this.m_bodyA.m_angularVelocity;\n const wB = this.m_bodyB.m_angularVelocity;\n return wB - wA;\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Set the motor speed, usually in radians per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Get the motor speed, usually in radians per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Set/Get the maximum motor force, usually in N-m.\n */\n setMaxMotorTorque(torque: number): void {\n if (torque == this.m_maxMotorTorque) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorTorque = torque;\n }\n\n getMaxMotorTorque(): number {\n return this.m_maxMotorTorque;\n }\n\n /**\n * Get the current motor torque given the inverse time step, usually in N-m.\n */\n getMotorTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Set/Get the spring frequency in hertz. Setting the frequency to zero disables\n * the spring.\n */\n setSpringFrequencyHz(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n getSpringFrequencyHz(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set/Get the spring damping ratio\n */\n setSpringDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n getSpringDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.combine(this.m_impulse, this.m_ay, this.m_springImpulse, this.m_ax).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective masses.\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n // Point to line constraint\n {\n this.m_ay = Rot.mulVec2(qA, this.m_localYAxisA);\n this.m_sAy = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_ay);\n this.m_sBy = Vec2.crossVec2Vec2(rB, this.m_ay);\n\n this.m_mass = mA + mB + iA * this.m_sAy * this.m_sAy + iB * this.m_sBy\n * this.m_sBy;\n\n if (this.m_mass > 0.0) {\n this.m_mass = 1.0 / this.m_mass;\n }\n }\n\n // Spring constraint\n this.m_springMass = 0.0;\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n if (this.m_frequencyHz > 0.0) {\n this.m_ax = Rot.mulVec2(qA, this.m_localXAxisA);\n this.m_sAx = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_ax);\n this.m_sBx = Vec2.crossVec2Vec2(rB, this.m_ax);\n\n const invMass = mA + mB + iA * this.m_sAx * this.m_sAx + iB * this.m_sBx\n * this.m_sBx;\n\n if (invMass > 0.0) {\n this.m_springMass = 1.0 / invMass;\n\n const C = Vec2.dot(d, this.m_ax);\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const damp = 2.0 * this.m_springMass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = this.m_springMass * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (damp + h * k);\n if (this.m_gamma > 0.0) {\n this.m_gamma = 1.0 / this.m_gamma;\n }\n\n this.m_bias = C * h * k * this.m_gamma;\n\n this.m_springMass = invMass + this.m_gamma;\n if (this.m_springMass > 0.0) {\n this.m_springMass = 1.0 / this.m_springMass;\n }\n }\n } else {\n this.m_springImpulse = 0.0;\n }\n\n // Rotational motor\n if (this.m_enableMotor) {\n this.m_motorMass = iA + iB;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n } else {\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n }\n\n if (step.warmStarting) {\n // Account for variable time step.\n this.m_impulse *= step.dtRatio;\n this.m_springImpulse *= step.dtRatio;\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.combine(this.m_impulse, this.m_ay, this.m_springImpulse, this.m_ax);\n const LA = this.m_impulse * this.m_sAy + this.m_springImpulse * this.m_sAx + this.m_motorImpulse;\n const LB = this.m_impulse * this.m_sBy + this.m_springImpulse * this.m_sBx + this.m_motorImpulse;\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * LA;\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * LB;\n\n } else {\n this.m_impulse = 0.0;\n this.m_springImpulse = 0.0;\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Solve spring constraint\n {\n const Cdot = Vec2.dot(this.m_ax, vB) - Vec2.dot(this.m_ax, vA) + this.m_sBx * wB - this.m_sAx * wA;\n const impulse = -this.m_springMass * (Cdot + this.m_bias + this.m_gamma * this.m_springImpulse);\n this.m_springImpulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_ax);\n const LA = impulse * this.m_sAx;\n const LB = impulse * this.m_sBx;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n // Solve rotational motor constraint\n {\n const Cdot = wB - wA - this.m_motorSpeed;\n let impulse = -this.m_motorMass * Cdot;\n\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorTorque;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve point to line constraint\n {\n const Cdot = Vec2.dot(this.m_ay, vB) - Vec2.dot(this.m_ay, vA) + this.m_sBy * wB - this.m_sAy * wA;\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_ay);\n const LA = impulse * this.m_sAy;\n const LB = impulse * this.m_sBy;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n const ay = Rot.mulVec2(qA, this.m_localYAxisA);\n\n const sAy = Vec2.crossVec2Vec2(Vec2.add(d, rA), ay);\n const sBy = Vec2.crossVec2Vec2(rB, ay);\n\n const C = Vec2.dot(d, ay);\n\n const k = this.m_invMassA + this.m_invMassB + this.m_invIA * this.m_sAy * this.m_sAy + this.m_invIB * this.m_sBy * this.m_sBy;\n\n const impulse = k != 0.0 ? -C / k : 0.0;\n\n const P = Vec2.mulNumVec2(impulse, ay);\n const LA = impulse * sAy;\n const LB = impulse * sBy;\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * LA;\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * LB;\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return math_abs(C) <= Settings.linearSlop;\n }\n\n}\n","import { World } from \"../dynamics/World\";\nimport { Body } from \"../dynamics/Body\";\nimport { Joint } from \"../dynamics/Joint\";\nimport { Fixture } from \"../dynamics/Fixture\";\nimport { Shape } from \"../collision/Shape\";\nimport { Vec2 } from \"../common/Vec2\";\nimport { Vec3 } from \"../common/Vec3\";\nimport { ChainShape } from \"../collision/shape/ChainShape\";\n// import { BoxShape } from \"../collision/shape/BoxShape\";\nimport { EdgeShape } from \"../collision/shape/EdgeShape\";\nimport { PolygonShape } from \"../collision/shape/PolygonShape\";\nimport { CircleShape } from \"../collision/shape/CircleShape\";\nimport { DistanceJoint } from \"../dynamics/joint/DistanceJoint\";\nimport { FrictionJoint } from \"../dynamics/joint/FrictionJoint\";\nimport { GearJoint } from \"../dynamics/joint/GearJoint\";\nimport { MotorJoint } from \"../dynamics/joint/MotorJoint\";\nimport { MouseJoint } from \"../dynamics/joint/MouseJoint\";\nimport { PrismaticJoint } from \"../dynamics/joint/PrismaticJoint\";\nimport { PulleyJoint } from \"../dynamics/joint/PulleyJoint\";\nimport { RevoluteJoint } from \"../dynamics/joint/RevoluteJoint\";\nimport { RopeJoint } from \"../dynamics/joint/RopeJoint\";\nimport { WeldJoint } from \"../dynamics/joint/WeldJoint\";\nimport { WheelJoint } from \"../dynamics/joint/WheelJoint\";\n\nlet SID = 0;\n\n// Classes to be serialized as reference objects\nconst SERIALIZE_REF_TYPES = {\n \"World\": World,\n \"Body\": Body,\n \"Joint\": Joint,\n \"Fixture\": Fixture,\n \"Shape\": Shape,\n};\n\n// For deserializing reference objects by reference type\nconst DESERIALIZE_BY_REF_TYPE = {\n \"Vec2\": Vec2,\n \"Vec3\": Vec3,\n \"World\": World,\n \"Body\": Body,\n \"Joint\": Joint,\n \"Fixture\": Fixture,\n \"Shape\": Shape,\n};\n\n// For deserializing data objects by type field\nconst DESERIALIZE_BY_TYPE_FIELD = {\n [Body.STATIC]: Body,\n [Body.DYNAMIC]: Body,\n [Body.KINEMATIC]: Body,\n [ChainShape.TYPE]: ChainShape,\n // [BoxShape.TYPE]: BoxShape,\n [PolygonShape.TYPE]: PolygonShape,\n [EdgeShape.TYPE]: EdgeShape,\n [CircleShape.TYPE]: CircleShape,\n [DistanceJoint.TYPE]: DistanceJoint,\n [FrictionJoint.TYPE]: FrictionJoint,\n [GearJoint.TYPE]: GearJoint,\n [MotorJoint.TYPE]: MotorJoint,\n [MouseJoint.TYPE]: MouseJoint,\n [PrismaticJoint.TYPE]: PrismaticJoint,\n [PulleyJoint.TYPE]: PulleyJoint,\n [RevoluteJoint.TYPE]: RevoluteJoint,\n [RopeJoint.TYPE]: RopeJoint,\n [WeldJoint.TYPE]: WeldJoint,\n [WheelJoint.TYPE]: WheelJoint,\n};\n\n// dummy types\ntype DataType = any;\ntype ObjectType = any;\ntype ClassName = any;\n\ntype SerializedType = object[];\n\ntype RefType = {\n refIndex: number,\n refType: string,\n};\n\ntype SerializerOptions = {\n rootClass: ClassName,\n preSerialize?: (obj: ObjectType) => DataType,\n postSerialize?: (data: DataType, obj: any) => DataType,\n preDeserialize?: (data: DataType) => DataType,\n postDeserialize?: (obj: ObjectType, data: DataType) => ObjectType,\n};\n\nconst DEFAULT_OPTIONS: SerializerOptions = {\n rootClass: World,\n preSerialize: function(obj) { return obj; },\n postSerialize: function(data, obj) { return data; },\n preDeserialize: function(data: DataType) { return data; },\n postDeserialize: function(obj, data) { return obj; },\n};\n\ntype DeserializeChildCallback = (classHint: any, obj: any, context: any) => any;\ntype ClassDeserializerMethod = (data: any, context: any, deserialize: DeserializeChildCallback) => any;\n\nexport class Serializer {\n private options: SerializerOptions;\n constructor(options: SerializerOptions) {\n this.options = {\n ...DEFAULT_OPTIONS,\n ...options,\n };\n }\n\n toJson = (root: T): SerializedType => {\n const preSerialize = this.options.preSerialize;\n const postSerialize = this.options.postSerialize;\n const json = [];\n\n // Breadth-first ref serialization queue\n const refQueue = [root];\n\n const refMemoById: Record = {};\n\n function addToRefQueue(value: any, typeName: string) {\n value.__sid = value.__sid || ++SID;\n if (!refMemoById[value.__sid]) {\n refQueue.push(value);\n const index = json.length + refQueue.length;\n const ref = {\n refIndex: index,\n refType: typeName\n };\n refMemoById[value.__sid] = ref;\n }\n return refMemoById[value.__sid];\n }\n\n function serializeWithHooks(obj: ObjectType) {\n obj = preSerialize(obj);\n let data = obj._serialize();\n data = postSerialize(data, obj);\n return data;\n }\n\n // traverse the object graph\n // ref objects are pushed into the queue\n // other objects are serialize in-place \n function traverse(value: any, noRefType = false) {\n if (typeof value !== \"object\" || value === null) {\n return value;\n }\n // object with _serialize function\n if (typeof value._serialize === \"function\") {\n if (!noRefType) {\n for (const typeName in SERIALIZE_REF_TYPES) {\n if (value instanceof SERIALIZE_REF_TYPES[typeName]) {\n return addToRefQueue(value, typeName);\n }\n }\n }\n // object with _serialize function\n value = serializeWithHooks(value);\n }\n // recursive for arrays any objects\n if (Array.isArray(value)) {\n const newValue = [];\n for (let key = 0; key < value.length; key++) {\n newValue[key] = traverse(value[key]);\n }\n value = newValue;\n\n } else {\n const newValue = {};\n for (const key in value) {\n if (value.hasOwnProperty(key)) {\n newValue[key] = traverse(value[key]);\n }\n }\n value = newValue;\n }\n return value;\n }\n\n while (refQueue.length) {\n const obj = refQueue.shift();\n const str = traverse(obj, true);\n json.push(str);\n }\n\n return json;\n };\n\n fromJson = (json: SerializedType): T => {\n const preDeserialize = this.options.preDeserialize;\n const postDeserialize = this.options.postDeserialize;\n const rootClass = this.options.rootClass;\n\n const deserializedRefMemoByIndex: Record = {};\n\n function deserializeWithHooks(classHint: ClassName, data: DataType, context: any): ObjectType {\n if (!classHint || !classHint._deserialize) {\n classHint = DESERIALIZE_BY_TYPE_FIELD[data.type];\n }\n const deserializer = classHint && classHint._deserialize;\n if (!deserializer) {\n return;\n }\n data = preDeserialize(data);\n const classDeserializeFn = classHint._deserialize as ClassDeserializerMethod;\n let obj = classDeserializeFn(data, context, deserializeChild);\n obj = postDeserialize(obj, data);\n return obj;\n }\n\n /**\n * Recursive callback function to deserialize a child data object or reference object.\n * \n * @param classHint suggested class to deserialize obj to\n * @param dataOrRef data or reference object\n * @param context for example world when deserializing bodies and joints\n */\n function deserializeChild(classHint: ClassName, dataOrRef: DataType | RefType, context: any) {\n const isRefObject = dataOrRef.refIndex && dataOrRef.refType;\n if (!isRefObject) {\n return deserializeWithHooks(classHint, dataOrRef, context); \n }\n const ref = dataOrRef as RefType;\n if (DESERIALIZE_BY_REF_TYPE[ref.refType]) {\n classHint = DESERIALIZE_BY_REF_TYPE[ref.refType];\n }\n const refIndex = ref.refIndex;\n if (!deserializedRefMemoByIndex[refIndex]) {\n const data = json[refIndex];\n const obj = deserializeWithHooks(classHint, data, context);\n deserializedRefMemoByIndex[refIndex] = obj;\n }\n return deserializedRefMemoByIndex[refIndex];\n }\n\n const root = deserializeWithHooks(rootClass, json[0], null);\n\n return root;\n };\n\n static toJson: (root: World) => SerializedType;\n static fromJson: (json: SerializedType) => World;\n}\n\nconst worldSerializer = new Serializer({\n rootClass: World,\n});\n\nSerializer.fromJson = worldSerializer.fromJson;\nSerializer.toJson = worldSerializer.toJson;\n","import type { AABBValue } from \"../collision/AABB\";\nimport type { World } from \"../dynamics/World\";\nimport type { Joint } from \"../dynamics/Joint\";\nimport type { Fixture } from \"../dynamics/Fixture\";\nimport type { Body } from \"../dynamics/Body\";\n\nexport interface Style {\n stroke?: string;\n fill?: string;\n lineWidth?: number;\n}\n\ntype KEY = \"0\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" |\n \"8\" | \"9\" | \"A\" | \"B\" | \"C\" | \"D\" | \"E\" | \"F\" | \"G\" |\n \"H\" | \"I\" | \"J\" | \"K\" | \"L\" | \"M\" | \"N\" | \"O\" | \"P\" |\n \"Q\" | \"R\" | \"S\" | \"T\" | \"U\" | \"V\" | \"W\" | \"X\" | \"Y\" |\n \"Z\" | \"right\" | \"left\" | \"up\" | \"down\" | \"fire\";\n\nexport type ActiveKeys = { [key in KEY]?: boolean };\n\ntype TestbedMountOptions = { [key: string]: any };\n\nexport abstract class Testbed {\n /**\n * Mounts testbed. Call start with a world to start simulation and rendering.\n */\n static mount(options?: TestbedMountOptions): Testbed {\n throw new Error(\"Not implemented\");\n }\n\n /**\n * Mounts testbed if needed, then starts simulation and rendering.\n * \n * If you need to customize testbed before starting, first run `const testbed = Testbed.mount()` and then `testbed.start()`.\n */\n static start(world: World): Testbed {\n const testbed = Testbed.mount();\n testbed.start(world);\n return testbed;\n }\n\n /** World viewbox width. */\n width: number = 80;\n\n /** World viewbox height. */\n height: number = 60;\n\n /** World viewbox center vertical offset. */\n x: number = 0;\n\n /** World viewbox center horizontal offset. */\n y: number = -10;\n\n /** @hidden */\n scaleY: number = -1;\n\n /** World simulation step frequency */\n hz: number = 60;\n\n /** World simulation speed, default is 1 */\n speed: number = 1;\n\n background: string = \"#222222\";\n\n mouseForce?: number;\n activeKeys: ActiveKeys = {};\n\n /** callback, to be implemented by user */\n step = (dt: number, t: number): void => {\n return;\n };\n\n /** callback, to be implemented by user */\n keydown = (keyCode: number, label: string): void => {\n return;\n };\n\n /** callback, to be implemented by user */\n keyup = (keyCode: number, label: string): void => {\n return;\n };\n\n abstract status(name: string, value: any): void;\n abstract status(value: object | string): void;\n\n abstract info(text: string): void;\n\n color(r: number, g: number, b: number): string {\n r = r * 256 | 0;\n g = g * 256 | 0;\n b = b * 256 | 0;\n return \"rgb(\" + r + \", \" + g + \", \" + b + \")\";\n }\n\n abstract drawPoint(p: {x: number, y: number}, r: any, color: string): void;\n abstract drawCircle(p: {x: number, y: number}, r: number, color: string): void;\n abstract drawEdge(a: {x: number, y: number}, b: {x: number, y: number}, color: string): void;\n abstract drawSegment(a: {x: number, y: number}, b: {x: number, y: number}, color: string): void;\n abstract drawPolygon(points: Array<{x: number, y: number}>, color: string): void;\n abstract drawAABB(aabb: AABBValue, color: string): void;\n\n abstract start(world: World): void;\n\n abstract findOne(query: string): (Body | Joint | Fixture | null);\n abstract findAll(query: string): (Body | Joint | Fixture)[];\n}\n\ntype TestbedFactoryOptions = string | TestbedMountOptions;\n\n/** @deprecated */\ntype TestbedCallback = (testbed: Testbed) => (World | undefined);\n\n/** @deprecated */\nexport function testbed(callback: TestbedCallback): void;\n/** @deprecated */\nexport function testbed(options: TestbedFactoryOptions, callback: TestbedCallback): void;\n/** @internal */\nexport function testbed(a?: any, b?: any) {\n let callback: TestbedCallback | undefined;\n let options;\n if (typeof a === \"function\") {\n callback = a;\n options = b;\n } else if (typeof b === \"function\") {\n callback = b;\n options = a;\n } else {\n options = a ?? b;\n }\n const testbed = Testbed.mount(options);\n if (callback) {\n // this is for backwards compatibility\n const world = callback(testbed) || (testbed as any).world;\n testbed.start(world);\n } else {\n return testbed;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { Vec2Value } from \"../../common/Vec2\";\nimport { PolygonShape } from \"./PolygonShape\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\ndeclare module \"./BoxShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function BoxShape(halfWidth: number, halfHeight: number, center?: Vec2Value, angle?: number): BoxShape;\n}\n\n/**\n * A rectangle polygon which extend PolygonShape.\n */\n// @ts-expect-error\nexport class BoxShape extends PolygonShape {\n // note that box is serialized/deserialized as polygon\n static TYPE = \"polygon\" as const;\n\n /**\n * \n * @param halfWidth \n * @param halfHeight \n * @param center coordinate of the center of the box relative to the body\n * @param angle angle of the box relative to the body\n */\n constructor(halfWidth: number, halfHeight: number, center?: Vec2Value, angle?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof BoxShape)) {\n return new BoxShape(halfWidth, halfHeight, center, angle);\n }\n\n super();\n\n this._setAsBox(halfWidth, halfHeight, center, angle);\n }\n}\n\nexport const Box = BoxShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { CircleShape } from \"./CircleShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(CircleShape.TYPE, CircleShape.TYPE, CircleCircleContact);\n\n/** @internal */ function CircleCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == CircleShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n CollideCircles(manifold, fixtureA.getShape() as CircleShape, xfA, fixtureB.getShape() as CircleShape, xfB);\n}\n\n/** @internal */ const pA = matrix.vec2(0, 0);\n/** @internal */ const pB = matrix.vec2(0, 0);\n\nexport const CollideCircles = function (manifold: Manifold, circleA: CircleShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n matrix.transformVec2(pA, xfA, circleA.m_p);\n matrix.transformVec2(pB, xfB, circleB.m_p);\n\n const distSqr = matrix.distSqrVec2(pB, pA);\n const rA = circleA.m_radius;\n const rB = circleB.m_radius;\n const radius = rA + rB;\n if (distSqr > radius * radius) {\n return;\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.copyVec2(manifold.localPoint, circleA.m_p);\n matrix.zeroVec2(manifold.localNormal);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { TransformValue } from \"../../common/Transform\";\nimport * as matrix from \"../../common/Matrix\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { EdgeShape } from \"./EdgeShape\";\nimport { ChainShape } from \"./ChainShape\";\nimport { CircleShape } from \"./CircleShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(EdgeShape.TYPE, CircleShape.TYPE, EdgeCircleContact);\nContact.addType(ChainShape.TYPE, CircleShape.TYPE, ChainCircleContact);\n\n/** @internal */ function EdgeCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == EdgeShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n\n const shapeA = fixtureA.getShape() as EdgeShape;\n const shapeB = fixtureB.getShape() as CircleShape;\n\n CollideEdgeCircle(manifold, shapeA, xfA, shapeB, xfB);\n}\n\nfunction ChainCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == ChainShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n\n const chain = fixtureA.getShape() as ChainShape;\n const edge = new EdgeShape();\n chain.getChildEdge(edge, indexA);\n\n const shapeA = edge;\n const shapeB = fixtureB.getShape() as CircleShape;\n\n CollideEdgeCircle(manifold, shapeA, xfA, shapeB, xfB);\n}\n\n/** @internal */ const e = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const e1 = matrix.vec2(0, 0);\n/** @internal */ const e2 = matrix.vec2(0, 0);\n/** @internal */ const Q = matrix.vec2(0, 0);\n/** @internal */ const P = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n\n// Compute contact points for edge versus circle.\n// This accounts for edge connectivity.\nexport const CollideEdgeCircle = function (manifold: Manifold, edgeA: EdgeShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n // Compute circle in frame of edge\n matrix.retransformVec2(Q, xfB, xfA, circleB.m_p);\n\n const A = edgeA.m_vertex1;\n const B = edgeA.m_vertex2;\n matrix.subVec2(e, B, A);\n\n // Barycentric coordinates\n const u = matrix.dotVec2(e, B) - matrix.dotVec2(e, Q);\n const v = matrix.dotVec2(e, Q) - matrix.dotVec2(e, A);\n\n const radius = edgeA.m_radius + circleB.m_radius;\n\n // Region A\n if (v <= 0.0) {\n matrix.copyVec2(P, A);\n const dd = matrix.distSqrVec2(Q, A);\n if (dd > radius * radius) {\n return;\n }\n\n // Is there an edge connected to A?\n if (edgeA.m_hasVertex0) {\n const A1 = edgeA.m_vertex0;\n const B1 = A;\n matrix.subVec2(e1, B1, A1);\n const u1 = matrix.dotVec2(e1, B1) - matrix.dotVec2(e1, Q);\n\n // Is the circle in Region AB of the previous edge?\n if (u1 > 0.0) {\n return;\n }\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.zeroVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, P);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n return;\n }\n\n // Region B\n if (u <= 0.0) {\n matrix.copyVec2(P, B);\n const dd = matrix.distSqrVec2(Q, P);\n if (dd > radius * radius) {\n return;\n }\n\n // Is there an edge connected to B?\n if (edgeA.m_hasVertex3) {\n const B2 = edgeA.m_vertex3;\n const A2 = B;\n matrix.subVec2(e2, B2, A2);\n const v2 = matrix.dotVec2(e2, Q) - matrix.dotVec2(e2, A2);\n\n // Is the circle in Region AB of the next edge?\n if (v2 > 0.0) {\n return;\n }\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.zeroVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, P);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(1, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n\n return;\n }\n\n // Region AB\n const den = matrix.lengthSqrVec2(e);\n if (_ASSERT) console.assert(den > 0.0);\n matrix.combine2Vec2(P, u / den, A, v / den, B);\n const dd = matrix.distSqrVec2(Q, P);\n if (dd > radius * radius) {\n return;\n }\n\n matrix.crossNumVec2(n, 1, e);\n if (matrix.dotVec2(n, Q) - matrix.dotVec2(n, A) < 0.0) {\n matrix.negVec2(n);\n }\n matrix.normalizeVec2(n);\n\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, n);\n matrix.copyVec2(manifold.localPoint, A);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_face, 0, ContactFeatureType.e_vertex);\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { TransformValue } from \"../../common/Transform\";\nimport * as matrix from \"../../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Manifold, clipSegmentToLine, ClipVertex, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/** @internal */ const incidentEdge = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints1 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints2 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipSegmentToLineNormal = matrix.vec2(0, 0);\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const v11 = matrix.vec2(0, 0);\n/** @internal */ const v12 = matrix.vec2(0, 0);\n/** @internal */ const localTangent = matrix.vec2(0, 0);\n/** @internal */ const localNormal = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const tangent = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const normal1 = matrix.vec2(0, 0);\n\n\nContact.addType(PolygonShape.TYPE, PolygonShape.TYPE, PolygonContact);\n\n/** @internal */ function PolygonContact(\n manifold: Manifold,\n xfA: TransformValue,\n fixtureA: Fixture,\n indexA: number,\n xfB: TransformValue,\n fixtureB: Fixture,\n indexB: number,\n): void {\n if (_ASSERT) console.assert(fixtureA.getType() == PolygonShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == PolygonShape.TYPE);\n CollidePolygons(manifold, fixtureA.getShape() as PolygonShape, xfA, fixtureB.getShape() as PolygonShape, xfB);\n}\n\n/** @internal */ interface MaxSeparation {\n maxSeparation: number;\n bestIndex: number;\n}\n\n/**\n * Find the max separation between poly1 and poly2 using edge normals from\n * poly1.\n */\n/** @internal */ function findMaxSeparation(\n poly1: PolygonShape,\n xf1: TransformValue,\n poly2: PolygonShape,\n xf2: TransformValue,\n output: MaxSeparation,\n): void {\n const count1 = poly1.m_count;\n const count2 = poly2.m_count;\n const n1s = poly1.m_normals;\n const v1s = poly1.m_vertices;\n const v2s = poly2.m_vertices;\n\n matrix.detransformTransform(xf, xf2, xf1);\n\n let bestIndex = 0;\n let maxSeparation = -Infinity;\n for (let i = 0; i < count1; ++i) {\n // Get poly1 normal in frame2.\n matrix.rotVec2(n, xf.q, n1s[i]);\n matrix.transformVec2(v1, xf, v1s[i]);\n\n // Find deepest point for normal i.\n let si = Infinity;\n for (let j = 0; j < count2; ++j) {\n const sij = matrix.dotVec2(n, v2s[j]) - matrix.dotVec2(n, v1);\n if (sij < si) {\n si = sij;\n }\n }\n\n if (si > maxSeparation) {\n maxSeparation = si;\n bestIndex = i;\n }\n }\n\n // used to keep last FindMaxSeparation call values\n output.maxSeparation = maxSeparation;\n output.bestIndex = bestIndex;\n}\n\n/** @internal */ function findIncidentEdge(\n clipVertex: ClipVertex[],\n poly1: PolygonShape,\n xf1: TransformValue,\n edge1: number,\n poly2: PolygonShape,\n xf2: TransformValue,\n): void {\n const normals1 = poly1.m_normals;\n\n const count2 = poly2.m_count;\n const vertices2 = poly2.m_vertices;\n const normals2 = poly2.m_normals;\n\n if (_ASSERT) console.assert(0 <= edge1 && edge1 < poly1.m_count);\n\n // Get the normal of the reference edge in poly2's frame.\n matrix.rerotVec2(normal1, xf2.q, xf1.q, normals1[edge1]);\n\n // Find the incident edge on poly2.\n let index = 0;\n let minDot = Infinity;\n for (let i = 0; i < count2; ++i) {\n const dot = matrix.dotVec2(normal1, normals2[i]);\n if (dot < minDot) {\n minDot = dot;\n index = i;\n }\n }\n\n // Build the clip vertices for the incident edge.\n const i1 = index;\n const i2 = i1 + 1 < count2 ? i1 + 1 : 0;\n\n matrix.transformVec2(clipVertex[0].v, xf2, vertices2[i1]);\n clipVertex[0].id.setFeatures(edge1, ContactFeatureType.e_face, i1, ContactFeatureType.e_vertex);\n\n matrix.transformVec2(clipVertex[1].v, xf2, vertices2[i2]);\n clipVertex[1].id.setFeatures(edge1, ContactFeatureType.e_face, i2, ContactFeatureType.e_vertex);\n}\n\n/** @internal */ const maxSeparation = {\n maxSeparation: 0,\n bestIndex: 0,\n};\n\n/**\n *\n * Find edge normal of max separation on A - return if separating axis is found
\n * Find edge normal of max separation on B - return if separation axis is found
\n * Choose reference edge as min(minA, minB)
\n * Find incident edge
\n * Clip\n *\n * The normal points from 1 to 2\n */\nexport const CollidePolygons = function (\n manifold: Manifold,\n polyA: PolygonShape,\n xfA: TransformValue,\n polyB: PolygonShape,\n xfB: TransformValue,\n): void {\n manifold.pointCount = 0;\n const totalRadius = polyA.m_radius + polyB.m_radius;\n\n findMaxSeparation(polyA, xfA, polyB, xfB, maxSeparation);\n const edgeA = maxSeparation.bestIndex;\n const separationA = maxSeparation.maxSeparation;\n if (separationA > totalRadius)\n return;\n\n findMaxSeparation(polyB, xfB, polyA, xfA, maxSeparation);\n const edgeB = maxSeparation.bestIndex;\n const separationB = maxSeparation.maxSeparation;\n if (separationB > totalRadius)\n return;\n\n let poly1: PolygonShape; // reference polygon\n let poly2: PolygonShape; // incident polygon\n let xf1: TransformValue;\n let xf2: TransformValue;\n let edge1: number; // reference edge\n let flip: boolean;\n const k_tol = 0.1 * Settings.linearSlop;\n\n if (separationB > separationA + k_tol) {\n poly1 = polyB;\n poly2 = polyA;\n xf1 = xfB;\n xf2 = xfA;\n edge1 = edgeB;\n manifold.type = ManifoldType.e_faceB;\n flip = true;\n } else {\n poly1 = polyA;\n poly2 = polyB;\n xf1 = xfA;\n xf2 = xfB;\n edge1 = edgeA;\n manifold.type = ManifoldType.e_faceA;\n flip = false;\n }\n\n incidentEdge[0].recycle();\n incidentEdge[1].recycle();\n findIncidentEdge(incidentEdge, poly1, xf1, edge1, poly2, xf2);\n\n const count1 = poly1.m_count;\n const vertices1 = poly1.m_vertices;\n\n const iv1 = edge1;\n const iv2 = edge1 + 1 < count1 ? edge1 + 1 : 0;\n\n matrix.copyVec2(v11, vertices1[iv1]);\n matrix.copyVec2(v12, vertices1[iv2]);\n\n matrix.subVec2(localTangent, v12, v11);\n matrix.normalizeVec2(localTangent);\n\n matrix.crossVec2Num(localNormal, localTangent, 1.0);\n matrix.combine2Vec2(planePoint, 0.5, v11, 0.5, v12);\n\n matrix.rotVec2(tangent, xf1.q, localTangent);\n matrix.crossVec2Num(normal, tangent, 1.0);\n\n matrix.transformVec2(v11, xf1, v11);\n matrix.transformVec2(v12, xf1, v12);\n\n // Face offset.\n const frontOffset = matrix.dotVec2(normal, v11);\n\n // Side offsets, extended by polytope skin thickness.\n const sideOffset1 = -matrix.dotVec2(tangent, v11) + totalRadius;\n const sideOffset2 = matrix.dotVec2(tangent, v12) + totalRadius;\n\n // Clip incident edge against extruded edge1 side edges.\n clipPoints1[0].recycle();\n clipPoints1[1].recycle();\n clipPoints2[0].recycle();\n clipPoints2[1].recycle();\n\n // Clip to box side 1\n matrix.setVec2(clipSegmentToLineNormal, -tangent.x, -tangent.y);\n const np1 = clipSegmentToLine(clipPoints1, incidentEdge, clipSegmentToLineNormal, sideOffset1, iv1);\n\n if (np1 < 2) {\n return;\n }\n\n // Clip to negative box side 1\n matrix.setVec2(clipSegmentToLineNormal, tangent.x, tangent.y);\n const np2 = clipSegmentToLine(clipPoints2, clipPoints1, clipSegmentToLineNormal, sideOffset2, iv2);\n\n if (np2 < 2) {\n return;\n }\n\n // Now clipPoints2 contains the clipped points.\n matrix.copyVec2(manifold.localNormal, localNormal);\n matrix.copyVec2(manifold.localPoint, planePoint);\n\n let pointCount = 0;\n for (let i = 0; i < clipPoints2.length/* maxManifoldPoints */; ++i) {\n const separation = matrix.dotVec2(normal, clipPoints2[i].v) - frontOffset;\n\n if (separation <= totalRadius) {\n const cp = manifold.points[pointCount];\n matrix.detransformVec2(cp.localPoint, xf2, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n if (flip) {\n // Swap features\n cp.id.swapFeatures();\n }\n ++pointCount;\n }\n }\n\n manifold.pointCount = pointCount;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { EPSILON } from \"../../common/Math\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { CircleShape } from \"./CircleShape\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(PolygonShape.TYPE, CircleShape.TYPE, PolygonCircleContact);\n\n/** @internal */ function PolygonCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == PolygonShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n CollidePolygonCircle(manifold, fixtureA.getShape() as PolygonShape, xfA, fixtureB.getShape() as CircleShape, xfB);\n}\n\n/** @internal */ const cLocal = matrix.vec2(0, 0);\n/** @internal */ const faceCenter = matrix.vec2(0, 0);\n\nexport const CollidePolygonCircle = function (manifold: Manifold, polygonA: PolygonShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n // Compute circle position in the frame of the polygon.\n matrix.retransformVec2(cLocal, xfB, xfA, circleB.m_p);\n\n // Find the min separating edge.\n let normalIndex = 0;\n let separation = -Infinity;\n const radius = polygonA.m_radius + circleB.m_radius;\n const vertexCount = polygonA.m_count;\n const vertices = polygonA.m_vertices;\n const normals = polygonA.m_normals;\n\n for (let i = 0; i < vertexCount; ++i) {\n const s = matrix.dotVec2(normals[i], cLocal) - matrix.dotVec2(normals[i], vertices[i]);\n\n if (s > radius) {\n // Early out.\n return;\n }\n\n if (s > separation) {\n separation = s;\n normalIndex = i;\n }\n }\n\n // Vertices that subtend the incident face.\n const vertIndex1 = normalIndex;\n const vertIndex2 = vertIndex1 + 1 < vertexCount ? vertIndex1 + 1 : 0;\n const v1 = vertices[vertIndex1];\n const v2 = vertices[vertIndex2];\n\n // If the center is inside the polygon ...\n if (separation < EPSILON) {\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, normals[normalIndex]);\n matrix.combine2Vec2(manifold.localPoint, 0.5, v1, 0.5, v2);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n return;\n }\n\n // Compute barycentric coordinates\n // u1 = (cLocal - v1) dot (v2 - v1))\n const u1 = matrix.dotVec2(cLocal, v2) - matrix.dotVec2(cLocal, v1) - matrix.dotVec2(v1, v2) + matrix.dotVec2(v1, v1);\n // u2 = (cLocal - v2) dot (v1 - v2)\n const u2 = matrix.dotVec2(cLocal, v1) - matrix.dotVec2(cLocal, v2) - matrix.dotVec2(v2, v1) + matrix.dotVec2(v2, v2);\n if (u1 <= 0.0) {\n if (matrix.distSqrVec2(cLocal, v1) > radius * radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.subVec2(manifold.localNormal, cLocal, v1);\n matrix.normalizeVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, v1);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n } else if (u2 <= 0.0) {\n if (matrix.distSqrVec2(cLocal, v2) > radius * radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.subVec2(manifold.localNormal, cLocal, v2);\n matrix.normalizeVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, v2);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n } else {\n matrix.combine2Vec2(faceCenter, 0.5, v1, 0.5, v2);\n const separation = matrix.dotVec2(cLocal, normals[vertIndex1]) - matrix.dotVec2(faceCenter, normals[vertIndex1]);\n if (separation > radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, normals[vertIndex1]);\n matrix.copyVec2(manifold.localPoint, faceCenter);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n }\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { Manifold, clipSegmentToLine, ClipVertex, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { EdgeShape } from \"./EdgeShape\";\nimport { ChainShape } from \"./ChainShape\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_min = Math.min;\n\nContact.addType(EdgeShape.TYPE, PolygonShape.TYPE, EdgePolygonContact);\nContact.addType(ChainShape.TYPE, PolygonShape.TYPE, ChainPolygonContact);\n\n/** @internal */ function EdgePolygonContact(manifold: Manifold, xfA: TransformValue, fA: Fixture, indexA: number, xfB: TransformValue, fB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fA.getType() == EdgeShape.TYPE);\n if (_ASSERT) console.assert(fB.getType() == PolygonShape.TYPE);\n\n CollideEdgePolygon(manifold, fA.getShape() as EdgeShape, xfA, fB.getShape() as PolygonShape, xfB);\n}\n\n// reused\n/** @internal */ const edge_reuse = new EdgeShape();\n\n/** @internal */ function ChainPolygonContact(manifold: Manifold, xfA: TransformValue, fA: Fixture, indexA: number, xfB: TransformValue, fB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fA.getType() == ChainShape.TYPE);\n if (_ASSERT) console.assert(fB.getType() == PolygonShape.TYPE);\n\n const chain = fA.getShape() as ChainShape;\n chain.getChildEdge(edge_reuse, indexA);\n\n CollideEdgePolygon(manifold, edge_reuse, xfA, fB.getShape() as PolygonShape, xfB);\n}\n\n/** @internal */ enum EPAxisType {\n e_unknown = -1,\n e_edgeA = 1,\n e_edgeB = 2,\n}\n\n// unused?\n/** @internal */ enum VertexType {\n e_isolated = 0,\n e_concave = 1,\n e_convex = 2,\n}\n\n/**\n * This structure is used to keep track of the best separating axis.\n */\n/** @internal */ class EPAxis {\n type: EPAxisType;\n index: number;\n separation: number;\n}\n\n/**\n * This holds polygon B expressed in frame A.\n */\n/** @internal */ class TempPolygon {\n vertices: Vec2Value[] = []; // [Settings.maxPolygonVertices]\n normals: Vec2Value[] = []; // [Settings.maxPolygonVertices];\n count: number = 0;\n constructor() {\n for (let i = 0; i < Settings.maxPolygonVertices; i++) {\n this.vertices.push(matrix.vec2(0, 0));\n this.normals.push(matrix.vec2(0, 0));\n }\n }\n}\n\n/**\n * Reference face used for clipping\n */\n/** @internal */ class ReferenceFace {\n i1: number;\n i2: number;\n readonly v1 = matrix.vec2(0 ,0);\n readonly v2 = matrix.vec2(0 ,0);\n readonly normal = matrix.vec2(0 ,0);\n readonly sideNormal1 = matrix.vec2(0 ,0);\n sideOffset1: number;\n readonly sideNormal2 = matrix.vec2(0 ,0);\n sideOffset2: number;\n recycle() {\n matrix.zeroVec2(this.v1);\n matrix.zeroVec2(this.v2);\n matrix.zeroVec2(this.normal);\n matrix.zeroVec2(this.sideNormal1);\n matrix.zeroVec2(this.sideNormal2);\n }\n}\n\n// reused\n/** @internal */ const clipPoints1 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints2 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const ie = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const edgeAxis = new EPAxis();\n/** @internal */ const polygonAxis = new EPAxis();\n/** @internal */ const polygonBA = new TempPolygon();\n/** @internal */ const rf = new ReferenceFace();\n/** @internal */ const centroidB = matrix.vec2(0, 0);\n/** @internal */ const edge0 = matrix.vec2(0, 0);\n/** @internal */ const edge1 = matrix.vec2(0, 0);\n/** @internal */ const edge2 = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const normal0 = matrix.vec2(0, 0);\n/** @internal */ const normal1 = matrix.vec2(0, 0);\n/** @internal */ const normal2 = matrix.vec2(0, 0);\n/** @internal */ const lowerLimit = matrix.vec2(0, 0);\n/** @internal */ const upperLimit = matrix.vec2(0, 0);\n/** @internal */ const perp = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n\n/**\n * This function collides and edge and a polygon, taking into account edge\n * adjacency.\n */\nexport const CollideEdgePolygon = function (manifold: Manifold, edgeA: EdgeShape, xfA: TransformValue, polygonB: PolygonShape, xfB: TransformValue): void {\n // Algorithm:\n // 1. Classify v1 and v2\n // 2. Classify polygon centroid as front or back\n // 3. Flip normal if necessary\n // 4. Initialize normal range to [-pi, pi] about face normal\n // 5. Adjust normal range according to adjacent edges\n // 6. Visit each separating axes, only accept axes within the range\n // 7. Return if _any_ axis indicates separation\n // 8. Clip\n\n // let m_type1: VertexType;\n // let m_type2: VertexType;\n\n matrix.detransformTransform(xf, xfA, xfB);\n matrix.transformVec2(centroidB, xf, polygonB.m_centroid);\n\n const v0 = edgeA.m_vertex0;\n const v1 = edgeA.m_vertex1;\n const v2 = edgeA.m_vertex2;\n const v3 = edgeA.m_vertex3;\n\n const hasVertex0 = edgeA.m_hasVertex0;\n const hasVertex3 = edgeA.m_hasVertex3;\n\n matrix.subVec2(edge1, v2, v1);\n matrix.normalizeVec2(edge1);\n matrix.setVec2(normal1, edge1.y, -edge1.x);\n const offset1 = matrix.dotVec2(normal1, centroidB) - matrix.dotVec2(normal1, v1);\n let offset0 = 0.0;\n let offset2 = 0.0;\n let convex1 = false;\n let convex2 = false;\n\n matrix.zeroVec2(normal0);\n matrix.zeroVec2(normal2);\n\n // Is there a preceding edge?\n if (hasVertex0) {\n matrix.subVec2(edge0, v1, v0);\n matrix.normalizeVec2(edge0);\n matrix.setVec2(normal0, edge0.y, -edge0.x);\n convex1 = matrix.crossVec2Vec2(edge0, edge1) >= 0.0;\n offset0 = Vec2.dot(normal0, centroidB) - Vec2.dot(normal0, v0);\n }\n\n // Is there a following edge?\n if (hasVertex3) {\n matrix.subVec2(edge2, v3, v2);\n matrix.normalizeVec2(edge2);\n matrix.setVec2(normal2, edge2.y, -edge2.x);\n convex2 = Vec2.crossVec2Vec2(edge1, edge2) > 0.0;\n offset2 = Vec2.dot(normal2, centroidB) - Vec2.dot(normal2, v2);\n }\n\n let front: boolean;\n matrix.zeroVec2(normal);\n matrix.zeroVec2(lowerLimit);\n matrix.zeroVec2(upperLimit);\n\n // Determine front or back collision. Determine collision normal limits.\n if (hasVertex0 && hasVertex3) {\n if (convex1 && convex2) {\n front = offset0 >= 0.0 || offset1 >= 0.0 || offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else if (convex1) {\n front = offset0 >= 0.0 || (offset1 >= 0.0 && offset2 >= 0.0);\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else if (convex2) {\n front = offset2 >= 0.0 || (offset0 >= 0.0 && offset1 >= 0.0);\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n } else {\n front = offset0 >= 0.0 && offset1 >= 0.0 && offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n }\n } else if (hasVertex0) {\n if (convex1) {\n front = offset0 >= 0.0 || offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else {\n front = offset0 >= 0.0 && offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n }\n } else if (hasVertex3) {\n if (convex2) {\n front = offset1 >= 0.0 || offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal1);\n }\n } else {\n front = offset1 >= 0.0 && offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.copyVec2(upperLimit, normal1);\n }\n }\n } else {\n front = offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal1);\n }\n }\n\n // Get polygonB in frameA\n polygonBA.count = polygonB.m_count;\n for (let i = 0; i < polygonB.m_count; ++i) {\n matrix.transformVec2(polygonBA.vertices[i], xf, polygonB.m_vertices[i]);\n matrix.rotVec2(polygonBA.normals[i], xf.q, polygonB.m_normals[i]);\n }\n\n const radius = polygonB.m_radius + edgeA.m_radius;\n\n manifold.pointCount = 0;\n\n { // ComputeEdgeSeparation\n edgeAxis.type = EPAxisType.e_edgeA;\n edgeAxis.index = front ? 0 : 1;\n edgeAxis.separation = Infinity;\n\n for (let i = 0; i < polygonBA.count; ++i) {\n const v = polygonBA.vertices[i];\n const s = matrix.dotVec2(normal, v) - matrix.dotVec2(normal, v1);\n if (s < edgeAxis.separation) {\n edgeAxis.separation = s;\n }\n }\n }\n\n // If no valid normal can be found than this edge should not collide.\n // @ts-ignore todo: why we need this if here?\n if (edgeAxis.type == EPAxisType.e_unknown) {\n return;\n }\n\n if (edgeAxis.separation > radius) {\n return;\n }\n\n { // ComputePolygonSeparation\n polygonAxis.type = EPAxisType.e_unknown;\n polygonAxis.index = -1;\n polygonAxis.separation = -Infinity;\n\n matrix.setVec2(perp, -normal.y, normal.x);\n\n for (let i = 0; i < polygonBA.count; ++i) {\n matrix.scaleVec2(n, -1, polygonBA.normals[i]);\n\n const s1 = matrix.dotVec2(n, polygonBA.vertices[i]) - matrix.dotVec2(n, v1);\n const s2 = matrix.dotVec2(n, polygonBA.vertices[i]) - matrix.dotVec2(n, v2);\n const s = math_min(s1, s2);\n\n if (s > radius) {\n // No collision\n polygonAxis.type = EPAxisType.e_edgeB;\n polygonAxis.index = i;\n polygonAxis.separation = s;\n break;\n }\n\n // Adjacency\n if (matrix.dotVec2(n, perp) >= 0.0) {\n if (matrix.dotVec2(n, normal) - matrix.dotVec2(upperLimit, normal) < -Settings.angularSlop) {\n continue;\n }\n } else {\n if (matrix.dotVec2(n, normal) - matrix.dotVec2(lowerLimit, normal) < -Settings.angularSlop) {\n continue;\n }\n }\n\n if (s > polygonAxis.separation) {\n polygonAxis.type = EPAxisType.e_edgeB;\n polygonAxis.index = i;\n polygonAxis.separation = s;\n }\n }\n }\n\n if (polygonAxis.type != EPAxisType.e_unknown && polygonAxis.separation > radius) {\n return;\n }\n\n // Use hysteresis for jitter reduction.\n const k_relativeTol = 0.98;\n const k_absoluteTol = 0.001;\n\n let primaryAxis: EPAxis;\n if (polygonAxis.type == EPAxisType.e_unknown) {\n primaryAxis = edgeAxis;\n } else if (polygonAxis.separation > k_relativeTol * edgeAxis.separation + k_absoluteTol) {\n primaryAxis = polygonAxis;\n } else {\n primaryAxis = edgeAxis;\n }\n\n ie[0].recycle();\n ie[1].recycle();\n\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n manifold.type = ManifoldType.e_faceA;\n\n // Search for the polygon normal that is most anti-parallel to the edge\n // normal.\n let bestIndex = 0;\n let bestValue = matrix.dotVec2(normal, polygonBA.normals[0]);\n for (let i = 1; i < polygonBA.count; ++i) {\n const value = matrix.dotVec2(normal, polygonBA.normals[i]);\n if (value < bestValue) {\n bestValue = value;\n bestIndex = i;\n }\n }\n\n const i1 = bestIndex;\n const i2 = i1 + 1 < polygonBA.count ? i1 + 1 : 0;\n\n matrix.copyVec2(ie[0].v, polygonBA.vertices[i1]);\n ie[0].id.setFeatures(0, ContactFeatureType.e_face, i1, ContactFeatureType.e_vertex);\n\n matrix.copyVec2(ie[1].v, polygonBA.vertices[i2]);\n ie[1].id.setFeatures(0, ContactFeatureType.e_face, i2, ContactFeatureType.e_vertex);\n\n if (front) {\n rf.i1 = 0;\n rf.i2 = 1;\n matrix.copyVec2(rf.v1, v1);\n matrix.copyVec2(rf.v2, v2);\n matrix.copyVec2(rf.normal, normal1);\n } else {\n rf.i1 = 1;\n rf.i2 = 0;\n matrix.copyVec2(rf.v1, v2);\n matrix.copyVec2(rf.v2, v1);\n matrix.scaleVec2(rf.normal, -1, normal1);\n }\n } else {\n manifold.type = ManifoldType.e_faceB;\n\n matrix.copyVec2(ie[0].v, v1);\n ie[0].id.setFeatures(0, ContactFeatureType.e_vertex, primaryAxis.index, ContactFeatureType.e_face);\n\n matrix.copyVec2(ie[1].v, v2);\n ie[1].id.setFeatures(0, ContactFeatureType.e_vertex, primaryAxis.index, ContactFeatureType.e_face);\n\n rf.i1 = primaryAxis.index;\n rf.i2 = rf.i1 + 1 < polygonBA.count ? rf.i1 + 1 : 0;\n matrix.copyVec2(rf.v1, polygonBA.vertices[rf.i1]);\n matrix.copyVec2(rf.v2, polygonBA.vertices[rf.i2]);\n matrix.copyVec2(rf.normal, polygonBA.normals[rf.i1]);\n }\n\n matrix.setVec2(rf.sideNormal1, rf.normal.y, -rf.normal.x);\n matrix.setVec2(rf.sideNormal2, -rf.sideNormal1.x, -rf.sideNormal1.y);\n rf.sideOffset1 = matrix.dotVec2(rf.sideNormal1, rf.v1);\n rf.sideOffset2 = matrix.dotVec2(rf.sideNormal2, rf.v2);\n\n // Clip incident edge against extruded edge1 side edges.\n clipPoints1[0].recycle();\n clipPoints1[1].recycle();\n clipPoints2[0].recycle();\n clipPoints2[1].recycle();\n\n // Clip to box side 1\n const np1 = clipSegmentToLine(clipPoints1, ie, rf.sideNormal1, rf.sideOffset1, rf.i1);\n\n if (np1 < Settings.maxManifoldPoints) {\n return;\n }\n\n // Clip to negative box side 1\n const np2 = clipSegmentToLine(clipPoints2, clipPoints1, rf.sideNormal2, rf.sideOffset2, rf.i2);\n\n if (np2 < Settings.maxManifoldPoints) {\n return;\n }\n\n // Now clipPoints2 contains the clipped points.\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n matrix.copyVec2(manifold.localNormal, rf.normal);\n matrix.copyVec2(manifold.localPoint, rf.v1);\n } else {\n matrix.copyVec2(manifold.localNormal, polygonB.m_normals[rf.i1]);\n matrix.copyVec2(manifold.localPoint, polygonB.m_vertices[rf.i1]);\n }\n\n let pointCount = 0;\n for (let i = 0; i < Settings.maxManifoldPoints; ++i) {\n const separation = matrix.dotVec2(rf.normal, clipPoints2[i].v) - matrix.dotVec2(rf.normal, rf.v1);\n\n if (separation <= radius) {\n const cp = manifold.points[pointCount]; // ManifoldPoint\n\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n matrix.detransformVec2(cp.localPoint, xf, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n } else {\n matrix.copyVec2(cp.localPoint, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n cp.id.swapFeatures();\n }\n\n ++pointCount;\n }\n }\n\n manifold.pointCount = pointCount;\n};\n","import { CollidePolygons } from \"./collision/shape/CollidePolygon\";\nimport { Settings } from \"./Settings\";\nimport { Sweep } from \"./common/Sweep\";\nimport { DynamicTree } from \"./collision/DynamicTree\";\nimport { Manifold } from \"./collision/Manifold\";\nimport { Distance } from \"./collision/Distance\";\nimport { TimeOfImpact } from \"./collision/TimeOfImpact\";\nimport { stats } from \"./util/stats\";\n\n/** @hidden @deprecated Merged with main namespace */\nexport const internal = {\n CollidePolygons,\n Settings,\n Sweep,\n Manifold,\n Distance,\n TimeOfImpact,\n DynamicTree,\n stats\n};\n","/**\n * Stage.js 1.0.0-alpha.5\n *\n * @copyright Copyright (c) 2024 Ali Shakiba\n * @license The MIT License (MIT)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\nvar math_random = Math.random;\nvar math_sqrt = Math.sqrt;\nfunction random(min, max) {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n return min == max ? min : math_random() * (max - min) + min;\n}\nfunction wrap(num, min, max) {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n if (max > min) {\n num = (num - min) % (max - min);\n return num + (num < 0 ? max : min);\n } else {\n num = (num - max) % (min - max);\n return num + (num <= 0 ? min : max);\n }\n}\nfunction clamp(num, min, max) {\n if (num < min) {\n return min;\n } else if (num > max) {\n return max;\n } else {\n return num;\n }\n}\nfunction length(x, y) {\n return math_sqrt(x * x + y * y);\n}\nvar math = Object.create(Math);\nmath.random = random;\nmath.wrap = wrap;\nmath.clamp = clamp;\nmath.length = length;\nmath.rotate = wrap;\nmath.limit = clamp;\nvar Matrix = (\n /** @class */\n function() {\n function Matrix2(a, b, c, d, e, f) {\n this.a = 1;\n this.b = 0;\n this.c = 0;\n this.d = 1;\n this.e = 0;\n this.f = 0;\n if (typeof a === \"object\") {\n this.reset(a);\n } else {\n this.reset(a, b, c, d, e, f);\n }\n }\n Matrix2.prototype.toString = function() {\n return \"[\" + this.a + \", \" + this.b + \", \" + this.c + \", \" + this.d + \", \" + this.e + \", \" + this.f + \"]\";\n };\n Matrix2.prototype.clone = function() {\n return new Matrix2(this.a, this.b, this.c, this.d, this.e, this.f);\n };\n Matrix2.prototype.reset = function(a, b, c, d, e, f) {\n this._dirty = true;\n if (typeof a === \"object\") {\n this.a = a.a;\n this.d = a.d;\n this.b = a.b;\n this.c = a.c;\n this.e = a.e;\n this.f = a.f;\n } else {\n this.a = typeof a === \"number\" ? a : 1;\n this.b = typeof b === \"number\" ? b : 0;\n this.c = typeof c === \"number\" ? c : 0;\n this.d = typeof d === \"number\" ? d : 1;\n this.e = typeof e === \"number\" ? e : 0;\n this.f = typeof f === \"number\" ? f : 0;\n }\n return this;\n };\n Matrix2.prototype.identity = function() {\n this._dirty = true;\n this.a = 1;\n this.b = 0;\n this.c = 0;\n this.d = 1;\n this.e = 0;\n this.f = 0;\n return this;\n };\n Matrix2.prototype.rotate = function(angle) {\n if (!angle) {\n return this;\n }\n this._dirty = true;\n var u = angle ? Math.cos(angle) : 1;\n var v = angle ? Math.sin(angle) : 0;\n var a = u * this.a - v * this.b;\n var b = u * this.b + v * this.a;\n var c = u * this.c - v * this.d;\n var d = u * this.d + v * this.c;\n var e = u * this.e - v * this.f;\n var f = u * this.f + v * this.e;\n this.a = a;\n this.b = b;\n this.c = c;\n this.d = d;\n this.e = e;\n this.f = f;\n return this;\n };\n Matrix2.prototype.translate = function(x, y) {\n if (!x && !y) {\n return this;\n }\n this._dirty = true;\n this.e += x;\n this.f += y;\n return this;\n };\n Matrix2.prototype.scale = function(x, y) {\n if (!(x - 1) && !(y - 1)) {\n return this;\n }\n this._dirty = true;\n this.a *= x;\n this.b *= y;\n this.c *= x;\n this.d *= y;\n this.e *= x;\n this.f *= y;\n return this;\n };\n Matrix2.prototype.skew = function(x, y) {\n if (!x && !y) {\n return this;\n }\n this._dirty = true;\n var a = this.a + this.b * x;\n var b = this.b + this.a * y;\n var c = this.c + this.d * x;\n var d = this.d + this.c * y;\n var e = this.e + this.f * x;\n var f = this.f + this.e * y;\n this.a = a;\n this.b = b;\n this.c = c;\n this.d = d;\n this.e = e;\n this.f = f;\n return this;\n };\n Matrix2.prototype.concat = function(m) {\n this._dirty = true;\n var a = this.a * m.a + this.b * m.c;\n var b = this.b * m.d + this.a * m.b;\n var c = this.c * m.a + this.d * m.c;\n var d = this.d * m.d + this.c * m.b;\n var e = this.e * m.a + m.e + this.f * m.c;\n var f = this.f * m.d + m.f + this.e * m.b;\n this.a = a;\n this.b = b;\n this.c = c;\n this.d = d;\n this.e = e;\n this.f = f;\n return this;\n };\n Matrix2.prototype.inverse = function() {\n if (this._dirty) {\n this._dirty = false;\n if (!this.inverted) {\n this.inverted = new Matrix2();\n }\n var z = this.a * this.d - this.b * this.c;\n this.inverted.a = this.d / z;\n this.inverted.b = -this.b / z;\n this.inverted.c = -this.c / z;\n this.inverted.d = this.a / z;\n this.inverted.e = (this.c * this.f - this.e * this.d) / z;\n this.inverted.f = (this.e * this.b - this.a * this.f) / z;\n }\n return this.inverted;\n };\n Matrix2.prototype.map = function(p, q) {\n q = q || { x: 0, y: 0 };\n q.x = this.a * p.x + this.c * p.y + this.e;\n q.y = this.b * p.x + this.d * p.y + this.f;\n return q;\n };\n Matrix2.prototype.mapX = function(x, y) {\n if (typeof x === \"object\") {\n y = x.y;\n x = x.x;\n }\n return this.a * x + this.c * y + this.e;\n };\n Matrix2.prototype.mapY = function(x, y) {\n if (typeof x === \"object\") {\n y = x.y;\n x = x.x;\n }\n return this.b * x + this.d * y + this.f;\n };\n return Matrix2;\n }()\n);\nvar objectToString = Object.prototype.toString;\nfunction isFn(value) {\n var str = objectToString.call(value);\n return str === \"[object Function]\" || str === \"[object GeneratorFunction]\" || str === \"[object AsyncFunction]\";\n}\nfunction isHash(value) {\n return objectToString.call(value) === \"[object Object]\" && value.constructor === Object;\n}\nconst stats = {\n create: 0,\n tick: 0,\n node: 0,\n draw: 0,\n fps: 0\n};\nvar uid = function() {\n return Date.now().toString(36) + Math.random().toString(36).slice(2);\n};\nvar Texture = (\n /** @class */\n function() {\n function Texture2() {\n this.uid = \"texture:\" + uid();\n this.sx = 0;\n this.sy = 0;\n this.dx = 0;\n this.dy = 0;\n }\n Texture2.prototype.setSourceCoordinate = function(x, y) {\n this.sx = x;\n this.sy = y;\n };\n Texture2.prototype.setSourceDimension = function(w, h) {\n this.sw = w;\n this.sh = h;\n };\n Texture2.prototype.setDestinationCoordinate = function(x, y) {\n this.dx = x;\n this.dy = y;\n };\n Texture2.prototype.setDestinationDimension = function(w, h) {\n this.dw = w;\n this.dh = h;\n };\n Texture2.prototype.draw = function(context, x1, y1, w1, h1, x2, y2, w2, h2) {\n var sx = this.sx;\n var sy = this.sy;\n var sw = this.sw;\n var sh = this.sh;\n var dx = this.dx;\n var dy = this.dy;\n var dw = this.dw;\n var dh = this.dh;\n if (typeof x1 === \"number\" || typeof y1 === \"number\" || typeof w1 === \"number\" || typeof h1 === \"number\" || typeof x2 === \"number\" || typeof y2 === \"number\" || typeof w2 === \"number\" || typeof h2 === \"number\") {\n if (typeof x2 === \"number\" || typeof y2 === \"number\" || typeof w2 === \"number\" || typeof h2 === \"number\") {\n sx += x1;\n sy += y1;\n sw = w1 !== null && w1 !== void 0 ? w1 : sw;\n sh = h1 !== null && h1 !== void 0 ? h1 : sh;\n dx += x2;\n dy += y2;\n dw = w2 !== null && w2 !== void 0 ? w2 : dw;\n dh = h2 !== null && h2 !== void 0 ? h2 : dh;\n } else {\n dx += x1;\n dy += y1;\n dw = w1;\n dh = h1;\n }\n }\n this.drawWithNormalizedArgs(context, sx, sy, sw, sh, dx, dy, dw, dh);\n };\n return Texture2;\n }()\n);\nvar __extends$9 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar ImageTexture = (\n /** @class */\n function(_super) {\n __extends$9(ImageTexture2, _super);\n function ImageTexture2(source, pixelRatio) {\n var _this = _super.call(this) || this;\n _this._pixelRatio = 1;\n if (typeof source === \"object\") {\n _this.setSourceImage(source, pixelRatio);\n }\n return _this;\n }\n ImageTexture2.prototype.setSourceImage = function(image2, pixelRatio) {\n if (pixelRatio === void 0) {\n pixelRatio = 1;\n }\n this._source = image2;\n this._pixelRatio = pixelRatio;\n };\n ImageTexture2.prototype.getWidth = function() {\n return this._source.width / this._pixelRatio;\n };\n ImageTexture2.prototype.getHeight = function() {\n return this._source.height / this._pixelRatio;\n };\n ImageTexture2.prototype.prerender = function(context) {\n return false;\n };\n ImageTexture2.prototype.drawWithNormalizedArgs = function(context, sx, sy, sw, sh, dx, dy, dw, dh) {\n var image2 = this._source;\n if (image2 === null || typeof image2 !== \"object\") {\n return;\n }\n sw = sw !== null && sw !== void 0 ? sw : this.getWidth();\n sh = sh !== null && sh !== void 0 ? sh : this.getHeight();\n dw = dw !== null && dw !== void 0 ? dw : sw;\n dh = dh !== null && dh !== void 0 ? dh : sh;\n sx *= this._pixelRatio;\n sy *= this._pixelRatio;\n sw *= this._pixelRatio;\n sh *= this._pixelRatio;\n try {\n stats.draw++;\n context.drawImage(image2, sx, sy, sw, sh, dx, dy, dw, dh);\n } catch (ex) {\n if (!this._draw_failed) {\n console.log(\"Unable to draw: \", image2);\n console.log(ex);\n this._draw_failed = true;\n }\n }\n };\n return ImageTexture2;\n }(Texture)\n);\nvar __extends$8 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar PipeTexture = (\n /** @class */\n function(_super) {\n __extends$8(PipeTexture2, _super);\n function PipeTexture2(source) {\n var _this = _super.call(this) || this;\n _this._source = source;\n return _this;\n }\n PipeTexture2.prototype.setSourceTexture = function(texture2) {\n this._source = texture2;\n };\n PipeTexture2.prototype.getWidth = function() {\n var _a, _b;\n return (_b = (_a = this.dw) !== null && _a !== void 0 ? _a : this.sw) !== null && _b !== void 0 ? _b : this._source.getWidth();\n };\n PipeTexture2.prototype.getHeight = function() {\n var _a, _b;\n return (_b = (_a = this.dh) !== null && _a !== void 0 ? _a : this.sh) !== null && _b !== void 0 ? _b : this._source.getHeight();\n };\n PipeTexture2.prototype.prerender = function(context) {\n return this._source.prerender(context);\n };\n PipeTexture2.prototype.drawWithNormalizedArgs = function(context, sx, sy, sw, sh, dx, dy, dw, dh) {\n var texture2 = this._source;\n if (texture2 === null || typeof texture2 !== \"object\") {\n return;\n }\n texture2.draw(context, sx, sy, sw, sh, dx, dy, dw, dh);\n };\n return PipeTexture2;\n }(Texture)\n);\nvar __extends$7 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar __awaiter$1 = function(thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function(resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function(resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator$1 = function(thisArg, body) {\n var _ = { label: 0, sent: function() {\n if (t[0] & 1)\n throw t[1];\n return t[1];\n }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() {\n return this;\n }), g;\n function verb(n) {\n return function(v) {\n return step([n, v]);\n };\n }\n function step(op) {\n if (f)\n throw new TypeError(\"Generator is already executing.\");\n while (_)\n try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)\n return t;\n if (y = 0, t)\n op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0:\n case 1:\n t = op;\n break;\n case 4:\n _.label++;\n return { value: op[1], done: false };\n case 5:\n _.label++;\n y = op[1];\n op = [0];\n continue;\n case 7:\n op = _.ops.pop();\n _.trys.pop();\n continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {\n _ = 0;\n continue;\n }\n if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {\n _.label = op[1];\n break;\n }\n if (op[0] === 6 && _.label < t[1]) {\n _.label = t[1];\n t = op;\n break;\n }\n if (t && _.label < t[2]) {\n _.label = t[2];\n _.ops.push(op);\n break;\n }\n if (t[2])\n _.ops.pop();\n _.trys.pop();\n continue;\n }\n op = body.call(thisArg, _);\n } catch (e) {\n op = [6, e];\n y = 0;\n } finally {\n f = t = 0;\n }\n if (op[0] & 5)\n throw op[1];\n return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar Atlas = (\n /** @class */\n function(_super) {\n __extends$7(Atlas2, _super);\n function Atlas2(def) {\n if (def === void 0) {\n def = {};\n }\n var _this = _super.call(this) || this;\n _this.pipeSpriteTexture = function(def2) {\n var map = _this._map;\n var ppu = _this._ppu;\n var trim = _this._trim;\n if (!def2) {\n return void 0;\n }\n def2 = Object.assign({}, def2);\n if (isFn(map)) {\n def2 = map(def2);\n }\n if (ppu != 1) {\n def2.x *= ppu;\n def2.y *= ppu;\n def2.width *= ppu;\n def2.height *= ppu;\n def2.top *= ppu;\n def2.bottom *= ppu;\n def2.left *= ppu;\n def2.right *= ppu;\n }\n if (trim != 0) {\n def2.x += trim;\n def2.y += trim;\n def2.width -= 2 * trim;\n def2.height -= 2 * trim;\n def2.top -= trim;\n def2.bottom -= trim;\n def2.left -= trim;\n def2.right -= trim;\n }\n var texture2 = new PipeTexture(_this);\n texture2.top = def2.top;\n texture2.bottom = def2.bottom;\n texture2.left = def2.left;\n texture2.right = def2.right;\n texture2.setSourceCoordinate(def2.x, def2.y);\n texture2.setSourceDimension(def2.width, def2.height);\n return texture2;\n };\n _this.findSpriteDefinition = function(query) {\n var textures = _this._textures;\n if (textures) {\n if (isFn(textures)) {\n return textures(query);\n } else if (isHash(textures)) {\n return textures[query];\n }\n }\n };\n _this.select = function(query) {\n if (!query) {\n return new TextureSelection(new PipeTexture(_this));\n }\n var textureDefinition = _this.findSpriteDefinition(query);\n if (textureDefinition) {\n return new TextureSelection(textureDefinition, _this);\n }\n };\n _this.name = def.name;\n _this._ppu = def.ppu || def.ratio || 1;\n _this._trim = def.trim || 0;\n _this._map = def.map || def.filter;\n _this._textures = def.textures;\n if (typeof def.image === \"object\" && isHash(def.image)) {\n _this._imageSrc = def.image.src || def.image.url;\n if (typeof def.image.ratio === \"number\") {\n _this._pixelRatio = def.image.ratio;\n }\n } else {\n if (typeof def.imagePath === \"string\") {\n _this._imageSrc = def.imagePath;\n } else if (typeof def.image === \"string\") {\n _this._imageSrc = def.image;\n }\n if (typeof def.imageRatio === \"number\") {\n _this._pixelRatio = def.imageRatio;\n }\n }\n deprecatedWarning(def);\n return _this;\n }\n Atlas2.prototype.load = function() {\n return __awaiter$1(this, void 0, void 0, function() {\n var image2;\n return __generator$1(this, function(_a) {\n switch (_a.label) {\n case 0:\n if (!this._imageSrc)\n return [3, 2];\n return [4, asyncLoadImage(this._imageSrc)];\n case 1:\n image2 = _a.sent();\n this.setSourceImage(image2, this._pixelRatio);\n _a.label = 2;\n case 2:\n return [\n 2\n /*return*/\n ];\n }\n });\n });\n };\n return Atlas2;\n }(ImageTexture)\n);\nfunction asyncLoadImage(src) {\n return new Promise(function(resolve, reject) {\n var img = new Image();\n img.onload = function() {\n resolve(img);\n };\n img.onerror = function(error) {\n console.error(\"Loading failed: \" + src);\n reject(error);\n };\n img.src = src;\n });\n}\nfunction deprecatedWarning(def) {\n if (\"filter\" in def)\n console.warn(\"'filter' field of atlas definition is deprecated\");\n if (\"cutouts\" in def)\n console.warn(\"'cutouts' field of atlas definition is deprecated\");\n if (\"sprites\" in def)\n console.warn(\"'sprites' field of atlas definition is deprecated\");\n if (\"factory\" in def)\n console.warn(\"'factory' field of atlas definition is deprecated\");\n if (\"ratio\" in def)\n console.warn(\"'ratio' field of atlas definition is deprecated\");\n if (\"imagePath\" in def)\n console.warn(\"'imagePath' field of atlas definition is deprecated\");\n if (\"imageRatio\" in def)\n console.warn(\"'imageRatio' field of atlas definition is deprecated\");\n if (typeof def.image === \"object\" && \"url\" in def.image)\n console.warn(\"'image.url' field of atlas definition is deprecated\");\n}\nvar __extends$6 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar __awaiter = function(thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function(resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function(resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = function(thisArg, body) {\n var _ = { label: 0, sent: function() {\n if (t[0] & 1)\n throw t[1];\n return t[1];\n }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() {\n return this;\n }), g;\n function verb(n) {\n return function(v) {\n return step([n, v]);\n };\n }\n function step(op) {\n if (f)\n throw new TypeError(\"Generator is already executing.\");\n while (_)\n try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)\n return t;\n if (y = 0, t)\n op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0:\n case 1:\n t = op;\n break;\n case 4:\n _.label++;\n return { value: op[1], done: false };\n case 5:\n _.label++;\n y = op[1];\n op = [0];\n continue;\n case 7:\n op = _.ops.pop();\n _.trys.pop();\n continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {\n _ = 0;\n continue;\n }\n if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {\n _.label = op[1];\n break;\n }\n if (op[0] === 6 && _.label < t[1]) {\n _.label = t[1];\n t = op;\n break;\n }\n if (t && _.label < t[2]) {\n _.label = t[2];\n _.ops.push(op);\n break;\n }\n if (t[2])\n _.ops.pop();\n _.trys.pop();\n continue;\n }\n op = body.call(thisArg, _);\n } catch (e) {\n op = [6, e];\n y = 0;\n } finally {\n f = t = 0;\n }\n if (op[0] & 5)\n throw op[1];\n return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nfunction isAtlasSpriteDefinition(selection) {\n return typeof selection === \"object\" && isHash(selection) && \"number\" === typeof selection.width && \"number\" === typeof selection.height;\n}\nvar TextureSelection = (\n /** @class */\n function() {\n function TextureSelection2(selection, atlas2) {\n this.selection = selection;\n this.atlas = atlas2;\n }\n TextureSelection2.prototype.resolve = function(selection, subquery) {\n if (!selection) {\n return NO_TEXTURE;\n } else if (Array.isArray(selection)) {\n return this.resolve(selection[0]);\n } else if (selection instanceof Texture) {\n return selection;\n } else if (isAtlasSpriteDefinition(selection)) {\n if (!this.atlas) {\n return NO_TEXTURE;\n }\n return this.atlas.pipeSpriteTexture(selection);\n } else if (typeof selection === \"object\" && isHash(selection) && typeof subquery !== \"undefined\") {\n return this.resolve(selection[subquery]);\n } else if (typeof selection === \"function\" && isFn(selection)) {\n return this.resolve(selection(subquery));\n } else if (typeof selection === \"string\") {\n if (!this.atlas) {\n return NO_TEXTURE;\n }\n return this.resolve(this.atlas.findSpriteDefinition(selection));\n }\n };\n TextureSelection2.prototype.one = function(subquery) {\n return this.resolve(this.selection, subquery);\n };\n TextureSelection2.prototype.array = function(arr) {\n var array = Array.isArray(arr) ? arr : [];\n if (Array.isArray(this.selection)) {\n for (var i = 0; i < this.selection.length; i++) {\n array[i] = this.resolve(this.selection[i]);\n }\n } else {\n array[0] = this.resolve(this.selection);\n }\n return array;\n };\n return TextureSelection2;\n }()\n);\nvar NO_TEXTURE = new /** @class */\n(function(_super) {\n __extends$6(class_1, _super);\n function class_1() {\n var _this = _super.call(this) || this;\n _this.setSourceDimension(0, 0);\n return _this;\n }\n class_1.prototype.getWidth = function() {\n return 0;\n };\n class_1.prototype.getHeight = function() {\n return 0;\n };\n class_1.prototype.prerender = function(context) {\n return false;\n };\n class_1.prototype.drawWithNormalizedArgs = function(context, sx, sy, sw, sh, dx, dy, dw, dh) {\n };\n class_1.prototype.setSourceCoordinate = function(x, y) {\n };\n class_1.prototype.setSourceDimension = function(w, h) {\n };\n class_1.prototype.setDestinationCoordinate = function(x, y) {\n };\n class_1.prototype.setDestinationDimension = function(w, h) {\n };\n class_1.prototype.draw = function() {\n };\n return class_1;\n}(Texture))();\nvar NO_SELECTION = new TextureSelection(NO_TEXTURE);\nvar ATLAS_MEMO_BY_NAME = {};\nvar ATLAS_ARRAY = [];\nfunction atlas(def) {\n return __awaiter(this, void 0, Promise, function() {\n var atlas2;\n return __generator(this, function(_a) {\n switch (_a.label) {\n case 0:\n if (def instanceof Atlas) {\n atlas2 = def;\n } else {\n atlas2 = new Atlas(def);\n }\n if (atlas2.name) {\n ATLAS_MEMO_BY_NAME[atlas2.name] = atlas2;\n }\n ATLAS_ARRAY.push(atlas2);\n return [4, atlas2.load()];\n case 1:\n _a.sent();\n return [2, atlas2];\n }\n });\n });\n}\nfunction texture(query) {\n if (\"string\" !== typeof query) {\n return new TextureSelection(query);\n }\n var result = null;\n var colonIndex = query.indexOf(\":\");\n if (colonIndex > 0 && query.length > colonIndex + 1) {\n var atlas_1 = ATLAS_MEMO_BY_NAME[query.slice(0, colonIndex)];\n result = atlas_1 && atlas_1.select(query.slice(colonIndex + 1));\n }\n if (!result) {\n var atlas_2 = ATLAS_MEMO_BY_NAME[query];\n result = atlas_2 && atlas_2.select();\n }\n if (!result) {\n for (var i = 0; i < ATLAS_ARRAY.length; i++) {\n result = ATLAS_ARRAY[i].select(query);\n if (result) {\n break;\n }\n }\n }\n if (!result) {\n console.error(\"Texture not found: \" + query);\n result = NO_SELECTION;\n }\n return result;\n}\nvar __extends$5 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar ResizableTexture = (\n /** @class */\n function(_super) {\n __extends$5(ResizableTexture2, _super);\n function ResizableTexture2(source, mode) {\n var _this = _super.call(this) || this;\n _this._source = source;\n _this._resizeMode = mode;\n return _this;\n }\n ResizableTexture2.prototype.getWidth = function() {\n var _a;\n return (_a = this.dw) !== null && _a !== void 0 ? _a : this._source.getWidth();\n };\n ResizableTexture2.prototype.getHeight = function() {\n var _a;\n return (_a = this.dh) !== null && _a !== void 0 ? _a : this._source.getHeight();\n };\n ResizableTexture2.prototype.prerender = function(context) {\n return false;\n };\n ResizableTexture2.prototype.drawWithNormalizedArgs = function(context, sx, sy, sw, sh, dx, dy, dw, dh) {\n var texture2 = this._source;\n if (texture2 === null || typeof texture2 !== \"object\") {\n return;\n }\n var outWidth = dw;\n var outHeight = dh;\n var left = Number.isFinite(texture2.left) ? texture2.left : 0;\n var right = Number.isFinite(texture2.right) ? texture2.right : 0;\n var top = Number.isFinite(texture2.top) ? texture2.top : 0;\n var bottom = Number.isFinite(texture2.bottom) ? texture2.bottom : 0;\n var width = texture2.getWidth() - left - right;\n var height = texture2.getHeight() - top - bottom;\n if (!this._innerSize) {\n outWidth = Math.max(outWidth - left - right, 0);\n outHeight = Math.max(outHeight - top - bottom, 0);\n }\n if (top > 0 && left > 0) {\n texture2.draw(context, 0, 0, left, top, 0, 0, left, top);\n }\n if (bottom > 0 && left > 0) {\n texture2.draw(context, 0, height + top, left, bottom, 0, outHeight + top, left, bottom);\n }\n if (top > 0 && right > 0) {\n texture2.draw(context, width + left, 0, right, top, outWidth + left, 0, right, top);\n }\n if (bottom > 0 && right > 0) {\n texture2.draw(context, width + left, height + top, right, bottom, outWidth + left, outHeight + top, right, bottom);\n }\n if (this._resizeMode === \"stretch\") {\n if (top > 0) {\n texture2.draw(context, left, 0, width, top, left, 0, outWidth, top);\n }\n if (bottom > 0) {\n texture2.draw(context, left, height + top, width, bottom, left, outHeight + top, outWidth, bottom);\n }\n if (left > 0) {\n texture2.draw(context, 0, top, left, height, 0, top, left, outHeight);\n }\n if (right > 0) {\n texture2.draw(context, width + left, top, right, height, outWidth + left, top, right, outHeight);\n }\n texture2.draw(context, left, top, width, height, left, top, outWidth, outHeight);\n } else if (this._resizeMode === \"tile\") {\n var l = left;\n var r = outWidth;\n var w = void 0;\n while (r > 0) {\n w = Math.min(width, r);\n r -= width;\n var t = top;\n var b = outHeight;\n var h = void 0;\n while (b > 0) {\n h = Math.min(height, b);\n b -= height;\n texture2.draw(context, left, top, w, h, l, t, w, h);\n if (r <= 0) {\n if (left) {\n texture2.draw(context, 0, top, left, h, 0, t, left, h);\n }\n if (right) {\n texture2.draw(context, width + left, top, right, h, l + w, t, right, h);\n }\n }\n t += h;\n }\n if (top) {\n texture2.draw(context, left, 0, w, top, l, 0, w, top);\n }\n if (bottom) {\n texture2.draw(context, left, height + top, w, bottom, l, t, w, bottom);\n }\n l += w;\n }\n }\n };\n return ResizableTexture2;\n }(Texture)\n);\nfunction getPixelRatio() {\n return typeof window !== \"undefined\" ? window.devicePixelRatio || 1 : 1;\n}\nfunction isValidFitMode(value) {\n return value && (value === \"cover\" || value === \"contain\" || value === \"fill\" || value === \"in\" || value === \"in-pad\" || value === \"out\" || value === \"out-crop\");\n}\nvar iid$1 = 0;\nvar Pin = (\n /** @class */\n function() {\n function Pin2(owner) {\n this.uid = \"pin:\" + uid();\n this._owner = owner;\n this._parent = null;\n this._relativeMatrix = new Matrix();\n this._absoluteMatrix = new Matrix();\n this.reset();\n }\n Pin2.prototype.reset = function() {\n this._textureAlpha = 1;\n this._alpha = 1;\n this._width = 0;\n this._height = 0;\n this._scaleX = 1;\n this._scaleY = 1;\n this._skewX = 0;\n this._skewY = 0;\n this._rotation = 0;\n this._pivoted = false;\n this._pivotX = 0;\n this._pivotY = 0;\n this._handled = false;\n this._handleX = 0;\n this._handleY = 0;\n this._aligned = false;\n this._alignX = 0;\n this._alignY = 0;\n this._offsetX = 0;\n this._offsetY = 0;\n this._boxX = 0;\n this._boxY = 0;\n this._boxWidth = this._width;\n this._boxHeight = this._height;\n this._ts_translate = ++iid$1;\n this._ts_transform = ++iid$1;\n this._ts_matrix = ++iid$1;\n };\n Pin2.prototype._update = function() {\n this._parent = this._owner._parent && this._owner._parent._pin;\n if (this._handled && this._mo_handle != this._ts_transform) {\n this._mo_handle = this._ts_transform;\n this._ts_translate = ++iid$1;\n }\n if (this._aligned && this._parent && this._mo_align != this._parent._ts_transform) {\n this._mo_align = this._parent._ts_transform;\n this._ts_translate = ++iid$1;\n }\n return this;\n };\n Pin2.prototype.toString = function() {\n return this._owner + \" (\" + (this._parent ? this._parent._owner : null) + \")\";\n };\n Pin2.prototype.absoluteMatrix = function() {\n this._update();\n var ts = Math.max(this._ts_transform, this._ts_translate, this._parent ? this._parent._ts_matrix : 0);\n if (this._mo_abs == ts) {\n return this._absoluteMatrix;\n }\n this._mo_abs = ts;\n var abs = this._absoluteMatrix;\n abs.reset(this.relativeMatrix());\n this._parent && abs.concat(this._parent._absoluteMatrix);\n this._ts_matrix = ++iid$1;\n return abs;\n };\n Pin2.prototype.relativeMatrix = function() {\n this._update();\n var ts = Math.max(this._ts_transform, this._ts_translate, this._parent ? this._parent._ts_transform : 0);\n if (this._mo_rel == ts) {\n return this._relativeMatrix;\n }\n this._mo_rel = ts;\n var rel = this._relativeMatrix;\n rel.identity();\n if (this._pivoted) {\n rel.translate(-this._pivotX * this._width, -this._pivotY * this._height);\n }\n rel.scale(this._scaleX, this._scaleY);\n rel.skew(this._skewX, this._skewY);\n rel.rotate(this._rotation);\n if (this._pivoted) {\n rel.translate(this._pivotX * this._width, this._pivotY * this._height);\n }\n if (this._pivoted) {\n this._boxX = 0;\n this._boxY = 0;\n this._boxWidth = this._width;\n this._boxHeight = this._height;\n } else {\n var p = void 0;\n var q = void 0;\n if (rel.a > 0 && rel.c > 0 || rel.a < 0 && rel.c < 0) {\n p = 0;\n q = rel.a * this._width + rel.c * this._height;\n } else {\n p = rel.a * this._width;\n q = rel.c * this._height;\n }\n if (p > q) {\n this._boxX = q;\n this._boxWidth = p - q;\n } else {\n this._boxX = p;\n this._boxWidth = q - p;\n }\n if (rel.b > 0 && rel.d > 0 || rel.b < 0 && rel.d < 0) {\n p = 0;\n q = rel.b * this._width + rel.d * this._height;\n } else {\n p = rel.b * this._width;\n q = rel.d * this._height;\n }\n if (p > q) {\n this._boxY = q;\n this._boxHeight = p - q;\n } else {\n this._boxY = p;\n this._boxHeight = q - p;\n }\n }\n this._x = this._offsetX;\n this._y = this._offsetY;\n this._x -= this._boxX + this._handleX * this._boxWidth;\n this._y -= this._boxY + this._handleY * this._boxHeight;\n if (this._aligned && this._parent) {\n this._parent.relativeMatrix();\n this._x += this._alignX * this._parent._width;\n this._y += this._alignY * this._parent._height;\n }\n rel.translate(this._x, this._y);\n return this._relativeMatrix;\n };\n Pin2.prototype.get = function(key) {\n if (typeof getters[key] === \"function\") {\n return getters[key](this);\n }\n };\n Pin2.prototype.set = function(a, b) {\n if (typeof a === \"string\") {\n if (typeof setters[a] === \"function\" && typeof b !== \"undefined\") {\n setters[a](this, b);\n }\n } else if (typeof a === \"object\") {\n for (b in a) {\n if (typeof setters[b] === \"function\" && typeof a[b] !== \"undefined\") {\n setters[b](this, a[b], a);\n }\n }\n }\n if (this._owner) {\n this._owner._ts_pin = ++iid$1;\n this._owner.touch();\n }\n return this;\n };\n Pin2.prototype.fit = function(width, height, mode) {\n this._ts_transform = ++iid$1;\n if (mode === \"contain\") {\n mode = \"in-pad\";\n }\n if (mode === \"cover\") {\n mode = \"out-crop\";\n }\n if (typeof width === \"number\") {\n this._scaleX = width / this._unscaled_width;\n this._width = this._unscaled_width;\n }\n if (typeof height === \"number\") {\n this._scaleY = height / this._unscaled_height;\n this._height = this._unscaled_height;\n }\n if (typeof width === \"number\" && typeof height === \"number\" && typeof mode === \"string\") {\n if (mode === \"fill\")\n ;\n else if (mode === \"out\" || mode === \"out-crop\") {\n this._scaleX = this._scaleY = Math.max(this._scaleX, this._scaleY);\n } else if (mode === \"in\" || mode === \"in-pad\") {\n this._scaleX = this._scaleY = Math.min(this._scaleX, this._scaleY);\n }\n if (mode === \"out-crop\" || mode === \"in-pad\") {\n this._width = width / this._scaleX;\n this._height = height / this._scaleY;\n }\n }\n };\n return Pin2;\n }()\n);\nvar getters = {\n alpha: function(pin) {\n return pin._alpha;\n },\n textureAlpha: function(pin) {\n return pin._textureAlpha;\n },\n width: function(pin) {\n return pin._width;\n },\n height: function(pin) {\n return pin._height;\n },\n boxWidth: function(pin) {\n return pin._boxWidth;\n },\n boxHeight: function(pin) {\n return pin._boxHeight;\n },\n // scale : function(pin: Pin) {\n // },\n scaleX: function(pin) {\n return pin._scaleX;\n },\n scaleY: function(pin) {\n return pin._scaleY;\n },\n // skew : function(pin: Pin) {\n // },\n skewX: function(pin) {\n return pin._skewX;\n },\n skewY: function(pin) {\n return pin._skewY;\n },\n rotation: function(pin) {\n return pin._rotation;\n },\n // pivot : function(pin: Pin) {\n // },\n pivotX: function(pin) {\n return pin._pivotX;\n },\n pivotY: function(pin) {\n return pin._pivotY;\n },\n // offset : function(pin: Pin) {\n // },\n offsetX: function(pin) {\n return pin._offsetX;\n },\n offsetY: function(pin) {\n return pin._offsetY;\n },\n // align : function(pin: Pin) {\n // },\n alignX: function(pin) {\n return pin._alignX;\n },\n alignY: function(pin) {\n return pin._alignY;\n },\n // handle : function(pin: Pin) {\n // },\n handleX: function(pin) {\n return pin._handleX;\n },\n handleY: function(pin) {\n return pin._handleY;\n }\n};\nvar setters = {\n alpha: function(pin, value) {\n pin._alpha = value;\n },\n textureAlpha: function(pin, value) {\n pin._textureAlpha = value;\n },\n width: function(pin, value) {\n pin._unscaled_width = value;\n pin._width = value;\n pin._ts_transform = ++iid$1;\n },\n height: function(pin, value) {\n pin._unscaled_height = value;\n pin._height = value;\n pin._ts_transform = ++iid$1;\n },\n scale: function(pin, value) {\n pin._scaleX = value;\n pin._scaleY = value;\n pin._ts_transform = ++iid$1;\n },\n scaleX: function(pin, value) {\n pin._scaleX = value;\n pin._ts_transform = ++iid$1;\n },\n scaleY: function(pin, value) {\n pin._scaleY = value;\n pin._ts_transform = ++iid$1;\n },\n skew: function(pin, value) {\n pin._skewX = value;\n pin._skewY = value;\n pin._ts_transform = ++iid$1;\n },\n skewX: function(pin, value) {\n pin._skewX = value;\n pin._ts_transform = ++iid$1;\n },\n skewY: function(pin, value) {\n pin._skewY = value;\n pin._ts_transform = ++iid$1;\n },\n rotation: function(pin, value) {\n pin._rotation = value;\n pin._ts_transform = ++iid$1;\n },\n pivot: function(pin, value) {\n pin._pivotX = value;\n pin._pivotY = value;\n pin._pivoted = true;\n pin._ts_transform = ++iid$1;\n },\n pivotX: function(pin, value) {\n pin._pivotX = value;\n pin._pivoted = true;\n pin._ts_transform = ++iid$1;\n },\n pivotY: function(pin, value) {\n pin._pivotY = value;\n pin._pivoted = true;\n pin._ts_transform = ++iid$1;\n },\n offset: function(pin, value) {\n pin._offsetX = value;\n pin._offsetY = value;\n pin._ts_translate = ++iid$1;\n },\n offsetX: function(pin, value) {\n pin._offsetX = value;\n pin._ts_translate = ++iid$1;\n },\n offsetY: function(pin, value) {\n pin._offsetY = value;\n pin._ts_translate = ++iid$1;\n },\n align: function(pin, value) {\n this.alignX(pin, value);\n this.alignY(pin, value);\n },\n alignX: function(pin, value) {\n pin._alignX = value;\n pin._aligned = true;\n pin._ts_translate = ++iid$1;\n this.handleX(pin, value);\n },\n alignY: function(pin, value) {\n pin._alignY = value;\n pin._aligned = true;\n pin._ts_translate = ++iid$1;\n this.handleY(pin, value);\n },\n handle: function(pin, value) {\n this.handleX(pin, value);\n this.handleY(pin, value);\n },\n handleX: function(pin, value) {\n pin._handleX = value;\n pin._handled = true;\n pin._ts_translate = ++iid$1;\n },\n handleY: function(pin, value) {\n pin._handleY = value;\n pin._handled = true;\n pin._ts_translate = ++iid$1;\n },\n resizeMode: function(pin, value, all) {\n if (all) {\n if (value == \"in\") {\n value = \"in-pad\";\n } else if (value == \"out\") {\n value = \"out-crop\";\n }\n pin.fit(all.resizeWidth, all.resizeHeight, value);\n }\n },\n resizeWidth: function(pin, value, all) {\n if (!all || !all.resizeMode) {\n pin.fit(value, null);\n }\n },\n resizeHeight: function(pin, value, all) {\n if (!all || !all.resizeMode) {\n pin.fit(null, value);\n }\n },\n scaleMode: function(pin, value, all) {\n if (all) {\n pin.fit(all.scaleWidth, all.scaleHeight, value);\n }\n },\n scaleWidth: function(pin, value, all) {\n if (!all || !all.scaleMode) {\n pin.fit(value, null);\n }\n },\n scaleHeight: function(pin, value, all) {\n if (!all || !all.scaleMode) {\n pin.fit(null, value);\n }\n },\n matrix: function(pin, value) {\n this.scaleX(pin, value.a);\n this.skewX(pin, value.c / value.d);\n this.skewY(pin, value.b / value.a);\n this.scaleY(pin, value.d);\n this.offsetX(pin, value.e);\n this.offsetY(pin, value.f);\n this.rotation(pin, 0);\n }\n};\nfunction IDENTITY(x) {\n return x;\n}\nvar LOOKUP_CACHE = {};\nvar MODE_BY_NAME = {};\nvar EASE_BY_NAME = {};\nvar Easing = (\n /** @class */\n function() {\n function Easing2() {\n }\n Easing2.get = function(token, fallback) {\n fallback = fallback || IDENTITY;\n if (typeof token === \"function\") {\n return token;\n }\n if (typeof token !== \"string\") {\n return fallback;\n }\n var easeFn = LOOKUP_CACHE[token];\n if (easeFn) {\n return easeFn;\n }\n var tokens = /^(\\w+)(-(in|out|in-out|out-in))?(\\((.*)\\))?$/i.exec(token);\n if (!tokens || !tokens.length) {\n return fallback;\n }\n var easeName = tokens[1];\n var easing = EASE_BY_NAME[easeName];\n var modeName = tokens[3];\n var modeFn = MODE_BY_NAME[modeName];\n var params = tokens[5];\n if (!easing) {\n easeFn = fallback;\n } else if (\"fn\" in easing && typeof easing.fn === \"function\") {\n easeFn = easing.fn;\n } else if (\"fc\" in easing && typeof easing.fc === \"function\") {\n var args = params ? params.replace(/\\s+/, \"\").split(\",\") : void 0;\n easeFn = easing.fc.apply(easing.fc, args);\n } else {\n easeFn = fallback;\n }\n if (modeFn) {\n easeFn = modeFn(easeFn);\n }\n LOOKUP_CACHE[token] = easeFn;\n return easeFn;\n };\n return Easing2;\n }()\n);\nfunction addMode(name, fn) {\n MODE_BY_NAME[name] = fn;\n}\nfunction addEaseFn(data) {\n var names = data.name.split(/\\s+/);\n for (var i = 0; i < names.length; i++) {\n var key = names[i];\n if (key) {\n EASE_BY_NAME[key] = data;\n }\n }\n}\naddMode(\"in\", function(f) {\n return f;\n});\naddMode(\"out\", function(f) {\n return function(t) {\n return 1 - f(1 - t);\n };\n});\naddMode(\"in-out\", function(f) {\n return function(t) {\n return t < 0.5 ? f(2 * t) / 2 : 1 - f(2 * (1 - t)) / 2;\n };\n});\naddMode(\"out-in\", function(f) {\n return function(t) {\n return t < 0.5 ? 1 - f(2 * (1 - t)) / 2 : f(2 * t) / 2;\n };\n});\naddEaseFn({\n name: \"linear\",\n fn: function(t) {\n return t;\n }\n});\naddEaseFn({\n name: \"quad\",\n fn: function(t) {\n return t * t;\n }\n});\naddEaseFn({\n name: \"cubic\",\n fn: function(t) {\n return t * t * t;\n }\n});\naddEaseFn({\n name: \"quart\",\n fn: function(t) {\n return t * t * t * t;\n }\n});\naddEaseFn({\n name: \"quint\",\n fn: function(t) {\n return t * t * t * t * t;\n }\n});\naddEaseFn({\n name: \"sin sine\",\n fn: function(t) {\n return 1 - Math.cos(t * Math.PI / 2);\n }\n});\naddEaseFn({\n name: \"exp expo\",\n fn: function(t) {\n return t == 0 ? 0 : Math.pow(2, 10 * (t - 1));\n }\n});\naddEaseFn({\n name: \"circle circ\",\n fn: function(t) {\n return 1 - Math.sqrt(1 - t * t);\n }\n});\naddEaseFn({\n name: \"bounce\",\n fn: function(t) {\n return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + 0.75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + 0.9375 : 7.5625 * (t -= 2.625 / 2.75) * t + 0.984375;\n }\n});\naddEaseFn({\n name: \"poly\",\n fc: function(e) {\n return function(t) {\n return Math.pow(t, e);\n };\n }\n});\naddEaseFn({\n name: \"elastic\",\n fc: function(a, p) {\n p = p || 0.45;\n a = a || 1;\n var s = p / (2 * Math.PI) * Math.asin(1 / a);\n return function(t) {\n return 1 + a * Math.pow(2, -10 * t) * Math.sin((t - s) * (2 * Math.PI) / p);\n };\n }\n});\naddEaseFn({\n name: \"back\",\n fc: function(s) {\n s = typeof s !== \"undefined\" ? s : 1.70158;\n return function(t) {\n return t * t * ((s + 1) * t - s);\n };\n }\n});\nvar Transition = (\n /** @class */\n function() {\n function Transition2(owner, options) {\n if (options === void 0) {\n options = {};\n }\n this.uid = \"transition:\" + uid();\n this._ending = [];\n this._end = {};\n this._duration = options.duration || 400;\n this._delay = options.delay || 0;\n this._owner = owner;\n this._time = 0;\n }\n Transition2.prototype.tick = function(node, elapsed, now, last) {\n this._time += elapsed;\n if (this._time < this._delay) {\n return;\n }\n var time = this._time - this._delay;\n if (!this._start) {\n this._start = {};\n for (var key in this._end) {\n this._start[key] = this._owner.pin(key);\n }\n }\n var p = Math.min(time / this._duration, 1);\n var ended = p >= 1;\n if (typeof this._easing == \"function\") {\n p = this._easing(p);\n }\n var q = 1 - p;\n for (var key in this._end) {\n this._owner.pin(key, this._start[key] * q + this._end[key] * p);\n }\n return ended;\n };\n Transition2.prototype.finish = function() {\n var _this = this;\n this._ending.forEach(function(callback) {\n try {\n callback.call(_this._owner);\n } catch (e) {\n console.error(e);\n }\n });\n return this._next;\n };\n Transition2.prototype.tween = function(a, b) {\n var options;\n if (typeof a === \"object\" && a !== null) {\n options = a;\n } else {\n options = {};\n if (typeof a === \"number\") {\n options.duration = a;\n if (typeof b === \"number\") {\n options.delay = b;\n }\n }\n }\n return this._next = new Transition2(this._owner, options);\n };\n Transition2.prototype.duration = function(duration) {\n this._duration = duration;\n return this;\n };\n Transition2.prototype.delay = function(delay) {\n this._delay = delay;\n return this;\n };\n Transition2.prototype.ease = function(easing) {\n this._easing = Easing.get(easing);\n return this;\n };\n Transition2.prototype.done = function(fn) {\n this._ending.push(fn);\n return this;\n };\n Transition2.prototype.hide = function() {\n this._ending.push(function() {\n this.hide();\n });\n this._hide = true;\n return this;\n };\n Transition2.prototype.remove = function() {\n this._ending.push(function() {\n this.remove();\n });\n this._remove = true;\n return this;\n };\n Transition2.prototype.pin = function(a, b) {\n if (typeof a === \"object\") {\n for (var attr in a) {\n pinning(this._owner, this._end, attr, a[attr]);\n }\n } else if (typeof b !== \"undefined\") {\n pinning(this._owner, this._end, a, b);\n }\n return this;\n };\n Transition2.prototype.then = function(fn) {\n this.done(fn);\n return this;\n };\n Transition2.prototype.clear = function(forward) {\n return this;\n };\n Transition2.prototype.size = function(w, h) {\n this.pin(\"width\", w);\n this.pin(\"height\", h);\n return this;\n };\n Transition2.prototype.width = function(w) {\n if (typeof w === \"undefined\") {\n return this.pin(\"width\");\n }\n this.pin(\"width\", w);\n return this;\n };\n Transition2.prototype.height = function(h) {\n if (typeof h === \"undefined\") {\n return this.pin(\"height\");\n }\n this.pin(\"height\", h);\n return this;\n };\n Transition2.prototype.offset = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n }\n this.pin(\"offsetX\", a);\n this.pin(\"offsetY\", b);\n return this;\n };\n Transition2.prototype.rotate = function(a) {\n this.pin(\"rotation\", a);\n return this;\n };\n Transition2.prototype.skew = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n } else if (typeof b === \"undefined\") {\n b = a;\n }\n this.pin(\"skewX\", a);\n this.pin(\"skewY\", b);\n return this;\n };\n Transition2.prototype.scale = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n } else if (typeof b === \"undefined\") {\n b = a;\n }\n this.pin(\"scaleX\", a);\n this.pin(\"scaleY\", b);\n return this;\n };\n Transition2.prototype.alpha = function(a, ta) {\n this.pin(\"alpha\", a);\n if (typeof ta !== \"undefined\") {\n this.pin(\"textureAlpha\", ta);\n }\n return this;\n };\n return Transition2;\n }()\n);\nfunction pinning(node, map, key, value) {\n if (typeof node.pin(key) === \"number\") {\n map[key] = value;\n } else if (typeof node.pin(key + \"X\") === \"number\" && typeof node.pin(key + \"Y\") === \"number\") {\n map[key + \"X\"] = value;\n map[key + \"Y\"] = value;\n }\n}\nvar iid = 0;\nstats.create = 0;\nfunction assertType(obj) {\n if (obj && obj instanceof Node) {\n return obj;\n }\n throw \"Invalid node: \" + obj;\n}\nfunction create() {\n return layout();\n}\nfunction layer() {\n return maximize();\n}\nfunction box() {\n return minimize();\n}\nfunction layout() {\n return new Node();\n}\nfunction row(align) {\n return layout().row(align).label(\"Row\");\n}\nfunction column(align) {\n return layout().column(align).label(\"Column\");\n}\nfunction minimize() {\n return layout().minimize().label(\"Minimize\");\n}\nfunction maximize() {\n return layout().maximize().label(\"Maximize\");\n}\nvar Node = (\n /** @class */\n function() {\n function Node2() {\n var _this = this;\n this.uid = \"node:\" + uid();\n this._label = \"\";\n this._parent = null;\n this._next = null;\n this._prev = null;\n this._first = null;\n this._last = null;\n this._visible = true;\n this._alpha = 1;\n this._padding = 0;\n this._spacing = 0;\n this._pin = new Pin(this);\n this._listeners = {};\n this._attrs = {};\n this._flags = {};\n this._transitions = [];\n this._tickBefore = [];\n this._tickAfter = [];\n this.MAX_ELAPSE = Infinity;\n this._transitionTickInitied = false;\n this._transitionTickLastTime = 0;\n this._transitionTick = function(elapsed, now, last) {\n if (!_this._transitions.length) {\n return false;\n }\n var ignore = _this._transitionTickLastTime !== last;\n _this._transitionTickLastTime = now;\n if (ignore) {\n return true;\n }\n var head = _this._transitions[0];\n var ended = head.tick(_this, elapsed, now, last);\n if (ended) {\n if (head === _this._transitions[0]) {\n _this._transitions.shift();\n }\n var next = head.finish();\n if (next) {\n _this._transitions.unshift(next);\n }\n }\n return true;\n };\n stats.create++;\n }\n Node2.prototype.matrix = function(relative) {\n if (relative === void 0) {\n relative = false;\n }\n if (relative === true) {\n return this._pin.relativeMatrix();\n }\n return this._pin.absoluteMatrix();\n };\n Node2.prototype.getPixelRatio = function() {\n var _a;\n var m = (_a = this._parent) === null || _a === void 0 ? void 0 : _a.matrix();\n var pixelRatio = !m ? 1 : Math.max(Math.abs(m.a), Math.abs(m.b)) / getPixelRatio();\n return pixelRatio;\n };\n Node2.prototype.pin = function(a, b) {\n if (typeof a === \"object\") {\n this._pin.set(a);\n return this;\n } else if (typeof a === \"string\") {\n if (typeof b === \"undefined\") {\n return this._pin.get(a);\n } else {\n this._pin.set(a, b);\n return this;\n }\n } else if (typeof a === \"undefined\") {\n return this._pin;\n }\n };\n Node2.prototype.fit = function(a, b, c) {\n if (typeof a === \"object\") {\n c = b;\n b = a.y;\n a = a.x;\n }\n this._pin.fit(a, b, c);\n return this;\n };\n Node2.prototype.scaleTo = function(a, b, c) {\n return this.fit(a, b, c);\n };\n Node2.prototype.toString = function() {\n return \"[\" + this._label + \"]\";\n };\n Node2.prototype.id = function(id) {\n return this.label(id);\n };\n Node2.prototype.label = function(label) {\n if (typeof label === \"undefined\") {\n return this._label;\n }\n this._label = label;\n return this;\n };\n Node2.prototype.attr = function(name, value) {\n if (typeof value === \"undefined\") {\n return this._attrs !== null ? this._attrs[name] : void 0;\n }\n (this._attrs !== null ? this._attrs : this._attrs = {})[name] = value;\n return this;\n };\n Node2.prototype.visible = function(visible) {\n if (typeof visible === \"undefined\") {\n return this._visible;\n }\n this._visible = visible;\n this._parent && (this._parent._ts_children = ++iid);\n this._ts_pin = ++iid;\n this.touch();\n return this;\n };\n Node2.prototype.hide = function() {\n this.visible(false);\n return this;\n };\n Node2.prototype.show = function() {\n this.visible(true);\n return this;\n };\n Node2.prototype.parent = function() {\n return this._parent;\n };\n Node2.prototype.next = function(visible) {\n var next = this._next;\n while (next && visible && !next._visible) {\n next = next._next;\n }\n return next;\n };\n Node2.prototype.prev = function(visible) {\n var prev = this._prev;\n while (prev && visible && !prev._visible) {\n prev = prev._prev;\n }\n return prev;\n };\n Node2.prototype.first = function(visible) {\n var next = this._first;\n while (next && visible && !next._visible) {\n next = next._next;\n }\n return next;\n };\n Node2.prototype.last = function(visible) {\n var prev = this._last;\n while (prev && visible && !prev._visible) {\n prev = prev._prev;\n }\n return prev;\n };\n Node2.prototype.visit = function(visitor, payload) {\n var reverse = visitor.reverse;\n var visible = visitor.visible;\n if (visitor.start && visitor.start(this, payload)) {\n return;\n }\n var child;\n var next = reverse ? this.last(visible) : this.first(visible);\n while (child = next) {\n next = reverse ? child.prev(visible) : child.next(visible);\n if (child.visit(visitor, payload)) {\n return true;\n }\n }\n return visitor.end && visitor.end(this, payload);\n };\n Node2.prototype.append = function(child, more) {\n if (Array.isArray(child)) {\n for (var i = 0; i < child.length; i++) {\n Node2.append(this, child[i]);\n }\n } else if (typeof more !== \"undefined\") {\n for (var i = 0; i < arguments.length; i++) {\n Node2.append(this, arguments[i]);\n }\n } else if (typeof child !== \"undefined\")\n Node2.append(this, child);\n return this;\n };\n Node2.prototype.prepend = function(child, more) {\n if (Array.isArray(child)) {\n for (var i = child.length - 1; i >= 0; i--) {\n Node2.prepend(this, child[i]);\n }\n } else if (typeof more !== \"undefined\") {\n for (var i = arguments.length - 1; i >= 0; i--) {\n Node2.prepend(this, arguments[i]);\n }\n } else if (typeof child !== \"undefined\")\n Node2.prepend(this, child);\n return this;\n };\n Node2.prototype.appendTo = function(parent) {\n Node2.append(parent, this);\n return this;\n };\n Node2.prototype.prependTo = function(parent) {\n Node2.prepend(parent, this);\n return this;\n };\n Node2.prototype.insertNext = function(sibling, more) {\n if (Array.isArray(sibling)) {\n for (var i = 0; i < sibling.length; i++) {\n Node2.insertAfter(sibling[i], this);\n }\n } else if (typeof more !== \"undefined\") {\n for (var i = 0; i < arguments.length; i++) {\n Node2.insertAfter(arguments[i], this);\n }\n } else if (typeof sibling !== \"undefined\") {\n Node2.insertAfter(sibling, this);\n }\n return this;\n };\n Node2.prototype.insertPrev = function(sibling, more) {\n if (Array.isArray(sibling)) {\n for (var i = sibling.length - 1; i >= 0; i--) {\n Node2.insertBefore(sibling[i], this);\n }\n } else if (typeof more !== \"undefined\") {\n for (var i = arguments.length - 1; i >= 0; i--) {\n Node2.insertBefore(arguments[i], this);\n }\n } else if (typeof sibling !== \"undefined\") {\n Node2.insertBefore(sibling, this);\n }\n return this;\n };\n Node2.prototype.insertAfter = function(prev) {\n Node2.insertAfter(this, prev);\n return this;\n };\n Node2.prototype.insertBefore = function(next) {\n Node2.insertBefore(this, next);\n return this;\n };\n Node2.append = function(parent, child) {\n assertType(child);\n assertType(parent);\n child.remove();\n if (parent._last) {\n parent._last._next = child;\n child._prev = parent._last;\n }\n child._parent = parent;\n parent._last = child;\n if (!parent._first) {\n parent._first = child;\n }\n child._parent._flag(child, true);\n child._ts_parent = ++iid;\n parent._ts_children = ++iid;\n parent.touch();\n };\n Node2.prepend = function(parent, child) {\n assertType(child);\n assertType(parent);\n child.remove();\n if (parent._first) {\n parent._first._prev = child;\n child._next = parent._first;\n }\n child._parent = parent;\n parent._first = child;\n if (!parent._last) {\n parent._last = child;\n }\n child._parent._flag(child, true);\n child._ts_parent = ++iid;\n parent._ts_children = ++iid;\n parent.touch();\n };\n Node2.insertBefore = function(self, next) {\n assertType(self);\n assertType(next);\n self.remove();\n var parent = next._parent;\n var prev = next._prev;\n if (!parent) {\n return;\n }\n next._prev = self;\n prev && (prev._next = self) || parent && (parent._first = self);\n self._parent = parent;\n self._prev = prev;\n self._next = next;\n self._parent._flag(self, true);\n self._ts_parent = ++iid;\n self.touch();\n };\n Node2.insertAfter = function(self, prev) {\n assertType(self);\n assertType(prev);\n self.remove();\n var parent = prev._parent;\n var next = prev._next;\n if (!parent) {\n return;\n }\n prev._next = self;\n next && (next._prev = self) || parent && (parent._last = self);\n self._parent = parent;\n self._prev = prev;\n self._next = next;\n self._parent._flag(self, true);\n self._ts_parent = ++iid;\n self.touch();\n };\n Node2.prototype.remove = function(child, more) {\n if (typeof child !== \"undefined\") {\n if (Array.isArray(child)) {\n for (var i = 0; i < child.length; i++) {\n assertType(child[i]).remove();\n }\n } else if (typeof more !== \"undefined\") {\n for (var i = 0; i < arguments.length; i++) {\n assertType(arguments[i]).remove();\n }\n } else {\n assertType(child).remove();\n }\n return this;\n }\n if (this._prev) {\n this._prev._next = this._next;\n }\n if (this._next) {\n this._next._prev = this._prev;\n }\n if (this._parent) {\n if (this._parent._first === this) {\n this._parent._first = this._next;\n }\n if (this._parent._last === this) {\n this._parent._last = this._prev;\n }\n this._parent._flag(this, false);\n this._parent._ts_children = ++iid;\n this._parent.touch();\n }\n this._prev = this._next = this._parent = null;\n this._ts_parent = ++iid;\n return this;\n };\n Node2.prototype.empty = function() {\n var child = null;\n var next = this._first;\n while (child = next) {\n next = child._next;\n child._prev = child._next = child._parent = null;\n this._flag(child, false);\n }\n this._first = this._last = null;\n this._ts_children = ++iid;\n this.touch();\n return this;\n };\n Node2.prototype.touch = function() {\n this._ts_touch = ++iid;\n this._parent && this._parent.touch();\n return this;\n };\n Node2.prototype._flag = function(key, value) {\n if (typeof value === \"undefined\") {\n return this._flags !== null && this._flags[key] || 0;\n }\n if (typeof key === \"string\") {\n if (value) {\n this._flags = this._flags || {};\n if (!this._flags[key] && this._parent) {\n this._parent._flag(key, true);\n }\n this._flags[key] = (this._flags[key] || 0) + 1;\n } else if (this._flags && this._flags[key] > 0) {\n if (this._flags[key] == 1 && this._parent) {\n this._parent._flag(key, false);\n }\n this._flags[key] = this._flags[key] - 1;\n }\n }\n if (typeof key === \"object\") {\n if (key._flags) {\n for (var type in key._flags) {\n if (key._flags[type] > 0) {\n this._flag(type, value);\n }\n }\n }\n }\n return this;\n };\n Node2.prototype.hitTest = function(hit) {\n var width = this._pin._width;\n var height = this._pin._height;\n return hit.x >= 0 && hit.x <= width && hit.y >= 0 && hit.y <= height;\n };\n Node2.prototype.prerender = function() {\n if (!this._visible) {\n return;\n }\n var child;\n var next = this._first;\n while (child = next) {\n next = child._next;\n child.prerender();\n }\n };\n Node2.prototype.render = function(context) {\n if (!this._visible) {\n return;\n }\n stats.node++;\n var m = this.matrix();\n context.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);\n this._alpha = this._pin._alpha * (this._parent ? this._parent._alpha : 1);\n var alpha = this._pin._textureAlpha * this._alpha;\n if (context.globalAlpha != alpha) {\n context.globalAlpha = alpha;\n }\n if (this._textures) {\n for (var i = 0, n = this._textures.length; i < n; i++) {\n this._textures[i].draw(context);\n }\n }\n if (context.globalAlpha != this._alpha) {\n context.globalAlpha = this._alpha;\n }\n var child;\n var next = this._first;\n while (child = next) {\n next = child._next;\n child.render(context);\n }\n };\n Node2.prototype._tick = function(elapsed, now, last) {\n if (!this._visible) {\n return;\n }\n if (elapsed > this.MAX_ELAPSE) {\n elapsed = this.MAX_ELAPSE;\n }\n var ticked = false;\n if (this._tickBefore !== null) {\n for (var i = 0; i < this._tickBefore.length; i++) {\n stats.tick++;\n var tickFn = this._tickBefore[i];\n ticked = tickFn.call(this, elapsed, now, last) === true || ticked;\n }\n }\n var child;\n var next = this._first;\n while (child = next) {\n next = child._next;\n if (child._flag(\"_tick\")) {\n ticked = child._tick(elapsed, now, last) === true ? true : ticked;\n }\n }\n if (this._tickAfter !== null) {\n for (var i = 0; i < this._tickAfter.length; i++) {\n stats.tick++;\n var tickFn = this._tickAfter[i];\n ticked = tickFn.call(this, elapsed, now, last) === true || ticked;\n }\n }\n return ticked;\n };\n Node2.prototype.tick = function(callback, before) {\n var _a, _b;\n if (before === void 0) {\n before = false;\n }\n if (typeof callback !== \"function\") {\n return;\n }\n if (before) {\n if (this._tickBefore === null) {\n this._tickBefore = [];\n }\n this._tickBefore.push(callback);\n } else {\n if (this._tickAfter === null) {\n this._tickAfter = [];\n }\n this._tickAfter.push(callback);\n }\n var hasTickListener = ((_a = this._tickAfter) === null || _a === void 0 ? void 0 : _a.length) > 0 || ((_b = this._tickBefore) === null || _b === void 0 ? void 0 : _b.length) > 0;\n this._flag(\"_tick\", hasTickListener);\n };\n Node2.prototype.untick = function(callback) {\n if (typeof callback !== \"function\") {\n return;\n }\n var i;\n if (this._tickBefore !== null && (i = this._tickBefore.indexOf(callback)) >= 0) {\n this._tickBefore.splice(i, 1);\n }\n if (this._tickAfter !== null && (i = this._tickAfter.indexOf(callback)) >= 0) {\n this._tickAfter.splice(i, 1);\n }\n };\n Node2.prototype.timeout = function(callback, time) {\n this.setTimeout(callback, time);\n };\n Node2.prototype.setTimeout = function(callback, time) {\n function timer(t) {\n if ((time -= t) < 0) {\n this.untick(timer);\n callback.call(this);\n } else {\n return true;\n }\n }\n this.tick(timer);\n return timer;\n };\n Node2.prototype.clearTimeout = function(timer) {\n this.untick(timer);\n };\n Node2.prototype.on = function(type, listener) {\n if (!type || !type.length || typeof listener !== \"function\") {\n return this;\n }\n if (typeof type !== \"string\" && typeof type.join === \"function\") {\n for (var i = 0; i < type.length; i++) {\n this.on(type[i], listener);\n }\n } else if (typeof type === \"string\" && type.indexOf(\" \") > -1) {\n type = type.match(/\\S+/g);\n for (var i = 0; i < type.length; i++) {\n this._on(type[i], listener);\n }\n } else if (typeof type === \"string\") {\n this._on(type, listener);\n } else\n ;\n return this;\n };\n Node2.prototype._on = function(type, listener) {\n if (typeof type !== \"string\" && typeof listener !== \"function\") {\n return;\n }\n this._listeners[type] = this._listeners[type] || [];\n this._listeners[type].push(listener);\n this._flag(type, true);\n };\n Node2.prototype.off = function(type, listener) {\n if (!type || !type.length || typeof listener !== \"function\") {\n return this;\n }\n if (typeof type !== \"string\" && typeof type.join === \"function\") {\n for (var i = 0; i < type.length; i++) {\n this.off(type[i], listener);\n }\n } else if (typeof type === \"string\" && type.indexOf(\" \") > -1) {\n type = type.match(/\\S+/g);\n for (var i = 0; i < type.length; i++) {\n this._off(type[i], listener);\n }\n } else if (typeof type === \"string\") {\n this._off(type, listener);\n } else\n ;\n return this;\n };\n Node2.prototype._off = function(type, listener) {\n if (typeof type !== \"string\" && typeof listener !== \"function\") {\n return;\n }\n var listeners = this._listeners[type];\n if (!listeners || !listeners.length) {\n return;\n }\n var index = listeners.indexOf(listener);\n if (index >= 0) {\n listeners.splice(index, 1);\n this._flag(type, false);\n }\n };\n Node2.prototype.listeners = function(type) {\n return this._listeners[type];\n };\n Node2.prototype.publish = function(name, args) {\n var listeners = this.listeners(name);\n if (!listeners || !listeners.length) {\n return 0;\n }\n for (var l = 0; l < listeners.length; l++) {\n listeners[l].apply(this, args);\n }\n return listeners.length;\n };\n Node2.prototype.trigger = function(name, args) {\n this.publish(name, args);\n return this;\n };\n Node2.prototype.size = function(w, h) {\n this.pin(\"width\", w);\n this.pin(\"height\", h);\n return this;\n };\n Node2.prototype.width = function(w) {\n if (typeof w === \"undefined\") {\n return this.pin(\"width\");\n }\n this.pin(\"width\", w);\n return this;\n };\n Node2.prototype.height = function(h) {\n if (typeof h === \"undefined\") {\n return this.pin(\"height\");\n }\n this.pin(\"height\", h);\n return this;\n };\n Node2.prototype.offset = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n }\n this.pin(\"offsetX\", a);\n this.pin(\"offsetY\", b);\n return this;\n };\n Node2.prototype.rotate = function(a) {\n this.pin(\"rotation\", a);\n return this;\n };\n Node2.prototype.skew = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n } else if (typeof b === \"undefined\")\n b = a;\n this.pin(\"skewX\", a);\n this.pin(\"skewY\", b);\n return this;\n };\n Node2.prototype.scale = function(a, b) {\n if (typeof a === \"object\") {\n b = a.y;\n a = a.x;\n } else if (typeof b === \"undefined\")\n b = a;\n this.pin(\"scaleX\", a);\n this.pin(\"scaleY\", b);\n return this;\n };\n Node2.prototype.alpha = function(a, ta) {\n this.pin(\"alpha\", a);\n if (typeof ta !== \"undefined\") {\n this.pin(\"textureAlpha\", ta);\n }\n return this;\n };\n Node2.prototype.tween = function(a, b, c) {\n var options;\n if (typeof a === \"object\" && a !== null) {\n options = a;\n } else {\n options = {};\n if (typeof a === \"number\") {\n options.duration = a;\n if (typeof b === \"number\") {\n options.delay = b;\n if (typeof c === \"boolean\") {\n options.append = c;\n }\n } else if (typeof b === \"boolean\") {\n options.append = b;\n }\n } else if (typeof a === \"boolean\") {\n options.append = a;\n }\n }\n if (!this._transitionTickInitied) {\n this.tick(this._transitionTick, true);\n this._transitionTickInitied = true;\n }\n this.touch();\n if (!options.append) {\n this._transitions.length = 0;\n }\n var transition = new Transition(this, options);\n this._transitions.push(transition);\n return transition;\n };\n Node2.prototype.row = function(align) {\n this.align(\"row\", align);\n return this;\n };\n Node2.prototype.column = function(align) {\n this.align(\"column\", align);\n return this;\n };\n Node2.prototype.align = function(type, align) {\n var _this = this;\n this._padding = this._padding;\n this._spacing = this._spacing;\n this._layoutTicker && this.untick(this._layoutTicker);\n this.tick(this._layoutTicker = function() {\n if (_this._mo_seq == _this._ts_touch) {\n return;\n }\n _this._mo_seq = _this._ts_touch;\n var alignChildren = _this._mo_seqAlign != _this._ts_children;\n _this._mo_seqAlign = _this._ts_children;\n var width = 0;\n var height = 0;\n var child;\n var next = _this.first(true);\n var first = true;\n while (child = next) {\n next = child.next(true);\n child.matrix(true);\n var w = child.pin(\"boxWidth\");\n var h = child.pin(\"boxHeight\");\n if (type == \"column\") {\n !first && (height += _this._spacing);\n child.pin(\"offsetY\") != height && child.pin(\"offsetY\", height);\n width = Math.max(width, w);\n height = height + h;\n alignChildren && child.pin(\"alignX\", align);\n } else if (type == \"row\") {\n !first && (width += _this._spacing);\n child.pin(\"offsetX\") != width && child.pin(\"offsetX\", width);\n width = width + w;\n height = Math.max(height, h);\n alignChildren && child.pin(\"alignY\", align);\n }\n first = false;\n }\n width += 2 * _this._padding;\n height += 2 * _this._padding;\n _this.pin(\"width\") != width && _this.pin(\"width\", width);\n _this.pin(\"height\") != height && _this.pin(\"height\", height);\n });\n return this;\n };\n Node2.prototype.box = function() {\n return this.minimize();\n };\n Node2.prototype.layer = function() {\n return this.maximize();\n };\n Node2.prototype.minimize = function() {\n var _this = this;\n this._padding = this._padding;\n this._layoutTicker && this.untick(this._layoutTicker);\n this.tick(this._layoutTicker = function() {\n if (_this._mo_box == _this._ts_touch) {\n return;\n }\n _this._mo_box = _this._ts_touch;\n var width = 0;\n var height = 0;\n var child;\n var next = _this.first(true);\n while (child = next) {\n next = child.next(true);\n child.matrix(true);\n var w = child.pin(\"boxWidth\");\n var h = child.pin(\"boxHeight\");\n width = Math.max(width, w);\n height = Math.max(height, h);\n }\n width += 2 * _this._padding;\n height += 2 * _this._padding;\n _this.pin(\"width\") != width && _this.pin(\"width\", width);\n _this.pin(\"height\") != height && _this.pin(\"height\", height);\n });\n return this;\n };\n Node2.prototype.maximize = function() {\n var _this = this;\n this._layoutTicker && this.untick(this._layoutTicker);\n this.tick(this._layoutTicker = function() {\n var parent = _this.parent();\n if (parent) {\n var width = parent.pin(\"width\");\n if (_this.pin(\"width\") != width) {\n _this.pin(\"width\", width);\n }\n var height = parent.pin(\"height\");\n if (_this.pin(\"height\") != height) {\n _this.pin(\"height\", height);\n }\n }\n }, true);\n return this;\n };\n Node2.prototype.padding = function(pad) {\n this._padding = pad;\n return this;\n };\n Node2.prototype.spacing = function(space) {\n this._spacing = space;\n return this;\n };\n return Node2;\n }()\n);\nvar __extends$4 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nfunction sprite(frame) {\n var sprite2 = new Sprite();\n frame && sprite2.texture(frame);\n return sprite2;\n}\nvar Sprite = (\n /** @class */\n function(_super) {\n __extends$4(Sprite2, _super);\n function Sprite2() {\n var _this = _super.call(this) || this;\n _this._tiled = false;\n _this._stretched = false;\n _this.prerenderContext = {};\n _this.label(\"Sprite\");\n _this._textures = [];\n _this._image = null;\n return _this;\n }\n Sprite2.prototype.texture = function(frame) {\n this._image = texture(frame).one();\n if (this._image) {\n this.pin(\"width\", this._image.getWidth());\n this.pin(\"height\", this._image.getHeight());\n if (this._tiled) {\n this._textures[0] = new ResizableTexture(this._image, \"tile\");\n } else if (this._stretched) {\n this._textures[0] = new ResizableTexture(this._image, \"stretch\");\n } else {\n this._textures[0] = new PipeTexture(this._image);\n }\n this._textures.length = 1;\n } else {\n this.pin(\"width\", 0);\n this.pin(\"height\", 0);\n this._textures.length = 0;\n }\n return this;\n };\n Sprite2.prototype.image = function(frame) {\n return this.texture(frame);\n };\n Sprite2.prototype.tile = function(inner) {\n this._tiled = true;\n var texture2 = new ResizableTexture(this._image, \"tile\");\n this._textures[0] = texture2;\n return this;\n };\n Sprite2.prototype.stretch = function(inner) {\n this._stretched = true;\n var texture2 = new ResizableTexture(this._image, \"stretch\");\n this._textures[0] = texture2;\n return this;\n };\n Sprite2.prototype.prerender = function() {\n if (!this._visible) {\n return;\n }\n if (this._image) {\n var pixelRatio = this.getPixelRatio();\n this.prerenderContext.pixelRatio = pixelRatio;\n var updated = this._image.prerender(this.prerenderContext);\n if (updated === true) {\n var w = this._image.getWidth();\n var h = this._image.getHeight();\n this.size(w, h);\n }\n }\n _super.prototype.prerender.call(this);\n };\n Sprite2.prototype.render = function(context) {\n var texture2 = this._textures[0];\n if (texture2 === null || texture2 === void 0 ? void 0 : texture2[\"_resizeMode\"]) {\n texture2.dw = this.pin(\"width\");\n texture2.dh = this.pin(\"height\");\n }\n _super.prototype.render.call(this, context);\n };\n return Sprite2;\n }(Node)\n);\nvar image = sprite;\nvar Image$1 = Sprite;\nvar __extends$3 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar CanvasTexture = (\n /** @class */\n function(_super) {\n __extends$3(CanvasTexture2, _super);\n function CanvasTexture2() {\n var _this = _super.call(this, document.createElement(\"canvas\")) || this;\n _this._lastPixelRatio = 0;\n return _this;\n }\n CanvasTexture2.prototype.setSize = function(textureWidth, textureHeight, pixelRatio) {\n if (pixelRatio === void 0) {\n pixelRatio = 1;\n }\n this._source.width = textureWidth * pixelRatio;\n this._source.height = textureHeight * pixelRatio;\n this._pixelRatio = pixelRatio;\n };\n CanvasTexture2.prototype.getContext = function(type, attributes) {\n if (type === void 0) {\n type = \"2d\";\n }\n return this._source.getContext(type, attributes);\n };\n CanvasTexture2.prototype.getOptimalPixelRatio = function() {\n return Math.ceil(this._lastPixelRatio);\n };\n CanvasTexture2.prototype.setMemoizer = function(memoizer) {\n this._memoizer = memoizer;\n };\n CanvasTexture2.prototype.setDrawer = function(drawer) {\n this._drawer = drawer;\n };\n CanvasTexture2.prototype.prerender = function(context) {\n var newPixelRatio = context.pixelRatio;\n var lastPixelRatio = this._lastPixelRatio;\n var pixelRationChange = lastPixelRatio / newPixelRatio;\n var pixelRatioChanged = lastPixelRatio === 0 || pixelRationChange > 1.25 || pixelRationChange < 0.8;\n if (pixelRatioChanged) {\n this._lastPixelRatio = newPixelRatio;\n }\n var newMemoKey = this._memoizer ? this._memoizer.call(this) : null;\n var memoKeyChanged = this._lastMemoKey !== newMemoKey;\n if (pixelRatioChanged || memoKeyChanged) {\n this._lastMemoKey = newMemoKey;\n this._lastPixelRatio = newPixelRatio;\n if (typeof this._drawer === \"function\") {\n this._drawer.call(this);\n }\n return true;\n }\n };\n CanvasTexture2.prototype.size = function(width, height, pixelRatio) {\n this.setSize(width, height, pixelRatio);\n return this;\n };\n CanvasTexture2.prototype.context = function(type, attributes) {\n if (type === void 0) {\n type = \"2d\";\n }\n return this.getContext(type, attributes);\n };\n CanvasTexture2.prototype.canvas = function(legacyTextureDrawer) {\n if (typeof legacyTextureDrawer === \"function\") {\n legacyTextureDrawer.call(this, this.getContext());\n } else if (typeof legacyTextureDrawer === \"undefined\") {\n if (typeof this._drawer === \"function\") {\n this._drawer.call(this);\n }\n }\n return this;\n };\n return CanvasTexture2;\n }(ImageTexture)\n);\nfunction canvas(type, attributes, legacyTextureDrawer) {\n if (typeof type === \"function\") {\n var texture_1 = new CanvasTexture();\n legacyTextureDrawer = type;\n texture_1.setDrawer(function() {\n legacyTextureDrawer.call(texture_1, texture_1.getContext());\n });\n return texture_1;\n } else if (typeof attributes === \"function\") {\n var texture_2 = new CanvasTexture();\n legacyTextureDrawer = attributes;\n texture_2.setDrawer(function() {\n legacyTextureDrawer.call(texture_2, texture_2.getContext(type));\n });\n return texture_2;\n } else if (typeof legacyTextureDrawer === \"function\") {\n var texture_3 = new CanvasTexture();\n texture_3.setDrawer(function() {\n legacyTextureDrawer.call(texture_3, texture_3.getContext(type, attributes));\n });\n return texture_3;\n } else {\n var texture2 = new CanvasTexture();\n return texture2;\n }\n}\nfunction memoizeDraw(legacySpriteDrawer, legacySpriteMemoizer) {\n if (legacySpriteMemoizer === void 0) {\n legacySpriteMemoizer = function() {\n return null;\n };\n }\n var sprite2 = new Sprite();\n var texture2 = new CanvasTexture();\n sprite2.texture(texture2);\n texture2.setDrawer(function() {\n legacySpriteDrawer(2.5 * texture2._lastPixelRatio, texture2, sprite2);\n });\n texture2.setMemoizer(legacySpriteMemoizer);\n return sprite2;\n}\nvar POINTER_CLICK = \"click\";\nvar POINTER_START = \"touchstart mousedown\";\nvar POINTER_MOVE = \"touchmove mousemove\";\nvar POINTER_END = \"touchend mouseup\";\nvar POINTER_CANCEL = \"touchcancel mousecancel\";\nvar EventPoint = (\n /** @class */\n function() {\n function EventPoint2() {\n }\n EventPoint2.prototype.clone = function(obj) {\n if (obj) {\n obj.x = this.x;\n obj.y = this.y;\n } else {\n obj = {\n x: this.x,\n y: this.y\n };\n }\n return obj;\n };\n EventPoint2.prototype.toString = function() {\n return (this.x | 0) + \"x\" + (this.y | 0);\n };\n return EventPoint2;\n }()\n);\nvar PointerSyntheticEvent = (\n /** @class */\n function() {\n function PointerSyntheticEvent2() {\n this.abs = new EventPoint();\n }\n PointerSyntheticEvent2.prototype.clone = function(obj) {\n if (obj) {\n obj.x = this.x;\n obj.y = this.y;\n } else {\n obj = {\n x: this.x,\n y: this.y\n };\n }\n return obj;\n };\n PointerSyntheticEvent2.prototype.toString = function() {\n return this.type + \": \" + (this.x | 0) + \"x\" + (this.y | 0);\n };\n return PointerSyntheticEvent2;\n }()\n);\nvar VisitPayload = (\n /** @class */\n function() {\n function VisitPayload2() {\n this.type = \"\";\n this.x = 0;\n this.y = 0;\n this.timeStamp = -1;\n this.event = null;\n this.root = null;\n this.collected = null;\n }\n VisitPayload2.prototype.toString = function() {\n return this.type + \": \" + (this.x | 0) + \"x\" + (this.y | 0);\n };\n return VisitPayload2;\n }()\n);\nvar syntheticEvent = new PointerSyntheticEvent();\nvar PAYLOAD = new VisitPayload();\nvar Pointer = (\n /** @class */\n function() {\n function Pointer2() {\n var _this = this;\n this.ratio = 1;\n this.clickList = [];\n this.cancelList = [];\n this.handleStart = function(event) {\n event.preventDefault();\n _this.localPoint(event);\n _this.dispatchEvent(event.type, event);\n _this.findTargets(\"click\", _this.clickList);\n _this.findTargets(\"mousecancel\", _this.cancelList);\n };\n this.handleMove = function(event) {\n event.preventDefault();\n _this.localPoint(event);\n _this.dispatchEvent(event.type, event);\n };\n this.handleEnd = function(event) {\n event.preventDefault();\n _this.dispatchEvent(event.type, event);\n if (_this.clickList.length) {\n _this.dispatchEvent(\"click\", event, _this.clickList);\n }\n _this.cancelList.length = 0;\n };\n this.handleCancel = function(event) {\n if (_this.cancelList.length) {\n _this.dispatchEvent(\"mousecancel\", event, _this.cancelList);\n }\n _this.clickList.length = 0;\n };\n this.visitStart = function(node, payload) {\n return !node._flag(payload.type);\n };\n this.visitEnd = function(node, payload) {\n syntheticEvent.raw = payload.event;\n syntheticEvent.type = payload.type;\n syntheticEvent.timeStamp = payload.timeStamp;\n syntheticEvent.abs.x = payload.x;\n syntheticEvent.abs.y = payload.y;\n var listeners = node.listeners(payload.type);\n if (!listeners) {\n return;\n }\n node.matrix().inverse().map(payload, syntheticEvent);\n var isEventTarget = node === payload.root || node.attr(\"spy\") || node.hitTest(syntheticEvent);\n if (!isEventTarget) {\n return;\n }\n if (payload.collected) {\n payload.collected.push(node);\n }\n if (payload.event) {\n var cancel = false;\n for (var l = 0; l < listeners.length; l++) {\n cancel = listeners[l].call(node, syntheticEvent) ? true : cancel;\n }\n return cancel;\n }\n };\n }\n Pointer2.prototype.mount = function(stage, elem) {\n var _this = this;\n this.stage = stage;\n this.elem = elem;\n this.ratio = stage.viewport().ratio || 1;\n stage.on(\"viewport\", function(viewport) {\n var _a;\n _this.ratio = (_a = viewport.ratio) !== null && _a !== void 0 ? _a : _this.ratio;\n });\n elem.addEventListener(\"touchstart\", this.handleStart);\n elem.addEventListener(\"touchend\", this.handleEnd);\n elem.addEventListener(\"touchmove\", this.handleMove);\n elem.addEventListener(\"touchcancel\", this.handleCancel);\n elem.addEventListener(\"mousedown\", this.handleStart);\n elem.addEventListener(\"mouseup\", this.handleEnd);\n elem.addEventListener(\"mousemove\", this.handleMove);\n document.addEventListener(\"mouseup\", this.handleCancel);\n window.addEventListener(\"blur\", this.handleCancel);\n return this;\n };\n Pointer2.prototype.unmount = function() {\n var elem = this.elem;\n elem.removeEventListener(\"touchstart\", this.handleStart);\n elem.removeEventListener(\"touchend\", this.handleEnd);\n elem.removeEventListener(\"touchmove\", this.handleMove);\n elem.removeEventListener(\"touchcancel\", this.handleCancel);\n elem.removeEventListener(\"mousedown\", this.handleStart);\n elem.removeEventListener(\"mouseup\", this.handleEnd);\n elem.removeEventListener(\"mousemove\", this.handleMove);\n document.removeEventListener(\"mouseup\", this.handleCancel);\n window.removeEventListener(\"blur\", this.handleCancel);\n return this;\n };\n Pointer2.prototype.localPoint = function(event) {\n var _a;\n var elem = this.elem;\n var x;\n var y;\n if ((_a = event.touches) === null || _a === void 0 ? void 0 : _a.length) {\n x = event.touches[0].clientX;\n y = event.touches[0].clientY;\n } else {\n x = event.clientX;\n y = event.clientY;\n }\n var rect = elem.getBoundingClientRect();\n x -= rect.left;\n y -= rect.top;\n x -= elem.clientLeft | 0;\n y -= elem.clientTop | 0;\n PAYLOAD.x = x * this.ratio;\n PAYLOAD.y = y * this.ratio;\n };\n Pointer2.prototype.findTargets = function(type, result) {\n var payload = PAYLOAD;\n payload.type = type;\n payload.root = this.stage;\n payload.event = null;\n payload.collected = result;\n payload.collected.length = 0;\n this.stage.visit({\n reverse: true,\n visible: true,\n start: this.visitStart,\n end: this.visitEnd\n }, payload);\n };\n Pointer2.prototype.dispatchEvent = function(type, event, targets) {\n var payload = PAYLOAD;\n payload.type = type;\n payload.root = this.stage;\n payload.event = event;\n payload.timeStamp = Date.now();\n payload.collected = null;\n if (targets) {\n while (targets.length) {\n var node = targets.shift();\n if (this.visitEnd(node, payload)) {\n break;\n }\n }\n targets.length = 0;\n } else {\n this.stage.visit({\n reverse: true,\n visible: true,\n start: this.visitStart,\n end: this.visitEnd\n }, payload);\n }\n };\n return Pointer2;\n }()\n);\nvar Mouse = {\n CLICK: \"click\",\n START: \"touchstart mousedown\",\n MOVE: \"touchmove mousemove\",\n END: \"touchend mouseup\",\n CANCEL: \"touchcancel mousecancel\"\n};\nvar __extends$2 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nvar __assign = function() {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s)\n if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar ROOTS = [];\nfunction pause() {\n for (var i = ROOTS.length - 1; i >= 0; i--) {\n ROOTS[i].pause();\n }\n}\nfunction resume() {\n for (var i = ROOTS.length - 1; i >= 0; i--) {\n ROOTS[i].resume();\n }\n}\nfunction mount(configs) {\n if (configs === void 0) {\n configs = {};\n }\n var root = new Root();\n root.mount(configs);\n root.pointer = new Pointer().mount(root, root.dom);\n return root;\n}\nvar Root = (\n /** @class */\n function(_super) {\n __extends$2(Root2, _super);\n function Root2() {\n var _this = _super.call(this) || this;\n _this.canvas = null;\n _this.dom = null;\n _this.context = null;\n _this.pixelWidth = -1;\n _this.pixelHeight = -1;\n _this.pixelRatio = 1;\n _this.drawingWidth = 0;\n _this.drawingHeight = 0;\n _this.mounted = false;\n _this.paused = false;\n _this.sleep = false;\n _this.mount = function(configs) {\n if (configs === void 0) {\n configs = {};\n }\n if (typeof configs.canvas === \"string\") {\n _this.canvas = document.getElementById(configs.canvas);\n if (!_this.canvas) {\n console.error(\"Canvas element not found: \", configs.canvas);\n }\n } else if (configs.canvas instanceof HTMLCanvasElement) {\n _this.canvas = configs.canvas;\n } else if (configs.canvas) {\n console.error(\"Unknown value for canvas:\", configs.canvas);\n }\n if (!_this.canvas) {\n _this.canvas = document.getElementById(\"cutjs\") || document.getElementById(\"stage\");\n }\n if (!_this.canvas) {\n _this.canvas = document.createElement(\"canvas\");\n Object.assign(_this.canvas.style, {\n position: \"absolute\",\n display: \"block\",\n top: \"0\",\n left: \"0\",\n bottom: \"0\",\n right: \"0\",\n width: \"100%\",\n height: \"100%\"\n });\n var body = document.body;\n body.insertBefore(_this.canvas, body.firstChild);\n }\n _this.dom = _this.canvas;\n _this.context = _this.canvas.getContext(\"2d\");\n var devicePixelRatio = window.devicePixelRatio || 1;\n var backingStorePixelRatio = (\n // @ts-ignore\n _this.context.webkitBackingStorePixelRatio || // @ts-ignore\n _this.context.mozBackingStorePixelRatio || // @ts-ignore\n _this.context.msBackingStorePixelRatio || // @ts-ignore\n _this.context.oBackingStorePixelRatio || // @ts-ignore\n _this.context.backingStorePixelRatio || 1\n );\n _this.devicePixelRatio = devicePixelRatio;\n _this.backingStoreRatio = backingStorePixelRatio;\n _this.pixelRatio = _this.devicePixelRatio / _this.backingStoreRatio;\n _this.mounted = true;\n ROOTS.push(_this);\n _this.requestFrame();\n };\n _this.frameRequested = false;\n _this.requestFrame = function() {\n if (!_this.frameRequested) {\n _this.frameRequested = true;\n requestAnimationFrame(_this.onFrame);\n }\n };\n _this._lastFrameTime = 0;\n _this._mo_touch = null;\n _this.onFrame = function(now) {\n _this.frameRequested = false;\n if (!_this.mounted || !_this.canvas || !_this.context) {\n return;\n }\n _this.requestFrame();\n var newPixelWidth = _this.canvas.clientWidth;\n var newPixelHeight = _this.canvas.clientHeight;\n if (_this.pixelWidth !== newPixelWidth || _this.pixelHeight !== newPixelHeight) {\n _this.pixelWidth = newPixelWidth;\n _this.pixelHeight = newPixelHeight;\n _this.drawingWidth = newPixelWidth * _this.pixelRatio;\n _this.drawingHeight = newPixelHeight * _this.pixelRatio;\n if (_this.canvas.width !== _this.drawingWidth || _this.canvas.height !== _this.drawingHeight) {\n _this.canvas.width = _this.drawingWidth;\n _this.canvas.height = _this.drawingHeight;\n _this.viewport({\n width: _this.drawingWidth,\n height: _this.drawingHeight,\n ratio: _this.pixelRatio\n });\n }\n }\n var last = _this._lastFrameTime || now;\n var elapsed = now - last;\n if (!_this.mounted || _this.paused || _this.sleep) {\n return;\n }\n _this._lastFrameTime = now;\n _this.prerender();\n var tickRequest = _this._tick(elapsed, now, last);\n if (_this._mo_touch != _this._ts_touch) {\n _this._mo_touch = _this._ts_touch;\n _this.sleep = false;\n if (_this.drawingWidth > 0 && _this.drawingHeight > 0) {\n _this.context.setTransform(1, 0, 0, 1, 0, 0);\n _this.context.clearRect(0, 0, _this.drawingWidth, _this.drawingHeight);\n _this.render(_this.context);\n }\n } else if (tickRequest) {\n _this.sleep = false;\n } else {\n _this.sleep = true;\n }\n stats.fps = elapsed ? 1e3 / elapsed : 0;\n };\n _this.label(\"Root\");\n return _this;\n }\n Root2.prototype.resume = function() {\n if (this.sleep || this.paused) {\n this.requestFrame();\n }\n this.paused = false;\n this.sleep = false;\n this.publish(\"resume\");\n return this;\n };\n Root2.prototype.pause = function() {\n if (!this.paused) {\n this.publish(\"pause\");\n }\n this.paused = true;\n return this;\n };\n Root2.prototype.touch = function() {\n if (this.sleep || this.paused) {\n this.requestFrame();\n }\n this.sleep = false;\n return _super.prototype.touch.call(this);\n };\n Root2.prototype.unmount = function() {\n var _a;\n this.mounted = false;\n var index = ROOTS.indexOf(this);\n if (index >= 0) {\n ROOTS.splice(index, 1);\n }\n (_a = this.pointer) === null || _a === void 0 ? void 0 : _a.unmount();\n return this;\n };\n Root2.prototype.background = function(color) {\n if (this.dom) {\n this.dom.style.backgroundColor = color;\n }\n return this;\n };\n Root2.prototype.viewport = function(width, height, ratio) {\n if (typeof width === \"undefined\") {\n return Object.assign({}, this._viewport);\n }\n if (typeof width === \"object\") {\n var options = width;\n width = options.width;\n height = options.height;\n ratio = options.ratio;\n }\n if (typeof width === \"number\" && typeof height === \"number\") {\n this._viewport = {\n width,\n height,\n ratio: typeof ratio === \"number\" ? ratio : 1\n };\n this.viewbox();\n var data_1 = Object.assign({}, this._viewport);\n this.visit({\n start: function(node) {\n if (!node._flag(\"viewport\")) {\n return true;\n }\n node.publish(\"viewport\", [data_1]);\n }\n });\n }\n return this;\n };\n Root2.prototype.viewbox = function(width, height, mode) {\n if (typeof width === \"number\" && typeof height === \"number\") {\n this._viewbox = {\n width,\n height,\n mode\n };\n } else if (typeof width === \"object\" && width !== null) {\n this._viewbox = __assign({}, width);\n }\n this.rescale();\n return this;\n };\n Root2.prototype.camera = function(matrix) {\n this._camera = matrix;\n this.rescale();\n return this;\n };\n Root2.prototype.rescale = function() {\n var viewbox = this._viewbox;\n var viewport = this._viewport;\n var camera = this._camera;\n if (viewport && viewbox) {\n var viewportWidth = viewport.width;\n var viewportHeight = viewport.height;\n var viewboxMode = isValidFitMode(viewbox.mode) ? viewbox.mode : \"in-pad\";\n var viewboxWidth = viewbox.width;\n var viewboxHeight = viewbox.height;\n this.pin({\n width: viewboxWidth,\n height: viewboxHeight\n });\n this.scaleTo(viewportWidth, viewportHeight, viewboxMode);\n var viewboxX = viewbox.x || 0;\n var viewboxY = viewbox.y || 0;\n var cameraZoom = (camera === null || camera === void 0 ? void 0 : camera.a) || 1;\n var cameraX = (camera === null || camera === void 0 ? void 0 : camera.e) || 0;\n var cameraY = (camera === null || camera === void 0 ? void 0 : camera.f) || 0;\n var scaleX = this.pin(\"scaleX\");\n var scaleY = this.pin(\"scaleY\");\n this.pin(\"scaleX\", scaleX * cameraZoom);\n this.pin(\"scaleY\", scaleY * cameraZoom);\n this.pin(\"offsetX\", cameraX - viewboxX * scaleX * cameraZoom);\n this.pin(\"offsetY\", cameraY - viewboxY * scaleY * cameraZoom);\n } else if (viewport) {\n this.pin({\n width: viewport.width,\n height: viewport.height\n });\n }\n return this;\n };\n return Root2;\n }(Node)\n);\nvar __extends$1 = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nfunction anim(frames, fps) {\n var anim2 = new Anim();\n anim2.frames(frames).gotoFrame(0);\n fps && anim2.fps(fps);\n return anim2;\n}\nvar FPS = 15;\nvar Anim = (\n /** @class */\n function(_super) {\n __extends$1(Anim2, _super);\n function Anim2() {\n var _this = _super.call(this) || this;\n _this.label(\"Anim\");\n _this._textures = [];\n _this._fps = FPS;\n _this._ft = 1e3 / _this._fps;\n _this._time = -1;\n _this._repeat = 0;\n _this._index = 0;\n _this._frames = [];\n var lastTime = 0;\n _this.tick(function(t, now, last) {\n if (this._time < 0 || this._frames.length <= 1) {\n return;\n }\n var ignore = lastTime != last;\n lastTime = now;\n if (ignore) {\n return true;\n }\n this._time += t;\n if (this._time < this._ft) {\n return true;\n }\n var n = this._time / this._ft | 0;\n this._time -= n * this._ft;\n this.moveFrame(n);\n if (this._repeat > 0 && (this._repeat -= n) <= 0) {\n this.stop();\n this._callback && this._callback();\n return false;\n }\n return true;\n }, false);\n return _this;\n }\n Anim2.prototype.fps = function(fps) {\n if (typeof fps === \"undefined\") {\n return this._fps;\n }\n this._fps = fps > 0 ? fps : FPS;\n this._ft = 1e3 / this._fps;\n return this;\n };\n Anim2.prototype.setFrames = function(frames) {\n return this.frames(frames);\n };\n Anim2.prototype.frames = function(frames) {\n this._index = 0;\n this._frames = texture(frames).array();\n this.touch();\n return this;\n };\n Anim2.prototype.length = function() {\n return this._frames ? this._frames.length : 0;\n };\n Anim2.prototype.gotoFrame = function(frame, resize) {\n if (resize === void 0) {\n resize = false;\n }\n this._index = math.wrap(frame, this._frames.length) | 0;\n resize = resize || !this._textures[0];\n this._textures[0] = this._frames[this._index];\n if (resize) {\n this.pin(\"width\", this._textures[0].getWidth());\n this.pin(\"height\", this._textures[0].getHeight());\n }\n this.touch();\n return this;\n };\n Anim2.prototype.moveFrame = function(move) {\n return this.gotoFrame(this._index + move);\n };\n Anim2.prototype.repeat = function(repeat, callback) {\n this._repeat = repeat * this._frames.length - 1;\n this._callback = callback;\n this.play();\n return this;\n };\n Anim2.prototype.play = function(frame) {\n if (typeof frame !== \"undefined\") {\n this.gotoFrame(frame);\n this._time = 0;\n } else if (this._time < 0) {\n this._time = 0;\n }\n this.touch();\n return this;\n };\n Anim2.prototype.stop = function(frame) {\n this._time = -1;\n if (typeof frame !== \"undefined\") {\n this.gotoFrame(frame);\n }\n return this;\n };\n return Anim2;\n }(Node)\n);\nvar __extends = function() {\n var extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {\n d2.__proto__ = b2;\n } || function(d2, b2) {\n for (var p in b2)\n if (Object.prototype.hasOwnProperty.call(b2, p))\n d2[p] = b2[p];\n };\n return extendStatics(d, b);\n };\n return function(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\nfunction monotype(chars) {\n return new Monotype().frames(chars);\n}\nvar Monotype = (\n /** @class */\n function(_super) {\n __extends(Monotype2, _super);\n function Monotype2() {\n var _this = _super.call(this) || this;\n _this.label(\"String\");\n _this._textures = [];\n return _this;\n }\n Monotype2.prototype.setFont = function(frames) {\n return this.frames(frames);\n };\n Monotype2.prototype.frames = function(frames) {\n this._textures = [];\n if (typeof frames == \"string\") {\n var selection_1 = texture(frames);\n this._font = function(value) {\n return selection_1.one(value);\n };\n } else if (typeof frames === \"object\") {\n this._font = function(value) {\n return frames[value];\n };\n } else if (typeof frames === \"function\") {\n this._font = frames;\n }\n return this;\n };\n Monotype2.prototype.setValue = function(value) {\n return this.value(value);\n };\n Monotype2.prototype.value = function(value) {\n if (typeof value === \"undefined\") {\n return this._value;\n }\n if (this._value === value) {\n return this;\n }\n this._value = value;\n if (value === null) {\n value = \"\";\n } else if (typeof value !== \"string\" && !Array.isArray(value)) {\n value = value.toString();\n }\n this._spacing = this._spacing || 0;\n var width = 0;\n var height = 0;\n for (var i = 0; i < value.length; i++) {\n var v = value[i];\n var texture_1 = this._textures[i] = this._font(typeof v === \"string\" ? v : v + \"\");\n width += i > 0 ? this._spacing : 0;\n texture_1.setDestinationCoordinate(width, 0);\n width = width + texture_1.getWidth();\n height = Math.max(height, texture_1.getHeight());\n }\n this.pin(\"width\", width);\n this.pin(\"height\", height);\n this._textures.length = value.length;\n return this;\n };\n return Monotype2;\n }(Node)\n);\nvar string = monotype;\nvar Str = Monotype;\nconst Stage = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({\n __proto__: null,\n Anim,\n Atlas,\n CanvasTexture,\n Image: Image$1,\n ImageTexture,\n Math: math,\n Matrix,\n Monotype,\n Mouse,\n Node,\n POINTER_CANCEL,\n POINTER_CLICK,\n POINTER_END,\n POINTER_MOVE,\n POINTER_START,\n Pin,\n PipeTexture,\n Pointer,\n ResizableTexture,\n Root,\n Sprite,\n Str,\n Texture,\n TextureSelection,\n Transition,\n anim,\n atlas,\n box,\n canvas,\n clamp,\n column,\n create,\n image,\n isValidFitMode,\n layer,\n layout,\n length,\n math,\n maximize,\n memoizeDraw,\n minimize,\n monotype,\n mount,\n pause,\n random,\n resume,\n row,\n sprite,\n string,\n texture,\n wrap\n}, Symbol.toStringTag, { value: \"Module\" }));\nexport {\n Anim,\n Atlas,\n CanvasTexture,\n Image$1 as Image,\n ImageTexture,\n math as Math,\n Matrix,\n Monotype,\n Mouse,\n Node,\n POINTER_CANCEL,\n POINTER_CLICK,\n POINTER_END,\n POINTER_MOVE,\n POINTER_START,\n Pin,\n PipeTexture,\n Pointer,\n ResizableTexture,\n Root,\n Sprite,\n Str,\n Texture,\n TextureSelection,\n Transition,\n anim,\n atlas,\n box,\n canvas,\n clamp,\n column,\n create,\n Stage as default,\n image,\n isValidFitMode,\n layer,\n layout,\n length,\n math,\n maximize,\n memoizeDraw,\n minimize,\n monotype,\n mount,\n pause,\n random,\n resume,\n row,\n sprite,\n string,\n texture,\n wrap\n};\n","import * as Stage from \"stage-js\";\n\nimport type { Vec2Value } from \"../src/common/Vec2\";\nimport type { World } from \"../src/dynamics/World\";\nimport type { Joint } from \"../src/dynamics/Joint\";\nimport type { Fixture } from \"../src/dynamics/Fixture\";\nimport type { Body } from \"../src/dynamics/Body\";\nimport type { AABBValue } from \"../src/collision/AABB\";\nimport type { Shape } from \"../src/collision/Shape\";\nimport type { Style } from \"../src/util/Testbed\";\nimport { Testbed } from \"../src/util/Testbed\";\nimport type { EdgeShape } from \"../src/collision/shape/EdgeShape\";\nimport type { PolygonShape } from \"../src/collision/shape/PolygonShape\";\nimport type { ChainShape } from \"../src/collision/shape/ChainShape\";\nimport type { CircleShape } from \"../src/collision/shape/CircleShape\";\nimport type { PulleyJoint } from \"../src/dynamics/joint/PulleyJoint\";\nimport { MouseJoint } from \"../src/dynamics/joint/MouseJoint\";\n\nconst math_atan2 = Math.atan2;\nconst math_abs = Math.abs;\nconst math_sqrt = Math.sqrt;\nconst math_PI = Math.PI;\nconst math_max = Math.max;\nconst math_min = Math.min;\n\ninterface DrawOptions {\n scaleY: number;\n lineWidth: number;\n stroke: string;\n fill: string;\n}\n\nlet mounted: StageTestbed | null = null;\n\n/** @internal */\nfunction memo() {\n const memory: any = [];\n function recall(...rest: any[]) {\n let equal = memory.length === rest.length;\n for (let i = 0; equal && i < rest.length; i++) {\n equal = equal && memory[i] === rest[i];\n memory[i] = rest[i];\n }\n memory.length = rest.length;\n return equal;\n }\n function reset() {\n memory.length = 0;\n // void 0;\n }\n return {\n recall,\n reset,\n };\n}\n\nTestbed.mount = () => {\n if (mounted) {\n return mounted;\n }\n\n mounted = new StageTestbed();\n\n // todo: merge rest of this into StageTestbed\n\n // todo: should we create these elements if not exists?\n const playButton = document.getElementById(\"testbed-play\");\n const statusElement = document.getElementById(\"testbed-status\");\n const infoElement = document.getElementById(\"testbed-info\");\n\n if (playButton) {\n playButton.addEventListener(\"click\", () => {\n if (mounted.isPaused() ) {\n mounted.resume();\n } else {\n mounted.pause();\n }\n });\n\n mounted._pause = () => {\n playButton.classList.add(\"pause\");\n playButton.classList.remove(\"play\");\n };\n\n mounted._resume = () => {\n playButton.classList.add(\"play\");\n playButton.classList.remove(\"pause\");\n };\n } else {\n console.log(\"Please create a button with id='testbed-play'\");\n }\n\n let lastStatus = \"\";\n if (statusElement) {\n statusElement.innerText = lastStatus;\n }\n mounted._status = (text: string) => {\n if (lastStatus === text) {\n return;\n }\n lastStatus = text;\n if (statusElement) {\n statusElement.innerText = text;\n }\n };\n\n let lastInfo = \"\";\n if (infoElement) {\n infoElement.innerText = lastInfo;\n }\n mounted._info = (text: string) => {\n if (lastInfo === text) {\n return;\n }\n lastInfo = text;\n if (infoElement) {\n infoElement.innerText = text;\n }\n };\n\n return mounted;\n};\n\nfunction getStyle(obj: Body | Fixture | Joint | Shape): Style {\n if (typeof obj[\"render\"] === \"object\" && (\"stroke\" in obj[\"render\"] || \"fill\" in obj[\"render\"])) {\n // this was used in planck before v1\n return obj[\"render\"];\n } else if (typeof obj[\"style\"] === \"object\") {\n return obj[\"style\"];\n }\n}\n\nfunction findBody(world: World, point: Vec2Value) {\n let body: Body | null = null;\n const aabb = {\n lowerBound: point,\n upperBound: point,\n };\n world.queryAABB(aabb, (fixture: Fixture) => {\n if (!fixture.getBody().isDynamic() || !fixture.testPoint(point)) {\n return true;\n }\n body = fixture.getBody();\n return false;\n });\n return body;\n}\n\n/** @internal */\nexport class StageTestbed extends Testbed {\n private canvas: HTMLCanvasElement;\n private stage: Stage.Root;\n private paused: boolean = false;\n private lastDrawHash = \"\";\n private newDrawHash = \"\";\n private buffer: ((context: CanvasRenderingContext2D, ratio: number)=> void)[] = [];\n\n start(world: World) {\n const stage = this.stage = Stage.mount();\n const canvas = this.canvas = stage.dom as HTMLCanvasElement;\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const testbed = this;\n this.canvas = canvas;\n\n stage.on(Stage.POINTER_START, () => {\n window.focus();\n // @ts-ignore\n document.activeElement?.blur();\n canvas.focus();\n });\n\n stage.MAX_ELAPSE = 1000 / 30;\n\n stage.on(\"resume\", () => {\n this.paused = false;\n this._resume();\n });\n stage.on(\"pause\", () => {\n this.paused = true;\n this._pause();\n });\n\n const drawingTexture = new Stage.CanvasTexture();\n drawingTexture.draw = (ctx: CanvasRenderingContext2D) => {\n const pixelRatio = 2 * drawingTexture.getOptimalPixelRatio();\n ctx.save();\n ctx.transform(1, 0, 0, this.scaleY, -this.x, -this.y);\n ctx.lineWidth = 3 / pixelRatio;\n ctx.lineCap = \"round\";\n for (let drawing = this.buffer.shift(); drawing; drawing = this.buffer.shift()) {\n drawing(ctx, pixelRatio);\n }\n ctx.restore();\n };\n\n const drawingElement = Stage.sprite(drawingTexture);\n stage.append(drawingElement);\n stage.tick(() => {\n this.buffer.length = 0;\n }, true);\n\n\n stage.background(this.background);\n stage.viewbox(this.width, this.height);\n stage.pin(\"alignX\", -0.5);\n stage.pin(\"alignY\", -0.5);\n\n const worldNode = new WorldStageNode(world, this);\n\n // stage.empty();\n stage.prepend(worldNode);\n\n let lastX = 0;\n let lastY = 0;\n stage.tick((dt: number, t: number) => {\n // update camera position\n if (lastX !== this.x || lastY !== this.y) {\n worldNode.offset(-this.x, -this.y);\n lastX = this.x;\n lastY = this.y;\n }\n });\n\n worldNode.tick((dt: number, t: number) => {\n this.step(dt, t);\n\n if (targetBody) {\n this.drawSegment(targetBody.getPosition(), mouseMove, \"rgba(255,255,255,0.2)\");\n }\n\n if (this.lastDrawHash !== this.newDrawHash) {\n this.lastDrawHash = this.newDrawHash;\n stage.touch();\n }\n this.newDrawHash = \"\";\n\n return true;\n });\n\n const mouseGround = world.createBody();\n let mouseJoint: MouseJoint | null = null;\n let targetBody: Body | null = null;\n const mouseMove = {x: 0, y: 0};\n\n worldNode.attr(\"spy\", true);\n\n worldNode.on(Stage.POINTER_START, (point: Vec2Value) => {\n point = { x: point.x, y: testbed.scaleY * point.y };\n if (targetBody) {\n return;\n }\n\n const body = findBody(world, point);\n if (!body) {\n return;\n }\n\n if (this.mouseForce) {\n targetBody = body;\n\n } else {\n mouseJoint = new MouseJoint({maxForce: 1000}, mouseGround, body, { x: point.x, y: point.y });\n world.createJoint(mouseJoint);\n }\n });\n\n worldNode.on(Stage.POINTER_MOVE, (point: Vec2Value) => {\n point = { x: point.x, y: testbed.scaleY * point.y };\n if (mouseJoint) {\n mouseJoint.setTarget(point);\n }\n\n mouseMove.x = point.x;\n mouseMove.y = point.y;\n });\n\n worldNode.on(Stage.POINTER_END, (point: Vec2Value) => {\n point = { x: point.x, y: testbed.scaleY * point.y };\n if (mouseJoint) {\n world.destroyJoint(mouseJoint);\n mouseJoint = null;\n }\n if (targetBody && this.mouseForce) {\n const target = targetBody.getPosition();\n const force = {\n x: (point.x - target.x) * this.mouseForce,\n y: (point.y - target.y) * this.mouseForce,\n };\n targetBody.applyForceToCenter(force, true);\n targetBody = null;\n }\n });\n\n worldNode.on(Stage.POINTER_CANCEL, (point: Vec2Value) => {\n point = { x: point.x, y: testbed.scaleY * point.y };\n if (mouseJoint) {\n world.destroyJoint(mouseJoint);\n mouseJoint = null;\n }\n if (targetBody) {\n targetBody = null;\n }\n });\n\n const activeKeys = testbed.activeKeys;\n const downKeys: Record = {};\n function updateActiveKeys(keyCode: number, down: boolean) {\n const char = String.fromCharCode(keyCode);\n if (/\\w/.test(char)) {\n activeKeys[char] = down;\n }\n activeKeys.right = downKeys[39] || activeKeys[\"D\"];\n activeKeys.left = downKeys[37] || activeKeys[\"A\"];\n activeKeys.up = downKeys[38] || activeKeys[\"W\"];\n activeKeys.down = downKeys[40] || activeKeys[\"S\"];\n activeKeys.fire = downKeys[32] || downKeys[13] ;\n }\n\n window.addEventListener(\"keydown\", function(e) {\n const keyCode = e.keyCode;\n downKeys[keyCode] = true;\n updateActiveKeys(keyCode, true);\n testbed.keydown?.(keyCode, String.fromCharCode(keyCode));\n });\n window.addEventListener(\"keyup\", function(e) {\n const keyCode = e.keyCode;\n downKeys[keyCode] = false;\n updateActiveKeys(keyCode, false);\n testbed.keyup?.(keyCode, String.fromCharCode(keyCode));\n });\n\n this.resume();\n }\n\n /** @private @internal */\n focus() {\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n document.activeElement && document.activeElement.blur();\n this.canvas.focus();\n }\n\n /** @internal */\n _pause() {\n }\n\n /** @internal */\n _resume() {\n }\n\n private statusText = \"\";\n private statusMap: Record = {};\n\n status(name: string, value: any): void;\n status(value: object | string): void;\n status(a: any, b?: any) {\n if (typeof b !== \"undefined\") {\n const key = a;\n const value = b;\n if (typeof value !== \"function\" && typeof value !== \"object\") {\n this.statusMap[key] = value;\n }\n } else if (a && typeof a === \"object\") {\n // tslint:disable-next-line:no-for-in\n for (const key in a) {\n const value = a[key];\n if (typeof value !== \"function\" && typeof value !== \"object\") {\n this.statusMap[key] = value;\n }\n }\n } else if (typeof a === \"string\") {\n this.statusText = a;\n }\n\n var newline = \"\\n\";\n var text = this.statusText || \"\";\n for (var key in this.statusMap) {\n var value = this.statusMap[key];\n if (typeof value === \"function\") continue;\n text += (text && newline) + key + \": \" + value;\n }\n\n this._status(text);\n }\n\n info(text: string): void {\n this._info(text);\n }\n\n /** @internal */\n _status(string: string) {\n }\n\n /** @internal */ \n _info(text: string) {\n }\n\n /** @internal */\n isPaused() {\n return this.paused;\n }\n\n /** @internal */\n togglePause() {\n if (this.paused) {\n this.resume();\n } else {\n this.pause();\n }\n }\n\n /** @internal */\n pause() {\n this.stage.pause();\n }\n\n /** @internal */\n resume() {\n this.stage.resume();\n this.focus();\n }\n\n drawPoint(p: {x: number, y: number}, r: number, color: string): void {\n this.buffer.push(function(ctx, ratio) {\n ctx.beginPath();\n ctx.arc(p.x, p.y, 5 / ratio, 0, 2 * math_PI);\n ctx.strokeStyle = color;\n ctx.stroke();\n });\n this.newDrawHash += \"point\" + p.x + \",\" + p.y + \",\" + r + \",\" + color;\n }\n\n drawCircle(p: {x: number, y: number}, r: number, color: string): void {\n this.buffer.push(function(ctx) {\n ctx.beginPath();\n ctx.arc(p.x, p.y, r, 0, 2 * math_PI);\n ctx.strokeStyle = color;\n ctx.stroke();\n });\n this.newDrawHash += \"circle\" + p.x + \",\" + p.y + \",\" + r + \",\" + color;\n }\n\n drawEdge(a: {x: number, y: number}, b: {x: number, y: number}, color: string): void {\n this.buffer.push(function(ctx) {\n ctx.beginPath();\n ctx.moveTo(a.x, a.y);\n ctx.lineTo(b.x, b.y);\n ctx.strokeStyle = color;\n ctx.stroke();\n });\n this.newDrawHash += \"segment\" + a.x + \",\" + a.y + \",\" + b.x + \",\" + b.y + \",\" + color;\n }\n\n drawSegment = this.drawEdge;\n\n drawPolygon(points: Array<{x: number, y: number}>, color: string): void {\n if (!points || !points.length) {\n return;\n }\n this.buffer.push(function(ctx) {\n ctx.beginPath();\n ctx.moveTo(points[0].x, points[0].y);\n for (let i = 1; i < points.length; i++) {\n ctx.lineTo(points[i].x, points[i].y);\n }\n ctx.strokeStyle = color;\n ctx.closePath();\n ctx.stroke();\n });\n this.newDrawHash += \"segment\";\n for (let i = 1; i < points.length; i++) {\n this.newDrawHash += points[i].x + \",\" + points[i].y + \",\";\n }\n this.newDrawHash += color;\n }\n\n drawAABB(aabb: AABBValue, color: string): void {\n this.buffer.push(function(ctx) {\n ctx.beginPath();\n ctx.moveTo(aabb.lowerBound.x, aabb.lowerBound.y);\n ctx.lineTo(aabb.upperBound.x, aabb.lowerBound.y);\n ctx.lineTo(aabb.upperBound.x, aabb.upperBound.y);\n ctx.lineTo(aabb.lowerBound.x, aabb.upperBound.y);\n ctx.strokeStyle = color;\n ctx.closePath();\n ctx.stroke();\n });\n this.newDrawHash += \"aabb\";\n this.newDrawHash += aabb.lowerBound.x + \",\" + aabb.lowerBound.y + \",\";\n this.newDrawHash += aabb.upperBound.x + \",\" + aabb.upperBound.y + \",\";\n this.newDrawHash += color;\n }\n\n findOne(query: string): (Body | Joint | Fixture | null) {\n throw new Error(\"Not implemented\");\n }\n\n findAll(query: string): (Body | Joint | Fixture)[] {\n throw new Error(\"Not implemented\");\n }\n}\n\ninterface WorldStageOptions {\n speed: number;\n hz: number;\n scaleY: number;\n lineWidth: number;\n stroke: string | undefined;\n fill: string | undefined;\n}\n\nclass WorldStageNode extends Stage.Node {\n private nodes = new WeakMap();\n\n private options: WorldStageOptions = {\n speed: 1,\n hz: 60,\n scaleY: -1,\n lineWidth: 3,\n stroke: undefined,\n fill: undefined\n };\n\n private world: World;\n private testbed: Testbed;\n\n constructor(world: World, opts: Partial = {}) {\n super();\n this.label(\"Planck\");\n\n this.options = { ...this.options, ...opts };\n\n if (math_abs(this.options.hz) < 1) {\n this.options.hz = 1 / this.options.hz;\n }\n\n this.world = world;\n this.testbed = opts as Testbed;\n\n const timeStep = 1 / this.options.hz;\n let elapsedTime = 0;\n let errored = false;\n this.tick((dt: number) => {\n if (errored) {\n return false;\n }\n try {\n dt = dt * 0.001 * this.options.speed;\n elapsedTime += dt;\n while (elapsedTime > timeStep) {\n world.step(timeStep);\n elapsedTime -= timeStep;\n }\n this.renderWorld();\n return true; \n } catch (error) {\n errored = true;\n console.error(error);\n return false;\n }\n }, true);\n\n world.on(\"remove-fixture\", (obj: Fixture) => {\n this.nodes.get(obj)?.remove();\n });\n\n world.on(\"remove-joint\", (obj: Joint) => {\n this.nodes.get(obj)?.remove();\n });\n }\n\n renderWorld() {\n const world = this.world;\n const options = this.options;\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const viewer = this;\n\n for (let b = world.getBodyList(); b; b = b.getNext()) {\n for (let f = b.getFixtureList(); f; f = f.getNext()) {\n\n let node = this.nodes.get(f);\n if (!node) {\n const type = f.getType();\n const shape = f.getShape();\n\n const opts: DrawOptions = Object.assign({\n stroke: options.stroke,\n fill: options.fill,\n scaleY: options.scaleY,\n lineWidth: options.lineWidth,\n }, getStyle(b), getStyle(f), getStyle(shape));\n\n if (opts.stroke) {\n // good\n } else if (b.isDynamic()) {\n opts.stroke = \"rgba(255,255,255,0.9)\";\n } else if (b.isKinematic()) {\n opts.stroke = \"rgba(255,255,255,0.7)\";\n } else if (b.isStatic()) {\n opts.stroke = \"rgba(255,255,255,0.5)\";\n }\n\n if (type == \"circle\") {\n node = viewer.drawCircle(shape as CircleShape, opts);\n }\n if (type == \"edge\") {\n node = viewer.drawEdge(shape as EdgeShape, opts);\n }\n if (type == \"polygon\") {\n node = viewer.drawPolygon(shape as PolygonShape, opts);\n }\n if (type == \"chain\") {\n node = viewer.drawChain(shape as ChainShape, opts);\n }\n\n if (node) {\n node.appendTo(viewer);\n this.nodes.set(f, node);\n }\n }\n\n if (node) {\n const p = b.getPosition();\n const r = b.getAngle();\n // @ts-ignore\n const isChanged = node.__lastX !== p.x || node.__lastY !== p.y || node.__lastR !== r;\n if (isChanged) {\n // @ts-ignore\n node.__lastX = p.x;\n // @ts-ignore\n node.__lastY = p.y;\n // @ts-ignore\n node.__lastR = r;\n node.offset(p.x, options.scaleY * p.y);\n node.rotate(options.scaleY * r);\n }\n }\n\n }\n }\n\n for (let j = world.getJointList(); j; j = j.getNext()) {\n const type = j.getType();\n if (type == \"pulley-joint\") {\n this.testbed.drawSegment(j.getAnchorA(), (j as PulleyJoint).getGroundAnchorA(), \"rgba(255,255,255,0.5)\");\n this.testbed.drawSegment(j.getAnchorB(), (j as PulleyJoint).getGroundAnchorB(), \"rgba(255,255,255,0.5)\");\n this.testbed.drawSegment((j as PulleyJoint).getGroundAnchorB(), (j as PulleyJoint).getGroundAnchorA(), \"rgba(255,255,255,0.5)\");\n } else {\n this.testbed.drawSegment(j.getAnchorA(), j.getAnchorB(), \"rgba(255,255,255,0.5)\");\n }\n }\n }\n\n drawCircle(shape: CircleShape, options: DrawOptions) {\n let offsetX = 0;\n let offsetY = 0;\n const offsetMemo = memo();\n\n const texture = Stage.canvas();\n texture.setDrawer(function () {\n const ctx = this.getContext();\n const ratio = 2 * this.getOptimalPixelRatio();\n const lw = options.lineWidth / ratio;\n\n const r = shape.m_radius;\n const cx = r + lw;\n const cy = r + lw;\n const w = r * 2 + lw * 2;\n const h = r * 2 + lw * 2;\n\n offsetX = shape.m_p.x - cx;\n offsetY = options.scaleY * shape.m_p.y - cy;\n\n this.setSize(w, h, ratio);\n\n ctx.scale(ratio, ratio);\n ctx.arc(cx, cy, r, 0, 2 * math_PI);\n if (options.fill) {\n ctx.fillStyle = options.fill;\n ctx.fill();\n }\n ctx.lineTo(cx, cy);\n ctx.lineWidth = options.lineWidth / ratio;\n ctx.strokeStyle = options.stroke ?? \"\";\n ctx.stroke();\n });\n\n const sprite = Stage.sprite(texture);\n sprite.tick(() => {\n if (!offsetMemo.recall(offsetX, offsetY)) {\n sprite.offset(offsetX, offsetY);\n }\n });\n\n const node = Stage.layout().append(sprite);\n return node;\n }\n\n drawEdge(edge: EdgeShape, options: DrawOptions) {\n let offsetX = 0;\n let offsetY = 0;\n let offsetA = 0;\n const offsetMemo = memo();\n\n const texture = Stage.canvas();\n texture.setDrawer(function () {\n const ctx = this.getContext();\n const ratio = 2 * this.getOptimalPixelRatio();\n const lw = options.lineWidth / ratio;\n\n const v1 = edge.m_vertex1;\n const v2 = edge.m_vertex2;\n\n const dx = v2.x - v1.x;\n const dy = v2.y - v1.y;\n\n const length = math_sqrt(dx * dx + dy * dy);\n\n this.setSize(length + 2 * lw, 2 * lw, ratio);\n\n const minX = math_min(v1.x, v2.x);\n const minY = math_min(options.scaleY * v1.y, options.scaleY * v2.y);\n \n offsetX = minX - lw;\n offsetY = minY - lw;\n offsetA = options.scaleY * math_atan2(dy, dx);\n\n ctx.scale(ratio, ratio);\n ctx.beginPath();\n ctx.moveTo(lw, lw);\n ctx.lineTo(lw + length, lw);\n\n ctx.lineCap = \"round\";\n ctx.lineWidth = options.lineWidth / ratio;\n ctx.strokeStyle = options.stroke ?? \"\";\n ctx.stroke();\n });\n\n const sprite = Stage.sprite(texture);\n sprite.tick(() => {\n if(!offsetMemo.recall(offsetX, offsetY, offsetA)) {\n sprite.offset(offsetX, offsetY);\n sprite.rotate(offsetA);\n }\n });\n const node = Stage.layout().append(sprite);\n return node;\n }\n\n drawPolygon(shape: PolygonShape, options: DrawOptions) {\n let offsetX = 0;\n let offsetY = 0;\n const offsetMemo = memo();\n\n const texture = Stage.canvas();\n texture.setDrawer(function () {\n const ctx = this.getContext();\n const ratio = 2 * this.getOptimalPixelRatio();\n const lw = options.lineWidth / ratio;\n\n const vertices = shape.m_vertices;\n\n if (!vertices.length) {\n return;\n }\n \n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (let i = 0; i < vertices.length; ++i) {\n const v = vertices[i];\n minX = math_min(minX, v.x);\n maxX = math_max(maxX, v.x);\n minY = math_min(minY, options.scaleY * v.y);\n maxY = math_max(maxY, options.scaleY * v.y);\n }\n \n const width = maxX - minX;\n const height = maxY - minY;\n\n offsetX = minX;\n offsetY = minY;\n\n this.setSize(width + 2 * lw, height + 2 * lw, ratio);\n\n ctx.scale(ratio, ratio);\n ctx.beginPath();\n for (let i = 0; i < vertices.length; ++i) {\n const v = vertices[i];\n const x = v.x - minX + lw;\n const y = options.scaleY * v.y - minY + lw;\n if (i == 0)\n ctx.moveTo(x, y);\n\n else\n ctx.lineTo(x, y);\n }\n\n if (vertices.length > 2) {\n ctx.closePath();\n }\n\n if (options.fill) {\n ctx.fillStyle = options.fill;\n ctx.fill();\n ctx.closePath();\n }\n\n ctx.lineCap = \"round\";\n ctx.lineWidth = options.lineWidth / ratio;\n ctx.strokeStyle = options.stroke ?? \"\";\n ctx.stroke();\n });\n\n const sprite = Stage.sprite(texture);\n sprite.tick(() => {\n if(!offsetMemo.recall(offsetX, offsetY)) {\n sprite.offset(offsetX, offsetY);\n }\n });\n\n const node = Stage.layout().append(sprite);\n return node;\n }\n\n drawChain(shape: ChainShape, options: DrawOptions) {\n let offsetX = 0;\n let offsetY = 0;\n const offsetMemo = memo();\n\n const texture = Stage.canvas();\n texture.setDrawer(function () {\n const ctx = this.getContext();\n const ratio = 2 * this.getOptimalPixelRatio();\n const lw = options.lineWidth / ratio;\n\n const vertices = shape.m_vertices;\n\n if (!vertices.length) {\n return;\n }\n \n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (let i = 0; i < vertices.length; ++i) {\n const v = vertices[i];\n minX = math_min(minX, v.x);\n maxX = math_max(maxX, v.x);\n minY = math_min(minY, options.scaleY * v.y);\n maxY = math_max(maxY, options.scaleY * v.y);\n }\n \n const width = maxX - minX;\n const height = maxY - minY;\n\n offsetX = minX;\n offsetY = minY;\n\n this.setSize(width + 2 * lw, height + 2 * lw, ratio);\n\n ctx.scale(ratio, ratio);\n ctx.beginPath();\n for (let i = 0; i < vertices.length; ++i) {\n const v = vertices[i];\n const x = v.x - minX + lw;\n const y = options.scaleY * v.y - minY + lw;\n if (i == 0)\n ctx.moveTo(x, y);\n\n else\n ctx.lineTo(x, y);\n }\n\n // TODO: if loop\n if (vertices.length > 2) {\n // ctx.closePath();\n }\n\n if (options.fill) {\n ctx.fillStyle = options.fill;\n ctx.fill();\n ctx.closePath();\n }\n\n ctx.lineCap = \"round\";\n ctx.lineWidth = options.lineWidth / ratio;\n ctx.strokeStyle = options.stroke ?? \"\";\n ctx.stroke();\n });\n\n const sprite = Stage.sprite(texture);\n sprite.tick(() => {\n if(!offsetMemo.recall(offsetX, offsetY)) {\n sprite.offset(offsetX, offsetY);\n }\n });\n\n const node = Stage.layout().append(sprite);\n return node;\n }\n}\n"],"names":["d","b","__extends","__assign","s","n","input","output","math_random","x","clamp","random","math","math_abs","math_sqrt","math_max","math_min","Vec2","v","a","length","AABB","normal","temp","math_PI","Settings","SettingsInternal","Pool","TreeNode","DynamicTree","c","Iterator","BroadPhase","displacement","math_sin","math_cos","transform","xf","math_atan2","Rot","matrix.vec2","Sweep","matrix.zeroVec2","matrix.transformVec2","matrix.copyVec2","localCenter","matrix.setRotAngle","matrix.combine2Vec2","matrix.minusVec2","matrix.rotVec2","Transform","rotation","Velocity","Position","Shape","FixtureProxy","Fixture","matrix.subVec2","matrix.transform","Body","matrix.plusScaleVec2","matrix.scaleVec2","matrix.dotVec2","matrix.crossNumVec2","matrix.plusVec2","point","JointEdge","Joint","stats","DistanceInput","DistanceOutput","SimplexCache","cache","xfA","xfB","matrix.lengthSqrVec2","matrix.derotVec2","matrix.distVec2","rA","rB","matrix.normalizeVec2","matrix.minusScaleVec2","DistanceProxy","SimplexVertex","Simplex","v1","v2","matrix.setVec2","matrix.crossVec2Vec2","pA","pB","matrix.combine3Vec2","matrix.copyTransform","ShapeCastInput","ShapeCastOutput","simplex","pointA","pointB","TOIInput","TOIOutputState","TOIOutput","SeparationFunctionType","SeparationFunction","matrix.normalizeVec2Length","matrix.crossVec2Num","matrix.negVec2","TimeStep","ContactImpulse","Solver","matrix.mulVec2","Mat22","cA","cB","planePoint","clipPoint","ManifoldType","ContactFeatureType","PointState","ClipVertex","Manifold","ManifoldPoint","ContactID","WorldManifold","ContactEdge","VelocityConstraintPoint","tangent","P","Contact","_a","worldManifold","DEFAULTS","World","oldManifold","Vec3","EdgeShape","e","ChainShape","e1","e2","PolygonShape","ie","center","matrix.detransformVec2","matrix.addVec2","CircleShape","matrix.distSqrVec2","DistanceJoint","vA","vB","FrictionJoint","Mat33","LimitState","RevoluteJoint","PrismaticJoint","translation","perp","GearJoint","MotorJoint","MouseJoint","PulleyJoint","RopeJoint","WeldJoint","WheelJoint","Serializer","options","obj","Testbed","testbed","BoxShape","matrix.retransformVec2","clipPoints1","clipPoints2","normal1","matrix.detransformTransform","maxSeparation","edge1","matrix.rerotVec2","EPAxisType","VertexType","EPAxis","TempPolygon","ReferenceFace","s2","extendStatics","d2","b2","now","StageTestbed","Stage.mount","canvas","Stage.POINTER_START","Stage.CanvasTexture","Stage.sprite","Stage.POINTER_MOVE","Stage.POINTER_END","Stage.POINTER_CANCEL","i","WorldStageNode","texture","Stage.canvas","sprite","Stage.layout","Stage.Node"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,IAAI,gBAAgB,SAASA,IAAGC,IAAG;AAC/B,kBAAgB,OAAO,kBAClB,EAAE,WAAW,CAAA,eAAgB,SAAS,SAAUD,IAAGC,IAAG;AAAE,IAAAD,GAAE,YAAYC;AAAA,EAAE,KACzE,SAAUD,IAAGC,IAAG;AAAE,aAAS,KAAKA,GAAG,KAAI,OAAO,UAAU,eAAe,KAAKA,IAAG,CAAC,EAAG,CAAAD,GAAE,CAAC,IAAIC,GAAE,CAAC;AAAA;AACjG,SAAO,cAAcD,IAAGC,EAAC;AAC7B;AAEO,SAASC,YAAUF,IAAGC,IAAG;AAC5B,MAAI,OAAOA,OAAM,cAAcA,OAAM;AACjC,UAAM,IAAI,UAAU,yBAAyB,OAAOA,EAAC,IAAI,+BAA+B;AAC5F,gBAAcD,IAAGC,EAAC;AAClB,WAAS,KAAK;AAAE,SAAK,cAAcD;AAAA,EAAI;AACvC,EAAAA,GAAE,YAAYC,OAAM,OAAO,OAAO,OAAOA,EAAC,KAAK,GAAG,YAAYA,GAAE,WAAW,IAAI,GAAI;AACvF;AAEO,IAAIE,aAAW,WAAW;AAC7BA,eAAW,OAAO,UAAU,SAASA,UAAS,GAAG;AAC7C,aAASC,IAAG,IAAI,GAAGC,KAAI,UAAU,QAAQ,IAAIA,IAAG,KAAK;AACjD,MAAAD,KAAI,UAAU,CAAC;AACf,eAAS,KAAKA,GAAG,KAAI,OAAO,UAAU,eAAe,KAAKA,IAAG,CAAC,EAAG,GAAE,CAAC,IAAIA,GAAE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AEZ,kBAAA;AACA,kBAAA;AAEV,aAAK,QAAQ,QAAQ,IAAI,IAAI,SAAS,IAAI,IAAI,KAAK;AAE/C,YAAA,MAAM,OAAO,KAAK;AACtB,YAAI,UAAS;AACb,iBAAS,IAAI,GAAG,IAAI,SAAS,QAAQ,EAAE,GAAG;AAClC,cAAAA,KAAI,SAAS,CAAC;AACd,cAAAT,KAAIS,GAAE,IAAI,OAAO;AACvB,cAAM,IAAIkJ,SAAQ,SAASlJ,GAAE,IAAI,OAAO;AACxC,cAAI,KAAK;AACH,gBAAA,OAAOT,IAAG,CAAC;AAAA;AAGX,gBAAA,OAAOA,IAAG,CAAC;AAAA,QAAA;AAIf,YAAA,SAAS,SAAS,EAAG;AAIzB,YAAI2J,SAAQ,MAAM;AAChB,cAAI,YAAYA,SAAQ;AACxB,cAAI,KAAI;AACR,cAAI,UAAS;AAAA,QAAA;AAGf,YAAI,UAAU;AACV,YAAA,YAAYA,SAAQ,YAAY;AACpC,YAAI,eAAcpC,MAAAoC,SAAQ,YAAU,QAAApC,QAAA,SAAAA,MAAA;AACpC,YAAI,OAAM;AAAA,MAAA,CACX;AAEK,UAAAwE,WAASR,OAAaM,QAAO;AACnCE,eAAO,KAAK,WAAA;AACV,YAAG,CAAC,WAAW,OAAO,SAAS,OAAO,GAAG;AAChCA,mBAAA,OAAO,SAAS,OAAO;AAAA,QAAA;AAAA,MAChC,CACD;AAED,UAAM,OAAOC,SAAe,OAAOD,QAAM;AAClC,aAAA;AAAA,IACT;AACDH,WAAAA;AAAAA,EAAA,EAxY6BK,IAAU;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","x_google_ignoreList":[0,54]} \ No newline at end of file diff --git a/dist/planck.d.ts b/dist/planck.d.ts index 29a5041a..9eb305a9 100644 --- a/dist/planck.d.ts +++ b/dist/planck.d.ts @@ -1596,6 +1596,8 @@ declare class Body$1 { /** * Set the type of the body to "static", "kinematic" or "dynamic". * @param type The type of the body. + * + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. */ setType(type: BodyType): void; isBullet(): boolean; @@ -1625,6 +1627,8 @@ declare class Body$1 { * in collisions, ray-casts, or queries. Joints connected to an inactive body * are implicitly inactive. An inactive body is still owned by a World object * and remains + * + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. */ setActive(flag: boolean): void; isFixedRotation(): boolean; @@ -1641,6 +1645,8 @@ declare class Body$1 { * transform may cause non-physical behavior. Note: contacts are updated on the * next call to World.step. * + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. + * * @param position The world position of the body's local origin. * @param angle The world rotation in radians. */ @@ -1649,6 +1655,8 @@ declare class Body$1 { * Set the position of the body's origin and rotation. Manipulating a body's * transform may cause non-physical behavior. Note: contacts are updated on the * next call to World.step. + * + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. */ setTransform(xf: Transform): void; synchronizeTransform(): void; @@ -1751,6 +1759,8 @@ declare class Body$1 { * destroying fixtures can also alter the mass. This function has no effect if * the body isn't dynamic. * + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. + * * @param massData The mass properties. */ setMassData(massData: MassData): void; @@ -1812,7 +1822,7 @@ declare class Body$1 { * * Contacts are not created until the next time step. * - * Warning: This function is locked during callbacks. + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. */ createFixture(def: FixtureDef): Fixture; createFixture(shape: Shape, opt?: FixtureOpt): Fixture; @@ -1824,7 +1834,7 @@ declare class Body$1 { * All fixtures attached to a body are implicitly destroyed when the body is * destroyed. * - * Warning: This function is locked during callbacks. + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. * * @param fixture The fixture to be removed. */ @@ -2074,13 +2084,15 @@ export declare class World { * position -= newOrigin * * @param newOrigin The new origin with respect to the old origin + * + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. */ shiftOrigin(newOrigin: Vec2Value): void; /** * Create a rigid body given a definition. No reference to the definition is * retained. * - * Warning: This function is locked during callbacks. + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. */ createBody(def?: BodyDef): Body$1; createBody(position: Vec2Value, angle?: number): Body$1; @@ -2089,24 +2101,26 @@ export declare class World { createKinematicBody(def?: BodyDef): Body$1; createKinematicBody(position: Vec2Value, angle?: number): Body$1; /** - * Destroy a rigid body given a definition. No reference to the definition is - * retained. + * Destroy a body from the world. * * Warning: This automatically deletes all associated shapes and joints. * - * Warning: This function is locked during callbacks. + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. */ destroyBody(b: Body$1): boolean; /** * Create a joint to constrain bodies together. No reference to the definition * is retained. This may cause the connected bodies to cease colliding. * - * Warning: This function is locked during callbacks. + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. */ createJoint(joint: T): T | null; /** - * Destroy a joint. This may cause the connected bodies to begin colliding. - * Warning: This function is locked during callbacks. + * Destroy a joint. + * + * Warning: This may cause the connected bodies to begin colliding. + * + * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step. */ destroyJoint(joint: Joint): void; /** @@ -2118,6 +2132,10 @@ export declare class World { * @param timeStep Time step, this should not vary. */ step(timeStep: number, velocityIterations?: number, positionIterations?: number): void; + /** + * Queue a function to be called after ongoing simulation step. If no simulation is in progress call it immediately. + */ + queueUpdate(callback: (world: World) => unknown): void; /** * Called when two fixtures begin to touch. * diff --git a/dist/planck.js b/dist/planck.js index 958e15c6..41adc3da 100644 --- a/dist/planck.js +++ b/dist/planck.js @@ -2,7 +2,7 @@ typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.planck = {})); })(this, function(exports2) { "use strict";/** - * Planck.js v1.1.6 + * Planck.js v1.2.0 * @license The MIT license * @copyright Copyright (c) 2024 Erin Catto, Ali Shakiba * @@ -5953,6 +5953,7 @@ this.m_velocityIterations = def.velocityIterations; this.m_positionIterations = def.positionIterations; this.m_t = 0; + this.m_step_callback = []; } World2.prototype._serialize = function() { var bodies = []; @@ -6099,7 +6100,7 @@ return this.m_broadPhase.getTreeQuality(); }; World2.prototype.shiftOrigin = function(newOrigin) { - if (this.m_locked) { + if (this.isLocked()) { return; } for (var b2 = this.m_bodyList; b2; b2 = b2.m_next) { @@ -6331,8 +6332,19 @@ this.clearForces(); } this.m_locked = false; + var callback; + while (callback = this.m_step_callback.shift()) { + callback(this); + } this.publish("post-step", timeStep); }; + World2.prototype.queueUpdate = function(callback) { + if (!this.isLocked()) { + callback(this); + } else { + this.m_step_callback.push(callback); + } + }; World2.prototype.findNewContacts = function() { var _this = this; this.m_broadPhase.updatePairs(function(proxyA, proxyB) { diff --git a/dist/planck.js.map b/dist/planck.js.map index ef7151ef..edc49826 100644 --- a/dist/planck.js.map +++ b/dist/planck.js.map @@ -1 +1 @@ -{"version":3,"file":"planck.js","sources":["../node_modules/tslib/tslib.es6.js","../src/util/options.ts","../src/common/Math.ts","../src/common/Vec2.ts","../src/collision/AABB.ts","../src/Settings.ts","../src/util/Pool.ts","../src/collision/DynamicTree.ts","../src/collision/BroadPhase.ts","../src/common/Matrix.ts","../src/common/Rot.ts","../src/common/Sweep.ts","../src/common/Transform.ts","../src/dynamics/Velocity.ts","../src/dynamics/Position.ts","../src/collision/Shape.ts","../src/dynamics/Fixture.ts","../src/dynamics/Body.ts","../src/dynamics/Joint.ts","../src/util/stats.ts","../src/util/Timer.ts","../src/collision/Distance.ts","../src/collision/TimeOfImpact.ts","../src/dynamics/Solver.ts","../src/common/Mat22.ts","../src/collision/Manifold.ts","../src/dynamics/Contact.ts","../src/dynamics/World.ts","../src/common/Vec3.ts","../src/collision/shape/EdgeShape.ts","../src/collision/shape/ChainShape.ts","../src/collision/shape/PolygonShape.ts","../src/collision/shape/CircleShape.ts","../src/dynamics/joint/DistanceJoint.ts","../src/dynamics/joint/FrictionJoint.ts","../src/common/Mat33.ts","../src/dynamics/joint/RevoluteJoint.ts","../src/dynamics/joint/PrismaticJoint.ts","../src/dynamics/joint/GearJoint.ts","../src/dynamics/joint/MotorJoint.ts","../src/dynamics/joint/MouseJoint.ts","../src/dynamics/joint/PulleyJoint.ts","../src/dynamics/joint/RopeJoint.ts","../src/dynamics/joint/WeldJoint.ts","../src/dynamics/joint/WheelJoint.ts","../src/serializer/index.ts","../src/util/Testbed.ts","../src/collision/shape/BoxShape.ts","../src/collision/shape/CollideCircle.ts","../src/collision/shape/CollideEdgeCircle.ts","../src/collision/shape/CollidePolygon.ts","../src/collision/shape/CollideCirclePolygon.ts","../src/collision/shape/CollideEdgePolygon.ts","../src/internal.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from) {\r\n for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)\r\n to[j] = from[i];\r\n return to;\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","/** @internal */\nexport const options = function(input: T, defaults: object): T {\n if (input === null || typeof input === \"undefined\") {\n // tslint:disable-next-line:no-object-literal-type-assertion\n input = {} as T;\n }\n\n const output = {...input};\n\n // tslint:disable-next-line:no-for-in\n for (const key in defaults) {\n if (defaults.hasOwnProperty(key) && typeof input[key] === \"undefined\") {\n output[key] = defaults[key];\n }\n }\n\n if (typeof Object.getOwnPropertySymbols === \"function\") {\n const symbols = Object.getOwnPropertySymbols(defaults);\n for (let i = 0; i < symbols.length; i++) {\n const symbol = symbols[i];\n if (defaults.propertyIsEnumerable(symbol) && typeof input[symbol] === \"undefined\") {\n output[symbol] = defaults[symbol];\n }\n }\n }\n\n return output;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_random = Math.random;\n\n\nexport const EPSILON = 1e-9;\n\n/** @internal @deprecated */\nexport const isFinite = Number.isFinite;\n\n/**\n * @deprecated\n * Next Largest Power of 2 Given a binary integer value x, the next largest\n * power of 2 can be computed by a SWAR algorithm that recursively \"folds\" the\n * upper bits into the lower bits. This process yields a bit vector with the\n * same most significant 1 as x, but all 1's below it. Adding 1 to that value\n * yields the next largest power of 2. For a 32-bit value:\n */\nexport function nextPowerOfTwo(x: number): number {\n x |= (x >> 1);\n x |= (x >> 2);\n x |= (x >> 4);\n x |= (x >> 8);\n x |= (x >> 16);\n return x + 1;\n}\n\n/** @deprecated */\nexport function isPowerOfTwo(x: number): boolean {\n return x > 0 && (x & (x - 1)) === 0;\n}\n\n/** @deprecated */\nexport function mod(num: number, min?: number, max?: number): number {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n if (max > min) {\n num = (num - min) % (max - min);\n return num + (num < 0 ? max : min);\n } else {\n num = (num - max) % (min - max);\n return num + (num <= 0 ? min : max);\n }\n}\n\n/**\n * @deprecated\n * Returns a min if num is less than min, and max if more than max, otherwise returns num.\n */\nexport function clamp(num: number, min: number, max: number): number {\n if (num < min) {\n return min;\n } else if (num > max) {\n return max;\n } else {\n return num;\n }\n}\n\n/**\n * @deprecated\n * Returns a random number between min and max when two arguments are provided.\n * If one arg is provided between 0 to max.\n * If one arg is passed between 0 to 1.\n */\nexport function random(min?: number, max?: number): number {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n return min === max ? min : math_random() * (max - min) + min;\n}\n\n/** @ignore */\nexport const math = Object.create(Math);\nmath.EPSILON = EPSILON;\nmath.isFinite = isFinite;\nmath.nextPowerOfTwo = nextPowerOfTwo;\nmath.isPowerOfTwo = isPowerOfTwo;\nmath.mod = mod;\nmath.clamp = clamp;\nmath.random = random;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { clamp, EPSILON } from \"./Math\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/** 2D vector */\nexport interface Vec2Value {\n x: number;\n y: number;\n}\n\ndeclare module \"./Vec2\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(x: number, y: number): Vec2;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(obj: Vec2Value): Vec2;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(): Vec2;\n}\n\n/** 2D vector */\n// @ts-expect-error\nexport class Vec2 {\n x: number;\n y: number;\n\n constructor(x: number, y: number);\n constructor(obj: Vec2Value);\n constructor();\n // tslint:disable-next-line:typedef\n constructor(x?, y?) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Vec2)) {\n return new Vec2(x, y);\n }\n if (typeof x === \"undefined\") {\n this.x = 0;\n this.y = 0;\n } else if (typeof x === \"object\") {\n this.x = x.x;\n this.y = x.y;\n } else {\n this.x = x;\n this.y = y;\n }\n if (_ASSERT) Vec2.assert(this);\n }\n\n /** @internal */\n _serialize(): object {\n return {\n x: this.x,\n y: this.y\n };\n }\n\n /** @internal */\n static _deserialize(data: any): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = data.x;\n obj.y = data.y;\n return obj;\n }\n\n static zero(): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = 0;\n obj.y = 0;\n return obj;\n }\n\n /** @hidden */\n static neo(x: number, y: number): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = x;\n obj.y = y;\n return obj;\n }\n\n static clone(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(v.x, v.y);\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n /**\n * Does this vector contain finite coordinates?\n */\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.x) && Number.isFinite(obj.y);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Vec2.isValid(o), \"Invalid Vec2!\", o);\n }\n\n clone(): Vec2 {\n return Vec2.clone(this);\n }\n\n /**\n * Set this vector to all zeros.\n *\n * @returns this\n */\n setZero(): Vec2 {\n this.x = 0.0;\n this.y = 0.0;\n return this;\n }\n\n set(x: number, y: number): Vec2;\n set(value: Vec2Value): Vec2;\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n // tslint:disable-next-line:typedef\n set(x, y?) {\n if (typeof x === \"object\") {\n if (_ASSERT) Vec2.assert(x);\n this.x = x.x;\n this.y = x.y;\n } else {\n if (_ASSERT) console.assert(Number.isFinite(x));\n if (_ASSERT) console.assert(Number.isFinite(y));\n this.x = x;\n this.y = y;\n }\n return this;\n }\n\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n setNum(x: number, y: number) {\n if (_ASSERT) console.assert(Number.isFinite(x));\n if (_ASSERT) console.assert(Number.isFinite(y));\n this.x = x;\n this.y = y;\n\n return this;\n }\n\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n setVec2(value: Vec2Value) {\n if (_ASSERT) Vec2.assert(value);\n this.x = value.x;\n this.y = value.y;\n\n return this;\n }\n\n /** @internal @deprecated Use setCombine or setMul */\n wSet(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.setCombine(a, v, b, w);\n } else {\n return this.setMul(a, v);\n }\n }\n\n /**\n * Set linear combination of v and w: `a * v + b * w`\n */\n setCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x = x;\n this.y = y;\n return this;\n }\n\n setMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x = x;\n this.y = y;\n return this;\n }\n\n /**\n * Add a vector to this vector.\n *\n * @returns this\n */\n add(w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(w);\n this.x += w.x;\n this.y += w.y;\n return this;\n }\n\n /** @internal @deprecated Use addCombine or addMul */\n wAdd(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.addCombine(a, v, b, w);\n } else {\n return this.addMul(a, v);\n }\n }\n\n /**\n * Add linear combination of v and w: `a * v + b * w`\n */\n addCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x += x;\n this.y += y;\n return this;\n }\n\n addMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x += x;\n this.y += y;\n return this;\n }\n\n /**\n * @deprecated Use subCombine or subMul\n */\n wSub(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.subCombine(a, v, b, w);\n } else {\n return this.subMul(a, v);\n }}\n\n /**\n * Subtract linear combination of v and w: `a * v + b * w`\n */\n subCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x -= x;\n this.y -= y;\n return this;\n }\n\n subMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x -= x;\n this.y -= y;\n return this;\n }\n\n /**\n * Subtract a vector from this vector\n *\n * @returns this\n */\n sub(w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(w);\n this.x -= w.x;\n this.y -= w.y;\n return this;\n }\n\n /**\n * Multiply this vector by a scalar.\n *\n * @returns this\n */\n mul(m: number): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(m));\n this.x *= m;\n this.y *= m;\n return this;\n }\n\n /**\n * Get the length of this vector (the norm).\n *\n * For performance, use this instead of lengthSquared (if possible).\n */\n length(): number {\n return Vec2.lengthOf(this);\n }\n\n /**\n * Get the length squared.\n */\n lengthSquared(): number {\n return Vec2.lengthSquared(this);\n }\n\n /**\n * Convert this vector into a unit vector.\n *\n * @returns old length\n */\n normalize(): number {\n const length = this.length();\n if (length < EPSILON) {\n return 0.0;\n }\n const invLength = 1.0 / length;\n this.x *= invLength;\n this.y *= invLength;\n return length;\n }\n\n /**\n * Returns a new unit vector from the provided vector.\n *\n * @returns new unit vector\n */\n static normalize(v: Vec2Value): Vec2 {\n const length = Vec2.lengthOf(v);\n if (length < EPSILON) {\n return Vec2.zero();\n }\n const invLength = 1.0 / length;\n return Vec2.neo(v.x * invLength, v.y * invLength);\n }\n\n /**\n * Get the length of this vector (the norm).\n *\n * For performance, use this instead of lengthSquared (if possible).\n */\n static lengthOf(v: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n return math_sqrt(v.x * v.x + v.y * v.y);\n }\n\n /**\n * Get the length squared.\n */\n static lengthSquared(v: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n return v.x * v.x + v.y * v.y;\n }\n\n static distance(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n const dx = v.x - w.x;\n const dy = v.y - w.y;\n return math_sqrt(dx * dx + dy * dy);\n }\n\n static distanceSquared(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n const dx = v.x - w.x;\n const dy = v.y - w.y;\n return dx * dx + dy * dy;\n }\n\n static areEqual(v: Vec2Value, w: Vec2Value): boolean {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v === w || typeof w === \"object\" && w !== null && v.x === w.x && v.y === w.y;\n }\n\n /**\n * Get the skew vector such that dot(skew_vec, other) == cross(vec, other)\n */\n static skew(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(-v.y, v.x);\n }\n\n /** Dot product on two vectors */\n static dot(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.x + v.y * w.y;\n }\n\n /** Cross product between two vectors */\n static cross(v: Vec2Value, w: Vec2Value): number;\n /** Cross product between a vector and a scalar */\n static cross(v: Vec2Value, w: number): Vec2;\n /** Cross product between a scalar and a vector */\n static cross(v: number, w: Vec2Value): Vec2;\n static cross(v: any, w: any): any {\n if (typeof w === \"number\") {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y, -w * v.x);\n\n } else if (typeof v === \"number\") {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y, v * w.x);\n\n } else {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.y - v.y * w.x;\n }\n }\n\n /** Cross product on two vectors */\n static crossVec2Vec2(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.y - v.y * w.x;\n }\n\n /** Cross product on a vector and a scalar */\n static crossVec2Num(v: Vec2Value, w: number): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y, -w * v.x);\n }\n\n /** Cross product on a vector and a scalar */\n static crossNumVec2(v: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y, v * w.x);\n }\n\n /** Returns `a + (v x w)` */\n static addCross(a: Vec2Value, v: Vec2Value, w: number): Vec2;\n /** Returns `a + (v x w)` */\n static addCross(a: Vec2Value, v: number, w: Vec2Value): Vec2;\n static addCross(a: Vec2Value, v: any, w: any): Vec2 {\n if (typeof w === \"number\") {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y + a.x, -w * v.x + a.y);\n\n } else if (typeof v === \"number\") {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y + a.x, v * w.x + a.y);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n /**\n * Returns `a + (v x w)`\n */\n static addCrossVec2Num(a: Vec2Value, v: Vec2Value, w: number): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y + a.x, -w * v.x + a.y);\n }\n\n /**\n * Returns `a + (v x w)`\n */\n static addCrossNumVec2(a: Vec2Value, v: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y + a.x, v * w.x + a.y);\n }\n\n static add(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(v.x + w.x, v.y + w.y);\n }\n\n /** @hidden @deprecated */\n static wAdd(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return Vec2.combine(a, v, b, w);\n } else {\n return Vec2.mulNumVec2(a, v);\n }\n }\n\n static combine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n return Vec2.zero().setCombine(a, v, b, w);\n }\n\n static sub(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(v.x - w.x, v.y - w.y);\n }\n\n static mul(a: Vec2Value, b: number): Vec2;\n static mul(a: number, b: Vec2Value): Vec2;\n static mul(a: any, b: any): Vec2 {\n if (typeof a === \"object\") {\n if (_ASSERT) Vec2.assert(a);\n if (_ASSERT) console.assert(Number.isFinite(b));\n return Vec2.neo(a.x * b, a.y * b);\n\n } else if (typeof b === \"object\") {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(b);\n return Vec2.neo(a * b.x, a * b.y);\n }\n }\n\n static mulVec2Num(a: Vec2Value, b: number): Vec2 {\n if (_ASSERT) Vec2.assert(a);\n if (_ASSERT) console.assert(Number.isFinite(b));\n return Vec2.neo(a.x * b, a.y * b);\n }\n\n static mulNumVec2(a: number, b: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(b);\n return Vec2.neo(a * b.x, a * b.y);\n }\n\n neg(): Vec2 {\n this.x = -this.x;\n this.y = -this.y;\n return this;\n }\n\n static neg(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(-v.x, -v.y);\n }\n\n static abs(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(math_abs(v.x), math_abs(v.y));\n }\n\n static mid(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo((v.x + w.x) * 0.5, (v.y + w.y) * 0.5);\n }\n\n static upper(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(math_max(v.x, w.x), math_max(v.y, w.y));\n }\n\n static lower(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(math_min(v.x, w.x), math_min(v.y, w.y));\n }\n\n clamp(max: number): Vec2 {\n const lengthSqr = this.x * this.x + this.y * this.y;\n if (lengthSqr > max * max) {\n const scale = max / math_sqrt(lengthSqr);\n this.x *= scale;\n this.y *= scale;\n }\n return this;\n }\n\n static clamp(v: Vec2Value, max: number): Vec2 {\n const r = Vec2.neo(v.x, v.y);\n r.clamp(max);\n return r;\n }\n\n /** @hidden */\n static clampVec2(v: Vec2Value, min?: Vec2Value, max?: Vec2Value): Vec2Value {\n return {\n x: clamp(v.x, min?.x, max?.x),\n y: clamp(v.y, min?.y, max?.y)\n };\n }\n\n /** @hidden @deprecated */\n static scaleFn(x: number, y: number) {\n // todo: this was used in examples, remove in the future\n return function(v: Vec2Value): Vec2 {\n return Vec2.neo(v.x * x, v.y * y);\n };\n }\n\n /** @hidden @deprecated */\n static translateFn(x: number, y: number) {\n // todo: this was used in examples, remove in the future\n return function(v: Vec2Value): Vec2 {\n return Vec2.neo(v.x + x, v.y + y);\n };\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { EPSILON } from \"../common/Math\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n/**\n * Ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n */\nexport interface RayCastInput {\n p1: Vec2Value;\n p2: Vec2Value;\n maxFraction: number;\n}\n\nexport type RayCastCallback = (subInput: RayCastInput, id: number) => number;\n\n/**\n * Ray-cast output data. The ray hits at `p1 + fraction * (p2 - p1)`,\n * where `p1` and `p2` come from RayCastInput.\n */\nexport interface RayCastOutput {\n normal: Vec2;\n fraction: number;\n}\n\n/** Axis-aligned bounding box */\nexport interface AABBValue {\n lowerBound: Vec2Value;\n upperBound: Vec2Value;\n}\n\ndeclare module \"./AABB\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function AABB(lower?: Vec2Value, upper?: Vec2Value): AABB;\n}\n\n/** Axis-aligned bounding box */\n// @ts-expect-error\nexport class AABB {\n lowerBound: Vec2;\n upperBound: Vec2;\n\n constructor(lower?: Vec2Value, upper?: Vec2Value) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof AABB)) {\n return new AABB(lower, upper);\n }\n\n this.lowerBound = Vec2.zero();\n this.upperBound = Vec2.zero();\n\n if (typeof lower === \"object\") {\n this.lowerBound.setVec2(lower);\n }\n if (typeof upper === \"object\") {\n this.upperBound.setVec2(upper);\n } else if (typeof lower === \"object\") {\n this.upperBound.setVec2(lower);\n }\n }\n\n /**\n * Verify that the bounds are sorted.\n */\n isValid(): boolean {\n return AABB.isValid(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.lowerBound) && Vec2.isValid(obj.upperBound) && Vec2.sub(obj.upperBound, obj.lowerBound).lengthSquared() >= 0;\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!AABB.isValid(o), \"Invalid AABB!\", o);\n }\n\n /**\n * Get the center of the AABB.\n */\n getCenter(): Vec2 {\n return Vec2.neo((this.lowerBound.x + this.upperBound.x) * 0.5, (this.lowerBound.y + this.upperBound.y) * 0.5);\n }\n\n /**\n * Get the extents of the AABB (half-widths).\n */\n getExtents(): Vec2 {\n return Vec2.neo((this.upperBound.x - this.lowerBound.x) * 0.5, (this.upperBound.y - this.lowerBound.y) * 0.5);\n }\n\n /**\n * Get the perimeter length.\n */\n getPerimeter(): number {\n return 2.0 * (this.upperBound.x - this.lowerBound.x + this.upperBound.y - this.lowerBound.y);\n }\n\n /**\n * Combine one or two AABB into this one.\n */\n combine(a: AABBValue, b?: AABBValue): void {\n b = b || this;\n\n const lowerA = a.lowerBound;\n const upperA = a.upperBound;\n const lowerB = b.lowerBound;\n const upperB = b.upperBound;\n\n const lowerX = math_min(lowerA.x, lowerB.x);\n const lowerY = math_min(lowerA.y, lowerB.y);\n const upperX = math_max(upperB.x, upperA.x);\n const upperY = math_max(upperB.y, upperA.y);\n\n this.lowerBound.setNum(lowerX, lowerY);\n this.upperBound.setNum(upperX, upperY);\n }\n\n combinePoints(a: Vec2Value, b: Vec2Value): void {\n this.lowerBound.setNum(math_min(a.x, b.x), math_min(a.y, b.y));\n this.upperBound.setNum(math_max(a.x, b.x), math_max(a.y, b.y));\n }\n\n set(aabb: AABBValue): void {\n this.lowerBound.setNum(aabb.lowerBound.x, aabb.lowerBound.y);\n this.upperBound.setNum(aabb.upperBound.x, aabb.upperBound.y);\n }\n\n contains(aabb: AABBValue): boolean {\n let result = true;\n result = result && this.lowerBound.x <= aabb.lowerBound.x;\n result = result && this.lowerBound.y <= aabb.lowerBound.y;\n result = result && aabb.upperBound.x <= this.upperBound.x;\n result = result && aabb.upperBound.y <= this.upperBound.y;\n return result;\n }\n\n extend(value: number): AABB {\n AABB.extend(this, value);\n return this;\n }\n\n static extend(out: AABBValue, value: number): AABBValue {\n out.lowerBound.x -= value;\n out.lowerBound.y -= value;\n out.upperBound.x += value;\n out.upperBound.y += value;\n return out;\n }\n\n static testOverlap(a: AABBValue, b: AABBValue): boolean {\n const d1x = b.lowerBound.x - a.upperBound.x;\n const d2x = a.lowerBound.x - b.upperBound.x;\n\n const d1y = b.lowerBound.y - a.upperBound.y;\n const d2y = a.lowerBound.y - b.upperBound.y;\n\n if (d1x > 0 || d1y > 0 || d2x > 0 || d2y > 0) {\n return false;\n }\n return true;\n }\n\n static areEqual(a: AABBValue, b: AABBValue): boolean {\n return Vec2.areEqual(a.lowerBound, b.lowerBound) && Vec2.areEqual(a.upperBound, b.upperBound);\n }\n\n static diff(a: AABBValue, b: AABBValue): number {\n const wD = math_max(0, math_min(a.upperBound.x, b.upperBound.x) - math_max(b.lowerBound.x, a.lowerBound.x));\n const hD = math_max(0, math_min(a.upperBound.y, b.upperBound.y) - math_max(b.lowerBound.y, a.lowerBound.y));\n\n const wA = a.upperBound.x - a.lowerBound.x;\n const hA = a.upperBound.y - a.lowerBound.y;\n\n const wB = b.upperBound.x - b.lowerBound.x;\n const hB = b.upperBound.y - b.lowerBound.y;\n\n return wA * hA + wB * hB - wD * hD;\n }\n\n rayCast(output: RayCastOutput, input: RayCastInput): boolean {\n // From Real-time Collision Detection, p179.\n\n let tmin = -Infinity;\n let tmax = Infinity;\n\n const p = input.p1;\n const d = Vec2.sub(input.p2, input.p1);\n const absD = Vec2.abs(d);\n\n const normal = Vec2.zero();\n\n for (let f: \"x\" | \"y\" = \"x\"; f !== null; f = (f === \"x\" ? \"y\" : null)) {\n if (absD.x < EPSILON) {\n // Parallel.\n if (p[f] < this.lowerBound[f] || this.upperBound[f] < p[f]) {\n return false;\n }\n } else {\n const inv_d = 1.0 / d[f];\n let t1 = (this.lowerBound[f] - p[f]) * inv_d;\n let t2 = (this.upperBound[f] - p[f]) * inv_d;\n\n // Sign of the normal vector.\n let s = -1.0;\n\n if (t1 > t2) {\n const temp = t1;\n t1 = t2;\n t2 = temp;\n s = 1.0;\n }\n\n // Push the min up\n if (t1 > tmin) {\n normal.setZero();\n normal[f] = s;\n tmin = t1;\n }\n\n // Pull the max down\n tmax = math_min(tmax, t2);\n\n if (tmin > tmax) {\n return false;\n }\n }\n }\n\n // Does the ray start inside the box?\n // Does the ray intersect beyond the max fraction?\n if (tmin < 0.0 || input.maxFraction < tmin) {\n return false;\n }\n\n // Intersection.\n output.fraction = tmin;\n output.normal = normal;\n return true;\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static combinePoints(out: AABBValue, a: Vec2Value, b: Vec2Value): AABBValue {\n out.lowerBound.x = math_min(a.x, b.x);\n out.lowerBound.y = math_min(a.y, b.y);\n out.upperBound.x = math_max(a.x, b.x);\n out.upperBound.y = math_max(a.y, b.y);\n return out;\n }\n\n static combinedPerimeter(a: AABBValue, b: AABBValue) {\n const lx = math_min(a.lowerBound.x, b.lowerBound.x);\n const ly = math_min(a.lowerBound.y, b.lowerBound.y);\n const ux = math_max(a.upperBound.x, b.upperBound.x);\n const uy = math_max(a.upperBound.y, b.upperBound.y);\n return 2.0 * (ux - lx + uy - ly); \n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Tuning constants based on meters-kilograms-seconds (MKS) units.\n * \n * Some tolerances are absolute and some are relative. Absolute tolerances use MKS units.\n */\nexport class Settings {\n /**\n * You can use this to change the length scale used by your game.\n * \n * For example for inches you could use 39.4.\n */\n static lengthUnitsPerMeter = 1.0;\n \n // Collision\n /**\n * The maximum number of contact points between two convex shapes. Do not change\n * this value.\n */\n static maxManifoldPoints: number = 2;\n\n /**\n * The maximum number of vertices on a convex polygon. You cannot increase this\n * too much because BlockAllocator has a maximum object size.\n */\n static maxPolygonVertices: number = 12;\n\n /**\n * This is used to fatten AABBs in the dynamic tree. This allows proxies to move\n * by a small amount without triggering a tree adjustment. This is in meters.\n */\n static aabbExtension: number = 0.1;\n\n /**\n * This is used to fatten AABBs in the dynamic tree. This is used to predict the\n * future position based on the current displacement. This is a dimensionless\n * multiplier.\n */\n static aabbMultiplier: number = 2.0;\n\n /**\n * A small length used as a collision and constraint tolerance. Usually it is\n * chosen to be numerically significant, but visually insignificant.\n */\n static linearSlop: number = 0.005;\n\n /**\n * A small angle used as a collision and constraint tolerance. Usually it is\n * chosen to be numerically significant, but visually insignificant.\n */\n static angularSlop: number = (2.0 / 180.0 * math_PI);\n\n /**\n * The radius of the polygon/edge shape skin. This should not be modified.\n * Making this smaller means polygons will have an insufficient buffer for\n * continuous collision. Making it larger may create artifacts for vertex\n * collision.\n */\n static get polygonRadius(): number { return 2.0 * Settings.linearSlop; }\n\n /**\n * Maximum number of sub-steps per contact in continuous physics simulation.\n */\n static maxSubSteps: number = 8;\n\n // Dynamics\n\n /**\n * Maximum number of contacts to be handled to solve a TOI impact.\n */\n static maxTOIContacts: number = 32;\n\n /**\n * Maximum iterations to solve a TOI.\n */\n static maxTOIIterations: number = 20;\n\n /**\n * Maximum iterations to find Distance.\n */\n static maxDistanceIterations: number = 20;\n\n /**\n * A velocity threshold for elastic collisions. Any collision with a relative\n * linear velocity below this threshold will be treated as inelastic.\n */\n static velocityThreshold: number = 1.0;\n\n /**\n * The maximum linear position correction used when solving constraints. This\n * helps to prevent overshoot.\n */\n static maxLinearCorrection: number = 0.2;\n\n /**\n * The maximum angular position correction used when solving constraints. This\n * helps to prevent overshoot.\n */\n static maxAngularCorrection: number = (8.0 / 180.0 * math_PI);\n\n /**\n * The maximum linear velocity of a body. This limit is very large and is used\n * to prevent numerical problems. You shouldn't need to adjust Settings.\n */\n static maxTranslation: number = 2.0;\n\n /**\n * The maximum angular velocity of a body. This limit is very large and is used\n * to prevent numerical problems. You shouldn't need to adjust Settings.\n */\n static maxRotation: number = (0.5 * math_PI);\n\n /**\n * This scale factor controls how fast overlap is resolved. Ideally this would\n * be 1 so that overlap is removed in one time step. However using values close\n * to 1 often lead to overshoot.\n */\n static baumgarte: number = 0.2;\n static toiBaugarte: number = 0.75;\n\n // Sleep\n\n /**\n * The time that a body must be still before it will go to sleep.\n */\n static timeToSleep: number = 0.5;\n\n /**\n * A body cannot sleep if its linear velocity is above this tolerance.\n */\n static linearSleepTolerance: number = 0.01;\n\n /**\n * A body cannot sleep if its angular velocity is above this tolerance.\n */\n static angularSleepTolerance: number = (2.0 / 180.0 * math_PI);\n}\n\n/** @internal */\nexport class SettingsInternal {\n static get maxManifoldPoints() {\n return Settings.maxManifoldPoints;\n }\n static get maxPolygonVertices() {\n return Settings.maxPolygonVertices;\n }\n static get aabbExtension() {\n return Settings.aabbExtension * Settings.lengthUnitsPerMeter;\n }\n static get aabbMultiplier() {\n return Settings.aabbMultiplier;\n }\n static get linearSlop() {\n return Settings.linearSlop * Settings.lengthUnitsPerMeter;\n }\n static get linearSlopSquared() {\n return Settings.linearSlop * Settings.lengthUnitsPerMeter * Settings.linearSlop * Settings.lengthUnitsPerMeter;\n }\n static get angularSlop() {\n return Settings.angularSlop;\n }\n static get polygonRadius() {\n return 2.0 * Settings.linearSlop;\n }\n static get maxSubSteps() {\n return Settings.maxSubSteps;\n }\n static get maxTOIContacts() {\n return Settings.maxTOIContacts;\n }\n static get maxTOIIterations() {\n return Settings.maxTOIIterations;\n }\n static get maxDistanceIterations() {\n return Settings.maxDistanceIterations;\n }\n static get velocityThreshold() {\n return Settings.velocityThreshold * Settings.lengthUnitsPerMeter;\n }\n static get maxLinearCorrection() {\n return Settings.maxLinearCorrection * Settings.lengthUnitsPerMeter;\n }\n static get maxAngularCorrection() {\n return Settings.maxAngularCorrection;\n }\n static get maxTranslation() {\n return Settings.maxTranslation * Settings.lengthUnitsPerMeter;\n }\n static get maxTranslationSquared() {\n return Settings.maxTranslation * Settings.lengthUnitsPerMeter * Settings.maxTranslation * Settings.lengthUnitsPerMeter;\n }\n static get maxRotation() {\n return Settings.maxRotation;\n }\n static get maxRotationSquared() {\n return Settings.maxRotation * Settings.maxRotation;\n }\n static get baumgarte() {\n return Settings.baumgarte;\n }\n static get toiBaugarte() {\n return Settings.toiBaugarte;\n }\n static get timeToSleep() {\n return Settings.timeToSleep;\n }\n static get linearSleepTolerance() {\n return Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter;\n }\n static get linearSleepToleranceSqr() {\n return Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter * Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter;\n }\n static get angularSleepTolerance() {\n return Settings.angularSleepTolerance;\n }\n static get angularSleepToleranceSqr() {\n return Settings.angularSleepTolerance * Settings.angularSleepTolerance;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */\nexport interface PoolOptions {\n max?: number,\n create?: () => T,\n /** Called when an object is being re-allocated. */\n allocate?: (item: T) => void,\n /** Called when an object is returned to pool. */\n release?: (item: T) => void,\n /** Called when an object is returned to the pool but will be disposed from pool. */\n dispose?: (item: T) => T,\n}\n\n/** @internal */\nexport class Pool {\n _list: T[] = [];\n _max: number = Infinity;\n\n _createFn: () => T;\n _hasCreateFn: boolean = false;\n _createCount: number = 0;\n\n _allocateFn: (item: T) => void;\n _hasAllocateFn: boolean = false;\n _allocateCount: number = 0;\n\n _releaseFn: (item: T) => void;\n _hasReleaseFn: boolean = false;\n _releaseCount: number = 0;\n\n _disposeFn: (item: T) => T;\n _hasDisposeFn: boolean = false;\n _disposeCount: number = 0;\n\n constructor(opts: PoolOptions) {\n this._list = [];\n this._max = opts.max || this._max;\n\n this._createFn = opts.create;\n this._hasCreateFn = typeof this._createFn === \"function\";\n this._allocateFn = opts.allocate;\n this._hasAllocateFn = typeof this._allocateFn === \"function\";\n this._releaseFn = opts.release;\n this._hasReleaseFn = typeof this._releaseFn === \"function\";\n this._disposeFn = opts.dispose;\n this._hasDisposeFn = typeof this._disposeFn === \"function\";\n }\n\n max(n?: number): number | Pool {\n if (typeof n === \"number\") {\n this._max = n;\n return this;\n }\n return this._max;\n }\n\n size(): number {\n return this._list.length;\n }\n\n allocate(): T {\n let item: T;\n if (this._list.length > 0) {\n item = this._list.shift();\n } else {\n this._createCount++;\n if (this._hasCreateFn) {\n item = this._createFn();\n } else {\n // tslint:disable-next-line:no-object-literal-type-assertion\n item = {} as T;\n }\n }\n this._allocateCount++;\n if (this._hasAllocateFn) {\n this._allocateFn(item);\n }\n return item;\n }\n\n release(item: T): void {\n if (this._list.length < this._max) {\n this._releaseCount++;\n if (this._hasReleaseFn) {\n this._releaseFn(item);\n }\n this._list.push(item);\n } else {\n this._disposeCount++;\n if (this._hasDisposeFn) {\n item = this._disposeFn(item);\n }\n }\n }\n\n toString(): string {\n return \" +\" + this._createCount + \" >\" + this._allocateCount + \" <\" + this._releaseCount + \" -\"\n + this._disposeCount + \" =\" + this._list.length + \"/\" + this._max;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { Pool } from \"../util/Pool\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { AABB, AABBValue, RayCastCallback, RayCastInput } from \"./AABB\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n\n\nexport type DynamicTreeQueryCallback = (nodeId: number) => boolean;\n\n/**\n * A node in the dynamic tree. The client does not interact with this directly.\n */\nexport class TreeNode {\n id: number;\n /** Enlarged AABB */\n aabb: AABB = new AABB();\n userData: T = null;\n parent: TreeNode = null;\n child1: TreeNode = null;\n child2: TreeNode = null;\n /** 0: leaf, -1: free node */\n height: number = -1;\n\n constructor(id?: number) {\n this.id = id;\n }\n\n /** @internal */\n toString(): string {\n return this.id + \": \" + this.userData;\n }\n\n isLeaf(): boolean {\n return this.child1 == null;\n }\n}\n\n/** @internal */ const poolTreeNode = new Pool>({\n create(): TreeNode {\n return new TreeNode();\n },\n release(node: TreeNode) {\n node.userData = null;\n node.parent = null;\n node.child1 = null;\n node.child2 = null;\n node.height = -1;\n node.id = undefined;\n }\n});\n\n/**\n * A dynamic AABB tree broad-phase, inspired by Nathanael Presson's btDbvt. A\n * dynamic tree arranges data in a binary tree to accelerate queries such as\n * volume queries and ray casts. Leafs are proxies with an AABB. In the tree we\n * expand the proxy AABB by `aabbExtension` so that the proxy AABB is bigger\n * than the client object. This allows the client object to move by small\n * amounts without triggering a tree update.\n *\n * Nodes are pooled and relocatable, so we use node indices rather than\n * pointers.\n */\nexport class DynamicTree {\n m_root: TreeNode;\n m_lastProxyId: number;\n m_nodes: {\n [id: number]: TreeNode\n };\n\n constructor() {\n this.m_root = null;\n this.m_nodes = {};\n this.m_lastProxyId = 0;\n }\n\n /**\n * Get proxy user data.\n *\n * @return the proxy user data or 0 if the id is invalid.\n */\n getUserData(id: number): T {\n const node = this.m_nodes[id];\n if (_ASSERT) console.assert(!!node);\n return node.userData;\n }\n\n /**\n * Get the fat AABB for a node id.\n *\n * @return the proxy user data or 0 if the id is invalid.\n */\n getFatAABB(id: number): AABB {\n const node = this.m_nodes[id];\n if (_ASSERT) console.assert(!!node);\n return node.aabb;\n }\n\n allocateNode(): TreeNode {\n const node = poolTreeNode.allocate();\n node.id = ++this.m_lastProxyId;\n this.m_nodes[node.id] = node;\n return node;\n }\n\n freeNode(node: TreeNode): void {\n // tslint:disable-next-line:no-dynamic-delete\n delete this.m_nodes[node.id];\n poolTreeNode.release(node);\n }\n\n /**\n * Create a proxy in the tree as a leaf node. We return the index of the node\n * instead of a pointer so that we can grow the node pool.\n *\n * Create a proxy. Provide a tight fitting AABB and a userData pointer.\n */\n createProxy(aabb: AABBValue, userData: T): number {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n\n const node = this.allocateNode();\n\n node.aabb.set(aabb);\n\n // Fatten the aabb.\n AABB.extend(node.aabb, Settings.aabbExtension);\n\n node.userData = userData;\n node.height = 0;\n\n this.insertLeaf(node);\n\n return node.id;\n }\n\n /**\n * Destroy a proxy. This asserts if the id is invalid.\n */\n destroyProxy(id: number): void {\n const node = this.m_nodes[id];\n\n if (_ASSERT) console.assert(!!node);\n if (_ASSERT) console.assert(node.isLeaf());\n\n this.removeLeaf(node);\n this.freeNode(node);\n }\n\n /**\n * Move a proxy with a swepted AABB. If the proxy has moved outside of its\n * fattened AABB, then the proxy is removed from the tree and re-inserted.\n * Otherwise the function returns immediately.\n *\n * @param d Displacement\n *\n * @return true if the proxy was re-inserted.\n */\n moveProxy(id: number, aabb: AABBValue, d: Vec2Value): boolean {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n if (_ASSERT) console.assert(!d || Vec2.isValid(d));\n\n const node = this.m_nodes[id];\n\n if (_ASSERT) console.assert(!!node);\n if (_ASSERT) console.assert(node.isLeaf());\n\n if (node.aabb.contains(aabb)) {\n return false;\n }\n\n this.removeLeaf(node);\n\n node.aabb.set(aabb);\n\n // Extend AABB.\n aabb = node.aabb;\n AABB.extend(aabb, Settings.aabbExtension);\n\n // Predict AABB displacement.\n // const d = Vec2.mul(Settings.aabbMultiplier, displacement);\n\n if (d.x < 0.0) {\n aabb.lowerBound.x += d.x * Settings.aabbMultiplier;\n } else {\n aabb.upperBound.x += d.x * Settings.aabbMultiplier;\n }\n\n if (d.y < 0.0) {\n aabb.lowerBound.y += d.y * Settings.aabbMultiplier;\n } else {\n aabb.upperBound.y += d.y * Settings.aabbMultiplier;\n }\n\n this.insertLeaf(node);\n\n return true;\n }\n\n insertLeaf(leaf: TreeNode): void {\n if (_ASSERT) console.assert(AABB.isValid(leaf.aabb));\n\n if (this.m_root == null) {\n this.m_root = leaf;\n this.m_root.parent = null;\n return;\n }\n\n // Find the best sibling for this node\n const leafAABB = leaf.aabb;\n let index = this.m_root;\n while (!index.isLeaf()) {\n const child1 = index.child1;\n const child2 = index.child2;\n\n const area = index.aabb.getPerimeter();\n\n const combinedArea = AABB.combinedPerimeter(index.aabb, leafAABB);\n\n // Cost of creating a new parent for this node and the new leaf\n const cost = 2.0 * combinedArea;\n\n // Minimum cost of pushing the leaf further down the tree\n const inheritanceCost = 2.0 * (combinedArea - area);\n\n // Cost of descending into child1\n const newArea1 = AABB.combinedPerimeter(leafAABB, child1.aabb);\n let cost1 = newArea1 + inheritanceCost;\n if (!child1.isLeaf()) {\n const oldArea = child1.aabb.getPerimeter();\n cost1 -= oldArea;\n }\n\n // Cost of descending into child2\n const newArea2 = AABB.combinedPerimeter(leafAABB, child2.aabb);\n let cost2 = newArea2 + inheritanceCost;\n if (!child2.isLeaf()) {\n const oldArea = child2.aabb.getPerimeter();\n cost2 -= oldArea;\n }\n\n // Descend according to the minimum cost.\n if (cost < cost1 && cost < cost2) {\n break;\n }\n\n // Descend\n if (cost1 < cost2) {\n index = child1;\n } else {\n index = child2;\n }\n }\n\n const sibling = index;\n\n // Create a new parent.\n const oldParent = sibling.parent;\n const newParent = this.allocateNode();\n newParent.parent = oldParent;\n newParent.userData = null;\n newParent.aabb.combine(leafAABB, sibling.aabb);\n newParent.height = sibling.height + 1;\n\n if (oldParent != null) {\n // The sibling was not the root.\n if (oldParent.child1 === sibling) {\n oldParent.child1 = newParent;\n } else {\n oldParent.child2 = newParent;\n }\n\n newParent.child1 = sibling;\n newParent.child2 = leaf;\n sibling.parent = newParent;\n leaf.parent = newParent;\n } else {\n // The sibling was the root.\n newParent.child1 = sibling;\n newParent.child2 = leaf;\n sibling.parent = newParent;\n leaf.parent = newParent;\n this.m_root = newParent;\n }\n\n // Walk back up the tree fixing heights and AABBs\n index = leaf.parent;\n while (index != null) {\n index = this.balance(index);\n\n const child1 = index.child1;\n const child2 = index.child2;\n\n if (_ASSERT) console.assert(child1 != null);\n if (_ASSERT) console.assert(child2 != null);\n\n index.height = 1 + math_max(child1.height, child2.height);\n index.aabb.combine(child1.aabb, child2.aabb);\n\n index = index.parent;\n }\n\n // validate();\n }\n\n removeLeaf(leaf: TreeNode): void {\n if (leaf === this.m_root) {\n this.m_root = null;\n return;\n }\n\n const parent = leaf.parent;\n const grandParent = parent.parent;\n let sibling;\n if (parent.child1 === leaf) {\n sibling = parent.child2;\n } else {\n sibling = parent.child1;\n }\n\n if (grandParent != null) {\n // Destroy parent and connect sibling to grandParent.\n if (grandParent.child1 === parent) {\n grandParent.child1 = sibling;\n } else {\n grandParent.child2 = sibling;\n }\n sibling.parent = grandParent;\n this.freeNode(parent);\n\n // Adjust ancestor bounds.\n let index = grandParent;\n while (index != null) {\n index = this.balance(index);\n\n const child1 = index.child1;\n const child2 = index.child2;\n\n index.aabb.combine(child1.aabb, child2.aabb);\n index.height = 1 + math_max(child1.height, child2.height);\n\n index = index.parent;\n }\n } else {\n this.m_root = sibling;\n sibling.parent = null;\n this.freeNode(parent);\n }\n\n // validate();\n }\n\n /**\n * Perform a left or right rotation if node A is imbalanced. Returns the new\n * root index.\n */\n balance(iA: TreeNode): TreeNode {\n if (_ASSERT) console.assert(iA != null);\n\n const A = iA;\n if (A.isLeaf() || A.height < 2) {\n return iA;\n }\n\n const B = A.child1;\n const C = A.child2;\n\n const balance = C.height - B.height;\n\n // Rotate C up\n if (balance > 1) {\n const F = C.child1;\n const G = C.child2;\n\n // Swap A and C\n C.child1 = A;\n C.parent = A.parent;\n A.parent = C;\n\n // A's old parent should point to C\n if (C.parent != null) {\n if (C.parent.child1 === iA) {\n C.parent.child1 = C;\n } else {\n C.parent.child2 = C;\n }\n } else {\n this.m_root = C;\n }\n\n // Rotate\n if (F.height > G.height) {\n C.child2 = F;\n A.child2 = G;\n G.parent = A;\n A.aabb.combine(B.aabb, G.aabb);\n C.aabb.combine(A.aabb, F.aabb);\n\n A.height = 1 + math_max(B.height, G.height);\n C.height = 1 + math_max(A.height, F.height);\n } else {\n C.child2 = G;\n A.child2 = F;\n F.parent = A;\n A.aabb.combine(B.aabb, F.aabb);\n C.aabb.combine(A.aabb, G.aabb);\n\n A.height = 1 + math_max(B.height, F.height);\n C.height = 1 + math_max(A.height, G.height);\n }\n\n return C;\n }\n\n // Rotate B up\n if (balance < -1) {\n const D = B.child1;\n const E = B.child2;\n\n // Swap A and B\n B.child1 = A;\n B.parent = A.parent;\n A.parent = B;\n\n // A's old parent should point to B\n if (B.parent != null) {\n if (B.parent.child1 === A) {\n B.parent.child1 = B;\n } else {\n B.parent.child2 = B;\n }\n } else {\n this.m_root = B;\n }\n\n // Rotate\n if (D.height > E.height) {\n B.child2 = D;\n A.child1 = E;\n E.parent = A;\n A.aabb.combine(C.aabb, E.aabb);\n B.aabb.combine(A.aabb, D.aabb);\n\n A.height = 1 + math_max(C.height, E.height);\n B.height = 1 + math_max(A.height, D.height);\n } else {\n B.child2 = E;\n A.child1 = D;\n D.parent = A;\n A.aabb.combine(C.aabb, D.aabb);\n B.aabb.combine(A.aabb, E.aabb);\n\n A.height = 1 + math_max(C.height, D.height);\n B.height = 1 + math_max(A.height, E.height);\n }\n\n return B;\n }\n\n return A;\n }\n\n /**\n * Compute the height of the binary tree in O(N) time. Should not be called\n * often.\n */\n getHeight(): number {\n if (this.m_root == null) {\n return 0;\n }\n\n return this.m_root.height;\n }\n\n /**\n * Get the ratio of the sum of the node areas to the root area.\n */\n getAreaRatio(): number {\n if (this.m_root == null) {\n return 0.0;\n }\n\n const root = this.m_root;\n const rootArea = root.aabb.getPerimeter();\n\n let totalArea = 0.0;\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height < 0) {\n // Free node in pool\n continue;\n }\n\n totalArea += node.aabb.getPerimeter();\n }\n\n this.iteratorPool.release(it);\n\n return totalArea / rootArea;\n }\n\n /**\n * Compute the height of a sub-tree.\n */\n computeHeight(id?: number): number {\n let node;\n if (typeof id !== \"undefined\") {\n node = this.m_nodes[id];\n } else {\n node = this.m_root;\n }\n\n // if (_ASSERT) console.assert(0 <= id && id < this.m_nodeCapacity);\n\n if (node.isLeaf()) {\n return 0;\n }\n\n const height1 = this.computeHeight(node.child1.id);\n const height2 = this.computeHeight(node.child2.id);\n return 1 + math_max(height1, height2);\n }\n\n validateStructure(node: TreeNode): void {\n if (node == null) {\n return;\n }\n\n if (node === this.m_root) {\n if (_ASSERT) console.assert(node.parent == null);\n }\n\n const child1 = node.child1;\n const child2 = node.child2;\n\n if (node.isLeaf()) {\n if (_ASSERT) console.assert(child1 == null);\n if (_ASSERT) console.assert(child2 == null);\n if (_ASSERT) console.assert(node.height === 0);\n return;\n }\n\n // if (_ASSERT) console.assert(0 <= child1 && child1 < this.m_nodeCapacity);\n // if (_ASSERT) console.assert(0 <= child2 && child2 < this.m_nodeCapacity);\n\n if (_ASSERT) console.assert(child1.parent === node);\n if (_ASSERT) console.assert(child2.parent === node);\n\n this.validateStructure(child1);\n this.validateStructure(child2);\n }\n\n validateMetrics(node: TreeNode): void {\n if (node == null) {\n return;\n }\n\n const child1 = node.child1;\n const child2 = node.child2;\n\n if (node.isLeaf()) {\n if (_ASSERT) console.assert(child1 == null);\n if (_ASSERT) console.assert(child2 == null);\n if (_ASSERT) console.assert(node.height === 0);\n return;\n }\n\n // if (_ASSERT) console.assert(0 <= child1 && child1 < this.m_nodeCapacity);\n // if (_ASSERT) console.assert(0 <= child2 && child2 < this.m_nodeCapacity);\n\n const height1 = child1.height;\n const height2 = child2.height;\n const height = 1 + math_max(height1, height2);\n if (_ASSERT) console.assert(node.height === height);\n\n const aabb = new AABB();\n aabb.combine(child1.aabb, child2.aabb);\n\n if (_ASSERT) console.assert(AABB.areEqual(aabb, node.aabb));\n\n this.validateMetrics(child1);\n this.validateMetrics(child2);\n }\n\n /**\n * Validate this tree. For testing.\n */\n validate(): void {\n if (!_ASSERT) return;\n this.validateStructure(this.m_root);\n this.validateMetrics(this.m_root);\n\n console.assert(this.getHeight() === this.computeHeight());\n }\n\n /**\n * Get the maximum balance of an node in the tree. The balance is the difference\n * in height of the two children of a node.\n */\n getMaxBalance(): number {\n let maxBalance = 0;\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height <= 1) {\n continue;\n }\n\n if (_ASSERT) console.assert(!node.isLeaf());\n\n const balance = math_abs(node.child2.height - node.child1.height);\n maxBalance = math_max(maxBalance, balance);\n }\n this.iteratorPool.release(it);\n\n return maxBalance;\n }\n\n /**\n * Build an optimal tree. Very expensive. For testing.\n */\n rebuildBottomUp(): void {\n const nodes = [];\n let count = 0;\n\n // Build array of leaves. Free the rest.\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height < 0) {\n // free node in pool\n continue;\n }\n\n if (node.isLeaf()) {\n node.parent = null;\n nodes[count] = node;\n ++count;\n } else {\n this.freeNode(node);\n }\n }\n this.iteratorPool.release(it);\n\n while (count > 1) {\n let minCost = Infinity;\n let iMin = -1;\n let jMin = -1;\n for (let i = 0; i < count; ++i) {\n const aabbi = nodes[i].aabb;\n for (let j = i + 1; j < count; ++j) {\n const aabbj = nodes[j].aabb;\n const cost = AABB.combinedPerimeter(aabbi, aabbj);\n if (cost < minCost) {\n iMin = i;\n jMin = j;\n minCost = cost;\n }\n }\n }\n\n const child1 = nodes[iMin];\n const child2 = nodes[jMin];\n\n const parent = this.allocateNode();\n parent.child1 = child1;\n parent.child2 = child2;\n parent.height = 1 + math_max(child1.height, child2.height);\n parent.aabb.combine(child1.aabb, child2.aabb);\n parent.parent = null;\n\n child1.parent = parent;\n child2.parent = parent;\n\n nodes[jMin] = nodes[count - 1];\n nodes[iMin] = parent;\n --count;\n }\n\n this.m_root = nodes[0];\n\n if (_ASSERT) this.validate();\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n // Build array of leaves. Free the rest.\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n const aabb = node.aabb;\n aabb.lowerBound.x -= newOrigin.x;\n aabb.lowerBound.y -= newOrigin.y;\n aabb.upperBound.x -= newOrigin.x;\n aabb.upperBound.y -= newOrigin.y;\n }\n this.iteratorPool.release(it);\n }\n\n /**\n * Query an AABB for overlapping proxies. The callback class is called for each\n * proxy that overlaps the supplied AABB.\n */\n query(aabb: AABBValue, queryCallback: DynamicTreeQueryCallback): void {\n if (_ASSERT) console.assert(typeof queryCallback === \"function\");\n const stack = this.stackPool.allocate();\n\n stack.push(this.m_root);\n while (stack.length > 0) {\n const node = stack.pop();\n if (node == null) {\n continue;\n }\n\n if (AABB.testOverlap(node.aabb, aabb)) {\n if (node.isLeaf()) {\n const proceed = queryCallback(node.id);\n if (proceed === false) {\n return;\n }\n } else {\n stack.push(node.child1);\n stack.push(node.child2);\n }\n }\n }\n\n this.stackPool.release(stack);\n }\n\n /**\n * Ray-cast against the proxies in the tree. This relies on the callback to\n * perform a exact ray-cast in the case were the proxy contains a shape. The\n * callback also performs the any collision filtering. This has performance\n * roughly equal to k * log(n), where k is the number of collisions and n is the\n * number of proxies in the tree.\n *\n * @param input The ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n * @param rayCastCallback A function that is called for each proxy that is hit by the ray. If the return value is a positive number it will update the maxFraction of the ray cast input, and if it is zero it will terminate they ray cast.\n */\n rayCast(input: RayCastInput, rayCastCallback: RayCastCallback): void {\n // TODO: GC\n if (_ASSERT) console.assert(typeof rayCastCallback === \"function\");\n const p1 = input.p1;\n const p2 = input.p2;\n const r = Vec2.sub(p2, p1);\n if (_ASSERT) console.assert(r.lengthSquared() > 0.0);\n r.normalize();\n\n // v is perpendicular to the segment.\n const v = Vec2.crossNumVec2(1.0, r);\n const abs_v = Vec2.abs(v);\n\n // Separating axis for segment (Gino, p80).\n // |dot(v, p1 - c)| > dot(|v|, h)\n\n let maxFraction = input.maxFraction;\n\n // Build a bounding box for the segment.\n const segmentAABB = new AABB();\n let t = Vec2.combine((1 - maxFraction), p1, maxFraction, p2);\n segmentAABB.combinePoints(p1, t);\n\n const stack = this.stackPool.allocate();\n const subInput = this.inputPool.allocate();\n\n stack.push(this.m_root);\n while (stack.length > 0) {\n const node = stack.pop();\n if (node == null) {\n continue;\n }\n\n if (AABB.testOverlap(node.aabb, segmentAABB) === false) {\n continue;\n }\n\n // Separating axis for segment (Gino, p80).\n // |dot(v, p1 - c)| > dot(|v|, h)\n const c = node.aabb.getCenter();\n const h = node.aabb.getExtents();\n const separation = math_abs(Vec2.dot(v, Vec2.sub(p1, c))) - Vec2.dot(abs_v, h);\n if (separation > 0.0) {\n continue;\n }\n\n if (node.isLeaf()) {\n subInput.p1 = Vec2.clone(input.p1);\n subInput.p2 = Vec2.clone(input.p2);\n subInput.maxFraction = maxFraction;\n\n const value = rayCastCallback(subInput, node.id);\n\n if (value === 0.0) {\n // The client has terminated the ray cast.\n break;\n } else if (value > 0.0) {\n // update segment bounding box.\n maxFraction = value;\n t = Vec2.combine((1 - maxFraction), p1, maxFraction, p2);\n segmentAABB.combinePoints(p1, t);\n }\n } else {\n stack.push(node.child1);\n stack.push(node.child2);\n }\n }\n this.stackPool.release(stack);\n this.inputPool.release(subInput);\n }\n\n private inputPool: Pool = new Pool({\n create(): RayCastInput {\n // tslint:disable-next-line:no-object-literal-type-assertion\n return {} as RayCastInput;\n },\n release(stack: RayCastInput): void {\n }\n });\n\n private stackPool: Pool>> = new Pool>>({\n create(): Array> {\n return [];\n },\n release(stack: Array>): void {\n stack.length = 0;\n }\n });\n\n private iteratorPool: Pool> = new Pool>({\n create(): Iterator {\n return new Iterator();\n },\n release(iterator: Iterator): void {\n iterator.close();\n }\n });\n\n}\n\n/** @internal */\nclass Iterator {\n parents: Array> = [];\n states: number[] = [];\n preorder(root: TreeNode): Iterator {\n this.parents.length = 0;\n this.parents.push(root);\n this.states.length = 0;\n this.states.push(0);\n return this;\n }\n next(): TreeNode {\n while (this.parents.length > 0) {\n const i = this.parents.length - 1;\n const node = this.parents[i];\n if (this.states[i] === 0) {\n this.states[i] = 1;\n return node;\n }\n if (this.states[i] === 1) {\n this.states[i] = 2;\n if (node.child1) {\n this.parents.push(node.child1);\n this.states.push(1);\n return node.child1;\n }\n }\n if (this.states[i] === 2) {\n this.states[i] = 3;\n if (node.child2) {\n this.parents.push(node.child2);\n this.states.push(1);\n return node.child2;\n }\n }\n this.parents.pop();\n this.states.pop();\n }\n }\n close(): void {\n this.parents.length = 0;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2Value } from \"../common/Vec2\";\nimport { AABB, AABBValue, RayCastCallback, RayCastInput } from \"./AABB\";\nimport { DynamicTree, DynamicTreeQueryCallback } from \"./DynamicTree\";\nimport { FixtureProxy } from \"../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/**\n * The broad-phase wraps and extends a dynamic-tree to keep track of moved\n * objects and query them on update.\n */\nexport class BroadPhase {\n m_tree: DynamicTree = new DynamicTree();\n m_moveBuffer: number[] = [];\n\n m_callback: (userDataA: any, userDataB: any) => void;\n m_queryProxyId: number;\n\n /**\n * Get user data from a proxy. Returns null if the id is invalid.\n */\n getUserData(proxyId: number): FixtureProxy {\n return this.m_tree.getUserData(proxyId);\n }\n\n /**\n * Test overlap of fat AABBs.\n */\n testOverlap(proxyIdA: number, proxyIdB: number): boolean {\n const aabbA = this.m_tree.getFatAABB(proxyIdA);\n const aabbB = this.m_tree.getFatAABB(proxyIdB);\n return AABB.testOverlap(aabbA, aabbB);\n }\n\n /**\n * Get the fat AABB for a proxy.\n */\n getFatAABB(proxyId: number): AABB {\n return this.m_tree.getFatAABB(proxyId);\n }\n\n /**\n * Get the number of proxies.\n */\n getProxyCount(): number {\n return this.m_moveBuffer.length;\n }\n\n /**\n * Get the height of the embedded tree.\n */\n getTreeHeight(): number {\n return this.m_tree.getHeight();\n }\n\n /**\n * Get the balance (integer) of the embedded tree.\n */\n getTreeBalance(): number {\n return this.m_tree.getMaxBalance();\n }\n\n /**\n * Get the quality metric of the embedded tree.\n */\n getTreeQuality(): number {\n return this.m_tree.getAreaRatio();\n }\n\n /**\n * Query an AABB for overlapping proxies. The callback class is called for each\n * proxy that overlaps the supplied AABB.\n */\n query = (aabb: AABBValue, queryCallback: DynamicTreeQueryCallback): void => {\n this.m_tree.query(aabb, queryCallback);\n };\n\n /**\n * Ray-cast against the proxies in the tree. This relies on the callback to\n * perform a exact ray-cast in the case were the proxy contains a shape. The\n * callback also performs the any collision filtering. This has performance\n * roughly equal to k * log(n), where k is the number of collisions and n is the\n * number of proxies in the tree.\n *\n * @param input The ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n * @param rayCastCallback A function that is called for each proxy that is hit by the ray. If the return value is a positive number it will update the maxFraction of the ray cast input, and if it is zero it will terminate they ray cast.\n */\n rayCast(input: RayCastInput, rayCastCallback: RayCastCallback): void {\n this.m_tree.rayCast(input, rayCastCallback);\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_tree.shiftOrigin(newOrigin);\n }\n\n /**\n * Create a proxy with an initial AABB. Pairs are not reported until UpdatePairs\n * is called.\n */\n createProxy(aabb: AABBValue, userData: FixtureProxy): number {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n const proxyId = this.m_tree.createProxy(aabb, userData);\n this.bufferMove(proxyId);\n return proxyId;\n }\n\n /**\n * Destroy a proxy. It is up to the client to remove any pairs.\n */\n destroyProxy(proxyId: number): void {\n this.unbufferMove(proxyId);\n this.m_tree.destroyProxy(proxyId);\n }\n\n /**\n * Call moveProxy as many times as you like, then when you are done call\n * UpdatePairs to finalized the proxy pairs (for your time step).\n */\n moveProxy(proxyId: number, aabb: AABB, displacement: Vec2Value): void {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n const changed = this.m_tree.moveProxy(proxyId, aabb, displacement);\n if (changed) {\n this.bufferMove(proxyId);\n }\n }\n\n /**\n * Call to trigger a re-processing of it's pairs on the next call to\n * UpdatePairs.\n */\n touchProxy(proxyId: number): void {\n this.bufferMove(proxyId);\n }\n\n bufferMove(proxyId: number): void {\n this.m_moveBuffer.push(proxyId);\n }\n\n unbufferMove(proxyId: number): void {\n for (let i = 0; i < this.m_moveBuffer.length; ++i) {\n if (this.m_moveBuffer[i] === proxyId) {\n this.m_moveBuffer[i] = null;\n }\n }\n }\n\n /**\n * Update the pairs. This results in pair callbacks. This can only add pairs.\n */\n updatePairs(addPairCallback: (userDataA: FixtureProxy, userDataB: FixtureProxy) => void): void {\n if (_ASSERT) console.assert(typeof addPairCallback === \"function\");\n this.m_callback = addPairCallback;\n\n // Perform tree queries for all moving proxies.\n while (this.m_moveBuffer.length > 0) {\n this.m_queryProxyId = this.m_moveBuffer.pop();\n if (this.m_queryProxyId === null) {\n continue;\n }\n\n // We have to query the tree with the fat AABB so that\n // we don't fail to create a pair that may touch later.\n const fatAABB = this.m_tree.getFatAABB(this.m_queryProxyId);\n\n // Query tree, create pairs and add them pair buffer.\n this.m_tree.query(fatAABB, this.queryCallback);\n }\n\n // Try to keep the tree balanced.\n // this.m_tree.rebalance(4);\n }\n\n queryCallback = (proxyId: number): boolean => {\n // A proxy cannot form a pair with itself.\n if (proxyId === this.m_queryProxyId) {\n return true;\n }\n\n const proxyIdA = math_min(proxyId, this.m_queryProxyId);\n const proxyIdB = math_max(proxyId, this.m_queryProxyId);\n\n // TODO: Skip any duplicate pairs.\n\n const userDataA = this.m_tree.getUserData(proxyIdA);\n const userDataB = this.m_tree.getUserData(proxyIdB);\n\n // Send the pairs back to the client.\n this.m_callback(userDataA, userDataB);\n\n return true;\n };\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n/** @internal */ const math_sqrt = Math.sqrt;\n\n\nimport { RotValue } from \"./Rot\";\nimport { TransformValue } from \"./Transform\";\nimport { Vec2Value } from \"./Vec2\";\nimport { Vec3Value } from \"./Vec3\";\n\nexport function vec2(x: number, y: number): Vec2Value {\n return { x, y };\n}\n\nexport function vec3(x: number, y: number, z: number): Vec3Value {\n return { x, y, z };\n}\n\nexport function rotation(angle: number): RotValue {\n return { s: math_sin(angle), c: math_cos(angle) };\n}\n\nexport function setVec2(out: Vec2Value, x: number, y: number): Vec2Value {\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function copyVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = w.x;\n out.y = w.y;\n return out;\n}\n\nexport function zeroVec2(out: Vec2Value): Vec2Value {\n out.x = 0;\n out.y = 0;\n return out;\n}\n\nexport function negVec2(out: Vec2Value): Vec2Value {\n out.x = -out.x;\n out.y = -out.y;\n return out;\n}\n\nexport function plusVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x += w.x;\n out.y += w.y;\n return out;\n}\n\nexport function addVec2(out: Vec2Value, v: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = v.x + w.x;\n out.y = v.x + w.y;\n return out;\n}\n\nexport function minusVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x -= w.x;\n out.y -= w.y;\n return out;\n}\n\nexport function subVec2(out: Vec2Value, v: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = v.x - w.x;\n out.y = v.y - w.y;\n return out;\n}\n\nexport function mulVec2(out: Vec2Value, m: number): Vec2Value {\n out.x *= m;\n out.y *= m;\n return out;\n}\n\nexport function scaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x = m * w.x;\n out.y = m * w.y;\n return out;\n}\n\nexport function plusScaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x += m * w.x;\n out.y += m * w.y;\n return out;\n}\n\nexport function minusScaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x -= m * w.x;\n out.y -= m * w.y;\n return out;\n}\n\nexport function combine2Vec2(out: Vec2Value, am: number, a: Vec2Value, bm: number, b: Vec2Value): Vec2Value {\n out.x = am * a.x + bm * b.x;\n out.y = am * a.y + bm * b.y;\n return out;\n}\n\nexport function combine3Vec2(out: Vec2Value, am: number, a: Vec2Value, bm: number, b: Vec2Value, cm: number, c: Vec2Value): Vec2Value {\n out.x = am * a.x + bm * b.x + cm * c.x;\n out.y = am * a.y + bm * b.y + cm * c.y;\n return out;\n}\n\nexport function normalizeVec2Length(out: Vec2Value): number {\n const length = math_sqrt(out.x * out.x + out.y * out.y);\n if (length !== 0) {\n const invLength = 1 / length;\n out.x *= invLength;\n out.y *= invLength;\n }\n return length;\n}\n\nexport function normalizeVec2(out: Vec2Value): Vec2Value {\n const length = math_sqrt(out.x * out.x + out.y * out.y);\n if (length > 0) {\n const invLength = 1 / length;\n out.x *= invLength;\n out.y *= invLength;\n }\n return out;\n}\n\nexport function crossVec2Num(out: Vec2Value, v: Vec2Value, w: number): Vec2Value {\n const x = w * v.y;\n const y = -w * v.x;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function crossNumVec2(out: Vec2Value, w: number, v: Vec2Value): Vec2Value {\n const x = -w * v.y;\n const y = w * v.x;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function crossVec2Vec2(a: Vec2Value, b: Vec2Value): number {\n return a.x * b.y - a.y * b.x;\n}\n\nexport function dotVec2(a: Vec2Value, b: Vec2Value): number {\n return a.x * b.x + a.y * b.y;\n}\n\nexport function lengthVec2(a: Vec2Value): number {\n return math_sqrt(a.x * a.x + a.y * a.y);\n}\n\nexport function lengthSqrVec2(a: Vec2Value): number {\n return a.x * a.x + a.y * a.y;\n}\n\nexport function distVec2(a: Vec2Value, b: Vec2Value): number {\n const dx = a.x - b.x;\n const dy = a.y - b.y;\n return math_sqrt(dx * dx + dy * dy);\n}\n\nexport function distSqrVec2(a: Vec2Value, b: Vec2Value): number {\n const dx = a.x - b.x;\n const dy = a.y - b.y;\n return dx * dx + dy * dy;\n}\n\nexport function dotVec3(v: Vec3Value, w: Vec3Value): number {\n return v.x * w.x + v.y * w.y + v.z * w.z;\n}\n\nexport function setRotAngle(out: RotValue, a: number): RotValue {\n out.c = math_cos(a);\n out.s = math_sin(a);\n return out;\n}\n\nexport function rotVec2(out: Vec2Value, q: RotValue, v: Vec2Value): Vec2Value {\n out.x = q.c * v.x - q.s * v.y;\n out.y = q.s * v.x + q.c * v.y;\n return out;\n}\n\nexport function derotVec2(out: Vec2Value, q: RotValue, v: Vec2Value): Vec2Value {\n const x = q.c * v.x + q.s * v.y;\n const y = -q.s * v.x + q.c * v.y;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function rerotVec2(out: Vec2Value, before: RotValue, after: RotValue, v: Vec2Value): Vec2Value {\n const x0 = before.c * v.x + before.s * v.y;\n const y0 = -before.s * v.x + before.c * v.y;\n const x = after.c * x0 - after.s * y0;\n const y = after.s * x0 + after.c * y0;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function transform(x: number, y: number, a: number): TransformValue {\n return { p: vec2(x, y), q: rotation(a) };\n}\n\nexport function copyTransform(out: TransformValue, transform: TransformValue): TransformValue {\n out.p.x = transform.p.x;\n out.p.y = transform.p.y;\n out.q.s = transform.q.s;\n out.q.c = transform.q.c;\n return out;\n}\n\nexport function transformVec2(out: Vec2Value, xf: TransformValue, v: Vec2Value): Vec2Value {\n const x = xf.q.c * v.x - xf.q.s * v.y + xf.p.x;\n const y = xf.q.s * v.x + xf.q.c * v.y + xf.p.y;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function detransformVec2(out: Vec2Value, xf: TransformValue, v: Vec2Value): Vec2Value {\n const px = v.x - xf.p.x;\n const py = v.y - xf.p.y;\n const x = (xf.q.c * px + xf.q.s * py);\n const y = (-xf.q.s * px + xf.q.c * py);\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function retransformVec2(out: Vec2Value, from: TransformValue, to: TransformValue, v: Vec2Value): Vec2Value {\n const x0 = from.q.c * v.x - from.q.s * v.y + from.p.x;\n const y0 = from.q.s * v.x + from.q.c * v.y + from.p.y;\n const px = x0 - to.p.x;\n const py = y0 - to.p.y;\n const x = to.q.c * px + to.q.s * py;\n const y = -to.q.s * px + to.q.c * py;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function detransformTransform(out: TransformValue, a: TransformValue, b: TransformValue): TransformValue {\n const c = a.q.c * b.q.c + a.q.s * b.q.s;\n const s = a.q.c * b.q.s - a.q.s * b.q.c;\n const x = a.q.c * (b.p.x - a.p.x) + a.q.s * (b.p.y - a.p.y);\n const y = -a.q.s * (b.p.x - a.p.x) + a.q.c * (b.p.y - a.p.y);\n out.q.c = c;\n out.q.s = s;\n out.p.x = x;\n out.p.y = y;\n return out;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n/** @internal */ const math_atan2 = Math.atan2;\n\nexport interface RotValue {\n /** sin(angle) */\n s: number;\n /** cos(angle) */\n c: number;\n}\n\ndeclare module \"./Rot\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(angle: number): Rot;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(obj: RotValue): Rot;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(): Rot;\n}\n\n/** Rotation */\n// @ts-expect-error\nexport class Rot {\n /** sin(angle) */\n s: number;\n /** cos(angle) */\n c: number;\n\n /** Initialize from an angle in radians. */\n constructor(angle?: number | RotValue) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Rot)) {\n return new Rot(angle);\n }\n if (typeof angle === \"number\") {\n this.setAngle(angle);\n } else if (typeof angle === \"object\") {\n this.setRot(angle);\n } else {\n this.setIdentity();\n }\n }\n\n /** @hidden */\n static neo(angle: number): Rot {\n const obj = Object.create(Rot.prototype);\n obj.setAngle(angle);\n return obj;\n }\n\n static clone(rot: RotValue): Rot {\n if (_ASSERT) Rot.assert(rot);\n const obj = Object.create(Rot.prototype);\n obj.s = rot.s;\n obj.c = rot.c;\n return obj;\n }\n\n static identity(): Rot {\n const obj = Object.create(Rot.prototype);\n obj.s = 0.0;\n obj.c = 1.0;\n return obj;\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.s) && Number.isFinite(obj.c);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Rot.isValid(o), \"Invalid Rot!\", o);\n }\n\n /** Set to the identity rotation. */\n setIdentity(): void {\n this.s = 0.0;\n this.c = 1.0;\n }\n\n set(angle: number | RotValue): void {\n if (typeof angle === \"object\") {\n if (_ASSERT) Rot.assert(angle);\n this.s = angle.s;\n this.c = angle.c;\n\n } else {\n if (_ASSERT) console.assert(Number.isFinite(angle));\n // TODO_ERIN optimize\n this.s = math_sin(angle);\n this.c = math_cos(angle);\n }\n }\n\n setRot(angle: RotValue): void {\n if (_ASSERT) Rot.assert(angle);\n this.s = angle.s;\n this.c = angle.c;\n }\n\n /** Set using an angle in radians. */\n setAngle(angle: number): void {\n if (_ASSERT) console.assert(Number.isFinite(angle));\n // TODO_ERIN optimize\n this.s = math_sin(angle);\n this.c = math_cos(angle);\n }\n\n /** Get the angle in radians. */\n getAngle(): number {\n return math_atan2(this.s, this.c);\n }\n\n /** Get the x-axis. */\n getXAxis(): Vec2 {\n return Vec2.neo(this.c, this.s);\n }\n\n /** Get the y-axis. */\n getYAxis(): Vec2 {\n return Vec2.neo(-this.s, this.c);\n }\n\n /** Multiply two rotations: q * r */\n static mul(rot: RotValue, m: RotValue): Rot;\n /** Rotate a vector */\n static mul(rot: RotValue, m: Vec2Value): Vec2;\n static mul(rot, m) {\n if (_ASSERT) Rot.assert(rot);\n if (\"c\" in m && \"s\" in m) {\n if (_ASSERT) Rot.assert(m);\n // [qc -qs] * [rc -rs] = [qc*rc-qs*rs -qc*rs-qs*rc]\n // [qs qc] [rs rc] [qs*rc+qc*rs -qs*rs+qc*rc]\n // s = qs * rc + qc * rs\n // c = qc * rc - qs * rs\n const qr = Rot.identity();\n qr.s = rot.s * m.c + rot.c * m.s;\n qr.c = rot.c * m.c - rot.s * m.s;\n return qr;\n\n } else if (\"x\" in m && \"y\" in m) {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x - rot.s * m.y, rot.s * m.x + rot.c * m.y);\n }\n }\n\n /** Multiply two rotations: q * r */\n static mulRot(rot: RotValue, m: RotValue): Rot {\n if (_ASSERT) Rot.assert(rot);\n if (_ASSERT) Rot.assert(m);\n // [qc -qs] * [rc -rs] = [qc*rc-qs*rs -qc*rs-qs*rc]\n // [qs qc] [rs rc] [qs*rc+qc*rs -qs*rs+qc*rc]\n // s = qs * rc + qc * rs\n // c = qc * rc - qs * rs\n const qr = Rot.identity();\n qr.s = rot.s * m.c + rot.c * m.s;\n qr.c = rot.c * m.c - rot.s * m.s;\n return qr;\n }\n\n /** Rotate a vector */\n static mulVec2(rot: RotValue, m: Vec2Value): Vec2 {\n if (_ASSERT) Rot.assert(rot);\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x - rot.s * m.y, rot.s * m.x + rot.c * m.y);\n }\n\n static mulSub(rot: RotValue, v: Vec2Value, w: Vec2Value): Vec2 {\n const x = rot.c * (v.x - w.x) - rot.s * (v.y - w.y);\n const y = rot.s * (v.x - w.x) + rot.c * (v.y - w.y);\n return Vec2.neo(x, y);\n }\n\n /** Transpose multiply two rotations: qT * r */\n static mulT(rot: RotValue, m: RotValue): Rot;\n /** Inverse rotate a vector */\n static mulT(rot: RotValue, m: Vec2Value): Vec2;\n static mulT(rot, m) {\n if (\"c\" in m && \"s\" in m) {\n if (_ASSERT) Rot.assert(m);\n // [ qc qs] * [rc -rs] = [qc*rc+qs*rs -qc*rs+qs*rc]\n // [-qs qc] [rs rc] [-qs*rc+qc*rs qs*rs+qc*rc]\n // s = qc * rs - qs * rc\n // c = qc * rc + qs * rs\n const qr = Rot.identity();\n qr.s = rot.c * m.s - rot.s * m.c;\n qr.c = rot.c * m.c + rot.s * m.s;\n return qr;\n\n } else if (\"x\" in m && \"y\" in m) {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x + rot.s * m.y, -rot.s * m.x + rot.c * m.y);\n }\n }\n\n /** Transpose multiply two rotations: qT * r */\n static mulTRot(rot: RotValue, m: RotValue): Rot {\n if (_ASSERT) Rot.assert(m);\n // [ qc qs] * [rc -rs] = [qc*rc+qs*rs -qc*rs+qs*rc]\n // [-qs qc] [rs rc] [-qs*rc+qc*rs qs*rs+qc*rc]\n // s = qc * rs - qs * rc\n // c = qc * rc + qs * rs\n const qr = Rot.identity();\n qr.s = rot.c * m.s - rot.s * m.c;\n qr.c = rot.c * m.c + rot.s * m.s;\n return qr;\n }\n\n /** Inverse rotate a vector */\n static mulTVec2(rot: RotValue, m: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x + rot.s * m.y, -rot.s * m.x + rot.c * m.y);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"./Matrix\";\nimport { mod } from \"./Math\";\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { TransformValue } from \"./Transform\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_atan2 = Math.atan2;\n/** @internal */ const math_PI = Math.PI;\n\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n\n/**\n * This describes the motion of a body/shape for TOI computation. Shapes are\n * defined with respect to the body origin, which may not coincide with the\n * center of mass. However, to support dynamics we must interpolate the center\n * of mass position.\n */\nexport class Sweep {\n /** Local center of mass position */\n localCenter = Vec2.zero();\n\n /** World center position */\n c = Vec2.zero();\n\n /** World angle */\n a = 0;\n\n /** Fraction of the current time step in the range [0,1], c0 and a0 are c and a at alpha0. */\n alpha0 = 0;\n\n c0 = Vec2.zero();\n a0 = 0;\n\n /** @internal */\n recycle() {\n matrix.zeroVec2(this.localCenter);\n matrix.zeroVec2(this.c);\n this.a = 0;\n this.alpha0 = 0;\n matrix.zeroVec2(this.c0);\n this.a0 = 0;\n }\n\n setTransform(xf: TransformValue): void {\n matrix.transformVec2(temp, xf, this.localCenter);\n matrix.copyVec2(this.c, temp);\n matrix.copyVec2(this.c0, temp);\n\n this.a = this.a0 = math_atan2(xf.q.s, xf.q.c);\n }\n\n setLocalCenter(localCenter: Vec2Value, xf: TransformValue): void {\n matrix.copyVec2(this.localCenter, localCenter);\n\n matrix.transformVec2(temp, xf, this.localCenter);\n matrix.copyVec2(this.c, temp);\n matrix.copyVec2(this.c0, temp);\n }\n\n /**\n * Get the interpolated transform at a specific time.\n *\n * @param xf\n * @param beta A factor in [0,1], where 0 indicates alpha0\n */\n getTransform(xf: TransformValue, beta: number = 0): void {\n matrix.setRotAngle(xf.q, (1.0 - beta) * this.a0 + beta * this.a);\n matrix.combine2Vec2(xf.p, (1.0 - beta), this.c0, beta, this.c);\n\n // shift to origin\n matrix.minusVec2(xf.p, matrix.rotVec2(temp, xf.q, this.localCenter));\n }\n\n /**\n * Advance the sweep forward, yielding a new initial state.\n *\n * @param alpha The new initial time\n */\n advance(alpha: number): void {\n if (_ASSERT) console.assert(this.alpha0 < 1.0);\n const beta = (alpha - this.alpha0) / (1.0 - this.alpha0);\n matrix.combine2Vec2(this.c0, beta, this.c, 1 - beta, this.c0);\n this.a0 = beta * this.a + (1 - beta) * this.a0;\n this.alpha0 = alpha;\n }\n\n forward(): void {\n this.a0 = this.a;\n matrix.copyVec2(this.c0, this.c);\n }\n\n /**\n * normalize the angles in radians to be between -pi and pi.\n */\n normalize(): void {\n const a0 = mod(this.a0, -math_PI, +math_PI);\n this.a -= this.a0 - a0;\n this.a0 = a0;\n }\n\n set(that: Sweep): void {\n matrix.copyVec2(this.localCenter, that.localCenter);\n matrix.copyVec2(this.c, that.c);\n this.a = that.a;\n this.alpha0 = that.alpha0;\n matrix.copyVec2(this.c0, that.c0);\n this.a0 = that.a0;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { Rot, RotValue } from \"./Rot\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\nexport type TransformValue = {\n p: Vec2Value;\n q: RotValue;\n};\n\ndeclare module \"./Transform\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Transform(position?: Vec2Value, rotation?: number): Transform;\n}\n\n/**\n * A transform contains translation and rotation. It is used to represent the\n * position and orientation of rigid frames. Initialize using a position vector\n * and a rotation.\n */\n// @ts-expect-error\nexport class Transform {\n /** position */\n p: Vec2;\n\n /** rotation */\n q: Rot;\n\n constructor(position?: Vec2Value, rotation?: number) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Transform)) {\n return new Transform(position, rotation);\n }\n this.p = Vec2.zero();\n this.q = Rot.identity();\n if (typeof position !== \"undefined\") {\n this.p.setVec2(position);\n }\n if (typeof rotation !== \"undefined\") {\n this.q.setAngle(rotation);\n }\n }\n\n static clone(xf: Transform): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.clone(xf.p);\n obj.q = Rot.clone(xf.q);\n return obj;\n }\n\n /** @hidden */\n static neo(position: Vec2Value, rotation: Rot): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.clone(position);\n obj.q = Rot.clone(rotation);\n return obj;\n }\n\n static identity(): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.zero();\n obj.q = Rot.identity();\n return obj;\n }\n\n /** Set this to the identity transform */\n setIdentity(): void {\n this.p.setZero();\n this.q.setIdentity();\n }\n\n /** Set position and angle */\n set(position: Vec2Value, rotation: number): void;\n /** Copy from another transform */\n set(xf: TransformValue): void;\n set(a: any, b?: any) {\n if (typeof b === \"undefined\") {\n this.p.set(a.p);\n this.q.set(a.q);\n } else {\n this.p.set(a);\n this.q.set(b);\n }\n }\n\n /** Set position and angle */\n setNum(position: Vec2Value, rotation: number) {\n this.p.setVec2(position);\n this.q.setAngle(rotation);\n }\n\n setTransform(xf: TransformValue): void {\n this.p.setVec2(xf.p);\n this.q.setRot(xf.q);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.p) && Rot.isValid(obj.q);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Transform.isValid(o), \"Invalid Transform!\", o);\n }\n\n static mul(a: TransformValue, b: Vec2Value): Vec2;\n static mul(a: TransformValue, b: TransformValue): Transform;\n // static mul(a: Transform, b: Vec2Value[]): Vec2[];\n // static mul(a: Transform, b: Transform[]): Transform[];\n static mul(a, b) {\n if (Array.isArray(b)) {\n // todo: this was used in examples, remove in the future\n if (_ASSERT) Transform.assert(a);\n const arr = [];\n for (let i = 0; i < b.length; i++) {\n arr[i] = Transform.mul(a, b[i]);\n }\n return arr;\n\n } else if (\"x\" in b && \"y\" in b) {\n return Transform.mulVec2(a, b);\n\n } else if (\"p\" in b && \"q\" in b) {\n return Transform.mulXf(a, b);\n }\n }\n\n static mulAll(a: Transform, b: Vec2Value[]): Vec2[];\n static mulAll(a: Transform, b: Transform[]): Transform[];\n static mulAll(a: TransformValue, b) {\n if (_ASSERT) Transform.assert(a);\n const arr = [];\n for (let i = 0; i < b.length; i++) {\n arr[i] = Transform.mul(a, b[i]);\n }\n return arr;\n }\n\n /** @hidden @deprecated */\n static mulFn(a: TransformValue) {\n // todo: this was used in examples, remove in the future\n if (_ASSERT) Transform.assert(a);\n return function(b: Vec2Value): Vec2 {\n return Transform.mul(a, b);\n };\n }\n\n static mulVec2(a: TransformValue, b: Vec2Value): Vec2 {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const x = (a.q.c * b.x - a.q.s * b.y) + a.p.x;\n const y = (a.q.s * b.x + a.q.c * b.y) + a.p.y;\n return Vec2.neo(x, y);\n }\n\n static mulXf(a: TransformValue, b: TransformValue): Transform {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Transform.assert(b);\n // v2 = A.q.Rot(B.q.Rot(v1) + B.p) + A.p\n // = (A.q * B.q).Rot(v1) + A.q.Rot(B.p) + A.p\n const xf = Transform.identity();\n xf.q = Rot.mulRot(a.q, b.q);\n xf.p = Vec2.add(Rot.mulVec2(a.q, b.p), a.p);\n return xf;\n }\n\n static mulT(a: TransformValue, b: Vec2Value): Vec2;\n static mulT(a: TransformValue, b: TransformValue): Transform;\n static mulT(a, b) {\n if (\"x\" in b && \"y\" in b) {\n return Transform.mulTVec2(a, b);\n\n } else if (\"p\" in b && \"q\" in b) {\n return Transform.mulTXf(a, b);\n }\n }\n\n static mulTVec2(a: TransformValue, b: Vec2Value): Vec2 {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const px = b.x - a.p.x;\n const py = b.y - a.p.y;\n const x = (a.q.c * px + a.q.s * py);\n const y = (-a.q.s * px + a.q.c * py);\n return Vec2.neo(x, y);\n }\n\n static mulTXf(a: TransformValue, b: TransformValue): Transform {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Transform.assert(b);\n // v2 = A.q' * (B.q * v1 + B.p - A.p)\n // = A.q' * B.q * v1 + A.q' * (B.p - A.p)\n const xf = Transform.identity();\n xf.q.setRot(Rot.mulTRot(a.q, b.q));\n xf.p.setVec2(Rot.mulTVec2(a.q, Vec2.sub(b.p, a.p)));\n return xf;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2 } from \"../common/Vec2\";\n\nexport class Velocity {\n /** linear */\n v = Vec2.zero();\n\n /** angular */\n w = 0;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { TransformValue } from \"../common/Transform\";\n\n\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n\n\nexport class Position {\n /** location */\n c = Vec2.zero();\n\n /** angle */\n a = 0;\n\n // todo: cache sin/cos\n getTransform(xf: TransformValue, p: Vec2Value): TransformValue {\n // xf.q = rotation(this.a);\n // xf.p = this.c - xf.q * p\n xf.q.c = math_cos(this.a);\n xf.q.s = math_sin(this.a);\n xf.p.x = this.c.x - (xf.q.c * p.x - xf.q.s * p.y);\n xf.p.y = this.c.y - (xf.q.s * p.x + xf.q.c * p.y);\n return xf;\n }\n}\n\nexport function getTransform(xf: TransformValue, p: Vec2Value, c: Vec2Value, a: number): TransformValue {\n // xf.q = rotation(a);\n // xf.p = this.c - xf.q * p\n xf.q.c = math_cos(a);\n xf.q.s = math_sin(a);\n xf.p.x = c.x - (xf.q.c * p.x - xf.q.s * p.y);\n xf.p.y = c.y - (xf.q.s * p.x + xf.q.c * p.y);\n return xf;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { MassData } from \"../dynamics/Body\";\nimport { RayCastOutput, RayCastInput, AABBValue } from \"./AABB\";\nimport { DistanceProxy } from \"./Distance\";\nimport type { Transform, TransformValue } from \"../common/Transform\";\nimport type { Vec2Value } from \"../common/Vec2\";\nimport { Style } from \"../util/Testbed\";\n\n// todo make shape an interface\n\n/**\n * A shape is used for collision detection. You can create a shape however you\n * like. Shapes used for simulation in World are created automatically when a\n * Fixture is created. Shapes may encapsulate one or more child shapes.\n */\nexport abstract class Shape {\n /** @hidden */ m_type: ShapeType;\n\n /**\n * @hidden\n * Radius of a shape. For polygonal shapes this must be b2_polygonRadius.\n * There is no support for making rounded polygons.\n */\n m_radius: number;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n /** @hidden */\n abstract _reset(): void;\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return typeof obj.m_type === \"string\" && typeof obj.m_radius === \"number\";\n }\n\n abstract getRadius(): number;\n\n /**\n * Get the type of this shape. You can use this to down cast to the concrete\n * shape.\n *\n * @return the shape type.\n */\n abstract getType(): ShapeType;\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n abstract _clone(): Shape;\n\n /**\n * Get the number of child primitives.\n */\n abstract getChildCount(): number;\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n abstract testPoint(xf: TransformValue, p: Vec2Value): boolean;\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n abstract rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean;\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n abstract computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void;\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n abstract computeMass(massData: MassData, density?: number): void;\n\n abstract computeDistanceProxy(proxy: DistanceProxy, childIndex: number): void;\n\n}\n\nexport type ShapeType = \"circle\" | \"edge\" | \"polygon\" | \"chain\";\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { options } from \"../util/options\";\nimport { Vec2Value } from \"../common/Vec2\";\nimport { AABB, RayCastInput, RayCastOutput } from \"../collision/AABB\";\nimport { Shape, ShapeType } from \"../collision/Shape\";\nimport { Body, MassData } from \"./Body\";\nimport { BroadPhase } from \"../collision/BroadPhase\";\nimport { TransformValue } from \"../common/Transform\";\nimport { Style } from \"../util/Testbed\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/** @internal */ const synchronize_aabb1 = new AABB();\n/** @internal */ const synchronize_aabb2 = new AABB();\n/** @internal */ const displacement = matrix.vec2(0, 0);\n\n/**\n * A fixture definition is used to create a fixture. This class defines an\n * abstract fixture definition. You can reuse fixture definitions safely.\n */\nexport interface FixtureOpt {\n userData?: unknown;\n /**\n * The friction coefficient, usually in the range [0,1]\n */\n friction?: number;\n /**\n * The restitution (elasticity) usually in the range [0,1]\n */\n restitution?: number;\n /**\n * The density, usually in kg/m^2\n */\n density?: number;\n /**\n * A sensor shape collects contact information but never generates a collision response.\n */\n isSensor?: boolean;\n /**\n * Zero, positive or negative collision group.\n * Fixtures with same positive groupIndex always collide and fixtures with same negative groupIndex never collide.\n */\n filterGroupIndex?: number;\n /**\n * Collision category bit or bits that this fixture belongs to.\n * If groupIndex is zero or not matching, then at least one bit in this fixture categoryBits should match other fixture maskBits and vice versa.\n */\n filterCategoryBits?: number;\n /**\n * Collision category bit or bits that this fixture accept for collision.\n */\n filterMaskBits?: number;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\nexport interface FixtureDef extends FixtureOpt {\n shape: Shape;\n}\n\n/** @internal */ const FixtureDefDefault: FixtureOpt = {\n userData : null,\n friction : 0.2,\n restitution : 0.0,\n density : 0.0,\n isSensor : false,\n\n filterGroupIndex : 0,\n filterCategoryBits : 0x0001,\n filterMaskBits : 0xFFFF\n};\n\n/**\n * This proxy is used internally to connect shape children to the broad-phase.\n */\nexport class FixtureProxy {\n aabb: AABB;\n fixture: Fixture;\n childIndex: number;\n proxyId: number;\n constructor(fixture: Fixture, childIndex: number) {\n this.aabb = new AABB();\n this.fixture = fixture;\n this.childIndex = childIndex;\n // this.proxyId;\n }\n}\n\n/**\n * A fixture is used to attach a shape to a body for collision detection. A\n * fixture inherits its transform from its parent. Fixtures hold additional\n * non-geometric data such as friction, collision filters, etc.\n *\n * To create a new Fixture use {@link Body.createFixture}.\n */\nexport class Fixture {\n /** @internal */ m_body: Body;\n /** @internal */ m_friction: number;\n /** @internal */ m_restitution: number;\n /** @internal */ m_density: number;\n /** @internal */ m_isSensor: boolean;\n /** @internal */ m_filterGroupIndex: number;\n /** @internal */ m_filterCategoryBits: number;\n /** @internal */ m_filterMaskBits: number;\n /** @internal */ m_shape: Shape;\n /** @internal */ m_next: Fixture | null;\n /** @internal */ m_proxies: FixtureProxy[];\n // 0 indicates inactive state, this is not the same as m_proxies.length\n /** @internal */ m_proxyCount: number;\n /** @internal */ m_userData: unknown;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n constructor(body: Body, def: FixtureDef);\n constructor(body: Body, shape: Shape, def?: FixtureOpt);\n constructor(body: Body, shape: Shape, density?: number);\n /** @internal */\n constructor(body: Body, shape?, def?) {\n if (shape.shape) {\n def = shape;\n shape = shape.shape;\n\n } else if (typeof def === \"number\") {\n def = {density : def};\n }\n\n def = options(def, FixtureDefDefault);\n\n this.m_body = body;\n\n this.m_friction = def.friction;\n this.m_restitution = def.restitution;\n this.m_density = def.density;\n this.m_isSensor = def.isSensor;\n\n this.m_filterGroupIndex = def.filterGroupIndex;\n this.m_filterCategoryBits = def.filterCategoryBits;\n this.m_filterMaskBits = def.filterMaskBits;\n\n // TODO validate shape\n this.m_shape = shape; // .clone();\n\n this.m_next = null;\n\n this.m_proxies = [];\n this.m_proxyCount = 0;\n\n // fixture proxies are created here,\n // but they are activate in when a fixture is added to body\n const childCount = this.m_shape.getChildCount();\n for (let i = 0; i < childCount; ++i) {\n this.m_proxies[i] = new FixtureProxy(this, i);\n }\n\n this.m_userData = def.userData;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /** @hidden Re-setup fixture. */\n _reset(): void {\n const body = this.getBody();\n const broadPhase = body.m_world.m_broadPhase;\n this.destroyProxies(broadPhase);\n if (this.m_shape._reset) {\n this.m_shape._reset();\n }\n const childCount = this.m_shape.getChildCount();\n for (let i = 0; i < childCount; ++i) {\n this.m_proxies[i] = new FixtureProxy(this, i);\n }\n this.createProxies(broadPhase, body.m_xf);\n body.resetMassData();\n }\n\n /** @internal */\n _serialize(): object {\n return {\n friction: this.m_friction,\n restitution: this.m_restitution,\n density: this.m_density,\n isSensor: this.m_isSensor,\n\n filterGroupIndex: this.m_filterGroupIndex,\n filterCategoryBits: this.m_filterCategoryBits,\n filterMaskBits: this.m_filterMaskBits,\n\n shape: this.m_shape,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, body: any, restore: any): Fixture {\n const shape = restore(Shape, data.shape);\n const fixture = shape && new Fixture(body, shape, data);\n return fixture;\n }\n\n /**\n * Get the type of the child shape. You can use this to down cast to the\n * concrete shape.\n */\n getType(): ShapeType {\n return this.m_shape.m_type;\n }\n\n /**\n * Get the child shape. You can modify the child shape, however you should not\n * change the number of vertices because this will crash some collision caching\n * mechanisms. Manipulating the shape may lead to non-physical behavior.\n */\n getShape(): Shape {\n return this.m_shape;\n }\n\n /**\n * A sensor shape collects contact information but never generates a collision\n * response.\n */\n isSensor(): boolean {\n return this.m_isSensor;\n }\n\n /**\n * Set if this fixture is a sensor.\n */\n setSensor(sensor: boolean): void {\n if (sensor != this.m_isSensor) {\n this.m_body.setAwake(true);\n this.m_isSensor = sensor;\n }\n }\n\n // /**\n // * Get the contact filtering data.\n // */\n // getFilterData() {\n // return this.m_filter;\n // }\n\n /**\n * Get the user data that was assigned in the fixture definition. Use this to\n * store your application specific data.\n */\n getUserData(): unknown {\n return this.m_userData;\n }\n\n /**\n * Set the user data. Use this to store your application specific data.\n */\n setUserData(data: unknown): void {\n this.m_userData = data;\n }\n\n /**\n * Get the parent body of this fixture. This is null if the fixture is not\n * attached.\n */\n getBody(): Body {\n return this.m_body;\n }\n\n /**\n * Get the next fixture in the parent body's fixture list.\n */\n getNext(): Fixture | null {\n return this.m_next;\n }\n\n /**\n * Get the density of this fixture.\n */\n getDensity(): number {\n return this.m_density;\n }\n\n /**\n * Set the density of this fixture. This will _not_ automatically adjust the\n * mass of the body. You must call Body.resetMassData to update the body's mass.\n */\n setDensity(density: number): void {\n if (_ASSERT) console.assert(Number.isFinite(density) && density >= 0.0);\n this.m_density = density;\n }\n\n /**\n * Get the coefficient of friction, usually in the range [0,1].\n */\n getFriction(): number {\n return this.m_friction;\n }\n\n /**\n * Set the coefficient of friction. This will not change the friction of\n * existing contacts.\n */\n setFriction(friction: number): void {\n this.m_friction = friction;\n }\n\n /**\n * Get the coefficient of restitution.\n */\n getRestitution(): number {\n return this.m_restitution;\n }\n\n /**\n * Set the coefficient of restitution. This will not change the restitution of\n * existing contacts.\n */\n setRestitution(restitution: number): void {\n this.m_restitution = restitution;\n }\n\n /**\n * Test a point in world coordinates for containment in this fixture.\n */\n testPoint(p: Vec2Value): boolean {\n return this.m_shape.testPoint(this.m_body.getTransform(), p);\n }\n\n /**\n * Cast a ray against this shape.\n */\n rayCast(output: RayCastOutput, input: RayCastInput, childIndex: number): boolean {\n return this.m_shape.rayCast(output, input, this.m_body.getTransform(), childIndex);\n }\n\n /**\n * Get the mass data for this fixture. The mass data is based on the density and\n * the shape. The rotational inertia is about the shape's origin. This operation\n * may be expensive.\n */\n getMassData(massData: MassData): void {\n this.m_shape.computeMass(massData, this.m_density);\n }\n\n /**\n * Get the fixture's AABB. This AABB may be enlarge and/or stale. If you need a\n * more accurate AABB, compute it using the shape and the body transform.\n */\n getAABB(childIndex: number): AABB {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_proxies.length);\n return this.m_proxies[childIndex].aabb;\n }\n\n /**\n * These support body activation/deactivation.\n */\n createProxies(broadPhase: BroadPhase, xf: TransformValue): void {\n if (_ASSERT) console.assert(this.m_proxyCount == 0);\n\n // Create proxies in the broad-phase.\n this.m_proxyCount = this.m_shape.getChildCount();\n\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n this.m_shape.computeAABB(proxy.aabb, xf, i);\n proxy.proxyId = broadPhase.createProxy(proxy.aabb, proxy);\n }\n }\n\n destroyProxies(broadPhase: BroadPhase): void {\n // Destroy proxies in the broad-phase.\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n broadPhase.destroyProxy(proxy.proxyId);\n proxy.proxyId = null;\n }\n\n this.m_proxyCount = 0;\n }\n\n /**\n * Updates this fixture proxy in broad-phase (with combined AABB of current and\n * next transformation).\n */\n synchronize(broadPhase: BroadPhase, xf1: TransformValue, xf2: TransformValue): void {\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n // Compute an AABB that covers the swept shape (may miss some rotation\n // effect).\n this.m_shape.computeAABB(synchronize_aabb1, xf1, proxy.childIndex);\n this.m_shape.computeAABB(synchronize_aabb2, xf2, proxy.childIndex);\n\n proxy.aabb.combine(synchronize_aabb1, synchronize_aabb2);\n\n matrix.subVec2(displacement, xf2.p, xf1.p);\n\n broadPhase.moveProxy(proxy.proxyId, proxy.aabb, displacement);\n }\n }\n\n /**\n * Set the contact filtering data. This will not update contacts until the next\n * time step when either parent body is active and awake. This automatically\n * calls refilter.\n */\n setFilterData(filter: { groupIndex: number, categoryBits: number, maskBits: number }): void {\n this.m_filterGroupIndex = filter.groupIndex;\n this.m_filterCategoryBits = filter.categoryBits;\n this.m_filterMaskBits = filter.maskBits;\n this.refilter();\n }\n\n getFilterGroupIndex(): number {\n return this.m_filterGroupIndex;\n }\n\n setFilterGroupIndex(groupIndex: number): void {\n this.m_filterGroupIndex = groupIndex;\n this.refilter();\n }\n\n getFilterCategoryBits(): number {\n return this.m_filterCategoryBits;\n }\n\n setFilterCategoryBits(categoryBits: number): void {\n this.m_filterCategoryBits = categoryBits;\n this.refilter();\n }\n\n getFilterMaskBits(): number {\n return this.m_filterMaskBits;\n }\n\n setFilterMaskBits(maskBits: number): void {\n this.m_filterMaskBits = maskBits;\n this.refilter();\n }\n\n /**\n * Call this if you want to establish collision that was previously disabled by\n * ContactFilter.\n */\n refilter(): void {\n if (this.m_body == null) {\n return;\n }\n\n // Flag associated contacts for filtering.\n let edge = this.m_body.getContactList();\n while (edge) {\n const contact = edge.contact;\n const fixtureA = contact.getFixtureA();\n const fixtureB = contact.getFixtureB();\n if (fixtureA == this || fixtureB == this) {\n contact.flagForFiltering();\n }\n\n edge = edge.next;\n }\n\n const world = this.m_body.getWorld();\n\n if (world == null) {\n return;\n }\n\n // Touch each proxy so that new pairs may be created\n const broadPhase = world.m_broadPhase;\n for (let i = 0; i < this.m_proxyCount; ++i) {\n broadPhase.touchProxy(this.m_proxies[i].proxyId);\n }\n }\n\n /**\n * Implement this method to provide collision filtering, if you want finer\n * control over contact creation.\n *\n * Return true if contact calculations should be performed between these two\n * fixtures.\n *\n * Warning: for performance reasons this is only called when the AABBs begin to\n * overlap.\n */\n shouldCollide(that: Fixture): boolean {\n\n if (that.m_filterGroupIndex === this.m_filterGroupIndex && that.m_filterGroupIndex !== 0) {\n return that.m_filterGroupIndex > 0;\n }\n\n const collideA = (that.m_filterMaskBits & this.m_filterCategoryBits) !== 0;\n const collideB = (that.m_filterCategoryBits & this.m_filterMaskBits) !== 0;\n const collide = collideA && collideB;\n return collide;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { options } from \"../util/options\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { Rot } from \"../common/Rot\";\nimport { Sweep } from \"../common/Sweep\";\nimport { Transform, TransformValue } from \"../common/Transform\";\nimport { Velocity } from \"./Velocity\";\nimport { Position } from \"./Position\";\nimport { Fixture, FixtureDef, FixtureOpt } from \"./Fixture\";\nimport { Shape } from \"../collision/Shape\";\nimport { JointEdge } from \"./Joint\";\nimport { World } from \"./World\";\nimport { ContactEdge } from \"./Contact\";\nimport { Style } from \"../util/Testbed\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A static body does not move under simulation and behaves as if it has infinite mass.\n * Internally, zero is stored for the mass and the inverse mass.\n * Static bodies can be moved manually by the user.\n * A static body has zero velocity.\n * Static bodies do not collide with other static or kinematic bodies.\n * \n * A kinematic body moves under simulation according to its velocity.\n * Kinematic bodies do not respond to forces.\n * They can be moved manually by the user, but normally a kinematic body is moved by setting its velocity.\n * A kinematic body behaves as if it has infinite mass, however, zero is stored for the mass and the inverse mass.\n * Kinematic bodies do not collide with other kinematic or static bodies.\n * \n * A dynamic body is fully simulated.\n * They can be moved manually by the user, but normally they move according to forces.\n * A dynamic body can collide with all body types.\n * A dynamic body always has finite, non-zero mass.\n * If you try to set the mass of a dynamic body to zero, it will automatically acquire a mass of one kilogram and it won't rotate.\n */\nexport type BodyType = \"static\" | \"kinematic\" | \"dynamic\";\n\n/** @internal */ const STATIC = \"static\";\n/** @internal */ const KINEMATIC = \"kinematic\";\n/** @internal */ const DYNAMIC = \"dynamic\";\n\n/** @internal */ const oldCenter = matrix.vec2(0, 0);\n/** @internal */ const localCenter = matrix.vec2(0, 0);\n/** @internal */ const shift = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n\nexport interface BodyDef {\n /**\n * Body types are static, kinematic, or dynamic. Note: if a dynamic\n * body would have zero mass, the mass is set to one.\n */\n type?: BodyType;\n /**\n * The world position of the body. Avoid creating bodies at the\n * origin since this can lead to many overlapping shapes.\n */\n position?: Vec2Value;\n /**\n * The world angle of the body in radians.\n */\n angle?: number;\n /**\n * The linear velocity of the body's origin in world co-ordinates.\n */\n linearVelocity?: Vec2Value;\n angularVelocity?: number;\n /**\n * Linear damping is use to reduce the linear velocity. The\n * damping parameter can be larger than 1.0 but the damping effect becomes\n * sensitive to the time step when the damping parameter is large.\n * Units are 1/time\n */\n linearDamping?: number;\n /**\n * Angular damping is use to reduce the angular velocity.\n * The damping parameter can be larger than 1.0 but the damping effect\n * becomes sensitive to the time step when the damping parameter is large.\n * Units are 1/time\n */\n angularDamping?: number;\n /**\n * Should this body be prevented from rotating? Useful for characters.\n */\n fixedRotation?: boolean;\n /**\n * Is this a fast moving body that should be prevented from\n * tunneling through other moving bodies? Note that all bodies are\n * prevented from tunneling through kinematic and static bodies. This\n * setting is only considered on dynamic bodies. Warning: You should use\n * this flag sparingly since it increases processing time.\n */\n bullet?: boolean;\n gravityScale?: number;\n /**\n * Set this flag to false if this body should never fall asleep. Note that this increases CPU usage.\n */\n allowSleep?: boolean;\n /**\n * Is this body initially awake or sleeping?\n */\n awake?: boolean;\n /**\n * Does this body start out active?\n */\n active?: boolean;\n userData?: any;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\n/** @internal */ const BodyDefDefault: BodyDef = {\n type : STATIC,\n position : Vec2.zero(),\n angle : 0.0,\n\n linearVelocity : Vec2.zero(),\n angularVelocity : 0.0,\n\n linearDamping : 0.0,\n angularDamping : 0.0,\n\n fixedRotation : false,\n bullet : false,\n gravityScale : 1.0,\n\n allowSleep : true,\n awake : true,\n active : true,\n\n userData : null\n};\n\n/**\n * MassData This holds the mass data computed for a shape.\n */\nexport interface MassData {\n /** The mass of the shape, usually in kilograms. */\n mass: number;\n /** The position of the shape's centroid relative to the shape's origin. */\n center: Vec2Value;\n /** The rotational inertia of the shape about the local origin. */\n I: number;\n}\n\n/**\n * A rigid body composed of one or more fixtures.\n *\n * To create a new Body use {@link World.createBody}.\n */\nexport class Body {\n /** @hidden */\n static readonly STATIC: BodyType = \"static\";\n /** @hidden */\n static readonly KINEMATIC: BodyType = \"kinematic\";\n /** @hidden */\n static readonly DYNAMIC: BodyType = \"dynamic\";\n\n /** @internal */ m_world: World;\n /** @internal */ m_awakeFlag: boolean;\n /** @internal */ m_autoSleepFlag: boolean;\n /** @internal */ m_bulletFlag: boolean;\n /** @internal */ m_fixedRotationFlag: boolean;\n /** @internal */ m_activeFlag: boolean;\n /** @internal */ m_islandFlag: boolean;\n /** @internal */ m_toiFlag: boolean;\n /** @internal */ m_userData: unknown;\n /** @internal */ m_type: BodyType;\n /** @internal */ m_mass: number;\n /** @internal */ m_invMass: number;\n /** @internal Rotational inertia about the center of mass. */\n m_I: number;\n /** @internal */ m_invI: number;\n /** @internal the body origin transform */\n m_xf: Transform;\n /** @internal the swept motion for CCD */\n m_sweep: Sweep;\n // position and velocity correction\n /** @internal */ c_velocity: Velocity;\n /** @internal */ c_position: Position;\n /** @internal */ m_force: Vec2;\n /** @internal */ m_torque: number;\n /** @internal */ m_linearVelocity: Vec2;\n /** @internal */ m_angularVelocity: number;\n /** @internal */ m_linearDamping: number;\n /** @internal */ m_angularDamping: number;\n /** @internal */ m_gravityScale: number;\n /** @internal */ m_sleepTime: number;\n /** @internal */ m_jointList: JointEdge | null;\n /** @internal */ m_contactList: ContactEdge | null;\n /** @internal */ m_fixtureList: Fixture | null;\n /** @internal */ m_prev: Body | null;\n /** @internal */ m_next: Body | null;\n /** @internal */ m_destroyed: boolean;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n /** @internal */\n constructor(world: World, def: BodyDef) {\n def = options(def, BodyDefDefault);\n\n if (_ASSERT) console.assert(Vec2.isValid(def.position));\n if (_ASSERT) console.assert(Vec2.isValid(def.linearVelocity));\n if (_ASSERT) console.assert(Number.isFinite(def.angle));\n if (_ASSERT) console.assert(Number.isFinite(def.angularVelocity));\n if (_ASSERT) console.assert(Number.isFinite(def.angularDamping) && def.angularDamping >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.linearDamping) && def.linearDamping >= 0.0);\n\n this.m_world = world;\n\n this.m_awakeFlag = def.awake;\n this.m_autoSleepFlag = def.allowSleep;\n this.m_bulletFlag = def.bullet;\n this.m_fixedRotationFlag = def.fixedRotation;\n this.m_activeFlag = def.active;\n\n this.m_islandFlag = false;\n this.m_toiFlag = false;\n\n this.m_userData = def.userData;\n this.m_type = def.type;\n\n if (this.m_type == DYNAMIC) {\n this.m_mass = 1.0;\n this.m_invMass = 1.0;\n } else {\n this.m_mass = 0.0;\n this.m_invMass = 0.0;\n }\n\n // Rotational inertia about the center of mass.\n this.m_I = 0.0;\n this.m_invI = 0.0;\n\n // the body origin transform\n this.m_xf = Transform.identity();\n this.m_xf.p.setVec2(def.position);\n this.m_xf.q.setAngle(def.angle);\n\n // the swept motion for CCD\n this.m_sweep = new Sweep();\n this.m_sweep.setTransform(this.m_xf);\n\n // position and velocity correction\n this.c_velocity = new Velocity();\n this.c_position = new Position();\n\n this.m_force = Vec2.zero();\n this.m_torque = 0.0;\n\n this.m_linearVelocity = Vec2.clone(def.linearVelocity);\n this.m_angularVelocity = def.angularVelocity;\n\n this.m_linearDamping = def.linearDamping;\n this.m_angularDamping = def.angularDamping;\n this.m_gravityScale = def.gravityScale;\n\n this.m_sleepTime = 0.0;\n\n this.m_jointList = null;\n this.m_contactList = null;\n this.m_fixtureList = null;\n\n this.m_prev = null;\n this.m_next = null;\n\n this.m_destroyed = false;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /** @internal */\n _serialize(): object {\n const fixtures = [];\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n fixtures.push(f);\n }\n return {\n type: this.m_type,\n bullet: this.m_bulletFlag,\n position: this.m_xf.p,\n angle: this.m_xf.q.getAngle(),\n linearVelocity: this.m_linearVelocity,\n angularVelocity: this.m_angularVelocity,\n fixtures,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): Body {\n const body = new Body(world, data);\n\n if (data.fixtures) {\n for (let i = data.fixtures.length - 1; i >= 0; i--) {\n const fixture = restore(Fixture, data.fixtures[i], body);\n body._addFixture(fixture);\n }\n }\n return body;\n }\n\n isWorldLocked(): boolean {\n return this.m_world && this.m_world.isLocked() ? true : false;\n }\n\n getWorld(): World {\n return this.m_world;\n }\n\n getNext(): Body | null {\n return this.m_next;\n }\n\n setUserData(data: any): void {\n this.m_userData = data;\n }\n\n getUserData(): unknown {\n return this.m_userData;\n }\n\n getFixtureList(): Fixture | null {\n return this.m_fixtureList;\n }\n\n getJointList(): JointEdge | null {\n return this.m_jointList;\n }\n\n /**\n * Warning: this list changes during the time step and you may miss some\n * collisions if you don't use ContactListener.\n */\n getContactList(): ContactEdge | null {\n return this.m_contactList;\n }\n\n isStatic(): boolean {\n return this.m_type == STATIC;\n }\n\n isDynamic(): boolean {\n return this.m_type == DYNAMIC;\n }\n\n isKinematic(): boolean {\n return this.m_type == KINEMATIC;\n }\n\n /**\n * This will alter the mass and velocity.\n */\n setStatic(): Body {\n this.setType(STATIC);\n return this;\n }\n\n setDynamic(): Body {\n this.setType(DYNAMIC);\n return this;\n }\n\n setKinematic(): Body {\n this.setType(KINEMATIC);\n return this;\n }\n\n /**\n * Get the type of the body.\n */\n getType(): BodyType {\n return this.m_type;\n }\n\n /**\n * Set the type of the body to \"static\", \"kinematic\" or \"dynamic\".\n * @param type The type of the body.\n */\n setType(type: BodyType): void {\n if (_ASSERT) console.assert(type === STATIC || type === KINEMATIC || type === DYNAMIC);\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (this.m_type == type) {\n return;\n }\n\n this.m_type = type;\n\n this.resetMassData();\n\n if (this.m_type == STATIC) {\n this.m_linearVelocity.setZero();\n this.m_angularVelocity = 0.0;\n this.m_sweep.forward();\n this.synchronizeFixtures();\n }\n\n this.setAwake(true);\n\n this.m_force.setZero();\n this.m_torque = 0.0;\n\n // Delete the attached contacts.\n let ce = this.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n this.m_world.destroyContact(ce0.contact);\n }\n this.m_contactList = null;\n\n // Touch the proxies so that new contacts will be created (when appropriate)\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n for (let i = 0; i < f.m_proxyCount; ++i) {\n broadPhase.touchProxy(f.m_proxies[i].proxyId);\n }\n }\n }\n\n isBullet(): boolean {\n return this.m_bulletFlag;\n }\n\n /**\n * Should this body be treated like a bullet for continuous collision detection?\n */\n setBullet(flag: boolean): void {\n this.m_bulletFlag = !!flag;\n }\n\n isSleepingAllowed(): boolean {\n return this.m_autoSleepFlag;\n }\n\n setSleepingAllowed(flag: boolean): void {\n this.m_autoSleepFlag = !!flag;\n if (this.m_autoSleepFlag == false) {\n this.setAwake(true);\n }\n }\n\n isAwake(): boolean {\n return this.m_awakeFlag;\n }\n\n /**\n * Set the sleep state of the body. A sleeping body has very low CPU cost.\n *\n * @param flag Set to true to wake the body, false to put it to sleep.\n */\n setAwake(flag: boolean): void {\n if (flag) {\n this.m_awakeFlag = true;\n this.m_sleepTime = 0.0;\n } else {\n this.m_awakeFlag = false;\n this.m_sleepTime = 0.0;\n this.m_linearVelocity.setZero();\n this.m_angularVelocity = 0.0;\n this.m_force.setZero();\n this.m_torque = 0.0;\n }\n }\n\n isActive(): boolean {\n return this.m_activeFlag;\n }\n\n /**\n * Set the active state of the body. An inactive body is not simulated and\n * cannot be collided with or woken up. If you pass a flag of true, all fixtures\n * will be added to the broad-phase. If you pass a flag of false, all fixtures\n * will be removed from the broad-phase and all contacts will be destroyed.\n * Fixtures and joints are otherwise unaffected.\n *\n * You may continue to create/destroy fixtures and joints on inactive bodies.\n * Fixtures on an inactive body are implicitly inactive and will not participate\n * in collisions, ray-casts, or queries. Joints connected to an inactive body\n * are implicitly inactive. An inactive body is still owned by a World object\n * and remains\n */\n setActive(flag: boolean): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (flag == this.m_activeFlag) {\n return;\n }\n\n this.m_activeFlag = !!flag;\n\n if (this.m_activeFlag) {\n // Create all proxies.\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.createProxies(broadPhase, this.m_xf);\n }\n\t\t // Contacts are created at the beginning of the next\n\t\t this.m_world.m_newFixture = true;\n } else {\n // Destroy all proxies.\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.destroyProxies(broadPhase);\n }\n\n // Destroy the attached contacts.\n let ce = this.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n this.m_world.destroyContact(ce0.contact);\n }\n this.m_contactList = null;\n }\n }\n\n isFixedRotation(): boolean {\n return this.m_fixedRotationFlag;\n }\n\n /**\n * Set this body to have fixed rotation. This causes the mass to be reset.\n */\n setFixedRotation(flag: boolean): void {\n if (this.m_fixedRotationFlag == flag) {\n return;\n }\n\n this.m_fixedRotationFlag = !!flag;\n\n this.m_angularVelocity = 0.0;\n\n this.resetMassData();\n }\n\n /**\n * Get the world transform for the body's origin.\n */\n getTransform(): Transform {\n return this.m_xf;\n }\n\n /**\n * Set the position of the body's origin and rotation. Manipulating a body's\n * transform may cause non-physical behavior. Note: contacts are updated on the\n * next call to World.step.\n *\n * @param position The world position of the body's local origin.\n * @param angle The world rotation in radians.\n */\n setTransform(position: Vec2Value, angle: number): void;\n /**\n * Set the position of the body's origin and rotation. Manipulating a body's\n * transform may cause non-physical behavior. Note: contacts are updated on the\n * next call to World.step.\n */\n setTransform(xf: Transform): void;\n setTransform(a: Vec2Value | Transform, b?: number): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return;\n }\n if (typeof b === \"number\") {\n this.m_xf.setNum(a as Vec2Value, b);\n } else {\n this.m_xf.setTransform(a as TransformValue);\n }\n\n this.m_sweep.setTransform(this.m_xf);\n\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.synchronize(broadPhase, this.m_xf, this.m_xf);\n }\n this.setAwake(true);\n }\n\n synchronizeTransform(): void {\n this.m_sweep.getTransform(this.m_xf, 1);\n }\n\n /**\n * Update fixtures in broad-phase.\n */\n synchronizeFixtures(): void {\n this.m_sweep.getTransform(xf, 0);\n\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.synchronize(broadPhase, xf, this.m_xf);\n }\n }\n\n /**\n * Used in TOI.\n */\n advance(alpha: number): void {\n // Advance to the new safe time. This doesn't sync the broad-phase.\n this.m_sweep.advance(alpha);\n matrix.copyVec2(this.m_sweep.c, this.m_sweep.c0);\n this.m_sweep.a = this.m_sweep.a0;\n this.m_sweep.getTransform(this.m_xf, 1);\n }\n\n /**\n * Get the world position for the body's origin.\n */\n getPosition(): Vec2 {\n return this.m_xf.p;\n }\n\n setPosition(p: Vec2Value): void {\n this.setTransform(p, this.m_sweep.a);\n }\n\n /**\n * Get the current world rotation angle in radians.\n */\n getAngle(): number {\n return this.m_sweep.a;\n }\n\n setAngle(angle: number): void {\n this.setTransform(this.m_xf.p, angle);\n }\n\n /**\n * Get the world position of the center of mass.\n */\n getWorldCenter(): Vec2 {\n return this.m_sweep.c;\n }\n\n /**\n * Get the local position of the center of mass.\n */\n getLocalCenter(): Vec2 {\n return this.m_sweep.localCenter;\n }\n\n /**\n * Get the linear velocity of the center of mass.\n *\n * @return the linear velocity of the center of mass.\n */\n getLinearVelocity(): Vec2 {\n return this.m_linearVelocity;\n }\n\n /**\n * Get the world linear velocity of a world point attached to this body.\n *\n * @param worldPoint A point in world coordinates.\n */\n getLinearVelocityFromWorldPoint(worldPoint: Vec2Value): Vec2 {\n const localCenter = Vec2.sub(worldPoint, this.m_sweep.c);\n return Vec2.add(this.m_linearVelocity, Vec2.crossNumVec2(this.m_angularVelocity,\n localCenter));\n }\n\n /**\n * Get the world velocity of a local point.\n *\n * @param localPoint A point in local coordinates.\n */\n getLinearVelocityFromLocalPoint(localPoint: Vec2Value): Vec2 {\n return this.getLinearVelocityFromWorldPoint(this.getWorldPoint(localPoint));\n }\n\n /**\n * Set the linear velocity of the center of mass.\n *\n * @param v The new linear velocity of the center of mass.\n */\n setLinearVelocity(v: Vec2Value): void {\n if (this.m_type == STATIC) {\n return;\n }\n if (Vec2.dot(v, v) > 0.0) {\n this.setAwake(true);\n }\n this.m_linearVelocity.setVec2(v);\n }\n\n /**\n * Get the angular velocity.\n *\n * @returns the angular velocity in radians/second.\n */\n getAngularVelocity(): number {\n return this.m_angularVelocity;\n }\n\n /**\n * Set the angular velocity.\n *\n * @param w The new angular velocity in radians/second.\n */\n setAngularVelocity(w: number): void {\n if (this.m_type == STATIC) {\n return;\n }\n if (w * w > 0.0) {\n this.setAwake(true);\n }\n this.m_angularVelocity = w;\n }\n\n getLinearDamping(): number {\n return this.m_linearDamping;\n }\n\n setLinearDamping(linearDamping: number): void {\n this.m_linearDamping = linearDamping;\n }\n\n getAngularDamping(): number {\n return this.m_angularDamping;\n }\n\n setAngularDamping(angularDamping: number): void {\n this.m_angularDamping = angularDamping;\n }\n\n getGravityScale(): number {\n return this.m_gravityScale;\n }\n\n /**\n * Scale the gravity applied to this body.\n */\n setGravityScale(scale: number): void {\n this.m_gravityScale = scale;\n }\n\n /**\n * Get the total mass of the body.\n *\n * @returns The mass, usually in kilograms (kg).\n */\n getMass(): number {\n return this.m_mass;\n }\n\n /**\n * Get the rotational inertia of the body about the local origin.\n *\n * @return the rotational inertia, usually in kg-m^2.\n */\n getInertia(): number {\n return this.m_I + this.m_mass\n * Vec2.dot(this.m_sweep.localCenter, this.m_sweep.localCenter);\n }\n\n /**\n * Copy the mass data of the body to data.\n */\n getMassData(data: MassData): void {\n data.mass = this.m_mass;\n data.I = this.getInertia();\n matrix.copyVec2(data.center, this.m_sweep.localCenter);\n }\n\n /**\n * This resets the mass properties to the sum of the mass properties of the\n * fixtures. This normally does not need to be called unless you called\n * SetMassData to override the mass and you later want to reset the mass.\n */\n resetMassData(): void {\n // Compute mass data from shapes. Each shape has its own density.\n this.m_mass = 0.0;\n this.m_invMass = 0.0;\n this.m_I = 0.0;\n this.m_invI = 0.0;\n matrix.zeroVec2(this.m_sweep.localCenter);\n\n // Static and kinematic bodies have zero mass.\n if (this.isStatic() || this.isKinematic()) {\n matrix.copyVec2(this.m_sweep.c0, this.m_xf.p);\n matrix.copyVec2(this.m_sweep.c, this.m_xf.p);\n this.m_sweep.a0 = this.m_sweep.a;\n return;\n }\n\n if (_ASSERT) console.assert(this.isDynamic());\n\n // Accumulate mass over all fixtures.\n matrix.zeroVec2(localCenter);\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n if (f.m_density == 0.0) {\n continue;\n }\n\n const massData: MassData = {\n mass: 0,\n center: matrix.vec2(0, 0),\n I: 0\n };\n f.getMassData(massData);\n this.m_mass += massData.mass;\n matrix.plusScaleVec2(localCenter, massData.mass, massData.center);\n this.m_I += massData.I;\n }\n\n // Compute center of mass.\n if (this.m_mass > 0.0) {\n this.m_invMass = 1.0 / this.m_mass;\n matrix.scaleVec2(localCenter, this.m_invMass, localCenter);\n\n } else {\n // Force all dynamic bodies to have a positive mass.\n this.m_mass = 1.0;\n this.m_invMass = 1.0;\n }\n\n if (this.m_I > 0.0 && this.m_fixedRotationFlag == false) {\n // Center the inertia about the center of mass.\n this.m_I -= this.m_mass * matrix.dotVec2(localCenter, localCenter);\n if (_ASSERT) console.assert(this.m_I > 0.0);\n this.m_invI = 1.0 / this.m_I;\n\n } else {\n this.m_I = 0.0;\n this.m_invI = 0.0;\n }\n\n // Move center of mass.\n matrix.copyVec2(oldCenter, this.m_sweep.c);\n this.m_sweep.setLocalCenter(localCenter, this.m_xf);\n\n // Update center of mass velocity.\n matrix.subVec2(shift, this.m_sweep.c, oldCenter);\n matrix.crossNumVec2(temp, this.m_angularVelocity, shift);\n matrix.plusVec2(this.m_linearVelocity, temp);\n }\n\n /**\n * Set the mass properties to override the mass properties of the fixtures. Note\n * that this changes the center of mass position. Note that creating or\n * destroying fixtures can also alter the mass. This function has no effect if\n * the body isn't dynamic.\n *\n * @param massData The mass properties.\n */\n setMassData(massData: MassData): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (this.m_type != DYNAMIC) {\n return;\n }\n\n this.m_invMass = 0.0;\n this.m_I = 0.0;\n this.m_invI = 0.0;\n\n this.m_mass = massData.mass;\n if (this.m_mass <= 0.0) {\n this.m_mass = 1.0;\n }\n\n this.m_invMass = 1.0 / this.m_mass;\n\n if (massData.I > 0.0 && this.m_fixedRotationFlag == false) {\n this.m_I = massData.I - this.m_mass * matrix.dotVec2(massData.center, massData.center);\n if (_ASSERT) console.assert(this.m_I > 0.0);\n this.m_invI = 1.0 / this.m_I;\n }\n\n // Move center of mass.\n matrix.copyVec2(oldCenter, this.m_sweep.c);\n this.m_sweep.setLocalCenter(massData.center, this.m_xf);\n\n // Update center of mass velocity.\n matrix.subVec2(shift, this.m_sweep.c, oldCenter);\n matrix.crossNumVec2(temp, this.m_angularVelocity, shift);\n matrix.plusVec2(this.m_linearVelocity, temp);\n }\n\n /**\n * Apply a force at a world point. If the force is not applied at the center of\n * mass, it will generate a torque and affect the angular velocity. This wakes\n * up the body.\n *\n * @param force The world force vector, usually in Newtons (N).\n * @param point The world position of the point of application.\n * @param wake Also wake up the body\n */\n applyForce(force: Vec2Value, point: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping.\n if (this.m_awakeFlag) {\n this.m_force.add(force);\n this.m_torque += Vec2.crossVec2Vec2(Vec2.sub(point, this.m_sweep.c), force);\n }\n }\n\n /**\n * Apply a force to the center of mass. This wakes up the body.\n *\n * @param force The world force vector, usually in Newtons (N).\n * @param wake Also wake up the body\n */\n applyForceToCenter(force: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_force.add(force);\n }\n }\n\n /**\n * Apply a torque. This affects the angular velocity without affecting the\n * linear velocity of the center of mass. This wakes up the body.\n *\n * @param torque About the z-axis (out of the screen), usually in N-m.\n * @param wake Also wake up the body\n */\n applyTorque(torque: number, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_torque += torque;\n }\n }\n\n /**\n * Apply an impulse at a point. This immediately modifies the velocity. It also\n * modifies the angular velocity if the point of application is not at the\n * center of mass. This wakes up the body.\n *\n * @param impulse The world impulse vector, usually in N-seconds or kg-m/s.\n * @param point The world position of the point of application.\n * @param wake Also wake up the body\n */\n applyLinearImpulse(impulse: Vec2Value, point: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n\n // Don't accumulate velocity if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_linearVelocity.addMul(this.m_invMass, impulse);\n this.m_angularVelocity += this.m_invI * Vec2.crossVec2Vec2(Vec2.sub(point, this.m_sweep.c), impulse);\n }\n }\n\n /**\n * Apply an angular impulse.\n *\n * @param impulse The angular impulse in units of kg*m*m/s\n * @param wake Also wake up the body\n */\n applyAngularImpulse(impulse: number, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate velocity if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_angularVelocity += this.m_invI * impulse;\n }\n }\n\n /**\n * This is used to test if two bodies should collide.\n * \n * Bodies do not collide when:\n * - Neither of them is dynamic\n * - They are connected by a joint with collideConnected == false\n */\n shouldCollide(that: Body): boolean {\n // At least one body should be dynamic.\n if (this.m_type != DYNAMIC && that.m_type != DYNAMIC) {\n return false;\n }\n // Does a joint prevent collision?\n for (let jn = this.m_jointList; jn; jn = jn.next) {\n if (jn.other == that) {\n if (jn.joint.m_collideConnected == false) {\n return false;\n }\n }\n }\n return true;\n }\n\n /** @internal Used for deserialize. */\n _addFixture(fixture: Fixture): Fixture {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return null;\n }\n\n if (this.m_activeFlag) {\n const broadPhase = this.m_world.m_broadPhase;\n fixture.createProxies(broadPhase, this.m_xf);\n }\n\n fixture.m_next = this.m_fixtureList;\n this.m_fixtureList = fixture;\n\n // Adjust mass properties if needed.\n if (fixture.m_density > 0.0) {\n this.resetMassData();\n }\n\n // Let the world know we have a new fixture. This will cause new contacts\n // to be created at the beginning of the next time step.\n this.m_world.m_newFixture = true;\n\n return fixture;\n }\n\n /**\n * Creates a fixture and attach it to this body.\n *\n * If the density is non-zero, this function automatically updates the mass of\n * the body.\n *\n * Contacts are not created until the next time step.\n *\n * Warning: This function is locked during callbacks.\n */\n createFixture(def: FixtureDef): Fixture;\n createFixture(shape: Shape, opt?: FixtureOpt): Fixture;\n createFixture(shape: Shape, density?: number): Fixture;\n // tslint:disable-next-line:typedef\n createFixture(shape, fixdef?) {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return null;\n }\n\n const fixture = new Fixture(this, shape, fixdef);\n this._addFixture(fixture);\n return fixture;\n }\n\n /**\n * Destroy a fixture. This removes the fixture from the broad-phase and destroys\n * all contacts associated with this fixture. This will automatically adjust the\n * mass of the body if the body is dynamic and the fixture has positive density.\n * All fixtures attached to a body are implicitly destroyed when the body is\n * destroyed.\n *\n * Warning: This function is locked during callbacks.\n *\n * @param fixture The fixture to be removed.\n */\n destroyFixture(fixture: Fixture): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (_ASSERT) console.assert(fixture.m_body == this);\n\n // Remove the fixture from this body's singly linked list.\n let found = false;\n if (this.m_fixtureList === fixture) {\n this.m_fixtureList = fixture.m_next;\n found = true;\n\n } else {\n let node = this.m_fixtureList;\n while (node != null) {\n if (node.m_next === fixture) {\n node.m_next = fixture.m_next;\n found = true;\n break;\n }\n node = node.m_next;\n }\n }\n\n // You tried to remove a shape that is not attached to this body.\n if (_ASSERT) console.assert(found);\n\n // Destroy any contacts associated with the fixture.\n let edge = this.m_contactList;\n while (edge) {\n const c = edge.contact;\n edge = edge.next;\n\n const fixtureA = c.getFixtureA();\n const fixtureB = c.getFixtureB();\n\n if (fixture == fixtureA || fixture == fixtureB) {\n // This destroys the contact and removes it from\n // this body's contact list.\n this.m_world.destroyContact(c);\n }\n }\n\n if (this.m_activeFlag) {\n const broadPhase = this.m_world.m_broadPhase;\n fixture.destroyProxies(broadPhase);\n }\n\n fixture.m_body = null;\n fixture.m_next = null;\n\n this.m_world.publish(\"remove-fixture\", fixture);\n\n // Reset the mass data.\n this.resetMassData();\n }\n\n /**\n * Get the corresponding world point of a local point.\n */\n getWorldPoint(localPoint: Vec2Value): Vec2 {\n return Transform.mulVec2(this.m_xf, localPoint);\n }\n\n /**\n * Get the corresponding world vector of a local vector.\n */\n getWorldVector(localVector: Vec2Value): Vec2 {\n return Rot.mulVec2(this.m_xf.q, localVector);\n }\n\n /**\n * Gets the corresponding local point of a world point.\n */\n getLocalPoint(worldPoint: Vec2Value): Vec2 {\n return Transform.mulTVec2(this.m_xf, worldPoint);\n }\n\n /**\n * Gets the corresponding local vector of a world vector.\n */\n getLocalVector(worldVector: Vec2Value): Vec2 {\n return Rot.mulTVec2(this.m_xf.q, worldVector);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { Vec2, Vec2Value } from \"../common/Vec2\";\nimport type { Body } from \"./Body\";\nimport { TimeStep } from \"./Solver\";\nimport { Style } from \"../util/Testbed\";\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/**\n * A joint edge is used to connect bodies and joints together in a joint graph\n * where each body is a node and each joint is an edge. A joint edge belongs to\n * a doubly linked list maintained in each attached body. Each joint has two\n * joint nodes, one for each attached body.\n */\nexport class JointEdge {\n /**\n * provides quick access to the other body attached.\n */\n other: Body | null = null;\n /**\n * the joint\n */\n joint: Joint | null = null;\n /**\n * prev the previous joint edge in the body's joint list\n */\n prev: JointEdge | null = null;\n /**\n * the next joint edge in the body's joint list\n */\n next: JointEdge | null = null;\n}\n\n/**\n * Joint definitions are used to construct joints.\n */\nexport interface JointOpt {\n /**\n * Use this to attach application specific data to your joints.\n */\n userData?: any;\n /**\n * Set this flag to true if the attached bodies\n * should collide.\n */\n collideConnected?: boolean;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\n/**\n * Joint definitions are used to construct joints.\n */\nexport interface JointDef extends JointOpt {\n /**\n * The first attached body.\n */\n bodyA: Body;\n /**\n * The second attached body.\n */\n bodyB: Body;\n}\n\n/** @internal */ const DEFAULTS = {\n userData : null,\n collideConnected : false\n};\n\n/**\n * The base joint class. Joints are used to constraint two bodies together in\n * various fashions. Some joints also feature limits and motors.\n */\nexport abstract class Joint {\n\n /** @internal */ m_type: string = \"unknown-joint\";\n\n /** @internal */ m_bodyA: Body;\n /** @internal */ m_bodyB: Body;\n\n /** @internal */ m_collideConnected: boolean;\n\n /** @internal */ m_prev: Joint | null = null;\n /** @internal */ m_next: Joint | null = null;\n\n /** @internal */ m_edgeA: JointEdge = new JointEdge();\n /** @internal */ m_edgeB: JointEdge = new JointEdge();\n\n /** @internal */ m_islandFlag: boolean = false;\n /** @internal */ m_userData: unknown;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n constructor(def: JointDef);\n constructor(def: JointOpt, bodyA: Body, bodyB: Body);\n constructor(def: JointDef | JointOpt, bodyA?: Body, bodyB?: Body) {\n bodyA = \"bodyA\" in def ? def.bodyA : bodyA;\n bodyB = \"bodyB\" in def ? def.bodyB : bodyB;\n\n if (_ASSERT) console.assert(!!bodyA);\n if (_ASSERT) console.assert(!!bodyB);\n if (_ASSERT) console.assert(bodyA != bodyB);\n\n this.m_bodyA = bodyA!;\n this.m_bodyB = bodyB!;\n\n this.m_collideConnected = !!def.collideConnected;\n this.m_userData = def.userData;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /**\n * Short-cut function to determine if either body is inactive.\n */\n isActive(): boolean {\n return this.m_bodyA.isActive() && this.m_bodyB.isActive();\n }\n\n /**\n * Get the type of the concrete joint.\n */\n getType(): string {\n return this.m_type;\n }\n\n /**\n * Get the first body attached to this joint.\n */\n getBodyA(): Body {\n return this.m_bodyA;\n }\n\n /**\n * Get the second body attached to this joint.\n */\n getBodyB(): Body {\n return this.m_bodyB;\n }\n\n /**\n * Get the next joint the world joint list.\n */\n getNext(): Joint {\n return this.m_next;\n }\n\n getUserData(): unknown {\n return this.m_userData;\n }\n\n setUserData(data: unknown): void {\n this.m_userData = data;\n }\n\n /**\n * Get collide connected. Note: modifying the collide connect flag won't work\n * correctly because the flag is only checked when fixture AABBs begin to\n * overlap.\n */\n getCollideConnected(): boolean {\n return this.m_collideConnected;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n abstract getAnchorA(): Vec2;\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n abstract getAnchorB(): Vec2;\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n abstract getReactionForce(inv_dt: number): Vec2;\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n abstract getReactionTorque(inv_dt: number): number;\n\n /**\n * Shift the origin for any points stored in world coordinates.\n */\n shiftOrigin(newOrigin: Vec2Value): void {}\n\n abstract initVelocityConstraints(step: TimeStep): void;\n\n abstract solveVelocityConstraints(step: TimeStep): void;\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n abstract solvePositionConstraints(step: TimeStep): boolean;\n\n /**\n * @hidden @experimental\n * Update joint with new props.\n */\n abstract _reset(def: Partial): void;\n\n /**\n * @internal @deprecated\n * Temporary for backward compatibility, will be removed.\n */\n _resetAnchors(def: any): void {\n return this._reset(def);\n }\n}\n","/** @hidden */\nexport const stats = {\n gjkCalls: 0,\n gjkIters: 0,\n gjkMaxIters: 0,\n\n toiTime: 0,\n toiMaxTime: 0,\n toiCalls: 0,\n toiIters: 0,\n toiMaxIters: 0,\n toiRootIters: 0,\n toiMaxRootIters: 0,\n\n toString(newline?: string): string {\n newline = typeof newline === \"string\" ? newline : \"\\n\";\n let string = \"\";\n // tslint:disable-next-line:no-for-in\n for (const name in this) {\n if (typeof this[name] !== \"function\" && typeof this[name] !== \"object\") {\n string += name + \": \" + this[name] + newline;\n }\n }\n return string;\n }\n};\n","/** @internal */\nexport const now = function(): number {\n return Date.now();\n};\n\n/** @internal */\nexport const diff = function(time: number): number {\n return Date.now() - time;\n};\n\n/** @internal */\nexport default {\n now,\n diff,\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { stats } from \"../util/stats\";\nimport { Shape } from \"./Shape\";\nimport { EPSILON } from \"../common/Math\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { Rot } from \"../common/Rot\";\nimport { Transform, TransformValue } from \"../common/Transform\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_max = Math.max;\n\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const e12 = matrix.vec2(0, 0);\n/** @internal */ const e13 = matrix.vec2(0, 0);\n/** @internal */ const e23 = matrix.vec2(0, 0);\n/** @internal */ const temp1 = matrix.vec2(0, 0);\n/** @internal */ const temp2 = matrix.vec2(0, 0);\n\n/**\n * GJK using Voronoi regions (Christer Ericson) and Barycentric coordinates.\n */\n\nstats.gjkCalls = 0;\nstats.gjkIters = 0;\nstats.gjkMaxIters = 0;\n\n/**\n * Input for Distance. You have to option to use the shape radii in the\n * computation. Even\n */\nexport class DistanceInput {\n readonly proxyA = new DistanceProxy();\n readonly proxyB = new DistanceProxy();\n readonly transformA = Transform.identity();\n readonly transformB = Transform.identity();\n useRadii = false;\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.transformA.setIdentity();\n this.transformB.setIdentity();\n this.useRadii = false;\n }\n}\n\n/**\n * Output for Distance.\n */\nexport class DistanceOutput {\n /** closest point on shapeA */\n pointA = matrix.vec2(0, 0);\n /** closest point on shapeB */\n pointB = matrix.vec2(0, 0);\n distance = 0;\n /** iterations number of GJK iterations used */\n iterations = 0;\n recycle() {\n matrix.zeroVec2(this.pointA);\n matrix.zeroVec2(this.pointB);\n this.distance = 0;\n this.iterations = 0;\n }\n}\n\n/**\n * Used to warm start Distance. Set count to zero on first call.\n */\nexport class SimplexCache {\n /** length or area */\n metric: number = 0;\n /** vertices on shape A */\n indexA: number[] = [];\n /** vertices on shape B */\n indexB: number[] = [];\n count: number = 0;\n recycle() {\n this.metric = 0;\n this.indexA.length = 0;\n this.indexB.length = 0;\n this.count = 0;\n }\n}\n\n/**\n * Compute the closest points between two shapes. Supports any combination of:\n * CircleShape, PolygonShape, EdgeShape. The simplex cache is input/output. On\n * the first call set SimplexCache.count to zero.\n */\nexport const Distance = function (output: DistanceOutput, cache: SimplexCache, input: DistanceInput): void {\n ++stats.gjkCalls;\n\n const proxyA = input.proxyA;\n const proxyB = input.proxyB;\n const xfA = input.transformA;\n const xfB = input.transformB;\n\n // Initialize the simplex.\n // const simplex = new Simplex();\n simplex.recycle();\n simplex.readCache(cache, proxyA, xfA, proxyB, xfB);\n\n // Get simplex vertices as an array.\n const vertices = simplex.m_v;\n const k_maxIters = Settings.maxDistanceIterations;\n\n // These store the vertices of the last simplex so that we\n // can check for duplicates and prevent cycling.\n const saveA = [];\n const saveB = []; // int[3]\n let saveCount = 0;\n\n // Main iteration loop.\n let iter = 0;\n while (iter < k_maxIters) {\n // Copy simplex so we can identify duplicates.\n saveCount = simplex.m_count;\n for (let i = 0; i < saveCount; ++i) {\n saveA[i] = vertices[i].indexA;\n saveB[i] = vertices[i].indexB;\n }\n\n simplex.solve();\n\n // If we have 3 points, then the origin is in the corresponding triangle.\n if (simplex.m_count === 3) {\n break;\n }\n\n // Get search direction.\n const d = simplex.getSearchDirection();\n\n // Ensure the search direction is numerically fit.\n if (matrix.lengthSqrVec2(d) < EPSILON * EPSILON) {\n // The origin is probably contained by a line segment\n // or triangle. Thus the shapes are overlapped.\n\n // We can't return zero here even though there may be overlap.\n // In case the simplex is a point, segment, or triangle it is difficult\n // to determine if the origin is contained in the CSO or very close to it.\n break;\n }\n\n // Compute a tentative new simplex vertex using support points.\n const vertex = vertices[simplex.m_count]; // SimplexVertex\n\n vertex.indexA = proxyA.getSupport(matrix.derotVec2(temp, xfA.q, matrix.scaleVec2(temp, -1, d)));\n matrix.transformVec2(vertex.wA, xfA, proxyA.getVertex(vertex.indexA));\n\n vertex.indexB = proxyB.getSupport(matrix.derotVec2(temp, xfB.q, d));\n matrix.transformVec2(vertex.wB, xfB, proxyB.getVertex(vertex.indexB));\n\n matrix.subVec2(vertex.w, vertex.wB, vertex.wA);\n\n // Iteration count is equated to the number of support point calls.\n ++iter;\n ++stats.gjkIters;\n\n // Check for duplicate support points. This is the main termination\n // criteria.\n let duplicate = false;\n for (let i = 0; i < saveCount; ++i) {\n if (vertex.indexA === saveA[i] && vertex.indexB === saveB[i]) {\n duplicate = true;\n break;\n }\n }\n\n // If we found a duplicate support point we must exit to avoid cycling.\n if (duplicate) {\n break;\n }\n\n // New vertex is ok and needed.\n ++simplex.m_count;\n }\n\n stats.gjkMaxIters = math_max(stats.gjkMaxIters, iter);\n\n // Prepare output.\n simplex.getWitnessPoints(output.pointA, output.pointB);\n output.distance = matrix.distVec2(output.pointA, output.pointB);\n output.iterations = iter;\n\n // Cache the simplex.\n simplex.writeCache(cache);\n\n // Apply radii if requested.\n if (input.useRadii) {\n const rA = proxyA.m_radius;\n const rB = proxyB.m_radius;\n\n if (output.distance > rA + rB && output.distance > EPSILON) {\n // Shapes are still no overlapped.\n // Move the witness points to the outer surface.\n output.distance -= rA + rB;\n matrix.subVec2(normal, output.pointB, output.pointA);\n matrix.normalizeVec2(normal);\n matrix.plusScaleVec2(output.pointA, rA, normal);\n matrix.minusScaleVec2(output.pointB, rB, normal);\n } else {\n // Shapes are overlapped when radii are considered.\n // Move the witness points to the middle.\n const p = matrix.subVec2(temp, output.pointA, output.pointB);\n matrix.copyVec2(output.pointA, p);\n matrix.copyVec2(output.pointB, p);\n output.distance = 0.0;\n }\n }\n};\n\n/**\n * A distance proxy is used by the GJK algorithm. It encapsulates any shape.\n */\nexport class DistanceProxy {\n /** @internal */ m_vertices: Vec2Value[] = [];\n // todo: remove this?\n /** @internal */ m_count = 0;\n /** @internal */ m_radius = 0;\n\n recycle() {\n this.m_vertices.length = 0;\n this.m_count = 0;\n this.m_radius = 0;\n }\n\n /**\n * Get the vertex count.\n */\n getVertexCount(): number {\n return this.m_count;\n }\n\n /**\n * Get a vertex by index. Used by Distance.\n */\n getVertex(index: number): Vec2Value {\n if (_ASSERT) console.assert(0 <= index && index < this.m_count);\n return this.m_vertices[index];\n }\n\n /**\n * Get the supporting vertex index in the given direction.\n */\n getSupport(d: Vec2Value): number {\n let bestIndex = -1;\n let bestValue = -Infinity;\n for (let i = 0; i < this.m_count; ++i) {\n const value = matrix.dotVec2(this.m_vertices[i], d);\n if (value > bestValue) {\n bestIndex = i;\n bestValue = value;\n }\n }\n return bestIndex;\n }\n\n /**\n * Get the supporting vertex in the given direction.\n */\n getSupportVertex(d: Vec2Value): Vec2Value {\n return this.m_vertices[this.getSupport(d)];\n }\n\n /**\n * Initialize the proxy using the given shape. The shape must remain in scope\n * while the proxy is in use.\n */\n set(shape: Shape, index: number): void {\n // TODO remove, use shape instead\n if (_ASSERT) console.assert(typeof shape.computeDistanceProxy === \"function\");\n shape.computeDistanceProxy(this, index);\n }\n\n /**\n * Initialize the proxy using a vertex cloud and radius. The vertices\n * must remain in scope while the proxy is in use.\n */\n setVertices(vertices: Vec2Value[], count: number, radius: number) {\n this.m_vertices = vertices;\n this.m_count = count;\n this.m_radius = radius;\n }\n}\n\nclass SimplexVertex {\n /** support point in proxyA */\n wA = matrix.vec2(0, 0);\n /** wA index */\n indexA = 0;\n\n /** support point in proxyB */\n wB = matrix.vec2(0, 0);\n /** wB index */\n indexB = 0;\n\n /** wB - wA; */\n w = matrix.vec2(0, 0);\n /** barycentric coordinate for closest point */\n a = 0;\n\n recycle() {\n this.indexA = 0;\n this.indexB = 0;\n matrix.zeroVec2(this.wA);\n matrix.zeroVec2(this.wB);\n matrix.zeroVec2(this.w);\n this.a = 0;\n }\n set(v: SimplexVertex): void {\n this.indexA = v.indexA;\n this.indexB = v.indexB;\n matrix.copyVec2(this.wA, v.wA);\n matrix.copyVec2(this.wB, v.wB);\n matrix.copyVec2(this.w, v.w);\n this.a = v.a;\n }\n}\n\n/** @internal */ const searchDirection_reuse = matrix.vec2(0, 0);\n/** @internal */ const closestPoint_reuse = matrix.vec2(0, 0); \n\nclass Simplex {\n m_v1 = new SimplexVertex();\n m_v2 = new SimplexVertex();\n m_v3 = new SimplexVertex();\n m_v = [this.m_v1, this.m_v2, this.m_v3];\n m_count: number;\n recycle() {\n this.m_v1.recycle();\n this.m_v2.recycle();\n this.m_v3.recycle();\n this.m_count = 0;\n }\n\n /** @internal */ toString(): string {\n if (this.m_count === 3) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y,\n this.m_v2.a, this.m_v2.wA.x, this.m_v2.wA.y, this.m_v2.wB.x, this.m_v2.wB.y,\n this.m_v3.a, this.m_v3.wA.x, this.m_v3.wA.y, this.m_v3.wB.x, this.m_v3.wB.y\n ].toString();\n\n } else if (this.m_count === 2) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y,\n this.m_v2.a, this.m_v2.wA.x, this.m_v2.wA.y, this.m_v2.wB.x, this.m_v2.wB.y\n ].toString();\n\n } else if (this.m_count === 1) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y\n ].toString();\n\n } else {\n return \"+\" + this.m_count;\n }\n }\n\n readCache(cache: SimplexCache, proxyA: DistanceProxy, transformA: TransformValue, proxyB: DistanceProxy, transformB: TransformValue): void {\n if (_ASSERT) console.assert(cache.count <= 3);\n\n // Copy data from cache.\n this.m_count = cache.count;\n for (let i = 0; i < this.m_count; ++i) {\n const v = this.m_v[i];\n v.indexA = cache.indexA[i];\n v.indexB = cache.indexB[i];\n const wALocal = proxyA.getVertex(v.indexA);\n const wBLocal = proxyB.getVertex(v.indexB);\n matrix.transformVec2(v.wA, transformA, wALocal);\n matrix.transformVec2(v.wB, transformB, wBLocal);\n matrix.subVec2(v.w,v.wB, v.wA);\n v.a = 0.0;\n }\n\n // Compute the new simplex metric, if it is substantially different than\n // old metric then flush the simplex.\n if (this.m_count > 1) {\n const metric1 = cache.metric;\n const metric2 = this.getMetric();\n if (metric2 < 0.5 * metric1 || 2.0 * metric1 < metric2 || metric2 < EPSILON) {\n // Reset the simplex.\n this.m_count = 0;\n }\n }\n\n // If the cache is empty or invalid...\n if (this.m_count === 0) {\n const v = this.m_v[0];\n v.indexA = 0;\n v.indexB = 0;\n const wALocal = proxyA.getVertex(0);\n const wBLocal = proxyB.getVertex(0);\n matrix.transformVec2(v.wA, transformA, wALocal);\n matrix.transformVec2(v.wB, transformB, wBLocal);\n matrix.subVec2(v.w,v.wB, v.wA);\n v.a = 1.0;\n this.m_count = 1;\n }\n }\n\n writeCache(cache: SimplexCache): void {\n cache.metric = this.getMetric();\n cache.count = this.m_count;\n for (let i = 0; i < this.m_count; ++i) {\n cache.indexA[i] = this.m_v[i].indexA;\n cache.indexB[i] = this.m_v[i].indexB;\n }\n }\n\n getSearchDirection(): Vec2Value {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 1:\n return matrix.setVec2(searchDirection_reuse, -v1.w.x, -v1.w.y);\n\n case 2: {\n matrix.subVec2(e12, v2.w, v1.w);\n const sgn = -matrix.crossVec2Vec2(e12, v1.w);\n if (sgn > 0.0) {\n // Origin is left of e12.\n return matrix.setVec2(searchDirection_reuse, -e12.y, e12.x);\n } else {\n // Origin is right of e12.\n return matrix.setVec2(searchDirection_reuse, e12.y, -e12.x);\n }\n }\n\n default:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(searchDirection_reuse);\n }\n }\n\n getClosestPoint(): Vec2Value {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(closestPoint_reuse);\n\n case 1:\n return matrix.copyVec2(closestPoint_reuse, v1.w);\n\n case 2:\n return matrix.combine2Vec2(closestPoint_reuse, v1.a, v1.w, v2.a, v2.w);\n\n case 3:\n return matrix.zeroVec2(closestPoint_reuse);\n\n default:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(closestPoint_reuse);\n }\n }\n\n getWitnessPoints(pA: Vec2Value, pB: Vec2Value): void {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n break;\n\n case 1:\n matrix.copyVec2(pA, v1.wA);\n matrix.copyVec2(pB, v1.wB);\n break;\n\n case 2:\n matrix.combine2Vec2(pA, v1.a, v1.wA, v2.a, v2.wA);\n matrix.combine2Vec2(pB, v1.a, v1.wB, v2.a, v2.wB);\n break;\n\n case 3:\n matrix.combine3Vec2(pA, v1.a, v1.wA, v2.a, v2.wA, v3.a, v3.wA);\n matrix.copyVec2(pB, pA);\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n break;\n }\n }\n\n getMetric(): number {\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n return 0.0;\n\n case 1:\n return 0.0;\n\n case 2:\n return matrix.distVec2(this.m_v1.w, this.m_v2.w);\n\n case 3:\n return matrix.crossVec2Vec2(\n matrix.subVec2(temp1, this.m_v2.w, this.m_v1.w),\n matrix.subVec2(temp2, this.m_v3.w, this.m_v1.w),\n );\n\n default:\n if (_ASSERT) console.assert(false);\n return 0.0;\n }\n }\n\n solve(): void {\n switch (this.m_count) {\n case 1:\n break;\n\n case 2:\n this.solve2();\n break;\n\n case 3:\n this.solve3();\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n }\n }\n\n// Solve a line segment using barycentric coordinates.\n//\n// p = a1 * w1 + a2 * w2\n// a1 + a2 = 1\n//\n// The vector from the origin to the closest point on the line is\n// perpendicular to the line.\n// e12 = w2 - w1\n// dot(p, e) = 0\n// a1 * dot(w1, e) + a2 * dot(w2, e) = 0\n//\n// 2-by-2 linear system\n// [1 1 ][a1] = [1]\n// [w1.e12 w2.e12][a2] = [0]\n//\n// Define\n// d12_1 = dot(w2, e12)\n// d12_2 = -dot(w1, e12)\n// d12 = d12_1 + d12_2\n//\n// Solution\n// a1 = d12_1 / d12\n// a2 = d12_2 / d12\n solve2(): void {\n const w1 = this.m_v1.w;\n const w2 = this.m_v2.w;\n matrix.subVec2(e12, w2, w1);\n\n // w1 region\n const d12_2 = -matrix.dotVec2(w1, e12);\n if (d12_2 <= 0.0) {\n // a2 <= 0, so we clamp it to 0\n this.m_v1.a = 1.0;\n this.m_count = 1;\n return;\n }\n\n // w2 region\n const d12_1 = matrix.dotVec2(w2, e12);\n if (d12_1 <= 0.0) {\n // a1 <= 0, so we clamp it to 0\n this.m_v2.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v2);\n return;\n }\n\n // Must be in e12 region.\n const inv_d12 = 1.0 / (d12_1 + d12_2);\n this.m_v1.a = d12_1 * inv_d12;\n this.m_v2.a = d12_2 * inv_d12;\n this.m_count = 2;\n }\n\n// Possible regions:\n// - points[2]\n// - edge points[0]-points[2]\n// - edge points[1]-points[2]\n// - inside the triangle\n solve3(): void {\n const w1 = this.m_v1.w;\n const w2 = this.m_v2.w;\n const w3 = this.m_v3.w;\n\n // Edge12\n // [1 1 ][a1] = [1]\n // [w1.e12 w2.e12][a2] = [0]\n // a3 = 0\n matrix.subVec2(e12, w2, w1);\n const w1e12 = matrix.dotVec2(w1, e12);\n const w2e12 = matrix.dotVec2(w2, e12);\n const d12_1 = w2e12;\n const d12_2 = -w1e12;\n\n // Edge13\n // [1 1 ][a1] = [1]\n // [w1.e13 w3.e13][a3] = [0]\n // a2 = 0\n matrix.subVec2(e13, w3, w1);\n const w1e13 = matrix.dotVec2(w1, e13);\n const w3e13 = matrix.dotVec2(w3, e13);\n const d13_1 = w3e13;\n const d13_2 = -w1e13;\n\n // Edge23\n // [1 1 ][a2] = [1]\n // [w2.e23 w3.e23][a3] = [0]\n // a1 = 0\n matrix.subVec2(e23, w3, w2);\n const w2e23 = matrix.dotVec2(w2, e23);\n const w3e23 = matrix.dotVec2(w3, e23);\n const d23_1 = w3e23;\n const d23_2 = -w2e23;\n\n // Triangle123\n const n123 = matrix.crossVec2Vec2(e12, e13);\n\n const d123_1 = n123 * matrix.crossVec2Vec2(w2, w3);\n const d123_2 = n123 * matrix.crossVec2Vec2(w3, w1);\n const d123_3 = n123 * matrix.crossVec2Vec2(w1, w2);\n\n // w1 region\n if (d12_2 <= 0.0 && d13_2 <= 0.0) {\n this.m_v1.a = 1.0;\n this.m_count = 1;\n return;\n }\n\n // e12\n if (d12_1 > 0.0 && d12_2 > 0.0 && d123_3 <= 0.0) {\n const inv_d12 = 1.0 / (d12_1 + d12_2);\n this.m_v1.a = d12_1 * inv_d12;\n this.m_v2.a = d12_2 * inv_d12;\n this.m_count = 2;\n return;\n }\n\n // e13\n if (d13_1 > 0.0 && d13_2 > 0.0 && d123_2 <= 0.0) {\n const inv_d13 = 1.0 / (d13_1 + d13_2);\n this.m_v1.a = d13_1 * inv_d13;\n this.m_v3.a = d13_2 * inv_d13;\n this.m_count = 2;\n this.m_v2.set(this.m_v3);\n return;\n }\n\n // w2 region\n if (d12_1 <= 0.0 && d23_2 <= 0.0) {\n this.m_v2.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v2);\n return;\n }\n\n // w3 region\n if (d13_1 <= 0.0 && d23_1 <= 0.0) {\n this.m_v3.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v3);\n return;\n }\n\n // e23\n if (d23_1 > 0.0 && d23_2 > 0.0 && d123_1 <= 0.0) {\n const inv_d23 = 1.0 / (d23_1 + d23_2);\n this.m_v2.a = d23_1 * inv_d23;\n this.m_v3.a = d23_2 * inv_d23;\n this.m_count = 2;\n this.m_v1.set(this.m_v3);\n return;\n }\n\n // Must be in triangle123\n const inv_d123 = 1.0 / (d123_1 + d123_2 + d123_3);\n this.m_v1.a = d123_1 * inv_d123;\n this.m_v2.a = d123_2 * inv_d123;\n this.m_v3.a = d123_3 * inv_d123;\n this.m_count = 3;\n }\n}\n\n/** @internal */ const simplex = new Simplex();\n\n/** @internal */ const input = new DistanceInput();\n/** @internal */ const cache = new SimplexCache();\n/** @internal */ const output = new DistanceOutput();\n\n/**\n * Determine if two generic shapes overlap.\n */\nexport const testOverlap = function (shapeA: Shape, indexA: number, shapeB: Shape, indexB: number, xfA: TransformValue, xfB: TransformValue): boolean {\n input.recycle();\n input.proxyA.set(shapeA, indexA);\n input.proxyB.set(shapeB, indexB);\n matrix.copyTransform(input.transformA, xfA);\n matrix.copyTransform(input.transformB, xfB);\n input.useRadii = true;\n\n output.recycle();\n cache.recycle();\n\n Distance(output, cache, input);\n\n return output.distance < 10.0 * EPSILON;\n};\n\n// legacy exports\nDistance.testOverlap = testOverlap;\nDistance.Input = DistanceInput;\nDistance.Output = DistanceOutput;\nDistance.Proxy = DistanceProxy;\nDistance.Cache = SimplexCache;\n\n/**\n * Input parameters for ShapeCast\n */\nexport class ShapeCastInput {\n readonly proxyA = new DistanceProxy();\n readonly proxyB = new DistanceProxy();\n readonly transformA = Transform.identity();\n readonly transformB = Transform.identity();\n readonly translationB = Vec2.zero();\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.transformA.setIdentity();\n this.transformB.setIdentity();\n matrix.zeroVec2(this.translationB);\n }\n}\n\n/**\n * Output results for b2ShapeCast\n */\nexport class ShapeCastOutput {\n point: Vec2 = Vec2.zero();\n normal: Vec2 = Vec2.zero();\n lambda = 1.0;\n iterations = 0;\n}\n\n/**\n * Perform a linear shape cast of shape B moving and shape A fixed. Determines\n * the hit point, normal, and translation fraction.\n * \n * @returns true if hit, false if there is no hit or an initial overlap\n */\n//\n// GJK-raycast\n// Algorithm by Gino van den Bergen.\n// \"Smooth Mesh Contacts with GJK\" in Game Physics Pearls. 2010\nexport const ShapeCast = function(output: ShapeCastOutput, input: ShapeCastInput): boolean {\n output.iterations = 0;\n output.lambda = 1.0;\n output.normal.setZero();\n output.point.setZero();\n\n const proxyA = input.proxyA;\n const proxyB = input.proxyB;\n\n const radiusA = math_max(proxyA.m_radius, Settings.polygonRadius);\n const radiusB = math_max(proxyB.m_radius, Settings.polygonRadius);\n const radius = radiusA + radiusB;\n\n const xfA = input.transformA;\n const xfB = input.transformB;\n\n const r = input.translationB;\n const n = Vec2.zero();\n let lambda = 0.0;\n\n // Initial simplex\n const simplex = new Simplex();\n simplex.m_count = 0;\n\n // Get simplex vertices as an array.\n const vertices = simplex.m_v;\n\n // Get support point in -r direction\n let indexA = proxyA.getSupport(Rot.mulTVec2(xfA.q, Vec2.neg(r)));\n let wA = Transform.mulVec2(xfA, proxyA.getVertex(indexA));\n let indexB = proxyB.getSupport(Rot.mulTVec2(xfB.q, r));\n let wB = Transform.mulVec2(xfB, proxyB.getVertex(indexB));\n const v = Vec2.sub(wA, wB);\n\n // Sigma is the target distance between polygons\n const sigma = math_max(Settings.polygonRadius, radius - Settings.polygonRadius);\n const tolerance = 0.5 * Settings.linearSlop;\n\n // Main iteration loop.\n const k_maxIters = 20;\n let iter = 0;\n while (iter < k_maxIters && v.length() - sigma > tolerance) {\n if (_ASSERT) console.assert(simplex.m_count < 3);\n\n output.iterations += 1;\n\n // Support in direction -v (A - B)\n indexA = proxyA.getSupport(Rot.mulTVec2(xfA.q, Vec2.neg(v)));\n wA = Transform.mulVec2(xfA, proxyA.getVertex(indexA));\n indexB = proxyB.getSupport(Rot.mulTVec2(xfB.q, v));\n wB = Transform.mulVec2(xfB, proxyB.getVertex(indexB));\n const p = Vec2.sub(wA, wB);\n\n // -v is a normal at p\n v.normalize();\n\n // Intersect ray with plane\n const vp = Vec2.dot(v, p);\n const vr = Vec2.dot(v, r);\n if (vp - sigma > lambda * vr) {\n if (vr <= 0.0) {\n return false;\n }\n\n lambda = (vp - sigma) / vr;\n if (lambda > 1.0) {\n return false;\n }\n\n n.setMul(-1, v);\n simplex.m_count = 0;\n }\n\n // Reverse simplex since it works with B - A.\n // Shift by lambda * r because we want the closest point to the current clip point.\n // Note that the support point p is not shifted because we want the plane equation\n // to be formed in unshifted space.\n const vertex = vertices[simplex.m_count];\n vertex.indexA = indexB;\n vertex.wA = Vec2.combine(1, wB, lambda, r);\n vertex.indexB = indexA;\n vertex.wB = wA;\n vertex.w = Vec2.sub(vertex.wB, vertex.wA);\n vertex.a = 1.0;\n simplex.m_count += 1;\n\n switch (simplex.m_count) {\n case 1:\n break;\n\n case 2:\n simplex.solve2();\n break;\n\n case 3:\n simplex.solve3();\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n }\n \n // If we have 3 points, then the origin is in the corresponding triangle.\n if (simplex.m_count == 3) {\n // Overlap\n return false;\n }\n\n // Get search direction.\n v.setVec2(simplex.getClosestPoint());\n\n // Iteration count is equated to the number of support point calls.\n ++iter;\n }\n\n if (iter == 0) {\n // Initial overlap\n return false;\n\t}\n\n // Prepare output.\n const pointA = Vec2.zero();\n const pointB = Vec2.zero();\n simplex.getWitnessPoints(pointB, pointA);\n\n if (v.lengthSquared() > 0.0) {\n n.setMul(-1, v);\n n.normalize();\n }\n\n output.point = Vec2.combine(1, pointA, radiusA, n);\n output.normal = n;\n output.lambda = lambda;\n output.iterations = iter;\n return true;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { stats } from \"../util/stats\";\nimport Timer from \"../util/Timer\";\nimport { Sweep } from \"../common/Sweep\";\nimport { Transform } from \"../common/Transform\";\nimport { Distance, DistanceInput, DistanceOutput, DistanceProxy, SimplexCache } from \"./Distance\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n\n\n/**\n * Input parameters for TimeOfImpact.\n */\nexport class TOIInput {\n proxyA = new DistanceProxy();\n proxyB = new DistanceProxy();\n sweepA = new Sweep();\n sweepB = new Sweep();\n /** defines sweep interval [0, tMax] */\n tMax: number;\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.sweepA.recycle();\n this.sweepB.recycle();\n this.tMax = -1;\n }\n}\n\nexport enum TOIOutputState {\n e_unset = -1,\n e_unknown = 0,\n e_failed = 1,\n e_overlapped = 2,\n e_touching = 3,\n e_separated = 4,\n}\n\n/**\n * Output parameters for TimeOfImpact.\n */\nexport class TOIOutput {\n state = TOIOutputState.e_unset;\n t = -1;\n recycle() {\n this.state = TOIOutputState.e_unset;\n this.t = -1;\n }\n}\n\nstats.toiTime = 0;\nstats.toiMaxTime = 0;\nstats.toiCalls = 0;\nstats.toiIters = 0;\nstats.toiMaxIters = 0;\nstats.toiRootIters = 0;\nstats.toiMaxRootIters = 0;\n\n/** @internal */ const distanceInput = new DistanceInput();\n/** @internal */ const distanceOutput = new DistanceOutput();\n// this is passed to Distance and SeparationFunction\n/** @internal */ const cache = new SimplexCache();\n\n/** @internal */ const xfA = matrix.transform(0, 0, 0);\n/** @internal */ const xfB = matrix.transform(0, 0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const axisA = matrix.vec2(0, 0);\n/** @internal */ const axisB = matrix.vec2(0, 0);\n/** @internal */ const localPointA = matrix.vec2(0, 0);\n/** @internal */ const localPointB = matrix.vec2(0, 0);\n\n\n/**\n * Compute the upper bound on time before two shapes penetrate. Time is\n * represented as a fraction between [0,tMax]. This uses a swept separating axis\n * and may miss some intermediate, non-tunneling collisions. If you change the\n * time interval, you should call this function again.\n *\n * Note: use Distance to compute the contact point and normal at the time of\n * impact.\n *\n * CCD via the local separating axis method. This seeks progression by computing\n * the largest time at which separation is maintained.\n */\nexport const TimeOfImpact = function (output: TOIOutput, input: TOIInput): void {\n const timer = Timer.now();\n\n ++stats.toiCalls;\n\n output.state = TOIOutputState.e_unknown;\n output.t = input.tMax;\n\n const proxyA = input.proxyA; // DistanceProxy\n const proxyB = input.proxyB; // DistanceProxy\n\n const sweepA = input.sweepA; // Sweep\n const sweepB = input.sweepB; // Sweep\n\n // Large rotations can make the root finder fail, so we normalize the\n // sweep angles.\n sweepA.normalize();\n sweepB.normalize();\n\n const tMax = input.tMax;\n\n const totalRadius = proxyA.m_radius + proxyB.m_radius;\n const target = math_max(Settings.linearSlop, totalRadius - 3.0 * Settings.linearSlop);\n const tolerance = 0.25 * Settings.linearSlop;\n if (_ASSERT) console.assert(target > tolerance);\n\n let t1 = 0.0;\n const k_maxIterations = Settings.maxTOIIterations;\n let iter = 0;\n\n // Prepare input for distance query.\n // const cache = new SimplexCache();\n cache.recycle();\n\n distanceInput.proxyA.setVertices(proxyA.m_vertices, proxyA.m_count, proxyA.m_radius);\n distanceInput.proxyB.setVertices(proxyB.m_vertices, proxyB.m_count, proxyB.m_radius);\n distanceInput.useRadii = false;\n\n // The outer loop progressively attempts to compute new separating axes.\n // This loop terminates when an axis is repeated (no progress is made).\n while (true) {\n sweepA.getTransform(xfA, t1);\n sweepB.getTransform(xfB, t1);\n\n // Get the distance between shapes. We can also use the results\n // to get a separating axis.\n matrix.copyTransform(distanceInput.transformA, xfA);\n matrix.copyTransform(distanceInput.transformB, xfB);\n Distance(distanceOutput, cache, distanceInput);\n\n // If the shapes are overlapped, we give up on continuous collision.\n if (distanceOutput.distance <= 0.0) {\n // Failure!\n output.state = TOIOutputState.e_overlapped;\n output.t = 0.0;\n break;\n }\n\n if (distanceOutput.distance < target + tolerance) {\n // Victory!\n output.state = TOIOutputState.e_touching;\n output.t = t1;\n break;\n }\n\n // Initialize the separating axis.\n separationFunction.initialize(cache, proxyA, sweepA, proxyB, sweepB, t1);\n\n // if (false) {\n // // Dump the curve seen by the root finder\n // const N = 100;\n // const dx = 1.0 / N;\n // const xs = []; // [ N + 1 ];\n // const fs = []; // [ N + 1 ];\n // const x = 0.0;\n // for (const i = 0; i <= N; ++i) {\n // sweepA.getTransform(xfA, x);\n // sweepB.getTransform(xfB, x);\n // const f = fcn.evaluate(xfA, xfB) - target;\n // printf(\"%g %g\\n\", x, f);\n // xs[i] = x;\n // fs[i] = f;\n // x += dx;\n // }\n // }\n\n // Compute the TOI on the separating axis. We do this by successively\n // resolving the deepest point. This loop is bounded by the number of\n // vertices.\n let done = false;\n let t2 = tMax;\n let pushBackIter = 0;\n while (true) {\n // Find the deepest point at t2. Store the witness point indices.\n let s2 = separationFunction.findMinSeparation(t2);\n\n // Is the final configuration separated?\n if (s2 > target + tolerance) {\n // Victory!\n output.state = TOIOutputState.e_separated;\n output.t = tMax;\n done = true;\n break;\n }\n\n // Has the separation reached tolerance?\n if (s2 > target - tolerance) {\n // Advance the sweeps\n t1 = t2;\n break;\n }\n\n // Compute the initial separation of the witness points.\n let s1 = separationFunction.evaluate(t1);\n\n // Check for initial overlap. This might happen if the root finder\n // runs out of iterations.\n if (s1 < target - tolerance) {\n output.state = TOIOutputState.e_failed;\n output.t = t1;\n done = true;\n break;\n }\n\n // Check for touching\n if (s1 <= target + tolerance) {\n // Victory! t1 should hold the TOI (could be 0.0).\n output.state = TOIOutputState.e_touching;\n output.t = t1;\n done = true;\n break;\n }\n\n // Compute 1D root of: f(x) - target = 0\n let rootIterCount = 0;\n let a1 = t1;\n let a2 = t2;\n while (true) {\n // Use a mix of the secant rule and bisection.\n let t;\n if (rootIterCount & 1) {\n // Secant rule to improve convergence.\n t = a1 + (target - s1) * (a2 - a1) / (s2 - s1);\n } else {\n // Bisection to guarantee progress.\n t = 0.5 * (a1 + a2);\n }\n\n ++rootIterCount;\n ++stats.toiRootIters;\n\n const s = separationFunction.evaluate(t);\n\n if (math_abs(s - target) < tolerance) {\n // t2 holds a tentative value for t1\n t2 = t;\n break;\n }\n\n // Ensure we continue to bracket the root.\n if (s > target) {\n a1 = t;\n s1 = s;\n } else {\n a2 = t;\n s2 = s;\n }\n\n if (rootIterCount === 50) {\n break;\n }\n }\n\n stats.toiMaxRootIters = math_max(stats.toiMaxRootIters, rootIterCount);\n\n ++pushBackIter;\n\n if (pushBackIter === Settings.maxPolygonVertices) {\n break;\n }\n }\n\n ++iter;\n ++stats.toiIters;\n\n if (done) {\n break;\n }\n\n if (iter === k_maxIterations) {\n // Root finder got stuck. Semi-victory.\n output.state = TOIOutputState.e_failed;\n output.t = t1;\n break;\n }\n }\n\n stats.toiMaxIters = math_max(stats.toiMaxIters, iter);\n\n const time = Timer.diff(timer);\n stats.toiMaxTime = math_max(stats.toiMaxTime, time);\n stats.toiTime += time;\n\n separationFunction.recycle();\n};\n\nenum SeparationFunctionType {\n e_unset = -1,\n e_points = 1,\n e_faceA = 2,\n e_faceB = 3,\n}\n\nclass SeparationFunction {\n // input cache\n // todo: maybe assign by copy instead of reference?\n m_proxyA: DistanceProxy = null;\n m_proxyB: DistanceProxy = null;\n m_sweepA: Sweep = null;\n m_sweepB: Sweep = null;\n\n // initialize cache\n m_type = SeparationFunctionType.e_unset;\n m_localPoint = matrix.vec2(0, 0);\n m_axis = matrix.vec2(0, 0);\n\n // compute output\n indexA = -1;\n indexB = -1;\n\n recycle() {\n this.m_proxyA = null;\n this.m_proxyB = null;\n this.m_sweepA = null;\n this.m_sweepB = null;\n\n this.m_type = SeparationFunctionType.e_unset;\n matrix.zeroVec2(this.m_localPoint);\n matrix.zeroVec2(this.m_axis);\n\n this.indexA = -1;\n this.indexB = -1;\n }\n\n // TODO_ERIN might not need to return the separation\n\n initialize(cache: SimplexCache, proxyA: DistanceProxy, sweepA: Sweep, proxyB: DistanceProxy, sweepB: Sweep, t1: number): number {\n const count = cache.count;\n if (_ASSERT) console.assert(0 < count && count < 3);\n\n this.m_proxyA = proxyA;\n this.m_proxyB = proxyB;\n this.m_sweepA = sweepA;\n this.m_sweepB = sweepB;\n\n this.m_sweepA.getTransform(xfA, t1);\n this.m_sweepB.getTransform(xfB, t1);\n\n if (count === 1) {\n this.m_type = SeparationFunctionType.e_points;\n const localPointA = this.m_proxyA.getVertex(cache.indexA[0]);\n const localPointB = this.m_proxyB.getVertex(cache.indexB[0]);\n matrix.transformVec2(pointA, xfA, localPointA);\n matrix.transformVec2(pointB, xfB, localPointB);\n matrix.subVec2(this.m_axis, pointB, pointA);\n const s = matrix.normalizeVec2Length(this.m_axis);\n return s;\n\n } else if (cache.indexA[0] === cache.indexA[1]) {\n // Two points on B and one on A.\n this.m_type = SeparationFunctionType.e_faceB;\n const localPointB1 = proxyB.getVertex(cache.indexB[0]);\n const localPointB2 = proxyB.getVertex(cache.indexB[1]);\n\n matrix.crossVec2Num(this.m_axis, matrix.subVec2(temp, localPointB2, localPointB1), 1.0);\n matrix.normalizeVec2(this.m_axis);\n matrix.rotVec2(normal, xfB.q, this.m_axis);\n\n matrix.combine2Vec2(this.m_localPoint, 0.5, localPointB1, 0.5, localPointB2);\n matrix.transformVec2(pointB, xfB, this.m_localPoint);\n\n const localPointA = proxyA.getVertex(cache.indexA[0]);\n const pointA = Transform.mulVec2(xfA, localPointA);\n\n let s = matrix.dotVec2(pointA, normal) - matrix.dotVec2(pointB, normal);\n if (s < 0.0) {\n matrix.negVec2(this.m_axis);\n s = -s;\n }\n return s;\n\n } else {\n // Two points on A and one or two points on B.\n this.m_type = SeparationFunctionType.e_faceA;\n const localPointA1 = this.m_proxyA.getVertex(cache.indexA[0]);\n const localPointA2 = this.m_proxyA.getVertex(cache.indexA[1]);\n\n matrix.crossVec2Num(this.m_axis, matrix.subVec2(temp, localPointA2, localPointA1), 1.0);\n matrix.normalizeVec2(this.m_axis);\n matrix.rotVec2(normal, xfA.q, this.m_axis);\n\n matrix.combine2Vec2(this.m_localPoint, 0.5, localPointA1, 0.5, localPointA2);\n matrix.transformVec2(pointA, xfA, this.m_localPoint);\n\n const localPointB = this.m_proxyB.getVertex(cache.indexB[0]);\n matrix.transformVec2(pointB, xfB, localPointB);\n\n let s = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal);\n if (s < 0.0) {\n matrix.negVec2(this.m_axis);\n s = -s;\n }\n return s;\n }\n }\n\n compute(find: boolean, t: number): number {\n // It was findMinSeparation and evaluate\n this.m_sweepA.getTransform(xfA, t);\n this.m_sweepB.getTransform(xfB, t);\n\n switch (this.m_type) {\n case SeparationFunctionType.e_points: {\n if (find) {\n matrix.derotVec2(axisA, xfA.q, this.m_axis);\n matrix.derotVec2(axisB, xfB.q, matrix.scaleVec2(temp, -1, this.m_axis));\n\n this.indexA = this.m_proxyA.getSupport(axisA);\n this.indexB = this.m_proxyB.getSupport(axisB);\n }\n\n matrix.copyVec2(localPointA, this.m_proxyA.getVertex(this.indexA));\n matrix.copyVec2(localPointB, this.m_proxyB.getVertex(this.indexB));\n\n matrix.transformVec2(pointA, xfA, localPointA);\n matrix.transformVec2(pointB, xfB, localPointB);\n\n const sep = matrix.dotVec2(pointB, this.m_axis) - matrix.dotVec2(pointA, this.m_axis);\n return sep;\n }\n\n case SeparationFunctionType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.m_axis);\n matrix.transformVec2(pointA, xfA, this.m_localPoint);\n\n if (find) {\n matrix.derotVec2(axisB, xfB.q, matrix.scaleVec2(temp, -1, normal));\n\n this.indexA = -1;\n this.indexB = this.m_proxyB.getSupport(axisB);\n }\n\n matrix.copyVec2(localPointB, this.m_proxyB.getVertex(this.indexB));\n matrix.transformVec2(pointB, xfB, localPointB);\n\n const sep = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal);\n return sep;\n }\n\n case SeparationFunctionType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.m_axis);\n matrix.transformVec2(pointB, xfB, this.m_localPoint);\n\n if (find) {\n matrix.derotVec2(axisA, xfA.q, matrix.scaleVec2(temp, -1, normal));\n\n this.indexB = -1;\n this.indexA = this.m_proxyA.getSupport(axisA);\n }\n\n matrix.copyVec2(localPointA, this.m_proxyA.getVertex(this.indexA));\n matrix.transformVec2(pointA, xfA, localPointA);\n\n const sep = matrix.dotVec2(pointA, normal) - matrix.dotVec2(pointB, normal);\n return sep;\n }\n\n default:\n if (_ASSERT) console.assert(false);\n if (find) {\n this.indexA = -1;\n this.indexB = -1;\n }\n return 0.0;\n }\n }\n\n findMinSeparation(t: number): number {\n return this.compute(true, t);\n }\n\n evaluate(t: number): number {\n return this.compute(false, t);\n }\n}\n\n/** @internal */ const separationFunction = new SeparationFunction();\n\n// legacy exports\nTimeOfImpact.Input = TOIInput;\nTimeOfImpact.Output = TOIOutput;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { EPSILON } from \"../common/Math\";\nimport { Body } from \"./Body\";\nimport type { Contact } from \"./Contact\";\nimport { Joint } from \"./Joint\";\nimport { TimeOfImpact, TOIInput, TOIOutput, TOIOutputState } from \"../collision/TimeOfImpact\";\nimport { Distance, DistanceInput, DistanceOutput, SimplexCache } from \"../collision/Distance\";\nimport { World } from \"./World\";\nimport { Sweep } from \"../common/Sweep\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_min = Math.min;\n\n\nexport class TimeStep {\n /** time step */\n dt: number = 0;\n /** inverse time step (0 if dt == 0) */\n inv_dt: number = 0;\n velocityIterations: number = 0;\n positionIterations: number = 0;\n warmStarting: boolean = false;\n blockSolve: boolean = true;\n\n /** timestep ratio for variable timestep */\n inv_dt0: number = 0.0;\n /** dt * inv_dt0 */\n dtRatio: number = 1;\n\n reset(dt: number): void {\n if (this.dt > 0.0) {\n this.inv_dt0 = this.inv_dt;\n }\n this.dt = dt;\n this.inv_dt = dt == 0 ? 0 : 1 / dt;\n this.dtRatio = dt * this.inv_dt0;\n }\n}\n\n// reuse\n/** @internal */ const s_subStep = new TimeStep();\n/** @internal */ const c = matrix.vec2(0, 0);\n/** @internal */ const v = matrix.vec2(0, 0);\n/** @internal */ const translation = matrix.vec2(0, 0);\n/** @internal */ const input = new TOIInput();\n/** @internal */ const output = new TOIOutput();\n/** @internal */ const backup = new Sweep();\n/** @internal */ const backup1 = new Sweep();\n/** @internal */ const backup2 = new Sweep();\n\n/**\n * Contact impulses for reporting. Impulses are used instead of forces because\n * sub-step forces may approach infinity for rigid body collisions. These match\n * up one-to-one with the contact points in Manifold.\n */\nexport class ContactImpulse {\n // TODO: merge with Contact class?\n\n private readonly contact: Contact;\n private readonly normals: number[];\n private readonly tangents: number[];\n\n constructor(contact: Contact) {\n this.contact = contact;\n this.normals = [];\n this.tangents = [];\n }\n\n recycle() {\n this.normals.length = 0;\n this.tangents.length = 0;\n }\n\n get normalImpulses(): number[] {\n const contact = this.contact;\n const normals = this.normals;\n normals.length = 0;\n for (let p = 0; p < contact.v_points.length; ++p) {\n normals.push(contact.v_points[p].normalImpulse);\n }\n return normals;\n }\n\n get tangentImpulses(): number[] {\n const contact = this.contact;\n const tangents = this.tangents;\n tangents.length = 0;\n for (let p = 0; p < contact.v_points.length; ++p) {\n tangents.push(contact.v_points[p].tangentImpulse);\n }\n return tangents;\n }\n}\n\n/**\n * Finds and solves islands. An island is a connected subset of the world.\n */\nexport class Solver {\n m_world: World;\n m_stack: Body[];\n m_bodies: Body[];\n m_contacts: Contact[];\n m_joints: Joint[];\n\n constructor(world: World) {\n this.m_world = world;\n this.m_stack = [];\n this.m_bodies = [];\n this.m_contacts = [];\n this.m_joints = [];\n }\n\n clear(): void {\n this.m_stack.length = 0;\n this.m_bodies.length = 0;\n this.m_contacts.length = 0;\n this.m_joints.length = 0;\n }\n\n addBody(body: Body): void {\n if (_ASSERT) console.assert(body instanceof Body, \"Not a Body!\", body);\n this.m_bodies.push(body);\n // why?\n // body.c_position.c.setZero();\n // body.c_position.a = 0;\n // body.c_velocity.v.setZero();\n // body.c_velocity.w = 0;\n }\n\n addContact(contact: Contact): void {\n // if (_ASSERT) console.assert(contact instanceof Contact, 'Not a Contact!', contact);\n this.m_contacts.push(contact);\n }\n\n addJoint(joint: Joint): void {\n if (_ASSERT) console.assert(joint instanceof Joint, \"Not a Joint!\", joint);\n this.m_joints.push(joint);\n }\n\n solveWorld(step: TimeStep): void {\n const world = this.m_world;\n\n // Clear all the island flags.\n for (let b = world.m_bodyList; b; b = b.m_next) {\n b.m_islandFlag = false;\n }\n for (let c = world.m_contactList; c; c = c.m_next) {\n c.m_islandFlag = false;\n }\n for (let j = world.m_jointList; j; j = j.m_next) {\n j.m_islandFlag = false;\n }\n\n // Build and simulate all awake islands.\n const stack = this.m_stack;\n let loop = -1;\n for (let seed = world.m_bodyList; seed; seed = seed.m_next) {\n loop++;\n if (seed.m_islandFlag) {\n continue;\n }\n\n if (seed.isAwake() == false || seed.isActive() == false) {\n continue;\n }\n\n // The seed can be dynamic or kinematic.\n if (seed.isStatic()) {\n continue;\n }\n\n // Reset island and stack.\n this.clear();\n\n stack.push(seed);\n\n seed.m_islandFlag = true;\n\n // Perform a depth first search (DFS) on the constraint graph.\n while (stack.length > 0) {\n // Grab the next body off the stack and add it to the island.\n const b = stack.pop();\n if (_ASSERT) console.assert(b.isActive() == true);\n this.addBody(b);\n\n // Make sure the body is awake (without resetting sleep timer).\n b.m_awakeFlag = true;\n\n // To keep islands as small as possible, we don't\n // propagate islands across static bodies.\n if (b.isStatic()) {\n continue;\n }\n\n // Search all contacts connected to this body.\n for (let ce = b.m_contactList; ce; ce = ce.next) {\n const contact = ce.contact;\n\n // Has this contact already been added to an island?\n if (contact.m_islandFlag) {\n continue;\n }\n\n // Is this contact solid and touching?\n if (contact.isEnabled() == false || contact.isTouching() == false) {\n continue;\n }\n\n // Skip sensors.\n const sensorA = contact.m_fixtureA.m_isSensor;\n const sensorB = contact.m_fixtureB.m_isSensor;\n if (sensorA || sensorB) {\n continue;\n }\n\n this.addContact(contact);\n contact.m_islandFlag = true;\n\n const other = ce.other;\n\n // Was the other body already added to this island?\n if (other.m_islandFlag) {\n continue;\n }\n\n // if (_ASSERT) console.assert(stack.length < world.m_bodyCount);\n stack.push(other);\n other.m_islandFlag = true;\n }\n\n // Search all joints connect to this body.\n for (let je = b.m_jointList; je; je = je.next) {\n if (je.joint.m_islandFlag == true) {\n continue;\n }\n\n const other = je.other;\n\n // Don't simulate joints connected to inactive bodies.\n if (other.isActive() == false) {\n continue;\n }\n\n this.addJoint(je.joint);\n je.joint.m_islandFlag = true;\n\n if (other.m_islandFlag) {\n continue;\n }\n\n // if (_ASSERT) console.assert(stack.length < world.m_bodyCount);\n stack.push(other);\n other.m_islandFlag = true;\n }\n }\n\n this.solveIsland(step);\n\n // Post solve cleanup.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n // Allow static bodies to participate in other islands.\n // TODO: are they added at all?\n const b = this.m_bodies[i];\n if (b.isStatic()) {\n b.m_islandFlag = false;\n }\n }\n }\n }\n\n solveIsland(step: TimeStep): void {\n // B2: Island Solve\n const world = this.m_world;\n const gravity = world.m_gravity;\n const allowSleep = world.m_allowSleep;\n\n const h = step.dt;\n\n // Integrate velocities and apply damping. Initialize the body state.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.m_sweep.c);\n const a = body.m_sweep.a;\n matrix.copyVec2(v, body.m_linearVelocity);\n let w = body.m_angularVelocity;\n\n // Store positions for continuous collision.\n matrix.copyVec2(body.m_sweep.c0, body.m_sweep.c);\n body.m_sweep.a0 = body.m_sweep.a;\n\n if (body.isDynamic()) {\n // Integrate velocities.\n matrix.plusScaleVec2(v, h * body.m_gravityScale, gravity);\n matrix.plusScaleVec2(v, h * body.m_invMass, body.m_force);\n w += h * body.m_invI * body.m_torque;\n /**\n *
\n         * Apply damping.\n         * ODE: dv/dt + c * v = 0\n         * Solution: v(t) = v0 * exp(-c * t)\n         * Time step: v(t + dt) = v0 * exp(-c * (t + dt)) = v0 * exp(-c * t) * exp(-c * dt) = v * exp(-c * dt)\n         * v2 = exp(-c * dt) * v1\n         * Pade approximation:\n         * v2 = v1 * 1 / (1 + c * dt)\n         * 
\n */\n matrix.scaleVec2(v, 1.0 / (1.0 + h * body.m_linearDamping), v);\n w *= 1.0 / (1.0 + h * body.m_angularDamping);\n }\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initConstraint(step);\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initVelocityConstraint(step);\n }\n\n if (step.warmStarting) {\n // Warm start.\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.warmStartConstraint(step);\n }\n }\n\n for (let i = 0; i < this.m_joints.length; ++i) {\n const joint = this.m_joints[i];\n joint.initVelocityConstraints(step);\n }\n\n // Solve velocity constraints\n for (let i = 0; i < step.velocityIterations; ++i) {\n for (let j = 0; j < this.m_joints.length; ++j) {\n const joint = this.m_joints[j];\n joint.solveVelocityConstraints(step);\n }\n\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n contact.solveVelocityConstraint(step);\n }\n }\n\n // Store impulses for warm starting\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.storeConstraintImpulses(step);\n }\n\n // Integrate positions\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.c_position.c);\n let a = body.c_position.a;\n matrix.copyVec2(v, body.c_velocity.v);\n let w = body.c_velocity.w;\n\n // Check for large velocities\n matrix.scaleVec2(translation, h, v);\n const translationLengthSqr = matrix.lengthSqrVec2(translation);\n if (translationLengthSqr > Settings.maxTranslationSquared) {\n const ratio = Settings.maxTranslation / math_sqrt(translationLengthSqr);\n matrix.mulVec2(v, ratio);\n }\n\n const rotation = h * w;\n if (rotation * rotation > Settings.maxRotationSquared) {\n const ratio = Settings.maxRotation / math_abs(rotation);\n w *= ratio;\n }\n\n // Integrate\n matrix.plusScaleVec2(c, h, v);\n a += h * w;\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n }\n\n // Solve position constraints\n let positionSolved = false;\n for (let i = 0; i < step.positionIterations; ++i) {\n let minSeparation = 0.0;\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n const separation = contact.solvePositionConstraint(step);\n minSeparation = math_min(minSeparation, separation);\n }\n // We can't expect minSpeparation >= -Settings.linearSlop because we don't\n // push the separation above -Settings.linearSlop.\n const contactsOkay = minSeparation >= -3.0 * Settings.linearSlop;\n\n let jointsOkay = true;\n for (let j = 0; j < this.m_joints.length; ++j) {\n const joint = this.m_joints[j];\n const jointOkay = joint.solvePositionConstraints(step);\n jointsOkay = jointsOkay && jointOkay;\n }\n\n if (contactsOkay && jointsOkay) {\n // Exit early if the position errors are small.\n positionSolved = true;\n break;\n }\n }\n\n // Copy state buffers back to the bodies\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(body.m_sweep.c, body.c_position.c);\n body.m_sweep.a = body.c_position.a;\n matrix.copyVec2(body.m_linearVelocity, body.c_velocity.v);\n body.m_angularVelocity = body.c_velocity.w;\n body.synchronizeTransform();\n }\n\n this.postSolveIsland();\n\n if (allowSleep) {\n let minSleepTime = Infinity;\n\n const linTolSqr = Settings.linearSleepToleranceSqr;\n const angTolSqr = Settings.angularSleepToleranceSqr;\n\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n if (body.isStatic()) {\n continue;\n }\n\n if ((body.m_autoSleepFlag == false)\n || (body.m_angularVelocity * body.m_angularVelocity > angTolSqr)\n || (matrix.lengthSqrVec2(body.m_linearVelocity) > linTolSqr)) {\n body.m_sleepTime = 0.0;\n minSleepTime = 0.0;\n } else {\n body.m_sleepTime += h;\n minSleepTime = math_min(minSleepTime, body.m_sleepTime);\n }\n }\n\n if (minSleepTime >= Settings.timeToSleep && positionSolved) {\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n body.setAwake(false);\n }\n }\n }\n }\n\n /**\n * Find TOI contacts and solve them.\n */\n solveWorldTOI(step: TimeStep): void {\n const world = this.m_world;\n\n if (world.m_stepComplete) {\n for (let b = world.m_bodyList; b; b = b.m_next) {\n b.m_islandFlag = false;\n b.m_sweep.alpha0 = 0.0;\n }\n\n for (let c = world.m_contactList; c; c = c.m_next) {\n // Invalidate TOI\n c.m_toiFlag = false;\n c.m_islandFlag = false;\n c.m_toiCount = 0;\n c.m_toi = 1.0;\n }\n }\n\n // Find TOI events and solve them.\n while (true) {\n // Find the first TOI.\n let minContact: Contact | null = null;\n let minAlpha = 1.0;\n\n for (let c = world.m_contactList; c; c = c.m_next) {\n // Is this contact disabled?\n if (c.isEnabled() == false) {\n continue;\n }\n\n // Prevent excessive sub-stepping.\n if (c.m_toiCount > Settings.maxSubSteps) {\n continue;\n }\n\n let alpha = 1.0;\n if (c.m_toiFlag) {\n // This contact has a valid cached TOI.\n alpha = c.m_toi;\n } else {\n const fA = c.getFixtureA();\n const fB = c.getFixtureB();\n\n // Is there a sensor?\n if (fA.isSensor() || fB.isSensor()) {\n continue;\n }\n\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n if (_ASSERT) console.assert(bA.isDynamic() || bB.isDynamic());\n\n const activeA = bA.isAwake() && !bA.isStatic();\n const activeB = bB.isAwake() && !bB.isStatic();\n\n // Is at least one body active (awake and dynamic or kinematic)?\n if (activeA == false && activeB == false) {\n continue;\n }\n\n const collideA = bA.isBullet() || !bA.isDynamic();\n const collideB = bB.isBullet() || !bB.isDynamic();\n\n // Are these two non-bullet dynamic bodies?\n if (collideA == false && collideB == false) {\n continue;\n }\n\n // Compute the TOI for this contact.\n // Put the sweeps onto the same time interval.\n let alpha0 = bA.m_sweep.alpha0;\n\n if (bA.m_sweep.alpha0 < bB.m_sweep.alpha0) {\n alpha0 = bB.m_sweep.alpha0;\n bA.m_sweep.advance(alpha0);\n } else if (bB.m_sweep.alpha0 < bA.m_sweep.alpha0) {\n alpha0 = bA.m_sweep.alpha0;\n bB.m_sweep.advance(alpha0);\n }\n\n if (_ASSERT) console.assert(alpha0 < 1.0);\n\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n\n const sweepA = bA.m_sweep;\n const sweepB = bB.m_sweep;\n\n // Compute the time of impact in interval [0, minTOI]\n input.proxyA.set(fA.getShape(), indexA);\n input.proxyB.set(fB.getShape(), indexB);\n input.sweepA.set(bA.m_sweep);\n input.sweepB.set(bB.m_sweep);\n input.tMax = 1.0;\n\n TimeOfImpact(output, input);\n\n // Beta is the fraction of the remaining portion of the [time?].\n const beta = output.t;\n if (output.state == TOIOutputState.e_touching) {\n alpha = math_min(alpha0 + (1.0 - alpha0) * beta, 1.0);\n } else {\n alpha = 1.0;\n }\n\n c.m_toi = alpha;\n c.m_toiFlag = true;\n }\n\n if (alpha < minAlpha) {\n // This is the minimum TOI found so far.\n minContact = c;\n minAlpha = alpha;\n }\n }\n\n if (minContact == null || 1.0 - 10.0 * EPSILON < minAlpha) {\n // No more TOI events. Done!\n world.m_stepComplete = true;\n break;\n }\n\n // Advance the bodies to the TOI.\n const fA = minContact.getFixtureA();\n const fB = minContact.getFixtureB();\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n backup1.set(bA.m_sweep);\n backup2.set(bB.m_sweep);\n\n bA.advance(minAlpha);\n bB.advance(minAlpha);\n\n // The TOI contact likely has some new contact points.\n minContact.update(world);\n minContact.m_toiFlag = false;\n ++minContact.m_toiCount;\n\n // Is the contact solid?\n if (minContact.isEnabled() == false || minContact.isTouching() == false) {\n // Restore the sweeps.\n minContact.setEnabled(false);\n bA.m_sweep.set(backup1);\n bB.m_sweep.set(backup2);\n bA.synchronizeTransform();\n bB.synchronizeTransform();\n continue;\n }\n\n bA.setAwake(true);\n bB.setAwake(true);\n\n // Build the island\n this.clear();\n this.addBody(bA);\n this.addBody(bB);\n this.addContact(minContact);\n\n bA.m_islandFlag = true;\n bB.m_islandFlag = true;\n minContact.m_islandFlag = true;\n\n // Get contacts on bodyA and bodyB.\n const bodies = [ bA, bB ];\n for (let i = 0; i < bodies.length; ++i) {\n const body = bodies[i];\n if (body.isDynamic()) {\n for (let ce = body.m_contactList; ce; ce = ce.next) {\n // if (this.m_bodyCount == this.m_bodyCapacity) { break; }\n // if (this.m_contactCount == this.m_contactCapacity) { break; }\n\n const contact = ce.contact;\n\n // Has this contact already been added to the island?\n if (contact.m_islandFlag) {\n continue;\n }\n\n // Only add if either is static, kinematic or bullet.\n const other = ce.other;\n if (other.isDynamic() && !body.isBullet() && !other.isBullet()) {\n continue;\n }\n\n // Skip sensors.\n const sensorA = contact.m_fixtureA.m_isSensor;\n const sensorB = contact.m_fixtureB.m_isSensor;\n if (sensorA || sensorB) {\n continue;\n }\n\n // Tentatively advance the body to the TOI.\n backup.set(other.m_sweep);\n if (other.m_islandFlag == false) {\n other.advance(minAlpha);\n }\n\n // Update the contact points\n contact.update(world);\n\n // Was the contact disabled by the user?\n // Are there contact points?\n if (contact.isEnabled() == false || contact.isTouching() == false) {\n other.m_sweep.set(backup);\n other.synchronizeTransform();\n continue;\n }\n\n // Add the contact to the island\n contact.m_islandFlag = true;\n this.addContact(contact);\n\n // Has the other body already been added to the island?\n if (other.m_islandFlag) {\n continue;\n }\n\n // Add the other body to the island.\n other.m_islandFlag = true;\n\n if (!other.isStatic()) {\n other.setAwake(true);\n }\n\n this.addBody(other);\n }\n }\n }\n\n s_subStep.reset((1.0 - minAlpha) * step.dt);\n s_subStep.dtRatio = 1.0;\n s_subStep.positionIterations = 20;\n s_subStep.velocityIterations = step.velocityIterations;\n s_subStep.warmStarting = false;\n\n this.solveIslandTOI(s_subStep, bA, bB);\n\n // Reset island flags and synchronize broad-phase proxies.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n body.m_islandFlag = false;\n\n if (!body.isDynamic()) {\n continue;\n }\n\n body.synchronizeFixtures();\n\n // Invalidate all contact TOIs on this displaced body.\n for (let ce = body.m_contactList; ce; ce = ce.next) {\n ce.contact.m_toiFlag = false;\n ce.contact.m_islandFlag = false;\n }\n }\n\n // Commit fixture proxy movements to the broad-phase so that new contacts\n // are created.\n // Also, some contacts can be destroyed.\n world.findNewContacts();\n\n if (world.m_subStepping) {\n world.m_stepComplete = false;\n break;\n }\n }\n }\n\n solveIslandTOI(subStep: TimeStep, toiA: Body, toiB: Body): void {\n\n // Initialize the body state.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n matrix.copyVec2(body.c_position.c, body.m_sweep.c);\n body.c_position.a = body.m_sweep.a;\n matrix.copyVec2(body.c_velocity.v, body.m_linearVelocity);\n body.c_velocity.w = body.m_angularVelocity;\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initConstraint(subStep);\n }\n\n // Solve position constraints.\n for (let i = 0; i < subStep.positionIterations; ++i) {\n let minSeparation = 0.0;\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n const separation = contact.solvePositionConstraintTOI(subStep, toiA, toiB);\n minSeparation = math_min(minSeparation, separation);\n }\n // We can't expect minSpeparation >= -Settings.linearSlop because we don't\n // push the separation above -Settings.linearSlop.\n const contactsOkay = minSeparation >= -1.5 * Settings.linearSlop;\n if (contactsOkay) {\n break;\n }\n }\n\n if (false) {\n // Is the new position really safe?\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const c = this.m_contacts[i];\n const fA = c.getFixtureA();\n const fB = c.getFixtureB();\n\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n\n const input = new DistanceInput();\n input.proxyA.set(fA.getShape(), indexA);\n input.proxyB.set(fB.getShape(), indexB);\n input.transformA.set(bA.getTransform());\n input.transformB.set(bB.getTransform());\n input.useRadii = false;\n\n const output = new DistanceOutput();\n const cache = new SimplexCache();\n Distance(output, cache, input);\n\n if (output.distance == 0 || cache.count == 3) {\n cache.count += 0;\n }\n }\n }\n\n // Leap of faith to new safe state.\n matrix.copyVec2(toiA.m_sweep.c0, toiA.c_position.c);\n toiA.m_sweep.a0 = toiA.c_position.a;\n matrix.copyVec2(toiB.m_sweep.c0, toiB.c_position.c);\n toiB.m_sweep.a0 = toiB.c_position.a;\n\n // No warm starting is needed for TOI events because warm\n // starting impulses were applied in the discrete solver.\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initVelocityConstraint(subStep);\n }\n\n // Solve velocity constraints.\n for (let i = 0; i < subStep.velocityIterations; ++i) {\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n contact.solveVelocityConstraint(subStep);\n }\n }\n\n // Don't store the TOI contact forces for warm starting\n // because they can be quite large.\n\n const h = subStep.dt;\n\n // Integrate positions\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.c_position.c);\n let a = body.c_position.a;\n matrix.copyVec2(v, body.c_velocity.v);\n let w = body.c_velocity.w;\n\n // Check for large velocities\n matrix.scaleVec2(translation, h, v);\n const translationLengthSqr = matrix.lengthSqrVec2(translation);\n if (translationLengthSqr > Settings.maxTranslationSquared) {\n const ratio = Settings.maxTranslation / math_sqrt(translationLengthSqr);\n matrix.mulVec2(v, ratio);\n }\n\n const rotation = h * w;\n if (rotation * rotation > Settings.maxRotationSquared) {\n const ratio = Settings.maxRotation / math_abs(rotation);\n w *= ratio;\n }\n\n // Integrate\n matrix.plusScaleVec2(c, h, v);\n a += h * w;\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n\n // Sync bodies\n matrix.copyVec2(body.m_sweep.c, c);\n body.m_sweep.a = a;\n matrix.copyVec2(body.m_linearVelocity, v);\n body.m_angularVelocity = w;\n body.synchronizeTransform();\n }\n\n this.postSolveIsland();\n }\n\n /** @internal */\n postSolveIsland(): void {\n for (let c = 0; c < this.m_contacts.length; ++c) {\n const contact = this.m_contacts[c];\n this.m_world.postSolve(contact, contact.m_impulse);\n }\n }\n}\n\n// @ts-ignore\nSolver.TimeStep = TimeStep;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A 2-by-2 matrix. Stored in column-major order.\n */\nexport class Mat22 {\n ex: Vec2;\n ey: Vec2;\n\n constructor(a: number, b: number, c: number, d: number);\n constructor(a: { x: number; y: number }, b: { x: number; y: number });\n constructor();\n constructor(a?, b?, c?, d?) {\n if (typeof a === \"object\" && a !== null) {\n this.ex = Vec2.clone(a);\n this.ey = Vec2.clone(b);\n } else if (typeof a === \"number\") {\n this.ex = Vec2.neo(a, c);\n this.ey = Vec2.neo(b, d);\n } else {\n this.ex = Vec2.zero();\n this.ey = Vec2.zero();\n }\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.ex) && Vec2.isValid(obj.ey);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Mat22.isValid(o), \"Invalid Mat22!\", o);\n }\n\n set(a: Mat22): void;\n set(a: Vec2Value, b: Vec2Value): void;\n set(a: number, b: number, c: number, d: number): void;\n set(a, b?, c?, d?): void {\n if (typeof a === \"number\" && typeof b === \"number\" && typeof c === \"number\"\n && typeof d === \"number\") {\n this.ex.setNum(a, c);\n this.ey.setNum(b, d);\n\n } else if (typeof a === \"object\" && typeof b === \"object\") {\n this.ex.setVec2(a);\n this.ey.setVec2(b);\n\n } else if (typeof a === \"object\") {\n if (_ASSERT) Mat22.assert(a);\n this.ex.setVec2(a.ex);\n this.ey.setVec2(a.ey);\n\n } else {\n if (_ASSERT) console.assert(false);\n }\n }\n\n setIdentity(): void {\n this.ex.x = 1.0;\n this.ey.x = 0.0;\n this.ex.y = 0.0;\n this.ey.y = 1.0;\n }\n\n setZero(): void {\n this.ex.x = 0.0;\n this.ey.x = 0.0;\n this.ex.y = 0.0;\n this.ey.y = 0.0;\n }\n\n getInverse(): Mat22 {\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const imx = new Mat22();\n imx.ex.x = det * d;\n imx.ey.x = -det * b;\n imx.ex.y = -det * c;\n imx.ey.y = det * a;\n return imx;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases.\n */\n solve(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const w = Vec2.zero();\n w.x = det * (d * v.x - b * v.y);\n w.y = det * (a * v.y - c * v.x);\n return w;\n }\n\n /**\n * Multiply a matrix times a vector. If a rotation matrix is provided, then this\n * transforms the vector from one frame to another.\n */\n static mul(mx: Mat22, my: Mat22): Mat22;\n static mul(mx: Mat22, v: Vec2Value): Vec2;\n static mul(mx, v) {\n if (v && \"x\" in v && \"y\" in v) {\n if (_ASSERT) Vec2.assert(v);\n const x = mx.ex.x * v.x + mx.ey.x * v.y;\n const y = mx.ex.y * v.x + mx.ey.y * v.y;\n return Vec2.neo(x, y);\n\n } else if (v && \"ex\" in v && \"ey\" in v) { // Mat22\n if (_ASSERT) Mat22.assert(v);\n // return new Mat22(Vec2.mul(mx, v.ex), Vec2.mul(mx, v.ey));\n const a = mx.ex.x * v.ex.x + mx.ey.x * v.ex.y;\n const b = mx.ex.x * v.ey.x + mx.ey.x * v.ey.y;\n const c = mx.ex.y * v.ex.x + mx.ey.y * v.ex.y;\n const d = mx.ex.y * v.ey.x + mx.ey.y * v.ey.y;\n return new Mat22(a, b, c, d);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulVec2(mx: Mat22, v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n const x = mx.ex.x * v.x + mx.ey.x * v.y;\n const y = mx.ex.y * v.x + mx.ey.y * v.y;\n return Vec2.neo(x, y);\n }\n\n static mulMat22(mx: Mat22, v: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(v);\n // return new Mat22(Vec2.mul(mx, v.ex), Vec2.mul(mx, v.ey));\n const a = mx.ex.x * v.ex.x + mx.ey.x * v.ex.y;\n const b = mx.ex.x * v.ey.x + mx.ey.x * v.ey.y;\n const c = mx.ex.y * v.ex.x + mx.ey.y * v.ex.y;\n const d = mx.ex.y * v.ey.x + mx.ey.y * v.ey.y;\n return new Mat22(a, b, c, d);\n }\n\n /**\n * Multiply a matrix transpose times a vector. If a rotation matrix is provided,\n * then this transforms the vector from one frame to another (inverse\n * transform).\n */\n static mulT(mx: Mat22, my: Mat22): Mat22;\n static mulT(mx: Mat22, v: Vec2Value): Vec2;\n static mulT(mx, v) {\n if (v && \"x\" in v && \"y\" in v) { // Vec2\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(Vec2.dot(v, mx.ex), Vec2.dot(v, mx.ey));\n\n } else if (v && \"ex\" in v && \"ey\" in v) { // Mat22\n if (_ASSERT) Mat22.assert(v);\n const c1 = Vec2.neo(Vec2.dot(mx.ex, v.ex), Vec2.dot(mx.ey, v.ex));\n const c2 = Vec2.neo(Vec2.dot(mx.ex, v.ey), Vec2.dot(mx.ey, v.ey));\n return new Mat22(c1, c2);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulTVec2(mx: Mat22, v: Vec2Value): Vec2 {\n if (_ASSERT) Mat22.assert(mx);\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(Vec2.dot(v, mx.ex), Vec2.dot(v, mx.ey));\n }\n\n static mulTMat22(mx: Mat22, v: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx);\n if (_ASSERT) Mat22.assert(v);\n const c1 = Vec2.neo(Vec2.dot(mx.ex, v.ex), Vec2.dot(mx.ey, v.ex));\n const c2 = Vec2.neo(Vec2.dot(mx.ex, v.ey), Vec2.dot(mx.ey, v.ey));\n return new Mat22(c1, c2);\n }\n\n static abs(mx: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx);\n return new Mat22(Vec2.abs(mx.ex), Vec2.abs(mx.ey));\n }\n\n static add(mx1: Mat22, mx2: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx1);\n if (_ASSERT) Mat22.assert(mx2);\n return new Mat22(Vec2.add(mx1.ex, mx2.ex), Vec2.add(mx1.ey, mx2.ey));\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { Vec2Value } from \"../common/Vec2\";\nimport { TransformValue } from \"../common/Transform\";\nimport { EPSILON } from \"../common/Math\";\n\n\n/** @internal */ const math_sqrt = Math.sqrt;\n\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const cA = matrix.vec2(0, 0);\n/** @internal */ const cB = matrix.vec2(0, 0);\n/** @internal */ const dist = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const clipPoint = matrix.vec2(0, 0);\n\nexport enum ManifoldType {\n e_unset = -1,\n e_circles = 0,\n e_faceA = 1,\n e_faceB = 2\n}\n\nexport enum ContactFeatureType {\n e_unset = -1,\n e_vertex = 0,\n e_face = 1\n}\n\n/**\n * This is used for determining the state of contact points.\n */\n export enum PointState {\n /** Point does not exist */\n nullState = 0,\n /** Point was added in the update */\n addState = 1,\n /** Point persisted across the update */\n persistState = 2,\n /** Point was removed in the update */\n removeState = 3\n}\n\n/**\n * Used for computing contact manifolds.\n */\n export class ClipVertex {\n v = matrix.vec2(0, 0);\n id: ContactID = new ContactID();\n\n set(o: ClipVertex): void {\n matrix.copyVec2(this.v, o.v);\n this.id.set(o.id);\n }\n recycle() {\n matrix.zeroVec2(this.v);\n this.id.recycle();\n }\n}\n\n/**\n * A manifold for two touching convex shapes. Manifolds are created in `evaluate`\n * method of Contact subclasses.\n *\n * Supported manifold types are e_faceA or e_faceB for clip point versus plane\n * with radius and e_circles point versus point with radius.\n *\n * We store contacts in this way so that position correction can account for\n * movement, which is critical for continuous physics. All contact scenarios\n * must be expressed in one of these types. This structure is stored across time\n * steps, so we keep it small.\n */\nexport class Manifold {\n type: ManifoldType;\n\n /**\n * Usage depends on manifold type:\n * - circles: not used\n * - faceA: the normal on polygonA\n * - faceB: the normal on polygonB\n */\n localNormal = matrix.vec2(0, 0);\n\n /**\n * Usage depends on manifold type:\n * - circles: the local center of circleA\n * - faceA: the center of faceA\n * - faceB: the center of faceB\n */\n localPoint = matrix.vec2(0, 0);\n\n /** The points of contact */\n points: ManifoldPoint[] = [ new ManifoldPoint(), new ManifoldPoint() ];\n\n /** The number of manifold points */\n pointCount: number = 0;\n\n set(that: Manifold): void {\n this.type = that.type;\n matrix.copyVec2(this.localNormal, that.localNormal);\n matrix.copyVec2(this.localPoint, that.localPoint);\n this.pointCount = that.pointCount;\n this.points[0].set(that.points[0]);\n this.points[1].set(that.points[1]);\n }\n\n recycle(): void {\n this.type = ManifoldType.e_unset;\n matrix.zeroVec2(this.localNormal);\n matrix.zeroVec2(this.localPoint);\n this.pointCount = 0;\n this.points[0].recycle();\n this.points[1].recycle();\n }\n\n /**\n * Evaluate the manifold with supplied transforms. This assumes modest motion\n * from the original state. This does not change the point count, impulses, etc.\n * The radii must come from the shapes that generated the manifold.\n */\n getWorldManifold(wm: WorldManifold | null, xfA: TransformValue, radiusA: number, xfB: TransformValue, radiusB: number): WorldManifold {\n if (this.pointCount == 0) {\n return wm;\n }\n\n wm = wm || new WorldManifold();\n\n wm.pointCount = this.pointCount;\n\n const normal = wm.normal;\n const points = wm.points;\n const separations = wm.separations;\n\n switch (this.type) {\n case ManifoldType.e_circles: {\n matrix.setVec2(normal, 1.0, 0.0);\n const manifoldPoint = this.points[0];\n matrix.transformVec2(pointA, xfA, this.localPoint);\n matrix.transformVec2(pointB, xfB, manifoldPoint.localPoint);\n matrix.subVec2(dist, pointB, pointA);\n const lengthSqr = matrix.lengthSqrVec2(dist);\n if (lengthSqr > EPSILON * EPSILON) {\n const length = math_sqrt(lengthSqr);\n matrix.scaleVec2(normal, 1 / length, dist);\n }\n matrix.combine2Vec2(cA, 1, pointA, radiusA, normal);\n matrix.combine2Vec2(cB, 1, pointB, -radiusB, normal);\n matrix.combine2Vec2(points[0], 0.5, cA, 0.5, cB);\n separations[0] = matrix.dotVec2(matrix.subVec2(temp, cB, cA), normal);\n break;\n }\n\n case ManifoldType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.localNormal);\n matrix.transformVec2(planePoint, xfA, this.localPoint);\n\n for (let i = 0; i < this.pointCount; ++i) {\n const manifoldPoint = this.points[i];\n matrix.transformVec2(clipPoint, xfB, manifoldPoint.localPoint);\n matrix.combine2Vec2(cA, 1, clipPoint, radiusA - matrix.dotVec2(matrix.subVec2(temp, clipPoint, planePoint), normal), normal);\n matrix.combine2Vec2(cB, 1, clipPoint, -radiusB, normal);\n matrix.combine2Vec2(points[i], 0.5, cA, 0.5, cB);\n separations[i] = matrix.dotVec2(matrix.subVec2(temp, cB, cA), normal);\n }\n break;\n }\n\n case ManifoldType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.localNormal);\n matrix.transformVec2(planePoint, xfB, this.localPoint);\n\n for (let i = 0; i < this.pointCount; ++i) {\n const manifoldPoint = this.points[i];\n matrix.transformVec2(clipPoint, xfA, manifoldPoint.localPoint);\n matrix.combine2Vec2(cB, 1, clipPoint, radiusB - matrix.dotVec2(matrix.subVec2(temp, clipPoint, planePoint), normal), normal);\n matrix.combine2Vec2(cA, 1, clipPoint, -radiusA, normal);\n matrix.combine2Vec2(points[i], 0.5, cA, 0.5, cB);\n separations[i] = matrix.dotVec2(matrix.subVec2(temp, cA, cB), normal);\n }\n // Ensure normal points from A to B.\n matrix.negVec2(normal);\n break;\n }\n }\n\n return wm;\n }\n\n static clipSegmentToLine = clipSegmentToLine;\n static ClipVertex = ClipVertex;\n static getPointStates = getPointStates;\n static PointState = PointState;\n}\n\n/**\n * A manifold point is a contact point belonging to a contact manifold. It holds\n * details related to the geometry and dynamics of the contact points.\n *\n * This structure is stored across time steps, so we keep it small.\n *\n * Note: impulses are used for internal caching and may not provide reliable\n * contact forces, especially for high speed collisions.\n */\nexport class ManifoldPoint {\n /**\n * Usage depends on manifold type:\n * - circles: the local center of circleB\n * - faceA: the local center of circleB or the clip point of polygonB\n * - faceB: the clip point of polygonA\n */\n localPoint = matrix.vec2(0, 0);\n /**\n * The non-penetration impulse\n */\n normalImpulse = 0;\n /**\n * The friction impulse\n */\n tangentImpulse = 0;\n /**\n * Uniquely identifies a contact point between two shapes to facilitate warm starting\n */\n readonly id = new ContactID();\n\n set(that: ManifoldPoint): void {\n matrix.copyVec2(this.localPoint, that.localPoint);\n this.normalImpulse = that.normalImpulse;\n this.tangentImpulse = that.tangentImpulse;\n this.id.set(that.id);\n }\n\n recycle(): void {\n matrix.zeroVec2(this.localPoint);\n this.normalImpulse = 0;\n this.tangentImpulse = 0;\n this.id.recycle();\n }\n}\n\n/**\n * Contact ids to facilitate warm starting.\n * \n * ContactFeature: The features that intersect to form the contact point.\n */\nexport class ContactID {\n\n /**\n * Used to quickly compare contact ids.\n */\n key = -1;\n\n /** ContactFeature index on shapeA */\n indexA = -1;\n\n /** ContactFeature index on shapeB */\n indexB = -1;\n\n /** ContactFeature type on shapeA */\n typeA = ContactFeatureType.e_unset;\n\n /** ContactFeature type on shapeB */\n typeB = ContactFeatureType.e_unset;\n\n setFeatures(indexA: number, typeA: ContactFeatureType, indexB: number, typeB: ContactFeatureType): void {\n this.indexA = indexA;\n this.indexB = indexB;\n this.typeA = typeA;\n this.typeB = typeB;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n set(that: ContactID): void {\n this.indexA = that.indexA;\n this.indexB = that.indexB;\n this.typeA = that.typeA;\n this.typeB = that.typeB;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n swapFeatures(): void {\n const indexA = this.indexA;\n const indexB = this.indexB;\n const typeA = this.typeA;\n const typeB = this.typeB;\n this.indexA = indexB;\n this.indexB = indexA;\n this.typeA = typeB;\n this.typeB = typeA;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n recycle(): void {\n this.indexA = 0;\n this.indexB = 0;\n this.typeA = ContactFeatureType.e_unset;\n this.typeB = ContactFeatureType.e_unset;\n this.key = -1;\n }\n}\n\n/**\n * This is used to compute the current state of a contact manifold.\n */\nexport class WorldManifold {\n /** World vector pointing from A to B */\n normal = matrix.vec2(0, 0);\n\n /** World contact point (point of intersection) */\n points = [matrix.vec2(0, 0), matrix.vec2(0, 0)]; // [maxManifoldPoints]\n\n /** A negative value indicates overlap, in meters */\n separations = [0, 0]; // [maxManifoldPoints]\n\n /** The number of manifold points */\n pointCount = 0;\n\n recycle() {\n matrix.zeroVec2(this.normal);\n matrix.zeroVec2(this.points[0]);\n matrix.zeroVec2(this.points[1]);\n this.separations[0] = 0;\n this.separations[1] = 0;\n this.pointCount = 0;\n }\n}\n\n/**\n * Compute the point states given two manifolds. The states pertain to the\n * transition from manifold1 to manifold2. So state1 is either persist or remove\n * while state2 is either add or persist.\n */\nexport function getPointStates(\n state1: PointState[],\n state2: PointState[],\n manifold1: Manifold,\n manifold2: Manifold\n): void {\n // state1, state2: PointState[Settings.maxManifoldPoints]\n\n // for (var i = 0; i < Settings.maxManifoldPoints; ++i) {\n // state1[i] = PointState.nullState;\n // state2[i] = PointState.nullState;\n // }\n\n // Detect persists and removes.\n for (let i = 0; i < manifold1.pointCount; ++i) {\n const id = manifold1.points[i].id;\n\n state1[i] = PointState.removeState;\n\n for (let j = 0; j < manifold2.pointCount; ++j) {\n if (manifold2.points[j].id.key === id.key) {\n state1[i] = PointState.persistState;\n break;\n }\n }\n }\n\n // Detect persists and adds.\n for (let i = 0; i < manifold2.pointCount; ++i) {\n const id = manifold2.points[i].id;\n\n state2[i] = PointState.addState;\n\n for (let j = 0; j < manifold1.pointCount; ++j) {\n if (manifold1.points[j].id.key === id.key) {\n state2[i] = PointState.persistState;\n break;\n }\n }\n }\n}\n\n/**\n * Clipping for contact manifolds. Sutherland-Hodgman clipping.\n */\nexport function clipSegmentToLine(\n vOut: ClipVertex[],\n vIn: ClipVertex[],\n normal: Vec2Value,\n offset: number,\n vertexIndexA: number\n): number {\n // Start with no output points\n let numOut = 0;\n\n // Calculate the distance of end points to the line\n const distance0 = matrix.dotVec2(normal, vIn[0].v) - offset;\n const distance1 = matrix.dotVec2(normal, vIn[1].v) - offset;\n\n // If the points are behind the plane\n if (distance0 <= 0.0)\n vOut[numOut++].set(vIn[0]);\n if (distance1 <= 0.0)\n vOut[numOut++].set(vIn[1]);\n\n // If the points are on different sides of the plane\n if (distance0 * distance1 < 0.0) {\n // Find intersection point of edge and plane\n const interp = distance0 / (distance0 - distance1);\n matrix.combine2Vec2(vOut[numOut].v, 1 - interp, vIn[0].v, interp, vIn[1].v);\n\n // VertexA is hitting edgeB.\n vOut[numOut].id.setFeatures(vertexIndexA, ContactFeatureType.e_vertex, vIn[0].id.indexB, ContactFeatureType.e_face);\n ++numOut;\n }\n\n return numOut;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { ShapeType } from \"../collision/Shape\";\nimport { clamp } from \"../common/Math\";\nimport { TransformValue } from \"../common/Transform\";\nimport { Mat22 } from \"../common/Mat22\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { Manifold, ManifoldType, WorldManifold } from \"../collision/Manifold\";\nimport { testOverlap } from \"../collision/Distance\";\nimport { Fixture } from \"./Fixture\";\nimport { Body } from \"./Body\";\nimport { ContactImpulse, TimeStep } from \"./Solver\";\nimport { Pool } from \"../util/Pool\";\nimport { getTransform } from \"./Position\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n// Solver debugging is normally disabled because the block solver sometimes has to deal with a poorly conditioned effective mass matrix.\n/** @internal */ const DEBUG_SOLVER = false;\n\n/** @internal */ const contactPool = new Pool({\n create() {\n return new Contact();\n },\n release(contact: Contact) {\n contact.recycle();\n }\n});\n\n/** @internal */ const oldManifold = new Manifold();\n\n/** @internal */ const worldManifold = new WorldManifold();\n\n/**\n * A contact edge is used to connect bodies and contacts together in a contact\n * graph where each body is a node and each contact is an edge. A contact edge\n * belongs to a doubly linked list maintained in each attached body. Each\n * contact has two contact nodes, one for each attached body.\n */\nexport class ContactEdge {\n contact: Contact;\n prev: ContactEdge | null = null;\n next: ContactEdge | null = null;\n other: Body | null = null;\n constructor(contact: Contact) {\n this.contact = contact;\n }\n\n /** @internal */\n recycle() {\n this.prev = null;\n this.next = null;\n this.other = null;\n }\n}\n\nexport type EvaluateFunction = (\n manifold: Manifold,\n xfA: TransformValue,\n fixtureA: Fixture,\n indexA: number,\n xfB: TransformValue,\n fixtureB: Fixture,\n indexB: number\n) => void;\n\n/**\n * Friction mixing law. The idea is to allow either fixture to drive the\n * friction to zero. For example, anything slides on ice.\n */\nexport function mixFriction(friction1: number, friction2: number): number {\n return math_sqrt(friction1 * friction2);\n}\n\n/**\n * Restitution mixing law. The idea is allow for anything to bounce off an\n * inelastic surface. For example, a superball bounces on anything.\n */\nexport function mixRestitution(restitution1: number, restitution2: number): number {\n return restitution1 > restitution2 ? restitution1 : restitution2;\n}\n\n// TODO: move this to Settings?\n/** @internal */ const s_registers = [];\n\n// TODO: merge with ManifoldPoint?\nexport class VelocityConstraintPoint {\n rA = matrix.vec2(0, 0);\n rB = matrix.vec2(0, 0);\n normalImpulse = 0;\n tangentImpulse = 0;\n normalMass = 0;\n tangentMass = 0;\n velocityBias = 0;\n\n recycle() {\n matrix.zeroVec2(this.rA);\n matrix.zeroVec2(this.rB);\n this.normalImpulse = 0;\n this.tangentImpulse = 0;\n this.normalMass = 0;\n this.tangentMass = 0;\n this.velocityBias = 0;\n }\n}\n\n/** @internal */ const cA = matrix.vec2(0, 0);\n/** @internal */ const vA = matrix.vec2(0, 0);\n/** @internal */ const cB = matrix.vec2(0, 0);\n/** @internal */ const vB = matrix.vec2(0, 0);\n/** @internal */ const tangent = matrix.vec2(0, 0);\n/** @internal */ const xfA = matrix.transform(0, 0, 0);\n/** @internal */ const xfB = matrix.transform(0, 0, 0);\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const clipPoint = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const rA = matrix.vec2(0, 0);\n/** @internal */ const rB = matrix.vec2(0, 0);\n/** @internal */ const P = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const point = matrix.vec2(0, 0);\n/** @internal */ const dv = matrix.vec2(0, 0);\n/** @internal */ const dv1 = matrix.vec2(0, 0);\n/** @internal */ const dv2 = matrix.vec2(0, 0);\n/** @internal */ const b = matrix.vec2(0, 0);\n/** @internal */ const a = matrix.vec2(0, 0);\n/** @internal */ const x = matrix.vec2(0, 0);\n/** @internal */ const d = matrix.vec2(0, 0);\n/** @internal */ const P1 = matrix.vec2(0, 0);\n/** @internal */ const P2 = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n\n/**\n * The class manages contact between two shapes. A contact exists for each\n * overlapping AABB in the broad-phase (except if filtered). Therefore a contact\n * object may exist that has no contact points.\n */\nexport class Contact {\n // Nodes for connecting bodies.\n /** @internal */ m_nodeA = new ContactEdge(this);\n /** @internal */ m_nodeB = new ContactEdge(this);\n /** @internal */ m_fixtureA: Fixture | null = null;\n /** @internal */ m_fixtureB: Fixture | null = null;\n /** @internal */ m_indexA = -1;\n /** @internal */ m_indexB = -1;\n /** @internal */ m_evaluateFcn: EvaluateFunction | null = null;\n /** @internal */ m_manifold: Manifold = new Manifold();\n /** @internal */ m_prev: Contact | null = null;\n /** @internal */ m_next: Contact | null = null;\n /** @internal */ m_toi = 1.0;\n /** @internal */ m_toiCount = 0;\n // This contact has a valid TOI in m_toi\n /** @internal */ m_toiFlag = false;\n /** @internal */ m_friction = 0.0;\n /** @internal */ m_restitution = 0.0;\n /** @internal */ m_tangentSpeed = 0.0;\n /** @internal This contact can be disabled (by user) */\n m_enabledFlag = true;\n /** @internal Used when crawling contact graph when forming islands. */\n m_islandFlag = false;\n /** @internal Set when the shapes are touching. */\n m_touchingFlag = false;\n /** @internal This contact needs filtering because a fixture filter was changed. */\n m_filterFlag = false;\n /** @internal This bullet contact had a TOI event */\n m_bulletHitFlag = false;\n\n /** @internal Contact reporting impulse object cache */\n m_impulse: ContactImpulse = new ContactImpulse(this);\n\n // VelocityConstraint\n /** @internal */ v_points = [new VelocityConstraintPoint(), new VelocityConstraintPoint()]; // [maxManifoldPoints];\n /** @internal */ v_normal = matrix.vec2(0, 0);\n /** @internal */ v_normalMass: Mat22 = new Mat22();\n /** @internal */ v_K: Mat22 = new Mat22();\n /** @internal */ v_pointCount = 0;\n /** @internal */ v_tangentSpeed = 0;\n /** @internal */ v_friction = 0;\n /** @internal */ v_restitution = 0;\n /** @internal */ v_invMassA = 0;\n /** @internal */ v_invMassB = 0;\n /** @internal */ v_invIA = 0;\n /** @internal */ v_invIB = 0;\n\n // PositionConstraint\n /** @internal */ p_localPoints = [matrix.vec2(0, 0), matrix.vec2(0, 0)]; // [maxManifoldPoints];\n /** @internal */ p_localNormal = matrix.vec2(0, 0);\n /** @internal */ p_localPoint = matrix.vec2(0, 0);\n /** @internal */ p_localCenterA = matrix.vec2(0, 0);\n /** @internal */ p_localCenterB = matrix.vec2(0, 0);\n /** @internal */ p_type = ManifoldType.e_unset;\n /** @internal */ p_radiusA = 0;\n /** @internal */ p_radiusB = 0;\n /** @internal */ p_pointCount = 0;\n /** @internal */ p_invMassA = 0;\n /** @internal */ p_invMassB = 0;\n /** @internal */ p_invIA = 0;\n /** @internal */ p_invIB = 0;\n\n /** @internal */ \n initialize(fA: Fixture, indexA: number, fB: Fixture, indexB: number, evaluateFcn: EvaluateFunction) {\n this.m_fixtureA = fA;\n this.m_fixtureB = fB;\n\n this.m_indexA = indexA;\n this.m_indexB = indexB;\n\n this.m_evaluateFcn = evaluateFcn;\n\n this.m_friction = mixFriction(this.m_fixtureA.m_friction, this.m_fixtureB.m_friction);\n this.m_restitution = mixRestitution(this.m_fixtureA.m_restitution, this.m_fixtureB.m_restitution);\n }\n\n /** @internal */ \n recycle() {\n this.m_nodeA.recycle();\n this.m_nodeB.recycle();\n this.m_fixtureA = null;\n this.m_fixtureB = null;\n this.m_indexA = -1;\n this.m_indexB = -1;\n this.m_evaluateFcn = null;\n this.m_manifold.recycle();\n this.m_prev = null;\n this.m_next = null;\n this.m_toi = 1;\n this.m_toiCount = 0;\n this.m_toiFlag = false;\n this.m_friction = 0;\n this.m_restitution = 0;\n this.m_tangentSpeed = 0;\n this.m_enabledFlag = true;\n this.m_islandFlag = false;\n this.m_touchingFlag = false;\n this.m_filterFlag = false;\n this.m_bulletHitFlag = false;\n\n this.m_impulse.recycle();\n\n // VelocityConstraint\n for(const point of this.v_points) {\n point.recycle();\n }\n matrix.zeroVec2(this.v_normal);\n this.v_normalMass.setZero();\n this.v_K.setZero();\n this.v_pointCount = 0;\n this.v_tangentSpeed = 0;\n this.v_friction = 0;\n this.v_restitution = 0;\n this.v_invMassA = 0;\n this.v_invMassB = 0;\n this.v_invIA = 0;\n this.v_invIB = 0;\n\n // PositionConstraint\n for(const point of this.p_localPoints) {\n matrix.zeroVec2(point);\n }\n matrix.zeroVec2(this.p_localNormal);\n matrix.zeroVec2(this.p_localPoint);\n matrix.zeroVec2(this.p_localCenterA);\n matrix.zeroVec2(this.p_localCenterB);\n this.p_type = ManifoldType.e_unset;\n this.p_radiusA = 0;\n this.p_radiusB = 0;\n this.p_pointCount = 0;\n this.p_invMassA = 0;\n this.p_invMassB = 0;\n this.p_invIA = 0;\n this.p_invIB = 0;\n }\n\n initConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n const manifold = this.m_manifold;\n\n const pointCount = manifold.pointCount;\n if (_ASSERT) console.assert(pointCount > 0);\n\n this.v_invMassA = bodyA.m_invMass;\n this.v_invMassB = bodyB.m_invMass;\n this.v_invIA = bodyA.m_invI;\n this.v_invIB = bodyB.m_invI;\n\n this.v_friction = this.m_friction;\n this.v_restitution = this.m_restitution;\n this.v_tangentSpeed = this.m_tangentSpeed;\n\n this.v_pointCount = pointCount;\n\n this.v_K.setZero();\n this.v_normalMass.setZero();\n\n this.p_invMassA = bodyA.m_invMass;\n this.p_invMassB = bodyB.m_invMass;\n this.p_invIA = bodyA.m_invI;\n this.p_invIB = bodyB.m_invI;\n matrix.copyVec2(this.p_localCenterA, bodyA.m_sweep.localCenter);\n matrix.copyVec2(this.p_localCenterB, bodyB.m_sweep.localCenter);\n\n this.p_radiusA = shapeA.m_radius;\n this.p_radiusB = shapeB.m_radius;\n\n this.p_type = manifold.type;\n matrix.copyVec2(this.p_localNormal, manifold.localNormal);\n matrix.copyVec2(this.p_localPoint, manifold.localPoint);\n this.p_pointCount = pointCount;\n\n for (let j = 0; j < Settings.maxManifoldPoints; ++j) {\n this.v_points[j].recycle();\n matrix.zeroVec2(this.p_localPoints[j]);\n }\n\n for (let j = 0; j < pointCount; ++j) {\n const cp = manifold.points[j];\n const vcp = this.v_points[j];\n if (step.warmStarting) {\n vcp.normalImpulse = step.dtRatio * cp.normalImpulse;\n vcp.tangentImpulse = step.dtRatio * cp.tangentImpulse;\n }\n matrix.copyVec2(this.p_localPoints[j], cp.localPoint);\n }\n }\n\n /**\n * Get the contact manifold. Do not modify the manifold unless you understand\n * the internals of the library.\n */\n getManifold(): Manifold {\n return this.m_manifold;\n }\n\n /**\n * Get the world manifold.\n */\n getWorldManifold(worldManifold: WorldManifold | null): WorldManifold | undefined {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n return this.m_manifold.getWorldManifold(\n worldManifold,\n bodyA.getTransform(), shapeA.m_radius,\n bodyB.getTransform(), shapeB.m_radius\n );\n }\n\n /**\n * Enable/disable this contact. This can be used inside the pre-solve contact\n * listener. The contact is only disabled for the current time step (or sub-step\n * in continuous collisions).\n */\n setEnabled(flag: boolean): void {\n this.m_enabledFlag = !!flag;\n }\n\n /**\n * Has this contact been disabled?\n */\n isEnabled(): boolean {\n return this.m_enabledFlag;\n }\n\n /**\n * Is this contact touching?\n */\n isTouching(): boolean {\n return this.m_touchingFlag;\n }\n\n /**\n * Get the next contact in the world's contact list.\n */\n getNext(): Contact | null {\n return this.m_next;\n }\n\n /**\n * Get fixture A in this contact.\n */\n getFixtureA(): Fixture {\n return this.m_fixtureA;\n }\n\n /**\n * Get fixture B in this contact.\n */\n getFixtureB(): Fixture {\n return this.m_fixtureB;\n }\n\n /**\n * Get the child primitive index for fixture A.\n */\n getChildIndexA(): number {\n return this.m_indexA;\n }\n\n /**\n * Get the child primitive index for fixture B.\n */\n getChildIndexB(): number {\n return this.m_indexB;\n }\n\n /**\n * Flag this contact for filtering. Filtering will occur the next time step.\n */\n flagForFiltering(): void {\n this.m_filterFlag = true;\n }\n\n /**\n * Override the default friction mixture. You can call this in\n * \"pre-solve\" callback. This value persists until set or reset.\n */\n setFriction(friction: number): void {\n this.m_friction = friction;\n }\n\n /**\n * Get the friction.\n */\n getFriction(): number {\n return this.m_friction;\n }\n\n /**\n * Reset the friction mixture to the default value.\n */\n resetFriction(): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_friction = mixFriction(fixtureA.m_friction, fixtureB.m_friction);\n }\n\n /**\n * Override the default restitution mixture. You can call this in\n * \"pre-solve\" callback. The value persists until you set or reset.\n */\n setRestitution(restitution: number): void {\n this.m_restitution = restitution;\n }\n\n /**\n * Get the restitution.\n */\n getRestitution(): number {\n return this.m_restitution;\n }\n\n /**\n * Reset the restitution to the default value.\n */\n resetRestitution(): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_restitution = mixRestitution(fixtureA.m_restitution, fixtureB.m_restitution);\n }\n\n /**\n * Set the desired tangent speed for a conveyor belt behavior. In meters per\n * second.\n */\n setTangentSpeed(speed: number): void {\n this.m_tangentSpeed = speed;\n }\n\n /**\n * Get the desired tangent speed. In meters per second.\n */\n getTangentSpeed(): number {\n return this.m_tangentSpeed;\n }\n\n /**\n * Called by Update method, and implemented by subclasses.\n */\n evaluate(manifold: Manifold, xfA: TransformValue, xfB: TransformValue): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_evaluateFcn(manifold, xfA, fixtureA, this.m_indexA, xfB, fixtureB, this.m_indexB);\n }\n\n /**\n * Updates the contact manifold and touching status.\n *\n * Note: do not assume the fixture AABBs are overlapping or are valid.\n *\n * @param listener.beginContact\n * @param listener.endContact\n * @param listener.preSolve\n */\n update(listener?: {\n beginContact(contact: Contact): void,\n endContact(contact: Contact): void,\n preSolve(contact: Contact, oldManifold: Manifold): void\n }): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n // Re-enable this contact.\n this.m_enabledFlag = true;\n\n let touching = false;\n const wasTouching = this.m_touchingFlag;\n\n const sensorA = fixtureA.m_isSensor;\n const sensorB = fixtureB.m_isSensor;\n const sensor = sensorA || sensorB;\n\n const xfA = bodyA.m_xf;\n const xfB = bodyB.m_xf;\n\n // Is this contact a sensor?\n if (sensor) {\n touching = testOverlap(shapeA, this.m_indexA, shapeB, this.m_indexB, xfA, xfB);\n\n // Sensors don't generate manifolds.\n this.m_manifold.pointCount = 0;\n } else {\n\n oldManifold.recycle();\n oldManifold.set(this.m_manifold);\n this.m_manifold.recycle();\n\n this.evaluate(this.m_manifold, xfA, xfB);\n touching = this.m_manifold.pointCount > 0;\n\n // Match old contact ids to new contact ids and copy the\n // stored impulses to warm start the solver.\n for (let i = 0; i < this.m_manifold.pointCount; ++i) {\n const nmp = this.m_manifold.points[i];\n nmp.normalImpulse = 0.0;\n nmp.tangentImpulse = 0.0;\n\n for (let j = 0; j < oldManifold.pointCount; ++j) {\n const omp = oldManifold.points[j];\n if (omp.id.key === nmp.id.key) {\n nmp.normalImpulse = omp.normalImpulse;\n nmp.tangentImpulse = omp.tangentImpulse;\n break;\n }\n }\n }\n\n if (touching !== wasTouching) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n }\n\n this.m_touchingFlag = touching;\n\n const hasListener = typeof listener === \"object\" && listener !== null;\n\n if (!wasTouching && touching && hasListener) {\n listener.beginContact(this);\n }\n\n if (wasTouching && !touching && hasListener) {\n listener.endContact(this);\n }\n\n if (!sensor && touching && hasListener && oldManifold) {\n listener.preSolve(this, oldManifold);\n }\n }\n\n solvePositionConstraint(step: TimeStep): number {\n return this._solvePositionConstraint(step, null, null);\n }\n\n solvePositionConstraintTOI(step: TimeStep, toiA: Body, toiB: Body): number {\n return this._solvePositionConstraint(step, toiA, toiB);\n }\n\n private _solvePositionConstraint(step: TimeStep, toiA: Body | null, toiB: Body | null): number {\n const toi = toiA !== null && toiB !== null ? true : false;\n let minSeparation = 0.0;\n\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return minSeparation;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return minSeparation;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const localCenterA = this.p_localCenterA;\n const localCenterB = this.p_localCenterB;\n\n let mA = 0.0;\n let iA = 0.0;\n if (!toi || (bodyA === toiA || bodyA === toiB)) {\n mA = this.p_invMassA;\n iA = this.p_invIA;\n }\n\n let mB = 0.0;\n let iB = 0.0;\n if (!toi || (bodyB === toiA || bodyB === toiB)) {\n mB = this.p_invMassB;\n iB = this.p_invIB;\n }\n\n matrix.copyVec2(cA, positionA.c);\n let aA = positionA.a;\n\n matrix.copyVec2(cB, positionB.c);\n let aB = positionB.a;\n\n // Solve normal constraints\n for (let j = 0; j < this.p_pointCount; ++j) {\n getTransform(xfA, localCenterA, cA, aA);\n getTransform(xfB, localCenterB, cB, aB);\n\n // PositionSolverManifold\n let separation: number;\n switch (this.p_type) {\n case ManifoldType.e_circles: {\n matrix.transformVec2(pointA, xfA, this.p_localPoint);\n matrix.transformVec2(pointB, xfB, this.p_localPoints[0]);\n matrix.subVec2(normal, pointB, pointA);\n matrix.normalizeVec2(normal);\n\n matrix.combine2Vec2(point, 0.5, pointA, 0.5, pointB);\n separation = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal) - this.p_radiusA - this.p_radiusB;\n break;\n }\n\n case ManifoldType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.p_localNormal);\n matrix.transformVec2(planePoint, xfA, this.p_localPoint);\n matrix.transformVec2(clipPoint, xfB, this.p_localPoints[j]);\n separation = matrix.dotVec2(clipPoint, normal) - matrix.dotVec2(planePoint, normal) - this.p_radiusA - this.p_radiusB;\n matrix.copyVec2(point, clipPoint);\n break;\n }\n\n case ManifoldType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.p_localNormal);\n matrix.transformVec2(planePoint, xfB, this.p_localPoint);\n matrix.transformVec2(clipPoint, xfA, this.p_localPoints[j]);\n separation = matrix.dotVec2(clipPoint, normal) - matrix.dotVec2(planePoint, normal) - this.p_radiusA - this.p_radiusB;\n matrix.copyVec2(point, clipPoint);\n\n // Ensure normal points from A to B\n matrix.negVec2(normal);\n break;\n }\n // todo: what should we do here?\n default: {\n return minSeparation;\n }\n }\n\n matrix.subVec2(rA, point, cA);\n matrix.subVec2(rB, point, cB);\n\n // Track max constraint error.\n minSeparation = math_min(minSeparation, separation);\n\n const baumgarte = toi ? Settings.toiBaugarte : Settings.baumgarte;\n const linearSlop = Settings.linearSlop;\n const maxLinearCorrection = Settings.maxLinearCorrection;\n\n // Prevent large corrections and allow slop.\n const C = clamp(baumgarte * (separation + linearSlop), -maxLinearCorrection, 0.0);\n\n // Compute the effective mass.\n const rnA = matrix.crossVec2Vec2(rA, normal);\n const rnB = matrix.crossVec2Vec2(rB, normal);\n const K = mA + mB + iA * rnA * rnA + iB * rnB * rnB;\n\n // Compute normal impulse\n const impulse = K > 0.0 ? -C / K : 0.0;\n\n matrix.scaleVec2(P, impulse, normal);\n\n matrix.minusScaleVec2(cA, mA, P);\n aA -= iA * matrix.crossVec2Vec2(rA, P);\n\n matrix.plusScaleVec2(cB, mB, P);\n aB += iB * matrix.crossVec2Vec2(rB, P);\n }\n\n matrix.copyVec2(positionA.c, cA);\n positionA.a = aA;\n\n matrix.copyVec2(positionB.c, cB);\n positionB.a = aB;\n\n return minSeparation;\n }\n\n initVelocityConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const radiusA = this.p_radiusA;\n const radiusB = this.p_radiusB;\n const manifold = this.m_manifold;\n\n const mA = this.v_invMassA;\n const mB = this.v_invMassB;\n const iA = this.v_invIA;\n const iB = this.v_invIB;\n const localCenterA = this.p_localCenterA;\n const localCenterB = this.p_localCenterB;\n\n matrix.copyVec2(cA, positionA.c);\n const aA = positionA.a;\n matrix.copyVec2(vA, velocityA.v);\n const wA = velocityA.w;\n\n matrix.copyVec2(cB, positionB.c);\n const aB = positionB.a;\n matrix.copyVec2(vB, velocityB.v);\n const wB = velocityB.w;\n\n if (_ASSERT) console.assert(manifold.pointCount > 0);\n\n getTransform(xfA, localCenterA, cA, aA);\n getTransform(xfB, localCenterB, cB, aB);\n\n worldManifold.recycle();\n manifold.getWorldManifold(worldManifold, xfA, radiusA, xfB, radiusB);\n\n matrix.copyVec2(this.v_normal, worldManifold.normal);\n\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n const wmp = worldManifold.points[j];\n\n matrix.subVec2(vcp.rA, wmp, cA);\n matrix.subVec2(vcp.rB, wmp, cB);\n\n const rnA = matrix.crossVec2Vec2(vcp.rA, this.v_normal);\n const rnB = matrix.crossVec2Vec2(vcp.rB, this.v_normal);\n\n const kNormal = mA + mB + iA * rnA * rnA + iB * rnB * rnB;\n\n vcp.normalMass = kNormal > 0.0 ? 1.0 / kNormal : 0.0;\n\n matrix.crossVec2Num(tangent, this.v_normal, 1.0);\n\n const rtA = matrix.crossVec2Vec2(vcp.rA, tangent);\n const rtB = matrix.crossVec2Vec2(vcp.rB, tangent);\n\n const kTangent = mA + mB + iA * rtA * rtA + iB * rtB * rtB;\n\n vcp.tangentMass = kTangent > 0.0 ? 1.0 / kTangent : 0.0;\n\n // Setup a velocity bias for restitution.\n vcp.velocityBias = 0.0;\n let vRel = 0;\n vRel += matrix.dotVec2(this.v_normal, vB);\n vRel += matrix.dotVec2(this.v_normal, matrix.crossNumVec2(temp, wB, vcp.rB));\n vRel -= matrix.dotVec2(this.v_normal, vA);\n vRel -= matrix.dotVec2(this.v_normal, matrix.crossNumVec2(temp, wA, vcp.rA));\n if (vRel < -Settings.velocityThreshold) {\n vcp.velocityBias = -this.v_restitution * vRel;\n }\n }\n\n // If we have two points, then prepare the block solver.\n if (this.v_pointCount == 2 && step.blockSolve) {\n const vcp1 = this.v_points[0]; // VelocityConstraintPoint\n const vcp2 = this.v_points[1]; // VelocityConstraintPoint\n\n const rn1A = matrix.crossVec2Vec2(vcp1.rA, this.v_normal);\n const rn1B = matrix.crossVec2Vec2(vcp1.rB, this.v_normal);\n const rn2A = matrix.crossVec2Vec2(vcp2.rA, this.v_normal);\n const rn2B = matrix.crossVec2Vec2(vcp2.rB, this.v_normal);\n\n const k11 = mA + mB + iA * rn1A * rn1A + iB * rn1B * rn1B;\n const k22 = mA + mB + iA * rn2A * rn2A + iB * rn2B * rn2B;\n const k12 = mA + mB + iA * rn1A * rn2A + iB * rn1B * rn2B;\n\n // Ensure a reasonable condition number.\n const k_maxConditionNumber = 1000.0;\n if (k11 * k11 < k_maxConditionNumber * (k11 * k22 - k12 * k12)) {\n // K is safe to invert.\n this.v_K.ex.setNum(k11, k12);\n this.v_K.ey.setNum(k12, k22);\n // this.v_normalMass.set(this.v_K.getInverse());\n const a = this.v_K.ex.x;\n const b = this.v_K.ey.x;\n const c = this.v_K.ex.y;\n const d = this.v_K.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n this.v_normalMass.ex.x = det * d;\n this.v_normalMass.ey.x = -det * b;\n this.v_normalMass.ex.y = -det * c;\n this.v_normalMass.ey.y = det * a;\n\n } else {\n // The constraints are redundant, just use one.\n // TODO_ERIN use deepest?\n this.v_pointCount = 1;\n }\n }\n\n matrix.copyVec2(positionA.c, cA);\n positionA.a = aA;\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n\n matrix.copyVec2(positionB.c, cB);\n positionB.a = aB;\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n warmStartConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const mA = this.v_invMassA;\n const iA = this.v_invIA;\n const mB = this.v_invMassB;\n const iB = this.v_invIB;\n\n matrix.copyVec2(vA, velocityA.v);\n let wA = velocityA.w;\n matrix.copyVec2(vB, velocityB.v);\n let wB = velocityB.w;\n\n matrix.copyVec2(normal, this.v_normal);\n matrix.crossVec2Num(tangent, normal, 1.0);\n\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n\n matrix.combine2Vec2(P, vcp.normalImpulse, normal, vcp.tangentImpulse, tangent);\n\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n matrix.minusScaleVec2(vA, mA, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n matrix.plusScaleVec2(vB, mB, P);\n }\n\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n storeConstraintImpulses(step: TimeStep): void {\n const manifold = this.m_manifold;\n for (let j = 0; j < this.v_pointCount; ++j) {\n manifold.points[j].normalImpulse = this.v_points[j].normalImpulse;\n manifold.points[j].tangentImpulse = this.v_points[j].tangentImpulse;\n }\n }\n\n solveVelocityConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const positionA = bodyA.c_position;\n\n const velocityB = bodyB.c_velocity;\n const positionB = bodyB.c_position;\n\n const mA = this.v_invMassA;\n const iA = this.v_invIA;\n const mB = this.v_invMassB;\n const iB = this.v_invIB;\n\n matrix.copyVec2(vA, velocityA.v);\n let wA = velocityA.w;\n matrix.copyVec2(vB, velocityB.v);\n let wB = velocityB.w;\n\n matrix.copyVec2(normal, this.v_normal);\n matrix.crossVec2Num(tangent, normal, 1.0);\n const friction = this.v_friction;\n\n if (_ASSERT) console.assert(this.v_pointCount == 1 || this.v_pointCount == 2);\n\n // Solve tangent constraints first because non-penetration is more important\n // than friction.\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n\n // Relative velocity at contact\n matrix.zeroVec2(dv);\n matrix.plusVec2(dv, vB);\n matrix.plusVec2(dv, matrix.crossNumVec2(temp, wB, vcp.rB));\n matrix.minusVec2(dv, vA);\n matrix.minusVec2(dv, matrix.crossNumVec2(temp, wA, vcp.rA));\n\n // Compute tangent force\n const vt = matrix.dotVec2(dv, tangent) - this.v_tangentSpeed;\n let lambda = vcp.tangentMass * (-vt);\n\n // Clamp the accumulated force\n const maxFriction = friction * vcp.normalImpulse;\n const newImpulse = clamp(vcp.tangentImpulse + lambda, -maxFriction, maxFriction);\n lambda = newImpulse - vcp.tangentImpulse;\n vcp.tangentImpulse = newImpulse;\n\n // Apply contact impulse\n matrix.scaleVec2(P, lambda, tangent);\n\n matrix.minusScaleVec2(vA, mA, P);\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n\n matrix.plusScaleVec2(vB, mB, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n }\n\n // Solve normal constraints\n if (this.v_pointCount == 1 || step.blockSolve == false) {\n for (let i = 0; i < this.v_pointCount; ++i) {\n const vcp = this.v_points[i]; // VelocityConstraintPoint\n\n // Relative velocity at contact\n matrix.zeroVec2(dv);\n matrix.plusVec2(dv, vB);\n matrix.plusVec2(dv, matrix.crossNumVec2(temp, wB, vcp.rB));\n matrix.minusVec2(dv, vA);\n matrix.minusVec2(dv, matrix.crossNumVec2(temp, wA, vcp.rA));\n\n // Compute normal impulse\n const vn = matrix.dotVec2(dv, normal);\n let lambda = -vcp.normalMass * (vn - vcp.velocityBias);\n\n // Clamp the accumulated impulse\n const newImpulse = math_max(vcp.normalImpulse + lambda, 0.0);\n lambda = newImpulse - vcp.normalImpulse;\n vcp.normalImpulse = newImpulse;\n\n // Apply contact impulse\n matrix.scaleVec2(P, lambda, normal);\n\n matrix.minusScaleVec2(vA, mA, P);\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n\n matrix.plusScaleVec2(vB, mB, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n }\n } else {\n // Block solver developed in collaboration with Dirk Gregorius (back in\n // 01/07 on Box2D_Lite).\n // Build the mini LCP for this contact patch\n //\n // vn = A * x + b, vn >= 0, x >= 0 and vn_i * x_i = 0 with i = 1..2\n //\n // A = J * W * JT and J = ( -n, -r1 x n, n, r2 x n )\n // b = vn0 - velocityBias\n //\n // The system is solved using the \"Total enumeration method\" (s. Murty).\n // The complementary constraint vn_i * x_i\n // implies that we must have in any solution either vn_i = 0 or x_i = 0.\n // So for the 2D contact problem the cases\n // vn1 = 0 and vn2 = 0, x1 = 0 and x2 = 0, x1 = 0 and vn2 = 0, x2 = 0 and\n // vn1 = 0 need to be tested. The first valid\n // solution that satisfies the problem is chosen.\n //\n // In order to account of the accumulated impulse 'a' (because of the\n // iterative nature of the solver which only requires\n // that the accumulated impulse is clamped and not the incremental\n // impulse) we change the impulse variable (x_i).\n //\n // Substitute:\n //\n // x = a + d\n //\n // a := old total impulse\n // x := new total impulse\n // d := incremental impulse\n //\n // For the current iteration we extend the formula for the incremental\n // impulse\n // to compute the new total impulse:\n //\n // vn = A * d + b\n // = A * (x - a) + b\n // = A * x + b - A * a\n // = A * x + b'\n // b' = b - A * a;\n\n const vcp1 = this.v_points[0]; // VelocityConstraintPoint\n const vcp2 = this.v_points[1]; // VelocityConstraintPoint\n\n matrix.setVec2(a, vcp1.normalImpulse, vcp2.normalImpulse);\n if (_ASSERT) console.assert(a.x >= 0.0 && a.y >= 0.0);\n\n // Relative velocity at contact\n // let dv1 = Vec2.zero().add(vB).add(Vec2.crossNumVec2(wB, vcp1.rB)).sub(vA).sub(Vec2.crossNumVec2(wA, vcp1.rA));\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n // let dv2 = Vec2.zero().add(vB).add(Vec2.crossNumVec2(wB, vcp2.rB)).sub(vA).sub(Vec2.crossNumVec2(wA, vcp2.rA));\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n let vn1 = matrix.dotVec2(dv1, normal);\n let vn2 = matrix.dotVec2(dv2, normal);\n\n matrix.setVec2(b, vn1 - vcp1.velocityBias, vn2 - vcp2.velocityBias);\n\n // Compute b'\n // b.sub(Mat22.mulVec2(this.v_K, a));\n b.x -= this.v_K.ex.x * a.x + this.v_K.ey.x * a.y;\n b.y -= this.v_K.ex.y * a.x + this.v_K.ey.y * a.y;\n\n const k_errorTol = 1e-3;\n // NOT_USED(k_errorTol);\n\n while (true) {\n //\n // Case 1: vn = 0\n //\n // 0 = A * x + b'\n //\n // Solve for x:\n //\n // x = - inv(A) * b'\n //\n // const x = Mat22.mulVec2(this.v_normalMass, b).neg();\n matrix.zeroVec2(x);\n x.x = -(this.v_normalMass.ex.x * b.x + this.v_normalMass.ey.x * b.y);\n x.y = -(this.v_normalMass.ex.y * b.x + this.v_normalMass.ey.y * b.y);\n\n if (x.x >= 0.0 && x.y >= 0.0) {\n // Get the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n vn1 = matrix.dotVec2(dv1, normal);\n vn2 = matrix.dotVec2(dv2, normal);\n\n if (_ASSERT) console.assert(math_abs(vn1 - vcp1.velocityBias) < k_errorTol);\n if (_ASSERT) console.assert(math_abs(vn2 - vcp2.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 2: vn1 = 0 and x2 = 0\n //\n // 0 = a11 * x1 + a12 * 0 + b1'\n // vn2 = a21 * x1 + a22 * 0 + b2'\n //\n x.x = -vcp1.normalMass * b.x;\n x.y = 0.0;\n vn1 = 0.0;\n vn2 = this.v_K.ex.y * x.x + b.y;\n\n if (x.x >= 0.0 && vn2 >= 0.0) {\n // Get the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n // Compute normal velocity\n vn1 = matrix.dotVec2(dv1, normal);\n\n if (_ASSERT) console.assert(math_abs(vn1 - vcp1.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 3: vn2 = 0 and x1 = 0\n //\n // vn1 = a11 * 0 + a12 * x2 + b1'\n // 0 = a21 * 0 + a22 * x2 + b2'\n //\n x.x = 0.0;\n x.y = -vcp2.normalMass * b.y;\n vn1 = this.v_K.ey.x * x.y + b.x;\n vn2 = 0.0;\n\n if (x.y >= 0.0 && vn1 >= 0.0) {\n // Resubstitute for the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n vn2 = matrix.dotVec2(dv2, normal);\n\n if (_ASSERT) console.assert(math_abs(vn2 - vcp2.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 4: x1 = 0 and x2 = 0\n //\n // vn1 = b1\n // vn2 = b2;\n //\n x.x = 0.0;\n x.y = 0.0;\n vn1 = b.x;\n vn2 = b.y;\n\n if (vn1 >= 0.0 && vn2 >= 0.0) {\n // Resubstitute for the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n break;\n }\n\n // No solution, give up. This is hit sometimes, but it doesn't seem to\n // matter.\n break;\n }\n }\n\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n /** @internal */\n static addType(type1: ShapeType, type2: ShapeType, callback: EvaluateFunction): void {\n s_registers[type1] = s_registers[type1] || {};\n s_registers[type1][type2] = callback;\n }\n\n /** @internal */\n static create(fixtureA: Fixture, indexA: number, fixtureB: Fixture, indexB: number): Contact | null {\n const typeA = fixtureA.m_shape.m_type;\n const typeB = fixtureB.m_shape.m_type;\n\n const contact = contactPool.allocate();\n let evaluateFcn;\n if (evaluateFcn = s_registers[typeA] && s_registers[typeA][typeB]) {\n contact.initialize(fixtureA, indexA, fixtureB, indexB, evaluateFcn);\n } else if (evaluateFcn = s_registers[typeB] && s_registers[typeB][typeA]) {\n contact.initialize(fixtureB, indexB, fixtureA, indexA, evaluateFcn);\n } else {\n return null;\n }\n\n // Contact creation may swap fixtures.\n fixtureA = contact.m_fixtureA;\n fixtureB = contact.m_fixtureB;\n indexA = contact.getChildIndexA();\n indexB = contact.getChildIndexB();\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n\n // Connect to body A\n contact.m_nodeA.contact = contact;\n contact.m_nodeA.other = bodyB;\n\n contact.m_nodeA.prev = null;\n contact.m_nodeA.next = bodyA.m_contactList;\n if (bodyA.m_contactList != null) {\n bodyA.m_contactList.prev = contact.m_nodeA;\n }\n bodyA.m_contactList = contact.m_nodeA;\n\n // Connect to body B\n contact.m_nodeB.contact = contact;\n contact.m_nodeB.other = bodyA;\n\n contact.m_nodeB.prev = null;\n contact.m_nodeB.next = bodyB.m_contactList;\n if (bodyB.m_contactList != null) {\n bodyB.m_contactList.prev = contact.m_nodeB;\n }\n bodyB.m_contactList = contact.m_nodeB;\n\n // Wake up the bodies\n if (fixtureA.isSensor() == false && fixtureB.isSensor() == false) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n\n return contact;\n }\n\n /** @internal */\n static destroy(contact: Contact, listener: { endContact: (contact: Contact) => void }): void {\n const fixtureA = contact.m_fixtureA;\n const fixtureB = contact.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n if (contact.isTouching()) {\n listener.endContact(contact);\n }\n\n // Remove from body 1\n if (contact.m_nodeA.prev) {\n contact.m_nodeA.prev.next = contact.m_nodeA.next;\n }\n\n if (contact.m_nodeA.next) {\n contact.m_nodeA.next.prev = contact.m_nodeA.prev;\n }\n\n if (contact.m_nodeA == bodyA.m_contactList) {\n bodyA.m_contactList = contact.m_nodeA.next;\n }\n\n // Remove from body 2\n if (contact.m_nodeB.prev) {\n contact.m_nodeB.prev.next = contact.m_nodeB.next;\n }\n\n if (contact.m_nodeB.next) {\n contact.m_nodeB.next.prev = contact.m_nodeB.prev;\n }\n\n if (contact.m_nodeB == bodyB.m_contactList) {\n bodyB.m_contactList = contact.m_nodeB.next;\n }\n\n if (contact.m_manifold.pointCount > 0 && !fixtureA.m_isSensor && !fixtureB.m_isSensor) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n\n // const typeA = fixtureA.getType();\n // const typeB = fixtureB.getType();\n\n // const destroyFcn = s_registers[typeA][typeB].destroyFcn;\n // if (typeof destroyFcn === 'function') {\n // destroyFcn(contact);\n // }\n\n contactPool.release(contact);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../util/options\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { BroadPhase } from \"../collision/BroadPhase\";\nimport { Solver, ContactImpulse, TimeStep } from \"./Solver\";\nimport { Body, BodyDef } from \"./Body\";\nimport { Joint } from \"./Joint\";\nimport { Contact } from \"./Contact\";\nimport { AABBValue, RayCastInput, RayCastOutput } from \"../collision/AABB\";\nimport { Fixture, FixtureProxy } from \"./Fixture\";\nimport { Manifold } from \"../collision/Manifold\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\nexport interface WorldDef {\n /** [default: { x : 0, y : 0}] */\n gravity?: Vec2Value;\n\n /** [default: true] */\n allowSleep?: boolean;\n\n /** [default: true] */\n warmStarting?: boolean;\n\n /** [default: true] */\n continuousPhysics?: boolean;\n\n /** [default: false] */\n subStepping?: boolean;\n\n /** [default: true] */\n blockSolve?: boolean;\n\n /** @internal [8] For the velocity constraint solver. */\n velocityIterations?: number;\n\n /** @internal [3] For the position constraint solver. */\n positionIterations?: number;\n}\n\n/** @internal */ const DEFAULTS: WorldDef = {\n gravity : Vec2.zero(),\n allowSleep : true,\n warmStarting : true,\n continuousPhysics : true,\n subStepping : false,\n blockSolve : true,\n velocityIterations : 8,\n positionIterations : 3\n};\n\n/**\n * Callback function for ray casts, see {@link World.rayCast}.\n *\n * Called for each fixture found in the query.\n * The returned value replaces the ray-cast input maxFraction.\n * You control how the ray cast proceeds by returning a numeric/float value.\n * \n * - `0` to terminate the ray cast\n * - `fraction` to clip the ray cast at current point\n * - `1` don't clip the ray and continue\n * - `-1` (or anything else) to continue\n *\n * @param fixture The fixture hit by the ray\n * @param point The point of initial intersection\n * @param normal The normal vector at the point of intersection\n * @param fraction The fraction along the ray at the point of intersection\n *\n * @returns A number to update the maxFraction\n */\nexport type WorldRayCastCallback = (fixture: Fixture, point: Vec2, normal: Vec2, fraction: number) => number;\n\n/**\n * Called for each fixture found in the query AABB. It may return `false` to terminate the query.\n */\nexport type WorldAABBQueryCallback = (fixture: Fixture) => boolean;\n\ndeclare module \"./World\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(deg: WorldDef): World;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(gravity: Vec2): World;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(): World;\n}\n\n/**\n * The `World` class contains the bodies and joints. It manages all aspects\n * of the simulation and allows for asynchronous queries (like AABB queries\n * and ray-casts). Much of your interactions with Planck.js will be with a\n * World object.\n */\n// @ts-expect-error\nexport class World {\n /** @internal */ m_solver: Solver;\n /** @internal */ m_broadPhase: BroadPhase;\n /** @internal */ m_contactList: Contact | null;\n /** @internal */ m_contactCount: number;\n /** @internal */ m_bodyList: Body | null;\n /** @internal */ m_bodyCount: number;\n /** @internal */ m_jointList: Joint | null;\n /** @internal */ m_jointCount: number;\n /** @internal */ m_stepComplete: boolean;\n /** @internal */ m_allowSleep: boolean;\n /** @internal */ m_gravity: Vec2;\n /** @internal */ m_clearForces: boolean;\n /** @internal */ m_newFixture: boolean;\n /** @internal */ m_locked: boolean;\n /** @internal */ m_warmStarting: boolean;\n /** @internal */ m_continuousPhysics: boolean;\n /** @internal */ m_subStepping: boolean;\n /** @internal */ m_blockSolve: boolean;\n /** @internal */ m_velocityIterations: number;\n /** @internal */ m_positionIterations: number;\n /** @internal */ m_t: number;\n\n // TODO\n /** @internal */ _listeners: {\n [key: string]: any[]\n };\n\n /**\n * @param def World definition or gravity vector.\n */\n constructor(def?: WorldDef | Vec2Value) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof World)) {\n return new World(def);\n }\n\n this.s_step = new TimeStep();\n\n\n if (!def) {\n def = {};\n } else if (Vec2.isValid(def)) {\n def = { gravity: def as Vec2 };\n }\n\n def = options(def, DEFAULTS) as WorldDef;\n\n this.m_solver = new Solver(this);\n\n this.m_broadPhase = new BroadPhase();\n\n this.m_contactList = null;\n this.m_contactCount = 0;\n\n this.m_bodyList = null;\n this.m_bodyCount = 0;\n\n this.m_jointList = null;\n this.m_jointCount = 0;\n\n this.m_stepComplete = true;\n\n this.m_allowSleep = def.allowSleep;\n this.m_gravity = Vec2.clone(def.gravity);\n\n this.m_clearForces = true;\n this.m_newFixture = false;\n this.m_locked = false;\n\n // These are for debugging the solver.\n this.m_warmStarting = def.warmStarting;\n this.m_continuousPhysics = def.continuousPhysics;\n this.m_subStepping = def.subStepping;\n\n this.m_blockSolve = def.blockSolve;\n this.m_velocityIterations = def.velocityIterations;\n this.m_positionIterations = def.positionIterations;\n\n this.m_t = 0;\n }\n\n /** @internal */\n _serialize(): object {\n const bodies = [];\n const joints = [];\n\n for (let b = this.getBodyList(); b; b = b.getNext()) {\n bodies.push(b);\n }\n\n for (let j = this.getJointList(); j; j = j.getNext()) {\n // @ts-ignore\n if (typeof j._serialize === \"function\") {\n joints.push(j);\n }\n }\n\n return {\n gravity: this.m_gravity,\n bodies,\n joints,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, context: any, restore: any): World {\n if (!data) {\n return new World();\n }\n\n const world = new World(data.gravity);\n\n if (data.bodies) {\n for (let i = data.bodies.length - 1; i >= 0; i -= 1) {\n world._addBody(restore(Body, data.bodies[i], world));\n }\n }\n\n if (data.joints) {\n for (let i = data.joints.length - 1; i >= 0; i--) {\n world.createJoint(restore(Joint, data.joints[i], world));\n }\n }\n\n return world;\n }\n\n /**\n * Get the world body list. With the returned body, use Body.getNext to get the\n * next body in the world list. A null body indicates the end of the list.\n *\n * @return the head of the world body list.\n */\n getBodyList(): Body | null {\n return this.m_bodyList;\n }\n\n /**\n * Get the world joint list. With the returned joint, use Joint.getNext to get\n * the next joint in the world list. A null joint indicates the end of the list.\n *\n * @return the head of the world joint list.\n */\n getJointList(): Joint | null {\n return this.m_jointList;\n }\n\n /**\n * Get the world contact list. With the returned contact, use Contact.getNext to\n * get the next contact in the world list. A null contact indicates the end of\n * the list.\n *\n * Warning: contacts are created and destroyed in the middle of a time step.\n * Use ContactListener to avoid missing contacts.\n *\n * @return the head of the world contact list.\n */\n getContactList(): Contact | null {\n return this.m_contactList;\n }\n\n getBodyCount(): number {\n return this.m_bodyCount;\n }\n\n getJointCount(): number {\n return this.m_jointCount;\n }\n\n /**\n * Get the number of contacts (each may have 0 or more contact points).\n */\n getContactCount(): number {\n return this.m_contactCount;\n }\n\n /**\n * Change the global gravity vector.\n */\n setGravity(gravity: Vec2Value): void {\n this.m_gravity.set(gravity);\n }\n\n /**\n * Get the global gravity vector.\n */\n getGravity(): Vec2 {\n return this.m_gravity;\n }\n\n /**\n * Is the world locked (in the middle of a time step).\n */\n isLocked(): boolean {\n return this.m_locked;\n }\n\n /**\n * Enable/disable sleep.\n */\n setAllowSleeping(flag: boolean): void {\n if (flag == this.m_allowSleep) {\n return;\n }\n\n this.m_allowSleep = flag;\n if (this.m_allowSleep == false) {\n for (let b = this.m_bodyList; b; b = b.m_next) {\n b.setAwake(true);\n }\n }\n }\n\n getAllowSleeping(): boolean {\n return this.m_allowSleep;\n }\n\n /**\n * Enable/disable warm starting. For testing.\n */\n setWarmStarting(flag: boolean): void {\n this.m_warmStarting = flag;\n }\n\n getWarmStarting(): boolean {\n return this.m_warmStarting;\n }\n\n /**\n * Enable/disable continuous physics. For testing.\n */\n setContinuousPhysics(flag: boolean): void {\n this.m_continuousPhysics = flag;\n }\n\n getContinuousPhysics(): boolean {\n return this.m_continuousPhysics;\n }\n\n /**\n * Enable/disable single stepped continuous physics. For testing.\n */\n setSubStepping(flag: boolean): void {\n this.m_subStepping = flag;\n }\n\n getSubStepping(): boolean {\n return this.m_subStepping;\n }\n\n /**\n * Set flag to control automatic clearing of forces after each time step.\n */\n setAutoClearForces(flag: boolean): void {\n this.m_clearForces = flag;\n }\n\n /**\n * Get the flag that controls automatic clearing of forces after each time step.\n */\n getAutoClearForces(): boolean {\n return this.m_clearForces;\n }\n\n /**\n * Manually clear the force buffer on all bodies. By default, forces are cleared\n * automatically after each call to step. The default behavior is modified by\n * calling setAutoClearForces. The purpose of this function is to support\n * sub-stepping. Sub-stepping is often used to maintain a fixed sized time step\n * under a variable frame-rate. When you perform sub-stepping you will disable\n * auto clearing of forces and instead call clearForces after all sub-steps are\n * complete in one pass of your game loop.\n *\n * See {@link World.setAutoClearForces}\n */\n clearForces(): void {\n for (let body = this.m_bodyList; body; body = body.getNext()) {\n body.m_force.setZero();\n body.m_torque = 0.0;\n }\n }\n\n /**\n * Query the world for all fixtures that potentially overlap the provided AABB.\n *\n * @param aabb The query box.\n * @param callback Called for each fixture found in the query AABB. It may return `false` to terminate the query.\n */\n queryAABB(aabb: AABBValue, callback: WorldAABBQueryCallback): void {\n if (_ASSERT) console.assert(typeof callback === \"function\");\n const broadPhase = this.m_broadPhase;\n this.m_broadPhase.query(aabb, function(proxyId: number): boolean { // TODO GC\n const proxy = broadPhase.getUserData(proxyId);\n return callback(proxy.fixture);\n });\n }\n\n /**\n * Ray-cast the world for all fixtures in the path of the ray. Your callback\n * controls whether you get the closest point, any point, or n-points. The\n * ray-cast ignores shapes that contain the starting point.\n *\n * @param point1 The ray starting point\n * @param point2 The ray ending point\n * @param callback A function that is called for each fixture that is hit by the ray. You control how the ray cast proceeds by returning a numeric/float value.\n */\n rayCast(point1: Vec2Value, point2: Vec2Value, callback: WorldRayCastCallback): void {\n if (_ASSERT) console.assert(typeof callback === \"function\");\n const broadPhase = this.m_broadPhase;\n\n this.m_broadPhase.rayCast({\n maxFraction : 1.0,\n p1 : point1,\n p2 : point2\n }, function(input: RayCastInput, proxyId: number): number { // TODO GC\n const proxy = broadPhase.getUserData(proxyId);\n const fixture = proxy.fixture;\n const index = proxy.childIndex;\n // @ts-ignore\n const output: RayCastOutput = {}; // TODO GC\n const hit = fixture.rayCast(output, input, index);\n if (hit) {\n const fraction = output.fraction;\n const point = Vec2.add(Vec2.mulNumVec2((1.0 - fraction), input.p1), Vec2.mulNumVec2(fraction, input.p2));\n return callback(fixture, point, output.normal, fraction);\n }\n return input.maxFraction;\n });\n }\n\n /**\n * Get the number of broad-phase proxies.\n */\n getProxyCount(): number {\n return this.m_broadPhase.getProxyCount();\n }\n\n /**\n * Get the height of broad-phase dynamic tree.\n */\n getTreeHeight(): number {\n return this.m_broadPhase.getTreeHeight();\n }\n\n /**\n * Get the balance of broad-phase dynamic tree.\n */\n getTreeBalance(): number {\n return this.m_broadPhase.getTreeBalance();\n }\n\n /**\n * Get the quality metric of broad-phase dynamic tree. The smaller the better.\n * The minimum is 1.\n */\n getTreeQuality(): number {\n return this.m_broadPhase.getTreeQuality();\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The body shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n if (_ASSERT) console.assert(this.m_locked == false);\n if (this.m_locked) {\n return;\n }\n\n for (let b = this.m_bodyList; b; b = b.m_next) {\n b.m_xf.p.sub(newOrigin);\n b.m_sweep.c0.sub(newOrigin);\n b.m_sweep.c.sub(newOrigin);\n }\n\n for (let j = this.m_jointList; j; j = j.m_next) {\n j.shiftOrigin(newOrigin);\n }\n\n this.m_broadPhase.shiftOrigin(newOrigin);\n }\n\n /** @internal Used for deserialize. */\n _addBody(body: Body): void {\n if (_ASSERT) console.assert(this.isLocked() === false);\n if (this.isLocked()) {\n return;\n }\n\n // Add to world doubly linked list.\n body.m_prev = null;\n body.m_next = this.m_bodyList;\n if (this.m_bodyList) {\n this.m_bodyList.m_prev = body;\n }\n this.m_bodyList = body;\n ++this.m_bodyCount;\n }\n\n /**\n * Create a rigid body given a definition. No reference to the definition is\n * retained.\n *\n * Warning: This function is locked during callbacks.\n */\n createBody(def?: BodyDef): Body;\n createBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createBody(arg1?, arg2?) {\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return null;\n }\n\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n\n const body = new Body(this, def);\n this._addBody(body);\n return body;\n }\n\n createDynamicBody(def?: BodyDef): Body;\n createDynamicBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createDynamicBody(arg1?, arg2?) {\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n def.type = \"dynamic\";\n return this.createBody(def);\n }\n\n createKinematicBody(def?: BodyDef): Body;\n createKinematicBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createKinematicBody(arg1?, arg2?) {\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n def.type = \"kinematic\";\n return this.createBody(def);\n }\n\n /**\n * Destroy a rigid body given a definition. No reference to the definition is\n * retained.\n *\n * Warning: This automatically deletes all associated shapes and joints.\n *\n * Warning: This function is locked during callbacks.\n */\n destroyBody(b: Body): boolean {\n if (_ASSERT) console.assert(this.m_bodyCount > 0);\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return;\n }\n\n if (b.m_destroyed) {\n return false;\n }\n\n // Delete the attached joints.\n let je = b.m_jointList;\n while (je) {\n const je0 = je;\n je = je.next;\n\n this.publish(\"remove-joint\", je0.joint);\n this.destroyJoint(je0.joint);\n\n b.m_jointList = je;\n }\n b.m_jointList = null;\n\n // Delete the attached contacts.\n let ce = b.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n\n this.destroyContact(ce0.contact);\n\n b.m_contactList = ce;\n }\n b.m_contactList = null;\n\n // Delete the attached fixtures. This destroys broad-phase proxies.\n let f = b.m_fixtureList;\n while (f) {\n const f0 = f;\n f = f.m_next;\n\n this.publish(\"remove-fixture\", f0);\n f0.destroyProxies(this.m_broadPhase);\n\n b.m_fixtureList = f;\n }\n b.m_fixtureList = null;\n\n // Remove world body list.\n if (b.m_prev) {\n b.m_prev.m_next = b.m_next;\n }\n\n if (b.m_next) {\n b.m_next.m_prev = b.m_prev;\n }\n\n if (b == this.m_bodyList) {\n this.m_bodyList = b.m_next;\n }\n\n b.m_destroyed = true;\n\n --this.m_bodyCount;\n\n this.publish(\"remove-body\", b);\n\n return true;\n }\n\n /**\n * Create a joint to constrain bodies together. No reference to the definition\n * is retained. This may cause the connected bodies to cease colliding.\n *\n * Warning: This function is locked during callbacks.\n */\n createJoint(joint: T): T | null {\n if (_ASSERT) console.assert(!!joint.m_bodyA);\n if (_ASSERT) console.assert(!!joint.m_bodyB);\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return null;\n }\n\n // Connect to the world list.\n joint.m_prev = null;\n joint.m_next = this.m_jointList;\n if (this.m_jointList) {\n this.m_jointList.m_prev = joint;\n }\n this.m_jointList = joint;\n ++this.m_jointCount;\n\n // Connect to the bodies' doubly linked lists.\n joint.m_edgeA.joint = joint;\n joint.m_edgeA.other = joint.m_bodyB;\n joint.m_edgeA.prev = null;\n joint.m_edgeA.next = joint.m_bodyA.m_jointList;\n if (joint.m_bodyA.m_jointList)\n joint.m_bodyA.m_jointList.prev = joint.m_edgeA;\n joint.m_bodyA.m_jointList = joint.m_edgeA;\n\n joint.m_edgeB.joint = joint;\n joint.m_edgeB.other = joint.m_bodyA;\n joint.m_edgeB.prev = null;\n joint.m_edgeB.next = joint.m_bodyB.m_jointList;\n if (joint.m_bodyB.m_jointList)\n joint.m_bodyB.m_jointList.prev = joint.m_edgeB;\n joint.m_bodyB.m_jointList = joint.m_edgeB;\n\n // If the joint prevents collisions, then flag any contacts for filtering.\n if (joint.m_collideConnected == false) {\n for (let edge = joint.m_bodyB.getContactList(); edge; edge = edge.next) {\n if (edge.other == joint.m_bodyA) {\n // Flag the contact for filtering at the next time step (where either\n // body is awake).\n edge.contact.flagForFiltering();\n }\n }\n }\n\n // Note: creating a joint doesn't wake the bodies.\n\n return joint;\n }\n\n /**\n * Destroy a joint. This may cause the connected bodies to begin colliding.\n * Warning: This function is locked during callbacks.\n */\n destroyJoint(joint: Joint): void {\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return;\n }\n\n // Remove from the doubly linked list.\n if (joint.m_prev) {\n joint.m_prev.m_next = joint.m_next;\n }\n\n if (joint.m_next) {\n joint.m_next.m_prev = joint.m_prev;\n }\n\n if (joint == this.m_jointList) {\n this.m_jointList = joint.m_next;\n }\n\n // Disconnect from bodies.\n const bodyA = joint.m_bodyA;\n const bodyB = joint.m_bodyB;\n\n // Wake up connected bodies.\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n\n // Remove from body 1.\n if (joint.m_edgeA.prev) {\n joint.m_edgeA.prev.next = joint.m_edgeA.next;\n }\n\n if (joint.m_edgeA.next) {\n joint.m_edgeA.next.prev = joint.m_edgeA.prev;\n }\n\n if (joint.m_edgeA == bodyA.m_jointList) {\n bodyA.m_jointList = joint.m_edgeA.next;\n }\n\n joint.m_edgeA.prev = null;\n joint.m_edgeA.next = null;\n\n // Remove from body 2\n if (joint.m_edgeB.prev) {\n joint.m_edgeB.prev.next = joint.m_edgeB.next;\n }\n\n if (joint.m_edgeB.next) {\n joint.m_edgeB.next.prev = joint.m_edgeB.prev;\n }\n\n if (joint.m_edgeB == bodyB.m_jointList) {\n bodyB.m_jointList = joint.m_edgeB.next;\n }\n\n joint.m_edgeB.prev = null;\n joint.m_edgeB.next = null;\n\n if (_ASSERT) console.assert(this.m_jointCount > 0);\n --this.m_jointCount;\n\n // If the joint prevents collisions, then flag any contacts for filtering.\n if (joint.m_collideConnected == false) {\n let edge = bodyB.getContactList();\n while (edge) {\n if (edge.other == bodyA) {\n // Flag the contact for filtering at the next time step (where either\n // body is awake).\n edge.contact.flagForFiltering();\n }\n\n edge = edge.next;\n }\n }\n\n this.publish(\"remove-joint\", joint);\n }\n\n /** @internal */\n s_step: TimeStep; // reuse\n\n /**\n * Take a time step. This performs collision detection, integration, and\n * constraint solution.\n *\n * Broad-phase, narrow-phase, solve and solve time of impacts.\n *\n * @param timeStep Time step, this should not vary.\n */\n step(timeStep: number, velocityIterations?: number, positionIterations?: number): void {\n this.publish(\"pre-step\", timeStep);\n\n if ((velocityIterations | 0) !== velocityIterations) {\n // TODO: remove this in future\n velocityIterations = 0;\n }\n\n velocityIterations = velocityIterations || this.m_velocityIterations;\n positionIterations = positionIterations || this.m_positionIterations;\n\n // If new fixtures were added, we need to find the new contacts.\n if (this.m_newFixture) {\n this.findNewContacts();\n this.m_newFixture = false;\n }\n\n this.m_locked = true;\n\n this.s_step.reset(timeStep);\n this.s_step.velocityIterations = velocityIterations;\n this.s_step.positionIterations = positionIterations;\n this.s_step.warmStarting = this.m_warmStarting;\n this.s_step.blockSolve = this.m_blockSolve;\n\n // Update contacts. This is where some contacts are destroyed.\n this.updateContacts();\n\n // Integrate velocities, solve velocity constraints, and integrate positions.\n if (this.m_stepComplete && timeStep > 0.0) {\n this.m_solver.solveWorld(this.s_step);\n\n // Synchronize fixtures, check for out of range bodies.\n for (let b = this.m_bodyList; b; b = b.getNext()) {\n // If a body was not in an island then it did not move.\n if (b.m_islandFlag == false) {\n continue;\n }\n\n if (b.isStatic()) {\n continue;\n }\n\n // Update fixtures (for broad-phase).\n b.synchronizeFixtures();\n }\n // Look for new contacts.\n this.findNewContacts();\n }\n\n // Handle TOI events.\n if (this.m_continuousPhysics && timeStep > 0.0) {\n this.m_solver.solveWorldTOI(this.s_step);\n }\n\n if (this.m_clearForces) {\n this.clearForces();\n }\n\n this.m_locked = false;\n\n this.publish(\"post-step\", timeStep);\n }\n\n /**\n * @internal\n * Call this method to find new contacts.\n */\n findNewContacts(): void {\n this.m_broadPhase.updatePairs(\n (proxyA: FixtureProxy, proxyB: FixtureProxy) => this.createContact(proxyA, proxyB)\n );\n }\n\n /**\n * @internal\n * Callback for broad-phase.\n */\n createContact(proxyA: FixtureProxy, proxyB: FixtureProxy): void {\n const fixtureA = proxyA.fixture;\n const fixtureB = proxyB.fixture;\n\n const indexA = proxyA.childIndex;\n const indexB = proxyB.childIndex;\n\n const bodyA = fixtureA.getBody();\n const bodyB = fixtureB.getBody();\n\n // Are the fixtures on the same body?\n if (bodyA == bodyB) {\n return;\n }\n\n // TODO_ERIN use a hash table to remove a potential bottleneck when both\n // bodies have a lot of contacts.\n // Does a contact already exist?\n let edge = bodyB.getContactList(); // ContactEdge\n while (edge) {\n if (edge.other == bodyA) {\n const fA = edge.contact.getFixtureA();\n const fB = edge.contact.getFixtureB();\n const iA = edge.contact.getChildIndexA();\n const iB = edge.contact.getChildIndexB();\n\n if (fA == fixtureA && fB == fixtureB && iA == indexA && iB == indexB) {\n // A contact already exists.\n return;\n }\n\n if (fA == fixtureB && fB == fixtureA && iA == indexB && iB == indexA) {\n // A contact already exists.\n return;\n }\n }\n\n edge = edge.next;\n }\n\n if (bodyB.shouldCollide(bodyA) == false) {\n return;\n }\n if (fixtureB.shouldCollide(fixtureA) == false) {\n return;\n }\n\n // Call the factory.\n const contact = Contact.create(fixtureA, indexA, fixtureB, indexB);\n if (contact == null) {\n return;\n }\n\n // Insert into the world.\n contact.m_prev = null;\n if (this.m_contactList != null) {\n contact.m_next = this.m_contactList;\n this.m_contactList.m_prev = contact;\n }\n this.m_contactList = contact;\n\n ++this.m_contactCount;\n }\n\n /**\n * @internal\n * Removes old non-overlapping contacts, applies filters and updates contacts.\n */\n updateContacts(): void {\n // Update awake contacts.\n let c: Contact;\n let next_c = this.m_contactList;\n while (c = next_c) {\n next_c = c.getNext();\n const fixtureA = c.getFixtureA();\n const fixtureB = c.getFixtureB();\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n const bodyA = fixtureA.getBody();\n const bodyB = fixtureB.getBody();\n\n // Is this contact flagged for filtering?\n if (c.m_filterFlag) {\n if (bodyB.shouldCollide(bodyA) == false) {\n this.destroyContact(c);\n continue;\n }\n\n if (fixtureB.shouldCollide(fixtureA) == false) {\n this.destroyContact(c);\n continue;\n }\n\n // Clear the filtering flag.\n c.m_filterFlag = false;\n }\n\n const activeA = bodyA.isAwake() && !bodyA.isStatic();\n const activeB = bodyB.isAwake() && !bodyB.isStatic();\n\n // At least one body must be awake and it must be dynamic or kinematic.\n if (activeA == false && activeB == false) {\n continue;\n }\n\n const proxyIdA = fixtureA.m_proxies[indexA].proxyId;\n const proxyIdB = fixtureB.m_proxies[indexB].proxyId;\n const overlap = this.m_broadPhase.testOverlap(proxyIdA, proxyIdB);\n\n // Here we destroy contacts that cease to overlap in the broad-phase.\n if (overlap == false) {\n this.destroyContact(c);\n continue;\n }\n\n // The contact persists.\n c.update(this);\n }\n }\n\n /** @internal */\n destroyContact(contact: Contact): void {\n // Remove from the world.\n if (contact.m_prev) {\n contact.m_prev.m_next = contact.m_next;\n }\n if (contact.m_next) {\n contact.m_next.m_prev = contact.m_prev;\n }\n if (contact == this.m_contactList) {\n this.m_contactList = contact.m_next;\n }\n\n Contact.destroy(contact, this);\n\n --this.m_contactCount;\n }\n\n\n /**\n * Called when two fixtures begin to touch.\n *\n * Implement contact callbacks to get contact information. You can use these\n * results for things like sounds and game logic. You can also get contact\n * results by traversing the contact lists after the time step. However, you\n * might miss some contacts because continuous physics leads to sub-stepping.\n * Additionally you may receive multiple callbacks for the same contact in a\n * single time step. You should strive to make your callbacks efficient because\n * there may be many callbacks per time step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"begin-contact\", listener: (contact: Contact) => void): World;\n /**\n * Called when two fixtures cease to touch.\n *\n * Implement contact callbacks to get contact information. You can use these\n * results for things like sounds and game logic. You can also get contact\n * results by traversing the contact lists after the time step. However, you\n * might miss some contacts because continuous physics leads to sub-stepping.\n * Additionally you may receive multiple callbacks for the same contact in a\n * single time step. You should strive to make your callbacks efficient because\n * there may be many callbacks per time step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"end-contact\", listener: (contact: Contact) => void): World;\n /**\n * This is called after a contact is updated. This allows you to inspect a\n * contact before it goes to the solver. If you are careful, you can modify the\n * contact manifold (e.g. disable contact). A copy of the old manifold is\n * provided so that you can detect changes. Note: this is called only for awake\n * bodies. Note: this is called even when the number of contact points is zero.\n * Note: this is not called for sensors. Note: if you set the number of contact\n * points to zero, you will not get an end-contact callback. However, you may get\n * a begin-contact callback the next step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"pre-solve\", listener: (contact: Contact, oldManifold: Manifold) => void): World;\n /**\n * This lets you inspect a contact after the solver is finished. This is useful\n * for inspecting impulses. Note: the contact manifold does not include time of\n * impact impulses, which can be arbitrarily large if the sub-step is small.\n * Hence the impulse is provided explicitly in a separate data structure. Note:\n * this is only called for contacts that are touching, solid, and awake.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"post-solve\", listener: (contact: Contact, impulse: ContactImpulse) => void): World;\n /** Listener is called whenever a body is removed. */\n on(name: \"remove-body\", listener: (body: Body) => void): World;\n /** Listener is called whenever a joint is removed implicitly or explicitly. */\n on(name: \"remove-joint\", listener: (joint: Joint) => void): World;\n /** Listener is called whenever a fixture is removed implicitly or explicitly. */\n on(name: \"remove-fixture\", listener: (fixture: Fixture) => void): World;\n /**\n * Register an event listener.\n */\n // tslint:disable-next-line:typedef\n on(name, listener) {\n if (typeof name !== \"string\" || typeof listener !== \"function\") {\n return this;\n }\n if (!this._listeners) {\n this._listeners = {};\n }\n if (!this._listeners[name]) {\n this._listeners[name] = [];\n }\n this._listeners[name].push(listener);\n return this;\n }\n\n off(name: \"begin-contact\", listener: (contact: Contact) => void): World;\n off(name: \"end-contact\", listener: (contact: Contact) => void): World;\n off(name: \"pre-solve\", listener: (contact: Contact, oldManifold: Manifold) => void): World;\n off(name: \"post-solve\", listener: (contact: Contact, impulse: ContactImpulse) => void): World;\n off(name: \"remove-body\", listener: (body: Body) => void): World;\n off(name: \"remove-joint\", listener: (joint: Joint) => void): World;\n off(name: \"remove-fixture\", listener: (fixture: Fixture) => void): World;\n /**\n * Remove an event listener.\n */\n // tslint:disable-next-line:typedef\n off(name, listener) {\n if (typeof name !== \"string\" || typeof listener !== \"function\") {\n return this;\n }\n const listeners = this._listeners && this._listeners[name];\n if (!listeners || !listeners.length) {\n return this;\n }\n const index = listeners.indexOf(listener);\n if (index >= 0) {\n listeners.splice(index, 1);\n }\n return this;\n }\n\n publish(name: string, arg1?: any, arg2?: any, arg3?: any): number {\n const listeners = this._listeners && this._listeners[name];\n if (!listeners || !listeners.length) {\n return 0;\n }\n for (let l = 0; l < listeners.length; l++) {\n listeners[l].call(this, arg1, arg2, arg3);\n }\n return listeners.length;\n }\n\n /** @internal */\n beginContact(contact: Contact): void {\n this.publish(\"begin-contact\", contact);\n }\n\n /** @internal */\n endContact(contact: Contact): void {\n this.publish(\"end-contact\", contact);\n }\n\n /** @internal */\n preSolve(contact: Contact, oldManifold: Manifold): void {\n this.publish(\"pre-solve\", contact, oldManifold);\n }\n\n /** @internal */\n postSolve(contact: Contact, impulse: ContactImpulse): void {\n this.publish(\"post-solve\", contact, impulse);\n }\n\n /**\n * Joints and fixtures are destroyed when their associated body is destroyed.\n * Register a destruction listener so that you may nullify references to these\n * joints and shapes.\n *\n * `function(object)` is called when any joint or fixture is about to\n * be destroyed due to the destruction of one of its attached or parent bodies.\n */\n\n /**\n * Register a contact filter to provide specific control over collision.\n * Otherwise the default filter is used (defaultFilter). The listener is owned\n * by you and must remain in scope.\n *\n * Moved to Fixture.\n */\n}","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/** 3D vector */\nexport interface Vec3Value {\n x: number;\n y: number;\n z: number;\n}\n\ndeclare module \"./Vec3\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(x: number, y: number, z: number): Vec3;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(obj: Vec3Value): Vec3;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(): Vec3;\n}\n\n/** 3D vector */\n// @ts-expect-error\nexport class Vec3 {\n x: number;\n y: number;\n z: number;\n\n constructor(x: number, y: number, z: number);\n constructor(obj: Vec3Value);\n constructor();\n constructor(x?, y?, z?) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Vec3)) {\n return new Vec3(x, y, z);\n }\n if (typeof x === \"undefined\") {\n this.x = 0;\n this.y = 0;\n this.z = 0;\n } else if (typeof x === \"object\") {\n this.x = x.x;\n this.y = x.y;\n this.z = x.z;\n } else {\n this.x = x;\n this.y = y;\n this.z = z;\n }\n if (_ASSERT) Vec3.assert(this);\n }\n\n /** @internal */\n _serialize(): object {\n return {\n x: this.x,\n y: this.y,\n z: this.z\n };\n }\n\n /** @internal */\n static _deserialize(data: any): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = data.x;\n obj.y = data.y;\n obj.z = data.z;\n return obj;\n }\n\n /** @hidden */\n static neo(x: number, y: number, z: number): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = x;\n obj.y = y;\n obj.z = z;\n return obj;\n }\n\n static zero(): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = 0;\n obj.y = 0;\n obj.z = 0;\n return obj;\n }\n\n static clone(v: Vec3Value): Vec3 {\n if (_ASSERT) Vec3.assert(v);\n return Vec3.neo(v.x, v.y, v.z);\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n /** Does this vector contain finite coordinates? */\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.x) && Number.isFinite(obj.y) && Number.isFinite(obj.z);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Vec3.isValid(o), \"Invalid Vec3!\", o);\n }\n\n setZero(): Vec3 {\n this.x = 0.0;\n this.y = 0.0;\n this.z = 0.0;\n return this;\n }\n\n set(x: number, y: number, z: number): Vec3 {\n this.x = x;\n this.y = y;\n this.z = z;\n return this;\n }\n\n add(w: Vec3Value): Vec3 {\n this.x += w.x;\n this.y += w.y;\n this.z += w.z;\n return this;\n }\n\n sub(w: Vec3Value): Vec3 {\n this.x -= w.x;\n this.y -= w.y;\n this.z -= w.z;\n return this;\n }\n\n mul(m: number): Vec3 {\n this.x *= m;\n this.y *= m;\n this.z *= m;\n return this;\n }\n\n static areEqual(v: Vec3Value, w: Vec3Value): boolean {\n if (_ASSERT) Vec3.assert(v);\n if (_ASSERT) Vec3.assert(w);\n return v === w ||\n typeof v === \"object\" && v !== null &&\n typeof w === \"object\" && w !== null &&\n v.x === w.x && v.y === w.y && v.z === w.z;\n }\n\n /** Dot product on two vectors */\n static dot(v: Vec3Value, w: Vec3Value): number {\n return v.x * w.x + v.y * w.y + v.z * w.z;\n }\n\n /** Cross product on two vectors */\n static cross(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(\n v.y * w.z - v.z * w.y,\n v.z * w.x - v.x * w.z,\n v.x * w.y - v.y * w.x\n );\n }\n\n static add(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(v.x + w.x, v.y + w.y, v.z + w.z);\n }\n\n static sub(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(v.x - w.x, v.y - w.y, v.z - w.z);\n }\n\n static mul(v: Vec3Value, m: number): Vec3 {\n return new Vec3(m * v.x, m * v.y, m * v.z);\n }\n\n neg(): Vec3 {\n this.x = -this.x;\n this.y = -this.y;\n this.z = -this.z;\n return this;\n }\n\n static neg(v: Vec3Value): Vec3 {\n return new Vec3(-v.x, -v.y, -v.z);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport * as matrix from \"../../common/Matrix\";\nimport { Shape } from \"../Shape\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { AABB, AABBValue, RayCastInput, RayCastOutput } from \"../AABB\";\nimport { MassData } from \"../../dynamics/Body\";\nimport { DistanceProxy } from \"../Distance\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const v2 = matrix.vec2(0, 0);\n\ndeclare module \"./EdgeShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function EdgeShape(v1?: Vec2Value, v2?: Vec2Value): EdgeShape;\n}\n\n/**\n * A line segment (edge) shape. These can be connected in chains or loops to\n * other edge shapes. The connectivity information is used to ensure correct\n * contact normals.\n */\n// @ts-expect-error\nexport class EdgeShape extends Shape {\n static TYPE = \"edge\" as const;\n /** @hidden */ m_type: \"edge\";\n\n /** @hidden */ m_radius: number;\n\n // These are the edge vertices\n /** @hidden */ m_vertex1: Vec2;\n /** @hidden */ m_vertex2: Vec2;\n\n // Optional adjacent vertices. These are used for smooth collision.\n // Used by chain shape.\n /** @hidden */ m_vertex0: Vec2;\n /** @hidden */ m_vertex3: Vec2;\n /** @hidden */ m_hasVertex0: boolean;\n /** @hidden */ m_hasVertex3: boolean;\n\n constructor(v1?: Vec2Value, v2?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof EdgeShape)) {\n return new EdgeShape(v1, v2);\n }\n\n super();\n\n this.m_type = EdgeShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n\n this.m_vertex1 = v1 ? Vec2.clone(v1) : Vec2.zero();\n this.m_vertex2 = v2 ? Vec2.clone(v2) : Vec2.zero();\n\n this.m_vertex0 = Vec2.zero();\n this.m_vertex3 = Vec2.zero();\n this.m_hasVertex0 = false;\n this.m_hasVertex3 = false;\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n vertex1: this.m_vertex1,\n vertex2: this.m_vertex2,\n\n vertex0: this.m_vertex0,\n vertex3: this.m_vertex3,\n hasVertex0: this.m_hasVertex0,\n hasVertex3: this.m_hasVertex3,\n };\n }\n\n /** @internal */\n static _deserialize(data: any): EdgeShape {\n const shape = new EdgeShape(data.vertex1, data.vertex2);\n if (shape.m_hasVertex0) {\n shape.setPrevVertex(data.vertex0);\n }\n if (shape.m_hasVertex3) {\n shape.setNextVertex(data.vertex3);\n }\n return shape;\n }\n\n /** @hidden */\n _reset(): void {\n // noop\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n getType(): \"edge\" {\n return this.m_type;\n }\n\n /** @internal @deprecated */\n setNext(v?: Vec2Value): EdgeShape {\n return this.setNextVertex(v);\n }\n\n /**\n * Optional next vertex, used for smooth collision.\n */\n setNextVertex(v?: Vec2Value): EdgeShape {\n if (v) {\n this.m_vertex3.setVec2(v);\n this.m_hasVertex3 = true;\n } else {\n this.m_vertex3.setZero();\n this.m_hasVertex3 = false;\n }\n return this;\n }\n\n /**\n * Optional next vertex, used for smooth collision.\n */\n getNextVertex(): Vec2 {\n return this.m_vertex3;\n }\n\n /** @internal @deprecated */\n setPrev(v?: Vec2Value): EdgeShape {\n return this.setPrevVertex(v);\n }\n\n /**\n * Optional prev vertex, used for smooth collision.\n */\n setPrevVertex(v?: Vec2Value): EdgeShape {\n if (v) {\n this.m_vertex0.setVec2(v);\n this.m_hasVertex0 = true;\n } else {\n this.m_vertex0.setZero();\n this.m_hasVertex0 = false;\n }\n return this;\n }\n\n /**\n * Optional prev vertex, used for smooth collision.\n */\n getPrevVertex(): Vec2 {\n return this.m_vertex0;\n }\n\n /**\n * Set this as an isolated edge.\n */\n _set(v1: Vec2Value, v2: Vec2Value): EdgeShape {\n this.m_vertex1.setVec2(v1);\n this.m_vertex2.setVec2(v2);\n this.m_hasVertex0 = false;\n this.m_hasVertex3 = false;\n return this;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): EdgeShape {\n const clone = new EdgeShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_vertex1.setVec2(this.m_vertex1);\n clone.m_vertex2.setVec2(this.m_vertex2);\n clone.m_vertex0.setVec2(this.m_vertex0);\n clone.m_vertex3.setVec2(this.m_vertex3);\n clone.m_hasVertex0 = this.m_hasVertex0;\n clone.m_hasVertex3 = this.m_hasVertex3;\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): false {\n return false;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n // p = p1 + t * d\n // v = v1 + s * e\n // p1 + t * d = v1 + s * e\n // s * e - t * d = p1 - v1\n\n // NOT_USED(childIndex);\n\n // Put the ray into the edge's frame of reference.\n const p1 = Rot.mulTVec2(xf.q, Vec2.sub(input.p1, xf.p));\n const p2 = Rot.mulTVec2(xf.q, Vec2.sub(input.p2, xf.p));\n const d = Vec2.sub(p2, p1);\n\n const v1 = this.m_vertex1;\n const v2 = this.m_vertex2;\n const e = Vec2.sub(v2, v1);\n const normal = Vec2.neo(e.y, -e.x);\n normal.normalize();\n\n // q = p1 + t * d\n // dot(normal, q - v1) = 0\n // dot(normal, p1 - v1) + t * dot(normal, d) = 0\n const numerator = Vec2.dot(normal, Vec2.sub(v1, p1));\n const denominator = Vec2.dot(normal, d);\n\n if (denominator == 0.0) {\n return false;\n }\n\n const t = numerator / denominator;\n if (t < 0.0 || input.maxFraction < t) {\n return false;\n }\n\n const q = Vec2.add(p1, Vec2.mulNumVec2(t, d));\n\n // q = v1 + s * r\n // s = dot(q - v1, r) / dot(r, r)\n const r = Vec2.sub(v2, v1);\n const rr = Vec2.dot(r, r);\n if (rr == 0.0) {\n return false;\n }\n\n const s = Vec2.dot(Vec2.sub(q, v1), r) / rr;\n if (s < 0.0 || 1.0 < s) {\n return false;\n }\n\n output.fraction = t;\n if (numerator > 0.0) {\n output.normal = Rot.mulVec2(xf.q, normal).neg();\n } else {\n output.normal = Rot.mulVec2(xf.q, normal);\n }\n return true;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n matrix.transformVec2(v1, xf, this.m_vertex1);\n matrix.transformVec2(v2, xf, this.m_vertex2);\n\n AABB.combinePoints(aabb, v1, v2);\n AABB.extend(aabb, this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density?: number): void {\n massData.mass = 0.0;\n matrix.combine2Vec2(massData.center, 0.5, this.m_vertex1, 0.5, this.m_vertex2);\n massData.I = 0.0;\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n proxy.m_vertices[0] = this.m_vertex1;\n proxy.m_vertices[1] = this.m_vertex2;\n proxy.m_vertices.length = 2;\n proxy.m_count = 2;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Edge = EdgeShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport type { MassData } from \"../../dynamics/Body\";\nimport { AABBValue, RayCastOutput, RayCastInput, AABB } from \"../AABB\";\nimport { DistanceProxy } from \"../Distance\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Shape } from \"../Shape\";\nimport { EdgeShape } from \"./EdgeShape\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const v2 = matrix.vec2(0, 0);\n\ndeclare module \"./ChainShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function ChainShape(vertices?: Vec2Value[], loop?: boolean): ChainShape;\n}\n\n/**\n * A chain shape is a free form sequence of line segments. The chain has\n * two-sided collision, so you can use inside and outside collision. Therefore,\n * you may use any winding order. Connectivity information is used to create\n * smooth collisions.\n *\n * WARNING: The chain will not collide properly if there are self-intersections.\n */\n// @ts-expect-error\nexport class ChainShape extends Shape {\n static TYPE = \"chain\" as const;\n /** @hidden */ m_type: \"chain\";\n\n /** @hidden */ m_radius: number;\n\n /** @hidden */ m_vertices: Vec2[];\n /** @hidden */ m_count: number;\n /** @hidden */ m_prevVertex: Vec2 | null;\n /** @hidden */ m_nextVertex: Vec2 | null;\n /** @hidden */ m_hasPrevVertex: boolean;\n /** @hidden */ m_hasNextVertex: boolean;\n\n /** @hidden */ m_isLoop: boolean;\n\n constructor(vertices?: Vec2Value[], loop?: boolean) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof ChainShape)) {\n return new ChainShape(vertices, loop);\n }\n\n super();\n\n this.m_type = ChainShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n this.m_vertices = [];\n this.m_count = 0;\n this.m_prevVertex = null;\n this.m_nextVertex = null;\n this.m_hasPrevVertex = false;\n this.m_hasNextVertex = false;\n\n this.m_isLoop = !!loop;\n\n if (vertices && vertices.length) {\n if (loop) {\n this._createLoop(vertices);\n } else {\n this._createChain(vertices);\n }\n }\n }\n\n /** @internal */\n _serialize(): object {\n const data = {\n type: this.m_type,\n vertices: this.m_isLoop ? this.m_vertices.slice(0, this.m_vertices.length - 1) : this.m_vertices,\n isLoop: this.m_isLoop,\n hasPrevVertex: this.m_hasPrevVertex,\n hasNextVertex: this.m_hasNextVertex,\n prevVertex: null as Vec2 | null,\n nextVertex: null as Vec2 | null,\n };\n if (this.m_prevVertex) {\n data.prevVertex = this.m_prevVertex;\n }\n if (this.m_nextVertex) {\n data.nextVertex = this.m_nextVertex;\n }\n return data;\n }\n\n /** @internal */\n static _deserialize(data: any, fixture: any, restore: any): ChainShape {\n const vertices: Vec2[] = [];\n if (data.vertices) {\n for (let i = 0; i < data.vertices.length; i++) {\n vertices.push(restore(Vec2, data.vertices[i]));\n }\n }\n const shape = new ChainShape(vertices, data.isLoop);\n if (data.prevVertex) {\n shape.setPrevVertex(data.prevVertex);\n }\n if (data.nextVertex) {\n shape.setNextVertex(data.nextVertex);\n }\n return shape;\n }\n\n // clear() {\n // this.m_vertices.length = 0;\n // this.m_count = 0;\n // }\n\n getType(): \"chain\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n /**\n * @internal\n * Create a loop. This automatically adjusts connectivity.\n *\n * @param vertices an array of vertices, these are copied\n */\n _createLoop(vertices: Vec2Value[]): ChainShape {\n if (_ASSERT) console.assert(this.m_vertices.length == 0 && this.m_count == 0);\n if (_ASSERT) console.assert(vertices.length >= 3);\n if (vertices.length < 3) {\n return;\n }\n\n for (let i = 1; i < vertices.length; ++i) {\n const v1 = vertices[i - 1];\n const v2 = vertices[i];\n // If the code crashes here, it means your vertices are too close together.\n if (_ASSERT) console.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);\n }\n\n this.m_vertices = [];\n this.m_count = vertices.length + 1;\n for (let i = 0; i < vertices.length; ++i) {\n this.m_vertices[i] = Vec2.clone(vertices[i]);\n }\n this.m_vertices[vertices.length] = Vec2.clone(vertices[0]);\n\n this.m_prevVertex = this.m_vertices[this.m_count - 2];\n this.m_nextVertex = this.m_vertices[1];\n this.m_hasPrevVertex = true;\n this.m_hasNextVertex = true;\n return this;\n }\n\n /**\n * @internal\n * Create a chain with isolated end vertices.\n *\n * @param vertices an array of vertices, these are copied\n */\n _createChain(vertices: Vec2Value[]): ChainShape {\n if (_ASSERT) console.assert(this.m_vertices.length == 0 && this.m_count == 0);\n if (_ASSERT) console.assert(vertices.length >= 2);\n for (let i = 1; i < vertices.length; ++i) {\n const v1 = vertices[i - 1];\n const v2 = vertices[i];\n // If the code crashes here, it means your vertices are too close together.\n if (_ASSERT) console.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);\n }\n\n this.m_vertices = [];\n this.m_count = vertices.length;\n for (let i = 0; i < vertices.length; ++i) {\n this.m_vertices[i] = Vec2.clone(vertices[i]);\n }\n\n this.m_prevVertex = null;\n this.m_nextVertex = null;\n this.m_hasPrevVertex = false;\n this.m_hasNextVertex = false;\n return this;\n }\n\n /** @hidden */\n _reset(): void {\n if (this.m_isLoop) {\n this._createLoop(this.m_vertices.slice(0, this.m_vertices.length - 1));\n } else {\n this._createChain(this.m_vertices);\n }\n }\n\n /**\n * Establish connectivity to a vertex that precedes the first vertex. Don't call\n * this for loops.\n */\n setPrevVertex(prevVertex: Vec2): void {\n // todo: copy or reference\n this.m_prevVertex = prevVertex;\n this.m_hasPrevVertex = true;\n }\n\n getPrevVertex(): Vec2 {\n return this.m_prevVertex;\n }\n\n /**\n * Establish connectivity to a vertex that follows the last vertex. Don't call\n * this for loops.\n */\n setNextVertex(nextVertex: Vec2): void {\n // todo: copy or reference\n this.m_nextVertex = nextVertex;\n this.m_hasNextVertex = true;\n }\n\n getNextVertex(): Vec2 {\n return this.m_nextVertex;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): ChainShape {\n const clone = new ChainShape();\n clone._createChain(this.m_vertices);\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_prevVertex = this.m_prevVertex;\n clone.m_nextVertex = this.m_nextVertex;\n clone.m_hasPrevVertex = this.m_hasPrevVertex;\n clone.m_hasNextVertex = this.m_hasNextVertex;\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): number {\n // edge count = vertex count - 1\n return this.m_count - 1;\n }\n\n // Get a child edge.\n getChildEdge(edge: EdgeShape, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count - 1);\n edge.m_type = EdgeShape.TYPE;\n edge.m_radius = this.m_radius;\n\n edge.m_vertex1 = this.m_vertices[childIndex];\n edge.m_vertex2 = this.m_vertices[childIndex + 1];\n\n if (childIndex > 0) {\n edge.m_vertex0 = this.m_vertices[childIndex - 1];\n edge.m_hasVertex0 = true;\n } else {\n edge.m_vertex0 = this.m_prevVertex;\n edge.m_hasVertex0 = this.m_hasPrevVertex;\n }\n\n if (childIndex < this.m_count - 2) {\n edge.m_vertex3 = this.m_vertices[childIndex + 2];\n edge.m_hasVertex3 = true;\n } else {\n edge.m_vertex3 = this.m_nextVertex;\n edge.m_hasVertex3 = this.m_hasNextVertex;\n }\n }\n\n getVertex(index: number): Vec2 {\n if (_ASSERT) console.assert(0 <= index && index <= this.m_count);\n if (index < this.m_count) {\n return this.m_vertices[index];\n } else {\n return this.m_vertices[0];\n }\n }\n\n isLoop(): boolean {\n return this.m_isLoop;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * This always return false.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): false {\n return false;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n\n const edgeShape = new EdgeShape(this.getVertex(childIndex), this.getVertex(childIndex + 1));\n return edgeShape.rayCast(output, input, xf, 0);\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n\n matrix.transformVec2(v1, xf, this.getVertex(childIndex));\n matrix.transformVec2(v2, xf, this.getVertex(childIndex + 1));\n\n AABB.combinePoints(aabb, v1, v2);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * Chains have zero mass.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density?: number): void {\n massData.mass = 0.0;\n matrix.zeroVec2(massData.center);\n massData.I = 0.0;\n }\n\n computeDistanceProxy(proxy: DistanceProxy, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n proxy.m_vertices[0] = this.getVertex(childIndex);\n proxy.m_vertices[1] = this.getVertex(childIndex + 1);\n proxy.m_count = 2;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Chain = ChainShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport type { MassData } from \"../../dynamics/Body\";\nimport { RayCastOutput, RayCastInput, AABBValue } from \"../AABB\";\nimport { DistanceProxy } from \"../Distance\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Shape } from \"../Shape\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const e = matrix.vec2(0, 0);\n/** @internal */ const e1 = matrix.vec2(0, 0);\n/** @internal */ const e2 = matrix.vec2(0, 0);\n/** @internal */ const center = matrix.vec2(0, 0);\n/** @internal */ const s = matrix.vec2(0, 0);\n\ndeclare module \"./PolygonShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PolygonShape(vertices?: Vec2Value[]): PolygonShape;\n}\n\n/**\n * A convex polygon. It is assumed that the interior of the polygon is to the\n * left of each edge. Polygons have a maximum number of vertices equal to\n * Settings.maxPolygonVertices. In most cases you should not need many vertices\n * for a convex polygon. extends Shape\n */\n// @ts-expect-error\nexport class PolygonShape extends Shape {\n static TYPE = \"polygon\" as const;\n /** @hidden */ m_type: \"polygon\";\n\n /** @hidden */ m_centroid: Vec2;\n /** @hidden */ m_vertices: Vec2[]; // [Settings.maxPolygonVertices]\n /** @hidden */ m_normals: Vec2[]; // [Settings.maxPolygonVertices]\n /** @hidden */ m_count: number;\n /** @hidden */ m_radius: number;\n\n constructor(vertices?: Vec2Value[]) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PolygonShape)) {\n return new PolygonShape(vertices);\n }\n\n super();\n\n this.m_type = PolygonShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n this.m_centroid = Vec2.zero();\n this.m_vertices = [];\n this.m_normals = [];\n this.m_count = 0;\n\n if (vertices && vertices.length) {\n this._set(vertices);\n }\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n vertices: this.m_vertices,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, fixture: any, restore: any): PolygonShape {\n const vertices: Vec2[] = [];\n if (data.vertices) {\n for (let i = 0; i < data.vertices.length; i++) {\n vertices.push(restore(Vec2, data.vertices[i]));\n }\n }\n\n const shape = new PolygonShape(vertices);\n return shape;\n }\n\n getType(): \"polygon\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): PolygonShape {\n const clone = new PolygonShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_count = this.m_count;\n clone.m_centroid.setVec2(this.m_centroid);\n for (let i = 0; i < this.m_count; i++) {\n clone.m_vertices.push(this.m_vertices[i].clone());\n }\n for (let i = 0; i < this.m_normals.length; i++) {\n clone.m_normals.push(this.m_normals[i].clone());\n }\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /** @hidden */\n _reset(): void {\n this._set(this.m_vertices);\n }\n\n /**\n * @internal\n *\n * Create a convex hull from the given array of local points. The count must be\n * in the range [3, Settings.maxPolygonVertices].\n *\n * Warning: the points may be re-ordered, even if they form a convex polygon\n * Warning: collinear points are handled but not removed. Collinear points may\n * lead to poor stacking behavior.\n */\n _set(vertices: Vec2Value[]): void {\n if (_ASSERT) console.assert(3 <= vertices.length && vertices.length <= Settings.maxPolygonVertices);\n if (vertices.length < 3) {\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n let n = math_min(vertices.length, Settings.maxPolygonVertices);\n\n // Perform welding and copy vertices into local buffer.\n const ps: Vec2[] = []; // [Settings.maxPolygonVertices];\n for (let i = 0; i < n; ++i) {\n const v = vertices[i];\n\n let unique = true;\n for (let j = 0; j < ps.length; ++j) {\n if (Vec2.distanceSquared(v, ps[j]) < 0.25 * Settings.linearSlopSquared) {\n unique = false;\n break;\n }\n }\n\n if (unique) {\n ps.push(Vec2.clone(v));\n }\n }\n\n n = ps.length;\n if (n < 3) {\n // Polygon is degenerate.\n if (_ASSERT) console.assert(false);\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n // Create the convex hull using the Gift wrapping algorithm\n // http://en.wikipedia.org/wiki/Gift_wrapping_algorithm\n\n // Find the right most point on the hull (in case of multiple points bottom most is used)\n let i0 = 0;\n let x0 = ps[0].x;\n for (let i = 1; i < n; ++i) {\n const x = ps[i].x;\n if (x > x0 || (x === x0 && ps[i].y < ps[i0].y)) {\n i0 = i;\n x0 = x;\n }\n }\n\n const hull = [] as number[]; // [Settings.maxPolygonVertices];\n let m = 0;\n let ih = i0;\n\n while (true) {\n if (_ASSERT) console.assert(m < Settings.maxPolygonVertices);\n hull[m] = ih;\n\n let ie = 0;\n for (let j = 1; j < n; ++j) {\n if (ie === ih) {\n ie = j;\n continue;\n }\n\n const r = Vec2.sub(ps[ie], ps[hull[m]]);\n const v = Vec2.sub(ps[j], ps[hull[m]]);\n const c = Vec2.crossVec2Vec2(r, v);\n // c < 0 means counter-clockwise wrapping, c > 0 means clockwise wrapping\n if (c < 0.0) {\n ie = j;\n }\n\n // Collinearity check\n if (c === 0.0 && v.lengthSquared() > r.lengthSquared()) {\n ie = j;\n }\n }\n\n ++m;\n ih = ie;\n\n if (ie === i0) {\n break;\n }\n }\n\n if (m < 3) {\n // Polygon is degenerate.\n if (_ASSERT) console.assert(false);\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n this.m_count = m;\n\n // Copy vertices.\n this.m_vertices = [];\n for (let i = 0; i < m; ++i) {\n this.m_vertices[i] = ps[hull[i]];\n }\n\n // Compute normals. Ensure the edges have non-zero length.\n for (let i = 0; i < m; ++i) {\n const i1 = i;\n const i2 = i + 1 < m ? i + 1 : 0;\n const edge = Vec2.sub(this.m_vertices[i2], this.m_vertices[i1]);\n if (_ASSERT) console.assert(edge.lengthSquared() > EPSILON * EPSILON);\n this.m_normals[i] = Vec2.crossVec2Num(edge, 1.0);\n this.m_normals[i].normalize();\n }\n\n // Compute the polygon centroid.\n this.m_centroid = computeCentroid(this.m_vertices, m);\n }\n\n /** @internal */ _setAsBox(hx: number, hy: number, center?: Vec2Value, angle?: number): void {\n // start with right-bottom, counter-clockwise, as in Gift wrapping algorithm in PolygonShape._set()\n this.m_vertices[0] = Vec2.neo(hx, -hy);\n this.m_vertices[1] = Vec2.neo(hx, hy);\n this.m_vertices[2] = Vec2.neo(-hx, hy);\n this.m_vertices[3] = Vec2.neo(-hx, -hy);\n\n this.m_normals[0] = Vec2.neo(1.0, 0.0);\n this.m_normals[1] = Vec2.neo(0.0, 1.0);\n this.m_normals[2] = Vec2.neo(-1.0, 0.0);\n this.m_normals[3] = Vec2.neo(0.0, -1.0);\n\n this.m_count = 4;\n\n if (center && Vec2.isValid(center)) {\n angle = angle || 0;\n\n matrix.copyVec2(this.m_centroid, center);\n\n const xf = Transform.identity();\n xf.p.setVec2(center);\n xf.q.setAngle(angle);\n\n // Transform vertices and normals.\n for (let i = 0; i < this.m_count; ++i) {\n this.m_vertices[i] = Transform.mulVec2(xf, this.m_vertices[i]);\n this.m_normals[i] = Rot.mulVec2(xf.q, this.m_normals[i]);\n }\n }\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): boolean {\n const pLocal = matrix.detransformVec2(temp, xf, p);\n\n for (let i = 0; i < this.m_count; ++i) {\n const dot = matrix.dotVec2(this.m_normals[i], pLocal) - matrix.dotVec2(this.m_normals[i], this.m_vertices[i]);\n if (dot > 0.0) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n\n // Put the ray into the polygon's frame of reference.\n const p1 = Rot.mulTVec2(xf.q, Vec2.sub(input.p1, xf.p));\n const p2 = Rot.mulTVec2(xf.q, Vec2.sub(input.p2, xf.p));\n const d = Vec2.sub(p2, p1);\n\n let lower = 0.0;\n let upper = input.maxFraction;\n\n let index = -1;\n\n for (let i = 0; i < this.m_count; ++i) {\n // p = p1 + a * d\n // dot(normal, p - v) = 0\n // dot(normal, p1 - v) + a * dot(normal, d) = 0\n const numerator = Vec2.dot(this.m_normals[i], Vec2.sub(this.m_vertices[i], p1));\n const denominator = Vec2.dot(this.m_normals[i], d);\n\n if (denominator == 0.0) {\n if (numerator < 0.0) {\n return false;\n }\n } else {\n // Note: we want this predicate without division:\n // lower < numerator / denominator, where denominator < 0\n // Since denominator < 0, we have to flip the inequality:\n // lower < numerator / denominator <==> denominator * lower > numerator.\n if (denominator < 0.0 && numerator < lower * denominator) {\n // Increase lower.\n // The segment enters this half-space.\n lower = numerator / denominator;\n index = i;\n } else if (denominator > 0.0 && numerator < upper * denominator) {\n // Decrease upper.\n // The segment exits this half-space.\n upper = numerator / denominator;\n }\n }\n\n // The use of epsilon here causes the assert on lower to trip\n // in some cases. Apparently the use of epsilon was to make edge\n // shapes work, but now those are handled separately.\n // if (upper < lower - matrix.EPSILON)\n if (upper < lower) {\n return false;\n }\n }\n\n if (_ASSERT) console.assert(0.0 <= lower && lower <= input.maxFraction);\n\n if (index >= 0) {\n output.fraction = lower;\n output.normal = Rot.mulVec2(xf.q, this.m_normals[index]);\n return true;\n }\n\n return false;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (let i = 0; i < this.m_count; ++i) {\n const v = matrix.transformVec2(temp, xf, this.m_vertices[i]);\n minX = math_min(minX, v.x);\n maxX = math_max(maxX, v.x);\n minY = math_min(minY, v.y);\n maxY = math_max(maxY, v.y);\n }\n\n matrix.setVec2(aabb.lowerBound, minX - this.m_radius, minY - this.m_radius);\n matrix.setVec2(aabb.upperBound, maxX + this.m_radius, maxY + this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density: number): void {\n // Polygon mass, centroid, and inertia.\n // Let rho be the polygon density in mass per unit area.\n // Then:\n // mass = rho * int(dA)\n // centroid.x = (1/mass) * rho * int(x * dA)\n // centroid.y = (1/mass) * rho * int(y * dA)\n // I = rho * int((x*x + y*y) * dA)\n //\n // We can compute these integrals by summing all the integrals\n // for each triangle of the polygon. To evaluate the integral\n // for a single triangle, we make a change of variables to\n // the (u,v) coordinates of the triangle:\n // x = x0 + e1x * u + e2x * v\n // y = y0 + e1y * u + e2y * v\n // where 0 <= u && 0 <= v && u + v <= 1.\n //\n // We integrate u from [0,1-v] and then v from [0,1].\n // We also need to use the Jacobian of the transformation:\n // D = cross(e1, e2)\n //\n // Simplification: triangle centroid = (1/3) * (p1 + p2 + p3)\n //\n // The rest of the derivation is handled by computer algebra.\n\n if (_ASSERT) console.assert(this.m_count >= 3);\n\n matrix.zeroVec2(center);\n let area = 0.0;\n let I = 0.0;\n\n // s is the reference point for forming triangles.\n // It's location doesn't change the result (except for rounding error).\n matrix.zeroVec2(s);\n\n // This code would put the reference point inside the polygon.\n for (let i = 0; i < this.m_count; ++i) {\n matrix.plusVec2(s, this.m_vertices[i]);\n }\n matrix.scaleVec2(s, 1.0 / this.m_count, s);\n\n const k_inv3 = 1.0 / 3.0;\n\n for (let i = 0; i < this.m_count; ++i) {\n // Triangle vertices.\n matrix.subVec2(e1, this.m_vertices[i], s);\n if ( i + 1 < this.m_count) {\n matrix.subVec2(e2, this.m_vertices[i + 1], s);\n } else {\n matrix.subVec2(e2, this.m_vertices[0], s);\n }\n\n const D = matrix.crossVec2Vec2(e1, e2);\n\n const triangleArea = 0.5 * D;\n area += triangleArea;\n\n // Area weighted centroid\n matrix.combine2Vec2(temp, triangleArea * k_inv3, e1, triangleArea * k_inv3, e2);\n matrix.plusVec2(center, temp);\n\n const ex1 = e1.x;\n const ey1 = e1.y;\n const ex2 = e2.x;\n const ey2 = e2.y;\n\n const intx2 = ex1 * ex1 + ex2 * ex1 + ex2 * ex2;\n const inty2 = ey1 * ey1 + ey2 * ey1 + ey2 * ey2;\n\n I += (0.25 * k_inv3 * D) * (intx2 + inty2);\n }\n\n // Total mass\n massData.mass = density * area;\n\n // Center of mass\n if (_ASSERT) console.assert(area > EPSILON);\n matrix.scaleVec2(center, 1.0 / area, center);\n matrix.addVec2(massData.center, center, s);\n\n // Inertia tensor relative to the local origin (point s).\n massData.I = density * I;\n\n // Shift to center of mass then to original body origin.\n massData.I += massData.mass * (matrix.dotVec2(massData.center, massData.center) - matrix.dotVec2(center, center));\n }\n\n /**\n * Validate convexity. This is a very time consuming operation.\n * @returns true if valid\n */\n validate(): boolean {\n for (let i = 0; i < this.m_count; ++i) {\n const i1 = i;\n const i2 = i < this.m_count - 1 ? i1 + 1 : 0;\n const p = this.m_vertices[i1];\n matrix.subVec2(e, this.m_vertices[i2], p);\n\n for (let j = 0; j < this.m_count; ++j) {\n if (j == i1 || j == i2) {\n continue;\n }\n\n const c = matrix.crossVec2Vec2(e, matrix.subVec2(temp, this.m_vertices[j], p));\n if (c < 0.0) {\n return false;\n }\n }\n }\n\n return true;\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n for (let i = 0; i < this.m_count; ++i) {\n proxy.m_vertices[i] = this.m_vertices[i];\n }\n proxy.m_vertices.length = this.m_count;\n proxy.m_count = this.m_count;\n proxy.m_radius = this.m_radius;\n }\n}\n\n/** @internal */ function computeCentroid(vs: Vec2[], count: number): Vec2 {\n if (_ASSERT) console.assert(count >= 3);\n\n const c = Vec2.zero();\n let area = 0.0;\n\n // pRef is the reference point for forming triangles.\n // It's location doesn't change the result (except for rounding error).\n const pRef = Vec2.zero();\n if (false) {\n // This code would put the reference point inside the polygon.\n for (let i = 0; i < count; ++i) {\n pRef.add(vs[i]);\n }\n pRef.mul(1.0 / count);\n }\n\n const inv3 = 1.0 / 3.0;\n\n for (let i = 0; i < count; ++i) {\n // Triangle vertices.\n const p1 = pRef;\n const p2 = vs[i];\n const p3 = i + 1 < count ? vs[i + 1] : vs[0];\n\n const e1 = Vec2.sub(p2, p1);\n const e2 = Vec2.sub(p3, p1);\n\n const D = Vec2.crossVec2Vec2(e1, e2);\n\n const triangleArea = 0.5 * D;\n area += triangleArea;\n\n // Area weighted centroid\n matrix.combine3Vec2(temp, 1, p1, 1, p2, 1, p3);\n matrix.plusScaleVec2(c, triangleArea * inv3, temp);\n }\n\n // Centroid\n if (_ASSERT) console.assert(area > EPSILON);\n c.mul(1.0 / area);\n return c;\n}\n\nexport const Polygon = PolygonShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Shape } from \"../Shape\";\nimport { AABBValue, RayCastInput, RayCastOutput } from \"../AABB\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { MassData } from \"../../dynamics/Body\";\nimport { DistanceProxy } from \"../Distance\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_PI = Math.PI;\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n\ndeclare module \"./CircleShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function CircleShape(position: Vec2Value, radius?: number): CircleShape;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function CircleShape(radius?: number): CircleShape;\n}\n\n/** Circle shape. */\n// @ts-expect-error\nexport class CircleShape extends Shape {\n static TYPE = \"circle\" as const;\n /** @hidden */ m_type: \"circle\";\n\n /** @hidden */ m_p: Vec2;\n /** @hidden */ m_radius: number;\n\n constructor(position: Vec2Value, radius?: number);\n constructor(radius?: number);\n constructor(a: any, b?: any) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof CircleShape)) {\n return new CircleShape(a, b);\n }\n\n super();\n\n this.m_type = CircleShape.TYPE;\n this.m_p = Vec2.zero();\n this.m_radius = 1;\n\n if (typeof a === \"object\" && Vec2.isValid(a)) {\n this.m_p.setVec2(a);\n\n if (typeof b === \"number\") {\n this.m_radius = b;\n }\n\n } else if (typeof a === \"number\") {\n this.m_radius = a;\n }\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n p: this.m_p,\n radius: this.m_radius,\n };\n }\n\n /** @internal */\n static _deserialize(data: any): CircleShape {\n return new CircleShape(data.p, data.radius);\n }\n\n /** @hidden */\n _reset(): void {\n // noop\n }\n\n getType(): \"circle\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n getCenter(): Vec2 {\n return this.m_p;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): CircleShape {\n const clone = new CircleShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_p = this.m_p.clone();\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): boolean {\n const center = matrix.transformVec2(temp, xf, this.m_p);\n return matrix.distSqrVec2(p, center) <= this.m_radius * this.m_radius;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n // Collision Detection in Interactive 3D Environments by Gino van den Bergen\n // From Section 3.1.2\n // x = s + a * r\n // norm(x) = radius\n\n const position = Vec2.add(xf.p, Rot.mulVec2(xf.q, this.m_p));\n const s = Vec2.sub(input.p1, position);\n const b = Vec2.dot(s, s) - this.m_radius * this.m_radius;\n\n // Solve quadratic equation.\n const r = Vec2.sub(input.p2, input.p1);\n const c = Vec2.dot(s, r);\n const rr = Vec2.dot(r, r);\n const sigma = c * c - rr * b;\n\n // Check for negative discriminant and short segment.\n if (sigma < 0.0 || rr < EPSILON) {\n return false;\n }\n\n // Find the point of intersection of the line with the circle.\n let a = -(c + math_sqrt(sigma));\n\n // Is the intersection point on the segment?\n if (0.0 <= a && a <= input.maxFraction * rr) {\n a /= rr;\n output.fraction = a;\n output.normal = Vec2.add(s, Vec2.mulNumVec2(a, r));\n output.normal.normalize();\n return true;\n }\n\n return false;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n const p = matrix.transformVec2(temp, xf, this.m_p);\n\n matrix.setVec2(aabb.lowerBound, p.x - this.m_radius, p.y - this.m_radius);\n matrix.setVec2(aabb.upperBound, p.x + this.m_radius, p.y + this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density: number): void {\n massData.mass = density * math_PI * this.m_radius * this.m_radius;\n matrix.copyVec2(massData.center, this.m_p);\n // inertia about the local origin\n massData.I = massData.mass * (0.5 * this.m_radius * this.m_radius + matrix.lengthSqrVec2(this.m_p));\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n proxy.m_vertices[0] = this.m_p;\n proxy.m_vertices.length = 1;\n proxy.m_count = 1;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Circle = CircleShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Distance joint definition. This requires defining an anchor point on both\n * bodies and the non-zero length of the distance joint. The definition uses\n * local anchor points so that the initial configuration can violate the\n * constraint slightly. This helps when saving and loading a game. Warning: Do\n * not use a zero or short length.\n */\nexport interface DistanceJointOpt extends JointOpt {\n /**\n * The mass-spring-damper frequency in Hertz. A value of 0 disables softness.\n */\n frequencyHz?: number;\n /**\n * The damping ratio. 0 = no damping, 1 = critical damping.\n */\n dampingRatio?: number;\n /**\n * Distance length.\n */\n length?: number;\n}\n/**\n * Distance joint definition. This requires defining an anchor point on both\n * bodies and the non-zero length of the distance joint. The definition uses\n * local anchor points so that the initial configuration can violate the\n * constraint slightly. This helps when saving and loading a game. Warning: Do\n * not use a zero or short length.\n */\nexport interface DistanceJointDef extends JointDef, DistanceJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n frequencyHz : 0.0,\n dampingRatio : 0.0\n};\n\ndeclare module \"./DistanceJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function DistanceJoint(def: DistanceJointDef): DistanceJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function DistanceJoint(def: DistanceJointOpt, bodyA: Body, bodyB: Body, anchorA: Vec2Value, anchorB: Vec2Value): DistanceJoint;\n}\n\n/**\n * A distance joint constrains two points on two bodies to remain at a fixed\n * distance from each other. You can view this as a massless, rigid rod.\n */\n// @ts-expect-error\nexport class DistanceJoint extends Joint {\n static TYPE = \"distance-joint\" as const;\n\n // Solver shared\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_length: number;\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_gamma: number;\n /** @internal */ m_bias: number;\n\n // Solver temp\n /** @internal */ m_u: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: number;\n\n /**\n * @param def DistanceJoint definition.\n */\n constructor(def: DistanceJointDef);\n /**\n * @param anchorA Anchor A in global coordination.\n * @param anchorB Anchor B in global coordination.\n */\n constructor(def: DistanceJointOpt, bodyA: Body, bodyB: Body, anchorA?: Vec2Value, anchorB?: Vec2Value);\n constructor(def: DistanceJointDef, bodyA?: Body, bodyB?: Body, anchorA?: Vec2Value, anchorB?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof DistanceJoint)) {\n return new DistanceJoint(def, bodyA, bodyB, anchorA, anchorB);\n }\n\n // order of constructor arguments is changed in v0.2\n if (bodyB && anchorA && (\"m_type\" in anchorA) && (\"x\" in bodyB) && (\"y\" in bodyB)) {\n const temp = bodyB;\n bodyB = anchorA as any as Body;\n anchorA = temp as any as Vec2;\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = DistanceJoint.TYPE;\n\n // Solver shared\n this.m_localAnchorA = Vec2.clone(anchorA ? bodyA.getLocalPoint(anchorA) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchorB ? bodyB.getLocalPoint(anchorB) : def.localAnchorB || Vec2.zero());\n this.m_length = Number.isFinite(def.length) ? def.length :\n Vec2.distance(bodyA.getWorldPoint(this.m_localAnchorA), bodyB.getWorldPoint(this.m_localAnchorB));\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n this.m_impulse = 0.0;\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n\n // 1-D constrained system\n // m (v2 - v1) = lambda\n // v2 + (beta/h) * x1 + gamma * lambda = 0, gamma has units of inverse mass.\n // x2 = x1 + h * v2\n\n // 1-D mass-damper-spring system\n // m (v2 - v1) + h * d * v2 + h * k *\n\n // C = norm(p2 - p1) - L\n // u = (p2 - p1) / norm(p2 - p1)\n // Cdot = dot(u, v2 + cross(w2, r2) - v1 - cross(w1, r1))\n // J = [-u -cross(r1, u) u cross(r2, u)]\n // K = J * invM * JT\n // = invMass1 + invI1 * cross(r1, u)^2 + invMass2 + invI2 * cross(r2, u)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n length: this.m_length,\n\n impulse: this.m_impulse,\n gamma: this.m_gamma,\n bias: this.m_bias,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): DistanceJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new DistanceJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n\n if (def.length > 0) {\n this.m_length = +def.length;\n } else if (def.length < 0) { // don't change length\n } else if (def.anchorA || def.anchorA || def.anchorA || def.anchorA) {\n this.m_length = Vec2.distance(\n this.m_bodyA.getWorldPoint(this.m_localAnchorA),\n this.m_bodyB.getWorldPoint(this.m_localAnchorB)\n );\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the natural length. Manipulating the length can lead to non-physical\n * behavior when the frequency is zero.\n */\n setLength(length: number): void {\n this.m_length = length;\n }\n\n /**\n * Get the natural length.\n */\n getLength(): number {\n return this.m_length;\n }\n\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_u).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n this.m_u = Vec2.sub(Vec2.add(cB, this.m_rB), Vec2.add(cA, this.m_rA));\n\n // Handle singularity.\n const length = this.m_u.length();\n if (length > Settings.linearSlop) {\n this.m_u.mul(1.0 / length);\n } else {\n this.m_u.setNum(0.0, 0.0);\n }\n\n const crAu = Vec2.crossVec2Vec2(this.m_rA, this.m_u);\n const crBu = Vec2.crossVec2Vec2(this.m_rB, this.m_u);\n let invMass = this.m_invMassA + this.m_invIA * crAu * crAu + this.m_invMassB + this.m_invIB * crBu * crBu;\n\n // Compute the effective mass matrix.\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n\n if (this.m_frequencyHz > 0.0) {\n const C = length - this.m_length;\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * this.m_mass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = this.m_mass * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (d + h * k);\n this.m_gamma = this.m_gamma != 0.0 ? 1.0 / this.m_gamma : 0.0;\n this.m_bias = C * h * k * this.m_gamma;\n\n invMass += this.m_gamma;\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n } else {\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n }\n\n if (step.warmStarting) {\n // Scale the impulse to support a variable time step.\n this.m_impulse *= step.dtRatio;\n\n const P = Vec2.mulNumVec2(this.m_impulse, this.m_u);\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Cdot = dot(u, v + cross(w, r))\n const vpA = Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA));\n const vpB = Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB));\n const Cdot = Vec2.dot(this.m_u, vpB) - Vec2.dot(this.m_u, vpA);\n\n const impulse = -this.m_mass * (Cdot + this.m_bias + this.m_gamma * this.m_impulse);\n this.m_impulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_u);\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n if (this.m_frequencyHz > 0.0) {\n // There is no position correction for soft distance constraints.\n return true;\n }\n\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n const u = Vec2.sub(Vec2.add(cB, rB), Vec2.add(cA, rA));\n\n const length = u.normalize();\n const C = clamp(length - this.m_length, -Settings.maxLinearCorrection, Settings.maxLinearCorrection);\n\n const impulse = -this.m_mass * C;\n const P = Vec2.mulNumVec2(impulse, u);\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * Vec2.crossVec2Vec2(rA, P);\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, P);\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return math_abs(C) < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Friction joint definition.\n */\nexport interface FrictionJointOpt extends JointOpt {\n /**\n * The maximum friction force in N.\n */\n maxForce?: number;\n /**\n * The maximum friction torque in N-m.\n */\n maxTorque?: number;\n}\n\n/**\n * Friction joint definition.\n */\nexport interface FrictionJointDef extends JointDef, FrictionJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 0.0,\n maxTorque : 0.0,\n};\n\ndeclare module \"./FrictionJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function FrictionJoint(def: FrictionJointDef): FrictionJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function FrictionJoint(def: FrictionJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): FrictionJoint;\n}\n\n/**\n * Friction joint. This is used for top-down friction. It provides 2D\n * translational friction and angular friction.\n */\n// @ts-expect-error\nexport class FrictionJoint extends Joint {\n static TYPE = \"friction-joint\" as const;\n\n /** @internal */ m_type: \"friction-joint\";\n\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n\n // Solver shared\n /** @internal */ m_linearImpulse: Vec2;\n /** @internal */ m_angularImpulse: number;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_maxTorque: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_linearMass: Mat22;\n /** @internal */ m_angularMass: number;\n\n constructor(def: FrictionJointDef);\n /**\n * @param anchor Anchor in global coordination.\n */\n constructor(def: FrictionJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: FrictionJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof FrictionJoint)) {\n return new FrictionJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = FrictionJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n\n // Solver shared\n this.m_linearImpulse = Vec2.zero();\n this.m_angularImpulse = 0.0;\n this.m_maxForce = def.maxForce;\n this.m_maxTorque = def.maxTorque;\n\n // Point-to-point constraint\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Angle constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n maxForce: this.m_maxForce,\n maxTorque: this.m_maxTorque,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): FrictionJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new FrictionJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.maxTorque)) {\n this.m_maxTorque = def.maxTorque;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the maximum friction force in N.\n */\n setMaxForce(force: number): void {\n if (_ASSERT) console.assert(Number.isFinite(force) && force >= 0.0);\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum friction force in N.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the maximum friction torque in N*m.\n */\n setMaxTorque(torque: number): void {\n if (_ASSERT) console.assert(Number.isFinite(torque) && torque >= 0.0);\n this.m_maxTorque = torque;\n }\n\n /**\n * Get the maximum friction torque in N*m.\n */\n getMaxTorque(): number {\n return this.m_maxTorque;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_linearImpulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_angularImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective mass matrix.\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat22();\n K.ex.x = mA + mB + iA * this.m_rA.y * this.m_rA.y + iB * this.m_rB.y\n * this.m_rB.y;\n K.ex.y = -iA * this.m_rA.x * this.m_rA.y - iB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * this.m_rA.x * this.m_rA.x + iB * this.m_rB.x\n * this.m_rB.x;\n\n this.m_linearMass = K.getInverse();\n\n this.m_angularMass = iA + iB;\n if (this.m_angularMass > 0.0) {\n this.m_angularMass = 1.0 / this.m_angularMass;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_linearImpulse.mul(step.dtRatio);\n this.m_angularImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_linearImpulse.x, this.m_linearImpulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_angularImpulse);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_angularImpulse);\n\n } else {\n this.m_linearImpulse.setZero();\n this.m_angularImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const h = step.dt;\n\n // Solve angular friction\n {\n const Cdot = wB - wA;\n let impulse = -this.m_angularMass * Cdot;\n\n const oldImpulse = this.m_angularImpulse;\n const maxImpulse = h * this.m_maxTorque;\n this.m_angularImpulse = clamp(this.m_angularImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_angularImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve linear friction\n {\n const Cdot = Vec2.sub(\n Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB)),\n Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA))\n );\n\n let impulse = Vec2.neg(Mat22.mulVec2(this.m_linearMass, Cdot));\n const oldImpulse = this.m_linearImpulse;\n this.m_linearImpulse.add(impulse);\n\n const maxImpulse = h * this.m_maxForce;\n\n if (this.m_linearImpulse.lengthSquared() > maxImpulse * maxImpulse) {\n this.m_linearImpulse.normalize();\n this.m_linearImpulse.mul(maxImpulse);\n }\n\n impulse = Vec2.sub(this.m_linearImpulse, oldImpulse);\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { Vec3, Vec3Value } from \"./Vec3\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A 3-by-3 matrix. Stored in column-major order.\n */\nexport class Mat33 {\n ex: Vec3;\n ey: Vec3;\n ez: Vec3;\n\n constructor(a: Vec3Value, b: Vec3Value, c: Vec3Value);\n constructor();\n constructor(a?: Vec3Value, b?: Vec3Value, c?: Vec3Value) {\n if (typeof a === \"object\" && a !== null) {\n this.ex = Vec3.clone(a);\n this.ey = Vec3.clone(b);\n this.ez = Vec3.clone(c);\n } else {\n this.ex = Vec3.zero();\n this.ey = Vec3.zero();\n this.ez = Vec3.zero();\n }\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec3.isValid(obj.ex) && Vec3.isValid(obj.ey) && Vec3.isValid(obj.ez);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Mat33.isValid(o), \"Invalid Mat33!\", o);\n }\n\n /**\n * Set this matrix to all zeros.\n */\n setZero(): Mat33 {\n this.ex.setZero();\n this.ey.setZero();\n this.ez.setZero();\n return this;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases.\n */\n solve33(v: Vec3Value): Vec3 {\n // let det = matrix.dotVec3(this.ex, matrix.newCrossVec3(this.ey, this.ez));\n let cross_x = this.ey.y * this.ez.z - this.ey.z * this.ez.y;\n let cross_y = this.ey.z * this.ez.x - this.ey.x * this.ez.z;\n let cross_z = this.ey.x * this.ez.y - this.ey.y * this.ez.x;\n let det = this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const r = new Vec3();\n // r.x = det * matrix.dotVec3(v, matrix.newCrossVec3(this.ey, this.ez));\n cross_x = this.ey.y * this.ez.z - this.ey.z * this.ez.y;\n cross_y = this.ey.z * this.ez.x - this.ey.x * this.ez.z;\n cross_z = this.ey.x * this.ez.y - this.ey.y * this.ez.x;\n r.x = det * (v.x * cross_x + v.y * cross_y + v.z * cross_z);\n\n // r.y = det * matrix.dotVec3(this.ex, matrix.newCrossVec3(v, this.ez));\n cross_x = v.y * this.ez.z - v.z * this.ez.y;\n cross_y = v.z * this.ez.x - v.x * this.ez.z;\n cross_z = v.x * this.ez.y - v.y * this.ez.x;\n r.y = det * (this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z);\n\n // r.z = det * matrix.dotVec3(this.ex, matrix.newCrossVec3(this.ey, v));\n cross_x = this.ey.y * v.z - this.ey.z * v.y;\n cross_y = this.ey.z * v.x - this.ey.x * v.z;\n cross_z = this.ey.x * v.y - this.ey.y * v.x;\n r.z = det * (this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z);\n return r;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases. Solve only the upper 2-by-2 matrix\n * equation.\n */\n solve22(v: Vec2Value): Vec2 {\n const a11 = this.ex.x;\n const a12 = this.ey.x;\n const a21 = this.ex.y;\n const a22 = this.ey.y;\n let det = a11 * a22 - a12 * a21;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const r = Vec2.zero();\n r.x = det * (a22 * v.x - a12 * v.y);\n r.y = det * (a11 * v.y - a21 * v.x);\n return r;\n }\n\n /**\n * Get the inverse of this matrix as a 2-by-2. Returns the zero matrix if\n * singular.\n */\n getInverse22(M: Mat33): void {\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n M.ex.x = det * d;\n M.ey.x = -det * b;\n M.ex.z = 0.0;\n M.ex.y = -det * c;\n M.ey.y = det * a;\n M.ey.z = 0.0;\n M.ez.x = 0.0;\n M.ez.y = 0.0;\n M.ez.z = 0.0;\n }\n\n /**\n * Get the symmetric inverse of this matrix as a 3-by-3. Returns the zero matrix\n * if singular.\n */\n getSymInverse33(M: Mat33): void {\n let det = Vec3.dot(this.ex, Vec3.cross(this.ey, this.ez));\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const a11 = this.ex.x;\n const a12 = this.ey.x;\n const a13 = this.ez.x;\n const a22 = this.ey.y;\n const a23 = this.ez.y;\n const a33 = this.ez.z;\n\n M.ex.x = det * (a22 * a33 - a23 * a23);\n M.ex.y = det * (a13 * a23 - a12 * a33);\n M.ex.z = det * (a12 * a23 - a13 * a22);\n\n M.ey.x = M.ex.y;\n M.ey.y = det * (a11 * a33 - a13 * a13);\n M.ey.z = det * (a13 * a12 - a11 * a23);\n\n M.ez.x = M.ex.z;\n M.ez.y = M.ey.z;\n M.ez.z = det * (a11 * a22 - a12 * a12);\n }\n\n /**\n * Multiply a matrix times a vector.\n */\n static mul(a: Mat33, b: Vec2Value): Vec2;\n static mul(a: Mat33, b: Vec3Value): Vec3;\n static mul(a, b) {\n if (_ASSERT) Mat33.assert(a);\n if (b && \"z\" in b && \"y\" in b && \"x\" in b) {\n if (_ASSERT) Vec3.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y + a.ez.x * b.z;\n const y = a.ex.y * b.x + a.ey.y * b.y + a.ez.y * b.z;\n const z = a.ex.z * b.x + a.ey.z * b.y + a.ez.z * b.z;\n return new Vec3(x, y, z);\n\n } else if (b && \"y\" in b && \"x\" in b) {\n if (_ASSERT) Vec2.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y;\n const y = a.ex.y * b.x + a.ey.y * b.y;\n return Vec2.neo(x, y);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulVec3(a: Mat33, b: Vec3Value): Vec3 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Vec3.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y + a.ez.x * b.z;\n const y = a.ex.y * b.x + a.ey.y * b.y + a.ez.y * b.z;\n const z = a.ex.z * b.x + a.ey.z * b.y + a.ez.z * b.z;\n return new Vec3(x, y, z);\n }\n\n static mulVec2(a: Mat33, b: Vec2Value): Vec2 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y;\n const y = a.ex.y * b.x + a.ey.y * b.y;\n return Vec2.neo(x, y);\n }\n\n static add(a: Mat33, b: Mat33): Mat33 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Mat33.assert(b);\n return new Mat33(\n Vec3.add(a.ex, b.ex),\n Vec3.add(a.ey, b.ey),\n Vec3.add(a.ez, b.ez)\n );\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n\n\n// todo: use string?\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3,\n} \n\n/**\n * Revolute joint definition. This requires defining an anchor point where the\n * bodies are joined. The definition uses local anchor points so that the\n * initial configuration can violate the constraint slightly. You also need to\n * specify the initial relative angle for joint limits. This helps when saving\n * and loading a game.\n *\n * The local anchor points are measured from the body's origin rather than the\n * center of mass because: 1. you might not know where the center of mass will\n * be. 2. if you add/remove shapes from a body and recompute the mass, the\n * joints will be broken.\n */\nexport interface RevoluteJointOpt extends JointOpt {\n /**\n * The lower angle for the joint limit (radians).\n */\n lowerAngle?: number;\n /**\n * The upper angle for the joint limit (radians).\n */\n upperAngle?: number;\n /**\n * The maximum motor torque used to achieve the desired motor speed. Usually\n * in N-m.\n */\n maxMotorTorque?: number;\n /**\n * The desired motor speed. Usually in radians per second.\n */\n motorSpeed?: number;\n /**\n * A flag to enable joint limits.\n */\n enableLimit?: boolean;\n /**\n * A flag to enable the joint motor.\n */\n enableMotor?: boolean;\n}\n\n/**\n * Revolute joint definition. This requires defining an anchor point where the\n * bodies are joined. The definition uses local anchor points so that the\n * initial configuration can violate the constraint slightly. You also need to\n * specify the initial relative angle for joint limits. This helps when saving\n * and loading a game.\n *\n * The local anchor points are measured from the body's origin rather than the\n * center of mass because: 1. you might not know where the center of mass will\n * be. 2. if you add/remove shapes from a body and recompute the mass, the\n * joints will be broken.\n */\nexport interface RevoluteJointDef extends JointDef, RevoluteJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The bodyB angle minus bodyA angle in the reference state (radians).\n */\n referenceAngle?: number;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n lowerAngle : 0.0,\n upperAngle : 0.0,\n maxMotorTorque : 0.0,\n motorSpeed : 0.0,\n enableLimit : false,\n enableMotor : false\n};\n\ndeclare module \"./RevoluteJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RevoluteJoint(def: RevoluteJointDef): RevoluteJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RevoluteJoint(def: RevoluteJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): RevoluteJoint;\n}\n\n/**\n * A revolute joint constrains two bodies to share a common point while they are\n * free to rotate about the point. The relative rotation about the shared point\n * is the joint angle. You can limit the relative rotation with a joint limit\n * that specifies a lower and upper angle. You can use a motor to drive the\n * relative rotation about the shared point. A maximum motor torque is provided\n * so that infinite forces are not generated.\n */\n// @ts-expect-error\nexport class RevoluteJoint extends Joint {\n static TYPE = \"revolute-joint\" as const;\n\n /** @internal */ m_type: \"revolute-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngle: number;\n /** @internal */ m_impulse: Vec3;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_lowerAngle: number;\n /** @internal */ m_upperAngle: number;\n /** @internal */ m_maxMotorTorque: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableLimit: boolean;\n /** @internal */ m_enableMotor: boolean;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n // effective mass for point-to-point constraint.\n /** @internal */ m_mass: Mat33;\n // effective mass for motor/limit angular constraint.\n /** @internal */ m_motorMass: number;\n /** @internal */ m_limitState: number;\n\n constructor(def: RevoluteJointDef);\n constructor(def: RevoluteJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: RevoluteJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof RevoluteJoint)) {\n return new RevoluteJoint(def, bodyA, bodyB, anchor);\n }\n\n def = def ?? {} as RevoluteJointDef;\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_mass = new Mat33();\n this.m_limitState = LimitState.inactiveLimit;\n\n this.m_type = RevoluteJoint.TYPE;\n\n if (Vec2.isValid(anchor)) {\n this.m_localAnchorA = bodyA.getLocalPoint(anchor);\n } else if (Vec2.isValid(def.localAnchorA)) {\n this.m_localAnchorA = Vec2.clone(def.localAnchorA);\n } else {\n this.m_localAnchorA = Vec2.zero();\n }\n\n if (Vec2.isValid(anchor)) {\n this.m_localAnchorB = bodyB.getLocalPoint(anchor);\n } else if (Vec2.isValid(def.localAnchorB)) {\n this.m_localAnchorB = Vec2.clone(def.localAnchorB);\n } else {\n this.m_localAnchorB = Vec2.zero();\n }\n\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n } else {\n this.m_referenceAngle = bodyB.getAngle() - bodyA.getAngle();\n }\n\n this.m_impulse = new Vec3();\n this.m_motorImpulse = 0.0;\n\n this.m_lowerAngle = def.lowerAngle ?? DEFAULTS.lowerAngle;\n this.m_upperAngle = def.upperAngle ?? DEFAULTS.upperAngle;\n this.m_maxMotorTorque = def.maxMotorTorque ?? DEFAULTS.maxMotorTorque;\n this.m_motorSpeed = def.motorSpeed ?? DEFAULTS.motorSpeed;\n this.m_enableLimit = def.enableLimit ?? DEFAULTS.enableLimit;\n this.m_enableMotor = def.enableMotor ?? DEFAULTS.enableMotor;\n\n // Point-to-point constraint\n // C = p2 - p1\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Motor constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n lowerAngle: this.m_lowerAngle,\n upperAngle: this.m_upperAngle,\n maxMotorTorque: this.m_maxMotorTorque,\n motorSpeed: this.m_motorSpeed,\n enableLimit: this.m_enableLimit,\n enableMotor: this.m_enableMotor,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any):RevoluteJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new RevoluteJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n }\n if (def.enableLimit !== undefined) {\n this.m_enableLimit = def.enableLimit;\n }\n if (Number.isFinite(def.lowerAngle)) {\n this.m_lowerAngle = def.lowerAngle;\n }\n if (Number.isFinite(def.upperAngle)) {\n this.m_upperAngle = def.upperAngle;\n }\n if (Number.isFinite(def.maxMotorTorque)) {\n this.m_maxMotorTorque = def.maxMotorTorque;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n if (def.enableMotor !== undefined) {\n this.m_enableMotor = def.enableMotor;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Get the current joint angle in radians.\n */\n getJointAngle(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n return bB.m_sweep.a - bA.m_sweep.a - this.m_referenceAngle;\n }\n\n /**\n * Get the current joint angle speed in radians per second.\n */\n getJointSpeed(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n return bB.m_angularVelocity - bA.m_angularVelocity;\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Get the current motor torque given the inverse time step. Unit is N*m.\n */\n getMotorTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Set the motor speed in radians per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Get the motor speed in radians per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Set the maximum motor torque, usually in N-m.\n */\n setMaxMotorTorque(torque: number): void {\n if (torque == this.m_maxMotorTorque) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorTorque = torque;\n }\n\n getMaxMotorTorque(): number {\n return this.m_maxMotorTorque;\n }\n\n /**\n * Is the joint limit enabled?\n */\n isLimitEnabled(): boolean {\n return this.m_enableLimit;\n }\n\n /**\n * Enable/disable the joint limit.\n */\n enableLimit(flag: boolean): void {\n if (flag != this.m_enableLimit) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableLimit = flag;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Get the lower joint limit in radians.\n */\n getLowerLimit(): number {\n return this.m_lowerAngle;\n }\n\n /**\n * Get the upper joint limit in radians.\n */\n getUpperLimit(): number {\n return this.m_upperAngle;\n }\n\n /**\n * Set the joint limits in radians.\n */\n setLimits(lower: number, upper: number): void {\n if (_ASSERT) console.assert(lower <= upper);\n\n if (lower != this.m_lowerAngle || upper != this.m_upperAngle) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_impulse.z = 0.0;\n this.m_lowerAngle = lower;\n this.m_upperAngle = upper;\n }\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force given the inverse time step. Unit is N.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.neo(this.m_impulse.x, this.m_impulse.y).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque due to the joint limit given the inverse time step.\n * Unit is N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.z;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const fixedRotation = (iA + iB === 0.0);\n\n this.m_mass.ex.x = mA + mB + this.m_rA.y * this.m_rA.y * iA + this.m_rB.y * this.m_rB.y * iB;\n this.m_mass.ey.x = -this.m_rA.y * this.m_rA.x * iA - this.m_rB.y * this.m_rB.x * iB;\n this.m_mass.ez.x = -this.m_rA.y * iA - this.m_rB.y * iB;\n this.m_mass.ex.y = this.m_mass.ey.x;\n this.m_mass.ey.y = mA + mB + this.m_rA.x * this.m_rA.x * iA + this.m_rB.x * this.m_rB.x * iB;\n this.m_mass.ez.y = this.m_rA.x * iA + this.m_rB.x * iB;\n this.m_mass.ex.z = this.m_mass.ez.x;\n this.m_mass.ey.z = this.m_mass.ez.y;\n this.m_mass.ez.z = iA + iB;\n\n this.m_motorMass = iA + iB;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n\n if (this.m_enableMotor == false || fixedRotation) {\n this.m_motorImpulse = 0.0;\n }\n\n if (this.m_enableLimit && fixedRotation == false) {\n const jointAngle = aB - aA - this.m_referenceAngle;\n\n if (math_abs(this.m_upperAngle - this.m_lowerAngle) < 2.0 * Settings.angularSlop) {\n this.m_limitState = LimitState.equalLimits;\n\n } else if (jointAngle <= this.m_lowerAngle) {\n if (this.m_limitState != LimitState.atLowerLimit) {\n this.m_impulse.z = 0.0;\n }\n this.m_limitState = LimitState.atLowerLimit;\n\n } else if (jointAngle >= this.m_upperAngle) {\n if (this.m_limitState != LimitState.atUpperLimit) {\n this.m_impulse.z = 0.0;\n }\n this.m_limitState = LimitState.atUpperLimit;\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_impulse.mul(step.dtRatio);\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_impulse.x, this.m_impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_motorImpulse + this.m_impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_motorImpulse + this.m_impulse.z);\n\n } else {\n this.m_impulse.setZero();\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const fixedRotation = (iA + iB === 0.0);\n\n // Solve motor constraint.\n if (this.m_enableMotor && this.m_limitState != LimitState.equalLimits && fixedRotation == false) {\n const Cdot = wB - wA - this.m_motorSpeed;\n let impulse = -this.m_motorMass * Cdot;\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorTorque;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve limit constraint.\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit && fixedRotation == false) {\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const Cdot2 = wB - wA;\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const impulse = Vec3.neg(this.m_mass.solve33(Cdot));\n\n if (this.m_limitState == LimitState.equalLimits) {\n this.m_impulse.add(impulse);\n\n } else if (this.m_limitState == LimitState.atLowerLimit) {\n const newImpulse = this.m_impulse.z + impulse.z;\n\n if (newImpulse < 0.0) {\n const rhs = Vec2.combine(-1, Cdot1, this.m_impulse.z, Vec2.neo(this.m_mass.ez.x, this.m_mass.ez.y));\n const reduced = this.m_mass.solve22(rhs);\n impulse.x = reduced.x;\n impulse.y = reduced.y;\n impulse.z = -this.m_impulse.z;\n this.m_impulse.x += reduced.x;\n this.m_impulse.y += reduced.y;\n this.m_impulse.z = 0.0;\n\n } else {\n this.m_impulse.add(impulse);\n }\n\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n const newImpulse = this.m_impulse.z + impulse.z;\n\n if (newImpulse > 0.0) {\n const rhs = Vec2.combine(-1, Cdot1, this.m_impulse.z, Vec2.neo(this.m_mass.ez.x, this.m_mass.ez.y));\n const reduced = this.m_mass.solve22(rhs);\n impulse.x = reduced.x;\n impulse.y = reduced.y;\n impulse.z = -this.m_impulse.z;\n this.m_impulse.x += reduced.x;\n this.m_impulse.y += reduced.y;\n this.m_impulse.z = 0.0;\n\n } else {\n this.m_impulse.add(impulse);\n }\n }\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + impulse.z);\n\n } else {\n // Solve point-to-point constraint\n const Cdot = Vec2.zero();\n Cdot.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const impulse = this.m_mass.solve22(Vec2.neg(Cdot));\n\n this.m_impulse.x += impulse.x;\n this.m_impulse.y += impulse.y;\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n let angularError = 0.0;\n let positionError = 0.0;\n\n const fixedRotation = (this.m_invIA + this.m_invIB == 0.0);\n\n // Solve angular limit constraint.\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit && fixedRotation == false) {\n const angle = aB - aA - this.m_referenceAngle;\n let limitImpulse = 0.0;\n\n if (this.m_limitState == LimitState.equalLimits) {\n // Prevent large angular corrections\n const C = clamp(angle - this.m_lowerAngle, -Settings.maxAngularCorrection, Settings.maxAngularCorrection);\n limitImpulse = -this.m_motorMass * C;\n angularError = math_abs(C);\n\n } else if (this.m_limitState == LimitState.atLowerLimit) {\n let C = angle - this.m_lowerAngle;\n angularError = -C;\n\n // Prevent large angular corrections and allow some slop.\n C = clamp(C + Settings.angularSlop, -Settings.maxAngularCorrection, 0.0);\n limitImpulse = -this.m_motorMass * C;\n\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n let C = angle - this.m_upperAngle;\n angularError = C;\n\n // Prevent large angular corrections and allow some slop.\n C = clamp(C - Settings.angularSlop, 0.0, Settings.maxAngularCorrection);\n limitImpulse = -this.m_motorMass * C;\n }\n\n aA -= this.m_invIA * limitImpulse;\n aB += this.m_invIB * limitImpulse;\n }\n\n // Solve point-to-point constraint.\n {\n qA.setAngle(aA);\n qB.setAngle(aB);\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n const C = Vec2.zero();\n C.addCombine(1, cB, 1, rB);\n C.subCombine(1, cA, 1, rA);\n positionError = C.length();\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat22();\n K.ex.x = mA + mB + iA * rA.y * rA.y + iB * rB.y * rB.y;\n K.ex.y = -iA * rA.x * rA.y - iB * rB.x * rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * rA.x * rA.x + iB * rB.x * rB.x;\n\n const impulse = Vec2.neg(K.solve(C));\n\n cA.subMul(mA, impulse);\n aA -= iA * Vec2.crossVec2Vec2(rA, impulse);\n\n cB.addMul(mB, impulse);\n aB += iB * Vec2.crossVec2Vec2(rB, impulse);\n }\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return positionError <= Settings.linearSlop && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3, \n}\n\n/**\n * Prismatic joint definition. This requires defining a line of motion using an\n * axis and an anchor point. The definition uses local anchor points and a local\n * axis so that the initial configuration can violate the constraint slightly.\n * The joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface PrismaticJointOpt extends JointOpt {\n /**\n * Enable/disable the joint limit.\n */\n enableLimit?: boolean;\n /**\n * The lower translation limit, usually in meters.\n */\n lowerTranslation?: number;\n /**\n * The upper translation limit, usually in meters.\n */\n upperTranslation?: number;\n /**\n * Enable/disable the joint motor.\n */\n enableMotor?: boolean;\n /**\n * The maximum motor torque, usually in N-m.\n */\n maxMotorForce?: number;\n /**\n * The desired motor speed in radians per second.\n */\n motorSpeed?: number;\n}\n\n/**\n * Prismatic joint definition. This requires defining a line of motion using an\n * axis and an anchor point. The definition uses local anchor points and a local\n * axis so that the initial configuration can violate the constraint slightly.\n * The joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface PrismaticJointDef extends JointDef, PrismaticJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The local translation unit axis in bodyA.\n */\n localAxisA: Vec2Value;\n /**\n * referenceAngle The constrained angle between the bodies:\n * bodyB_angle - bodyA_angle.\n */\n referenceAngle?: number;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n enableLimit : false,\n lowerTranslation : 0.0,\n upperTranslation : 0.0,\n enableMotor : false,\n maxMotorForce : 0.0,\n motorSpeed : 0.0\n};\n\ndeclare module \"./PrismaticJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PrismaticJoint(def: PrismaticJointDef): PrismaticJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PrismaticJoint(def: PrismaticJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value, axis: Vec2Value): PrismaticJoint;\n}\n\n/**\n * A prismatic joint. This joint provides one degree of freedom: translation\n * along an axis fixed in bodyA. Relative rotation is prevented. You can use a\n * joint limit to restrict the range of motion and a joint motor to drive the\n * motion or to model joint friction.\n */\n// @ts-expect-error\nexport class PrismaticJoint extends Joint {\n static TYPE = \"prismatic-joint\" as const;\n\n /** @internal */ m_type: \"prismatic-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_localXAxisA: Vec2;\n /** @internal */ m_localYAxisA: Vec2;\n /** @internal */ m_referenceAngle: number;\n /** @internal */ m_impulse: Vec3;\n /** @internal */ m_motorMass: number;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_lowerTranslation: number;\n /** @internal */ m_upperTranslation: number;\n /** @internal */ m_maxMotorForce: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableLimit: boolean;\n /** @internal */ m_enableMotor: boolean;\n /** @internal */ m_limitState: number; // TODO enum\n /** @internal */ m_axis: Vec2;\n /** @internal */ m_perp: Vec2;\n // Solver temp\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_s1: number;\n /** @internal */ m_s2: number;\n /** @internal */ m_a1: number;\n /** @internal */ m_a2: number;\n /** @internal */ m_K: Mat33;\n\n constructor(def: PrismaticJointDef);\n constructor(def: PrismaticJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value, axis?: Vec2Value);\n constructor(def: PrismaticJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value, axis?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PrismaticJoint)) {\n return new PrismaticJoint(def, bodyA, bodyB, anchor, axis);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = PrismaticJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n this.m_localXAxisA = Vec2.clone(axis ? bodyA.getLocalVector(axis) : def.localAxisA || Vec2.neo(1.0, 0.0));\n this.m_localXAxisA.normalize();\n this.m_localYAxisA = Vec2.crossNumVec2(1.0, this.m_localXAxisA);\n this.m_referenceAngle = Number.isFinite(def.referenceAngle) ? def.referenceAngle : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_impulse = new Vec3();\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n\n this.m_lowerTranslation = def.lowerTranslation;\n this.m_upperTranslation = def.upperTranslation;\n this.m_maxMotorForce = def.maxMotorForce;\n this.m_motorSpeed = def.motorSpeed;\n this.m_enableLimit = def.enableLimit;\n this.m_enableMotor = def.enableMotor;\n this.m_limitState = LimitState.inactiveLimit;\n\n this.m_axis = Vec2.zero();\n this.m_perp = Vec2.zero();\n\n this.m_K = new Mat33();\n\n // Linear constraint (point-to-line)\n // d = p2 - p1 = x2 + r2 - x1 - r1\n // C = dot(perp, d)\n // Cdot = dot(d, cross(w1, perp)) + dot(perp, v2 + cross(w2, r2) - v1 -\n // cross(w1, r1))\n // = -dot(perp, v1) - dot(cross(d + r1, perp), w1) + dot(perp, v2) +\n // dot(cross(r2, perp), v2)\n // J = [-perp, -cross(d + r1, perp), perp, cross(r2,perp)]\n //\n // Angular constraint\n // C = a2 - a1 + a_initial\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n //\n // K = J * invM * JT\n //\n // J = [-a -s1 a s2]\n // [0 -1 0 1]\n // a = perp\n // s1 = cross(d + r1, a) = cross(p2 - x1, a)\n // s2 = cross(r2, a) = cross(p2 - x2, a)\n\n // Motor/Limit linear constraint\n // C = dot(ax1, d)\n // Cdot = = -dot(ax1, v1) - dot(cross(d + r1, ax1), w1) + dot(ax1, v2) +\n // dot(cross(r2, ax1), v2)\n // J = [-ax1 -cross(d+r1,ax1) ax1 cross(r2,ax1)]\n\n // Block Solver\n // We develop a block solver that includes the joint limit. This makes the\n // limit stiff (inelastic) even\n // when the mass has poor distribution (leading to large torques about the\n // joint anchor points).\n //\n // The Jacobian has 3 rows:\n // J = [-uT -s1 uT s2] // linear\n // [0 -1 0 1] // angular\n // [-vT -a1 vT a2] // limit\n //\n // u = perp\n // v = axis\n // s1 = cross(d + r1, u), s2 = cross(r2, u)\n // a1 = cross(d + r1, v), a2 = cross(r2, v)\n\n // M * (v2 - v1) = JT * df\n // J * v2 = bias\n //\n // v2 = v1 + invM * JT * df\n // J * (v1 + invM * JT * df) = bias\n // K * df = bias - J * v1 = -Cdot\n // K = J * invM * JT\n // Cdot = J * v1 - bias\n //\n // Now solve for f2.\n // df = f2 - f1\n // K * (f2 - f1) = -Cdot\n // f2 = invK * (-Cdot) + f1\n //\n // Clamp accumulated limit impulse.\n // lower: f2(3) = max(f2(3), 0)\n // upper: f2(3) = min(f2(3), 0)\n //\n // Solve for correct f2(1:2)\n // K(1:2, 1:2) * f2(1:2) = -Cdot(1:2) - K(1:2,3) * f2(3) + K(1:2,1:3) * f1\n // = -Cdot(1:2) - K(1:2,3) * f2(3) + K(1:2,1:2) * f1(1:2) + K(1:2,3) * f1(3)\n // K(1:2, 1:2) * f2(1:2) = -Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3)) +\n // K(1:2,1:2) * f1(1:2)\n // f2(1:2) = invK(1:2,1:2) * (-Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3))) +\n // f1(1:2)\n //\n // Now compute impulse to be applied:\n // df = f2 - f1\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n lowerTranslation: this.m_lowerTranslation,\n upperTranslation: this.m_upperTranslation,\n maxMotorForce: this.m_maxMotorForce,\n motorSpeed: this.m_motorSpeed,\n enableLimit: this.m_enableLimit,\n enableMotor: this.m_enableMotor,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n localAxisA: this.m_localXAxisA,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): PrismaticJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.localAxisA = Vec2.clone(data.localAxisA);\n const joint = new PrismaticJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (def.localAxisA) {\n this.m_localXAxisA.setVec2(def.localAxisA);\n this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1.0, def.localAxisA));\n }\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n }\n if (typeof def.enableLimit !== \"undefined\") {\n this.m_enableLimit = !!def.enableLimit;\n }\n if (Number.isFinite(def.lowerTranslation)) {\n this.m_lowerTranslation = def.lowerTranslation;\n }\n if (Number.isFinite(def.upperTranslation)) {\n this.m_upperTranslation = def.upperTranslation;\n }\n if (typeof def.enableMotor !== \"undefined\") {\n this.m_enableMotor = !!def.enableMotor;\n }\n if (Number.isFinite(def.maxMotorForce)) {\n this.m_maxMotorForce = def.maxMotorForce;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * The local joint axis relative to bodyA.\n */\n getLocalAxisA(): Vec2 {\n return this.m_localXAxisA;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Get the current joint translation, usually in meters.\n */\n getJointTranslation(): number {\n const pA = this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n const pB = this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n const d = Vec2.sub(pB, pA);\n const axis = this.m_bodyA.getWorldVector(this.m_localXAxisA);\n\n const translation = Vec2.dot(d, axis);\n return translation;\n }\n\n /**\n * Get the current joint translation speed, usually in meters per second.\n */\n getJointSpeed(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n\n const rA = Rot.mulVec2(bA.m_xf.q, Vec2.sub(this.m_localAnchorA, bA.m_sweep.localCenter));\n const rB = Rot.mulVec2(bB.m_xf.q, Vec2.sub(this.m_localAnchorB, bB.m_sweep.localCenter));\n const p1 = Vec2.add(bA.m_sweep.c, rA);\n const p2 = Vec2.add(bB.m_sweep.c, rB);\n const d = Vec2.sub(p2, p1);\n const axis = Rot.mulVec2(bA.m_xf.q, this.m_localXAxisA);\n\n const vA = bA.m_linearVelocity;\n const vB = bB.m_linearVelocity;\n const wA = bA.m_angularVelocity;\n const wB = bB.m_angularVelocity;\n\n const speed = Vec2.dot(d, Vec2.crossNumVec2(wA, axis)) + Vec2.dot(axis, Vec2.sub(Vec2.addCrossNumVec2(vB, wB, rB), Vec2.addCrossNumVec2(vA, wA, rA)));\n return speed;\n }\n\n /**\n * Is the joint limit enabled?\n */\n isLimitEnabled(): boolean {\n return this.m_enableLimit;\n }\n\n /**\n * Enable/disable the joint limit.\n */\n enableLimit(flag: boolean): void {\n if (flag != this.m_enableLimit) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableLimit = flag;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Get the lower joint limit, usually in meters.\n */\n getLowerLimit(): number {\n return this.m_lowerTranslation;\n }\n\n /**\n * Get the upper joint limit, usually in meters.\n */\n getUpperLimit(): number {\n return this.m_upperTranslation;\n }\n\n /**\n * Set the joint limits, usually in meters.\n */\n setLimits(lower: number, upper: number): void {\n if (_ASSERT) console.assert(lower <= upper);\n if (lower != this.m_lowerTranslation || upper != this.m_upperTranslation) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_lowerTranslation = lower;\n this.m_upperTranslation = upper;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Set the motor speed, usually in meters per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Set the maximum motor force, usually in N.\n */\n setMaxMotorForce(force: number): void {\n if (force == this.m_maxMotorForce) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorForce = force;\n }\n\n getMaxMotorForce(): number {\n return this.m_maxMotorForce;\n }\n\n /**\n * Get the motor speed, usually in meters per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Get the current motor force given the inverse time step, usually in N.\n */\n getMotorForce(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.combine(this.m_impulse.x, this.m_perp, this.m_motorImpulse + this.m_impulse.z, this.m_axis).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.y;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective masses.\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Compute motor Jacobian and effective mass.\n {\n this.m_axis = Rot.mulVec2(qA, this.m_localXAxisA);\n this.m_a1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_axis);\n this.m_a2 = Vec2.crossVec2Vec2(rB, this.m_axis);\n\n this.m_motorMass = mA + mB + iA * this.m_a1 * this.m_a1 + iB * this.m_a2\n * this.m_a2;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n }\n\n // Prismatic constraint.\n {\n this.m_perp = Rot.mulVec2(qA, this.m_localYAxisA);\n\n this.m_s1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_perp);\n this.m_s2 = Vec2.crossVec2Vec2(rB, this.m_perp);\n\n const s1test = Vec2.crossVec2Vec2(rA, this.m_perp);\n\n const k11 = mA + mB + iA * this.m_s1 * this.m_s1 + iB * this.m_s2 * this.m_s2;\n const k12 = iA * this.m_s1 + iB * this.m_s2;\n const k13 = iA * this.m_s1 * this.m_a1 + iB * this.m_s2 * this.m_a2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n // For bodies with fixed rotation.\n k22 = 1.0;\n }\n const k23 = iA * this.m_a1 + iB * this.m_a2;\n const k33 = mA + mB + iA * this.m_a1 * this.m_a1 + iB * this.m_a2 * this.m_a2;\n\n this.m_K.ex.set(k11, k12, k13);\n this.m_K.ey.set(k12, k22, k23);\n this.m_K.ez.set(k13, k23, k33);\n }\n\n // Compute motor and limit terms.\n if (this.m_enableLimit) {\n\n const jointTranslation = Vec2.dot(this.m_axis, d);\n if (math_abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * Settings.linearSlop) {\n this.m_limitState = LimitState.equalLimits;\n\n } else if (jointTranslation <= this.m_lowerTranslation) {\n if (this.m_limitState != LimitState.atLowerLimit) {\n this.m_limitState = LimitState.atLowerLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else if (jointTranslation >= this.m_upperTranslation) {\n if (this.m_limitState != LimitState.atUpperLimit) {\n this.m_limitState = LimitState.atUpperLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n if (this.m_enableMotor == false) {\n this.m_motorImpulse = 0.0;\n }\n\n if (step.warmStarting) {\n // Account for variable time step.\n this.m_impulse.mul(step.dtRatio);\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.combine(this.m_impulse.x, this.m_perp, this.m_motorImpulse\n + this.m_impulse.z, this.m_axis);\n const LA = this.m_impulse.x * this.m_s1 + this.m_impulse.y\n + (this.m_motorImpulse + this.m_impulse.z) * this.m_a1;\n const LB = this.m_impulse.x * this.m_s2 + this.m_impulse.y\n + (this.m_motorImpulse + this.m_impulse.z) * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n } else {\n this.m_impulse.setZero();\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Solve linear motor constraint.\n if (this.m_enableMotor && this.m_limitState != LimitState.equalLimits) {\n const Cdot = Vec2.dot(this.m_axis, Vec2.sub(vB, vA)) + this.m_a2 * wB\n - this.m_a1 * wA;\n let impulse = this.m_motorMass * (this.m_motorSpeed - Cdot);\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorForce;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse,\n -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_axis);\n const LA = impulse * this.m_a1;\n const LB = impulse * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n const Cdot1 = Vec2.zero();\n Cdot1.x += Vec2.dot(this.m_perp, vB) + this.m_s2 * wB;\n Cdot1.x -= Vec2.dot(this.m_perp, vA) + this.m_s1 * wA;\n Cdot1.y = wB - wA;\n\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit) {\n // Solve prismatic and limit constraint in block form.\n let Cdot2 = 0;\n Cdot2 += Vec2.dot(this.m_axis, vB) + this.m_a2 * wB;\n Cdot2 -= Vec2.dot(this.m_axis, vA) + this.m_a1 * wA;\n\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const f1 = Vec3.clone(this.m_impulse);\n let df = this.m_K.solve33(Vec3.neg(Cdot));\n this.m_impulse.add(df);\n\n if (this.m_limitState == LimitState.atLowerLimit) {\n this.m_impulse.z = math_max(this.m_impulse.z, 0.0);\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n this.m_impulse.z = math_min(this.m_impulse.z, 0.0);\n }\n\n // f2(1:2) = invK(1:2,1:2) * (-Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3))) +\n // f1(1:2)\n const b = Vec2.combine(-1, Cdot1, -(this.m_impulse.z - f1.z), Vec2.neo(this.m_K.ez.x, this.m_K.ez.y));\n const f2r = Vec2.add(this.m_K.solve22(b), Vec2.neo(f1.x, f1.y));\n this.m_impulse.x = f2r.x;\n this.m_impulse.y = f2r.y;\n\n df = Vec3.sub(this.m_impulse, f1);\n\n const P = Vec2.combine(df.x, this.m_perp, df.z, this.m_axis);\n const LA = df.x * this.m_s1 + df.y + df.z * this.m_a1;\n const LB = df.x * this.m_s2 + df.y + df.z * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n } else {\n // Limit is inactive, just solve the prismatic constraint in block form.\n const df = this.m_K.solve22(Vec2.neg(Cdot1));\n this.m_impulse.x += df.x;\n this.m_impulse.y += df.y;\n\n const P = Vec2.mulNumVec2(df.x, this.m_perp);\n const LA = df.x * this.m_s1 + df.y;\n const LB = df.x * this.m_s2 + df.y;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Compute fresh Jacobians\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.sub(Vec2.add(cB, rB), Vec2.add(cA, rA));\n\n const axis = Rot.mulVec2(qA, this.m_localXAxisA);\n const a1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), axis);\n const a2 = Vec2.crossVec2Vec2(rB, axis);\n const perp = Rot.mulVec2(qA, this.m_localYAxisA);\n\n const s1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), perp);\n const s2 = Vec2.crossVec2Vec2(rB, perp);\n\n let impulse = new Vec3();\n const C1 = Vec2.zero();\n C1.x = Vec2.dot(perp, d);\n C1.y = aB - aA - this.m_referenceAngle;\n\n let linearError = math_abs(C1.x);\n const angularError = math_abs(C1.y);\n\n const linearSlop = Settings.linearSlop;\n const maxLinearCorrection = Settings.maxLinearCorrection;\n\n let active = false; // bool\n let C2 = 0.0;\n if (this.m_enableLimit) {\n\n const translation = Vec2.dot(axis, d);\n if (math_abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * linearSlop) {\n // Prevent large angular corrections\n C2 = clamp(translation, -maxLinearCorrection, maxLinearCorrection);\n linearError = math_max(linearError, math_abs(translation));\n active = true;\n\n } else if (translation <= this.m_lowerTranslation) {\n // Prevent large linear corrections and allow some slop.\n C2 = clamp(translation - this.m_lowerTranslation + linearSlop,\n -maxLinearCorrection, 0.0);\n linearError = Math\n .max(linearError, this.m_lowerTranslation - translation);\n active = true;\n\n } else if (translation >= this.m_upperTranslation) {\n // Prevent large linear corrections and allow some slop.\n C2 = clamp(translation - this.m_upperTranslation - linearSlop, 0.0,\n maxLinearCorrection);\n linearError = Math\n .max(linearError, translation - this.m_upperTranslation);\n active = true;\n }\n }\n\n if (active) {\n const k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2;\n const k12 = iA * s1 + iB * s2;\n const k13 = iA * s1 * a1 + iB * s2 * a2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n // For fixed rotation\n k22 = 1.0;\n }\n const k23 = iA * a1 + iB * a2;\n const k33 = mA + mB + iA * a1 * a1 + iB * a2 * a2;\n\n const K = new Mat33();\n K.ex.set(k11, k12, k13);\n K.ey.set(k12, k22, k23);\n K.ez.set(k13, k23, k33);\n\n const C = new Vec3();\n C.x = C1.x;\n C.y = C1.y;\n C.z = C2;\n\n impulse = K.solve33(Vec3.neg(C));\n } else {\n const k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2;\n const k12 = iA * s1 + iB * s2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n k22 = 1.0;\n }\n\n const K = new Mat22();\n K.ex.setNum(k11, k12);\n K.ey.setNum(k12, k22);\n\n const impulse1 = K.solve(Vec2.neg(C1));\n impulse.x = impulse1.x;\n impulse.y = impulse1.y;\n impulse.z = 0.0;\n }\n\n const P = Vec2.combine(impulse.x, perp, impulse.z, axis);\n const LA = impulse.x * s1 + impulse.y + impulse.z * a1;\n const LB = impulse.x * s2 + impulse.y + impulse.z * a2;\n\n cA.subMul(mA, P);\n aA -= iA * LA;\n cB.addMul(mB, P);\n aB += iB * LB;\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return linearError <= Settings.linearSlop\n && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { } from \"../../common/Math\";\nimport { Vec2 } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { RevoluteJoint } from \"./RevoluteJoint\";\nimport { PrismaticJoint } from \"./PrismaticJoint\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Gear joint definition.\n */\nexport interface GearJointOpt extends JointOpt {\n /**\n * The gear ratio. See {@link GearJoint} for explanation.\n */\n ratio?: number;\n}\n\n/**\n * Gear joint definition.\n */\nexport interface GearJointDef extends JointDef, GearJointOpt {\n /**\n * The first revolute/prismatic joint attached to the gear joint.\n */\n joint1: RevoluteJoint | PrismaticJoint;\n /**\n * The second prismatic/revolute joint attached to the gear joint.\n */\n joint2: RevoluteJoint | PrismaticJoint;\n}\n\n/** @internal */ const DEFAULTS = {\n ratio : 1.0\n};\n\ndeclare module \"./GearJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function GearJoint(def: GearJointDef): GearJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function GearJoint(def: GearJointOpt, bodyA: Body, bodyB: Body, joint1: RevoluteJoint | PrismaticJoint, joint2: RevoluteJoint | PrismaticJoint, ratio?: number): GearJoint;\n}\n\n/**\n * A gear joint is used to connect two joints together. Either joint can be a\n * revolute or prismatic joint. You specify a gear ratio to bind the motions\n * together: coordinate1 + ratio * coordinate2 = constant\n *\n * The ratio can be negative or positive. If one joint is a revolute joint and\n * the other joint is a prismatic joint, then the ratio will have units of\n * length or units of 1/length. Warning: You have to manually destroy the gear\n * joint if joint1 or joint2 is destroyed.\n *\n * This definition requires two existing revolute or prismatic joints (any\n * combination will work).\n */\n// @ts-expect-error\nexport class GearJoint extends Joint {\n static TYPE = \"gear-joint\" as const;\n\n /** @internal */ m_type: \"gear-joint\";\n /** @internal */ m_joint1: RevoluteJoint | PrismaticJoint;\n /** @internal */ m_joint2: RevoluteJoint | PrismaticJoint;\n /** @internal */ m_type1: \"revolute-joint\" | \"prismatic-joint\";\n /** @internal */ m_type2: \"revolute-joint\" | \"prismatic-joint\";\n /** @internal */ m_bodyC: Body;\n /** @internal */ m_localAnchorC: Vec2;\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_referenceAngleA: number;\n /** @internal */ m_localAxisC: Vec2;\n /** @internal */ m_bodyD: Body;\n /** @internal */ m_localAnchorD: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngleB: number;\n /** @internal */ m_localAxisD: Vec2;\n /** @internal */ m_ratio: number;\n /** @internal */ m_constant: number;\n /** @internal */ m_impulse: number;\n\n // Solver temp\n /** @internal */ m_lcA: Vec2;\n /** @internal */ m_lcB: Vec2;\n /** @internal */ m_lcC: Vec2;\n /** @internal */ m_lcD: Vec2;\n /** @internal */ m_mA: number;\n /** @internal */ m_mB: number;\n /** @internal */ m_mC: number;\n /** @internal */ m_mD: number;\n /** @internal */ m_iA: number;\n /** @internal */ m_iB: number;\n /** @internal */ m_iC: number;\n /** @internal */ m_iD: number;\n /** @internal */ m_JvAC: Vec2;\n /** @internal */ m_JvBD: Vec2;\n /** @internal */ m_JwA: number;\n /** @internal */ m_JwB: number;\n /** @internal */ m_JwC: number;\n /** @internal */ m_JwD: number;\n /** @internal */ m_mass: number;\n\n constructor(def: GearJointDef);\n constructor(def: GearJointOpt, bodyA: Body, bodyB: Body, joint1: RevoluteJoint | PrismaticJoint, joint2: RevoluteJoint | PrismaticJoint, ratio?: number);\n constructor(def: GearJointDef, bodyA?: Body, bodyB?: Body, joint1?: RevoluteJoint | PrismaticJoint, joint2?: RevoluteJoint | PrismaticJoint, ratio?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof GearJoint)) {\n return new GearJoint(def, bodyA, bodyB, joint1, joint2, ratio);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = GearJoint.TYPE;\n\n if (_ASSERT) console.assert(joint1.m_type === RevoluteJoint.TYPE || joint1.m_type === PrismaticJoint.TYPE);\n if (_ASSERT) console.assert(joint2.m_type === RevoluteJoint.TYPE || joint2.m_type === PrismaticJoint.TYPE);\n\n this.m_joint1 = joint1 ? joint1 : def.joint1;\n this.m_joint2 = joint2 ? joint2 : def.joint2;\n this.m_ratio = Number.isFinite(ratio) ? ratio : def.ratio;\n\n this.m_type1 = this.m_joint1.getType() as \"revolute-joint\" | \"prismatic-joint\";\n this.m_type2 = this.m_joint2.getType() as \"revolute-joint\" | \"prismatic-joint\";\n\n // joint1 connects body A to body C\n // joint2 connects body B to body D\n\n let coordinateA: number;\n let coordinateB: number;\n\n // TODO_ERIN there might be some problem with the joint edges in Joint.\n\n this.m_bodyC = this.m_joint1.getBodyA();\n this.m_bodyA = this.m_joint1.getBodyB();\n\n // Get geometry of joint1\n const xfA = this.m_bodyA.m_xf;\n const aA = this.m_bodyA.m_sweep.a;\n const xfC = this.m_bodyC.m_xf;\n const aC = this.m_bodyC.m_sweep.a;\n\n if (this.m_type1 === RevoluteJoint.TYPE) {\n const revolute = this.m_joint1 as RevoluteJoint;\n this.m_localAnchorC = revolute.m_localAnchorA;\n this.m_localAnchorA = revolute.m_localAnchorB;\n this.m_referenceAngleA = revolute.m_referenceAngle;\n this.m_localAxisC = Vec2.zero();\n\n coordinateA = aA - aC - this.m_referenceAngleA;\n } else {\n const prismatic = this.m_joint1 as PrismaticJoint;\n this.m_localAnchorC = prismatic.m_localAnchorA;\n this.m_localAnchorA = prismatic.m_localAnchorB;\n this.m_referenceAngleA = prismatic.m_referenceAngle;\n this.m_localAxisC = prismatic.m_localXAxisA;\n\n const pC = this.m_localAnchorC;\n const pA = Rot.mulTVec2(xfC.q, Vec2.add(Rot.mulVec2(xfA.q, this.m_localAnchorA), Vec2.sub(xfA.p, xfC.p)));\n coordinateA = Vec2.dot(pA, this.m_localAxisC) - Vec2.dot(pC, this.m_localAxisC);\n }\n\n this.m_bodyD = this.m_joint2.getBodyA();\n this.m_bodyB = this.m_joint2.getBodyB();\n\n // Get geometry of joint2\n const xfB = this.m_bodyB.m_xf;\n const aB = this.m_bodyB.m_sweep.a;\n const xfD = this.m_bodyD.m_xf;\n const aD = this.m_bodyD.m_sweep.a;\n\n if (this.m_type2 === RevoluteJoint.TYPE) {\n const revolute = this.m_joint2 as RevoluteJoint;\n this.m_localAnchorD = revolute.m_localAnchorA;\n this.m_localAnchorB = revolute.m_localAnchorB;\n this.m_referenceAngleB = revolute.m_referenceAngle;\n this.m_localAxisD = Vec2.zero();\n\n coordinateB = aB - aD - this.m_referenceAngleB;\n } else {\n const prismatic = this.m_joint2 as PrismaticJoint;\n this.m_localAnchorD = prismatic.m_localAnchorA;\n this.m_localAnchorB = prismatic.m_localAnchorB;\n this.m_referenceAngleB = prismatic.m_referenceAngle;\n this.m_localAxisD = prismatic.m_localXAxisA;\n\n const pD = this.m_localAnchorD;\n const pB = Rot.mulTVec2(xfD.q, Vec2.add(Rot.mulVec2(xfB.q, this.m_localAnchorB), Vec2.sub(xfB.p, xfD.p)));\n coordinateB = Vec2.dot(pB, this.m_localAxisD) - Vec2.dot(pD, this.m_localAxisD);\n }\n\n this.m_constant = coordinateA + this.m_ratio * coordinateB;\n\n this.m_impulse = 0.0;\n\n // Gear Joint:\n // C0 = (coordinate1 + ratio * coordinate2)_initial\n // C = (coordinate1 + ratio * coordinate2) - C0 = 0\n // J = [J1 ratio * J2]\n // K = J * invM * JT\n // = J1 * invM1 * J1T + ratio * ratio * J2 * invM2 * J2T\n //\n // Revolute:\n // coordinate = rotation\n // Cdot = angularVelocity\n // J = [0 0 1]\n // K = J * invM * JT = invI\n //\n // Prismatic:\n // coordinate = dot(p - pg, ug)\n // Cdot = dot(v + cross(w, r), ug)\n // J = [ug cross(r, ug)]\n // K = J * invM * JT = invMass + invI * cross(r, ug)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n joint1: this.m_joint1,\n joint2: this.m_joint2,\n ratio: this.m_ratio,\n\n // _constant: this.m_constant,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): GearJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.joint1 = restore(Joint, data.joint1, world);\n data.joint2 = restore(Joint, data.joint2, world);\n const joint = new GearJoint(data);\n // if (data._constant) joint.m_constant = data._constant;\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n // todo: implement other fields\n if (Number.isFinite(def.ratio)) {\n this.m_ratio = def.ratio;\n }\n }\n\n /**\n * Get the first joint.\n */\n getJoint1(): Joint {\n return this.m_joint1;\n }\n\n /**\n * Get the second joint.\n */\n getJoint2(): Joint {\n return this.m_joint2;\n }\n\n /**\n * Set the gear ratio.\n */\n setRatio(ratio: number): void {\n if (_ASSERT) console.assert(Number.isFinite(ratio));\n this.m_ratio = ratio;\n }\n\n /**\n * Get the gear ratio.\n */\n getRatio(): number {\n return this.m_ratio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_JvAC).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n const L = this.m_impulse * this.m_JwA;\n return inv_dt * L;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_lcA = this.m_bodyA.m_sweep.localCenter;\n this.m_lcB = this.m_bodyB.m_sweep.localCenter;\n this.m_lcC = this.m_bodyC.m_sweep.localCenter;\n this.m_lcD = this.m_bodyD.m_sweep.localCenter;\n this.m_mA = this.m_bodyA.m_invMass;\n this.m_mB = this.m_bodyB.m_invMass;\n this.m_mC = this.m_bodyC.m_invMass;\n this.m_mD = this.m_bodyD.m_invMass;\n this.m_iA = this.m_bodyA.m_invI;\n this.m_iB = this.m_bodyB.m_invI;\n this.m_iC = this.m_bodyC.m_invI;\n this.m_iD = this.m_bodyD.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const aC = this.m_bodyC.c_position.a;\n const vC = this.m_bodyC.c_velocity.v;\n let wC = this.m_bodyC.c_velocity.w;\n\n const aD = this.m_bodyD.c_position.a;\n const vD = this.m_bodyD.c_velocity.v;\n let wD = this.m_bodyD.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n const qC = Rot.neo(aC);\n const qD = Rot.neo(aD);\n\n this.m_mass = 0.0;\n\n if (this.m_type1 == RevoluteJoint.TYPE) {\n this.m_JvAC = Vec2.zero();\n this.m_JwA = 1.0;\n this.m_JwC = 1.0;\n this.m_mass += this.m_iA + this.m_iC;\n } else {\n const u = Rot.mulVec2(qC, this.m_localAxisC);\n const rC = Rot.mulSub(qC, this.m_localAnchorC, this.m_lcC);\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_lcA);\n this.m_JvAC = u;\n this.m_JwC = Vec2.crossVec2Vec2(rC, u);\n this.m_JwA = Vec2.crossVec2Vec2(rA, u);\n this.m_mass += this.m_mC + this.m_mA + this.m_iC * this.m_JwC * this.m_JwC + this.m_iA * this.m_JwA * this.m_JwA;\n }\n\n if (this.m_type2 == RevoluteJoint.TYPE) {\n this.m_JvBD = Vec2.zero();\n this.m_JwB = this.m_ratio;\n this.m_JwD = this.m_ratio;\n this.m_mass += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD);\n } else {\n const u = Rot.mulVec2(qD, this.m_localAxisD);\n const rD = Rot.mulSub(qD, this.m_localAnchorD, this.m_lcD);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_lcB);\n this.m_JvBD = Vec2.mulNumVec2(this.m_ratio, u);\n this.m_JwD = this.m_ratio * Vec2.crossVec2Vec2(rD, u);\n this.m_JwB = this.m_ratio * Vec2.crossVec2Vec2(rB, u);\n this.m_mass += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * this.m_JwD * this.m_JwD + this.m_iB * this.m_JwB * this.m_JwB;\n }\n\n // Compute effective mass.\n this.m_mass = this.m_mass > 0.0 ? 1.0 / this.m_mass : 0.0;\n\n if (step.warmStarting) {\n vA.addMul(this.m_mA * this.m_impulse, this.m_JvAC);\n wA += this.m_iA * this.m_impulse * this.m_JwA;\n\n vB.addMul(this.m_mB * this.m_impulse, this.m_JvBD);\n wB += this.m_iB * this.m_impulse * this.m_JwB;\n\n vC.subMul(this.m_mC * this.m_impulse, this.m_JvAC);\n wC -= this.m_iC * this.m_impulse * this.m_JwC;\n\n vD.subMul(this.m_mD * this.m_impulse, this.m_JvBD);\n wD -= this.m_iD * this.m_impulse * this.m_JwD;\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n this.m_bodyC.c_velocity.v.setVec2(vC);\n this.m_bodyC.c_velocity.w = wC;\n this.m_bodyD.c_velocity.v.setVec2(vD);\n this.m_bodyD.c_velocity.w = wD;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n const vC = this.m_bodyC.c_velocity.v;\n let wC = this.m_bodyC.c_velocity.w;\n const vD = this.m_bodyD.c_velocity.v;\n let wD = this.m_bodyD.c_velocity.w;\n\n let Cdot = Vec2.dot(this.m_JvAC, vA) - Vec2.dot(this.m_JvAC, vC) + Vec2.dot(this.m_JvBD, vB) - Vec2.dot(this.m_JvBD, vD);\n Cdot += (this.m_JwA * wA - this.m_JwC * wC) + (this.m_JwB * wB - this.m_JwD * wD);\n\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n vA.addMul(this.m_mA * impulse, this.m_JvAC);\n wA += this.m_iA * impulse * this.m_JwA;\n vB.addMul(this.m_mB * impulse, this.m_JvBD);\n wB += this.m_iB * impulse * this.m_JwB;\n vC.subMul(this.m_mC * impulse, this.m_JvAC);\n wC -= this.m_iC * impulse * this.m_JwC;\n vD.subMul(this.m_mD * impulse, this.m_JvBD);\n wD -= this.m_iD * impulse * this.m_JwD;\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n this.m_bodyC.c_velocity.v.setVec2(vC);\n this.m_bodyC.c_velocity.w = wC;\n this.m_bodyD.c_velocity.v.setVec2(vD);\n this.m_bodyD.c_velocity.w = wD;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n const cC = this.m_bodyC.c_position.c;\n let aC = this.m_bodyC.c_position.a;\n const cD = this.m_bodyD.c_position.c;\n let aD = this.m_bodyD.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n const qC = Rot.neo(aC);\n const qD = Rot.neo(aD);\n\n const linearError = 0.0;\n\n let coordinateA: number;\n let coordinateB: number;\n\n let JvAC: Vec2;\n let JvBD: Vec2;\n let JwA: number;\n let JwB: number;\n let JwC: number;\n let JwD: number;\n let mass = 0.0;\n\n if (this.m_type1 == RevoluteJoint.TYPE) {\n JvAC = Vec2.zero();\n JwA = 1.0;\n JwC = 1.0;\n mass += this.m_iA + this.m_iC;\n\n coordinateA = aA - aC - this.m_referenceAngleA;\n } else {\n const u = Rot.mulVec2(qC, this.m_localAxisC);\n const rC = Rot.mulSub(qC, this.m_localAnchorC, this.m_lcC);\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_lcA);\n JvAC = u;\n JwC = Vec2.crossVec2Vec2(rC, u);\n JwA = Vec2.crossVec2Vec2(rA, u);\n mass += this.m_mC + this.m_mA + this.m_iC * JwC * JwC + this.m_iA * JwA * JwA;\n\n const pC = Vec2.sub(this.m_localAnchorC, this.m_lcC);\n const pA = Rot.mulTVec2(qC, Vec2.add(rA, Vec2.sub(cA, cC)));\n coordinateA = Vec2.dot(Vec2.sub(pA, pC), this.m_localAxisC);\n }\n\n if (this.m_type2 == RevoluteJoint.TYPE) {\n JvBD = Vec2.zero();\n JwB = this.m_ratio;\n JwD = this.m_ratio;\n mass += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD);\n\n coordinateB = aB - aD - this.m_referenceAngleB;\n } else {\n const u = Rot.mulVec2(qD, this.m_localAxisD);\n const rD = Rot.mulSub(qD, this.m_localAnchorD, this.m_lcD);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_lcB);\n JvBD = Vec2.mulNumVec2(this.m_ratio, u);\n JwD = this.m_ratio * Vec2.crossVec2Vec2(rD, u);\n JwB = this.m_ratio * Vec2.crossVec2Vec2(rB, u);\n mass += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * JwD * JwD + this.m_iB * JwB * JwB;\n\n const pD = Vec2.sub(this.m_localAnchorD, this.m_lcD);\n const pB = Rot.mulTVec2(qD, Vec2.add(rB, Vec2.sub(cB, cD)));\n coordinateB = Vec2.dot(pB, this.m_localAxisD) - Vec2.dot(pD, this.m_localAxisD);\n }\n\n const C = (coordinateA + this.m_ratio * coordinateB) - this.m_constant;\n\n let impulse = 0.0;\n if (mass > 0.0) {\n impulse = -C / mass;\n }\n\n cA.addMul(this.m_mA * impulse, JvAC);\n aA += this.m_iA * impulse * JwA;\n cB.addMul(this.m_mB * impulse, JvBD);\n aB += this.m_iB * impulse * JwB;\n cC.subMul(this.m_mC * impulse, JvAC);\n aC -= this.m_iC * impulse * JwC;\n cD.subMul(this.m_mD * impulse, JvBD);\n aD -= this.m_iD * impulse * JwD;\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n this.m_bodyC.c_position.c.setVec2(cC);\n this.m_bodyC.c_position.a = aC;\n this.m_bodyD.c_position.c.setVec2(cD);\n this.m_bodyD.c_position.a = aD;\n\n // TODO_ERIN not implemented\n return linearError < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Motor joint definition.\n */\nexport interface MotorJointOpt extends JointOpt {\n /**\n * The bodyB angle minus bodyA angle in radians.\n */\n angularOffset?: number;\n /**\n * The maximum motor force in N.\n */\n maxForce?: number;\n /**\n * The maximum motor torque in N-m.\n */\n maxTorque?: number;\n /**\n * Position correction factor in the range [0,1].\n */\n correctionFactor?: number;\n /**\n * Position of bodyB minus the position of bodyA, in bodyA's frame, in meters.\n */\n linearOffset?: Vec2Value;\n}\n\n/**\n * Motor joint definition.\n */\nexport interface MotorJointDef extends JointDef, MotorJointOpt {\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 1.0,\n maxTorque : 1.0,\n correctionFactor : 0.3\n};\n\ndeclare module \"./MotorJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MotorJoint(def: MotorJointDef): MotorJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MotorJoint(def: MotorJointOpt, bodyA: Body, bodyB: Body): MotorJoint;\n}\n\n/**\n * A motor joint is used to control the relative motion between two bodies. A\n * typical usage is to control the movement of a dynamic body with respect to\n * the ground.\n */\n// @ts-expect-error\nexport class MotorJoint extends Joint {\n static TYPE = \"motor-joint\" as const;\n\n /** @internal */ m_type: \"motor-joint\";\n /** @internal */ m_linearOffset: Vec2;\n /** @internal */ m_angularOffset: number;\n /** @internal */ m_linearImpulse: Vec2;\n /** @internal */ m_angularImpulse: number;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_maxTorque: number;\n /** @internal */ m_correctionFactor: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_linearError: Vec2;\n /** @internal */ m_angularError: number;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_linearMass: Mat22;\n /** @internal */ m_angularMass: number;\n\n constructor(def: MotorJointDef);\n constructor(def: MotorJointOpt, bodyA: Body, bodyB: Body);\n constructor(def: MotorJointDef | MotorJointOpt, bodyA?: Body, bodyB?: Body) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof MotorJoint)) {\n return new MotorJoint(def, bodyA, bodyB);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = MotorJoint.TYPE;\n\n this.m_linearOffset = Vec2.isValid(def.linearOffset) ? Vec2.clone(def.linearOffset) : bodyA.getLocalPoint(bodyB.getPosition());\n this.m_angularOffset = Number.isFinite(def.angularOffset) ? def.angularOffset : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_linearImpulse = Vec2.zero();\n this.m_angularImpulse = 0.0;\n\n this.m_maxForce = def.maxForce;\n this.m_maxTorque = def.maxTorque;\n this.m_correctionFactor = def.correctionFactor;\n\n // Point-to-point constraint\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n //\n // r1 = offset - c1\n // r2 = -c2\n\n // Angle constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n maxForce: this.m_maxForce,\n maxTorque: this.m_maxTorque,\n correctionFactor: this.m_correctionFactor,\n\n linearOffset: this.m_linearOffset,\n angularOffset: this.m_angularOffset,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): MotorJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new MotorJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.angularOffset)) {\n this.m_angularOffset = def.angularOffset;\n }\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.maxTorque)) {\n this.m_maxTorque = def.maxTorque;\n }\n if (Number.isFinite(def.correctionFactor)) {\n this.m_correctionFactor = def.correctionFactor;\n }\n if (Vec2.isValid(def.linearOffset)) {\n this.m_linearOffset.set(def.linearOffset); \n }\n }\n\n /**\n * Set the maximum friction force in N.\n */\n setMaxForce(force: number): void {\n if (_ASSERT) console.assert(Number.isFinite(force) && force >= 0.0);\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum friction force in N.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the maximum friction torque in N*m.\n */\n setMaxTorque(torque: number): void {\n if (_ASSERT) console.assert(Number.isFinite(torque) && torque >= 0.0);\n this.m_maxTorque = torque;\n }\n\n /**\n * Get the maximum friction torque in N*m.\n */\n getMaxTorque(): number {\n return this.m_maxTorque;\n }\n\n /**\n * Set the position correction factor in the range [0,1].\n */\n setCorrectionFactor(factor: number): void {\n if (_ASSERT) console.assert(Number.isFinite(factor) && 0.0 <= factor && factor <= 1.0);\n this.m_correctionFactor = factor;\n }\n\n /**\n * Get the position correction factor in the range [0,1].\n */\n getCorrectionFactor(): number {\n return this.m_correctionFactor;\n }\n\n /**\n * Set/get the target linear offset, in frame A, in meters.\n */\n setLinearOffset(linearOffset: Vec2Value): void {\n if (linearOffset.x != this.m_linearOffset.x || linearOffset.y != this.m_linearOffset.y) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_linearOffset.set(linearOffset);\n }\n }\n\n getLinearOffset(): Vec2 {\n return this.m_linearOffset;\n }\n\n /**\n * Set/get the target angular offset, in radians.\n */\n setAngularOffset(angularOffset: number): void {\n if (angularOffset != this.m_angularOffset) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_angularOffset = angularOffset;\n }\n }\n\n getAngularOffset(): number {\n return this.m_angularOffset;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getPosition();\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getPosition();\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_linearImpulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_angularImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective mass matrix.\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_linearOffset, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.neg(this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Upper 2 by 2 of K for point to point\n const K = new Mat22();\n K.ex.x = mA + mB + iA * this.m_rA.y * this.m_rA.y + iB * this.m_rB.y * this.m_rB.y;\n K.ex.y = -iA * this.m_rA.x * this.m_rA.y - iB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * this.m_rA.x * this.m_rA.x + iB * this.m_rB.x * this.m_rB.x;\n\n this.m_linearMass = K.getInverse();\n\n this.m_angularMass = iA + iB;\n if (this.m_angularMass > 0.0) {\n this.m_angularMass = 1.0 / this.m_angularMass;\n }\n\n this.m_linearError = Vec2.zero();\n this.m_linearError.addCombine(1, cB, 1, this.m_rB);\n this.m_linearError.subCombine(1, cA, 1, this.m_rA);\n\n this.m_angularError = aB - aA - this.m_angularOffset;\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_linearImpulse.mul(step.dtRatio);\n this.m_angularImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_linearImpulse.x, this.m_linearImpulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_angularImpulse);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_angularImpulse);\n\n } else {\n this.m_linearImpulse.setZero();\n this.m_angularImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const h = step.dt;\n const inv_h = step.inv_dt;\n\n // Solve angular friction\n {\n const Cdot = wB - wA + inv_h * this.m_correctionFactor * this.m_angularError;\n let impulse = -this.m_angularMass * Cdot;\n\n const oldImpulse = this.m_angularImpulse;\n const maxImpulse = h * this.m_maxTorque;\n this.m_angularImpulse = clamp(this.m_angularImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_angularImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve linear friction\n {\n const Cdot = Vec2.zero();\n Cdot.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n Cdot.addMul(inv_h * this.m_correctionFactor, this.m_linearError);\n\n let impulse = Vec2.neg(Mat22.mulVec2(this.m_linearMass, Cdot));\n const oldImpulse = Vec2.clone(this.m_linearImpulse);\n this.m_linearImpulse.add(impulse);\n\n const maxImpulse = h * this.m_maxForce;\n\n this.m_linearImpulse.clamp(maxImpulse);\n\n impulse = Vec2.sub(this.m_linearImpulse, oldImpulse);\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Transform } from \"../../common/Transform\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Mouse joint definition. This requires a world target point, tuning\n * parameters, and the time step.\n */\nexport interface MouseJointOpt extends JointOpt {\n /**\n * [maxForce = 0.0] The maximum constraint force that can be exerted to move\n * the candidate body. Usually you will express as some multiple of the\n * weight (multiplier * mass * gravity).\n */\n maxForce?: number;\n /**\n * [frequencyHz = 5.0] The response speed.\n */\n frequencyHz?: number;\n /**\n * [dampingRatio = 0.7] The damping ratio. 0 = no damping, 1 = critical\n * damping.\n */\n dampingRatio?: number;\n}\n\n/**\n * Mouse joint definition. This requires a world target point, tuning\n * parameters, and the time step.\n */\nexport interface MouseJointDef extends JointDef, MouseJointOpt {\n /**\n * The initial world target point. This is assumed to coincide with the body\n * anchor initially.\n */\n target: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 0.0,\n frequencyHz : 5.0,\n dampingRatio : 0.7\n};\n\ndeclare module \"./MouseJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MouseJoint(def: MouseJointDef): MouseJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MouseJoint(def: MouseJointOpt, bodyA: Body, bodyB: Body, target: Vec2Value): MouseJoint;\n}\n\n/**\n * A mouse joint is used to make a point on a body track a specified world\n * point. This a soft constraint with a maximum force. This allows the\n * constraint to stretch and without applying huge forces.\n *\n * You need to call setTarget(target) every time that mouse is \n * moved, to track the new location of the mouse.\n *\n * NOTE: this joint is not documented in the manual because it was developed to\n * be used in the testbed. If you want to learn how to use the mouse joint, look\n * at the testbed.\n */\n// @ts-expect-error\nexport class MouseJoint extends Joint {\n static TYPE = \"mouse-joint\" as const;\n\n /** @internal */ m_type: \"mouse-joint\";\n /** @internal */ m_targetA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_impulse: Vec2;\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n /** @internal */ m_beta: number;\n /** @internal */ m_gamma: number;\n // Solver temp\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: Mat22;\n /** @internal */ m_C: Vec2;\n\n constructor(def: MouseJointDef);\n constructor(def: MouseJointOpt, bodyA: Body, bodyB: Body, target?: Vec2Value);\n constructor(def: MouseJointDef, bodyA?: Body, bodyB?: Body, target?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof MouseJoint)) {\n return new MouseJoint(def, bodyA, bodyB, target);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = MouseJoint.TYPE;\n\n if (_ASSERT) console.assert(Number.isFinite(def.maxForce) && def.maxForce >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.frequencyHz) && def.frequencyHz >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.dampingRatio) && def.dampingRatio >= 0.0);\n\n if (Vec2.isValid(target)) {\n this.m_targetA = Vec2.clone(target);\n } else if (Vec2.isValid(def.target)) {\n this.m_targetA = Vec2.clone(def.target);\n } else {\n this.m_targetA = Vec2.zero();\n }\n\n this.m_localAnchorB = Transform.mulTVec2(bodyB.getTransform(), this.m_targetA);\n\n this.m_maxForce = def.maxForce;\n this.m_impulse = Vec2.zero();\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_beta = 0.0;\n this.m_gamma = 0.0;\n\n // Solver temp\n this.m_rB = Vec2.zero();\n this.m_localCenterB = Vec2.zero();\n this.m_invMassB = 0.0;\n this.m_invIB = 0.0;\n this.m_mass = new Mat22();\n this.m_C = Vec2.zero();\n\n // p = attached point, m = mouse point\n // C = p - m\n // Cdot = v\n // = v + cross(w, r)\n // J = [I r_skew]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n target: this.m_targetA,\n maxForce: this.m_maxForce,\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n _localAnchorB: this.m_localAnchorB,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): MouseJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.target = Vec2.clone(data.target);\n const joint = new MouseJoint(data);\n if (data._localAnchorB) {\n joint.m_localAnchorB = data._localAnchorB;\n }\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * Use this to update the target point.\n */\n setTarget(target: Vec2Value): void {\n if (Vec2.areEqual(target, this.m_targetA)) return;\n this.m_bodyB.setAwake(true);\n this.m_targetA.set(target);\n }\n\n getTarget(): Vec2 {\n return this.m_targetA;\n }\n\n /**\n * Set the maximum force in Newtons.\n */\n setMaxForce(force: number): void {\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum force in Newtons.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the frequency in Hertz.\n */\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n /**\n * Get the frequency in Hertz.\n */\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set the damping ratio (dimensionless).\n */\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n /**\n * Get the damping ratio (dimensionless).\n */\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return Vec2.clone(this.m_targetA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_impulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * 0.0;\n }\n\n /**\n * Shift the origin for any points stored in world coordinates.\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_targetA.sub(newOrigin);\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const position = this.m_bodyB.c_position;\n const velocity = this.m_bodyB.c_velocity;\n\n const cB = position.c;\n const aB = position.a;\n const vB = velocity.v;\n let wB = velocity.w;\n\n const qB = Rot.neo(aB);\n\n const mass = this.m_bodyB.getMass();\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * mass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = mass * (omega * omega);\n\n // magic formulas\n // gamma has units of inverse mass.\n // beta has units of inverse time.\n const h = step.dt;\n if (_ASSERT) console.assert(d + h * k > EPSILON);\n this.m_gamma = h * (d + h * k);\n if (this.m_gamma != 0.0) {\n this.m_gamma = 1.0 / this.m_gamma;\n }\n this.m_beta = h * k * this.m_gamma;\n\n // Compute the effective mass matrix.\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // K = [(1/m1 + 1/m2) * eye(2) - skew(r1) * invI1 * skew(r1) - skew(r2) *\n // invI2 * skew(r2)]\n // = [1/m1+1/m2 0 ] + invI1 * [r1.y*r1.y -r1.x*r1.y] + invI2 * [r1.y*r1.y\n // -r1.x*r1.y]\n // [ 0 1/m1+1/m2] [-r1.x*r1.y r1.x*r1.x] [-r1.x*r1.y r1.x*r1.x]\n const K = new Mat22();\n K.ex.x = this.m_invMassB + this.m_invIB * this.m_rB.y * this.m_rB.y\n + this.m_gamma;\n K.ex.y = -this.m_invIB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = this.m_invMassB + this.m_invIB * this.m_rB.x * this.m_rB.x\n + this.m_gamma;\n\n this.m_mass = K.getInverse();\n\n this.m_C.setVec2(cB);\n this.m_C.addCombine(1, this.m_rB, -1, this.m_targetA);\n this.m_C.mul(this.m_beta);\n\n // Cheat with some damping\n wB *= 0.98;\n\n if (step.warmStarting) {\n this.m_impulse.mul(step.dtRatio);\n vB.addMul(this.m_invMassB, this.m_impulse);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, this.m_impulse);\n\n } else {\n this.m_impulse.setZero();\n }\n\n velocity.v.setVec2(vB);\n velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const velocity = this.m_bodyB.c_velocity;\n const vB = Vec2.clone(velocity.v);\n let wB = velocity.w;\n\n // Cdot = v + cross(w, r)\n\n const Cdot = Vec2.crossNumVec2(wB, this.m_rB);\n Cdot.add(vB);\n\n Cdot.addCombine(1, this.m_C, this.m_gamma, this.m_impulse);\n Cdot.neg();\n\n let impulse = Mat22.mulVec2(this.m_mass, Cdot);\n\n const oldImpulse = Vec2.clone(this.m_impulse);\n this.m_impulse.add(impulse);\n const maxImpulse = step.dt * this.m_maxForce;\n this.m_impulse.clamp(maxImpulse);\n impulse = Vec2.sub(this.m_impulse, oldImpulse);\n\n vB.addMul(this.m_invMassB, impulse);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n\n velocity.v.setVec2(vB);\n velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n\n\n/**\n * Pulley joint definition. This requires two ground anchors, two dynamic body\n * anchor points, and a pulley ratio.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface PulleyJointOpt extends JointOpt {\n}\n\n/**\n * Pulley joint definition. This requires two ground anchors, two dynamic body\n * anchor points, and a pulley ratio.\n */\nexport interface PulleyJointDef extends JointDef, PulleyJointOpt {\n /**\n * The first ground anchor in world coordinates. This point never moves.\n */\n groundAnchorA: Vec2Value;\n /**\n * The second ground anchor in world coordinates. This point never moves.\n */\n groundAnchorB: Vec2Value;\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The reference length for the segment attached to bodyA.\n */\n lengthA: number;\n /**\n * The reference length for the segment attached to bodyB.\n */\n lengthB: number;\n /**\n * The pulley ratio, used to simulate a block-and-tackle.\n */\n ratio: number;\n\n /** @hidden */ anchorA?: Vec2Value;\n /** @hidden */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n collideConnected : true\n};\n\ndeclare module \"./PulleyJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PulleyJoint(def: PulleyJointDef): PulleyJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PulleyJoint(def: PulleyJointOpt, bodyA: Body, bodyB: Body, groundA: Vec2Value, groundB: Vec2Value, anchorA: Vec2Value, anchorB: Vec2Value, ratio: number): PulleyJoint;\n}\n\n/**\n * The pulley joint is connected to two bodies and two fixed ground points. The\n * pulley supports a ratio such that: length1 + ratio * length2 <= constant\n *\n * Yes, the force transmitted is scaled by the ratio.\n *\n * Warning: the pulley joint can get a bit squirrelly by itself. They often work\n * better when combined with prismatic joints. You should also cover the the\n * anchor points with static shapes to prevent one side from going to zero\n * length.\n */\n// @ts-expect-error\nexport class PulleyJoint extends Joint {\n static TYPE = \"pulley-joint\" as const;\n // static MIN_PULLEY_LENGTH: number = 2.0; // TODO where this is used?\n\n /** @internal */ m_type: \"pulley-joint\";\n /** @internal */ m_groundAnchorA: Vec2;\n /** @internal */ m_groundAnchorB: Vec2;\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_lengthA: number;\n /** @internal */ m_lengthB: number;\n /** @internal */ m_ratio: number;\n /** @internal */ m_constant: number;\n /** @internal */ m_impulse: number;\n\n // Solver temp\n /** @internal */ m_uA: Vec2;\n /** @internal */ m_uB: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: number;\n\n constructor(def: PulleyJointDef);\n constructor(def: PulleyJointOpt, bodyA: Body, bodyB: Body, groundA?: Vec2Value, groundB?: Vec2Value, anchorA?: Vec2Value, anchorB?: Vec2Value, ratio?: number);\n constructor(def: PulleyJointDef, bodyA?: Body, bodyB?: Body, groundA?: Vec2Value, groundB?: Vec2Value, anchorA?: Vec2Value, anchorB?: Vec2Value, ratio?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PulleyJoint)) {\n return new PulleyJoint(def, bodyA, bodyB, groundA, groundB, anchorA, anchorB, ratio);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = PulleyJoint.TYPE;\n this.m_groundAnchorA = Vec2.clone(groundA ? groundA : def.groundAnchorA || Vec2.neo(-1.0, 1.0));\n this.m_groundAnchorB = Vec2.clone(groundB ? groundB : def.groundAnchorB || Vec2.neo(1.0, 1.0));\n this.m_localAnchorA = Vec2.clone(anchorA ? bodyA.getLocalPoint(anchorA) : def.localAnchorA || Vec2.neo(-1.0, 0.0));\n this.m_localAnchorB = Vec2.clone(anchorB ? bodyB.getLocalPoint(anchorB) : def.localAnchorB || Vec2.neo(1.0, 0.0));\n this.m_lengthA = Number.isFinite(def.lengthA) ? def.lengthA : Vec2.distance(anchorA, groundA);\n this.m_lengthB = Number.isFinite(def.lengthB) ? def.lengthB : Vec2.distance(anchorB, groundB);\n this.m_ratio = Number.isFinite(ratio) ? ratio : def.ratio;\n\n if (_ASSERT) console.assert(ratio > EPSILON);\n\n this.m_constant = this.m_lengthA + this.m_ratio * this.m_lengthB;\n\n this.m_impulse = 0.0;\n\n // Pulley:\n // length1 = norm(p1 - s1)\n // length2 = norm(p2 - s2)\n // C0 = (length1 + ratio * length2)_initial\n // C = C0 - (length1 + ratio * length2)\n // u1 = (p1 - s1) / norm(p1 - s1)\n // u2 = (p2 - s2) / norm(p2 - s2)\n // Cdot = -dot(u1, v1 + cross(w1, r1)) - ratio * dot(u2, v2 + cross(w2, r2))\n // J = -[u1 cross(r1, u1) ratio * u2 ratio * cross(r2, u2)]\n // K = J * invM * JT\n // = invMass1 + invI1 * cross(r1, u1)^2 + ratio^2 * (invMass2 + invI2 *\n // cross(r2, u2)^2)\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n groundAnchorA: this.m_groundAnchorA,\n groundAnchorB: this.m_groundAnchorB,\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n lengthA: this.m_lengthA,\n lengthB: this.m_lengthB,\n ratio: this.m_ratio,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): PulleyJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new PulleyJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Vec2.isValid(def.groundAnchorA)) {\n this.m_groundAnchorA.set(def.groundAnchorA);\n }\n if (Vec2.isValid(def.groundAnchorB)) {\n this.m_groundAnchorB.set(def.groundAnchorB);\n }\n if (Vec2.isValid(def.localAnchorA)) {\n this.m_localAnchorA.set(def.localAnchorA);\n } else if (Vec2.isValid(def.anchorA)) {\n this.m_localAnchorA.set(this.m_bodyA.getLocalPoint(def.anchorA));\n }\n if (Vec2.isValid(def.localAnchorB)) {\n this.m_localAnchorB.set(def.localAnchorB);\n } else if (Vec2.isValid(def.anchorB)) {\n this.m_localAnchorB.set(this.m_bodyB.getLocalPoint(def.anchorB));\n }\n if (Number.isFinite(def.lengthA)) {\n this.m_lengthA = def.lengthA;\n }\n if (Number.isFinite(def.lengthB)) {\n this.m_lengthB = def.lengthB;\n }\n if (Number.isFinite(def.ratio)) {\n this.m_ratio = def.ratio;\n }\n }\n\n /**\n * Get the first ground anchor.\n */\n getGroundAnchorA(): Vec2 {\n return this.m_groundAnchorA;\n }\n\n /**\n * Get the second ground anchor.\n */\n getGroundAnchorB(): Vec2 {\n return this.m_groundAnchorB;\n }\n\n /**\n * Get the current length of the segment attached to bodyA.\n */\n getLengthA(): number {\n return this.m_lengthA;\n }\n\n /**\n * Get the current length of the segment attached to bodyB.\n */\n getLengthB(): number {\n return this.m_lengthB;\n }\n\n /**\n * Get the pulley ratio.\n */\n getRatio(): number {\n return this.m_ratio;\n }\n\n /**\n * Get the current length of the segment attached to bodyA.\n */\n getCurrentLengthA(): number {\n const p = this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n const s = this.m_groundAnchorA;\n return Vec2.distance(p, s);\n }\n\n /**\n * Get the current length of the segment attached to bodyB.\n */\n getCurrentLengthB(): number {\n const p = this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n const s = this.m_groundAnchorB;\n return Vec2.distance(p, s);\n }\n\n /**\n * Shift the origin for any points stored in world coordinates.\n *\n * @param newOrigin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_groundAnchorA.sub(newOrigin);\n this.m_groundAnchorB.sub(newOrigin);\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_uB).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // Get the pulley axes.\n this.m_uA = Vec2.sub(Vec2.add(cA, this.m_rA), this.m_groundAnchorA);\n this.m_uB = Vec2.sub(Vec2.add(cB, this.m_rB), this.m_groundAnchorB);\n\n const lengthA = this.m_uA.length();\n const lengthB = this.m_uB.length();\n\n if (lengthA > 10.0 * Settings.linearSlop) {\n this.m_uA.mul(1.0 / lengthA);\n } else {\n this.m_uA.setZero();\n }\n\n if (lengthB > 10.0 * Settings.linearSlop) {\n this.m_uB.mul(1.0 / lengthB);\n } else {\n this.m_uB.setZero();\n }\n\n // Compute effective mass.\n const ruA = Vec2.crossVec2Vec2(this.m_rA, this.m_uA);\n const ruB = Vec2.crossVec2Vec2(this.m_rB, this.m_uB);\n\n const mA = this.m_invMassA + this.m_invIA * ruA * ruA;\n const mB = this.m_invMassB + this.m_invIB * ruB * ruB;\n\n this.m_mass = mA + this.m_ratio * this.m_ratio * mB;\n\n if (this.m_mass > 0.0) {\n this.m_mass = 1.0 / this.m_mass;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support variable time steps.\n this.m_impulse *= step.dtRatio;\n\n // Warm starting.\n const PA = Vec2.mulNumVec2(-this.m_impulse, this.m_uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * this.m_impulse, this.m_uB);\n\n vA.addMul(this.m_invMassA, PA);\n wA += this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, PA);\n\n vB.addMul(this.m_invMassB, PB);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, PB);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const vpA = Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA));\n const vpB = Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB));\n\n const Cdot = -Vec2.dot(this.m_uA, vpA) - this.m_ratio * Vec2.dot(this.m_uB, vpB);\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n const PA = Vec2.mulNumVec2(-impulse, this.m_uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * impulse, this.m_uB);\n vA.addMul(this.m_invMassA, PA);\n wA += this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, PA);\n vB.addMul(this.m_invMassB, PB);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, PB);\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // Get the pulley axes.\n const uA = Vec2.sub(Vec2.add(cA, this.m_rA), this.m_groundAnchorA);\n const uB = Vec2.sub(Vec2.add(cB, this.m_rB), this.m_groundAnchorB);\n\n const lengthA = uA.length();\n const lengthB = uB.length();\n\n if (lengthA > 10.0 * Settings.linearSlop) {\n uA.mul(1.0 / lengthA);\n } else {\n uA.setZero();\n }\n\n if (lengthB > 10.0 * Settings.linearSlop) {\n uB.mul(1.0 / lengthB);\n } else {\n uB.setZero();\n }\n\n // Compute effective mass.\n const ruA = Vec2.crossVec2Vec2(rA, uA);\n const ruB = Vec2.crossVec2Vec2(rB, uB);\n\n const mA = this.m_invMassA + this.m_invIA * ruA * ruA;\n const mB = this.m_invMassB + this.m_invIB * ruB * ruB;\n\n let mass = mA + this.m_ratio * this.m_ratio * mB;\n\n if (mass > 0.0) {\n mass = 1.0 / mass;\n }\n\n const C = this.m_constant - lengthA - this.m_ratio * lengthB;\n const linearError = math_abs(C);\n\n const impulse = -mass * C;\n\n const PA = Vec2.mulNumVec2(-impulse, uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * impulse, uB);\n\n cA.addMul(this.m_invMassA, PA);\n aA += this.m_invIA * Vec2.crossVec2Vec2(rA, PA);\n cB.addMul(this.m_invMassB, PB);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, PB);\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return linearError < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_min = Math.min;\n\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3,\n}\n\n/**\n * Rope joint definition. This requires two body anchor points and a maximum\n * lengths. Note: by default the connected objects will not collide. see\n * collideConnected in JointDef.\n */\nexport interface RopeJointOpt extends JointOpt {\n /**\n * The maximum length of the rope.\n * Warning: this must be larger than linearSlop or the joint will have no effect.\n */\n maxLength?: number;\n}\n\n/**\n * Rope joint definition. This requires two body anchor points and a maximum\n * lengths. Note: by default the connected objects will not collide. see\n * collideConnected in JointDef.\n */\nexport interface RopeJointDef extends JointDef, RopeJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxLength : 0.0,\n};\n\ndeclare module \"./RopeJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RopeJoint(def: RopeJointDef): RopeJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RopeJoint(def: RopeJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): RopeJoint;\n}\n\n/**\n * A rope joint enforces a maximum distance between two points on two bodies. It\n * has no other effect.\n *\n * Warning: if you attempt to change the maximum length during the simulation\n * you will get some non-physical behavior.\n *\n * A model that would allow you to dynamically modify the length would have some\n * sponginess, so I chose not to implement it that way. See {@link DistanceJoint} if you\n * want to dynamically control length.\n */\n// @ts-expect-error\nexport class RopeJoint extends Joint {\n static TYPE = \"rope-joint\" as const;\n\n /** @internal */ m_type: \"rope-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n\n /** @internal */ m_maxLength: number;\n\n /** @internal */ m_mass: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_length: number;\n /** @internal */ m_state: number; // TODO enum\n\n // Solver temp\n /** @internal */ m_u: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n\n constructor(def: RopeJointDef);\n constructor(def: RopeJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: RopeJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof RopeJoint)) {\n return new RopeJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = RopeJoint.TYPE;\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.neo(-1.0, 0.0));\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.neo(1.0, 0.0));\n\n this.m_maxLength = def.maxLength;\n\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n this.m_length = 0.0;\n this.m_state = LimitState.inactiveLimit;\n\n // Limit:\n // C = norm(pB - pA) - L\n // u = (pB - pA) / norm(pB - pA)\n // Cdot = dot(u, vB + cross(wB, rB) - vA - cross(wA, rA))\n // J = [-u -cross(rA, u) u cross(rB, u)]\n // K = J * invM * JT\n // = invMassA + invIA * cross(rA, u)^2 + invMassB + invIB * cross(rB, u)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n maxLength: this.m_maxLength,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): RopeJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new RopeJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.maxLength)) {\n this.m_maxLength = def.maxLength;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the maximum length of the rope.\n */\n setMaxLength(length: number): void {\n this.m_maxLength = length;\n }\n\n /**\n * Get the maximum length of the rope.\n */\n getMaxLength(): number {\n return this.m_maxLength;\n }\n\n getLimitState(): number {\n // TODO LimitState\n return this.m_state;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_u).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n this.m_rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n this.m_u = Vec2.zero();\n this.m_u.addCombine(1, cB, 1, this.m_rB);\n this.m_u.subCombine(1, cA, 1, this.m_rA);\n\n this.m_length = this.m_u.length();\n\n const C = this.m_length - this.m_maxLength;\n if (C > 0.0) {\n this.m_state = LimitState.atUpperLimit;\n } else {\n this.m_state = LimitState.inactiveLimit;\n }\n\n if (this.m_length > Settings.linearSlop) {\n this.m_u.mul(1.0 / this.m_length);\n } else {\n this.m_u.setZero();\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n return;\n }\n\n // Compute effective mass.\n const crA = Vec2.crossVec2Vec2(this.m_rA, this.m_u);\n const crB = Vec2.crossVec2Vec2(this.m_rB, this.m_u);\n const invMass = this.m_invMassA + this.m_invIA * crA * crA + this.m_invMassB + this.m_invIB * crB * crB;\n\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n\n if (step.warmStarting) {\n // Scale the impulse to support a variable time step.\n this.m_impulse *= step.dtRatio;\n\n const P = Vec2.mulNumVec2(this.m_impulse, this.m_u);\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Cdot = dot(u, v + cross(w, r))\n const vpA = Vec2.addCrossNumVec2(vA, wA, this.m_rA);\n const vpB = Vec2.addCrossNumVec2(vB, wB, this.m_rB);\n const C = this.m_length - this.m_maxLength;\n let Cdot = Vec2.dot(this.m_u, Vec2.sub(vpB, vpA));\n\n // Predictive constraint.\n if (C < 0.0) {\n Cdot += step.inv_dt * C;\n }\n\n let impulse = -this.m_mass * Cdot;\n const oldImpulse = this.m_impulse;\n this.m_impulse = math_min(0.0, this.m_impulse + impulse);\n impulse = this.m_impulse - oldImpulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_u);\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n const u = Vec2.zero();\n u.addCombine(1, cB, 1, rB);\n u.subCombine(1, cA, 1, rA);\n\n const length = u.normalize();\n let C = length - this.m_maxLength;\n\n C = clamp(C, 0.0, Settings.maxLinearCorrection);\n\n const impulse = -this.m_mass * C;\n const P = Vec2.mulNumVec2(impulse, u);\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * Vec2.crossVec2Vec2(rA, P);\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, P);\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return length - this.m_maxLength < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Weld joint definition. You need to specify local anchor points where they are\n * attached and the relative body angle. The position of the anchor points is\n * important for computing the reaction torque.\n */\nexport interface WeldJointOpt extends JointOpt {\n /**\n * The mass-spring-damper frequency in Hertz. Rotation only. Disable softness\n * with a value of 0.\n */\n frequencyHz?: number;\n /**\n * The damping ratio. 0 = no damping, 1 = critical damping.\n */\n dampingRatio?: number;\n /**\n * The bodyB angle minus bodyA angle in the reference state (radians).\n */\n referenceAngle?: number;\n}\n\n/**\n * Weld joint definition. You need to specify local anchor points where they are\n * attached and the relative body angle. The position of the anchor points is\n * important for computing the reaction torque.\n */\nexport interface WeldJointDef extends JointDef, WeldJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n frequencyHz : 0.0,\n dampingRatio : 0.0,\n};\n\ndeclare module \"./WeldJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WeldJoint(def: WeldJointDef): WeldJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WeldJoint(def: WeldJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): WeldJoint;\n}\n\n/**\n * A weld joint essentially glues two bodies together. A weld joint may distort\n * somewhat because the island constraint solver is approximate.\n */\n// @ts-expect-error\nexport class WeldJoint extends Joint {\n static TYPE = \"weld-joint\" as const;\n\n /** @internal */ m_type: \"weld-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngle: number;\n\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n\n /** @internal */ m_impulse: Vec3;\n\n /** @internal */ m_bias: number;\n /** @internal */ m_gamma: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: Mat33;\n\n constructor(def: WeldJointDef);\n constructor(def: WeldJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: WeldJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof WeldJoint)) {\n return new WeldJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = WeldJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n this.m_referenceAngle = Number.isFinite(def.referenceAngle) ? def.referenceAngle : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_impulse = new Vec3();\n\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n\n // Solver temp\n // todo: do we need to initialize?\n // this.m_rA;\n // this.m_rB;\n // this.m_localCenterA;\n // this.m_localCenterB;\n // this.m_invMassA;\n // this.m_invMassB;\n // this.m_invIA;\n // this.m_invIB;\n this.m_mass = new Mat33();\n\n // Point-to-point constraint\n // C = p2 - p1\n // Cdot = v2 - v1\n // / = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Angle constraint\n // C = angle2 - angle1 - referenceAngle\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): WeldJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new WeldJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Set frequency in Hz.\n */\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n /**\n * Get frequency in Hz.\n */\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set damping ratio.\n */\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n /**\n * Get damping ratio.\n */\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.neo(this.m_impulse.x, this.m_impulse.y).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.z;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat33();\n K.ex.x = mA + mB + this.m_rA.y * this.m_rA.y * iA + this.m_rB.y * this.m_rB.y\n * iB;\n K.ey.x = -this.m_rA.y * this.m_rA.x * iA - this.m_rB.y * this.m_rB.x * iB;\n K.ez.x = -this.m_rA.y * iA - this.m_rB.y * iB;\n K.ex.y = K.ey.x;\n K.ey.y = mA + mB + this.m_rA.x * this.m_rA.x * iA + this.m_rB.x * this.m_rB.x\n * iB;\n K.ez.y = this.m_rA.x * iA + this.m_rB.x * iB;\n K.ex.z = K.ez.x;\n K.ey.z = K.ez.y;\n K.ez.z = iA + iB;\n\n if (this.m_frequencyHz > 0.0) {\n K.getInverse22(this.m_mass);\n\n let invM = iA + iB;\n const m = invM > 0.0 ? 1.0 / invM : 0.0;\n\n const C = aB - aA - this.m_referenceAngle;\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * m * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = m * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (d + h * k);\n this.m_gamma = this.m_gamma != 0.0 ? 1.0 / this.m_gamma : 0.0;\n this.m_bias = C * h * k * this.m_gamma;\n\n invM += this.m_gamma;\n this.m_mass.ez.z = invM != 0.0 ? 1.0 / invM : 0.0;\n } else if (K.ez.z == 0.0) {\n K.getInverse22(this.m_mass);\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n } else {\n K.getSymInverse33(this.m_mass);\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_impulse.mul(step.dtRatio);\n\n const P = Vec2.neo(this.m_impulse.x, this.m_impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_impulse.z);\n\n } else {\n this.m_impulse.setZero();\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n if (this.m_frequencyHz > 0.0) {\n const Cdot2 = wB - wA;\n\n const impulse2 = -this.m_mass.ez.z * (Cdot2 + this.m_bias + this.m_gamma * this.m_impulse.z);\n this.m_impulse.z += impulse2;\n\n wA -= iA * impulse2;\n wB += iB * impulse2;\n\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n\n const impulse1 = Vec2.neg(Mat33.mulVec2(this.m_mass, Cdot1));\n this.m_impulse.x += impulse1.x;\n this.m_impulse.y += impulse1.y;\n\n const P = Vec2.clone(impulse1);\n\n vA.subMul(mA, P);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(mB, P);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, P);\n } else {\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const Cdot2 = wB - wA;\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const impulse = Vec3.neg(Mat33.mulVec3(this.m_mass, Cdot));\n this.m_impulse.add(impulse);\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + impulse.z);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n let positionError: number;\n let angularError: number;\n\n const K = new Mat33();\n K.ex.x = mA + mB + rA.y * rA.y * iA + rB.y * rB.y * iB;\n K.ey.x = -rA.y * rA.x * iA - rB.y * rB.x * iB;\n K.ez.x = -rA.y * iA - rB.y * iB;\n K.ex.y = K.ey.x;\n K.ey.y = mA + mB + rA.x * rA.x * iA + rB.x * rB.x * iB;\n K.ez.y = rA.x * iA + rB.x * iB;\n K.ex.z = K.ez.x;\n K.ey.z = K.ez.y;\n K.ez.z = iA + iB;\n\n if (this.m_frequencyHz > 0.0) {\n const C1 = Vec2.zero();\n C1.addCombine(1, cB, 1, rB);\n C1.subCombine(1, cA, 1, rA);\n\n positionError = C1.length();\n angularError = 0.0;\n\n const P = Vec2.neg(K.solve22(C1));\n\n cA.subMul(mA, P);\n aA -= iA * Vec2.crossVec2Vec2(rA, P);\n\n cB.addMul(mB, P);\n aB += iB * Vec2.crossVec2Vec2(rB, P);\n } else {\n const C1 = Vec2.zero();\n C1.addCombine(1, cB, 1, rB);\n C1.subCombine(1, cA, 1, rA);\n\n const C2 = aB - aA - this.m_referenceAngle;\n\n positionError = C1.length();\n angularError = math_abs(C2);\n\n const C = new Vec3(C1.x, C1.y, C2);\n\n let impulse = new Vec3();\n if (K.ez.z > 0.0) {\n impulse = Vec3.neg(K.solve33(C));\n } else {\n const impulse2 = Vec2.neg(K.solve22(C1));\n impulse.set(impulse2.x, impulse2.y, 0.0);\n }\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n cA.subMul(mA, P);\n aA -= iA * (Vec2.crossVec2Vec2(rA, P) + impulse.z);\n\n cB.addMul(mB, P);\n aB += iB * (Vec2.crossVec2Vec2(rB, P) + impulse.z);\n }\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return positionError <= Settings.linearSlop && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Wheel joint definition. This requires defining a line of motion using an axis\n * and an anchor point. The definition uses local anchor points and a local axis\n * so that the initial configuration can violate the constraint slightly. The\n * joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface WheelJointOpt extends JointOpt {\n /**\n * Enable/disable the joint motor.\n */\n enableMotor?: boolean;\n /**\n * The maximum motor torque, usually in N-m.\n */\n maxMotorTorque?: number;\n /**\n * The desired motor speed in radians per second.\n */\n motorSpeed?: number;\n /**\n * Suspension frequency, zero indicates no suspension.\n */\n frequencyHz?: number;\n /**\n * Suspension damping ratio, one indicates critical damping.\n */\n dampingRatio?: number;\n}\n\n/**\n * Wheel joint definition. This requires defining a line of motion using an axis\n * and an anchor point. The definition uses local anchor points and a local axis\n * so that the initial configuration can violate the constraint slightly. The\n * joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface WheelJointDef extends JointDef, WheelJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The local translation axis in bodyA.\n */\n localAxisA: Vec2Value;\n\n /** @internal renamed to localAxisA */\n localAxis?: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n enableMotor : false,\n maxMotorTorque : 0.0,\n motorSpeed : 0.0,\n frequencyHz : 2.0,\n dampingRatio : 0.7,\n};\n\ndeclare module \"./WheelJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WheelJoint(def: WheelJointDef): WheelJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WheelJoint(def: WheelJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value, axis: Vec2Value): WheelJoint;\n}\n\n/**\n * A wheel joint. This joint provides two degrees of freedom: translation along\n * an axis fixed in bodyA and rotation in the plane. In other words, it is a\n * point to line constraint with a rotational motor and a linear spring/damper.\n * This joint is designed for vehicle suspensions.\n */\n// @ts-expect-error\nexport class WheelJoint extends Joint {\n static TYPE = \"wheel-joint\" as const;\n\n /** @internal */ m_type: \"wheel-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_localXAxisA: Vec2;\n /** @internal */ m_localYAxisA: Vec2;\n\n /** @internal */ m_mass: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_motorMass: number;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_springMass: number;\n /** @internal */ m_springImpulse: number;\n\n /** @internal */ m_maxMotorTorque: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableMotor: boolean;\n\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n\n /** @internal */ m_bias: number;\n /** @internal */ m_gamma: number;\n\n // Solver temp\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n\n /** @internal */ m_ax: Vec2;\n /** @internal */ m_ay: Vec2;\n /** @internal */ m_sAx: number;\n /** @internal */ m_sBx: number;\n /** @internal */ m_sAy: number;\n /** @internal */ m_sBy: number;\n\n constructor(def: WheelJointDef);\n constructor(def: WheelJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value, axis?: Vec2Value);\n constructor(def: WheelJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value, axis?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof WheelJoint)) {\n return new WheelJoint(def, bodyA, bodyB, anchor, axis);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_ax = Vec2.zero();\n this.m_ay = Vec2.zero();\n\n this.m_type = WheelJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n\n if (Vec2.isValid(axis)) {\n this.m_localXAxisA = bodyA.getLocalVector(axis);\n } else if (Vec2.isValid(def.localAxisA)) {\n this.m_localXAxisA = Vec2.clone(def.localAxisA);\n } else if (Vec2.isValid(def.localAxis)) {\n // localAxis is renamed to localAxisA, this is for backward compatibility\n this.m_localXAxisA = Vec2.clone(def.localAxis);\n } else {\n this.m_localXAxisA = Vec2.neo(1.0, 0.0);\n }\n\n this.m_localYAxisA = Vec2.crossNumVec2(1.0, this.m_localXAxisA);\n\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n this.m_springMass = 0.0;\n this.m_springImpulse = 0.0;\n\n this.m_maxMotorTorque = def.maxMotorTorque;\n this.m_motorSpeed = def.motorSpeed;\n this.m_enableMotor = def.enableMotor;\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n\n // Linear constraint (point-to-line)\n // d = pB - pA = xB + rB - xA - rA\n // C = dot(ay, d)\n // Cdot = dot(d, cross(wA, ay)) + dot(ay, vB + cross(wB, rB) - vA - cross(wA,\n // rA))\n // = -dot(ay, vA) - dot(cross(d + rA, ay), wA) + dot(ay, vB) + dot(cross(rB,\n // ay), vB)\n // J = [-ay, -cross(d + rA, ay), ay, cross(rB, ay)]\n\n // Spring linear constraint\n // C = dot(ax, d)\n // Cdot = = -dot(ax, vA) - dot(cross(d + rA, ax), wA) + dot(ax, vB) +\n // dot(cross(rB, ax), vB)\n // J = [-ax -cross(d+rA, ax) ax cross(rB, ax)]\n\n // Motor rotational constraint\n // Cdot = wB - wA\n // J = [0 0 -1 0 0 1]\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n enableMotor: this.m_enableMotor,\n maxMotorTorque: this.m_maxMotorTorque,\n motorSpeed: this.m_motorSpeed,\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n localAxisA: this.m_localXAxisA,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): WheelJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new WheelJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (def.localAxisA) {\n this.m_localXAxisA.setVec2(def.localAxisA);\n this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1.0, def.localAxisA));\n }\n if (def.enableMotor !== undefined) {\n this.m_enableMotor = def.enableMotor;\n }\n if (Number.isFinite(def.maxMotorTorque)) {\n this.m_maxMotorTorque = def.maxMotorTorque;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * The local joint axis relative to bodyA.\n */\n getLocalAxisA(): Vec2 {\n return this.m_localXAxisA;\n }\n\n /**\n * Get the current joint translation, usually in meters.\n */\n getJointTranslation(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n\n const pA = bA.getWorldPoint(this.m_localAnchorA);\n const pB = bB.getWorldPoint(this.m_localAnchorB);\n const d = Vec2.sub(pB, pA);\n const axis = bA.getWorldVector(this.m_localXAxisA);\n\n const translation = Vec2.dot(d, axis);\n return translation;\n }\n\n /**\n * Get the current joint translation speed, usually in meters per second.\n */\n getJointSpeed(): number {\n const wA = this.m_bodyA.m_angularVelocity;\n const wB = this.m_bodyB.m_angularVelocity;\n return wB - wA;\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Set the motor speed, usually in radians per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Get the motor speed, usually in radians per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Set/Get the maximum motor force, usually in N-m.\n */\n setMaxMotorTorque(torque: number): void {\n if (torque == this.m_maxMotorTorque) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorTorque = torque;\n }\n\n getMaxMotorTorque(): number {\n return this.m_maxMotorTorque;\n }\n\n /**\n * Get the current motor torque given the inverse time step, usually in N-m.\n */\n getMotorTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Set/Get the spring frequency in hertz. Setting the frequency to zero disables\n * the spring.\n */\n setSpringFrequencyHz(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n getSpringFrequencyHz(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set/Get the spring damping ratio\n */\n setSpringDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n getSpringDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.combine(this.m_impulse, this.m_ay, this.m_springImpulse, this.m_ax).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective masses.\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n // Point to line constraint\n {\n this.m_ay = Rot.mulVec2(qA, this.m_localYAxisA);\n this.m_sAy = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_ay);\n this.m_sBy = Vec2.crossVec2Vec2(rB, this.m_ay);\n\n this.m_mass = mA + mB + iA * this.m_sAy * this.m_sAy + iB * this.m_sBy\n * this.m_sBy;\n\n if (this.m_mass > 0.0) {\n this.m_mass = 1.0 / this.m_mass;\n }\n }\n\n // Spring constraint\n this.m_springMass = 0.0;\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n if (this.m_frequencyHz > 0.0) {\n this.m_ax = Rot.mulVec2(qA, this.m_localXAxisA);\n this.m_sAx = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_ax);\n this.m_sBx = Vec2.crossVec2Vec2(rB, this.m_ax);\n\n const invMass = mA + mB + iA * this.m_sAx * this.m_sAx + iB * this.m_sBx\n * this.m_sBx;\n\n if (invMass > 0.0) {\n this.m_springMass = 1.0 / invMass;\n\n const C = Vec2.dot(d, this.m_ax);\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const damp = 2.0 * this.m_springMass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = this.m_springMass * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (damp + h * k);\n if (this.m_gamma > 0.0) {\n this.m_gamma = 1.0 / this.m_gamma;\n }\n\n this.m_bias = C * h * k * this.m_gamma;\n\n this.m_springMass = invMass + this.m_gamma;\n if (this.m_springMass > 0.0) {\n this.m_springMass = 1.0 / this.m_springMass;\n }\n }\n } else {\n this.m_springImpulse = 0.0;\n }\n\n // Rotational motor\n if (this.m_enableMotor) {\n this.m_motorMass = iA + iB;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n } else {\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n }\n\n if (step.warmStarting) {\n // Account for variable time step.\n this.m_impulse *= step.dtRatio;\n this.m_springImpulse *= step.dtRatio;\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.combine(this.m_impulse, this.m_ay, this.m_springImpulse, this.m_ax);\n const LA = this.m_impulse * this.m_sAy + this.m_springImpulse * this.m_sAx + this.m_motorImpulse;\n const LB = this.m_impulse * this.m_sBy + this.m_springImpulse * this.m_sBx + this.m_motorImpulse;\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * LA;\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * LB;\n\n } else {\n this.m_impulse = 0.0;\n this.m_springImpulse = 0.0;\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Solve spring constraint\n {\n const Cdot = Vec2.dot(this.m_ax, vB) - Vec2.dot(this.m_ax, vA) + this.m_sBx * wB - this.m_sAx * wA;\n const impulse = -this.m_springMass * (Cdot + this.m_bias + this.m_gamma * this.m_springImpulse);\n this.m_springImpulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_ax);\n const LA = impulse * this.m_sAx;\n const LB = impulse * this.m_sBx;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n // Solve rotational motor constraint\n {\n const Cdot = wB - wA - this.m_motorSpeed;\n let impulse = -this.m_motorMass * Cdot;\n\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorTorque;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve point to line constraint\n {\n const Cdot = Vec2.dot(this.m_ay, vB) - Vec2.dot(this.m_ay, vA) + this.m_sBy * wB - this.m_sAy * wA;\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_ay);\n const LA = impulse * this.m_sAy;\n const LB = impulse * this.m_sBy;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n const ay = Rot.mulVec2(qA, this.m_localYAxisA);\n\n const sAy = Vec2.crossVec2Vec2(Vec2.add(d, rA), ay);\n const sBy = Vec2.crossVec2Vec2(rB, ay);\n\n const C = Vec2.dot(d, ay);\n\n const k = this.m_invMassA + this.m_invMassB + this.m_invIA * this.m_sAy * this.m_sAy + this.m_invIB * this.m_sBy * this.m_sBy;\n\n const impulse = k != 0.0 ? -C / k : 0.0;\n\n const P = Vec2.mulNumVec2(impulse, ay);\n const LA = impulse * sAy;\n const LB = impulse * sBy;\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * LA;\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * LB;\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return math_abs(C) <= Settings.linearSlop;\n }\n\n}\n","import { World } from \"../dynamics/World\";\nimport { Body } from \"../dynamics/Body\";\nimport { Joint } from \"../dynamics/Joint\";\nimport { Fixture } from \"../dynamics/Fixture\";\nimport { Shape } from \"../collision/Shape\";\nimport { Vec2 } from \"../common/Vec2\";\nimport { Vec3 } from \"../common/Vec3\";\nimport { ChainShape } from \"../collision/shape/ChainShape\";\n// import { BoxShape } from \"../collision/shape/BoxShape\";\nimport { EdgeShape } from \"../collision/shape/EdgeShape\";\nimport { PolygonShape } from \"../collision/shape/PolygonShape\";\nimport { CircleShape } from \"../collision/shape/CircleShape\";\nimport { DistanceJoint } from \"../dynamics/joint/DistanceJoint\";\nimport { FrictionJoint } from \"../dynamics/joint/FrictionJoint\";\nimport { GearJoint } from \"../dynamics/joint/GearJoint\";\nimport { MotorJoint } from \"../dynamics/joint/MotorJoint\";\nimport { MouseJoint } from \"../dynamics/joint/MouseJoint\";\nimport { PrismaticJoint } from \"../dynamics/joint/PrismaticJoint\";\nimport { PulleyJoint } from \"../dynamics/joint/PulleyJoint\";\nimport { RevoluteJoint } from \"../dynamics/joint/RevoluteJoint\";\nimport { RopeJoint } from \"../dynamics/joint/RopeJoint\";\nimport { WeldJoint } from \"../dynamics/joint/WeldJoint\";\nimport { WheelJoint } from \"../dynamics/joint/WheelJoint\";\n\nlet SID = 0;\n\n// Classes to be serialized as reference objects\nconst SERIALIZE_REF_TYPES = {\n \"World\": World,\n \"Body\": Body,\n \"Joint\": Joint,\n \"Fixture\": Fixture,\n \"Shape\": Shape,\n};\n\n// For deserializing reference objects by reference type\nconst DESERIALIZE_BY_REF_TYPE = {\n \"Vec2\": Vec2,\n \"Vec3\": Vec3,\n \"World\": World,\n \"Body\": Body,\n \"Joint\": Joint,\n \"Fixture\": Fixture,\n \"Shape\": Shape,\n};\n\n// For deserializing data objects by type field\nconst DESERIALIZE_BY_TYPE_FIELD = {\n [Body.STATIC]: Body,\n [Body.DYNAMIC]: Body,\n [Body.KINEMATIC]: Body,\n [ChainShape.TYPE]: ChainShape,\n // [BoxShape.TYPE]: BoxShape,\n [PolygonShape.TYPE]: PolygonShape,\n [EdgeShape.TYPE]: EdgeShape,\n [CircleShape.TYPE]: CircleShape,\n [DistanceJoint.TYPE]: DistanceJoint,\n [FrictionJoint.TYPE]: FrictionJoint,\n [GearJoint.TYPE]: GearJoint,\n [MotorJoint.TYPE]: MotorJoint,\n [MouseJoint.TYPE]: MouseJoint,\n [PrismaticJoint.TYPE]: PrismaticJoint,\n [PulleyJoint.TYPE]: PulleyJoint,\n [RevoluteJoint.TYPE]: RevoluteJoint,\n [RopeJoint.TYPE]: RopeJoint,\n [WeldJoint.TYPE]: WeldJoint,\n [WheelJoint.TYPE]: WheelJoint,\n};\n\n// dummy types\ntype DataType = any;\ntype ObjectType = any;\ntype ClassName = any;\n\ntype SerializedType = object[];\n\ntype RefType = {\n refIndex: number,\n refType: string,\n};\n\ntype SerializerOptions = {\n rootClass: ClassName,\n preSerialize?: (obj: ObjectType) => DataType,\n postSerialize?: (data: DataType, obj: any) => DataType,\n preDeserialize?: (data: DataType) => DataType,\n postDeserialize?: (obj: ObjectType, data: DataType) => ObjectType,\n};\n\nconst DEFAULT_OPTIONS: SerializerOptions = {\n rootClass: World,\n preSerialize: function(obj) { return obj; },\n postSerialize: function(data, obj) { return data; },\n preDeserialize: function(data: DataType) { return data; },\n postDeserialize: function(obj, data) { return obj; },\n};\n\ntype DeserializeChildCallback = (classHint: any, obj: any, context: any) => any;\ntype ClassDeserializerMethod = (data: any, context: any, deserialize: DeserializeChildCallback) => any;\n\nexport class Serializer {\n private options: SerializerOptions;\n constructor(options: SerializerOptions) {\n this.options = {\n ...DEFAULT_OPTIONS,\n ...options,\n };\n }\n\n toJson = (root: T): SerializedType => {\n const preSerialize = this.options.preSerialize;\n const postSerialize = this.options.postSerialize;\n const json = [];\n\n // Breadth-first ref serialization queue\n const refQueue = [root];\n\n const refMemoById: Record = {};\n\n function addToRefQueue(value: any, typeName: string) {\n value.__sid = value.__sid || ++SID;\n if (!refMemoById[value.__sid]) {\n refQueue.push(value);\n const index = json.length + refQueue.length;\n const ref = {\n refIndex: index,\n refType: typeName\n };\n refMemoById[value.__sid] = ref;\n }\n return refMemoById[value.__sid];\n }\n\n function serializeWithHooks(obj: ObjectType) {\n obj = preSerialize(obj);\n let data = obj._serialize();\n data = postSerialize(data, obj);\n return data;\n }\n\n // traverse the object graph\n // ref objects are pushed into the queue\n // other objects are serialize in-place \n function traverse(value: any, noRefType = false) {\n if (typeof value !== \"object\" || value === null) {\n return value;\n }\n // object with _serialize function\n if (typeof value._serialize === \"function\") {\n if (!noRefType) {\n for (const typeName in SERIALIZE_REF_TYPES) {\n if (value instanceof SERIALIZE_REF_TYPES[typeName]) {\n return addToRefQueue(value, typeName);\n }\n }\n }\n // object with _serialize function\n value = serializeWithHooks(value);\n }\n // recursive for arrays any objects\n if (Array.isArray(value)) {\n const newValue = [];\n for (let key = 0; key < value.length; key++) {\n newValue[key] = traverse(value[key]);\n }\n value = newValue;\n\n } else {\n const newValue = {};\n for (const key in value) {\n if (value.hasOwnProperty(key)) {\n newValue[key] = traverse(value[key]);\n }\n }\n value = newValue;\n }\n return value;\n }\n\n while (refQueue.length) {\n const obj = refQueue.shift();\n const str = traverse(obj, true);\n json.push(str);\n }\n\n return json;\n };\n\n fromJson = (json: SerializedType): T => {\n const preDeserialize = this.options.preDeserialize;\n const postDeserialize = this.options.postDeserialize;\n const rootClass = this.options.rootClass;\n\n const deserializedRefMemoByIndex: Record = {};\n\n function deserializeWithHooks(classHint: ClassName, data: DataType, context: any): ObjectType {\n if (!classHint || !classHint._deserialize) {\n classHint = DESERIALIZE_BY_TYPE_FIELD[data.type];\n }\n const deserializer = classHint && classHint._deserialize;\n if (!deserializer) {\n return;\n }\n data = preDeserialize(data);\n const classDeserializeFn = classHint._deserialize as ClassDeserializerMethod;\n let obj = classDeserializeFn(data, context, deserializeChild);\n obj = postDeserialize(obj, data);\n return obj;\n }\n\n /**\n * Recursive callback function to deserialize a child data object or reference object.\n * \n * @param classHint suggested class to deserialize obj to\n * @param dataOrRef data or reference object\n * @param context for example world when deserializing bodies and joints\n */\n function deserializeChild(classHint: ClassName, dataOrRef: DataType | RefType, context: any) {\n const isRefObject = dataOrRef.refIndex && dataOrRef.refType;\n if (!isRefObject) {\n return deserializeWithHooks(classHint, dataOrRef, context); \n }\n const ref = dataOrRef as RefType;\n if (DESERIALIZE_BY_REF_TYPE[ref.refType]) {\n classHint = DESERIALIZE_BY_REF_TYPE[ref.refType];\n }\n const refIndex = ref.refIndex;\n if (!deserializedRefMemoByIndex[refIndex]) {\n const data = json[refIndex];\n const obj = deserializeWithHooks(classHint, data, context);\n deserializedRefMemoByIndex[refIndex] = obj;\n }\n return deserializedRefMemoByIndex[refIndex];\n }\n\n const root = deserializeWithHooks(rootClass, json[0], null);\n\n return root;\n };\n\n static toJson: (root: World) => SerializedType;\n static fromJson: (json: SerializedType) => World;\n}\n\nconst worldSerializer = new Serializer({\n rootClass: World,\n});\n\nSerializer.fromJson = worldSerializer.fromJson;\nSerializer.toJson = worldSerializer.toJson;\n","import type { AABBValue } from \"../collision/AABB\";\nimport type { World } from \"../dynamics/World\";\nimport type { Joint } from \"../dynamics/Joint\";\nimport type { Fixture } from \"../dynamics/Fixture\";\nimport type { Body } from \"../dynamics/Body\";\n\nexport interface Style {\n stroke?: string;\n fill?: string;\n lineWidth?: number;\n}\n\ntype KEY = \"0\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" |\n \"8\" | \"9\" | \"A\" | \"B\" | \"C\" | \"D\" | \"E\" | \"F\" | \"G\" |\n \"H\" | \"I\" | \"J\" | \"K\" | \"L\" | \"M\" | \"N\" | \"O\" | \"P\" |\n \"Q\" | \"R\" | \"S\" | \"T\" | \"U\" | \"V\" | \"W\" | \"X\" | \"Y\" |\n \"Z\" | \"right\" | \"left\" | \"up\" | \"down\" | \"fire\";\n\nexport type ActiveKeys = { [key in KEY]?: boolean };\n\ntype TestbedMountOptions = { [key: string]: any };\n\nexport abstract class Testbed {\n /**\n * Mounts testbed. Call start with a world to start simulation and rendering.\n */\n static mount(options?: TestbedMountOptions): Testbed {\n throw new Error(\"Not implemented\");\n }\n\n /**\n * Mounts testbed if needed, then starts simulation and rendering.\n * \n * If you need to customize testbed before starting, first run `const testbed = Testbed.mount()` and then `testbed.start()`.\n */\n static start(world: World): Testbed {\n const testbed = Testbed.mount();\n testbed.start(world);\n return testbed;\n }\n\n /** World viewbox width. */\n width: number = 80;\n\n /** World viewbox height. */\n height: number = 60;\n\n /** World viewbox center vertical offset. */\n x: number = 0;\n\n /** World viewbox center horizontal offset. */\n y: number = -10;\n\n /** @hidden */\n scaleY: number = -1;\n\n /** World simulation step frequency */\n hz: number = 60;\n\n /** World simulation speed, default is 1 */\n speed: number = 1;\n\n background: string = \"#222222\";\n\n mouseForce?: number;\n activeKeys: ActiveKeys = {};\n\n /** callback, to be implemented by user */\n step = (dt: number, t: number): void => {\n return;\n };\n\n /** callback, to be implemented by user */\n keydown = (keyCode: number, label: string): void => {\n return;\n };\n\n /** callback, to be implemented by user */\n keyup = (keyCode: number, label: string): void => {\n return;\n };\n\n abstract status(name: string, value: any): void;\n abstract status(value: object | string): void;\n\n abstract info(text: string): void;\n\n color(r: number, g: number, b: number): string {\n r = r * 256 | 0;\n g = g * 256 | 0;\n b = b * 256 | 0;\n return \"rgb(\" + r + \", \" + g + \", \" + b + \")\";\n }\n\n abstract drawPoint(p: {x: number, y: number}, r: any, color: string): void;\n abstract drawCircle(p: {x: number, y: number}, r: number, color: string): void;\n abstract drawEdge(a: {x: number, y: number}, b: {x: number, y: number}, color: string): void;\n abstract drawSegment(a: {x: number, y: number}, b: {x: number, y: number}, color: string): void;\n abstract drawPolygon(points: Array<{x: number, y: number}>, color: string): void;\n abstract drawAABB(aabb: AABBValue, color: string): void;\n\n abstract start(world: World): void;\n\n abstract findOne(query: string): (Body | Joint | Fixture | null);\n abstract findAll(query: string): (Body | Joint | Fixture)[];\n}\n\ntype TestbedFactoryOptions = string | TestbedMountOptions;\n\n/** @deprecated */\ntype TestbedCallback = (testbed: Testbed) => (World | undefined);\n\n/** @deprecated */\nexport function testbed(callback: TestbedCallback): void;\n/** @deprecated */\nexport function testbed(options: TestbedFactoryOptions, callback: TestbedCallback): void;\n/** @internal */\nexport function testbed(a?: any, b?: any) {\n let callback: TestbedCallback | undefined;\n let options;\n if (typeof a === \"function\") {\n callback = a;\n options = b;\n } else if (typeof b === \"function\") {\n callback = b;\n options = a;\n } else {\n options = a ?? b;\n }\n const testbed = Testbed.mount(options);\n if (callback) {\n // this is for backwards compatibility\n const world = callback(testbed) || (testbed as any).world;\n testbed.start(world);\n } else {\n return testbed;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { Vec2Value } from \"../../common/Vec2\";\nimport { PolygonShape } from \"./PolygonShape\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\ndeclare module \"./BoxShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function BoxShape(halfWidth: number, halfHeight: number, center?: Vec2Value, angle?: number): BoxShape;\n}\n\n/**\n * A rectangle polygon which extend PolygonShape.\n */\n// @ts-expect-error\nexport class BoxShape extends PolygonShape {\n // note that box is serialized/deserialized as polygon\n static TYPE = \"polygon\" as const;\n\n /**\n * \n * @param halfWidth \n * @param halfHeight \n * @param center coordinate of the center of the box relative to the body\n * @param angle angle of the box relative to the body\n */\n constructor(halfWidth: number, halfHeight: number, center?: Vec2Value, angle?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof BoxShape)) {\n return new BoxShape(halfWidth, halfHeight, center, angle);\n }\n\n super();\n\n this._setAsBox(halfWidth, halfHeight, center, angle);\n }\n}\n\nexport const Box = BoxShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { CircleShape } from \"./CircleShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(CircleShape.TYPE, CircleShape.TYPE, CircleCircleContact);\n\n/** @internal */ function CircleCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == CircleShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n CollideCircles(manifold, fixtureA.getShape() as CircleShape, xfA, fixtureB.getShape() as CircleShape, xfB);\n}\n\n/** @internal */ const pA = matrix.vec2(0, 0);\n/** @internal */ const pB = matrix.vec2(0, 0);\n\nexport const CollideCircles = function (manifold: Manifold, circleA: CircleShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n matrix.transformVec2(pA, xfA, circleA.m_p);\n matrix.transformVec2(pB, xfB, circleB.m_p);\n\n const distSqr = matrix.distSqrVec2(pB, pA);\n const rA = circleA.m_radius;\n const rB = circleB.m_radius;\n const radius = rA + rB;\n if (distSqr > radius * radius) {\n return;\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.copyVec2(manifold.localPoint, circleA.m_p);\n matrix.zeroVec2(manifold.localNormal);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { TransformValue } from \"../../common/Transform\";\nimport * as matrix from \"../../common/Matrix\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { EdgeShape } from \"./EdgeShape\";\nimport { ChainShape } from \"./ChainShape\";\nimport { CircleShape } from \"./CircleShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(EdgeShape.TYPE, CircleShape.TYPE, EdgeCircleContact);\nContact.addType(ChainShape.TYPE, CircleShape.TYPE, ChainCircleContact);\n\n/** @internal */ function EdgeCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == EdgeShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n\n const shapeA = fixtureA.getShape() as EdgeShape;\n const shapeB = fixtureB.getShape() as CircleShape;\n\n CollideEdgeCircle(manifold, shapeA, xfA, shapeB, xfB);\n}\n\nfunction ChainCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == ChainShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n\n const chain = fixtureA.getShape() as ChainShape;\n const edge = new EdgeShape();\n chain.getChildEdge(edge, indexA);\n\n const shapeA = edge;\n const shapeB = fixtureB.getShape() as CircleShape;\n\n CollideEdgeCircle(manifold, shapeA, xfA, shapeB, xfB);\n}\n\n/** @internal */ const e = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const e1 = matrix.vec2(0, 0);\n/** @internal */ const e2 = matrix.vec2(0, 0);\n/** @internal */ const Q = matrix.vec2(0, 0);\n/** @internal */ const P = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n\n// Compute contact points for edge versus circle.\n// This accounts for edge connectivity.\nexport const CollideEdgeCircle = function (manifold: Manifold, edgeA: EdgeShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n // Compute circle in frame of edge\n matrix.retransformVec2(Q, xfB, xfA, circleB.m_p);\n\n const A = edgeA.m_vertex1;\n const B = edgeA.m_vertex2;\n matrix.subVec2(e, B, A);\n\n // Barycentric coordinates\n const u = matrix.dotVec2(e, B) - matrix.dotVec2(e, Q);\n const v = matrix.dotVec2(e, Q) - matrix.dotVec2(e, A);\n\n const radius = edgeA.m_radius + circleB.m_radius;\n\n // Region A\n if (v <= 0.0) {\n matrix.copyVec2(P, A);\n const dd = matrix.distSqrVec2(Q, A);\n if (dd > radius * radius) {\n return;\n }\n\n // Is there an edge connected to A?\n if (edgeA.m_hasVertex0) {\n const A1 = edgeA.m_vertex0;\n const B1 = A;\n matrix.subVec2(e1, B1, A1);\n const u1 = matrix.dotVec2(e1, B1) - matrix.dotVec2(e1, Q);\n\n // Is the circle in Region AB of the previous edge?\n if (u1 > 0.0) {\n return;\n }\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.zeroVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, P);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n return;\n }\n\n // Region B\n if (u <= 0.0) {\n matrix.copyVec2(P, B);\n const dd = matrix.distSqrVec2(Q, P);\n if (dd > radius * radius) {\n return;\n }\n\n // Is there an edge connected to B?\n if (edgeA.m_hasVertex3) {\n const B2 = edgeA.m_vertex3;\n const A2 = B;\n matrix.subVec2(e2, B2, A2);\n const v2 = matrix.dotVec2(e2, Q) - matrix.dotVec2(e2, A2);\n\n // Is the circle in Region AB of the next edge?\n if (v2 > 0.0) {\n return;\n }\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.zeroVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, P);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(1, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n\n return;\n }\n\n // Region AB\n const den = matrix.lengthSqrVec2(e);\n if (_ASSERT) console.assert(den > 0.0);\n matrix.combine2Vec2(P, u / den, A, v / den, B);\n const dd = matrix.distSqrVec2(Q, P);\n if (dd > radius * radius) {\n return;\n }\n\n matrix.crossNumVec2(n, 1, e);\n if (matrix.dotVec2(n, Q) - matrix.dotVec2(n, A) < 0.0) {\n matrix.negVec2(n);\n }\n matrix.normalizeVec2(n);\n\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, n);\n matrix.copyVec2(manifold.localPoint, A);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_face, 0, ContactFeatureType.e_vertex);\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { TransformValue } from \"../../common/Transform\";\nimport * as matrix from \"../../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Manifold, clipSegmentToLine, ClipVertex, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/** @internal */ const incidentEdge = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints1 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints2 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipSegmentToLineNormal = matrix.vec2(0, 0);\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const v11 = matrix.vec2(0, 0);\n/** @internal */ const v12 = matrix.vec2(0, 0);\n/** @internal */ const localTangent = matrix.vec2(0, 0);\n/** @internal */ const localNormal = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const tangent = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const normal1 = matrix.vec2(0, 0);\n\n\nContact.addType(PolygonShape.TYPE, PolygonShape.TYPE, PolygonContact);\n\n/** @internal */ function PolygonContact(\n manifold: Manifold,\n xfA: TransformValue,\n fixtureA: Fixture,\n indexA: number,\n xfB: TransformValue,\n fixtureB: Fixture,\n indexB: number,\n): void {\n if (_ASSERT) console.assert(fixtureA.getType() == PolygonShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == PolygonShape.TYPE);\n CollidePolygons(manifold, fixtureA.getShape() as PolygonShape, xfA, fixtureB.getShape() as PolygonShape, xfB);\n}\n\n/** @internal */ interface MaxSeparation {\n maxSeparation: number;\n bestIndex: number;\n}\n\n/**\n * Find the max separation between poly1 and poly2 using edge normals from\n * poly1.\n */\n/** @internal */ function findMaxSeparation(\n poly1: PolygonShape,\n xf1: TransformValue,\n poly2: PolygonShape,\n xf2: TransformValue,\n output: MaxSeparation,\n): void {\n const count1 = poly1.m_count;\n const count2 = poly2.m_count;\n const n1s = poly1.m_normals;\n const v1s = poly1.m_vertices;\n const v2s = poly2.m_vertices;\n\n matrix.detransformTransform(xf, xf2, xf1);\n\n let bestIndex = 0;\n let maxSeparation = -Infinity;\n for (let i = 0; i < count1; ++i) {\n // Get poly1 normal in frame2.\n matrix.rotVec2(n, xf.q, n1s[i]);\n matrix.transformVec2(v1, xf, v1s[i]);\n\n // Find deepest point for normal i.\n let si = Infinity;\n for (let j = 0; j < count2; ++j) {\n const sij = matrix.dotVec2(n, v2s[j]) - matrix.dotVec2(n, v1);\n if (sij < si) {\n si = sij;\n }\n }\n\n if (si > maxSeparation) {\n maxSeparation = si;\n bestIndex = i;\n }\n }\n\n // used to keep last FindMaxSeparation call values\n output.maxSeparation = maxSeparation;\n output.bestIndex = bestIndex;\n}\n\n/** @internal */ function findIncidentEdge(\n clipVertex: ClipVertex[],\n poly1: PolygonShape,\n xf1: TransformValue,\n edge1: number,\n poly2: PolygonShape,\n xf2: TransformValue,\n): void {\n const normals1 = poly1.m_normals;\n\n const count2 = poly2.m_count;\n const vertices2 = poly2.m_vertices;\n const normals2 = poly2.m_normals;\n\n if (_ASSERT) console.assert(0 <= edge1 && edge1 < poly1.m_count);\n\n // Get the normal of the reference edge in poly2's frame.\n matrix.rerotVec2(normal1, xf2.q, xf1.q, normals1[edge1]);\n\n // Find the incident edge on poly2.\n let index = 0;\n let minDot = Infinity;\n for (let i = 0; i < count2; ++i) {\n const dot = matrix.dotVec2(normal1, normals2[i]);\n if (dot < minDot) {\n minDot = dot;\n index = i;\n }\n }\n\n // Build the clip vertices for the incident edge.\n const i1 = index;\n const i2 = i1 + 1 < count2 ? i1 + 1 : 0;\n\n matrix.transformVec2(clipVertex[0].v, xf2, vertices2[i1]);\n clipVertex[0].id.setFeatures(edge1, ContactFeatureType.e_face, i1, ContactFeatureType.e_vertex);\n\n matrix.transformVec2(clipVertex[1].v, xf2, vertices2[i2]);\n clipVertex[1].id.setFeatures(edge1, ContactFeatureType.e_face, i2, ContactFeatureType.e_vertex);\n}\n\n/** @internal */ const maxSeparation = {\n maxSeparation: 0,\n bestIndex: 0,\n};\n\n/**\n *\n * Find edge normal of max separation on A - return if separating axis is found
\n * Find edge normal of max separation on B - return if separation axis is found
\n * Choose reference edge as min(minA, minB)
\n * Find incident edge
\n * Clip\n *\n * The normal points from 1 to 2\n */\nexport const CollidePolygons = function (\n manifold: Manifold,\n polyA: PolygonShape,\n xfA: TransformValue,\n polyB: PolygonShape,\n xfB: TransformValue,\n): void {\n manifold.pointCount = 0;\n const totalRadius = polyA.m_radius + polyB.m_radius;\n\n findMaxSeparation(polyA, xfA, polyB, xfB, maxSeparation);\n const edgeA = maxSeparation.bestIndex;\n const separationA = maxSeparation.maxSeparation;\n if (separationA > totalRadius)\n return;\n\n findMaxSeparation(polyB, xfB, polyA, xfA, maxSeparation);\n const edgeB = maxSeparation.bestIndex;\n const separationB = maxSeparation.maxSeparation;\n if (separationB > totalRadius)\n return;\n\n let poly1: PolygonShape; // reference polygon\n let poly2: PolygonShape; // incident polygon\n let xf1: TransformValue;\n let xf2: TransformValue;\n let edge1: number; // reference edge\n let flip: boolean;\n const k_tol = 0.1 * Settings.linearSlop;\n\n if (separationB > separationA + k_tol) {\n poly1 = polyB;\n poly2 = polyA;\n xf1 = xfB;\n xf2 = xfA;\n edge1 = edgeB;\n manifold.type = ManifoldType.e_faceB;\n flip = true;\n } else {\n poly1 = polyA;\n poly2 = polyB;\n xf1 = xfA;\n xf2 = xfB;\n edge1 = edgeA;\n manifold.type = ManifoldType.e_faceA;\n flip = false;\n }\n\n incidentEdge[0].recycle();\n incidentEdge[1].recycle();\n findIncidentEdge(incidentEdge, poly1, xf1, edge1, poly2, xf2);\n\n const count1 = poly1.m_count;\n const vertices1 = poly1.m_vertices;\n\n const iv1 = edge1;\n const iv2 = edge1 + 1 < count1 ? edge1 + 1 : 0;\n\n matrix.copyVec2(v11, vertices1[iv1]);\n matrix.copyVec2(v12, vertices1[iv2]);\n\n matrix.subVec2(localTangent, v12, v11);\n matrix.normalizeVec2(localTangent);\n\n matrix.crossVec2Num(localNormal, localTangent, 1.0);\n matrix.combine2Vec2(planePoint, 0.5, v11, 0.5, v12);\n\n matrix.rotVec2(tangent, xf1.q, localTangent);\n matrix.crossVec2Num(normal, tangent, 1.0);\n\n matrix.transformVec2(v11, xf1, v11);\n matrix.transformVec2(v12, xf1, v12);\n\n // Face offset.\n const frontOffset = matrix.dotVec2(normal, v11);\n\n // Side offsets, extended by polytope skin thickness.\n const sideOffset1 = -matrix.dotVec2(tangent, v11) + totalRadius;\n const sideOffset2 = matrix.dotVec2(tangent, v12) + totalRadius;\n\n // Clip incident edge against extruded edge1 side edges.\n clipPoints1[0].recycle();\n clipPoints1[1].recycle();\n clipPoints2[0].recycle();\n clipPoints2[1].recycle();\n\n // Clip to box side 1\n matrix.setVec2(clipSegmentToLineNormal, -tangent.x, -tangent.y);\n const np1 = clipSegmentToLine(clipPoints1, incidentEdge, clipSegmentToLineNormal, sideOffset1, iv1);\n\n if (np1 < 2) {\n return;\n }\n\n // Clip to negative box side 1\n matrix.setVec2(clipSegmentToLineNormal, tangent.x, tangent.y);\n const np2 = clipSegmentToLine(clipPoints2, clipPoints1, clipSegmentToLineNormal, sideOffset2, iv2);\n\n if (np2 < 2) {\n return;\n }\n\n // Now clipPoints2 contains the clipped points.\n matrix.copyVec2(manifold.localNormal, localNormal);\n matrix.copyVec2(manifold.localPoint, planePoint);\n\n let pointCount = 0;\n for (let i = 0; i < clipPoints2.length/* maxManifoldPoints */; ++i) {\n const separation = matrix.dotVec2(normal, clipPoints2[i].v) - frontOffset;\n\n if (separation <= totalRadius) {\n const cp = manifold.points[pointCount];\n matrix.detransformVec2(cp.localPoint, xf2, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n if (flip) {\n // Swap features\n cp.id.swapFeatures();\n }\n ++pointCount;\n }\n }\n\n manifold.pointCount = pointCount;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { EPSILON } from \"../../common/Math\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { CircleShape } from \"./CircleShape\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(PolygonShape.TYPE, CircleShape.TYPE, PolygonCircleContact);\n\n/** @internal */ function PolygonCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == PolygonShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n CollidePolygonCircle(manifold, fixtureA.getShape() as PolygonShape, xfA, fixtureB.getShape() as CircleShape, xfB);\n}\n\n/** @internal */ const cLocal = matrix.vec2(0, 0);\n/** @internal */ const faceCenter = matrix.vec2(0, 0);\n\nexport const CollidePolygonCircle = function (manifold: Manifold, polygonA: PolygonShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n // Compute circle position in the frame of the polygon.\n matrix.retransformVec2(cLocal, xfB, xfA, circleB.m_p);\n\n // Find the min separating edge.\n let normalIndex = 0;\n let separation = -Infinity;\n const radius = polygonA.m_radius + circleB.m_radius;\n const vertexCount = polygonA.m_count;\n const vertices = polygonA.m_vertices;\n const normals = polygonA.m_normals;\n\n for (let i = 0; i < vertexCount; ++i) {\n const s = matrix.dotVec2(normals[i], cLocal) - matrix.dotVec2(normals[i], vertices[i]);\n\n if (s > radius) {\n // Early out.\n return;\n }\n\n if (s > separation) {\n separation = s;\n normalIndex = i;\n }\n }\n\n // Vertices that subtend the incident face.\n const vertIndex1 = normalIndex;\n const vertIndex2 = vertIndex1 + 1 < vertexCount ? vertIndex1 + 1 : 0;\n const v1 = vertices[vertIndex1];\n const v2 = vertices[vertIndex2];\n\n // If the center is inside the polygon ...\n if (separation < EPSILON) {\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, normals[normalIndex]);\n matrix.combine2Vec2(manifold.localPoint, 0.5, v1, 0.5, v2);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n return;\n }\n\n // Compute barycentric coordinates\n // u1 = (cLocal - v1) dot (v2 - v1))\n const u1 = matrix.dotVec2(cLocal, v2) - matrix.dotVec2(cLocal, v1) - matrix.dotVec2(v1, v2) + matrix.dotVec2(v1, v1);\n // u2 = (cLocal - v2) dot (v1 - v2)\n const u2 = matrix.dotVec2(cLocal, v1) - matrix.dotVec2(cLocal, v2) - matrix.dotVec2(v2, v1) + matrix.dotVec2(v2, v2);\n if (u1 <= 0.0) {\n if (matrix.distSqrVec2(cLocal, v1) > radius * radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.subVec2(manifold.localNormal, cLocal, v1);\n matrix.normalizeVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, v1);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n } else if (u2 <= 0.0) {\n if (matrix.distSqrVec2(cLocal, v2) > radius * radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.subVec2(manifold.localNormal, cLocal, v2);\n matrix.normalizeVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, v2);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n } else {\n matrix.combine2Vec2(faceCenter, 0.5, v1, 0.5, v2);\n const separation = matrix.dotVec2(cLocal, normals[vertIndex1]) - matrix.dotVec2(faceCenter, normals[vertIndex1]);\n if (separation > radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, normals[vertIndex1]);\n matrix.copyVec2(manifold.localPoint, faceCenter);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n }\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { Manifold, clipSegmentToLine, ClipVertex, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { EdgeShape } from \"./EdgeShape\";\nimport { ChainShape } from \"./ChainShape\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_min = Math.min;\n\nContact.addType(EdgeShape.TYPE, PolygonShape.TYPE, EdgePolygonContact);\nContact.addType(ChainShape.TYPE, PolygonShape.TYPE, ChainPolygonContact);\n\n/** @internal */ function EdgePolygonContact(manifold: Manifold, xfA: TransformValue, fA: Fixture, indexA: number, xfB: TransformValue, fB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fA.getType() == EdgeShape.TYPE);\n if (_ASSERT) console.assert(fB.getType() == PolygonShape.TYPE);\n\n CollideEdgePolygon(manifold, fA.getShape() as EdgeShape, xfA, fB.getShape() as PolygonShape, xfB);\n}\n\n// reused\n/** @internal */ const edge_reuse = new EdgeShape();\n\n/** @internal */ function ChainPolygonContact(manifold: Manifold, xfA: TransformValue, fA: Fixture, indexA: number, xfB: TransformValue, fB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fA.getType() == ChainShape.TYPE);\n if (_ASSERT) console.assert(fB.getType() == PolygonShape.TYPE);\n\n const chain = fA.getShape() as ChainShape;\n chain.getChildEdge(edge_reuse, indexA);\n\n CollideEdgePolygon(manifold, edge_reuse, xfA, fB.getShape() as PolygonShape, xfB);\n}\n\n/** @internal */ enum EPAxisType {\n e_unknown = -1,\n e_edgeA = 1,\n e_edgeB = 2,\n}\n\n// unused?\n/** @internal */ enum VertexType {\n e_isolated = 0,\n e_concave = 1,\n e_convex = 2,\n}\n\n/**\n * This structure is used to keep track of the best separating axis.\n */\n/** @internal */ class EPAxis {\n type: EPAxisType;\n index: number;\n separation: number;\n}\n\n/**\n * This holds polygon B expressed in frame A.\n */\n/** @internal */ class TempPolygon {\n vertices: Vec2Value[] = []; // [Settings.maxPolygonVertices]\n normals: Vec2Value[] = []; // [Settings.maxPolygonVertices];\n count: number = 0;\n constructor() {\n for (let i = 0; i < Settings.maxPolygonVertices; i++) {\n this.vertices.push(matrix.vec2(0, 0));\n this.normals.push(matrix.vec2(0, 0));\n }\n }\n}\n\n/**\n * Reference face used for clipping\n */\n/** @internal */ class ReferenceFace {\n i1: number;\n i2: number;\n readonly v1 = matrix.vec2(0 ,0);\n readonly v2 = matrix.vec2(0 ,0);\n readonly normal = matrix.vec2(0 ,0);\n readonly sideNormal1 = matrix.vec2(0 ,0);\n sideOffset1: number;\n readonly sideNormal2 = matrix.vec2(0 ,0);\n sideOffset2: number;\n recycle() {\n matrix.zeroVec2(this.v1);\n matrix.zeroVec2(this.v2);\n matrix.zeroVec2(this.normal);\n matrix.zeroVec2(this.sideNormal1);\n matrix.zeroVec2(this.sideNormal2);\n }\n}\n\n// reused\n/** @internal */ const clipPoints1 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints2 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const ie = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const edgeAxis = new EPAxis();\n/** @internal */ const polygonAxis = new EPAxis();\n/** @internal */ const polygonBA = new TempPolygon();\n/** @internal */ const rf = new ReferenceFace();\n/** @internal */ const centroidB = matrix.vec2(0, 0);\n/** @internal */ const edge0 = matrix.vec2(0, 0);\n/** @internal */ const edge1 = matrix.vec2(0, 0);\n/** @internal */ const edge2 = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const normal0 = matrix.vec2(0, 0);\n/** @internal */ const normal1 = matrix.vec2(0, 0);\n/** @internal */ const normal2 = matrix.vec2(0, 0);\n/** @internal */ const lowerLimit = matrix.vec2(0, 0);\n/** @internal */ const upperLimit = matrix.vec2(0, 0);\n/** @internal */ const perp = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n\n/**\n * This function collides and edge and a polygon, taking into account edge\n * adjacency.\n */\nexport const CollideEdgePolygon = function (manifold: Manifold, edgeA: EdgeShape, xfA: TransformValue, polygonB: PolygonShape, xfB: TransformValue): void {\n // Algorithm:\n // 1. Classify v1 and v2\n // 2. Classify polygon centroid as front or back\n // 3. Flip normal if necessary\n // 4. Initialize normal range to [-pi, pi] about face normal\n // 5. Adjust normal range according to adjacent edges\n // 6. Visit each separating axes, only accept axes within the range\n // 7. Return if _any_ axis indicates separation\n // 8. Clip\n\n // let m_type1: VertexType;\n // let m_type2: VertexType;\n\n matrix.detransformTransform(xf, xfA, xfB);\n matrix.transformVec2(centroidB, xf, polygonB.m_centroid);\n\n const v0 = edgeA.m_vertex0;\n const v1 = edgeA.m_vertex1;\n const v2 = edgeA.m_vertex2;\n const v3 = edgeA.m_vertex3;\n\n const hasVertex0 = edgeA.m_hasVertex0;\n const hasVertex3 = edgeA.m_hasVertex3;\n\n matrix.subVec2(edge1, v2, v1);\n matrix.normalizeVec2(edge1);\n matrix.setVec2(normal1, edge1.y, -edge1.x);\n const offset1 = matrix.dotVec2(normal1, centroidB) - matrix.dotVec2(normal1, v1);\n let offset0 = 0.0;\n let offset2 = 0.0;\n let convex1 = false;\n let convex2 = false;\n\n matrix.zeroVec2(normal0);\n matrix.zeroVec2(normal2);\n\n // Is there a preceding edge?\n if (hasVertex0) {\n matrix.subVec2(edge0, v1, v0);\n matrix.normalizeVec2(edge0);\n matrix.setVec2(normal0, edge0.y, -edge0.x);\n convex1 = matrix.crossVec2Vec2(edge0, edge1) >= 0.0;\n offset0 = Vec2.dot(normal0, centroidB) - Vec2.dot(normal0, v0);\n }\n\n // Is there a following edge?\n if (hasVertex3) {\n matrix.subVec2(edge2, v3, v2);\n matrix.normalizeVec2(edge2);\n matrix.setVec2(normal2, edge2.y, -edge2.x);\n convex2 = Vec2.crossVec2Vec2(edge1, edge2) > 0.0;\n offset2 = Vec2.dot(normal2, centroidB) - Vec2.dot(normal2, v2);\n }\n\n let front: boolean;\n matrix.zeroVec2(normal);\n matrix.zeroVec2(lowerLimit);\n matrix.zeroVec2(upperLimit);\n\n // Determine front or back collision. Determine collision normal limits.\n if (hasVertex0 && hasVertex3) {\n if (convex1 && convex2) {\n front = offset0 >= 0.0 || offset1 >= 0.0 || offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else if (convex1) {\n front = offset0 >= 0.0 || (offset1 >= 0.0 && offset2 >= 0.0);\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else if (convex2) {\n front = offset2 >= 0.0 || (offset0 >= 0.0 && offset1 >= 0.0);\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n } else {\n front = offset0 >= 0.0 && offset1 >= 0.0 && offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n }\n } else if (hasVertex0) {\n if (convex1) {\n front = offset0 >= 0.0 || offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else {\n front = offset0 >= 0.0 && offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n }\n } else if (hasVertex3) {\n if (convex2) {\n front = offset1 >= 0.0 || offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal1);\n }\n } else {\n front = offset1 >= 0.0 && offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.copyVec2(upperLimit, normal1);\n }\n }\n } else {\n front = offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal1);\n }\n }\n\n // Get polygonB in frameA\n polygonBA.count = polygonB.m_count;\n for (let i = 0; i < polygonB.m_count; ++i) {\n matrix.transformVec2(polygonBA.vertices[i], xf, polygonB.m_vertices[i]);\n matrix.rotVec2(polygonBA.normals[i], xf.q, polygonB.m_normals[i]);\n }\n\n const radius = polygonB.m_radius + edgeA.m_radius;\n\n manifold.pointCount = 0;\n\n { // ComputeEdgeSeparation\n edgeAxis.type = EPAxisType.e_edgeA;\n edgeAxis.index = front ? 0 : 1;\n edgeAxis.separation = Infinity;\n\n for (let i = 0; i < polygonBA.count; ++i) {\n const v = polygonBA.vertices[i];\n const s = matrix.dotVec2(normal, v) - matrix.dotVec2(normal, v1);\n if (s < edgeAxis.separation) {\n edgeAxis.separation = s;\n }\n }\n }\n\n // If no valid normal can be found than this edge should not collide.\n // @ts-ignore todo: why we need this if here?\n if (edgeAxis.type == EPAxisType.e_unknown) {\n return;\n }\n\n if (edgeAxis.separation > radius) {\n return;\n }\n\n { // ComputePolygonSeparation\n polygonAxis.type = EPAxisType.e_unknown;\n polygonAxis.index = -1;\n polygonAxis.separation = -Infinity;\n\n matrix.setVec2(perp, -normal.y, normal.x);\n\n for (let i = 0; i < polygonBA.count; ++i) {\n matrix.scaleVec2(n, -1, polygonBA.normals[i]);\n\n const s1 = matrix.dotVec2(n, polygonBA.vertices[i]) - matrix.dotVec2(n, v1);\n const s2 = matrix.dotVec2(n, polygonBA.vertices[i]) - matrix.dotVec2(n, v2);\n const s = math_min(s1, s2);\n\n if (s > radius) {\n // No collision\n polygonAxis.type = EPAxisType.e_edgeB;\n polygonAxis.index = i;\n polygonAxis.separation = s;\n break;\n }\n\n // Adjacency\n if (matrix.dotVec2(n, perp) >= 0.0) {\n if (matrix.dotVec2(n, normal) - matrix.dotVec2(upperLimit, normal) < -Settings.angularSlop) {\n continue;\n }\n } else {\n if (matrix.dotVec2(n, normal) - matrix.dotVec2(lowerLimit, normal) < -Settings.angularSlop) {\n continue;\n }\n }\n\n if (s > polygonAxis.separation) {\n polygonAxis.type = EPAxisType.e_edgeB;\n polygonAxis.index = i;\n polygonAxis.separation = s;\n }\n }\n }\n\n if (polygonAxis.type != EPAxisType.e_unknown && polygonAxis.separation > radius) {\n return;\n }\n\n // Use hysteresis for jitter reduction.\n const k_relativeTol = 0.98;\n const k_absoluteTol = 0.001;\n\n let primaryAxis: EPAxis;\n if (polygonAxis.type == EPAxisType.e_unknown) {\n primaryAxis = edgeAxis;\n } else if (polygonAxis.separation > k_relativeTol * edgeAxis.separation + k_absoluteTol) {\n primaryAxis = polygonAxis;\n } else {\n primaryAxis = edgeAxis;\n }\n\n ie[0].recycle();\n ie[1].recycle();\n\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n manifold.type = ManifoldType.e_faceA;\n\n // Search for the polygon normal that is most anti-parallel to the edge\n // normal.\n let bestIndex = 0;\n let bestValue = matrix.dotVec2(normal, polygonBA.normals[0]);\n for (let i = 1; i < polygonBA.count; ++i) {\n const value = matrix.dotVec2(normal, polygonBA.normals[i]);\n if (value < bestValue) {\n bestValue = value;\n bestIndex = i;\n }\n }\n\n const i1 = bestIndex;\n const i2 = i1 + 1 < polygonBA.count ? i1 + 1 : 0;\n\n matrix.copyVec2(ie[0].v, polygonBA.vertices[i1]);\n ie[0].id.setFeatures(0, ContactFeatureType.e_face, i1, ContactFeatureType.e_vertex);\n\n matrix.copyVec2(ie[1].v, polygonBA.vertices[i2]);\n ie[1].id.setFeatures(0, ContactFeatureType.e_face, i2, ContactFeatureType.e_vertex);\n\n if (front) {\n rf.i1 = 0;\n rf.i2 = 1;\n matrix.copyVec2(rf.v1, v1);\n matrix.copyVec2(rf.v2, v2);\n matrix.copyVec2(rf.normal, normal1);\n } else {\n rf.i1 = 1;\n rf.i2 = 0;\n matrix.copyVec2(rf.v1, v2);\n matrix.copyVec2(rf.v2, v1);\n matrix.scaleVec2(rf.normal, -1, normal1);\n }\n } else {\n manifold.type = ManifoldType.e_faceB;\n\n matrix.copyVec2(ie[0].v, v1);\n ie[0].id.setFeatures(0, ContactFeatureType.e_vertex, primaryAxis.index, ContactFeatureType.e_face);\n\n matrix.copyVec2(ie[1].v, v2);\n ie[1].id.setFeatures(0, ContactFeatureType.e_vertex, primaryAxis.index, ContactFeatureType.e_face);\n\n rf.i1 = primaryAxis.index;\n rf.i2 = rf.i1 + 1 < polygonBA.count ? rf.i1 + 1 : 0;\n matrix.copyVec2(rf.v1, polygonBA.vertices[rf.i1]);\n matrix.copyVec2(rf.v2, polygonBA.vertices[rf.i2]);\n matrix.copyVec2(rf.normal, polygonBA.normals[rf.i1]);\n }\n\n matrix.setVec2(rf.sideNormal1, rf.normal.y, -rf.normal.x);\n matrix.setVec2(rf.sideNormal2, -rf.sideNormal1.x, -rf.sideNormal1.y);\n rf.sideOffset1 = matrix.dotVec2(rf.sideNormal1, rf.v1);\n rf.sideOffset2 = matrix.dotVec2(rf.sideNormal2, rf.v2);\n\n // Clip incident edge against extruded edge1 side edges.\n clipPoints1[0].recycle();\n clipPoints1[1].recycle();\n clipPoints2[0].recycle();\n clipPoints2[1].recycle();\n\n // Clip to box side 1\n const np1 = clipSegmentToLine(clipPoints1, ie, rf.sideNormal1, rf.sideOffset1, rf.i1);\n\n if (np1 < Settings.maxManifoldPoints) {\n return;\n }\n\n // Clip to negative box side 1\n const np2 = clipSegmentToLine(clipPoints2, clipPoints1, rf.sideNormal2, rf.sideOffset2, rf.i2);\n\n if (np2 < Settings.maxManifoldPoints) {\n return;\n }\n\n // Now clipPoints2 contains the clipped points.\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n matrix.copyVec2(manifold.localNormal, rf.normal);\n matrix.copyVec2(manifold.localPoint, rf.v1);\n } else {\n matrix.copyVec2(manifold.localNormal, polygonB.m_normals[rf.i1]);\n matrix.copyVec2(manifold.localPoint, polygonB.m_vertices[rf.i1]);\n }\n\n let pointCount = 0;\n for (let i = 0; i < Settings.maxManifoldPoints; ++i) {\n const separation = matrix.dotVec2(rf.normal, clipPoints2[i].v) - matrix.dotVec2(rf.normal, rf.v1);\n\n if (separation <= radius) {\n const cp = manifold.points[pointCount]; // ManifoldPoint\n\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n matrix.detransformVec2(cp.localPoint, xf, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n } else {\n matrix.copyVec2(cp.localPoint, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n cp.id.swapFeatures();\n }\n\n ++pointCount;\n }\n }\n\n manifold.pointCount = pointCount;\n};\n","import { CollidePolygons } from \"./collision/shape/CollidePolygon\";\nimport { Settings } from \"./Settings\";\nimport { Sweep } from \"./common/Sweep\";\nimport { DynamicTree } from \"./collision/DynamicTree\";\nimport { Manifold } from \"./collision/Manifold\";\nimport { Distance } from \"./collision/Distance\";\nimport { TimeOfImpact } from \"./collision/TimeOfImpact\";\nimport { stats } from \"./util/stats\";\n\n/** @hidden @deprecated Merged with main namespace */\nexport const internal = {\n CollidePolygons,\n Settings,\n Sweep,\n Manifold,\n Distance,\n TimeOfImpact,\n DynamicTree,\n stats\n};\n"],"names":["d","b","__assign","s","n","input","output","x","math_abs","math_sqrt","math_max","math_min","Vec2","v","a","AABB","normal","temp","math_PI","Settings","SettingsInternal","Pool","TreeNode","DynamicTree","c","Iterator","BroadPhase","displacement","math_sin","math_cos","transform","xf","math_atan2","Rot","matrix.vec2","Sweep","matrix.zeroVec2","matrix.transformVec2","matrix.copyVec2","localCenter","matrix.setRotAngle","matrix.combine2Vec2","matrix.minusVec2","matrix.rotVec2","Transform","rotation","Velocity","Position","Shape","FixtureProxy","Fixture","matrix.subVec2","matrix.transform","Body","matrix.plusScaleVec2","matrix.scaleVec2","matrix.dotVec2","matrix.crossNumVec2","matrix.plusVec2","point","JointEdge","Joint","DistanceInput","DistanceOutput","SimplexCache","cache","xfA","xfB","matrix.lengthSqrVec2","matrix.derotVec2","matrix.distVec2","rA","rB","matrix.normalizeVec2","matrix.minusScaleVec2","DistanceProxy","SimplexVertex","Simplex","v1","v2","matrix.setVec2","matrix.crossVec2Vec2","pA","pB","matrix.combine3Vec2","matrix.copyTransform","ShapeCastInput","ShapeCastOutput","simplex","pointA","pointB","TOIInput","TOIOutputState","TOIOutput","SeparationFunctionType","SeparationFunction","matrix.normalizeVec2Length","matrix.crossVec2Num","matrix.negVec2","TimeStep","ContactImpulse","Solver","matrix.mulVec2","Mat22","cA","cB","planePoint","clipPoint","ManifoldType","ContactFeatureType","PointState","ClipVertex","Manifold","ManifoldPoint","ContactID","WorldManifold","ContactEdge","VelocityConstraintPoint","tangent","P","Contact","_a","worldManifold","DEFAULTS","World","oldManifold","Vec3","EdgeShape","e","ChainShape","e1","e2","PolygonShape","ie","center","matrix.detransformVec2","matrix.addVec2","CircleShape","matrix.distSqrVec2","DistanceJoint","vA","vB","FrictionJoint","Mat33","LimitState","RevoluteJoint","PrismaticJoint","translation","perp","GearJoint","MotorJoint","MouseJoint","PulleyJoint","RopeJoint","WeldJoint","WheelJoint","Serializer","options","obj","Testbed","testbed","BoxShape","matrix.retransformVec2","clipPoints1","clipPoints2","normal1","matrix.detransformTransform","maxSeparation","edge1","matrix.rerotVec2","EPAxisType","VertexType","EPAxis","TempPolygon","ReferenceFace","s2"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,MAAI,gBAAgB,SAASA,IAAGC,IAAG;AAC/B,oBAAgB,OAAO,kBAClB,EAAE,WAAW,CAAA,eAAgB,SAAS,SAAUD,IAAGC,IAAG;AAAE,MAAAD,GAAE,YAAYC;AAAA,IAAE,KACzE,SAAUD,IAAGC,IAAG;AAAE,eAAS,KAAKA,GAAG,KAAI,OAAO,UAAU,eAAe,KAAKA,IAAG,CAAC,EAAG,CAAAD,GAAE,CAAC,IAAIC,GAAE,CAAC;AAAA;AACjG,WAAO,cAAcD,IAAGC,EAAC;AAAA,EAC7B;AAEO,WAAS,UAAUD,IAAGC,IAAG;AAC5B,QAAI,OAAOA,OAAM,cAAcA,OAAM;AACjC,YAAM,IAAI,UAAU,yBAAyB,OAAOA,EAAC,IAAI,+BAA+B;AAC5F,kBAAcD,IAAGC,EAAC;AAClB,aAAS,KAAK;AAAE,WAAK,c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node_modules/tslib/tslib.es6.js","../src/util/options.ts","../src/common/Math.ts","../src/common/Vec2.ts","../src/collision/AABB.ts","../src/Settings.ts","../src/util/Pool.ts","../src/collision/DynamicTree.ts","../src/collision/BroadPhase.ts","../src/common/Matrix.ts","../src/common/Rot.ts","../src/common/Sweep.ts","../src/common/Transform.ts","../src/dynamics/Velocity.ts","../src/dynamics/Position.ts","../src/collision/Shape.ts","../src/dynamics/Fixture.ts","../src/dynamics/Body.ts","../src/dynamics/Joint.ts","../src/util/stats.ts","../src/util/Timer.ts","../src/collision/Distance.ts","../src/collision/TimeOfImpact.ts","../src/dynamics/Solver.ts","../src/common/Mat22.ts","../src/collision/Manifold.ts","../src/dynamics/Contact.ts","../src/dynamics/World.ts","../src/common/Vec3.ts","../src/collision/shape/EdgeShape.ts","../src/collision/shape/ChainShape.ts","../src/collision/shape/PolygonShape.ts","../src/collision/shape/CircleShape.ts","../src/dynamics/joint/DistanceJoint.ts","../src/dynamics/joint/FrictionJoint.ts","../src/common/Mat33.ts","../src/dynamics/joint/RevoluteJoint.ts","../src/dynamics/joint/PrismaticJoint.ts","../src/dynamics/joint/GearJoint.ts","../src/dynamics/joint/MotorJoint.ts","../src/dynamics/joint/MouseJoint.ts","../src/dynamics/joint/PulleyJoint.ts","../src/dynamics/joint/RopeJoint.ts","../src/dynamics/joint/WeldJoint.ts","../src/dynamics/joint/WheelJoint.ts","../src/serializer/index.ts","../src/util/Testbed.ts","../src/collision/shape/BoxShape.ts","../src/collision/shape/CollideCircle.ts","../src/collision/shape/CollideEdgeCircle.ts","../src/collision/shape/CollidePolygon.ts","../src/collision/shape/CollideCirclePolygon.ts","../src/collision/shape/CollideEdgePolygon.ts","../src/internal.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from) {\r\n for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)\r\n to[j] = from[i];\r\n return to;\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","/** @internal */\nexport const options = function(input: T, defaults: object): T {\n if (input === null || typeof input === \"undefined\") {\n // tslint:disable-next-line:no-object-literal-type-assertion\n input = {} as T;\n }\n\n const output = {...input};\n\n // tslint:disable-next-line:no-for-in\n for (const key in defaults) {\n if (defaults.hasOwnProperty(key) && typeof input[key] === \"undefined\") {\n output[key] = defaults[key];\n }\n }\n\n if (typeof Object.getOwnPropertySymbols === \"function\") {\n const symbols = Object.getOwnPropertySymbols(defaults);\n for (let i = 0; i < symbols.length; i++) {\n const symbol = symbols[i];\n if (defaults.propertyIsEnumerable(symbol) && typeof input[symbol] === \"undefined\") {\n output[symbol] = defaults[symbol];\n }\n }\n }\n\n return output;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_random = Math.random;\n\n\nexport const EPSILON = 1e-9;\n\n/** @internal @deprecated */\nexport const isFinite = Number.isFinite;\n\n/**\n * @deprecated\n * Next Largest Power of 2 Given a binary integer value x, the next largest\n * power of 2 can be computed by a SWAR algorithm that recursively \"folds\" the\n * upper bits into the lower bits. This process yields a bit vector with the\n * same most significant 1 as x, but all 1's below it. Adding 1 to that value\n * yields the next largest power of 2. For a 32-bit value:\n */\nexport function nextPowerOfTwo(x: number): number {\n x |= (x >> 1);\n x |= (x >> 2);\n x |= (x >> 4);\n x |= (x >> 8);\n x |= (x >> 16);\n return x + 1;\n}\n\n/** @deprecated */\nexport function isPowerOfTwo(x: number): boolean {\n return x > 0 && (x & (x - 1)) === 0;\n}\n\n/** @deprecated */\nexport function mod(num: number, min?: number, max?: number): number {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n if (max > min) {\n num = (num - min) % (max - min);\n return num + (num < 0 ? max : min);\n } else {\n num = (num - max) % (min - max);\n return num + (num <= 0 ? min : max);\n }\n}\n\n/**\n * @deprecated\n * Returns a min if num is less than min, and max if more than max, otherwise returns num.\n */\nexport function clamp(num: number, min: number, max: number): number {\n if (num < min) {\n return min;\n } else if (num > max) {\n return max;\n } else {\n return num;\n }\n}\n\n/**\n * @deprecated\n * Returns a random number between min and max when two arguments are provided.\n * If one arg is provided between 0 to max.\n * If one arg is passed between 0 to 1.\n */\nexport function random(min?: number, max?: number): number {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n return min === max ? min : math_random() * (max - min) + min;\n}\n\n/** @ignore */\nexport const math = Object.create(Math);\nmath.EPSILON = EPSILON;\nmath.isFinite = isFinite;\nmath.nextPowerOfTwo = nextPowerOfTwo;\nmath.isPowerOfTwo = isPowerOfTwo;\nmath.mod = mod;\nmath.clamp = clamp;\nmath.random = random;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { clamp, EPSILON } from \"./Math\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/** 2D vector */\nexport interface Vec2Value {\n x: number;\n y: number;\n}\n\ndeclare module \"./Vec2\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(x: number, y: number): Vec2;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(obj: Vec2Value): Vec2;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(): Vec2;\n}\n\n/** 2D vector */\n// @ts-expect-error\nexport class Vec2 {\n x: number;\n y: number;\n\n constructor(x: number, y: number);\n constructor(obj: Vec2Value);\n constructor();\n // tslint:disable-next-line:typedef\n constructor(x?, y?) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Vec2)) {\n return new Vec2(x, y);\n }\n if (typeof x === \"undefined\") {\n this.x = 0;\n this.y = 0;\n } else if (typeof x === \"object\") {\n this.x = x.x;\n this.y = x.y;\n } else {\n this.x = x;\n this.y = y;\n }\n if (_ASSERT) Vec2.assert(this);\n }\n\n /** @internal */\n _serialize(): object {\n return {\n x: this.x,\n y: this.y\n };\n }\n\n /** @internal */\n static _deserialize(data: any): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = data.x;\n obj.y = data.y;\n return obj;\n }\n\n static zero(): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = 0;\n obj.y = 0;\n return obj;\n }\n\n /** @hidden */\n static neo(x: number, y: number): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = x;\n obj.y = y;\n return obj;\n }\n\n static clone(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(v.x, v.y);\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n /**\n * Does this vector contain finite coordinates?\n */\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.x) && Number.isFinite(obj.y);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Vec2.isValid(o), \"Invalid Vec2!\", o);\n }\n\n clone(): Vec2 {\n return Vec2.clone(this);\n }\n\n /**\n * Set this vector to all zeros.\n *\n * @returns this\n */\n setZero(): Vec2 {\n this.x = 0.0;\n this.y = 0.0;\n return this;\n }\n\n set(x: number, y: number): Vec2;\n set(value: Vec2Value): Vec2;\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n // tslint:disable-next-line:typedef\n set(x, y?) {\n if (typeof x === \"object\") {\n if (_ASSERT) Vec2.assert(x);\n this.x = x.x;\n this.y = x.y;\n } else {\n if (_ASSERT) console.assert(Number.isFinite(x));\n if (_ASSERT) console.assert(Number.isFinite(y));\n this.x = x;\n this.y = y;\n }\n return this;\n }\n\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n setNum(x: number, y: number) {\n if (_ASSERT) console.assert(Number.isFinite(x));\n if (_ASSERT) console.assert(Number.isFinite(y));\n this.x = x;\n this.y = y;\n\n return this;\n }\n\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n setVec2(value: Vec2Value) {\n if (_ASSERT) Vec2.assert(value);\n this.x = value.x;\n this.y = value.y;\n\n return this;\n }\n\n /** @internal @deprecated Use setCombine or setMul */\n wSet(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.setCombine(a, v, b, w);\n } else {\n return this.setMul(a, v);\n }\n }\n\n /**\n * Set linear combination of v and w: `a * v + b * w`\n */\n setCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x = x;\n this.y = y;\n return this;\n }\n\n setMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x = x;\n this.y = y;\n return this;\n }\n\n /**\n * Add a vector to this vector.\n *\n * @returns this\n */\n add(w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(w);\n this.x += w.x;\n this.y += w.y;\n return this;\n }\n\n /** @internal @deprecated Use addCombine or addMul */\n wAdd(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.addCombine(a, v, b, w);\n } else {\n return this.addMul(a, v);\n }\n }\n\n /**\n * Add linear combination of v and w: `a * v + b * w`\n */\n addCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x += x;\n this.y += y;\n return this;\n }\n\n addMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x += x;\n this.y += y;\n return this;\n }\n\n /**\n * @deprecated Use subCombine or subMul\n */\n wSub(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.subCombine(a, v, b, w);\n } else {\n return this.subMul(a, v);\n }}\n\n /**\n * Subtract linear combination of v and w: `a * v + b * w`\n */\n subCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x -= x;\n this.y -= y;\n return this;\n }\n\n subMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x -= x;\n this.y -= y;\n return this;\n }\n\n /**\n * Subtract a vector from this vector\n *\n * @returns this\n */\n sub(w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(w);\n this.x -= w.x;\n this.y -= w.y;\n return this;\n }\n\n /**\n * Multiply this vector by a scalar.\n *\n * @returns this\n */\n mul(m: number): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(m));\n this.x *= m;\n this.y *= m;\n return this;\n }\n\n /**\n * Get the length of this vector (the norm).\n *\n * For performance, use this instead of lengthSquared (if possible).\n */\n length(): number {\n return Vec2.lengthOf(this);\n }\n\n /**\n * Get the length squared.\n */\n lengthSquared(): number {\n return Vec2.lengthSquared(this);\n }\n\n /**\n * Convert this vector into a unit vector.\n *\n * @returns old length\n */\n normalize(): number {\n const length = this.length();\n if (length < EPSILON) {\n return 0.0;\n }\n const invLength = 1.0 / length;\n this.x *= invLength;\n this.y *= invLength;\n return length;\n }\n\n /**\n * Returns a new unit vector from the provided vector.\n *\n * @returns new unit vector\n */\n static normalize(v: Vec2Value): Vec2 {\n const length = Vec2.lengthOf(v);\n if (length < EPSILON) {\n return Vec2.zero();\n }\n const invLength = 1.0 / length;\n return Vec2.neo(v.x * invLength, v.y * invLength);\n }\n\n /**\n * Get the length of this vector (the norm).\n *\n * For performance, use this instead of lengthSquared (if possible).\n */\n static lengthOf(v: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n return math_sqrt(v.x * v.x + v.y * v.y);\n }\n\n /**\n * Get the length squared.\n */\n static lengthSquared(v: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n return v.x * v.x + v.y * v.y;\n }\n\n static distance(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n const dx = v.x - w.x;\n const dy = v.y - w.y;\n return math_sqrt(dx * dx + dy * dy);\n }\n\n static distanceSquared(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n const dx = v.x - w.x;\n const dy = v.y - w.y;\n return dx * dx + dy * dy;\n }\n\n static areEqual(v: Vec2Value, w: Vec2Value): boolean {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v === w || typeof w === \"object\" && w !== null && v.x === w.x && v.y === w.y;\n }\n\n /**\n * Get the skew vector such that dot(skew_vec, other) == cross(vec, other)\n */\n static skew(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(-v.y, v.x);\n }\n\n /** Dot product on two vectors */\n static dot(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.x + v.y * w.y;\n }\n\n /** Cross product between two vectors */\n static cross(v: Vec2Value, w: Vec2Value): number;\n /** Cross product between a vector and a scalar */\n static cross(v: Vec2Value, w: number): Vec2;\n /** Cross product between a scalar and a vector */\n static cross(v: number, w: Vec2Value): Vec2;\n static cross(v: any, w: any): any {\n if (typeof w === \"number\") {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y, -w * v.x);\n\n } else if (typeof v === \"number\") {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y, v * w.x);\n\n } else {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.y - v.y * w.x;\n }\n }\n\n /** Cross product on two vectors */\n static crossVec2Vec2(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.y - v.y * w.x;\n }\n\n /** Cross product on a vector and a scalar */\n static crossVec2Num(v: Vec2Value, w: number): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y, -w * v.x);\n }\n\n /** Cross product on a vector and a scalar */\n static crossNumVec2(v: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y, v * w.x);\n }\n\n /** Returns `a + (v x w)` */\n static addCross(a: Vec2Value, v: Vec2Value, w: number): Vec2;\n /** Returns `a + (v x w)` */\n static addCross(a: Vec2Value, v: number, w: Vec2Value): Vec2;\n static addCross(a: Vec2Value, v: any, w: any): Vec2 {\n if (typeof w === \"number\") {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y + a.x, -w * v.x + a.y);\n\n } else if (typeof v === \"number\") {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y + a.x, v * w.x + a.y);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n /**\n * Returns `a + (v x w)`\n */\n static addCrossVec2Num(a: Vec2Value, v: Vec2Value, w: number): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y + a.x, -w * v.x + a.y);\n }\n\n /**\n * Returns `a + (v x w)`\n */\n static addCrossNumVec2(a: Vec2Value, v: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y + a.x, v * w.x + a.y);\n }\n\n static add(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(v.x + w.x, v.y + w.y);\n }\n\n /** @hidden @deprecated */\n static wAdd(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return Vec2.combine(a, v, b, w);\n } else {\n return Vec2.mulNumVec2(a, v);\n }\n }\n\n static combine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n return Vec2.zero().setCombine(a, v, b, w);\n }\n\n static sub(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(v.x - w.x, v.y - w.y);\n }\n\n static mul(a: Vec2Value, b: number): Vec2;\n static mul(a: number, b: Vec2Value): Vec2;\n static mul(a: any, b: any): Vec2 {\n if (typeof a === \"object\") {\n if (_ASSERT) Vec2.assert(a);\n if (_ASSERT) console.assert(Number.isFinite(b));\n return Vec2.neo(a.x * b, a.y * b);\n\n } else if (typeof b === \"object\") {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(b);\n return Vec2.neo(a * b.x, a * b.y);\n }\n }\n\n static mulVec2Num(a: Vec2Value, b: number): Vec2 {\n if (_ASSERT) Vec2.assert(a);\n if (_ASSERT) console.assert(Number.isFinite(b));\n return Vec2.neo(a.x * b, a.y * b);\n }\n\n static mulNumVec2(a: number, b: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(b);\n return Vec2.neo(a * b.x, a * b.y);\n }\n\n neg(): Vec2 {\n this.x = -this.x;\n this.y = -this.y;\n return this;\n }\n\n static neg(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(-v.x, -v.y);\n }\n\n static abs(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(math_abs(v.x), math_abs(v.y));\n }\n\n static mid(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo((v.x + w.x) * 0.5, (v.y + w.y) * 0.5);\n }\n\n static upper(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(math_max(v.x, w.x), math_max(v.y, w.y));\n }\n\n static lower(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(math_min(v.x, w.x), math_min(v.y, w.y));\n }\n\n clamp(max: number): Vec2 {\n const lengthSqr = this.x * this.x + this.y * this.y;\n if (lengthSqr > max * max) {\n const scale = max / math_sqrt(lengthSqr);\n this.x *= scale;\n this.y *= scale;\n }\n return this;\n }\n\n static clamp(v: Vec2Value, max: number): Vec2 {\n const r = Vec2.neo(v.x, v.y);\n r.clamp(max);\n return r;\n }\n\n /** @hidden */\n static clampVec2(v: Vec2Value, min?: Vec2Value, max?: Vec2Value): Vec2Value {\n return {\n x: clamp(v.x, min?.x, max?.x),\n y: clamp(v.y, min?.y, max?.y)\n };\n }\n\n /** @hidden @deprecated */\n static scaleFn(x: number, y: number) {\n // todo: this was used in examples, remove in the future\n return function(v: Vec2Value): Vec2 {\n return Vec2.neo(v.x * x, v.y * y);\n };\n }\n\n /** @hidden @deprecated */\n static translateFn(x: number, y: number) {\n // todo: this was used in examples, remove in the future\n return function(v: Vec2Value): Vec2 {\n return Vec2.neo(v.x + x, v.y + y);\n };\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { EPSILON } from \"../common/Math\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n/**\n * Ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n */\nexport interface RayCastInput {\n p1: Vec2Value;\n p2: Vec2Value;\n maxFraction: number;\n}\n\nexport type RayCastCallback = (subInput: RayCastInput, id: number) => number;\n\n/**\n * Ray-cast output data. The ray hits at `p1 + fraction * (p2 - p1)`,\n * where `p1` and `p2` come from RayCastInput.\n */\nexport interface RayCastOutput {\n normal: Vec2;\n fraction: number;\n}\n\n/** Axis-aligned bounding box */\nexport interface AABBValue {\n lowerBound: Vec2Value;\n upperBound: Vec2Value;\n}\n\ndeclare module \"./AABB\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function AABB(lower?: Vec2Value, upper?: Vec2Value): AABB;\n}\n\n/** Axis-aligned bounding box */\n// @ts-expect-error\nexport class AABB {\n lowerBound: Vec2;\n upperBound: Vec2;\n\n constructor(lower?: Vec2Value, upper?: Vec2Value) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof AABB)) {\n return new AABB(lower, upper);\n }\n\n this.lowerBound = Vec2.zero();\n this.upperBound = Vec2.zero();\n\n if (typeof lower === \"object\") {\n this.lowerBound.setVec2(lower);\n }\n if (typeof upper === \"object\") {\n this.upperBound.setVec2(upper);\n } else if (typeof lower === \"object\") {\n this.upperBound.setVec2(lower);\n }\n }\n\n /**\n * Verify that the bounds are sorted.\n */\n isValid(): boolean {\n return AABB.isValid(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.lowerBound) && Vec2.isValid(obj.upperBound) && Vec2.sub(obj.upperBound, obj.lowerBound).lengthSquared() >= 0;\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!AABB.isValid(o), \"Invalid AABB!\", o);\n }\n\n /**\n * Get the center of the AABB.\n */\n getCenter(): Vec2 {\n return Vec2.neo((this.lowerBound.x + this.upperBound.x) * 0.5, (this.lowerBound.y + this.upperBound.y) * 0.5);\n }\n\n /**\n * Get the extents of the AABB (half-widths).\n */\n getExtents(): Vec2 {\n return Vec2.neo((this.upperBound.x - this.lowerBound.x) * 0.5, (this.upperBound.y - this.lowerBound.y) * 0.5);\n }\n\n /**\n * Get the perimeter length.\n */\n getPerimeter(): number {\n return 2.0 * (this.upperBound.x - this.lowerBound.x + this.upperBound.y - this.lowerBound.y);\n }\n\n /**\n * Combine one or two AABB into this one.\n */\n combine(a: AABBValue, b?: AABBValue): void {\n b = b || this;\n\n const lowerA = a.lowerBound;\n const upperA = a.upperBound;\n const lowerB = b.lowerBound;\n const upperB = b.upperBound;\n\n const lowerX = math_min(lowerA.x, lowerB.x);\n const lowerY = math_min(lowerA.y, lowerB.y);\n const upperX = math_max(upperB.x, upperA.x);\n const upperY = math_max(upperB.y, upperA.y);\n\n this.lowerBound.setNum(lowerX, lowerY);\n this.upperBound.setNum(upperX, upperY);\n }\n\n combinePoints(a: Vec2Value, b: Vec2Value): void {\n this.lowerBound.setNum(math_min(a.x, b.x), math_min(a.y, b.y));\n this.upperBound.setNum(math_max(a.x, b.x), math_max(a.y, b.y));\n }\n\n set(aabb: AABBValue): void {\n this.lowerBound.setNum(aabb.lowerBound.x, aabb.lowerBound.y);\n this.upperBound.setNum(aabb.upperBound.x, aabb.upperBound.y);\n }\n\n contains(aabb: AABBValue): boolean {\n let result = true;\n result = result && this.lowerBound.x <= aabb.lowerBound.x;\n result = result && this.lowerBound.y <= aabb.lowerBound.y;\n result = result && aabb.upperBound.x <= this.upperBound.x;\n result = result && aabb.upperBound.y <= this.upperBound.y;\n return result;\n }\n\n extend(value: number): AABB {\n AABB.extend(this, value);\n return this;\n }\n\n static extend(out: AABBValue, value: number): AABBValue {\n out.lowerBound.x -= value;\n out.lowerBound.y -= value;\n out.upperBound.x += value;\n out.upperBound.y += value;\n return out;\n }\n\n static testOverlap(a: AABBValue, b: AABBValue): boolean {\n const d1x = b.lowerBound.x - a.upperBound.x;\n const d2x = a.lowerBound.x - b.upperBound.x;\n\n const d1y = b.lowerBound.y - a.upperBound.y;\n const d2y = a.lowerBound.y - b.upperBound.y;\n\n if (d1x > 0 || d1y > 0 || d2x > 0 || d2y > 0) {\n return false;\n }\n return true;\n }\n\n static areEqual(a: AABBValue, b: AABBValue): boolean {\n return Vec2.areEqual(a.lowerBound, b.lowerBound) && Vec2.areEqual(a.upperBound, b.upperBound);\n }\n\n static diff(a: AABBValue, b: AABBValue): number {\n const wD = math_max(0, math_min(a.upperBound.x, b.upperBound.x) - math_max(b.lowerBound.x, a.lowerBound.x));\n const hD = math_max(0, math_min(a.upperBound.y, b.upperBound.y) - math_max(b.lowerBound.y, a.lowerBound.y));\n\n const wA = a.upperBound.x - a.lowerBound.x;\n const hA = a.upperBound.y - a.lowerBound.y;\n\n const wB = b.upperBound.x - b.lowerBound.x;\n const hB = b.upperBound.y - b.lowerBound.y;\n\n return wA * hA + wB * hB - wD * hD;\n }\n\n rayCast(output: RayCastOutput, input: RayCastInput): boolean {\n // From Real-time Collision Detection, p179.\n\n let tmin = -Infinity;\n let tmax = Infinity;\n\n const p = input.p1;\n const d = Vec2.sub(input.p2, input.p1);\n const absD = Vec2.abs(d);\n\n const normal = Vec2.zero();\n\n for (let f: \"x\" | \"y\" = \"x\"; f !== null; f = (f === \"x\" ? \"y\" : null)) {\n if (absD.x < EPSILON) {\n // Parallel.\n if (p[f] < this.lowerBound[f] || this.upperBound[f] < p[f]) {\n return false;\n }\n } else {\n const inv_d = 1.0 / d[f];\n let t1 = (this.lowerBound[f] - p[f]) * inv_d;\n let t2 = (this.upperBound[f] - p[f]) * inv_d;\n\n // Sign of the normal vector.\n let s = -1.0;\n\n if (t1 > t2) {\n const temp = t1;\n t1 = t2;\n t2 = temp;\n s = 1.0;\n }\n\n // Push the min up\n if (t1 > tmin) {\n normal.setZero();\n normal[f] = s;\n tmin = t1;\n }\n\n // Pull the max down\n tmax = math_min(tmax, t2);\n\n if (tmin > tmax) {\n return false;\n }\n }\n }\n\n // Does the ray start inside the box?\n // Does the ray intersect beyond the max fraction?\n if (tmin < 0.0 || input.maxFraction < tmin) {\n return false;\n }\n\n // Intersection.\n output.fraction = tmin;\n output.normal = normal;\n return true;\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static combinePoints(out: AABBValue, a: Vec2Value, b: Vec2Value): AABBValue {\n out.lowerBound.x = math_min(a.x, b.x);\n out.lowerBound.y = math_min(a.y, b.y);\n out.upperBound.x = math_max(a.x, b.x);\n out.upperBound.y = math_max(a.y, b.y);\n return out;\n }\n\n static combinedPerimeter(a: AABBValue, b: AABBValue) {\n const lx = math_min(a.lowerBound.x, b.lowerBound.x);\n const ly = math_min(a.lowerBound.y, b.lowerBound.y);\n const ux = math_max(a.upperBound.x, b.upperBound.x);\n const uy = math_max(a.upperBound.y, b.upperBound.y);\n return 2.0 * (ux - lx + uy - ly); \n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Tuning constants based on meters-kilograms-seconds (MKS) units.\n * \n * Some tolerances are absolute and some are relative. Absolute tolerances use MKS units.\n */\nexport class Settings {\n /**\n * You can use this to change the length scale used by your game.\n * \n * For example for inches you could use 39.4.\n */\n static lengthUnitsPerMeter = 1.0;\n \n // Collision\n /**\n * The maximum number of contact points between two convex shapes. Do not change\n * this value.\n */\n static maxManifoldPoints: number = 2;\n\n /**\n * The maximum number of vertices on a convex polygon. You cannot increase this\n * too much because BlockAllocator has a maximum object size.\n */\n static maxPolygonVertices: number = 12;\n\n /**\n * This is used to fatten AABBs in the dynamic tree. This allows proxies to move\n * by a small amount without triggering a tree adjustment. This is in meters.\n */\n static aabbExtension: number = 0.1;\n\n /**\n * This is used to fatten AABBs in the dynamic tree. This is used to predict the\n * future position based on the current displacement. This is a dimensionless\n * multiplier.\n */\n static aabbMultiplier: number = 2.0;\n\n /**\n * A small length used as a collision and constraint tolerance. Usually it is\n * chosen to be numerically significant, but visually insignificant.\n */\n static linearSlop: number = 0.005;\n\n /**\n * A small angle used as a collision and constraint tolerance. Usually it is\n * chosen to be numerically significant, but visually insignificant.\n */\n static angularSlop: number = (2.0 / 180.0 * math_PI);\n\n /**\n * The radius of the polygon/edge shape skin. This should not be modified.\n * Making this smaller means polygons will have an insufficient buffer for\n * continuous collision. Making it larger may create artifacts for vertex\n * collision.\n */\n static get polygonRadius(): number { return 2.0 * Settings.linearSlop; }\n\n /**\n * Maximum number of sub-steps per contact in continuous physics simulation.\n */\n static maxSubSteps: number = 8;\n\n // Dynamics\n\n /**\n * Maximum number of contacts to be handled to solve a TOI impact.\n */\n static maxTOIContacts: number = 32;\n\n /**\n * Maximum iterations to solve a TOI.\n */\n static maxTOIIterations: number = 20;\n\n /**\n * Maximum iterations to find Distance.\n */\n static maxDistanceIterations: number = 20;\n\n /**\n * A velocity threshold for elastic collisions. Any collision with a relative\n * linear velocity below this threshold will be treated as inelastic.\n */\n static velocityThreshold: number = 1.0;\n\n /**\n * The maximum linear position correction used when solving constraints. This\n * helps to prevent overshoot.\n */\n static maxLinearCorrection: number = 0.2;\n\n /**\n * The maximum angular position correction used when solving constraints. This\n * helps to prevent overshoot.\n */\n static maxAngularCorrection: number = (8.0 / 180.0 * math_PI);\n\n /**\n * The maximum linear velocity of a body. This limit is very large and is used\n * to prevent numerical problems. You shouldn't need to adjust Settings.\n */\n static maxTranslation: number = 2.0;\n\n /**\n * The maximum angular velocity of a body. This limit is very large and is used\n * to prevent numerical problems. You shouldn't need to adjust Settings.\n */\n static maxRotation: number = (0.5 * math_PI);\n\n /**\n * This scale factor controls how fast overlap is resolved. Ideally this would\n * be 1 so that overlap is removed in one time step. However using values close\n * to 1 often lead to overshoot.\n */\n static baumgarte: number = 0.2;\n static toiBaugarte: number = 0.75;\n\n // Sleep\n\n /**\n * The time that a body must be still before it will go to sleep.\n */\n static timeToSleep: number = 0.5;\n\n /**\n * A body cannot sleep if its linear velocity is above this tolerance.\n */\n static linearSleepTolerance: number = 0.01;\n\n /**\n * A body cannot sleep if its angular velocity is above this tolerance.\n */\n static angularSleepTolerance: number = (2.0 / 180.0 * math_PI);\n}\n\n/** @internal */\nexport class SettingsInternal {\n static get maxManifoldPoints() {\n return Settings.maxManifoldPoints;\n }\n static get maxPolygonVertices() {\n return Settings.maxPolygonVertices;\n }\n static get aabbExtension() {\n return Settings.aabbExtension * Settings.lengthUnitsPerMeter;\n }\n static get aabbMultiplier() {\n return Settings.aabbMultiplier;\n }\n static get linearSlop() {\n return Settings.linearSlop * Settings.lengthUnitsPerMeter;\n }\n static get linearSlopSquared() {\n return Settings.linearSlop * Settings.lengthUnitsPerMeter * Settings.linearSlop * Settings.lengthUnitsPerMeter;\n }\n static get angularSlop() {\n return Settings.angularSlop;\n }\n static get polygonRadius() {\n return 2.0 * Settings.linearSlop;\n }\n static get maxSubSteps() {\n return Settings.maxSubSteps;\n }\n static get maxTOIContacts() {\n return Settings.maxTOIContacts;\n }\n static get maxTOIIterations() {\n return Settings.maxTOIIterations;\n }\n static get maxDistanceIterations() {\n return Settings.maxDistanceIterations;\n }\n static get velocityThreshold() {\n return Settings.velocityThreshold * Settings.lengthUnitsPerMeter;\n }\n static get maxLinearCorrection() {\n return Settings.maxLinearCorrection * Settings.lengthUnitsPerMeter;\n }\n static get maxAngularCorrection() {\n return Settings.maxAngularCorrection;\n }\n static get maxTranslation() {\n return Settings.maxTranslation * Settings.lengthUnitsPerMeter;\n }\n static get maxTranslationSquared() {\n return Settings.maxTranslation * Settings.lengthUnitsPerMeter * Settings.maxTranslation * Settings.lengthUnitsPerMeter;\n }\n static get maxRotation() {\n return Settings.maxRotation;\n }\n static get maxRotationSquared() {\n return Settings.maxRotation * Settings.maxRotation;\n }\n static get baumgarte() {\n return Settings.baumgarte;\n }\n static get toiBaugarte() {\n return Settings.toiBaugarte;\n }\n static get timeToSleep() {\n return Settings.timeToSleep;\n }\n static get linearSleepTolerance() {\n return Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter;\n }\n static get linearSleepToleranceSqr() {\n return Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter * Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter;\n }\n static get angularSleepTolerance() {\n return Settings.angularSleepTolerance;\n }\n static get angularSleepToleranceSqr() {\n return Settings.angularSleepTolerance * Settings.angularSleepTolerance;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */\nexport interface PoolOptions {\n max?: number,\n create?: () => T,\n /** Called when an object is being re-allocated. */\n allocate?: (item: T) => void,\n /** Called when an object is returned to pool. */\n release?: (item: T) => void,\n /** Called when an object is returned to the pool but will be disposed from pool. */\n dispose?: (item: T) => T,\n}\n\n/** @internal */\nexport class Pool {\n _list: T[] = [];\n _max: number = Infinity;\n\n _createFn: () => T;\n _hasCreateFn: boolean = false;\n _createCount: number = 0;\n\n _allocateFn: (item: T) => void;\n _hasAllocateFn: boolean = false;\n _allocateCount: number = 0;\n\n _releaseFn: (item: T) => void;\n _hasReleaseFn: boolean = false;\n _releaseCount: number = 0;\n\n _disposeFn: (item: T) => T;\n _hasDisposeFn: boolean = false;\n _disposeCount: number = 0;\n\n constructor(opts: PoolOptions) {\n this._list = [];\n this._max = opts.max || this._max;\n\n this._createFn = opts.create;\n this._hasCreateFn = typeof this._createFn === \"function\";\n this._allocateFn = opts.allocate;\n this._hasAllocateFn = typeof this._allocateFn === \"function\";\n this._releaseFn = opts.release;\n this._hasReleaseFn = typeof this._releaseFn === \"function\";\n this._disposeFn = opts.dispose;\n this._hasDisposeFn = typeof this._disposeFn === \"function\";\n }\n\n max(n?: number): number | Pool {\n if (typeof n === \"number\") {\n this._max = n;\n return this;\n }\n return this._max;\n }\n\n size(): number {\n return this._list.length;\n }\n\n allocate(): T {\n let item: T;\n if (this._list.length > 0) {\n item = this._list.shift();\n } else {\n this._createCount++;\n if (this._hasCreateFn) {\n item = this._createFn();\n } else {\n // tslint:disable-next-line:no-object-literal-type-assertion\n item = {} as T;\n }\n }\n this._allocateCount++;\n if (this._hasAllocateFn) {\n this._allocateFn(item);\n }\n return item;\n }\n\n release(item: T): void {\n if (this._list.length < this._max) {\n this._releaseCount++;\n if (this._hasReleaseFn) {\n this._releaseFn(item);\n }\n this._list.push(item);\n } else {\n this._disposeCount++;\n if (this._hasDisposeFn) {\n item = this._disposeFn(item);\n }\n }\n }\n\n toString(): string {\n return \" +\" + this._createCount + \" >\" + this._allocateCount + \" <\" + this._releaseCount + \" -\"\n + this._disposeCount + \" =\" + this._list.length + \"/\" + this._max;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { Pool } from \"../util/Pool\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { AABB, AABBValue, RayCastCallback, RayCastInput } from \"./AABB\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n\n\nexport type DynamicTreeQueryCallback = (nodeId: number) => boolean;\n\n/**\n * A node in the dynamic tree. The client does not interact with this directly.\n */\nexport class TreeNode {\n id: number;\n /** Enlarged AABB */\n aabb: AABB = new AABB();\n userData: T = null;\n parent: TreeNode = null;\n child1: TreeNode = null;\n child2: TreeNode = null;\n /** 0: leaf, -1: free node */\n height: number = -1;\n\n constructor(id?: number) {\n this.id = id;\n }\n\n /** @internal */\n toString(): string {\n return this.id + \": \" + this.userData;\n }\n\n isLeaf(): boolean {\n return this.child1 == null;\n }\n}\n\n/** @internal */ const poolTreeNode = new Pool>({\n create(): TreeNode {\n return new TreeNode();\n },\n release(node: TreeNode) {\n node.userData = null;\n node.parent = null;\n node.child1 = null;\n node.child2 = null;\n node.height = -1;\n node.id = undefined;\n }\n});\n\n/**\n * A dynamic AABB tree broad-phase, inspired by Nathanael Presson's btDbvt. A\n * dynamic tree arranges data in a binary tree to accelerate queries such as\n * volume queries and ray casts. Leafs are proxies with an AABB. In the tree we\n * expand the proxy AABB by `aabbExtension` so that the proxy AABB is bigger\n * than the client object. This allows the client object to move by small\n * amounts without triggering a tree update.\n *\n * Nodes are pooled and relocatable, so we use node indices rather than\n * pointers.\n */\nexport class DynamicTree {\n m_root: TreeNode;\n m_lastProxyId: number;\n m_nodes: {\n [id: number]: TreeNode\n };\n\n constructor() {\n this.m_root = null;\n this.m_nodes = {};\n this.m_lastProxyId = 0;\n }\n\n /**\n * Get proxy user data.\n *\n * @return the proxy user data or 0 if the id is invalid.\n */\n getUserData(id: number): T {\n const node = this.m_nodes[id];\n if (_ASSERT) console.assert(!!node);\n return node.userData;\n }\n\n /**\n * Get the fat AABB for a node id.\n *\n * @return the proxy user data or 0 if the id is invalid.\n */\n getFatAABB(id: number): AABB {\n const node = this.m_nodes[id];\n if (_ASSERT) console.assert(!!node);\n return node.aabb;\n }\n\n allocateNode(): TreeNode {\n const node = poolTreeNode.allocate();\n node.id = ++this.m_lastProxyId;\n this.m_nodes[node.id] = node;\n return node;\n }\n\n freeNode(node: TreeNode): void {\n // tslint:disable-next-line:no-dynamic-delete\n delete this.m_nodes[node.id];\n poolTreeNode.release(node);\n }\n\n /**\n * Create a proxy in the tree as a leaf node. We return the index of the node\n * instead of a pointer so that we can grow the node pool.\n *\n * Create a proxy. Provide a tight fitting AABB and a userData pointer.\n */\n createProxy(aabb: AABBValue, userData: T): number {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n\n const node = this.allocateNode();\n\n node.aabb.set(aabb);\n\n // Fatten the aabb.\n AABB.extend(node.aabb, Settings.aabbExtension);\n\n node.userData = userData;\n node.height = 0;\n\n this.insertLeaf(node);\n\n return node.id;\n }\n\n /**\n * Destroy a proxy. This asserts if the id is invalid.\n */\n destroyProxy(id: number): void {\n const node = this.m_nodes[id];\n\n if (_ASSERT) console.assert(!!node);\n if (_ASSERT) console.assert(node.isLeaf());\n\n this.removeLeaf(node);\n this.freeNode(node);\n }\n\n /**\n * Move a proxy with a swepted AABB. If the proxy has moved outside of its\n * fattened AABB, then the proxy is removed from the tree and re-inserted.\n * Otherwise the function returns immediately.\n *\n * @param d Displacement\n *\n * @return true if the proxy was re-inserted.\n */\n moveProxy(id: number, aabb: AABBValue, d: Vec2Value): boolean {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n if (_ASSERT) console.assert(!d || Vec2.isValid(d));\n\n const node = this.m_nodes[id];\n\n if (_ASSERT) console.assert(!!node);\n if (_ASSERT) console.assert(node.isLeaf());\n\n if (node.aabb.contains(aabb)) {\n return false;\n }\n\n this.removeLeaf(node);\n\n node.aabb.set(aabb);\n\n // Extend AABB.\n aabb = node.aabb;\n AABB.extend(aabb, Settings.aabbExtension);\n\n // Predict AABB displacement.\n // const d = Vec2.mul(Settings.aabbMultiplier, displacement);\n\n if (d.x < 0.0) {\n aabb.lowerBound.x += d.x * Settings.aabbMultiplier;\n } else {\n aabb.upperBound.x += d.x * Settings.aabbMultiplier;\n }\n\n if (d.y < 0.0) {\n aabb.lowerBound.y += d.y * Settings.aabbMultiplier;\n } else {\n aabb.upperBound.y += d.y * Settings.aabbMultiplier;\n }\n\n this.insertLeaf(node);\n\n return true;\n }\n\n insertLeaf(leaf: TreeNode): void {\n if (_ASSERT) console.assert(AABB.isValid(leaf.aabb));\n\n if (this.m_root == null) {\n this.m_root = leaf;\n this.m_root.parent = null;\n return;\n }\n\n // Find the best sibling for this node\n const leafAABB = leaf.aabb;\n let index = this.m_root;\n while (!index.isLeaf()) {\n const child1 = index.child1;\n const child2 = index.child2;\n\n const area = index.aabb.getPerimeter();\n\n const combinedArea = AABB.combinedPerimeter(index.aabb, leafAABB);\n\n // Cost of creating a new parent for this node and the new leaf\n const cost = 2.0 * combinedArea;\n\n // Minimum cost of pushing the leaf further down the tree\n const inheritanceCost = 2.0 * (combinedArea - area);\n\n // Cost of descending into child1\n const newArea1 = AABB.combinedPerimeter(leafAABB, child1.aabb);\n let cost1 = newArea1 + inheritanceCost;\n if (!child1.isLeaf()) {\n const oldArea = child1.aabb.getPerimeter();\n cost1 -= oldArea;\n }\n\n // Cost of descending into child2\n const newArea2 = AABB.combinedPerimeter(leafAABB, child2.aabb);\n let cost2 = newArea2 + inheritanceCost;\n if (!child2.isLeaf()) {\n const oldArea = child2.aabb.getPerimeter();\n cost2 -= oldArea;\n }\n\n // Descend according to the minimum cost.\n if (cost < cost1 && cost < cost2) {\n break;\n }\n\n // Descend\n if (cost1 < cost2) {\n index = child1;\n } else {\n index = child2;\n }\n }\n\n const sibling = index;\n\n // Create a new parent.\n const oldParent = sibling.parent;\n const newParent = this.allocateNode();\n newParent.parent = oldParent;\n newParent.userData = null;\n newParent.aabb.combine(leafAABB, sibling.aabb);\n newParent.height = sibling.height + 1;\n\n if (oldParent != null) {\n // The sibling was not the root.\n if (oldParent.child1 === sibling) {\n oldParent.child1 = newParent;\n } else {\n oldParent.child2 = newParent;\n }\n\n newParent.child1 = sibling;\n newParent.child2 = leaf;\n sibling.parent = newParent;\n leaf.parent = newParent;\n } else {\n // The sibling was the root.\n newParent.child1 = sibling;\n newParent.child2 = leaf;\n sibling.parent = newParent;\n leaf.parent = newParent;\n this.m_root = newParent;\n }\n\n // Walk back up the tree fixing heights and AABBs\n index = leaf.parent;\n while (index != null) {\n index = this.balance(index);\n\n const child1 = index.child1;\n const child2 = index.child2;\n\n if (_ASSERT) console.assert(child1 != null);\n if (_ASSERT) console.assert(child2 != null);\n\n index.height = 1 + math_max(child1.height, child2.height);\n index.aabb.combine(child1.aabb, child2.aabb);\n\n index = index.parent;\n }\n\n // validate();\n }\n\n removeLeaf(leaf: TreeNode): void {\n if (leaf === this.m_root) {\n this.m_root = null;\n return;\n }\n\n const parent = leaf.parent;\n const grandParent = parent.parent;\n let sibling;\n if (parent.child1 === leaf) {\n sibling = parent.child2;\n } else {\n sibling = parent.child1;\n }\n\n if (grandParent != null) {\n // Destroy parent and connect sibling to grandParent.\n if (grandParent.child1 === parent) {\n grandParent.child1 = sibling;\n } else {\n grandParent.child2 = sibling;\n }\n sibling.parent = grandParent;\n this.freeNode(parent);\n\n // Adjust ancestor bounds.\n let index = grandParent;\n while (index != null) {\n index = this.balance(index);\n\n const child1 = index.child1;\n const child2 = index.child2;\n\n index.aabb.combine(child1.aabb, child2.aabb);\n index.height = 1 + math_max(child1.height, child2.height);\n\n index = index.parent;\n }\n } else {\n this.m_root = sibling;\n sibling.parent = null;\n this.freeNode(parent);\n }\n\n // validate();\n }\n\n /**\n * Perform a left or right rotation if node A is imbalanced. Returns the new\n * root index.\n */\n balance(iA: TreeNode): TreeNode {\n if (_ASSERT) console.assert(iA != null);\n\n const A = iA;\n if (A.isLeaf() || A.height < 2) {\n return iA;\n }\n\n const B = A.child1;\n const C = A.child2;\n\n const balance = C.height - B.height;\n\n // Rotate C up\n if (balance > 1) {\n const F = C.child1;\n const G = C.child2;\n\n // Swap A and C\n C.child1 = A;\n C.parent = A.parent;\n A.parent = C;\n\n // A's old parent should point to C\n if (C.parent != null) {\n if (C.parent.child1 === iA) {\n C.parent.child1 = C;\n } else {\n C.parent.child2 = C;\n }\n } else {\n this.m_root = C;\n }\n\n // Rotate\n if (F.height > G.height) {\n C.child2 = F;\n A.child2 = G;\n G.parent = A;\n A.aabb.combine(B.aabb, G.aabb);\n C.aabb.combine(A.aabb, F.aabb);\n\n A.height = 1 + math_max(B.height, G.height);\n C.height = 1 + math_max(A.height, F.height);\n } else {\n C.child2 = G;\n A.child2 = F;\n F.parent = A;\n A.aabb.combine(B.aabb, F.aabb);\n C.aabb.combine(A.aabb, G.aabb);\n\n A.height = 1 + math_max(B.height, F.height);\n C.height = 1 + math_max(A.height, G.height);\n }\n\n return C;\n }\n\n // Rotate B up\n if (balance < -1) {\n const D = B.child1;\n const E = B.child2;\n\n // Swap A and B\n B.child1 = A;\n B.parent = A.parent;\n A.parent = B;\n\n // A's old parent should point to B\n if (B.parent != null) {\n if (B.parent.child1 === A) {\n B.parent.child1 = B;\n } else {\n B.parent.child2 = B;\n }\n } else {\n this.m_root = B;\n }\n\n // Rotate\n if (D.height > E.height) {\n B.child2 = D;\n A.child1 = E;\n E.parent = A;\n A.aabb.combine(C.aabb, E.aabb);\n B.aabb.combine(A.aabb, D.aabb);\n\n A.height = 1 + math_max(C.height, E.height);\n B.height = 1 + math_max(A.height, D.height);\n } else {\n B.child2 = E;\n A.child1 = D;\n D.parent = A;\n A.aabb.combine(C.aabb, D.aabb);\n B.aabb.combine(A.aabb, E.aabb);\n\n A.height = 1 + math_max(C.height, D.height);\n B.height = 1 + math_max(A.height, E.height);\n }\n\n return B;\n }\n\n return A;\n }\n\n /**\n * Compute the height of the binary tree in O(N) time. Should not be called\n * often.\n */\n getHeight(): number {\n if (this.m_root == null) {\n return 0;\n }\n\n return this.m_root.height;\n }\n\n /**\n * Get the ratio of the sum of the node areas to the root area.\n */\n getAreaRatio(): number {\n if (this.m_root == null) {\n return 0.0;\n }\n\n const root = this.m_root;\n const rootArea = root.aabb.getPerimeter();\n\n let totalArea = 0.0;\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height < 0) {\n // Free node in pool\n continue;\n }\n\n totalArea += node.aabb.getPerimeter();\n }\n\n this.iteratorPool.release(it);\n\n return totalArea / rootArea;\n }\n\n /**\n * Compute the height of a sub-tree.\n */\n computeHeight(id?: number): number {\n let node;\n if (typeof id !== \"undefined\") {\n node = this.m_nodes[id];\n } else {\n node = this.m_root;\n }\n\n // if (_ASSERT) console.assert(0 <= id && id < this.m_nodeCapacity);\n\n if (node.isLeaf()) {\n return 0;\n }\n\n const height1 = this.computeHeight(node.child1.id);\n const height2 = this.computeHeight(node.child2.id);\n return 1 + math_max(height1, height2);\n }\n\n validateStructure(node: TreeNode): void {\n if (node == null) {\n return;\n }\n\n if (node === this.m_root) {\n if (_ASSERT) console.assert(node.parent == null);\n }\n\n const child1 = node.child1;\n const child2 = node.child2;\n\n if (node.isLeaf()) {\n if (_ASSERT) console.assert(child1 == null);\n if (_ASSERT) console.assert(child2 == null);\n if (_ASSERT) console.assert(node.height === 0);\n return;\n }\n\n // if (_ASSERT) console.assert(0 <= child1 && child1 < this.m_nodeCapacity);\n // if (_ASSERT) console.assert(0 <= child2 && child2 < this.m_nodeCapacity);\n\n if (_ASSERT) console.assert(child1.parent === node);\n if (_ASSERT) console.assert(child2.parent === node);\n\n this.validateStructure(child1);\n this.validateStructure(child2);\n }\n\n validateMetrics(node: TreeNode): void {\n if (node == null) {\n return;\n }\n\n const child1 = node.child1;\n const child2 = node.child2;\n\n if (node.isLeaf()) {\n if (_ASSERT) console.assert(child1 == null);\n if (_ASSERT) console.assert(child2 == null);\n if (_ASSERT) console.assert(node.height === 0);\n return;\n }\n\n // if (_ASSERT) console.assert(0 <= child1 && child1 < this.m_nodeCapacity);\n // if (_ASSERT) console.assert(0 <= child2 && child2 < this.m_nodeCapacity);\n\n const height1 = child1.height;\n const height2 = child2.height;\n const height = 1 + math_max(height1, height2);\n if (_ASSERT) console.assert(node.height === height);\n\n const aabb = new AABB();\n aabb.combine(child1.aabb, child2.aabb);\n\n if (_ASSERT) console.assert(AABB.areEqual(aabb, node.aabb));\n\n this.validateMetrics(child1);\n this.validateMetrics(child2);\n }\n\n /**\n * Validate this tree. For testing.\n */\n validate(): void {\n if (!_ASSERT) return;\n this.validateStructure(this.m_root);\n this.validateMetrics(this.m_root);\n\n console.assert(this.getHeight() === this.computeHeight());\n }\n\n /**\n * Get the maximum balance of an node in the tree. The balance is the difference\n * in height of the two children of a node.\n */\n getMaxBalance(): number {\n let maxBalance = 0;\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height <= 1) {\n continue;\n }\n\n if (_ASSERT) console.assert(!node.isLeaf());\n\n const balance = math_abs(node.child2.height - node.child1.height);\n maxBalance = math_max(maxBalance, balance);\n }\n this.iteratorPool.release(it);\n\n return maxBalance;\n }\n\n /**\n * Build an optimal tree. Very expensive. For testing.\n */\n rebuildBottomUp(): void {\n const nodes = [];\n let count = 0;\n\n // Build array of leaves. Free the rest.\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height < 0) {\n // free node in pool\n continue;\n }\n\n if (node.isLeaf()) {\n node.parent = null;\n nodes[count] = node;\n ++count;\n } else {\n this.freeNode(node);\n }\n }\n this.iteratorPool.release(it);\n\n while (count > 1) {\n let minCost = Infinity;\n let iMin = -1;\n let jMin = -1;\n for (let i = 0; i < count; ++i) {\n const aabbi = nodes[i].aabb;\n for (let j = i + 1; j < count; ++j) {\n const aabbj = nodes[j].aabb;\n const cost = AABB.combinedPerimeter(aabbi, aabbj);\n if (cost < minCost) {\n iMin = i;\n jMin = j;\n minCost = cost;\n }\n }\n }\n\n const child1 = nodes[iMin];\n const child2 = nodes[jMin];\n\n const parent = this.allocateNode();\n parent.child1 = child1;\n parent.child2 = child2;\n parent.height = 1 + math_max(child1.height, child2.height);\n parent.aabb.combine(child1.aabb, child2.aabb);\n parent.parent = null;\n\n child1.parent = parent;\n child2.parent = parent;\n\n nodes[jMin] = nodes[count - 1];\n nodes[iMin] = parent;\n --count;\n }\n\n this.m_root = nodes[0];\n\n if (_ASSERT) this.validate();\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n // Build array of leaves. Free the rest.\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n const aabb = node.aabb;\n aabb.lowerBound.x -= newOrigin.x;\n aabb.lowerBound.y -= newOrigin.y;\n aabb.upperBound.x -= newOrigin.x;\n aabb.upperBound.y -= newOrigin.y;\n }\n this.iteratorPool.release(it);\n }\n\n /**\n * Query an AABB for overlapping proxies. The callback class is called for each\n * proxy that overlaps the supplied AABB.\n */\n query(aabb: AABBValue, queryCallback: DynamicTreeQueryCallback): void {\n if (_ASSERT) console.assert(typeof queryCallback === \"function\");\n const stack = this.stackPool.allocate();\n\n stack.push(this.m_root);\n while (stack.length > 0) {\n const node = stack.pop();\n if (node == null) {\n continue;\n }\n\n if (AABB.testOverlap(node.aabb, aabb)) {\n if (node.isLeaf()) {\n const proceed = queryCallback(node.id);\n if (proceed === false) {\n return;\n }\n } else {\n stack.push(node.child1);\n stack.push(node.child2);\n }\n }\n }\n\n this.stackPool.release(stack);\n }\n\n /**\n * Ray-cast against the proxies in the tree. This relies on the callback to\n * perform a exact ray-cast in the case were the proxy contains a shape. The\n * callback also performs the any collision filtering. This has performance\n * roughly equal to k * log(n), where k is the number of collisions and n is the\n * number of proxies in the tree.\n *\n * @param input The ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n * @param rayCastCallback A function that is called for each proxy that is hit by the ray. If the return value is a positive number it will update the maxFraction of the ray cast input, and if it is zero it will terminate they ray cast.\n */\n rayCast(input: RayCastInput, rayCastCallback: RayCastCallback): void {\n // TODO: GC\n if (_ASSERT) console.assert(typeof rayCastCallback === \"function\");\n const p1 = input.p1;\n const p2 = input.p2;\n const r = Vec2.sub(p2, p1);\n if (_ASSERT) console.assert(r.lengthSquared() > 0.0);\n r.normalize();\n\n // v is perpendicular to the segment.\n const v = Vec2.crossNumVec2(1.0, r);\n const abs_v = Vec2.abs(v);\n\n // Separating axis for segment (Gino, p80).\n // |dot(v, p1 - c)| > dot(|v|, h)\n\n let maxFraction = input.maxFraction;\n\n // Build a bounding box for the segment.\n const segmentAABB = new AABB();\n let t = Vec2.combine((1 - maxFraction), p1, maxFraction, p2);\n segmentAABB.combinePoints(p1, t);\n\n const stack = this.stackPool.allocate();\n const subInput = this.inputPool.allocate();\n\n stack.push(this.m_root);\n while (stack.length > 0) {\n const node = stack.pop();\n if (node == null) {\n continue;\n }\n\n if (AABB.testOverlap(node.aabb, segmentAABB) === false) {\n continue;\n }\n\n // Separating axis for segment (Gino, p80).\n // |dot(v, p1 - c)| > dot(|v|, h)\n const c = node.aabb.getCenter();\n const h = node.aabb.getExtents();\n const separation = math_abs(Vec2.dot(v, Vec2.sub(p1, c))) - Vec2.dot(abs_v, h);\n if (separation > 0.0) {\n continue;\n }\n\n if (node.isLeaf()) {\n subInput.p1 = Vec2.clone(input.p1);\n subInput.p2 = Vec2.clone(input.p2);\n subInput.maxFraction = maxFraction;\n\n const value = rayCastCallback(subInput, node.id);\n\n if (value === 0.0) {\n // The client has terminated the ray cast.\n break;\n } else if (value > 0.0) {\n // update segment bounding box.\n maxFraction = value;\n t = Vec2.combine((1 - maxFraction), p1, maxFraction, p2);\n segmentAABB.combinePoints(p1, t);\n }\n } else {\n stack.push(node.child1);\n stack.push(node.child2);\n }\n }\n this.stackPool.release(stack);\n this.inputPool.release(subInput);\n }\n\n private inputPool: Pool = new Pool({\n create(): RayCastInput {\n // tslint:disable-next-line:no-object-literal-type-assertion\n return {} as RayCastInput;\n },\n release(stack: RayCastInput): void {\n }\n });\n\n private stackPool: Pool>> = new Pool>>({\n create(): Array> {\n return [];\n },\n release(stack: Array>): void {\n stack.length = 0;\n }\n });\n\n private iteratorPool: Pool> = new Pool>({\n create(): Iterator {\n return new Iterator();\n },\n release(iterator: Iterator): void {\n iterator.close();\n }\n });\n\n}\n\n/** @internal */\nclass Iterator {\n parents: Array> = [];\n states: number[] = [];\n preorder(root: TreeNode): Iterator {\n this.parents.length = 0;\n this.parents.push(root);\n this.states.length = 0;\n this.states.push(0);\n return this;\n }\n next(): TreeNode {\n while (this.parents.length > 0) {\n const i = this.parents.length - 1;\n const node = this.parents[i];\n if (this.states[i] === 0) {\n this.states[i] = 1;\n return node;\n }\n if (this.states[i] === 1) {\n this.states[i] = 2;\n if (node.child1) {\n this.parents.push(node.child1);\n this.states.push(1);\n return node.child1;\n }\n }\n if (this.states[i] === 2) {\n this.states[i] = 3;\n if (node.child2) {\n this.parents.push(node.child2);\n this.states.push(1);\n return node.child2;\n }\n }\n this.parents.pop();\n this.states.pop();\n }\n }\n close(): void {\n this.parents.length = 0;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2Value } from \"../common/Vec2\";\nimport { AABB, AABBValue, RayCastCallback, RayCastInput } from \"./AABB\";\nimport { DynamicTree, DynamicTreeQueryCallback } from \"./DynamicTree\";\nimport { FixtureProxy } from \"../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/**\n * The broad-phase wraps and extends a dynamic-tree to keep track of moved\n * objects and query them on update.\n */\nexport class BroadPhase {\n m_tree: DynamicTree = new DynamicTree();\n m_moveBuffer: number[] = [];\n\n m_callback: (userDataA: any, userDataB: any) => void;\n m_queryProxyId: number;\n\n /**\n * Get user data from a proxy. Returns null if the id is invalid.\n */\n getUserData(proxyId: number): FixtureProxy {\n return this.m_tree.getUserData(proxyId);\n }\n\n /**\n * Test overlap of fat AABBs.\n */\n testOverlap(proxyIdA: number, proxyIdB: number): boolean {\n const aabbA = this.m_tree.getFatAABB(proxyIdA);\n const aabbB = this.m_tree.getFatAABB(proxyIdB);\n return AABB.testOverlap(aabbA, aabbB);\n }\n\n /**\n * Get the fat AABB for a proxy.\n */\n getFatAABB(proxyId: number): AABB {\n return this.m_tree.getFatAABB(proxyId);\n }\n\n /**\n * Get the number of proxies.\n */\n getProxyCount(): number {\n return this.m_moveBuffer.length;\n }\n\n /**\n * Get the height of the embedded tree.\n */\n getTreeHeight(): number {\n return this.m_tree.getHeight();\n }\n\n /**\n * Get the balance (integer) of the embedded tree.\n */\n getTreeBalance(): number {\n return this.m_tree.getMaxBalance();\n }\n\n /**\n * Get the quality metric of the embedded tree.\n */\n getTreeQuality(): number {\n return this.m_tree.getAreaRatio();\n }\n\n /**\n * Query an AABB for overlapping proxies. The callback class is called for each\n * proxy that overlaps the supplied AABB.\n */\n query = (aabb: AABBValue, queryCallback: DynamicTreeQueryCallback): void => {\n this.m_tree.query(aabb, queryCallback);\n };\n\n /**\n * Ray-cast against the proxies in the tree. This relies on the callback to\n * perform a exact ray-cast in the case were the proxy contains a shape. The\n * callback also performs the any collision filtering. This has performance\n * roughly equal to k * log(n), where k is the number of collisions and n is the\n * number of proxies in the tree.\n *\n * @param input The ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n * @param rayCastCallback A function that is called for each proxy that is hit by the ray. If the return value is a positive number it will update the maxFraction of the ray cast input, and if it is zero it will terminate they ray cast.\n */\n rayCast(input: RayCastInput, rayCastCallback: RayCastCallback): void {\n this.m_tree.rayCast(input, rayCastCallback);\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_tree.shiftOrigin(newOrigin);\n }\n\n /**\n * Create a proxy with an initial AABB. Pairs are not reported until UpdatePairs\n * is called.\n */\n createProxy(aabb: AABBValue, userData: FixtureProxy): number {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n const proxyId = this.m_tree.createProxy(aabb, userData);\n this.bufferMove(proxyId);\n return proxyId;\n }\n\n /**\n * Destroy a proxy. It is up to the client to remove any pairs.\n */\n destroyProxy(proxyId: number): void {\n this.unbufferMove(proxyId);\n this.m_tree.destroyProxy(proxyId);\n }\n\n /**\n * Call moveProxy as many times as you like, then when you are done call\n * UpdatePairs to finalized the proxy pairs (for your time step).\n */\n moveProxy(proxyId: number, aabb: AABB, displacement: Vec2Value): void {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n const changed = this.m_tree.moveProxy(proxyId, aabb, displacement);\n if (changed) {\n this.bufferMove(proxyId);\n }\n }\n\n /**\n * Call to trigger a re-processing of it's pairs on the next call to\n * UpdatePairs.\n */\n touchProxy(proxyId: number): void {\n this.bufferMove(proxyId);\n }\n\n bufferMove(proxyId: number): void {\n this.m_moveBuffer.push(proxyId);\n }\n\n unbufferMove(proxyId: number): void {\n for (let i = 0; i < this.m_moveBuffer.length; ++i) {\n if (this.m_moveBuffer[i] === proxyId) {\n this.m_moveBuffer[i] = null;\n }\n }\n }\n\n /**\n * Update the pairs. This results in pair callbacks. This can only add pairs.\n */\n updatePairs(addPairCallback: (userDataA: FixtureProxy, userDataB: FixtureProxy) => void): void {\n if (_ASSERT) console.assert(typeof addPairCallback === \"function\");\n this.m_callback = addPairCallback;\n\n // Perform tree queries for all moving proxies.\n while (this.m_moveBuffer.length > 0) {\n this.m_queryProxyId = this.m_moveBuffer.pop();\n if (this.m_queryProxyId === null) {\n continue;\n }\n\n // We have to query the tree with the fat AABB so that\n // we don't fail to create a pair that may touch later.\n const fatAABB = this.m_tree.getFatAABB(this.m_queryProxyId);\n\n // Query tree, create pairs and add them pair buffer.\n this.m_tree.query(fatAABB, this.queryCallback);\n }\n\n // Try to keep the tree balanced.\n // this.m_tree.rebalance(4);\n }\n\n queryCallback = (proxyId: number): boolean => {\n // A proxy cannot form a pair with itself.\n if (proxyId === this.m_queryProxyId) {\n return true;\n }\n\n const proxyIdA = math_min(proxyId, this.m_queryProxyId);\n const proxyIdB = math_max(proxyId, this.m_queryProxyId);\n\n // TODO: Skip any duplicate pairs.\n\n const userDataA = this.m_tree.getUserData(proxyIdA);\n const userDataB = this.m_tree.getUserData(proxyIdB);\n\n // Send the pairs back to the client.\n this.m_callback(userDataA, userDataB);\n\n return true;\n };\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n/** @internal */ const math_sqrt = Math.sqrt;\n\n\nimport { RotValue } from \"./Rot\";\nimport { TransformValue } from \"./Transform\";\nimport { Vec2Value } from \"./Vec2\";\nimport { Vec3Value } from \"./Vec3\";\n\nexport function vec2(x: number, y: number): Vec2Value {\n return { x, y };\n}\n\nexport function vec3(x: number, y: number, z: number): Vec3Value {\n return { x, y, z };\n}\n\nexport function rotation(angle: number): RotValue {\n return { s: math_sin(angle), c: math_cos(angle) };\n}\n\nexport function setVec2(out: Vec2Value, x: number, y: number): Vec2Value {\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function copyVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = w.x;\n out.y = w.y;\n return out;\n}\n\nexport function zeroVec2(out: Vec2Value): Vec2Value {\n out.x = 0;\n out.y = 0;\n return out;\n}\n\nexport function negVec2(out: Vec2Value): Vec2Value {\n out.x = -out.x;\n out.y = -out.y;\n return out;\n}\n\nexport function plusVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x += w.x;\n out.y += w.y;\n return out;\n}\n\nexport function addVec2(out: Vec2Value, v: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = v.x + w.x;\n out.y = v.x + w.y;\n return out;\n}\n\nexport function minusVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x -= w.x;\n out.y -= w.y;\n return out;\n}\n\nexport function subVec2(out: Vec2Value, v: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = v.x - w.x;\n out.y = v.y - w.y;\n return out;\n}\n\nexport function mulVec2(out: Vec2Value, m: number): Vec2Value {\n out.x *= m;\n out.y *= m;\n return out;\n}\n\nexport function scaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x = m * w.x;\n out.y = m * w.y;\n return out;\n}\n\nexport function plusScaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x += m * w.x;\n out.y += m * w.y;\n return out;\n}\n\nexport function minusScaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x -= m * w.x;\n out.y -= m * w.y;\n return out;\n}\n\nexport function combine2Vec2(out: Vec2Value, am: number, a: Vec2Value, bm: number, b: Vec2Value): Vec2Value {\n out.x = am * a.x + bm * b.x;\n out.y = am * a.y + bm * b.y;\n return out;\n}\n\nexport function combine3Vec2(out: Vec2Value, am: number, a: Vec2Value, bm: number, b: Vec2Value, cm: number, c: Vec2Value): Vec2Value {\n out.x = am * a.x + bm * b.x + cm * c.x;\n out.y = am * a.y + bm * b.y + cm * c.y;\n return out;\n}\n\nexport function normalizeVec2Length(out: Vec2Value): number {\n const length = math_sqrt(out.x * out.x + out.y * out.y);\n if (length !== 0) {\n const invLength = 1 / length;\n out.x *= invLength;\n out.y *= invLength;\n }\n return length;\n}\n\nexport function normalizeVec2(out: Vec2Value): Vec2Value {\n const length = math_sqrt(out.x * out.x + out.y * out.y);\n if (length > 0) {\n const invLength = 1 / length;\n out.x *= invLength;\n out.y *= invLength;\n }\n return out;\n}\n\nexport function crossVec2Num(out: Vec2Value, v: Vec2Value, w: number): Vec2Value {\n const x = w * v.y;\n const y = -w * v.x;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function crossNumVec2(out: Vec2Value, w: number, v: Vec2Value): Vec2Value {\n const x = -w * v.y;\n const y = w * v.x;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function crossVec2Vec2(a: Vec2Value, b: Vec2Value): number {\n return a.x * b.y - a.y * b.x;\n}\n\nexport function dotVec2(a: Vec2Value, b: Vec2Value): number {\n return a.x * b.x + a.y * b.y;\n}\n\nexport function lengthVec2(a: Vec2Value): number {\n return math_sqrt(a.x * a.x + a.y * a.y);\n}\n\nexport function lengthSqrVec2(a: Vec2Value): number {\n return a.x * a.x + a.y * a.y;\n}\n\nexport function distVec2(a: Vec2Value, b: Vec2Value): number {\n const dx = a.x - b.x;\n const dy = a.y - b.y;\n return math_sqrt(dx * dx + dy * dy);\n}\n\nexport function distSqrVec2(a: Vec2Value, b: Vec2Value): number {\n const dx = a.x - b.x;\n const dy = a.y - b.y;\n return dx * dx + dy * dy;\n}\n\nexport function dotVec3(v: Vec3Value, w: Vec3Value): number {\n return v.x * w.x + v.y * w.y + v.z * w.z;\n}\n\nexport function setRotAngle(out: RotValue, a: number): RotValue {\n out.c = math_cos(a);\n out.s = math_sin(a);\n return out;\n}\n\nexport function rotVec2(out: Vec2Value, q: RotValue, v: Vec2Value): Vec2Value {\n out.x = q.c * v.x - q.s * v.y;\n out.y = q.s * v.x + q.c * v.y;\n return out;\n}\n\nexport function derotVec2(out: Vec2Value, q: RotValue, v: Vec2Value): Vec2Value {\n const x = q.c * v.x + q.s * v.y;\n const y = -q.s * v.x + q.c * v.y;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function rerotVec2(out: Vec2Value, before: RotValue, after: RotValue, v: Vec2Value): Vec2Value {\n const x0 = before.c * v.x + before.s * v.y;\n const y0 = -before.s * v.x + before.c * v.y;\n const x = after.c * x0 - after.s * y0;\n const y = after.s * x0 + after.c * y0;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function transform(x: number, y: number, a: number): TransformValue {\n return { p: vec2(x, y), q: rotation(a) };\n}\n\nexport function copyTransform(out: TransformValue, transform: TransformValue): TransformValue {\n out.p.x = transform.p.x;\n out.p.y = transform.p.y;\n out.q.s = transform.q.s;\n out.q.c = transform.q.c;\n return out;\n}\n\nexport function transformVec2(out: Vec2Value, xf: TransformValue, v: Vec2Value): Vec2Value {\n const x = xf.q.c * v.x - xf.q.s * v.y + xf.p.x;\n const y = xf.q.s * v.x + xf.q.c * v.y + xf.p.y;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function detransformVec2(out: Vec2Value, xf: TransformValue, v: Vec2Value): Vec2Value {\n const px = v.x - xf.p.x;\n const py = v.y - xf.p.y;\n const x = (xf.q.c * px + xf.q.s * py);\n const y = (-xf.q.s * px + xf.q.c * py);\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function retransformVec2(out: Vec2Value, from: TransformValue, to: TransformValue, v: Vec2Value): Vec2Value {\n const x0 = from.q.c * v.x - from.q.s * v.y + from.p.x;\n const y0 = from.q.s * v.x + from.q.c * v.y + from.p.y;\n const px = x0 - to.p.x;\n const py = y0 - to.p.y;\n const x = to.q.c * px + to.q.s * py;\n const y = -to.q.s * px + to.q.c * py;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function detransformTransform(out: TransformValue, a: TransformValue, b: TransformValue): TransformValue {\n const c = a.q.c * b.q.c + a.q.s * b.q.s;\n const s = a.q.c * b.q.s - a.q.s * b.q.c;\n const x = a.q.c * (b.p.x - a.p.x) + a.q.s * (b.p.y - a.p.y);\n const y = -a.q.s * (b.p.x - a.p.x) + a.q.c * (b.p.y - a.p.y);\n out.q.c = c;\n out.q.s = s;\n out.p.x = x;\n out.p.y = y;\n return out;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n/** @internal */ const math_atan2 = Math.atan2;\n\nexport interface RotValue {\n /** sin(angle) */\n s: number;\n /** cos(angle) */\n c: number;\n}\n\ndeclare module \"./Rot\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(angle: number): Rot;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(obj: RotValue): Rot;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(): Rot;\n}\n\n/** Rotation */\n// @ts-expect-error\nexport class Rot {\n /** sin(angle) */\n s: number;\n /** cos(angle) */\n c: number;\n\n /** Initialize from an angle in radians. */\n constructor(angle?: number | RotValue) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Rot)) {\n return new Rot(angle);\n }\n if (typeof angle === \"number\") {\n this.setAngle(angle);\n } else if (typeof angle === \"object\") {\n this.setRot(angle);\n } else {\n this.setIdentity();\n }\n }\n\n /** @hidden */\n static neo(angle: number): Rot {\n const obj = Object.create(Rot.prototype);\n obj.setAngle(angle);\n return obj;\n }\n\n static clone(rot: RotValue): Rot {\n if (_ASSERT) Rot.assert(rot);\n const obj = Object.create(Rot.prototype);\n obj.s = rot.s;\n obj.c = rot.c;\n return obj;\n }\n\n static identity(): Rot {\n const obj = Object.create(Rot.prototype);\n obj.s = 0.0;\n obj.c = 1.0;\n return obj;\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.s) && Number.isFinite(obj.c);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Rot.isValid(o), \"Invalid Rot!\", o);\n }\n\n /** Set to the identity rotation. */\n setIdentity(): void {\n this.s = 0.0;\n this.c = 1.0;\n }\n\n set(angle: number | RotValue): void {\n if (typeof angle === \"object\") {\n if (_ASSERT) Rot.assert(angle);\n this.s = angle.s;\n this.c = angle.c;\n\n } else {\n if (_ASSERT) console.assert(Number.isFinite(angle));\n // TODO_ERIN optimize\n this.s = math_sin(angle);\n this.c = math_cos(angle);\n }\n }\n\n setRot(angle: RotValue): void {\n if (_ASSERT) Rot.assert(angle);\n this.s = angle.s;\n this.c = angle.c;\n }\n\n /** Set using an angle in radians. */\n setAngle(angle: number): void {\n if (_ASSERT) console.assert(Number.isFinite(angle));\n // TODO_ERIN optimize\n this.s = math_sin(angle);\n this.c = math_cos(angle);\n }\n\n /** Get the angle in radians. */\n getAngle(): number {\n return math_atan2(this.s, this.c);\n }\n\n /** Get the x-axis. */\n getXAxis(): Vec2 {\n return Vec2.neo(this.c, this.s);\n }\n\n /** Get the y-axis. */\n getYAxis(): Vec2 {\n return Vec2.neo(-this.s, this.c);\n }\n\n /** Multiply two rotations: q * r */\n static mul(rot: RotValue, m: RotValue): Rot;\n /** Rotate a vector */\n static mul(rot: RotValue, m: Vec2Value): Vec2;\n static mul(rot, m) {\n if (_ASSERT) Rot.assert(rot);\n if (\"c\" in m && \"s\" in m) {\n if (_ASSERT) Rot.assert(m);\n // [qc -qs] * [rc -rs] = [qc*rc-qs*rs -qc*rs-qs*rc]\n // [qs qc] [rs rc] [qs*rc+qc*rs -qs*rs+qc*rc]\n // s = qs * rc + qc * rs\n // c = qc * rc - qs * rs\n const qr = Rot.identity();\n qr.s = rot.s * m.c + rot.c * m.s;\n qr.c = rot.c * m.c - rot.s * m.s;\n return qr;\n\n } else if (\"x\" in m && \"y\" in m) {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x - rot.s * m.y, rot.s * m.x + rot.c * m.y);\n }\n }\n\n /** Multiply two rotations: q * r */\n static mulRot(rot: RotValue, m: RotValue): Rot {\n if (_ASSERT) Rot.assert(rot);\n if (_ASSERT) Rot.assert(m);\n // [qc -qs] * [rc -rs] = [qc*rc-qs*rs -qc*rs-qs*rc]\n // [qs qc] [rs rc] [qs*rc+qc*rs -qs*rs+qc*rc]\n // s = qs * rc + qc * rs\n // c = qc * rc - qs * rs\n const qr = Rot.identity();\n qr.s = rot.s * m.c + rot.c * m.s;\n qr.c = rot.c * m.c - rot.s * m.s;\n return qr;\n }\n\n /** Rotate a vector */\n static mulVec2(rot: RotValue, m: Vec2Value): Vec2 {\n if (_ASSERT) Rot.assert(rot);\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x - rot.s * m.y, rot.s * m.x + rot.c * m.y);\n }\n\n static mulSub(rot: RotValue, v: Vec2Value, w: Vec2Value): Vec2 {\n const x = rot.c * (v.x - w.x) - rot.s * (v.y - w.y);\n const y = rot.s * (v.x - w.x) + rot.c * (v.y - w.y);\n return Vec2.neo(x, y);\n }\n\n /** Transpose multiply two rotations: qT * r */\n static mulT(rot: RotValue, m: RotValue): Rot;\n /** Inverse rotate a vector */\n static mulT(rot: RotValue, m: Vec2Value): Vec2;\n static mulT(rot, m) {\n if (\"c\" in m && \"s\" in m) {\n if (_ASSERT) Rot.assert(m);\n // [ qc qs] * [rc -rs] = [qc*rc+qs*rs -qc*rs+qs*rc]\n // [-qs qc] [rs rc] [-qs*rc+qc*rs qs*rs+qc*rc]\n // s = qc * rs - qs * rc\n // c = qc * rc + qs * rs\n const qr = Rot.identity();\n qr.s = rot.c * m.s - rot.s * m.c;\n qr.c = rot.c * m.c + rot.s * m.s;\n return qr;\n\n } else if (\"x\" in m && \"y\" in m) {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x + rot.s * m.y, -rot.s * m.x + rot.c * m.y);\n }\n }\n\n /** Transpose multiply two rotations: qT * r */\n static mulTRot(rot: RotValue, m: RotValue): Rot {\n if (_ASSERT) Rot.assert(m);\n // [ qc qs] * [rc -rs] = [qc*rc+qs*rs -qc*rs+qs*rc]\n // [-qs qc] [rs rc] [-qs*rc+qc*rs qs*rs+qc*rc]\n // s = qc * rs - qs * rc\n // c = qc * rc + qs * rs\n const qr = Rot.identity();\n qr.s = rot.c * m.s - rot.s * m.c;\n qr.c = rot.c * m.c + rot.s * m.s;\n return qr;\n }\n\n /** Inverse rotate a vector */\n static mulTVec2(rot: RotValue, m: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x + rot.s * m.y, -rot.s * m.x + rot.c * m.y);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"./Matrix\";\nimport { mod } from \"./Math\";\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { TransformValue } from \"./Transform\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_atan2 = Math.atan2;\n/** @internal */ const math_PI = Math.PI;\n\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n\n/**\n * This describes the motion of a body/shape for TOI computation. Shapes are\n * defined with respect to the body origin, which may not coincide with the\n * center of mass. However, to support dynamics we must interpolate the center\n * of mass position.\n */\nexport class Sweep {\n /** Local center of mass position */\n localCenter = Vec2.zero();\n\n /** World center position */\n c = Vec2.zero();\n\n /** World angle */\n a = 0;\n\n /** Fraction of the current time step in the range [0,1], c0 and a0 are c and a at alpha0. */\n alpha0 = 0;\n\n c0 = Vec2.zero();\n a0 = 0;\n\n /** @internal */\n recycle() {\n matrix.zeroVec2(this.localCenter);\n matrix.zeroVec2(this.c);\n this.a = 0;\n this.alpha0 = 0;\n matrix.zeroVec2(this.c0);\n this.a0 = 0;\n }\n\n setTransform(xf: TransformValue): void {\n matrix.transformVec2(temp, xf, this.localCenter);\n matrix.copyVec2(this.c, temp);\n matrix.copyVec2(this.c0, temp);\n\n this.a = this.a0 = math_atan2(xf.q.s, xf.q.c);\n }\n\n setLocalCenter(localCenter: Vec2Value, xf: TransformValue): void {\n matrix.copyVec2(this.localCenter, localCenter);\n\n matrix.transformVec2(temp, xf, this.localCenter);\n matrix.copyVec2(this.c, temp);\n matrix.copyVec2(this.c0, temp);\n }\n\n /**\n * Get the interpolated transform at a specific time.\n *\n * @param xf\n * @param beta A factor in [0,1], where 0 indicates alpha0\n */\n getTransform(xf: TransformValue, beta: number = 0): void {\n matrix.setRotAngle(xf.q, (1.0 - beta) * this.a0 + beta * this.a);\n matrix.combine2Vec2(xf.p, (1.0 - beta), this.c0, beta, this.c);\n\n // shift to origin\n matrix.minusVec2(xf.p, matrix.rotVec2(temp, xf.q, this.localCenter));\n }\n\n /**\n * Advance the sweep forward, yielding a new initial state.\n *\n * @param alpha The new initial time\n */\n advance(alpha: number): void {\n if (_ASSERT) console.assert(this.alpha0 < 1.0);\n const beta = (alpha - this.alpha0) / (1.0 - this.alpha0);\n matrix.combine2Vec2(this.c0, beta, this.c, 1 - beta, this.c0);\n this.a0 = beta * this.a + (1 - beta) * this.a0;\n this.alpha0 = alpha;\n }\n\n forward(): void {\n this.a0 = this.a;\n matrix.copyVec2(this.c0, this.c);\n }\n\n /**\n * normalize the angles in radians to be between -pi and pi.\n */\n normalize(): void {\n const a0 = mod(this.a0, -math_PI, +math_PI);\n this.a -= this.a0 - a0;\n this.a0 = a0;\n }\n\n set(that: Sweep): void {\n matrix.copyVec2(this.localCenter, that.localCenter);\n matrix.copyVec2(this.c, that.c);\n this.a = that.a;\n this.alpha0 = that.alpha0;\n matrix.copyVec2(this.c0, that.c0);\n this.a0 = that.a0;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { Rot, RotValue } from \"./Rot\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\nexport type TransformValue = {\n p: Vec2Value;\n q: RotValue;\n};\n\ndeclare module \"./Transform\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Transform(position?: Vec2Value, rotation?: number): Transform;\n}\n\n/**\n * A transform contains translation and rotation. It is used to represent the\n * position and orientation of rigid frames. Initialize using a position vector\n * and a rotation.\n */\n// @ts-expect-error\nexport class Transform {\n /** position */\n p: Vec2;\n\n /** rotation */\n q: Rot;\n\n constructor(position?: Vec2Value, rotation?: number) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Transform)) {\n return new Transform(position, rotation);\n }\n this.p = Vec2.zero();\n this.q = Rot.identity();\n if (typeof position !== \"undefined\") {\n this.p.setVec2(position);\n }\n if (typeof rotation !== \"undefined\") {\n this.q.setAngle(rotation);\n }\n }\n\n static clone(xf: Transform): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.clone(xf.p);\n obj.q = Rot.clone(xf.q);\n return obj;\n }\n\n /** @hidden */\n static neo(position: Vec2Value, rotation: Rot): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.clone(position);\n obj.q = Rot.clone(rotation);\n return obj;\n }\n\n static identity(): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.zero();\n obj.q = Rot.identity();\n return obj;\n }\n\n /** Set this to the identity transform */\n setIdentity(): void {\n this.p.setZero();\n this.q.setIdentity();\n }\n\n /** Set position and angle */\n set(position: Vec2Value, rotation: number): void;\n /** Copy from another transform */\n set(xf: TransformValue): void;\n set(a: any, b?: any) {\n if (typeof b === \"undefined\") {\n this.p.set(a.p);\n this.q.set(a.q);\n } else {\n this.p.set(a);\n this.q.set(b);\n }\n }\n\n /** Set position and angle */\n setNum(position: Vec2Value, rotation: number) {\n this.p.setVec2(position);\n this.q.setAngle(rotation);\n }\n\n setTransform(xf: TransformValue): void {\n this.p.setVec2(xf.p);\n this.q.setRot(xf.q);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.p) && Rot.isValid(obj.q);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Transform.isValid(o), \"Invalid Transform!\", o);\n }\n\n static mul(a: TransformValue, b: Vec2Value): Vec2;\n static mul(a: TransformValue, b: TransformValue): Transform;\n // static mul(a: Transform, b: Vec2Value[]): Vec2[];\n // static mul(a: Transform, b: Transform[]): Transform[];\n static mul(a, b) {\n if (Array.isArray(b)) {\n // todo: this was used in examples, remove in the future\n if (_ASSERT) Transform.assert(a);\n const arr = [];\n for (let i = 0; i < b.length; i++) {\n arr[i] = Transform.mul(a, b[i]);\n }\n return arr;\n\n } else if (\"x\" in b && \"y\" in b) {\n return Transform.mulVec2(a, b);\n\n } else if (\"p\" in b && \"q\" in b) {\n return Transform.mulXf(a, b);\n }\n }\n\n static mulAll(a: Transform, b: Vec2Value[]): Vec2[];\n static mulAll(a: Transform, b: Transform[]): Transform[];\n static mulAll(a: TransformValue, b) {\n if (_ASSERT) Transform.assert(a);\n const arr = [];\n for (let i = 0; i < b.length; i++) {\n arr[i] = Transform.mul(a, b[i]);\n }\n return arr;\n }\n\n /** @hidden @deprecated */\n static mulFn(a: TransformValue) {\n // todo: this was used in examples, remove in the future\n if (_ASSERT) Transform.assert(a);\n return function(b: Vec2Value): Vec2 {\n return Transform.mul(a, b);\n };\n }\n\n static mulVec2(a: TransformValue, b: Vec2Value): Vec2 {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const x = (a.q.c * b.x - a.q.s * b.y) + a.p.x;\n const y = (a.q.s * b.x + a.q.c * b.y) + a.p.y;\n return Vec2.neo(x, y);\n }\n\n static mulXf(a: TransformValue, b: TransformValue): Transform {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Transform.assert(b);\n // v2 = A.q.Rot(B.q.Rot(v1) + B.p) + A.p\n // = (A.q * B.q).Rot(v1) + A.q.Rot(B.p) + A.p\n const xf = Transform.identity();\n xf.q = Rot.mulRot(a.q, b.q);\n xf.p = Vec2.add(Rot.mulVec2(a.q, b.p), a.p);\n return xf;\n }\n\n static mulT(a: TransformValue, b: Vec2Value): Vec2;\n static mulT(a: TransformValue, b: TransformValue): Transform;\n static mulT(a, b) {\n if (\"x\" in b && \"y\" in b) {\n return Transform.mulTVec2(a, b);\n\n } else if (\"p\" in b && \"q\" in b) {\n return Transform.mulTXf(a, b);\n }\n }\n\n static mulTVec2(a: TransformValue, b: Vec2Value): Vec2 {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const px = b.x - a.p.x;\n const py = b.y - a.p.y;\n const x = (a.q.c * px + a.q.s * py);\n const y = (-a.q.s * px + a.q.c * py);\n return Vec2.neo(x, y);\n }\n\n static mulTXf(a: TransformValue, b: TransformValue): Transform {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Transform.assert(b);\n // v2 = A.q' * (B.q * v1 + B.p - A.p)\n // = A.q' * B.q * v1 + A.q' * (B.p - A.p)\n const xf = Transform.identity();\n xf.q.setRot(Rot.mulTRot(a.q, b.q));\n xf.p.setVec2(Rot.mulTVec2(a.q, Vec2.sub(b.p, a.p)));\n return xf;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2 } from \"../common/Vec2\";\n\nexport class Velocity {\n /** linear */\n v = Vec2.zero();\n\n /** angular */\n w = 0;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { TransformValue } from \"../common/Transform\";\n\n\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n\n\nexport class Position {\n /** location */\n c = Vec2.zero();\n\n /** angle */\n a = 0;\n\n // todo: cache sin/cos\n getTransform(xf: TransformValue, p: Vec2Value): TransformValue {\n // xf.q = rotation(this.a);\n // xf.p = this.c - xf.q * p\n xf.q.c = math_cos(this.a);\n xf.q.s = math_sin(this.a);\n xf.p.x = this.c.x - (xf.q.c * p.x - xf.q.s * p.y);\n xf.p.y = this.c.y - (xf.q.s * p.x + xf.q.c * p.y);\n return xf;\n }\n}\n\nexport function getTransform(xf: TransformValue, p: Vec2Value, c: Vec2Value, a: number): TransformValue {\n // xf.q = rotation(a);\n // xf.p = this.c - xf.q * p\n xf.q.c = math_cos(a);\n xf.q.s = math_sin(a);\n xf.p.x = c.x - (xf.q.c * p.x - xf.q.s * p.y);\n xf.p.y = c.y - (xf.q.s * p.x + xf.q.c * p.y);\n return xf;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { MassData } from \"../dynamics/Body\";\nimport { RayCastOutput, RayCastInput, AABBValue } from \"./AABB\";\nimport { DistanceProxy } from \"./Distance\";\nimport type { Transform, TransformValue } from \"../common/Transform\";\nimport type { Vec2Value } from \"../common/Vec2\";\nimport { Style } from \"../util/Testbed\";\n\n// todo make shape an interface\n\n/**\n * A shape is used for collision detection. You can create a shape however you\n * like. Shapes used for simulation in World are created automatically when a\n * Fixture is created. Shapes may encapsulate one or more child shapes.\n */\nexport abstract class Shape {\n /** @hidden */ m_type: ShapeType;\n\n /**\n * @hidden\n * Radius of a shape. For polygonal shapes this must be b2_polygonRadius.\n * There is no support for making rounded polygons.\n */\n m_radius: number;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n /** @hidden */\n abstract _reset(): void;\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return typeof obj.m_type === \"string\" && typeof obj.m_radius === \"number\";\n }\n\n abstract getRadius(): number;\n\n /**\n * Get the type of this shape. You can use this to down cast to the concrete\n * shape.\n *\n * @return the shape type.\n */\n abstract getType(): ShapeType;\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n abstract _clone(): Shape;\n\n /**\n * Get the number of child primitives.\n */\n abstract getChildCount(): number;\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n abstract testPoint(xf: TransformValue, p: Vec2Value): boolean;\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n abstract rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean;\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n abstract computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void;\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n abstract computeMass(massData: MassData, density?: number): void;\n\n abstract computeDistanceProxy(proxy: DistanceProxy, childIndex: number): void;\n\n}\n\nexport type ShapeType = \"circle\" | \"edge\" | \"polygon\" | \"chain\";\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { options } from \"../util/options\";\nimport { Vec2Value } from \"../common/Vec2\";\nimport { AABB, RayCastInput, RayCastOutput } from \"../collision/AABB\";\nimport { Shape, ShapeType } from \"../collision/Shape\";\nimport { Body, MassData } from \"./Body\";\nimport { BroadPhase } from \"../collision/BroadPhase\";\nimport { TransformValue } from \"../common/Transform\";\nimport { Style } from \"../util/Testbed\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/** @internal */ const synchronize_aabb1 = new AABB();\n/** @internal */ const synchronize_aabb2 = new AABB();\n/** @internal */ const displacement = matrix.vec2(0, 0);\n\n/**\n * A fixture definition is used to create a fixture. This class defines an\n * abstract fixture definition. You can reuse fixture definitions safely.\n */\nexport interface FixtureOpt {\n userData?: unknown;\n /**\n * The friction coefficient, usually in the range [0,1]\n */\n friction?: number;\n /**\n * The restitution (elasticity) usually in the range [0,1]\n */\n restitution?: number;\n /**\n * The density, usually in kg/m^2\n */\n density?: number;\n /**\n * A sensor shape collects contact information but never generates a collision response.\n */\n isSensor?: boolean;\n /**\n * Zero, positive or negative collision group.\n * Fixtures with same positive groupIndex always collide and fixtures with same negative groupIndex never collide.\n */\n filterGroupIndex?: number;\n /**\n * Collision category bit or bits that this fixture belongs to.\n * If groupIndex is zero or not matching, then at least one bit in this fixture categoryBits should match other fixture maskBits and vice versa.\n */\n filterCategoryBits?: number;\n /**\n * Collision category bit or bits that this fixture accept for collision.\n */\n filterMaskBits?: number;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\nexport interface FixtureDef extends FixtureOpt {\n shape: Shape;\n}\n\n/** @internal */ const FixtureDefDefault: FixtureOpt = {\n userData : null,\n friction : 0.2,\n restitution : 0.0,\n density : 0.0,\n isSensor : false,\n\n filterGroupIndex : 0,\n filterCategoryBits : 0x0001,\n filterMaskBits : 0xFFFF\n};\n\n/**\n * This proxy is used internally to connect shape children to the broad-phase.\n */\nexport class FixtureProxy {\n aabb: AABB;\n fixture: Fixture;\n childIndex: number;\n proxyId: number;\n constructor(fixture: Fixture, childIndex: number) {\n this.aabb = new AABB();\n this.fixture = fixture;\n this.childIndex = childIndex;\n // this.proxyId;\n }\n}\n\n/**\n * A fixture is used to attach a shape to a body for collision detection. A\n * fixture inherits its transform from its parent. Fixtures hold additional\n * non-geometric data such as friction, collision filters, etc.\n *\n * To create a new Fixture use {@link Body.createFixture}.\n */\nexport class Fixture {\n /** @internal */ m_body: Body;\n /** @internal */ m_friction: number;\n /** @internal */ m_restitution: number;\n /** @internal */ m_density: number;\n /** @internal */ m_isSensor: boolean;\n /** @internal */ m_filterGroupIndex: number;\n /** @internal */ m_filterCategoryBits: number;\n /** @internal */ m_filterMaskBits: number;\n /** @internal */ m_shape: Shape;\n /** @internal */ m_next: Fixture | null;\n /** @internal */ m_proxies: FixtureProxy[];\n // 0 indicates inactive state, this is not the same as m_proxies.length\n /** @internal */ m_proxyCount: number;\n /** @internal */ m_userData: unknown;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n constructor(body: Body, def: FixtureDef);\n constructor(body: Body, shape: Shape, def?: FixtureOpt);\n constructor(body: Body, shape: Shape, density?: number);\n /** @internal */\n constructor(body: Body, shape?, def?) {\n if (shape.shape) {\n def = shape;\n shape = shape.shape;\n\n } else if (typeof def === \"number\") {\n def = {density : def};\n }\n\n def = options(def, FixtureDefDefault);\n\n this.m_body = body;\n\n this.m_friction = def.friction;\n this.m_restitution = def.restitution;\n this.m_density = def.density;\n this.m_isSensor = def.isSensor;\n\n this.m_filterGroupIndex = def.filterGroupIndex;\n this.m_filterCategoryBits = def.filterCategoryBits;\n this.m_filterMaskBits = def.filterMaskBits;\n\n // TODO validate shape\n this.m_shape = shape; // .clone();\n\n this.m_next = null;\n\n this.m_proxies = [];\n this.m_proxyCount = 0;\n\n // fixture proxies are created here,\n // but they are activate in when a fixture is added to body\n const childCount = this.m_shape.getChildCount();\n for (let i = 0; i < childCount; ++i) {\n this.m_proxies[i] = new FixtureProxy(this, i);\n }\n\n this.m_userData = def.userData;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /** @hidden Re-setup fixture. */\n _reset(): void {\n const body = this.getBody();\n const broadPhase = body.m_world.m_broadPhase;\n this.destroyProxies(broadPhase);\n if (this.m_shape._reset) {\n this.m_shape._reset();\n }\n const childCount = this.m_shape.getChildCount();\n for (let i = 0; i < childCount; ++i) {\n this.m_proxies[i] = new FixtureProxy(this, i);\n }\n this.createProxies(broadPhase, body.m_xf);\n body.resetMassData();\n }\n\n /** @internal */\n _serialize(): object {\n return {\n friction: this.m_friction,\n restitution: this.m_restitution,\n density: this.m_density,\n isSensor: this.m_isSensor,\n\n filterGroupIndex: this.m_filterGroupIndex,\n filterCategoryBits: this.m_filterCategoryBits,\n filterMaskBits: this.m_filterMaskBits,\n\n shape: this.m_shape,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, body: any, restore: any): Fixture {\n const shape = restore(Shape, data.shape);\n const fixture = shape && new Fixture(body, shape, data);\n return fixture;\n }\n\n /**\n * Get the type of the child shape. You can use this to down cast to the\n * concrete shape.\n */\n getType(): ShapeType {\n return this.m_shape.m_type;\n }\n\n /**\n * Get the child shape. You can modify the child shape, however you should not\n * change the number of vertices because this will crash some collision caching\n * mechanisms. Manipulating the shape may lead to non-physical behavior.\n */\n getShape(): Shape {\n return this.m_shape;\n }\n\n /**\n * A sensor shape collects contact information but never generates a collision\n * response.\n */\n isSensor(): boolean {\n return this.m_isSensor;\n }\n\n /**\n * Set if this fixture is a sensor.\n */\n setSensor(sensor: boolean): void {\n if (sensor != this.m_isSensor) {\n this.m_body.setAwake(true);\n this.m_isSensor = sensor;\n }\n }\n\n // /**\n // * Get the contact filtering data.\n // */\n // getFilterData() {\n // return this.m_filter;\n // }\n\n /**\n * Get the user data that was assigned in the fixture definition. Use this to\n * store your application specific data.\n */\n getUserData(): unknown {\n return this.m_userData;\n }\n\n /**\n * Set the user data. Use this to store your application specific data.\n */\n setUserData(data: unknown): void {\n this.m_userData = data;\n }\n\n /**\n * Get the parent body of this fixture. This is null if the fixture is not\n * attached.\n */\n getBody(): Body {\n return this.m_body;\n }\n\n /**\n * Get the next fixture in the parent body's fixture list.\n */\n getNext(): Fixture | null {\n return this.m_next;\n }\n\n /**\n * Get the density of this fixture.\n */\n getDensity(): number {\n return this.m_density;\n }\n\n /**\n * Set the density of this fixture. This will _not_ automatically adjust the\n * mass of the body. You must call Body.resetMassData to update the body's mass.\n */\n setDensity(density: number): void {\n if (_ASSERT) console.assert(Number.isFinite(density) && density >= 0.0);\n this.m_density = density;\n }\n\n /**\n * Get the coefficient of friction, usually in the range [0,1].\n */\n getFriction(): number {\n return this.m_friction;\n }\n\n /**\n * Set the coefficient of friction. This will not change the friction of\n * existing contacts.\n */\n setFriction(friction: number): void {\n this.m_friction = friction;\n }\n\n /**\n * Get the coefficient of restitution.\n */\n getRestitution(): number {\n return this.m_restitution;\n }\n\n /**\n * Set the coefficient of restitution. This will not change the restitution of\n * existing contacts.\n */\n setRestitution(restitution: number): void {\n this.m_restitution = restitution;\n }\n\n /**\n * Test a point in world coordinates for containment in this fixture.\n */\n testPoint(p: Vec2Value): boolean {\n return this.m_shape.testPoint(this.m_body.getTransform(), p);\n }\n\n /**\n * Cast a ray against this shape.\n */\n rayCast(output: RayCastOutput, input: RayCastInput, childIndex: number): boolean {\n return this.m_shape.rayCast(output, input, this.m_body.getTransform(), childIndex);\n }\n\n /**\n * Get the mass data for this fixture. The mass data is based on the density and\n * the shape. The rotational inertia is about the shape's origin. This operation\n * may be expensive.\n */\n getMassData(massData: MassData): void {\n this.m_shape.computeMass(massData, this.m_density);\n }\n\n /**\n * Get the fixture's AABB. This AABB may be enlarge and/or stale. If you need a\n * more accurate AABB, compute it using the shape and the body transform.\n */\n getAABB(childIndex: number): AABB {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_proxies.length);\n return this.m_proxies[childIndex].aabb;\n }\n\n /**\n * These support body activation/deactivation.\n */\n createProxies(broadPhase: BroadPhase, xf: TransformValue): void {\n if (_ASSERT) console.assert(this.m_proxyCount == 0);\n\n // Create proxies in the broad-phase.\n this.m_proxyCount = this.m_shape.getChildCount();\n\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n this.m_shape.computeAABB(proxy.aabb, xf, i);\n proxy.proxyId = broadPhase.createProxy(proxy.aabb, proxy);\n }\n }\n\n destroyProxies(broadPhase: BroadPhase): void {\n // Destroy proxies in the broad-phase.\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n broadPhase.destroyProxy(proxy.proxyId);\n proxy.proxyId = null;\n }\n\n this.m_proxyCount = 0;\n }\n\n /**\n * Updates this fixture proxy in broad-phase (with combined AABB of current and\n * next transformation).\n */\n synchronize(broadPhase: BroadPhase, xf1: TransformValue, xf2: TransformValue): void {\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n // Compute an AABB that covers the swept shape (may miss some rotation\n // effect).\n this.m_shape.computeAABB(synchronize_aabb1, xf1, proxy.childIndex);\n this.m_shape.computeAABB(synchronize_aabb2, xf2, proxy.childIndex);\n\n proxy.aabb.combine(synchronize_aabb1, synchronize_aabb2);\n\n matrix.subVec2(displacement, xf2.p, xf1.p);\n\n broadPhase.moveProxy(proxy.proxyId, proxy.aabb, displacement);\n }\n }\n\n /**\n * Set the contact filtering data. This will not update contacts until the next\n * time step when either parent body is active and awake. This automatically\n * calls refilter.\n */\n setFilterData(filter: { groupIndex: number, categoryBits: number, maskBits: number }): void {\n this.m_filterGroupIndex = filter.groupIndex;\n this.m_filterCategoryBits = filter.categoryBits;\n this.m_filterMaskBits = filter.maskBits;\n this.refilter();\n }\n\n getFilterGroupIndex(): number {\n return this.m_filterGroupIndex;\n }\n\n setFilterGroupIndex(groupIndex: number): void {\n this.m_filterGroupIndex = groupIndex;\n this.refilter();\n }\n\n getFilterCategoryBits(): number {\n return this.m_filterCategoryBits;\n }\n\n setFilterCategoryBits(categoryBits: number): void {\n this.m_filterCategoryBits = categoryBits;\n this.refilter();\n }\n\n getFilterMaskBits(): number {\n return this.m_filterMaskBits;\n }\n\n setFilterMaskBits(maskBits: number): void {\n this.m_filterMaskBits = maskBits;\n this.refilter();\n }\n\n /**\n * Call this if you want to establish collision that was previously disabled by\n * ContactFilter.\n */\n refilter(): void {\n if (this.m_body == null) {\n return;\n }\n\n // Flag associated contacts for filtering.\n let edge = this.m_body.getContactList();\n while (edge) {\n const contact = edge.contact;\n const fixtureA = contact.getFixtureA();\n const fixtureB = contact.getFixtureB();\n if (fixtureA == this || fixtureB == this) {\n contact.flagForFiltering();\n }\n\n edge = edge.next;\n }\n\n const world = this.m_body.getWorld();\n\n if (world == null) {\n return;\n }\n\n // Touch each proxy so that new pairs may be created\n const broadPhase = world.m_broadPhase;\n for (let i = 0; i < this.m_proxyCount; ++i) {\n broadPhase.touchProxy(this.m_proxies[i].proxyId);\n }\n }\n\n /**\n * Implement this method to provide collision filtering, if you want finer\n * control over contact creation.\n *\n * Return true if contact calculations should be performed between these two\n * fixtures.\n *\n * Warning: for performance reasons this is only called when the AABBs begin to\n * overlap.\n */\n shouldCollide(that: Fixture): boolean {\n\n if (that.m_filterGroupIndex === this.m_filterGroupIndex && that.m_filterGroupIndex !== 0) {\n return that.m_filterGroupIndex > 0;\n }\n\n const collideA = (that.m_filterMaskBits & this.m_filterCategoryBits) !== 0;\n const collideB = (that.m_filterCategoryBits & this.m_filterMaskBits) !== 0;\n const collide = collideA && collideB;\n return collide;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { options } from \"../util/options\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { Rot } from \"../common/Rot\";\nimport { Sweep } from \"../common/Sweep\";\nimport { Transform, TransformValue } from \"../common/Transform\";\nimport { Velocity } from \"./Velocity\";\nimport { Position } from \"./Position\";\nimport { Fixture, FixtureDef, FixtureOpt } from \"./Fixture\";\nimport { Shape } from \"../collision/Shape\";\nimport { JointEdge } from \"./Joint\";\nimport { World } from \"./World\";\nimport { ContactEdge } from \"./Contact\";\nimport { Style } from \"../util/Testbed\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A static body does not move under simulation and behaves as if it has infinite mass.\n * Internally, zero is stored for the mass and the inverse mass.\n * Static bodies can be moved manually by the user.\n * A static body has zero velocity.\n * Static bodies do not collide with other static or kinematic bodies.\n * \n * A kinematic body moves under simulation according to its velocity.\n * Kinematic bodies do not respond to forces.\n * They can be moved manually by the user, but normally a kinematic body is moved by setting its velocity.\n * A kinematic body behaves as if it has infinite mass, however, zero is stored for the mass and the inverse mass.\n * Kinematic bodies do not collide with other kinematic or static bodies.\n * \n * A dynamic body is fully simulated.\n * They can be moved manually by the user, but normally they move according to forces.\n * A dynamic body can collide with all body types.\n * A dynamic body always has finite, non-zero mass.\n * If you try to set the mass of a dynamic body to zero, it will automatically acquire a mass of one kilogram and it won't rotate.\n */\nexport type BodyType = \"static\" | \"kinematic\" | \"dynamic\";\n\n/** @internal */ const STATIC = \"static\";\n/** @internal */ const KINEMATIC = \"kinematic\";\n/** @internal */ const DYNAMIC = \"dynamic\";\n\n/** @internal */ const oldCenter = matrix.vec2(0, 0);\n/** @internal */ const localCenter = matrix.vec2(0, 0);\n/** @internal */ const shift = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n\nexport interface BodyDef {\n /**\n * Body types are static, kinematic, or dynamic. Note: if a dynamic\n * body would have zero mass, the mass is set to one.\n */\n type?: BodyType;\n /**\n * The world position of the body. Avoid creating bodies at the\n * origin since this can lead to many overlapping shapes.\n */\n position?: Vec2Value;\n /**\n * The world angle of the body in radians.\n */\n angle?: number;\n /**\n * The linear velocity of the body's origin in world co-ordinates.\n */\n linearVelocity?: Vec2Value;\n angularVelocity?: number;\n /**\n * Linear damping is use to reduce the linear velocity. The\n * damping parameter can be larger than 1.0 but the damping effect becomes\n * sensitive to the time step when the damping parameter is large.\n * Units are 1/time\n */\n linearDamping?: number;\n /**\n * Angular damping is use to reduce the angular velocity.\n * The damping parameter can be larger than 1.0 but the damping effect\n * becomes sensitive to the time step when the damping parameter is large.\n * Units are 1/time\n */\n angularDamping?: number;\n /**\n * Should this body be prevented from rotating? Useful for characters.\n */\n fixedRotation?: boolean;\n /**\n * Is this a fast moving body that should be prevented from\n * tunneling through other moving bodies? Note that all bodies are\n * prevented from tunneling through kinematic and static bodies. This\n * setting is only considered on dynamic bodies. Warning: You should use\n * this flag sparingly since it increases processing time.\n */\n bullet?: boolean;\n gravityScale?: number;\n /**\n * Set this flag to false if this body should never fall asleep. Note that this increases CPU usage.\n */\n allowSleep?: boolean;\n /**\n * Is this body initially awake or sleeping?\n */\n awake?: boolean;\n /**\n * Does this body start out active?\n */\n active?: boolean;\n userData?: any;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\n/** @internal */ const BodyDefDefault: BodyDef = {\n type : STATIC,\n position : Vec2.zero(),\n angle : 0.0,\n\n linearVelocity : Vec2.zero(),\n angularVelocity : 0.0,\n\n linearDamping : 0.0,\n angularDamping : 0.0,\n\n fixedRotation : false,\n bullet : false,\n gravityScale : 1.0,\n\n allowSleep : true,\n awake : true,\n active : true,\n\n userData : null\n};\n\n/**\n * MassData This holds the mass data computed for a shape.\n */\nexport interface MassData {\n /** The mass of the shape, usually in kilograms. */\n mass: number;\n /** The position of the shape's centroid relative to the shape's origin. */\n center: Vec2Value;\n /** The rotational inertia of the shape about the local origin. */\n I: number;\n}\n\n/**\n * A rigid body composed of one or more fixtures.\n *\n * To create a new Body use {@link World.createBody}.\n */\nexport class Body {\n /** @hidden */\n static readonly STATIC: BodyType = \"static\";\n /** @hidden */\n static readonly KINEMATIC: BodyType = \"kinematic\";\n /** @hidden */\n static readonly DYNAMIC: BodyType = \"dynamic\";\n\n /** @internal */ m_world: World;\n /** @internal */ m_awakeFlag: boolean;\n /** @internal */ m_autoSleepFlag: boolean;\n /** @internal */ m_bulletFlag: boolean;\n /** @internal */ m_fixedRotationFlag: boolean;\n /** @internal */ m_activeFlag: boolean;\n /** @internal */ m_islandFlag: boolean;\n /** @internal */ m_toiFlag: boolean;\n /** @internal */ m_userData: unknown;\n /** @internal */ m_type: BodyType;\n /** @internal */ m_mass: number;\n /** @internal */ m_invMass: number;\n /** @internal Rotational inertia about the center of mass. */\n m_I: number;\n /** @internal */ m_invI: number;\n /** @internal the body origin transform */\n m_xf: Transform;\n /** @internal the swept motion for CCD */\n m_sweep: Sweep;\n // position and velocity correction\n /** @internal */ c_velocity: Velocity;\n /** @internal */ c_position: Position;\n /** @internal */ m_force: Vec2;\n /** @internal */ m_torque: number;\n /** @internal */ m_linearVelocity: Vec2;\n /** @internal */ m_angularVelocity: number;\n /** @internal */ m_linearDamping: number;\n /** @internal */ m_angularDamping: number;\n /** @internal */ m_gravityScale: number;\n /** @internal */ m_sleepTime: number;\n /** @internal */ m_jointList: JointEdge | null;\n /** @internal */ m_contactList: ContactEdge | null;\n /** @internal */ m_fixtureList: Fixture | null;\n /** @internal */ m_prev: Body | null;\n /** @internal */ m_next: Body | null;\n /** @internal */ m_destroyed: boolean;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n /** @internal */\n constructor(world: World, def: BodyDef) {\n def = options(def, BodyDefDefault);\n\n if (_ASSERT) console.assert(Vec2.isValid(def.position));\n if (_ASSERT) console.assert(Vec2.isValid(def.linearVelocity));\n if (_ASSERT) console.assert(Number.isFinite(def.angle));\n if (_ASSERT) console.assert(Number.isFinite(def.angularVelocity));\n if (_ASSERT) console.assert(Number.isFinite(def.angularDamping) && def.angularDamping >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.linearDamping) && def.linearDamping >= 0.0);\n\n this.m_world = world;\n\n this.m_awakeFlag = def.awake;\n this.m_autoSleepFlag = def.allowSleep;\n this.m_bulletFlag = def.bullet;\n this.m_fixedRotationFlag = def.fixedRotation;\n this.m_activeFlag = def.active;\n\n this.m_islandFlag = false;\n this.m_toiFlag = false;\n\n this.m_userData = def.userData;\n this.m_type = def.type;\n\n if (this.m_type == DYNAMIC) {\n this.m_mass = 1.0;\n this.m_invMass = 1.0;\n } else {\n this.m_mass = 0.0;\n this.m_invMass = 0.0;\n }\n\n // Rotational inertia about the center of mass.\n this.m_I = 0.0;\n this.m_invI = 0.0;\n\n // the body origin transform\n this.m_xf = Transform.identity();\n this.m_xf.p.setVec2(def.position);\n this.m_xf.q.setAngle(def.angle);\n\n // the swept motion for CCD\n this.m_sweep = new Sweep();\n this.m_sweep.setTransform(this.m_xf);\n\n // position and velocity correction\n this.c_velocity = new Velocity();\n this.c_position = new Position();\n\n this.m_force = Vec2.zero();\n this.m_torque = 0.0;\n\n this.m_linearVelocity = Vec2.clone(def.linearVelocity);\n this.m_angularVelocity = def.angularVelocity;\n\n this.m_linearDamping = def.linearDamping;\n this.m_angularDamping = def.angularDamping;\n this.m_gravityScale = def.gravityScale;\n\n this.m_sleepTime = 0.0;\n\n this.m_jointList = null;\n this.m_contactList = null;\n this.m_fixtureList = null;\n\n this.m_prev = null;\n this.m_next = null;\n\n this.m_destroyed = false;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /** @internal */\n _serialize(): object {\n const fixtures = [];\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n fixtures.push(f);\n }\n return {\n type: this.m_type,\n bullet: this.m_bulletFlag,\n position: this.m_xf.p,\n angle: this.m_xf.q.getAngle(),\n linearVelocity: this.m_linearVelocity,\n angularVelocity: this.m_angularVelocity,\n fixtures,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): Body {\n const body = new Body(world, data);\n\n if (data.fixtures) {\n for (let i = data.fixtures.length - 1; i >= 0; i--) {\n const fixture = restore(Fixture, data.fixtures[i], body);\n body._addFixture(fixture);\n }\n }\n return body;\n }\n\n isWorldLocked(): boolean {\n return this.m_world && this.m_world.isLocked() ? true : false;\n }\n\n getWorld(): World {\n return this.m_world;\n }\n\n getNext(): Body | null {\n return this.m_next;\n }\n\n setUserData(data: any): void {\n this.m_userData = data;\n }\n\n getUserData(): unknown {\n return this.m_userData;\n }\n\n getFixtureList(): Fixture | null {\n return this.m_fixtureList;\n }\n\n getJointList(): JointEdge | null {\n return this.m_jointList;\n }\n\n /**\n * Warning: this list changes during the time step and you may miss some\n * collisions if you don't use ContactListener.\n */\n getContactList(): ContactEdge | null {\n return this.m_contactList;\n }\n\n isStatic(): boolean {\n return this.m_type == STATIC;\n }\n\n isDynamic(): boolean {\n return this.m_type == DYNAMIC;\n }\n\n isKinematic(): boolean {\n return this.m_type == KINEMATIC;\n }\n\n /**\n * This will alter the mass and velocity.\n */\n setStatic(): Body {\n this.setType(STATIC);\n return this;\n }\n\n setDynamic(): Body {\n this.setType(DYNAMIC);\n return this;\n }\n\n setKinematic(): Body {\n this.setType(KINEMATIC);\n return this;\n }\n\n /**\n * Get the type of the body.\n */\n getType(): BodyType {\n return this.m_type;\n }\n\n /**\n * Set the type of the body to \"static\", \"kinematic\" or \"dynamic\".\n * @param type The type of the body.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n setType(type: BodyType): void {\n if (_ASSERT) console.assert(type === STATIC || type === KINEMATIC || type === DYNAMIC);\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (this.m_type == type) {\n return;\n }\n\n this.m_type = type;\n\n this.resetMassData();\n\n if (this.m_type == STATIC) {\n this.m_linearVelocity.setZero();\n this.m_angularVelocity = 0.0;\n this.m_sweep.forward();\n this.synchronizeFixtures();\n }\n\n this.setAwake(true);\n\n this.m_force.setZero();\n this.m_torque = 0.0;\n\n // Delete the attached contacts.\n let ce = this.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n this.m_world.destroyContact(ce0.contact);\n }\n this.m_contactList = null;\n\n // Touch the proxies so that new contacts will be created (when appropriate)\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n for (let i = 0; i < f.m_proxyCount; ++i) {\n broadPhase.touchProxy(f.m_proxies[i].proxyId);\n }\n }\n }\n\n isBullet(): boolean {\n return this.m_bulletFlag;\n }\n\n /**\n * Should this body be treated like a bullet for continuous collision detection?\n */\n setBullet(flag: boolean): void {\n this.m_bulletFlag = !!flag;\n }\n\n isSleepingAllowed(): boolean {\n return this.m_autoSleepFlag;\n }\n\n setSleepingAllowed(flag: boolean): void {\n this.m_autoSleepFlag = !!flag;\n if (this.m_autoSleepFlag == false) {\n this.setAwake(true);\n }\n }\n\n isAwake(): boolean {\n return this.m_awakeFlag;\n }\n\n /**\n * Set the sleep state of the body. A sleeping body has very low CPU cost.\n *\n * @param flag Set to true to wake the body, false to put it to sleep.\n */\n setAwake(flag: boolean): void {\n if (flag) {\n this.m_awakeFlag = true;\n this.m_sleepTime = 0.0;\n } else {\n this.m_awakeFlag = false;\n this.m_sleepTime = 0.0;\n this.m_linearVelocity.setZero();\n this.m_angularVelocity = 0.0;\n this.m_force.setZero();\n this.m_torque = 0.0;\n }\n }\n\n isActive(): boolean {\n return this.m_activeFlag;\n }\n\n /**\n * Set the active state of the body. An inactive body is not simulated and\n * cannot be collided with or woken up. If you pass a flag of true, all fixtures\n * will be added to the broad-phase. If you pass a flag of false, all fixtures\n * will be removed from the broad-phase and all contacts will be destroyed.\n * Fixtures and joints are otherwise unaffected.\n *\n * You may continue to create/destroy fixtures and joints on inactive bodies.\n * Fixtures on an inactive body are implicitly inactive and will not participate\n * in collisions, ray-casts, or queries. Joints connected to an inactive body\n * are implicitly inactive. An inactive body is still owned by a World object\n * and remains\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n setActive(flag: boolean): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (flag == this.m_activeFlag) {\n return;\n }\n\n this.m_activeFlag = !!flag;\n\n if (this.m_activeFlag) {\n // Create all proxies.\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.createProxies(broadPhase, this.m_xf);\n }\n\t\t // Contacts are created at the beginning of the next\n\t\t this.m_world.m_newFixture = true;\n } else {\n // Destroy all proxies.\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.destroyProxies(broadPhase);\n }\n\n // Destroy the attached contacts.\n let ce = this.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n this.m_world.destroyContact(ce0.contact);\n }\n this.m_contactList = null;\n }\n }\n\n isFixedRotation(): boolean {\n return this.m_fixedRotationFlag;\n }\n\n /**\n * Set this body to have fixed rotation. This causes the mass to be reset.\n */\n setFixedRotation(flag: boolean): void {\n if (this.m_fixedRotationFlag == flag) {\n return;\n }\n\n this.m_fixedRotationFlag = !!flag;\n\n this.m_angularVelocity = 0.0;\n\n this.resetMassData();\n }\n\n /**\n * Get the world transform for the body's origin.\n */\n getTransform(): Transform {\n return this.m_xf;\n }\n\n /**\n * Set the position of the body's origin and rotation. Manipulating a body's\n * transform may cause non-physical behavior. Note: contacts are updated on the\n * next call to World.step.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n *\n * @param position The world position of the body's local origin.\n * @param angle The world rotation in radians.\n */\n setTransform(position: Vec2Value, angle: number): void;\n /**\n * Set the position of the body's origin and rotation. Manipulating a body's\n * transform may cause non-physical behavior. Note: contacts are updated on the\n * next call to World.step.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n setTransform(xf: Transform): void;\n setTransform(a: Vec2Value | Transform, b?: number): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return;\n }\n if (typeof b === \"number\") {\n this.m_xf.setNum(a as Vec2Value, b);\n } else {\n this.m_xf.setTransform(a as TransformValue);\n }\n\n this.m_sweep.setTransform(this.m_xf);\n\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.synchronize(broadPhase, this.m_xf, this.m_xf);\n }\n this.setAwake(true);\n }\n\n synchronizeTransform(): void {\n this.m_sweep.getTransform(this.m_xf, 1);\n }\n\n /**\n * Update fixtures in broad-phase.\n */\n synchronizeFixtures(): void {\n this.m_sweep.getTransform(xf, 0);\n\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.synchronize(broadPhase, xf, this.m_xf);\n }\n }\n\n /**\n * Used in TOI.\n */\n advance(alpha: number): void {\n // Advance to the new safe time. This doesn't sync the broad-phase.\n this.m_sweep.advance(alpha);\n matrix.copyVec2(this.m_sweep.c, this.m_sweep.c0);\n this.m_sweep.a = this.m_sweep.a0;\n this.m_sweep.getTransform(this.m_xf, 1);\n }\n\n /**\n * Get the world position for the body's origin.\n */\n getPosition(): Vec2 {\n return this.m_xf.p;\n }\n\n setPosition(p: Vec2Value): void {\n this.setTransform(p, this.m_sweep.a);\n }\n\n /**\n * Get the current world rotation angle in radians.\n */\n getAngle(): number {\n return this.m_sweep.a;\n }\n\n setAngle(angle: number): void {\n this.setTransform(this.m_xf.p, angle);\n }\n\n /**\n * Get the world position of the center of mass.\n */\n getWorldCenter(): Vec2 {\n return this.m_sweep.c;\n }\n\n /**\n * Get the local position of the center of mass.\n */\n getLocalCenter(): Vec2 {\n return this.m_sweep.localCenter;\n }\n\n /**\n * Get the linear velocity of the center of mass.\n *\n * @return the linear velocity of the center of mass.\n */\n getLinearVelocity(): Vec2 {\n return this.m_linearVelocity;\n }\n\n /**\n * Get the world linear velocity of a world point attached to this body.\n *\n * @param worldPoint A point in world coordinates.\n */\n getLinearVelocityFromWorldPoint(worldPoint: Vec2Value): Vec2 {\n const localCenter = Vec2.sub(worldPoint, this.m_sweep.c);\n return Vec2.add(this.m_linearVelocity, Vec2.crossNumVec2(this.m_angularVelocity,\n localCenter));\n }\n\n /**\n * Get the world velocity of a local point.\n *\n * @param localPoint A point in local coordinates.\n */\n getLinearVelocityFromLocalPoint(localPoint: Vec2Value): Vec2 {\n return this.getLinearVelocityFromWorldPoint(this.getWorldPoint(localPoint));\n }\n\n /**\n * Set the linear velocity of the center of mass.\n *\n * @param v The new linear velocity of the center of mass.\n */\n setLinearVelocity(v: Vec2Value): void {\n if (this.m_type == STATIC) {\n return;\n }\n if (Vec2.dot(v, v) > 0.0) {\n this.setAwake(true);\n }\n this.m_linearVelocity.setVec2(v);\n }\n\n /**\n * Get the angular velocity.\n *\n * @returns the angular velocity in radians/second.\n */\n getAngularVelocity(): number {\n return this.m_angularVelocity;\n }\n\n /**\n * Set the angular velocity.\n *\n * @param w The new angular velocity in radians/second.\n */\n setAngularVelocity(w: number): void {\n if (this.m_type == STATIC) {\n return;\n }\n if (w * w > 0.0) {\n this.setAwake(true);\n }\n this.m_angularVelocity = w;\n }\n\n getLinearDamping(): number {\n return this.m_linearDamping;\n }\n\n setLinearDamping(linearDamping: number): void {\n this.m_linearDamping = linearDamping;\n }\n\n getAngularDamping(): number {\n return this.m_angularDamping;\n }\n\n setAngularDamping(angularDamping: number): void {\n this.m_angularDamping = angularDamping;\n }\n\n getGravityScale(): number {\n return this.m_gravityScale;\n }\n\n /**\n * Scale the gravity applied to this body.\n */\n setGravityScale(scale: number): void {\n this.m_gravityScale = scale;\n }\n\n /**\n * Get the total mass of the body.\n *\n * @returns The mass, usually in kilograms (kg).\n */\n getMass(): number {\n return this.m_mass;\n }\n\n /**\n * Get the rotational inertia of the body about the local origin.\n *\n * @return the rotational inertia, usually in kg-m^2.\n */\n getInertia(): number {\n return this.m_I + this.m_mass\n * Vec2.dot(this.m_sweep.localCenter, this.m_sweep.localCenter);\n }\n\n /**\n * Copy the mass data of the body to data.\n */\n getMassData(data: MassData): void {\n data.mass = this.m_mass;\n data.I = this.getInertia();\n matrix.copyVec2(data.center, this.m_sweep.localCenter);\n }\n\n /**\n * This resets the mass properties to the sum of the mass properties of the\n * fixtures. This normally does not need to be called unless you called\n * SetMassData to override the mass and you later want to reset the mass.\n */\n resetMassData(): void {\n // Compute mass data from shapes. Each shape has its own density.\n this.m_mass = 0.0;\n this.m_invMass = 0.0;\n this.m_I = 0.0;\n this.m_invI = 0.0;\n matrix.zeroVec2(this.m_sweep.localCenter);\n\n // Static and kinematic bodies have zero mass.\n if (this.isStatic() || this.isKinematic()) {\n matrix.copyVec2(this.m_sweep.c0, this.m_xf.p);\n matrix.copyVec2(this.m_sweep.c, this.m_xf.p);\n this.m_sweep.a0 = this.m_sweep.a;\n return;\n }\n\n if (_ASSERT) console.assert(this.isDynamic());\n\n // Accumulate mass over all fixtures.\n matrix.zeroVec2(localCenter);\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n if (f.m_density == 0.0) {\n continue;\n }\n\n const massData: MassData = {\n mass: 0,\n center: matrix.vec2(0, 0),\n I: 0\n };\n f.getMassData(massData);\n this.m_mass += massData.mass;\n matrix.plusScaleVec2(localCenter, massData.mass, massData.center);\n this.m_I += massData.I;\n }\n\n // Compute center of mass.\n if (this.m_mass > 0.0) {\n this.m_invMass = 1.0 / this.m_mass;\n matrix.scaleVec2(localCenter, this.m_invMass, localCenter);\n\n } else {\n // Force all dynamic bodies to have a positive mass.\n this.m_mass = 1.0;\n this.m_invMass = 1.0;\n }\n\n if (this.m_I > 0.0 && this.m_fixedRotationFlag == false) {\n // Center the inertia about the center of mass.\n this.m_I -= this.m_mass * matrix.dotVec2(localCenter, localCenter);\n if (_ASSERT) console.assert(this.m_I > 0.0);\n this.m_invI = 1.0 / this.m_I;\n\n } else {\n this.m_I = 0.0;\n this.m_invI = 0.0;\n }\n\n // Move center of mass.\n matrix.copyVec2(oldCenter, this.m_sweep.c);\n this.m_sweep.setLocalCenter(localCenter, this.m_xf);\n\n // Update center of mass velocity.\n matrix.subVec2(shift, this.m_sweep.c, oldCenter);\n matrix.crossNumVec2(temp, this.m_angularVelocity, shift);\n matrix.plusVec2(this.m_linearVelocity, temp);\n }\n\n /**\n * Set the mass properties to override the mass properties of the fixtures. Note\n * that this changes the center of mass position. Note that creating or\n * destroying fixtures can also alter the mass. This function has no effect if\n * the body isn't dynamic.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n *\n * @param massData The mass properties.\n */\n setMassData(massData: MassData): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (this.m_type != DYNAMIC) {\n return;\n }\n\n this.m_invMass = 0.0;\n this.m_I = 0.0;\n this.m_invI = 0.0;\n\n this.m_mass = massData.mass;\n if (this.m_mass <= 0.0) {\n this.m_mass = 1.0;\n }\n\n this.m_invMass = 1.0 / this.m_mass;\n\n if (massData.I > 0.0 && this.m_fixedRotationFlag == false) {\n this.m_I = massData.I - this.m_mass * matrix.dotVec2(massData.center, massData.center);\n if (_ASSERT) console.assert(this.m_I > 0.0);\n this.m_invI = 1.0 / this.m_I;\n }\n\n // Move center of mass.\n matrix.copyVec2(oldCenter, this.m_sweep.c);\n this.m_sweep.setLocalCenter(massData.center, this.m_xf);\n\n // Update center of mass velocity.\n matrix.subVec2(shift, this.m_sweep.c, oldCenter);\n matrix.crossNumVec2(temp, this.m_angularVelocity, shift);\n matrix.plusVec2(this.m_linearVelocity, temp);\n }\n\n /**\n * Apply a force at a world point. If the force is not applied at the center of\n * mass, it will generate a torque and affect the angular velocity. This wakes\n * up the body.\n *\n * @param force The world force vector, usually in Newtons (N).\n * @param point The world position of the point of application.\n * @param wake Also wake up the body\n */\n applyForce(force: Vec2Value, point: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping.\n if (this.m_awakeFlag) {\n this.m_force.add(force);\n this.m_torque += Vec2.crossVec2Vec2(Vec2.sub(point, this.m_sweep.c), force);\n }\n }\n\n /**\n * Apply a force to the center of mass. This wakes up the body.\n *\n * @param force The world force vector, usually in Newtons (N).\n * @param wake Also wake up the body\n */\n applyForceToCenter(force: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_force.add(force);\n }\n }\n\n /**\n * Apply a torque. This affects the angular velocity without affecting the\n * linear velocity of the center of mass. This wakes up the body.\n *\n * @param torque About the z-axis (out of the screen), usually in N-m.\n * @param wake Also wake up the body\n */\n applyTorque(torque: number, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_torque += torque;\n }\n }\n\n /**\n * Apply an impulse at a point. This immediately modifies the velocity. It also\n * modifies the angular velocity if the point of application is not at the\n * center of mass. This wakes up the body.\n *\n * @param impulse The world impulse vector, usually in N-seconds or kg-m/s.\n * @param point The world position of the point of application.\n * @param wake Also wake up the body\n */\n applyLinearImpulse(impulse: Vec2Value, point: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n\n // Don't accumulate velocity if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_linearVelocity.addMul(this.m_invMass, impulse);\n this.m_angularVelocity += this.m_invI * Vec2.crossVec2Vec2(Vec2.sub(point, this.m_sweep.c), impulse);\n }\n }\n\n /**\n * Apply an angular impulse.\n *\n * @param impulse The angular impulse in units of kg*m*m/s\n * @param wake Also wake up the body\n */\n applyAngularImpulse(impulse: number, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate velocity if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_angularVelocity += this.m_invI * impulse;\n }\n }\n\n /**\n * This is used to test if two bodies should collide.\n * \n * Bodies do not collide when:\n * - Neither of them is dynamic\n * - They are connected by a joint with collideConnected == false\n */\n shouldCollide(that: Body): boolean {\n // At least one body should be dynamic.\n if (this.m_type != DYNAMIC && that.m_type != DYNAMIC) {\n return false;\n }\n // Does a joint prevent collision?\n for (let jn = this.m_jointList; jn; jn = jn.next) {\n if (jn.other == that) {\n if (jn.joint.m_collideConnected == false) {\n return false;\n }\n }\n }\n return true;\n }\n\n /** @internal Used for deserialize. */\n _addFixture(fixture: Fixture): Fixture {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return null;\n }\n\n if (this.m_activeFlag) {\n const broadPhase = this.m_world.m_broadPhase;\n fixture.createProxies(broadPhase, this.m_xf);\n }\n\n fixture.m_next = this.m_fixtureList;\n this.m_fixtureList = fixture;\n\n // Adjust mass properties if needed.\n if (fixture.m_density > 0.0) {\n this.resetMassData();\n }\n\n // Let the world know we have a new fixture. This will cause new contacts\n // to be created at the beginning of the next time step.\n this.m_world.m_newFixture = true;\n\n return fixture;\n }\n\n /**\n * Creates a fixture and attach it to this body.\n *\n * If the density is non-zero, this function automatically updates the mass of\n * the body.\n *\n * Contacts are not created until the next time step.\n *\n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n createFixture(def: FixtureDef): Fixture;\n createFixture(shape: Shape, opt?: FixtureOpt): Fixture;\n createFixture(shape: Shape, density?: number): Fixture;\n // tslint:disable-next-line:typedef\n createFixture(shape, fixdef?) {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return null;\n }\n\n const fixture = new Fixture(this, shape, fixdef);\n this._addFixture(fixture);\n return fixture;\n }\n\n /**\n * Destroy a fixture. This removes the fixture from the broad-phase and destroys\n * all contacts associated with this fixture. This will automatically adjust the\n * mass of the body if the body is dynamic and the fixture has positive density.\n * All fixtures attached to a body are implicitly destroyed when the body is\n * destroyed.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n *\n * @param fixture The fixture to be removed.\n */\n destroyFixture(fixture: Fixture): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (_ASSERT) console.assert(fixture.m_body == this);\n\n // Remove the fixture from this body's singly linked list.\n let found = false;\n if (this.m_fixtureList === fixture) {\n this.m_fixtureList = fixture.m_next;\n found = true;\n\n } else {\n let node = this.m_fixtureList;\n while (node != null) {\n if (node.m_next === fixture) {\n node.m_next = fixture.m_next;\n found = true;\n break;\n }\n node = node.m_next;\n }\n }\n\n // You tried to remove a shape that is not attached to this body.\n if (_ASSERT) console.assert(found);\n\n // Destroy any contacts associated with the fixture.\n let edge = this.m_contactList;\n while (edge) {\n const c = edge.contact;\n edge = edge.next;\n\n const fixtureA = c.getFixtureA();\n const fixtureB = c.getFixtureB();\n\n if (fixture == fixtureA || fixture == fixtureB) {\n // This destroys the contact and removes it from\n // this body's contact list.\n this.m_world.destroyContact(c);\n }\n }\n\n if (this.m_activeFlag) {\n const broadPhase = this.m_world.m_broadPhase;\n fixture.destroyProxies(broadPhase);\n }\n\n fixture.m_body = null;\n fixture.m_next = null;\n\n this.m_world.publish(\"remove-fixture\", fixture);\n\n // Reset the mass data.\n this.resetMassData();\n }\n\n /**\n * Get the corresponding world point of a local point.\n */\n getWorldPoint(localPoint: Vec2Value): Vec2 {\n return Transform.mulVec2(this.m_xf, localPoint);\n }\n\n /**\n * Get the corresponding world vector of a local vector.\n */\n getWorldVector(localVector: Vec2Value): Vec2 {\n return Rot.mulVec2(this.m_xf.q, localVector);\n }\n\n /**\n * Gets the corresponding local point of a world point.\n */\n getLocalPoint(worldPoint: Vec2Value): Vec2 {\n return Transform.mulTVec2(this.m_xf, worldPoint);\n }\n\n /**\n * Gets the corresponding local vector of a world vector.\n */\n getLocalVector(worldVector: Vec2Value): Vec2 {\n return Rot.mulTVec2(this.m_xf.q, worldVector);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { Vec2, Vec2Value } from \"../common/Vec2\";\nimport type { Body } from \"./Body\";\nimport { TimeStep } from \"./Solver\";\nimport { Style } from \"../util/Testbed\";\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/**\n * A joint edge is used to connect bodies and joints together in a joint graph\n * where each body is a node and each joint is an edge. A joint edge belongs to\n * a doubly linked list maintained in each attached body. Each joint has two\n * joint nodes, one for each attached body.\n */\nexport class JointEdge {\n /**\n * provides quick access to the other body attached.\n */\n other: Body | null = null;\n /**\n * the joint\n */\n joint: Joint | null = null;\n /**\n * prev the previous joint edge in the body's joint list\n */\n prev: JointEdge | null = null;\n /**\n * the next joint edge in the body's joint list\n */\n next: JointEdge | null = null;\n}\n\n/**\n * Joint definitions are used to construct joints.\n */\nexport interface JointOpt {\n /**\n * Use this to attach application specific data to your joints.\n */\n userData?: any;\n /**\n * Set this flag to true if the attached bodies\n * should collide.\n */\n collideConnected?: boolean;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\n/**\n * Joint definitions are used to construct joints.\n */\nexport interface JointDef extends JointOpt {\n /**\n * The first attached body.\n */\n bodyA: Body;\n /**\n * The second attached body.\n */\n bodyB: Body;\n}\n\n/** @internal */ const DEFAULTS = {\n userData : null,\n collideConnected : false\n};\n\n/**\n * The base joint class. Joints are used to constraint two bodies together in\n * various fashions. Some joints also feature limits and motors.\n */\nexport abstract class Joint {\n\n /** @internal */ m_type: string = \"unknown-joint\";\n\n /** @internal */ m_bodyA: Body;\n /** @internal */ m_bodyB: Body;\n\n /** @internal */ m_collideConnected: boolean;\n\n /** @internal */ m_prev: Joint | null = null;\n /** @internal */ m_next: Joint | null = null;\n\n /** @internal */ m_edgeA: JointEdge = new JointEdge();\n /** @internal */ m_edgeB: JointEdge = new JointEdge();\n\n /** @internal */ m_islandFlag: boolean = false;\n /** @internal */ m_userData: unknown;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n constructor(def: JointDef);\n constructor(def: JointOpt, bodyA: Body, bodyB: Body);\n constructor(def: JointDef | JointOpt, bodyA?: Body, bodyB?: Body) {\n bodyA = \"bodyA\" in def ? def.bodyA : bodyA;\n bodyB = \"bodyB\" in def ? def.bodyB : bodyB;\n\n if (_ASSERT) console.assert(!!bodyA);\n if (_ASSERT) console.assert(!!bodyB);\n if (_ASSERT) console.assert(bodyA != bodyB);\n\n this.m_bodyA = bodyA!;\n this.m_bodyB = bodyB!;\n\n this.m_collideConnected = !!def.collideConnected;\n this.m_userData = def.userData;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /**\n * Short-cut function to determine if either body is inactive.\n */\n isActive(): boolean {\n return this.m_bodyA.isActive() && this.m_bodyB.isActive();\n }\n\n /**\n * Get the type of the concrete joint.\n */\n getType(): string {\n return this.m_type;\n }\n\n /**\n * Get the first body attached to this joint.\n */\n getBodyA(): Body {\n return this.m_bodyA;\n }\n\n /**\n * Get the second body attached to this joint.\n */\n getBodyB(): Body {\n return this.m_bodyB;\n }\n\n /**\n * Get the next joint the world joint list.\n */\n getNext(): Joint {\n return this.m_next;\n }\n\n getUserData(): unknown {\n return this.m_userData;\n }\n\n setUserData(data: unknown): void {\n this.m_userData = data;\n }\n\n /**\n * Get collide connected. Note: modifying the collide connect flag won't work\n * correctly because the flag is only checked when fixture AABBs begin to\n * overlap.\n */\n getCollideConnected(): boolean {\n return this.m_collideConnected;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n abstract getAnchorA(): Vec2;\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n abstract getAnchorB(): Vec2;\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n abstract getReactionForce(inv_dt: number): Vec2;\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n abstract getReactionTorque(inv_dt: number): number;\n\n /**\n * Shift the origin for any points stored in world coordinates.\n */\n shiftOrigin(newOrigin: Vec2Value): void {}\n\n abstract initVelocityConstraints(step: TimeStep): void;\n\n abstract solveVelocityConstraints(step: TimeStep): void;\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n abstract solvePositionConstraints(step: TimeStep): boolean;\n\n /**\n * @hidden @experimental\n * Update joint with new props.\n */\n abstract _reset(def: Partial): void;\n\n /**\n * @internal @deprecated\n * Temporary for backward compatibility, will be removed.\n */\n _resetAnchors(def: any): void {\n return this._reset(def);\n }\n}\n","/** @hidden */\nexport const stats = {\n gjkCalls: 0,\n gjkIters: 0,\n gjkMaxIters: 0,\n\n toiTime: 0,\n toiMaxTime: 0,\n toiCalls: 0,\n toiIters: 0,\n toiMaxIters: 0,\n toiRootIters: 0,\n toiMaxRootIters: 0,\n\n toString(newline?: string): string {\n newline = typeof newline === \"string\" ? newline : \"\\n\";\n let string = \"\";\n // tslint:disable-next-line:no-for-in\n for (const name in this) {\n if (typeof this[name] !== \"function\" && typeof this[name] !== \"object\") {\n string += name + \": \" + this[name] + newline;\n }\n }\n return string;\n }\n};\n","/** @internal */\nexport const now = function(): number {\n return Date.now();\n};\n\n/** @internal */\nexport const diff = function(time: number): number {\n return Date.now() - time;\n};\n\n/** @internal */\nexport default {\n now,\n diff,\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { stats } from \"../util/stats\";\nimport { Shape } from \"./Shape\";\nimport { EPSILON } from \"../common/Math\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { Rot } from \"../common/Rot\";\nimport { Transform, TransformValue } from \"../common/Transform\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_max = Math.max;\n\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const e12 = matrix.vec2(0, 0);\n/** @internal */ const e13 = matrix.vec2(0, 0);\n/** @internal */ const e23 = matrix.vec2(0, 0);\n/** @internal */ const temp1 = matrix.vec2(0, 0);\n/** @internal */ const temp2 = matrix.vec2(0, 0);\n\n/**\n * GJK using Voronoi regions (Christer Ericson) and Barycentric coordinates.\n */\n\nstats.gjkCalls = 0;\nstats.gjkIters = 0;\nstats.gjkMaxIters = 0;\n\n/**\n * Input for Distance. You have to option to use the shape radii in the\n * computation. Even\n */\nexport class DistanceInput {\n readonly proxyA = new DistanceProxy();\n readonly proxyB = new DistanceProxy();\n readonly transformA = Transform.identity();\n readonly transformB = Transform.identity();\n useRadii = false;\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.transformA.setIdentity();\n this.transformB.setIdentity();\n this.useRadii = false;\n }\n}\n\n/**\n * Output for Distance.\n */\nexport class DistanceOutput {\n /** closest point on shapeA */\n pointA = matrix.vec2(0, 0);\n /** closest point on shapeB */\n pointB = matrix.vec2(0, 0);\n distance = 0;\n /** iterations number of GJK iterations used */\n iterations = 0;\n recycle() {\n matrix.zeroVec2(this.pointA);\n matrix.zeroVec2(this.pointB);\n this.distance = 0;\n this.iterations = 0;\n }\n}\n\n/**\n * Used to warm start Distance. Set count to zero on first call.\n */\nexport class SimplexCache {\n /** length or area */\n metric: number = 0;\n /** vertices on shape A */\n indexA: number[] = [];\n /** vertices on shape B */\n indexB: number[] = [];\n count: number = 0;\n recycle() {\n this.metric = 0;\n this.indexA.length = 0;\n this.indexB.length = 0;\n this.count = 0;\n }\n}\n\n/**\n * Compute the closest points between two shapes. Supports any combination of:\n * CircleShape, PolygonShape, EdgeShape. The simplex cache is input/output. On\n * the first call set SimplexCache.count to zero.\n */\nexport const Distance = function (output: DistanceOutput, cache: SimplexCache, input: DistanceInput): void {\n ++stats.gjkCalls;\n\n const proxyA = input.proxyA;\n const proxyB = input.proxyB;\n const xfA = input.transformA;\n const xfB = input.transformB;\n\n // Initialize the simplex.\n // const simplex = new Simplex();\n simplex.recycle();\n simplex.readCache(cache, proxyA, xfA, proxyB, xfB);\n\n // Get simplex vertices as an array.\n const vertices = simplex.m_v;\n const k_maxIters = Settings.maxDistanceIterations;\n\n // These store the vertices of the last simplex so that we\n // can check for duplicates and prevent cycling.\n const saveA = [];\n const saveB = []; // int[3]\n let saveCount = 0;\n\n // Main iteration loop.\n let iter = 0;\n while (iter < k_maxIters) {\n // Copy simplex so we can identify duplicates.\n saveCount = simplex.m_count;\n for (let i = 0; i < saveCount; ++i) {\n saveA[i] = vertices[i].indexA;\n saveB[i] = vertices[i].indexB;\n }\n\n simplex.solve();\n\n // If we have 3 points, then the origin is in the corresponding triangle.\n if (simplex.m_count === 3) {\n break;\n }\n\n // Get search direction.\n const d = simplex.getSearchDirection();\n\n // Ensure the search direction is numerically fit.\n if (matrix.lengthSqrVec2(d) < EPSILON * EPSILON) {\n // The origin is probably contained by a line segment\n // or triangle. Thus the shapes are overlapped.\n\n // We can't return zero here even though there may be overlap.\n // In case the simplex is a point, segment, or triangle it is difficult\n // to determine if the origin is contained in the CSO or very close to it.\n break;\n }\n\n // Compute a tentative new simplex vertex using support points.\n const vertex = vertices[simplex.m_count]; // SimplexVertex\n\n vertex.indexA = proxyA.getSupport(matrix.derotVec2(temp, xfA.q, matrix.scaleVec2(temp, -1, d)));\n matrix.transformVec2(vertex.wA, xfA, proxyA.getVertex(vertex.indexA));\n\n vertex.indexB = proxyB.getSupport(matrix.derotVec2(temp, xfB.q, d));\n matrix.transformVec2(vertex.wB, xfB, proxyB.getVertex(vertex.indexB));\n\n matrix.subVec2(vertex.w, vertex.wB, vertex.wA);\n\n // Iteration count is equated to the number of support point calls.\n ++iter;\n ++stats.gjkIters;\n\n // Check for duplicate support points. This is the main termination\n // criteria.\n let duplicate = false;\n for (let i = 0; i < saveCount; ++i) {\n if (vertex.indexA === saveA[i] && vertex.indexB === saveB[i]) {\n duplicate = true;\n break;\n }\n }\n\n // If we found a duplicate support point we must exit to avoid cycling.\n if (duplicate) {\n break;\n }\n\n // New vertex is ok and needed.\n ++simplex.m_count;\n }\n\n stats.gjkMaxIters = math_max(stats.gjkMaxIters, iter);\n\n // Prepare output.\n simplex.getWitnessPoints(output.pointA, output.pointB);\n output.distance = matrix.distVec2(output.pointA, output.pointB);\n output.iterations = iter;\n\n // Cache the simplex.\n simplex.writeCache(cache);\n\n // Apply radii if requested.\n if (input.useRadii) {\n const rA = proxyA.m_radius;\n const rB = proxyB.m_radius;\n\n if (output.distance > rA + rB && output.distance > EPSILON) {\n // Shapes are still no overlapped.\n // Move the witness points to the outer surface.\n output.distance -= rA + rB;\n matrix.subVec2(normal, output.pointB, output.pointA);\n matrix.normalizeVec2(normal);\n matrix.plusScaleVec2(output.pointA, rA, normal);\n matrix.minusScaleVec2(output.pointB, rB, normal);\n } else {\n // Shapes are overlapped when radii are considered.\n // Move the witness points to the middle.\n const p = matrix.subVec2(temp, output.pointA, output.pointB);\n matrix.copyVec2(output.pointA, p);\n matrix.copyVec2(output.pointB, p);\n output.distance = 0.0;\n }\n }\n};\n\n/**\n * A distance proxy is used by the GJK algorithm. It encapsulates any shape.\n */\nexport class DistanceProxy {\n /** @internal */ m_vertices: Vec2Value[] = [];\n // todo: remove this?\n /** @internal */ m_count = 0;\n /** @internal */ m_radius = 0;\n\n recycle() {\n this.m_vertices.length = 0;\n this.m_count = 0;\n this.m_radius = 0;\n }\n\n /**\n * Get the vertex count.\n */\n getVertexCount(): number {\n return this.m_count;\n }\n\n /**\n * Get a vertex by index. Used by Distance.\n */\n getVertex(index: number): Vec2Value {\n if (_ASSERT) console.assert(0 <= index && index < this.m_count);\n return this.m_vertices[index];\n }\n\n /**\n * Get the supporting vertex index in the given direction.\n */\n getSupport(d: Vec2Value): number {\n let bestIndex = -1;\n let bestValue = -Infinity;\n for (let i = 0; i < this.m_count; ++i) {\n const value = matrix.dotVec2(this.m_vertices[i], d);\n if (value > bestValue) {\n bestIndex = i;\n bestValue = value;\n }\n }\n return bestIndex;\n }\n\n /**\n * Get the supporting vertex in the given direction.\n */\n getSupportVertex(d: Vec2Value): Vec2Value {\n return this.m_vertices[this.getSupport(d)];\n }\n\n /**\n * Initialize the proxy using the given shape. The shape must remain in scope\n * while the proxy is in use.\n */\n set(shape: Shape, index: number): void {\n // TODO remove, use shape instead\n if (_ASSERT) console.assert(typeof shape.computeDistanceProxy === \"function\");\n shape.computeDistanceProxy(this, index);\n }\n\n /**\n * Initialize the proxy using a vertex cloud and radius. The vertices\n * must remain in scope while the proxy is in use.\n */\n setVertices(vertices: Vec2Value[], count: number, radius: number) {\n this.m_vertices = vertices;\n this.m_count = count;\n this.m_radius = radius;\n }\n}\n\nclass SimplexVertex {\n /** support point in proxyA */\n wA = matrix.vec2(0, 0);\n /** wA index */\n indexA = 0;\n\n /** support point in proxyB */\n wB = matrix.vec2(0, 0);\n /** wB index */\n indexB = 0;\n\n /** wB - wA; */\n w = matrix.vec2(0, 0);\n /** barycentric coordinate for closest point */\n a = 0;\n\n recycle() {\n this.indexA = 0;\n this.indexB = 0;\n matrix.zeroVec2(this.wA);\n matrix.zeroVec2(this.wB);\n matrix.zeroVec2(this.w);\n this.a = 0;\n }\n set(v: SimplexVertex): void {\n this.indexA = v.indexA;\n this.indexB = v.indexB;\n matrix.copyVec2(this.wA, v.wA);\n matrix.copyVec2(this.wB, v.wB);\n matrix.copyVec2(this.w, v.w);\n this.a = v.a;\n }\n}\n\n/** @internal */ const searchDirection_reuse = matrix.vec2(0, 0);\n/** @internal */ const closestPoint_reuse = matrix.vec2(0, 0); \n\nclass Simplex {\n m_v1 = new SimplexVertex();\n m_v2 = new SimplexVertex();\n m_v3 = new SimplexVertex();\n m_v = [this.m_v1, this.m_v2, this.m_v3];\n m_count: number;\n recycle() {\n this.m_v1.recycle();\n this.m_v2.recycle();\n this.m_v3.recycle();\n this.m_count = 0;\n }\n\n /** @internal */ toString(): string {\n if (this.m_count === 3) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y,\n this.m_v2.a, this.m_v2.wA.x, this.m_v2.wA.y, this.m_v2.wB.x, this.m_v2.wB.y,\n this.m_v3.a, this.m_v3.wA.x, this.m_v3.wA.y, this.m_v3.wB.x, this.m_v3.wB.y\n ].toString();\n\n } else if (this.m_count === 2) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y,\n this.m_v2.a, this.m_v2.wA.x, this.m_v2.wA.y, this.m_v2.wB.x, this.m_v2.wB.y\n ].toString();\n\n } else if (this.m_count === 1) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y\n ].toString();\n\n } else {\n return \"+\" + this.m_count;\n }\n }\n\n readCache(cache: SimplexCache, proxyA: DistanceProxy, transformA: TransformValue, proxyB: DistanceProxy, transformB: TransformValue): void {\n if (_ASSERT) console.assert(cache.count <= 3);\n\n // Copy data from cache.\n this.m_count = cache.count;\n for (let i = 0; i < this.m_count; ++i) {\n const v = this.m_v[i];\n v.indexA = cache.indexA[i];\n v.indexB = cache.indexB[i];\n const wALocal = proxyA.getVertex(v.indexA);\n const wBLocal = proxyB.getVertex(v.indexB);\n matrix.transformVec2(v.wA, transformA, wALocal);\n matrix.transformVec2(v.wB, transformB, wBLocal);\n matrix.subVec2(v.w,v.wB, v.wA);\n v.a = 0.0;\n }\n\n // Compute the new simplex metric, if it is substantially different than\n // old metric then flush the simplex.\n if (this.m_count > 1) {\n const metric1 = cache.metric;\n const metric2 = this.getMetric();\n if (metric2 < 0.5 * metric1 || 2.0 * metric1 < metric2 || metric2 < EPSILON) {\n // Reset the simplex.\n this.m_count = 0;\n }\n }\n\n // If the cache is empty or invalid...\n if (this.m_count === 0) {\n const v = this.m_v[0];\n v.indexA = 0;\n v.indexB = 0;\n const wALocal = proxyA.getVertex(0);\n const wBLocal = proxyB.getVertex(0);\n matrix.transformVec2(v.wA, transformA, wALocal);\n matrix.transformVec2(v.wB, transformB, wBLocal);\n matrix.subVec2(v.w,v.wB, v.wA);\n v.a = 1.0;\n this.m_count = 1;\n }\n }\n\n writeCache(cache: SimplexCache): void {\n cache.metric = this.getMetric();\n cache.count = this.m_count;\n for (let i = 0; i < this.m_count; ++i) {\n cache.indexA[i] = this.m_v[i].indexA;\n cache.indexB[i] = this.m_v[i].indexB;\n }\n }\n\n getSearchDirection(): Vec2Value {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 1:\n return matrix.setVec2(searchDirection_reuse, -v1.w.x, -v1.w.y);\n\n case 2: {\n matrix.subVec2(e12, v2.w, v1.w);\n const sgn = -matrix.crossVec2Vec2(e12, v1.w);\n if (sgn > 0.0) {\n // Origin is left of e12.\n return matrix.setVec2(searchDirection_reuse, -e12.y, e12.x);\n } else {\n // Origin is right of e12.\n return matrix.setVec2(searchDirection_reuse, e12.y, -e12.x);\n }\n }\n\n default:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(searchDirection_reuse);\n }\n }\n\n getClosestPoint(): Vec2Value {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(closestPoint_reuse);\n\n case 1:\n return matrix.copyVec2(closestPoint_reuse, v1.w);\n\n case 2:\n return matrix.combine2Vec2(closestPoint_reuse, v1.a, v1.w, v2.a, v2.w);\n\n case 3:\n return matrix.zeroVec2(closestPoint_reuse);\n\n default:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(closestPoint_reuse);\n }\n }\n\n getWitnessPoints(pA: Vec2Value, pB: Vec2Value): void {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n break;\n\n case 1:\n matrix.copyVec2(pA, v1.wA);\n matrix.copyVec2(pB, v1.wB);\n break;\n\n case 2:\n matrix.combine2Vec2(pA, v1.a, v1.wA, v2.a, v2.wA);\n matrix.combine2Vec2(pB, v1.a, v1.wB, v2.a, v2.wB);\n break;\n\n case 3:\n matrix.combine3Vec2(pA, v1.a, v1.wA, v2.a, v2.wA, v3.a, v3.wA);\n matrix.copyVec2(pB, pA);\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n break;\n }\n }\n\n getMetric(): number {\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n return 0.0;\n\n case 1:\n return 0.0;\n\n case 2:\n return matrix.distVec2(this.m_v1.w, this.m_v2.w);\n\n case 3:\n return matrix.crossVec2Vec2(\n matrix.subVec2(temp1, this.m_v2.w, this.m_v1.w),\n matrix.subVec2(temp2, this.m_v3.w, this.m_v1.w),\n );\n\n default:\n if (_ASSERT) console.assert(false);\n return 0.0;\n }\n }\n\n solve(): void {\n switch (this.m_count) {\n case 1:\n break;\n\n case 2:\n this.solve2();\n break;\n\n case 3:\n this.solve3();\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n }\n }\n\n// Solve a line segment using barycentric coordinates.\n//\n// p = a1 * w1 + a2 * w2\n// a1 + a2 = 1\n//\n// The vector from the origin to the closest point on the line is\n// perpendicular to the line.\n// e12 = w2 - w1\n// dot(p, e) = 0\n// a1 * dot(w1, e) + a2 * dot(w2, e) = 0\n//\n// 2-by-2 linear system\n// [1 1 ][a1] = [1]\n// [w1.e12 w2.e12][a2] = [0]\n//\n// Define\n// d12_1 = dot(w2, e12)\n// d12_2 = -dot(w1, e12)\n// d12 = d12_1 + d12_2\n//\n// Solution\n// a1 = d12_1 / d12\n// a2 = d12_2 / d12\n solve2(): void {\n const w1 = this.m_v1.w;\n const w2 = this.m_v2.w;\n matrix.subVec2(e12, w2, w1);\n\n // w1 region\n const d12_2 = -matrix.dotVec2(w1, e12);\n if (d12_2 <= 0.0) {\n // a2 <= 0, so we clamp it to 0\n this.m_v1.a = 1.0;\n this.m_count = 1;\n return;\n }\n\n // w2 region\n const d12_1 = matrix.dotVec2(w2, e12);\n if (d12_1 <= 0.0) {\n // a1 <= 0, so we clamp it to 0\n this.m_v2.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v2);\n return;\n }\n\n // Must be in e12 region.\n const inv_d12 = 1.0 / (d12_1 + d12_2);\n this.m_v1.a = d12_1 * inv_d12;\n this.m_v2.a = d12_2 * inv_d12;\n this.m_count = 2;\n }\n\n// Possible regions:\n// - points[2]\n// - edge points[0]-points[2]\n// - edge points[1]-points[2]\n// - inside the triangle\n solve3(): void {\n const w1 = this.m_v1.w;\n const w2 = this.m_v2.w;\n const w3 = this.m_v3.w;\n\n // Edge12\n // [1 1 ][a1] = [1]\n // [w1.e12 w2.e12][a2] = [0]\n // a3 = 0\n matrix.subVec2(e12, w2, w1);\n const w1e12 = matrix.dotVec2(w1, e12);\n const w2e12 = matrix.dotVec2(w2, e12);\n const d12_1 = w2e12;\n const d12_2 = -w1e12;\n\n // Edge13\n // [1 1 ][a1] = [1]\n // [w1.e13 w3.e13][a3] = [0]\n // a2 = 0\n matrix.subVec2(e13, w3, w1);\n const w1e13 = matrix.dotVec2(w1, e13);\n const w3e13 = matrix.dotVec2(w3, e13);\n const d13_1 = w3e13;\n const d13_2 = -w1e13;\n\n // Edge23\n // [1 1 ][a2] = [1]\n // [w2.e23 w3.e23][a3] = [0]\n // a1 = 0\n matrix.subVec2(e23, w3, w2);\n const w2e23 = matrix.dotVec2(w2, e23);\n const w3e23 = matrix.dotVec2(w3, e23);\n const d23_1 = w3e23;\n const d23_2 = -w2e23;\n\n // Triangle123\n const n123 = matrix.crossVec2Vec2(e12, e13);\n\n const d123_1 = n123 * matrix.crossVec2Vec2(w2, w3);\n const d123_2 = n123 * matrix.crossVec2Vec2(w3, w1);\n const d123_3 = n123 * matrix.crossVec2Vec2(w1, w2);\n\n // w1 region\n if (d12_2 <= 0.0 && d13_2 <= 0.0) {\n this.m_v1.a = 1.0;\n this.m_count = 1;\n return;\n }\n\n // e12\n if (d12_1 > 0.0 && d12_2 > 0.0 && d123_3 <= 0.0) {\n const inv_d12 = 1.0 / (d12_1 + d12_2);\n this.m_v1.a = d12_1 * inv_d12;\n this.m_v2.a = d12_2 * inv_d12;\n this.m_count = 2;\n return;\n }\n\n // e13\n if (d13_1 > 0.0 && d13_2 > 0.0 && d123_2 <= 0.0) {\n const inv_d13 = 1.0 / (d13_1 + d13_2);\n this.m_v1.a = d13_1 * inv_d13;\n this.m_v3.a = d13_2 * inv_d13;\n this.m_count = 2;\n this.m_v2.set(this.m_v3);\n return;\n }\n\n // w2 region\n if (d12_1 <= 0.0 && d23_2 <= 0.0) {\n this.m_v2.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v2);\n return;\n }\n\n // w3 region\n if (d13_1 <= 0.0 && d23_1 <= 0.0) {\n this.m_v3.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v3);\n return;\n }\n\n // e23\n if (d23_1 > 0.0 && d23_2 > 0.0 && d123_1 <= 0.0) {\n const inv_d23 = 1.0 / (d23_1 + d23_2);\n this.m_v2.a = d23_1 * inv_d23;\n this.m_v3.a = d23_2 * inv_d23;\n this.m_count = 2;\n this.m_v1.set(this.m_v3);\n return;\n }\n\n // Must be in triangle123\n const inv_d123 = 1.0 / (d123_1 + d123_2 + d123_3);\n this.m_v1.a = d123_1 * inv_d123;\n this.m_v2.a = d123_2 * inv_d123;\n this.m_v3.a = d123_3 * inv_d123;\n this.m_count = 3;\n }\n}\n\n/** @internal */ const simplex = new Simplex();\n\n/** @internal */ const input = new DistanceInput();\n/** @internal */ const cache = new SimplexCache();\n/** @internal */ const output = new DistanceOutput();\n\n/**\n * Determine if two generic shapes overlap.\n */\nexport const testOverlap = function (shapeA: Shape, indexA: number, shapeB: Shape, indexB: number, xfA: TransformValue, xfB: TransformValue): boolean {\n input.recycle();\n input.proxyA.set(shapeA, indexA);\n input.proxyB.set(shapeB, indexB);\n matrix.copyTransform(input.transformA, xfA);\n matrix.copyTransform(input.transformB, xfB);\n input.useRadii = true;\n\n output.recycle();\n cache.recycle();\n\n Distance(output, cache, input);\n\n return output.distance < 10.0 * EPSILON;\n};\n\n// legacy exports\nDistance.testOverlap = testOverlap;\nDistance.Input = DistanceInput;\nDistance.Output = DistanceOutput;\nDistance.Proxy = DistanceProxy;\nDistance.Cache = SimplexCache;\n\n/**\n * Input parameters for ShapeCast\n */\nexport class ShapeCastInput {\n readonly proxyA = new DistanceProxy();\n readonly proxyB = new DistanceProxy();\n readonly transformA = Transform.identity();\n readonly transformB = Transform.identity();\n readonly translationB = Vec2.zero();\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.transformA.setIdentity();\n this.transformB.setIdentity();\n matrix.zeroVec2(this.translationB);\n }\n}\n\n/**\n * Output results for b2ShapeCast\n */\nexport class ShapeCastOutput {\n point: Vec2 = Vec2.zero();\n normal: Vec2 = Vec2.zero();\n lambda = 1.0;\n iterations = 0;\n}\n\n/**\n * Perform a linear shape cast of shape B moving and shape A fixed. Determines\n * the hit point, normal, and translation fraction.\n * \n * @returns true if hit, false if there is no hit or an initial overlap\n */\n//\n// GJK-raycast\n// Algorithm by Gino van den Bergen.\n// \"Smooth Mesh Contacts with GJK\" in Game Physics Pearls. 2010\nexport const ShapeCast = function(output: ShapeCastOutput, input: ShapeCastInput): boolean {\n output.iterations = 0;\n output.lambda = 1.0;\n output.normal.setZero();\n output.point.setZero();\n\n const proxyA = input.proxyA;\n const proxyB = input.proxyB;\n\n const radiusA = math_max(proxyA.m_radius, Settings.polygonRadius);\n const radiusB = math_max(proxyB.m_radius, Settings.polygonRadius);\n const radius = radiusA + radiusB;\n\n const xfA = input.transformA;\n const xfB = input.transformB;\n\n const r = input.translationB;\n const n = Vec2.zero();\n let lambda = 0.0;\n\n // Initial simplex\n const simplex = new Simplex();\n simplex.m_count = 0;\n\n // Get simplex vertices as an array.\n const vertices = simplex.m_v;\n\n // Get support point in -r direction\n let indexA = proxyA.getSupport(Rot.mulTVec2(xfA.q, Vec2.neg(r)));\n let wA = Transform.mulVec2(xfA, proxyA.getVertex(indexA));\n let indexB = proxyB.getSupport(Rot.mulTVec2(xfB.q, r));\n let wB = Transform.mulVec2(xfB, proxyB.getVertex(indexB));\n const v = Vec2.sub(wA, wB);\n\n // Sigma is the target distance between polygons\n const sigma = math_max(Settings.polygonRadius, radius - Settings.polygonRadius);\n const tolerance = 0.5 * Settings.linearSlop;\n\n // Main iteration loop.\n const k_maxIters = 20;\n let iter = 0;\n while (iter < k_maxIters && v.length() - sigma > tolerance) {\n if (_ASSERT) console.assert(simplex.m_count < 3);\n\n output.iterations += 1;\n\n // Support in direction -v (A - B)\n indexA = proxyA.getSupport(Rot.mulTVec2(xfA.q, Vec2.neg(v)));\n wA = Transform.mulVec2(xfA, proxyA.getVertex(indexA));\n indexB = proxyB.getSupport(Rot.mulTVec2(xfB.q, v));\n wB = Transform.mulVec2(xfB, proxyB.getVertex(indexB));\n const p = Vec2.sub(wA, wB);\n\n // -v is a normal at p\n v.normalize();\n\n // Intersect ray with plane\n const vp = Vec2.dot(v, p);\n const vr = Vec2.dot(v, r);\n if (vp - sigma > lambda * vr) {\n if (vr <= 0.0) {\n return false;\n }\n\n lambda = (vp - sigma) / vr;\n if (lambda > 1.0) {\n return false;\n }\n\n n.setMul(-1, v);\n simplex.m_count = 0;\n }\n\n // Reverse simplex since it works with B - A.\n // Shift by lambda * r because we want the closest point to the current clip point.\n // Note that the support point p is not shifted because we want the plane equation\n // to be formed in unshifted space.\n const vertex = vertices[simplex.m_count];\n vertex.indexA = indexB;\n vertex.wA = Vec2.combine(1, wB, lambda, r);\n vertex.indexB = indexA;\n vertex.wB = wA;\n vertex.w = Vec2.sub(vertex.wB, vertex.wA);\n vertex.a = 1.0;\n simplex.m_count += 1;\n\n switch (simplex.m_count) {\n case 1:\n break;\n\n case 2:\n simplex.solve2();\n break;\n\n case 3:\n simplex.solve3();\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n }\n \n // If we have 3 points, then the origin is in the corresponding triangle.\n if (simplex.m_count == 3) {\n // Overlap\n return false;\n }\n\n // Get search direction.\n v.setVec2(simplex.getClosestPoint());\n\n // Iteration count is equated to the number of support point calls.\n ++iter;\n }\n\n if (iter == 0) {\n // Initial overlap\n return false;\n\t}\n\n // Prepare output.\n const pointA = Vec2.zero();\n const pointB = Vec2.zero();\n simplex.getWitnessPoints(pointB, pointA);\n\n if (v.lengthSquared() > 0.0) {\n n.setMul(-1, v);\n n.normalize();\n }\n\n output.point = Vec2.combine(1, pointA, radiusA, n);\n output.normal = n;\n output.lambda = lambda;\n output.iterations = iter;\n return true;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { stats } from \"../util/stats\";\nimport Timer from \"../util/Timer\";\nimport { Sweep } from \"../common/Sweep\";\nimport { Transform } from \"../common/Transform\";\nimport { Distance, DistanceInput, DistanceOutput, DistanceProxy, SimplexCache } from \"./Distance\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n\n\n/**\n * Input parameters for TimeOfImpact.\n */\nexport class TOIInput {\n proxyA = new DistanceProxy();\n proxyB = new DistanceProxy();\n sweepA = new Sweep();\n sweepB = new Sweep();\n /** defines sweep interval [0, tMax] */\n tMax: number;\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.sweepA.recycle();\n this.sweepB.recycle();\n this.tMax = -1;\n }\n}\n\nexport enum TOIOutputState {\n e_unset = -1,\n e_unknown = 0,\n e_failed = 1,\n e_overlapped = 2,\n e_touching = 3,\n e_separated = 4,\n}\n\n/**\n * Output parameters for TimeOfImpact.\n */\nexport class TOIOutput {\n state = TOIOutputState.e_unset;\n t = -1;\n recycle() {\n this.state = TOIOutputState.e_unset;\n this.t = -1;\n }\n}\n\nstats.toiTime = 0;\nstats.toiMaxTime = 0;\nstats.toiCalls = 0;\nstats.toiIters = 0;\nstats.toiMaxIters = 0;\nstats.toiRootIters = 0;\nstats.toiMaxRootIters = 0;\n\n/** @internal */ const distanceInput = new DistanceInput();\n/** @internal */ const distanceOutput = new DistanceOutput();\n// this is passed to Distance and SeparationFunction\n/** @internal */ const cache = new SimplexCache();\n\n/** @internal */ const xfA = matrix.transform(0, 0, 0);\n/** @internal */ const xfB = matrix.transform(0, 0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const axisA = matrix.vec2(0, 0);\n/** @internal */ const axisB = matrix.vec2(0, 0);\n/** @internal */ const localPointA = matrix.vec2(0, 0);\n/** @internal */ const localPointB = matrix.vec2(0, 0);\n\n\n/**\n * Compute the upper bound on time before two shapes penetrate. Time is\n * represented as a fraction between [0,tMax]. This uses a swept separating axis\n * and may miss some intermediate, non-tunneling collisions. If you change the\n * time interval, you should call this function again.\n *\n * Note: use Distance to compute the contact point and normal at the time of\n * impact.\n *\n * CCD via the local separating axis method. This seeks progression by computing\n * the largest time at which separation is maintained.\n */\nexport const TimeOfImpact = function (output: TOIOutput, input: TOIInput): void {\n const timer = Timer.now();\n\n ++stats.toiCalls;\n\n output.state = TOIOutputState.e_unknown;\n output.t = input.tMax;\n\n const proxyA = input.proxyA; // DistanceProxy\n const proxyB = input.proxyB; // DistanceProxy\n\n const sweepA = input.sweepA; // Sweep\n const sweepB = input.sweepB; // Sweep\n\n // Large rotations can make the root finder fail, so we normalize the\n // sweep angles.\n sweepA.normalize();\n sweepB.normalize();\n\n const tMax = input.tMax;\n\n const totalRadius = proxyA.m_radius + proxyB.m_radius;\n const target = math_max(Settings.linearSlop, totalRadius - 3.0 * Settings.linearSlop);\n const tolerance = 0.25 * Settings.linearSlop;\n if (_ASSERT) console.assert(target > tolerance);\n\n let t1 = 0.0;\n const k_maxIterations = Settings.maxTOIIterations;\n let iter = 0;\n\n // Prepare input for distance query.\n // const cache = new SimplexCache();\n cache.recycle();\n\n distanceInput.proxyA.setVertices(proxyA.m_vertices, proxyA.m_count, proxyA.m_radius);\n distanceInput.proxyB.setVertices(proxyB.m_vertices, proxyB.m_count, proxyB.m_radius);\n distanceInput.useRadii = false;\n\n // The outer loop progressively attempts to compute new separating axes.\n // This loop terminates when an axis is repeated (no progress is made).\n while (true) {\n sweepA.getTransform(xfA, t1);\n sweepB.getTransform(xfB, t1);\n\n // Get the distance between shapes. We can also use the results\n // to get a separating axis.\n matrix.copyTransform(distanceInput.transformA, xfA);\n matrix.copyTransform(distanceInput.transformB, xfB);\n Distance(distanceOutput, cache, distanceInput);\n\n // If the shapes are overlapped, we give up on continuous collision.\n if (distanceOutput.distance <= 0.0) {\n // Failure!\n output.state = TOIOutputState.e_overlapped;\n output.t = 0.0;\n break;\n }\n\n if (distanceOutput.distance < target + tolerance) {\n // Victory!\n output.state = TOIOutputState.e_touching;\n output.t = t1;\n break;\n }\n\n // Initialize the separating axis.\n separationFunction.initialize(cache, proxyA, sweepA, proxyB, sweepB, t1);\n\n // if (false) {\n // // Dump the curve seen by the root finder\n // const N = 100;\n // const dx = 1.0 / N;\n // const xs = []; // [ N + 1 ];\n // const fs = []; // [ N + 1 ];\n // const x = 0.0;\n // for (const i = 0; i <= N; ++i) {\n // sweepA.getTransform(xfA, x);\n // sweepB.getTransform(xfB, x);\n // const f = fcn.evaluate(xfA, xfB) - target;\n // printf(\"%g %g\\n\", x, f);\n // xs[i] = x;\n // fs[i] = f;\n // x += dx;\n // }\n // }\n\n // Compute the TOI on the separating axis. We do this by successively\n // resolving the deepest point. This loop is bounded by the number of\n // vertices.\n let done = false;\n let t2 = tMax;\n let pushBackIter = 0;\n while (true) {\n // Find the deepest point at t2. Store the witness point indices.\n let s2 = separationFunction.findMinSeparation(t2);\n\n // Is the final configuration separated?\n if (s2 > target + tolerance) {\n // Victory!\n output.state = TOIOutputState.e_separated;\n output.t = tMax;\n done = true;\n break;\n }\n\n // Has the separation reached tolerance?\n if (s2 > target - tolerance) {\n // Advance the sweeps\n t1 = t2;\n break;\n }\n\n // Compute the initial separation of the witness points.\n let s1 = separationFunction.evaluate(t1);\n\n // Check for initial overlap. This might happen if the root finder\n // runs out of iterations.\n if (s1 < target - tolerance) {\n output.state = TOIOutputState.e_failed;\n output.t = t1;\n done = true;\n break;\n }\n\n // Check for touching\n if (s1 <= target + tolerance) {\n // Victory! t1 should hold the TOI (could be 0.0).\n output.state = TOIOutputState.e_touching;\n output.t = t1;\n done = true;\n break;\n }\n\n // Compute 1D root of: f(x) - target = 0\n let rootIterCount = 0;\n let a1 = t1;\n let a2 = t2;\n while (true) {\n // Use a mix of the secant rule and bisection.\n let t;\n if (rootIterCount & 1) {\n // Secant rule to improve convergence.\n t = a1 + (target - s1) * (a2 - a1) / (s2 - s1);\n } else {\n // Bisection to guarantee progress.\n t = 0.5 * (a1 + a2);\n }\n\n ++rootIterCount;\n ++stats.toiRootIters;\n\n const s = separationFunction.evaluate(t);\n\n if (math_abs(s - target) < tolerance) {\n // t2 holds a tentative value for t1\n t2 = t;\n break;\n }\n\n // Ensure we continue to bracket the root.\n if (s > target) {\n a1 = t;\n s1 = s;\n } else {\n a2 = t;\n s2 = s;\n }\n\n if (rootIterCount === 50) {\n break;\n }\n }\n\n stats.toiMaxRootIters = math_max(stats.toiMaxRootIters, rootIterCount);\n\n ++pushBackIter;\n\n if (pushBackIter === Settings.maxPolygonVertices) {\n break;\n }\n }\n\n ++iter;\n ++stats.toiIters;\n\n if (done) {\n break;\n }\n\n if (iter === k_maxIterations) {\n // Root finder got stuck. Semi-victory.\n output.state = TOIOutputState.e_failed;\n output.t = t1;\n break;\n }\n }\n\n stats.toiMaxIters = math_max(stats.toiMaxIters, iter);\n\n const time = Timer.diff(timer);\n stats.toiMaxTime = math_max(stats.toiMaxTime, time);\n stats.toiTime += time;\n\n separationFunction.recycle();\n};\n\nenum SeparationFunctionType {\n e_unset = -1,\n e_points = 1,\n e_faceA = 2,\n e_faceB = 3,\n}\n\nclass SeparationFunction {\n // input cache\n // todo: maybe assign by copy instead of reference?\n m_proxyA: DistanceProxy = null;\n m_proxyB: DistanceProxy = null;\n m_sweepA: Sweep = null;\n m_sweepB: Sweep = null;\n\n // initialize cache\n m_type = SeparationFunctionType.e_unset;\n m_localPoint = matrix.vec2(0, 0);\n m_axis = matrix.vec2(0, 0);\n\n // compute output\n indexA = -1;\n indexB = -1;\n\n recycle() {\n this.m_proxyA = null;\n this.m_proxyB = null;\n this.m_sweepA = null;\n this.m_sweepB = null;\n\n this.m_type = SeparationFunctionType.e_unset;\n matrix.zeroVec2(this.m_localPoint);\n matrix.zeroVec2(this.m_axis);\n\n this.indexA = -1;\n this.indexB = -1;\n }\n\n // TODO_ERIN might not need to return the separation\n\n initialize(cache: SimplexCache, proxyA: DistanceProxy, sweepA: Sweep, proxyB: DistanceProxy, sweepB: Sweep, t1: number): number {\n const count = cache.count;\n if (_ASSERT) console.assert(0 < count && count < 3);\n\n this.m_proxyA = proxyA;\n this.m_proxyB = proxyB;\n this.m_sweepA = sweepA;\n this.m_sweepB = sweepB;\n\n this.m_sweepA.getTransform(xfA, t1);\n this.m_sweepB.getTransform(xfB, t1);\n\n if (count === 1) {\n this.m_type = SeparationFunctionType.e_points;\n const localPointA = this.m_proxyA.getVertex(cache.indexA[0]);\n const localPointB = this.m_proxyB.getVertex(cache.indexB[0]);\n matrix.transformVec2(pointA, xfA, localPointA);\n matrix.transformVec2(pointB, xfB, localPointB);\n matrix.subVec2(this.m_axis, pointB, pointA);\n const s = matrix.normalizeVec2Length(this.m_axis);\n return s;\n\n } else if (cache.indexA[0] === cache.indexA[1]) {\n // Two points on B and one on A.\n this.m_type = SeparationFunctionType.e_faceB;\n const localPointB1 = proxyB.getVertex(cache.indexB[0]);\n const localPointB2 = proxyB.getVertex(cache.indexB[1]);\n\n matrix.crossVec2Num(this.m_axis, matrix.subVec2(temp, localPointB2, localPointB1), 1.0);\n matrix.normalizeVec2(this.m_axis);\n matrix.rotVec2(normal, xfB.q, this.m_axis);\n\n matrix.combine2Vec2(this.m_localPoint, 0.5, localPointB1, 0.5, localPointB2);\n matrix.transformVec2(pointB, xfB, this.m_localPoint);\n\n const localPointA = proxyA.getVertex(cache.indexA[0]);\n const pointA = Transform.mulVec2(xfA, localPointA);\n\n let s = matrix.dotVec2(pointA, normal) - matrix.dotVec2(pointB, normal);\n if (s < 0.0) {\n matrix.negVec2(this.m_axis);\n s = -s;\n }\n return s;\n\n } else {\n // Two points on A and one or two points on B.\n this.m_type = SeparationFunctionType.e_faceA;\n const localPointA1 = this.m_proxyA.getVertex(cache.indexA[0]);\n const localPointA2 = this.m_proxyA.getVertex(cache.indexA[1]);\n\n matrix.crossVec2Num(this.m_axis, matrix.subVec2(temp, localPointA2, localPointA1), 1.0);\n matrix.normalizeVec2(this.m_axis);\n matrix.rotVec2(normal, xfA.q, this.m_axis);\n\n matrix.combine2Vec2(this.m_localPoint, 0.5, localPointA1, 0.5, localPointA2);\n matrix.transformVec2(pointA, xfA, this.m_localPoint);\n\n const localPointB = this.m_proxyB.getVertex(cache.indexB[0]);\n matrix.transformVec2(pointB, xfB, localPointB);\n\n let s = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal);\n if (s < 0.0) {\n matrix.negVec2(this.m_axis);\n s = -s;\n }\n return s;\n }\n }\n\n compute(find: boolean, t: number): number {\n // It was findMinSeparation and evaluate\n this.m_sweepA.getTransform(xfA, t);\n this.m_sweepB.getTransform(xfB, t);\n\n switch (this.m_type) {\n case SeparationFunctionType.e_points: {\n if (find) {\n matrix.derotVec2(axisA, xfA.q, this.m_axis);\n matrix.derotVec2(axisB, xfB.q, matrix.scaleVec2(temp, -1, this.m_axis));\n\n this.indexA = this.m_proxyA.getSupport(axisA);\n this.indexB = this.m_proxyB.getSupport(axisB);\n }\n\n matrix.copyVec2(localPointA, this.m_proxyA.getVertex(this.indexA));\n matrix.copyVec2(localPointB, this.m_proxyB.getVertex(this.indexB));\n\n matrix.transformVec2(pointA, xfA, localPointA);\n matrix.transformVec2(pointB, xfB, localPointB);\n\n const sep = matrix.dotVec2(pointB, this.m_axis) - matrix.dotVec2(pointA, this.m_axis);\n return sep;\n }\n\n case SeparationFunctionType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.m_axis);\n matrix.transformVec2(pointA, xfA, this.m_localPoint);\n\n if (find) {\n matrix.derotVec2(axisB, xfB.q, matrix.scaleVec2(temp, -1, normal));\n\n this.indexA = -1;\n this.indexB = this.m_proxyB.getSupport(axisB);\n }\n\n matrix.copyVec2(localPointB, this.m_proxyB.getVertex(this.indexB));\n matrix.transformVec2(pointB, xfB, localPointB);\n\n const sep = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal);\n return sep;\n }\n\n case SeparationFunctionType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.m_axis);\n matrix.transformVec2(pointB, xfB, this.m_localPoint);\n\n if (find) {\n matrix.derotVec2(axisA, xfA.q, matrix.scaleVec2(temp, -1, normal));\n\n this.indexB = -1;\n this.indexA = this.m_proxyA.getSupport(axisA);\n }\n\n matrix.copyVec2(localPointA, this.m_proxyA.getVertex(this.indexA));\n matrix.transformVec2(pointA, xfA, localPointA);\n\n const sep = matrix.dotVec2(pointA, normal) - matrix.dotVec2(pointB, normal);\n return sep;\n }\n\n default:\n if (_ASSERT) console.assert(false);\n if (find) {\n this.indexA = -1;\n this.indexB = -1;\n }\n return 0.0;\n }\n }\n\n findMinSeparation(t: number): number {\n return this.compute(true, t);\n }\n\n evaluate(t: number): number {\n return this.compute(false, t);\n }\n}\n\n/** @internal */ const separationFunction = new SeparationFunction();\n\n// legacy exports\nTimeOfImpact.Input = TOIInput;\nTimeOfImpact.Output = TOIOutput;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { EPSILON } from \"../common/Math\";\nimport { Body } from \"./Body\";\nimport type { Contact } from \"./Contact\";\nimport { Joint } from \"./Joint\";\nimport { TimeOfImpact, TOIInput, TOIOutput, TOIOutputState } from \"../collision/TimeOfImpact\";\nimport { Distance, DistanceInput, DistanceOutput, SimplexCache } from \"../collision/Distance\";\nimport { World } from \"./World\";\nimport { Sweep } from \"../common/Sweep\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_min = Math.min;\n\n\nexport class TimeStep {\n /** time step */\n dt: number = 0;\n /** inverse time step (0 if dt == 0) */\n inv_dt: number = 0;\n velocityIterations: number = 0;\n positionIterations: number = 0;\n warmStarting: boolean = false;\n blockSolve: boolean = true;\n\n /** timestep ratio for variable timestep */\n inv_dt0: number = 0.0;\n /** dt * inv_dt0 */\n dtRatio: number = 1;\n\n reset(dt: number): void {\n if (this.dt > 0.0) {\n this.inv_dt0 = this.inv_dt;\n }\n this.dt = dt;\n this.inv_dt = dt == 0 ? 0 : 1 / dt;\n this.dtRatio = dt * this.inv_dt0;\n }\n}\n\n// reuse\n/** @internal */ const s_subStep = new TimeStep();\n/** @internal */ const c = matrix.vec2(0, 0);\n/** @internal */ const v = matrix.vec2(0, 0);\n/** @internal */ const translation = matrix.vec2(0, 0);\n/** @internal */ const input = new TOIInput();\n/** @internal */ const output = new TOIOutput();\n/** @internal */ const backup = new Sweep();\n/** @internal */ const backup1 = new Sweep();\n/** @internal */ const backup2 = new Sweep();\n\n/**\n * Contact impulses for reporting. Impulses are used instead of forces because\n * sub-step forces may approach infinity for rigid body collisions. These match\n * up one-to-one with the contact points in Manifold.\n */\nexport class ContactImpulse {\n // TODO: merge with Contact class?\n\n private readonly contact: Contact;\n private readonly normals: number[];\n private readonly tangents: number[];\n\n constructor(contact: Contact) {\n this.contact = contact;\n this.normals = [];\n this.tangents = [];\n }\n\n recycle() {\n this.normals.length = 0;\n this.tangents.length = 0;\n }\n\n get normalImpulses(): number[] {\n const contact = this.contact;\n const normals = this.normals;\n normals.length = 0;\n for (let p = 0; p < contact.v_points.length; ++p) {\n normals.push(contact.v_points[p].normalImpulse);\n }\n return normals;\n }\n\n get tangentImpulses(): number[] {\n const contact = this.contact;\n const tangents = this.tangents;\n tangents.length = 0;\n for (let p = 0; p < contact.v_points.length; ++p) {\n tangents.push(contact.v_points[p].tangentImpulse);\n }\n return tangents;\n }\n}\n\n/**\n * Finds and solves islands. An island is a connected subset of the world.\n */\nexport class Solver {\n m_world: World;\n m_stack: Body[];\n m_bodies: Body[];\n m_contacts: Contact[];\n m_joints: Joint[];\n\n constructor(world: World) {\n this.m_world = world;\n this.m_stack = [];\n this.m_bodies = [];\n this.m_contacts = [];\n this.m_joints = [];\n }\n\n clear(): void {\n this.m_stack.length = 0;\n this.m_bodies.length = 0;\n this.m_contacts.length = 0;\n this.m_joints.length = 0;\n }\n\n addBody(body: Body): void {\n if (_ASSERT) console.assert(body instanceof Body, \"Not a Body!\", body);\n this.m_bodies.push(body);\n // why?\n // body.c_position.c.setZero();\n // body.c_position.a = 0;\n // body.c_velocity.v.setZero();\n // body.c_velocity.w = 0;\n }\n\n addContact(contact: Contact): void {\n // if (_ASSERT) console.assert(contact instanceof Contact, 'Not a Contact!', contact);\n this.m_contacts.push(contact);\n }\n\n addJoint(joint: Joint): void {\n if (_ASSERT) console.assert(joint instanceof Joint, \"Not a Joint!\", joint);\n this.m_joints.push(joint);\n }\n\n solveWorld(step: TimeStep): void {\n const world = this.m_world;\n\n // Clear all the island flags.\n for (let b = world.m_bodyList; b; b = b.m_next) {\n b.m_islandFlag = false;\n }\n for (let c = world.m_contactList; c; c = c.m_next) {\n c.m_islandFlag = false;\n }\n for (let j = world.m_jointList; j; j = j.m_next) {\n j.m_islandFlag = false;\n }\n\n // Build and simulate all awake islands.\n const stack = this.m_stack;\n let loop = -1;\n for (let seed = world.m_bodyList; seed; seed = seed.m_next) {\n loop++;\n if (seed.m_islandFlag) {\n continue;\n }\n\n if (seed.isAwake() == false || seed.isActive() == false) {\n continue;\n }\n\n // The seed can be dynamic or kinematic.\n if (seed.isStatic()) {\n continue;\n }\n\n // Reset island and stack.\n this.clear();\n\n stack.push(seed);\n\n seed.m_islandFlag = true;\n\n // Perform a depth first search (DFS) on the constraint graph.\n while (stack.length > 0) {\n // Grab the next body off the stack and add it to the island.\n const b = stack.pop();\n if (_ASSERT) console.assert(b.isActive() == true);\n this.addBody(b);\n\n // Make sure the body is awake (without resetting sleep timer).\n b.m_awakeFlag = true;\n\n // To keep islands as small as possible, we don't\n // propagate islands across static bodies.\n if (b.isStatic()) {\n continue;\n }\n\n // Search all contacts connected to this body.\n for (let ce = b.m_contactList; ce; ce = ce.next) {\n const contact = ce.contact;\n\n // Has this contact already been added to an island?\n if (contact.m_islandFlag) {\n continue;\n }\n\n // Is this contact solid and touching?\n if (contact.isEnabled() == false || contact.isTouching() == false) {\n continue;\n }\n\n // Skip sensors.\n const sensorA = contact.m_fixtureA.m_isSensor;\n const sensorB = contact.m_fixtureB.m_isSensor;\n if (sensorA || sensorB) {\n continue;\n }\n\n this.addContact(contact);\n contact.m_islandFlag = true;\n\n const other = ce.other;\n\n // Was the other body already added to this island?\n if (other.m_islandFlag) {\n continue;\n }\n\n // if (_ASSERT) console.assert(stack.length < world.m_bodyCount);\n stack.push(other);\n other.m_islandFlag = true;\n }\n\n // Search all joints connect to this body.\n for (let je = b.m_jointList; je; je = je.next) {\n if (je.joint.m_islandFlag == true) {\n continue;\n }\n\n const other = je.other;\n\n // Don't simulate joints connected to inactive bodies.\n if (other.isActive() == false) {\n continue;\n }\n\n this.addJoint(je.joint);\n je.joint.m_islandFlag = true;\n\n if (other.m_islandFlag) {\n continue;\n }\n\n // if (_ASSERT) console.assert(stack.length < world.m_bodyCount);\n stack.push(other);\n other.m_islandFlag = true;\n }\n }\n\n this.solveIsland(step);\n\n // Post solve cleanup.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n // Allow static bodies to participate in other islands.\n // TODO: are they added at all?\n const b = this.m_bodies[i];\n if (b.isStatic()) {\n b.m_islandFlag = false;\n }\n }\n }\n }\n\n solveIsland(step: TimeStep): void {\n // B2: Island Solve\n const world = this.m_world;\n const gravity = world.m_gravity;\n const allowSleep = world.m_allowSleep;\n\n const h = step.dt;\n\n // Integrate velocities and apply damping. Initialize the body state.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.m_sweep.c);\n const a = body.m_sweep.a;\n matrix.copyVec2(v, body.m_linearVelocity);\n let w = body.m_angularVelocity;\n\n // Store positions for continuous collision.\n matrix.copyVec2(body.m_sweep.c0, body.m_sweep.c);\n body.m_sweep.a0 = body.m_sweep.a;\n\n if (body.isDynamic()) {\n // Integrate velocities.\n matrix.plusScaleVec2(v, h * body.m_gravityScale, gravity);\n matrix.plusScaleVec2(v, h * body.m_invMass, body.m_force);\n w += h * body.m_invI * body.m_torque;\n /**\n *
\n         * Apply damping.\n         * ODE: dv/dt + c * v = 0\n         * Solution: v(t) = v0 * exp(-c * t)\n         * Time step: v(t + dt) = v0 * exp(-c * (t + dt)) = v0 * exp(-c * t) * exp(-c * dt) = v * exp(-c * dt)\n         * v2 = exp(-c * dt) * v1\n         * Pade approximation:\n         * v2 = v1 * 1 / (1 + c * dt)\n         * 
\n */\n matrix.scaleVec2(v, 1.0 / (1.0 + h * body.m_linearDamping), v);\n w *= 1.0 / (1.0 + h * body.m_angularDamping);\n }\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initConstraint(step);\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initVelocityConstraint(step);\n }\n\n if (step.warmStarting) {\n // Warm start.\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.warmStartConstraint(step);\n }\n }\n\n for (let i = 0; i < this.m_joints.length; ++i) {\n const joint = this.m_joints[i];\n joint.initVelocityConstraints(step);\n }\n\n // Solve velocity constraints\n for (let i = 0; i < step.velocityIterations; ++i) {\n for (let j = 0; j < this.m_joints.length; ++j) {\n const joint = this.m_joints[j];\n joint.solveVelocityConstraints(step);\n }\n\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n contact.solveVelocityConstraint(step);\n }\n }\n\n // Store impulses for warm starting\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.storeConstraintImpulses(step);\n }\n\n // Integrate positions\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.c_position.c);\n let a = body.c_position.a;\n matrix.copyVec2(v, body.c_velocity.v);\n let w = body.c_velocity.w;\n\n // Check for large velocities\n matrix.scaleVec2(translation, h, v);\n const translationLengthSqr = matrix.lengthSqrVec2(translation);\n if (translationLengthSqr > Settings.maxTranslationSquared) {\n const ratio = Settings.maxTranslation / math_sqrt(translationLengthSqr);\n matrix.mulVec2(v, ratio);\n }\n\n const rotation = h * w;\n if (rotation * rotation > Settings.maxRotationSquared) {\n const ratio = Settings.maxRotation / math_abs(rotation);\n w *= ratio;\n }\n\n // Integrate\n matrix.plusScaleVec2(c, h, v);\n a += h * w;\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n }\n\n // Solve position constraints\n let positionSolved = false;\n for (let i = 0; i < step.positionIterations; ++i) {\n let minSeparation = 0.0;\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n const separation = contact.solvePositionConstraint(step);\n minSeparation = math_min(minSeparation, separation);\n }\n // We can't expect minSpeparation >= -Settings.linearSlop because we don't\n // push the separation above -Settings.linearSlop.\n const contactsOkay = minSeparation >= -3.0 * Settings.linearSlop;\n\n let jointsOkay = true;\n for (let j = 0; j < this.m_joints.length; ++j) {\n const joint = this.m_joints[j];\n const jointOkay = joint.solvePositionConstraints(step);\n jointsOkay = jointsOkay && jointOkay;\n }\n\n if (contactsOkay && jointsOkay) {\n // Exit early if the position errors are small.\n positionSolved = true;\n break;\n }\n }\n\n // Copy state buffers back to the bodies\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(body.m_sweep.c, body.c_position.c);\n body.m_sweep.a = body.c_position.a;\n matrix.copyVec2(body.m_linearVelocity, body.c_velocity.v);\n body.m_angularVelocity = body.c_velocity.w;\n body.synchronizeTransform();\n }\n\n this.postSolveIsland();\n\n if (allowSleep) {\n let minSleepTime = Infinity;\n\n const linTolSqr = Settings.linearSleepToleranceSqr;\n const angTolSqr = Settings.angularSleepToleranceSqr;\n\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n if (body.isStatic()) {\n continue;\n }\n\n if ((body.m_autoSleepFlag == false)\n || (body.m_angularVelocity * body.m_angularVelocity > angTolSqr)\n || (matrix.lengthSqrVec2(body.m_linearVelocity) > linTolSqr)) {\n body.m_sleepTime = 0.0;\n minSleepTime = 0.0;\n } else {\n body.m_sleepTime += h;\n minSleepTime = math_min(minSleepTime, body.m_sleepTime);\n }\n }\n\n if (minSleepTime >= Settings.timeToSleep && positionSolved) {\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n body.setAwake(false);\n }\n }\n }\n }\n\n /**\n * Find TOI contacts and solve them.\n */\n solveWorldTOI(step: TimeStep): void {\n const world = this.m_world;\n\n if (world.m_stepComplete) {\n for (let b = world.m_bodyList; b; b = b.m_next) {\n b.m_islandFlag = false;\n b.m_sweep.alpha0 = 0.0;\n }\n\n for (let c = world.m_contactList; c; c = c.m_next) {\n // Invalidate TOI\n c.m_toiFlag = false;\n c.m_islandFlag = false;\n c.m_toiCount = 0;\n c.m_toi = 1.0;\n }\n }\n\n // Find TOI events and solve them.\n while (true) {\n // Find the first TOI.\n let minContact: Contact | null = null;\n let minAlpha = 1.0;\n\n for (let c = world.m_contactList; c; c = c.m_next) {\n // Is this contact disabled?\n if (c.isEnabled() == false) {\n continue;\n }\n\n // Prevent excessive sub-stepping.\n if (c.m_toiCount > Settings.maxSubSteps) {\n continue;\n }\n\n let alpha = 1.0;\n if (c.m_toiFlag) {\n // This contact has a valid cached TOI.\n alpha = c.m_toi;\n } else {\n const fA = c.getFixtureA();\n const fB = c.getFixtureB();\n\n // Is there a sensor?\n if (fA.isSensor() || fB.isSensor()) {\n continue;\n }\n\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n if (_ASSERT) console.assert(bA.isDynamic() || bB.isDynamic());\n\n const activeA = bA.isAwake() && !bA.isStatic();\n const activeB = bB.isAwake() && !bB.isStatic();\n\n // Is at least one body active (awake and dynamic or kinematic)?\n if (activeA == false && activeB == false) {\n continue;\n }\n\n const collideA = bA.isBullet() || !bA.isDynamic();\n const collideB = bB.isBullet() || !bB.isDynamic();\n\n // Are these two non-bullet dynamic bodies?\n if (collideA == false && collideB == false) {\n continue;\n }\n\n // Compute the TOI for this contact.\n // Put the sweeps onto the same time interval.\n let alpha0 = bA.m_sweep.alpha0;\n\n if (bA.m_sweep.alpha0 < bB.m_sweep.alpha0) {\n alpha0 = bB.m_sweep.alpha0;\n bA.m_sweep.advance(alpha0);\n } else if (bB.m_sweep.alpha0 < bA.m_sweep.alpha0) {\n alpha0 = bA.m_sweep.alpha0;\n bB.m_sweep.advance(alpha0);\n }\n\n if (_ASSERT) console.assert(alpha0 < 1.0);\n\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n\n const sweepA = bA.m_sweep;\n const sweepB = bB.m_sweep;\n\n // Compute the time of impact in interval [0, minTOI]\n input.proxyA.set(fA.getShape(), indexA);\n input.proxyB.set(fB.getShape(), indexB);\n input.sweepA.set(bA.m_sweep);\n input.sweepB.set(bB.m_sweep);\n input.tMax = 1.0;\n\n TimeOfImpact(output, input);\n\n // Beta is the fraction of the remaining portion of the [time?].\n const beta = output.t;\n if (output.state == TOIOutputState.e_touching) {\n alpha = math_min(alpha0 + (1.0 - alpha0) * beta, 1.0);\n } else {\n alpha = 1.0;\n }\n\n c.m_toi = alpha;\n c.m_toiFlag = true;\n }\n\n if (alpha < minAlpha) {\n // This is the minimum TOI found so far.\n minContact = c;\n minAlpha = alpha;\n }\n }\n\n if (minContact == null || 1.0 - 10.0 * EPSILON < minAlpha) {\n // No more TOI events. Done!\n world.m_stepComplete = true;\n break;\n }\n\n // Advance the bodies to the TOI.\n const fA = minContact.getFixtureA();\n const fB = minContact.getFixtureB();\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n backup1.set(bA.m_sweep);\n backup2.set(bB.m_sweep);\n\n bA.advance(minAlpha);\n bB.advance(minAlpha);\n\n // The TOI contact likely has some new contact points.\n minContact.update(world);\n minContact.m_toiFlag = false;\n ++minContact.m_toiCount;\n\n // Is the contact solid?\n if (minContact.isEnabled() == false || minContact.isTouching() == false) {\n // Restore the sweeps.\n minContact.setEnabled(false);\n bA.m_sweep.set(backup1);\n bB.m_sweep.set(backup2);\n bA.synchronizeTransform();\n bB.synchronizeTransform();\n continue;\n }\n\n bA.setAwake(true);\n bB.setAwake(true);\n\n // Build the island\n this.clear();\n this.addBody(bA);\n this.addBody(bB);\n this.addContact(minContact);\n\n bA.m_islandFlag = true;\n bB.m_islandFlag = true;\n minContact.m_islandFlag = true;\n\n // Get contacts on bodyA and bodyB.\n const bodies = [ bA, bB ];\n for (let i = 0; i < bodies.length; ++i) {\n const body = bodies[i];\n if (body.isDynamic()) {\n for (let ce = body.m_contactList; ce; ce = ce.next) {\n // if (this.m_bodyCount == this.m_bodyCapacity) { break; }\n // if (this.m_contactCount == this.m_contactCapacity) { break; }\n\n const contact = ce.contact;\n\n // Has this contact already been added to the island?\n if (contact.m_islandFlag) {\n continue;\n }\n\n // Only add if either is static, kinematic or bullet.\n const other = ce.other;\n if (other.isDynamic() && !body.isBullet() && !other.isBullet()) {\n continue;\n }\n\n // Skip sensors.\n const sensorA = contact.m_fixtureA.m_isSensor;\n const sensorB = contact.m_fixtureB.m_isSensor;\n if (sensorA || sensorB) {\n continue;\n }\n\n // Tentatively advance the body to the TOI.\n backup.set(other.m_sweep);\n if (other.m_islandFlag == false) {\n other.advance(minAlpha);\n }\n\n // Update the contact points\n contact.update(world);\n\n // Was the contact disabled by the user?\n // Are there contact points?\n if (contact.isEnabled() == false || contact.isTouching() == false) {\n other.m_sweep.set(backup);\n other.synchronizeTransform();\n continue;\n }\n\n // Add the contact to the island\n contact.m_islandFlag = true;\n this.addContact(contact);\n\n // Has the other body already been added to the island?\n if (other.m_islandFlag) {\n continue;\n }\n\n // Add the other body to the island.\n other.m_islandFlag = true;\n\n if (!other.isStatic()) {\n other.setAwake(true);\n }\n\n this.addBody(other);\n }\n }\n }\n\n s_subStep.reset((1.0 - minAlpha) * step.dt);\n s_subStep.dtRatio = 1.0;\n s_subStep.positionIterations = 20;\n s_subStep.velocityIterations = step.velocityIterations;\n s_subStep.warmStarting = false;\n\n this.solveIslandTOI(s_subStep, bA, bB);\n\n // Reset island flags and synchronize broad-phase proxies.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n body.m_islandFlag = false;\n\n if (!body.isDynamic()) {\n continue;\n }\n\n body.synchronizeFixtures();\n\n // Invalidate all contact TOIs on this displaced body.\n for (let ce = body.m_contactList; ce; ce = ce.next) {\n ce.contact.m_toiFlag = false;\n ce.contact.m_islandFlag = false;\n }\n }\n\n // Commit fixture proxy movements to the broad-phase so that new contacts\n // are created.\n // Also, some contacts can be destroyed.\n world.findNewContacts();\n\n if (world.m_subStepping) {\n world.m_stepComplete = false;\n break;\n }\n }\n }\n\n solveIslandTOI(subStep: TimeStep, toiA: Body, toiB: Body): void {\n\n // Initialize the body state.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n matrix.copyVec2(body.c_position.c, body.m_sweep.c);\n body.c_position.a = body.m_sweep.a;\n matrix.copyVec2(body.c_velocity.v, body.m_linearVelocity);\n body.c_velocity.w = body.m_angularVelocity;\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initConstraint(subStep);\n }\n\n // Solve position constraints.\n for (let i = 0; i < subStep.positionIterations; ++i) {\n let minSeparation = 0.0;\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n const separation = contact.solvePositionConstraintTOI(subStep, toiA, toiB);\n minSeparation = math_min(minSeparation, separation);\n }\n // We can't expect minSpeparation >= -Settings.linearSlop because we don't\n // push the separation above -Settings.linearSlop.\n const contactsOkay = minSeparation >= -1.5 * Settings.linearSlop;\n if (contactsOkay) {\n break;\n }\n }\n\n if (false) {\n // Is the new position really safe?\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const c = this.m_contacts[i];\n const fA = c.getFixtureA();\n const fB = c.getFixtureB();\n\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n\n const input = new DistanceInput();\n input.proxyA.set(fA.getShape(), indexA);\n input.proxyB.set(fB.getShape(), indexB);\n input.transformA.set(bA.getTransform());\n input.transformB.set(bB.getTransform());\n input.useRadii = false;\n\n const output = new DistanceOutput();\n const cache = new SimplexCache();\n Distance(output, cache, input);\n\n if (output.distance == 0 || cache.count == 3) {\n cache.count += 0;\n }\n }\n }\n\n // Leap of faith to new safe state.\n matrix.copyVec2(toiA.m_sweep.c0, toiA.c_position.c);\n toiA.m_sweep.a0 = toiA.c_position.a;\n matrix.copyVec2(toiB.m_sweep.c0, toiB.c_position.c);\n toiB.m_sweep.a0 = toiB.c_position.a;\n\n // No warm starting is needed for TOI events because warm\n // starting impulses were applied in the discrete solver.\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initVelocityConstraint(subStep);\n }\n\n // Solve velocity constraints.\n for (let i = 0; i < subStep.velocityIterations; ++i) {\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n contact.solveVelocityConstraint(subStep);\n }\n }\n\n // Don't store the TOI contact forces for warm starting\n // because they can be quite large.\n\n const h = subStep.dt;\n\n // Integrate positions\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.c_position.c);\n let a = body.c_position.a;\n matrix.copyVec2(v, body.c_velocity.v);\n let w = body.c_velocity.w;\n\n // Check for large velocities\n matrix.scaleVec2(translation, h, v);\n const translationLengthSqr = matrix.lengthSqrVec2(translation);\n if (translationLengthSqr > Settings.maxTranslationSquared) {\n const ratio = Settings.maxTranslation / math_sqrt(translationLengthSqr);\n matrix.mulVec2(v, ratio);\n }\n\n const rotation = h * w;\n if (rotation * rotation > Settings.maxRotationSquared) {\n const ratio = Settings.maxRotation / math_abs(rotation);\n w *= ratio;\n }\n\n // Integrate\n matrix.plusScaleVec2(c, h, v);\n a += h * w;\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n\n // Sync bodies\n matrix.copyVec2(body.m_sweep.c, c);\n body.m_sweep.a = a;\n matrix.copyVec2(body.m_linearVelocity, v);\n body.m_angularVelocity = w;\n body.synchronizeTransform();\n }\n\n this.postSolveIsland();\n }\n\n /** @internal */\n postSolveIsland(): void {\n for (let c = 0; c < this.m_contacts.length; ++c) {\n const contact = this.m_contacts[c];\n this.m_world.postSolve(contact, contact.m_impulse);\n }\n }\n}\n\n// @ts-ignore\nSolver.TimeStep = TimeStep;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A 2-by-2 matrix. Stored in column-major order.\n */\nexport class Mat22 {\n ex: Vec2;\n ey: Vec2;\n\n constructor(a: number, b: number, c: number, d: number);\n constructor(a: { x: number; y: number }, b: { x: number; y: number });\n constructor();\n constructor(a?, b?, c?, d?) {\n if (typeof a === \"object\" && a !== null) {\n this.ex = Vec2.clone(a);\n this.ey = Vec2.clone(b);\n } else if (typeof a === \"number\") {\n this.ex = Vec2.neo(a, c);\n this.ey = Vec2.neo(b, d);\n } else {\n this.ex = Vec2.zero();\n this.ey = Vec2.zero();\n }\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.ex) && Vec2.isValid(obj.ey);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Mat22.isValid(o), \"Invalid Mat22!\", o);\n }\n\n set(a: Mat22): void;\n set(a: Vec2Value, b: Vec2Value): void;\n set(a: number, b: number, c: number, d: number): void;\n set(a, b?, c?, d?): void {\n if (typeof a === \"number\" && typeof b === \"number\" && typeof c === \"number\"\n && typeof d === \"number\") {\n this.ex.setNum(a, c);\n this.ey.setNum(b, d);\n\n } else if (typeof a === \"object\" && typeof b === \"object\") {\n this.ex.setVec2(a);\n this.ey.setVec2(b);\n\n } else if (typeof a === \"object\") {\n if (_ASSERT) Mat22.assert(a);\n this.ex.setVec2(a.ex);\n this.ey.setVec2(a.ey);\n\n } else {\n if (_ASSERT) console.assert(false);\n }\n }\n\n setIdentity(): void {\n this.ex.x = 1.0;\n this.ey.x = 0.0;\n this.ex.y = 0.0;\n this.ey.y = 1.0;\n }\n\n setZero(): void {\n this.ex.x = 0.0;\n this.ey.x = 0.0;\n this.ex.y = 0.0;\n this.ey.y = 0.0;\n }\n\n getInverse(): Mat22 {\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const imx = new Mat22();\n imx.ex.x = det * d;\n imx.ey.x = -det * b;\n imx.ex.y = -det * c;\n imx.ey.y = det * a;\n return imx;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases.\n */\n solve(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const w = Vec2.zero();\n w.x = det * (d * v.x - b * v.y);\n w.y = det * (a * v.y - c * v.x);\n return w;\n }\n\n /**\n * Multiply a matrix times a vector. If a rotation matrix is provided, then this\n * transforms the vector from one frame to another.\n */\n static mul(mx: Mat22, my: Mat22): Mat22;\n static mul(mx: Mat22, v: Vec2Value): Vec2;\n static mul(mx, v) {\n if (v && \"x\" in v && \"y\" in v) {\n if (_ASSERT) Vec2.assert(v);\n const x = mx.ex.x * v.x + mx.ey.x * v.y;\n const y = mx.ex.y * v.x + mx.ey.y * v.y;\n return Vec2.neo(x, y);\n\n } else if (v && \"ex\" in v && \"ey\" in v) { // Mat22\n if (_ASSERT) Mat22.assert(v);\n // return new Mat22(Vec2.mul(mx, v.ex), Vec2.mul(mx, v.ey));\n const a = mx.ex.x * v.ex.x + mx.ey.x * v.ex.y;\n const b = mx.ex.x * v.ey.x + mx.ey.x * v.ey.y;\n const c = mx.ex.y * v.ex.x + mx.ey.y * v.ex.y;\n const d = mx.ex.y * v.ey.x + mx.ey.y * v.ey.y;\n return new Mat22(a, b, c, d);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulVec2(mx: Mat22, v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n const x = mx.ex.x * v.x + mx.ey.x * v.y;\n const y = mx.ex.y * v.x + mx.ey.y * v.y;\n return Vec2.neo(x, y);\n }\n\n static mulMat22(mx: Mat22, v: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(v);\n // return new Mat22(Vec2.mul(mx, v.ex), Vec2.mul(mx, v.ey));\n const a = mx.ex.x * v.ex.x + mx.ey.x * v.ex.y;\n const b = mx.ex.x * v.ey.x + mx.ey.x * v.ey.y;\n const c = mx.ex.y * v.ex.x + mx.ey.y * v.ex.y;\n const d = mx.ex.y * v.ey.x + mx.ey.y * v.ey.y;\n return new Mat22(a, b, c, d);\n }\n\n /**\n * Multiply a matrix transpose times a vector. If a rotation matrix is provided,\n * then this transforms the vector from one frame to another (inverse\n * transform).\n */\n static mulT(mx: Mat22, my: Mat22): Mat22;\n static mulT(mx: Mat22, v: Vec2Value): Vec2;\n static mulT(mx, v) {\n if (v && \"x\" in v && \"y\" in v) { // Vec2\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(Vec2.dot(v, mx.ex), Vec2.dot(v, mx.ey));\n\n } else if (v && \"ex\" in v && \"ey\" in v) { // Mat22\n if (_ASSERT) Mat22.assert(v);\n const c1 = Vec2.neo(Vec2.dot(mx.ex, v.ex), Vec2.dot(mx.ey, v.ex));\n const c2 = Vec2.neo(Vec2.dot(mx.ex, v.ey), Vec2.dot(mx.ey, v.ey));\n return new Mat22(c1, c2);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulTVec2(mx: Mat22, v: Vec2Value): Vec2 {\n if (_ASSERT) Mat22.assert(mx);\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(Vec2.dot(v, mx.ex), Vec2.dot(v, mx.ey));\n }\n\n static mulTMat22(mx: Mat22, v: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx);\n if (_ASSERT) Mat22.assert(v);\n const c1 = Vec2.neo(Vec2.dot(mx.ex, v.ex), Vec2.dot(mx.ey, v.ex));\n const c2 = Vec2.neo(Vec2.dot(mx.ex, v.ey), Vec2.dot(mx.ey, v.ey));\n return new Mat22(c1, c2);\n }\n\n static abs(mx: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx);\n return new Mat22(Vec2.abs(mx.ex), Vec2.abs(mx.ey));\n }\n\n static add(mx1: Mat22, mx2: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx1);\n if (_ASSERT) Mat22.assert(mx2);\n return new Mat22(Vec2.add(mx1.ex, mx2.ex), Vec2.add(mx1.ey, mx2.ey));\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { Vec2Value } from \"../common/Vec2\";\nimport { TransformValue } from \"../common/Transform\";\nimport { EPSILON } from \"../common/Math\";\n\n\n/** @internal */ const math_sqrt = Math.sqrt;\n\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const cA = matrix.vec2(0, 0);\n/** @internal */ const cB = matrix.vec2(0, 0);\n/** @internal */ const dist = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const clipPoint = matrix.vec2(0, 0);\n\nexport enum ManifoldType {\n e_unset = -1,\n e_circles = 0,\n e_faceA = 1,\n e_faceB = 2\n}\n\nexport enum ContactFeatureType {\n e_unset = -1,\n e_vertex = 0,\n e_face = 1\n}\n\n/**\n * This is used for determining the state of contact points.\n */\n export enum PointState {\n /** Point does not exist */\n nullState = 0,\n /** Point was added in the update */\n addState = 1,\n /** Point persisted across the update */\n persistState = 2,\n /** Point was removed in the update */\n removeState = 3\n}\n\n/**\n * Used for computing contact manifolds.\n */\n export class ClipVertex {\n v = matrix.vec2(0, 0);\n id: ContactID = new ContactID();\n\n set(o: ClipVertex): void {\n matrix.copyVec2(this.v, o.v);\n this.id.set(o.id);\n }\n recycle() {\n matrix.zeroVec2(this.v);\n this.id.recycle();\n }\n}\n\n/**\n * A manifold for two touching convex shapes. Manifolds are created in `evaluate`\n * method of Contact subclasses.\n *\n * Supported manifold types are e_faceA or e_faceB for clip point versus plane\n * with radius and e_circles point versus point with radius.\n *\n * We store contacts in this way so that position correction can account for\n * movement, which is critical for continuous physics. All contact scenarios\n * must be expressed in one of these types. This structure is stored across time\n * steps, so we keep it small.\n */\nexport class Manifold {\n type: ManifoldType;\n\n /**\n * Usage depends on manifold type:\n * - circles: not used\n * - faceA: the normal on polygonA\n * - faceB: the normal on polygonB\n */\n localNormal = matrix.vec2(0, 0);\n\n /**\n * Usage depends on manifold type:\n * - circles: the local center of circleA\n * - faceA: the center of faceA\n * - faceB: the center of faceB\n */\n localPoint = matrix.vec2(0, 0);\n\n /** The points of contact */\n points: ManifoldPoint[] = [ new ManifoldPoint(), new ManifoldPoint() ];\n\n /** The number of manifold points */\n pointCount: number = 0;\n\n set(that: Manifold): void {\n this.type = that.type;\n matrix.copyVec2(this.localNormal, that.localNormal);\n matrix.copyVec2(this.localPoint, that.localPoint);\n this.pointCount = that.pointCount;\n this.points[0].set(that.points[0]);\n this.points[1].set(that.points[1]);\n }\n\n recycle(): void {\n this.type = ManifoldType.e_unset;\n matrix.zeroVec2(this.localNormal);\n matrix.zeroVec2(this.localPoint);\n this.pointCount = 0;\n this.points[0].recycle();\n this.points[1].recycle();\n }\n\n /**\n * Evaluate the manifold with supplied transforms. This assumes modest motion\n * from the original state. This does not change the point count, impulses, etc.\n * The radii must come from the shapes that generated the manifold.\n */\n getWorldManifold(wm: WorldManifold | null, xfA: TransformValue, radiusA: number, xfB: TransformValue, radiusB: number): WorldManifold {\n if (this.pointCount == 0) {\n return wm;\n }\n\n wm = wm || new WorldManifold();\n\n wm.pointCount = this.pointCount;\n\n const normal = wm.normal;\n const points = wm.points;\n const separations = wm.separations;\n\n switch (this.type) {\n case ManifoldType.e_circles: {\n matrix.setVec2(normal, 1.0, 0.0);\n const manifoldPoint = this.points[0];\n matrix.transformVec2(pointA, xfA, this.localPoint);\n matrix.transformVec2(pointB, xfB, manifoldPoint.localPoint);\n matrix.subVec2(dist, pointB, pointA);\n const lengthSqr = matrix.lengthSqrVec2(dist);\n if (lengthSqr > EPSILON * EPSILON) {\n const length = math_sqrt(lengthSqr);\n matrix.scaleVec2(normal, 1 / length, dist);\n }\n matrix.combine2Vec2(cA, 1, pointA, radiusA, normal);\n matrix.combine2Vec2(cB, 1, pointB, -radiusB, normal);\n matrix.combine2Vec2(points[0], 0.5, cA, 0.5, cB);\n separations[0] = matrix.dotVec2(matrix.subVec2(temp, cB, cA), normal);\n break;\n }\n\n case ManifoldType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.localNormal);\n matrix.transformVec2(planePoint, xfA, this.localPoint);\n\n for (let i = 0; i < this.pointCount; ++i) {\n const manifoldPoint = this.points[i];\n matrix.transformVec2(clipPoint, xfB, manifoldPoint.localPoint);\n matrix.combine2Vec2(cA, 1, clipPoint, radiusA - matrix.dotVec2(matrix.subVec2(temp, clipPoint, planePoint), normal), normal);\n matrix.combine2Vec2(cB, 1, clipPoint, -radiusB, normal);\n matrix.combine2Vec2(points[i], 0.5, cA, 0.5, cB);\n separations[i] = matrix.dotVec2(matrix.subVec2(temp, cB, cA), normal);\n }\n break;\n }\n\n case ManifoldType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.localNormal);\n matrix.transformVec2(planePoint, xfB, this.localPoint);\n\n for (let i = 0; i < this.pointCount; ++i) {\n const manifoldPoint = this.points[i];\n matrix.transformVec2(clipPoint, xfA, manifoldPoint.localPoint);\n matrix.combine2Vec2(cB, 1, clipPoint, radiusB - matrix.dotVec2(matrix.subVec2(temp, clipPoint, planePoint), normal), normal);\n matrix.combine2Vec2(cA, 1, clipPoint, -radiusA, normal);\n matrix.combine2Vec2(points[i], 0.5, cA, 0.5, cB);\n separations[i] = matrix.dotVec2(matrix.subVec2(temp, cA, cB), normal);\n }\n // Ensure normal points from A to B.\n matrix.negVec2(normal);\n break;\n }\n }\n\n return wm;\n }\n\n static clipSegmentToLine = clipSegmentToLine;\n static ClipVertex = ClipVertex;\n static getPointStates = getPointStates;\n static PointState = PointState;\n}\n\n/**\n * A manifold point is a contact point belonging to a contact manifold. It holds\n * details related to the geometry and dynamics of the contact points.\n *\n * This structure is stored across time steps, so we keep it small.\n *\n * Note: impulses are used for internal caching and may not provide reliable\n * contact forces, especially for high speed collisions.\n */\nexport class ManifoldPoint {\n /**\n * Usage depends on manifold type:\n * - circles: the local center of circleB\n * - faceA: the local center of circleB or the clip point of polygonB\n * - faceB: the clip point of polygonA\n */\n localPoint = matrix.vec2(0, 0);\n /**\n * The non-penetration impulse\n */\n normalImpulse = 0;\n /**\n * The friction impulse\n */\n tangentImpulse = 0;\n /**\n * Uniquely identifies a contact point between two shapes to facilitate warm starting\n */\n readonly id = new ContactID();\n\n set(that: ManifoldPoint): void {\n matrix.copyVec2(this.localPoint, that.localPoint);\n this.normalImpulse = that.normalImpulse;\n this.tangentImpulse = that.tangentImpulse;\n this.id.set(that.id);\n }\n\n recycle(): void {\n matrix.zeroVec2(this.localPoint);\n this.normalImpulse = 0;\n this.tangentImpulse = 0;\n this.id.recycle();\n }\n}\n\n/**\n * Contact ids to facilitate warm starting.\n * \n * ContactFeature: The features that intersect to form the contact point.\n */\nexport class ContactID {\n\n /**\n * Used to quickly compare contact ids.\n */\n key = -1;\n\n /** ContactFeature index on shapeA */\n indexA = -1;\n\n /** ContactFeature index on shapeB */\n indexB = -1;\n\n /** ContactFeature type on shapeA */\n typeA = ContactFeatureType.e_unset;\n\n /** ContactFeature type on shapeB */\n typeB = ContactFeatureType.e_unset;\n\n setFeatures(indexA: number, typeA: ContactFeatureType, indexB: number, typeB: ContactFeatureType): void {\n this.indexA = indexA;\n this.indexB = indexB;\n this.typeA = typeA;\n this.typeB = typeB;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n set(that: ContactID): void {\n this.indexA = that.indexA;\n this.indexB = that.indexB;\n this.typeA = that.typeA;\n this.typeB = that.typeB;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n swapFeatures(): void {\n const indexA = this.indexA;\n const indexB = this.indexB;\n const typeA = this.typeA;\n const typeB = this.typeB;\n this.indexA = indexB;\n this.indexB = indexA;\n this.typeA = typeB;\n this.typeB = typeA;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n recycle(): void {\n this.indexA = 0;\n this.indexB = 0;\n this.typeA = ContactFeatureType.e_unset;\n this.typeB = ContactFeatureType.e_unset;\n this.key = -1;\n }\n}\n\n/**\n * This is used to compute the current state of a contact manifold.\n */\nexport class WorldManifold {\n /** World vector pointing from A to B */\n normal = matrix.vec2(0, 0);\n\n /** World contact point (point of intersection) */\n points = [matrix.vec2(0, 0), matrix.vec2(0, 0)]; // [maxManifoldPoints]\n\n /** A negative value indicates overlap, in meters */\n separations = [0, 0]; // [maxManifoldPoints]\n\n /** The number of manifold points */\n pointCount = 0;\n\n recycle() {\n matrix.zeroVec2(this.normal);\n matrix.zeroVec2(this.points[0]);\n matrix.zeroVec2(this.points[1]);\n this.separations[0] = 0;\n this.separations[1] = 0;\n this.pointCount = 0;\n }\n}\n\n/**\n * Compute the point states given two manifolds. The states pertain to the\n * transition from manifold1 to manifold2. So state1 is either persist or remove\n * while state2 is either add or persist.\n */\nexport function getPointStates(\n state1: PointState[],\n state2: PointState[],\n manifold1: Manifold,\n manifold2: Manifold\n): void {\n // state1, state2: PointState[Settings.maxManifoldPoints]\n\n // for (var i = 0; i < Settings.maxManifoldPoints; ++i) {\n // state1[i] = PointState.nullState;\n // state2[i] = PointState.nullState;\n // }\n\n // Detect persists and removes.\n for (let i = 0; i < manifold1.pointCount; ++i) {\n const id = manifold1.points[i].id;\n\n state1[i] = PointState.removeState;\n\n for (let j = 0; j < manifold2.pointCount; ++j) {\n if (manifold2.points[j].id.key === id.key) {\n state1[i] = PointState.persistState;\n break;\n }\n }\n }\n\n // Detect persists and adds.\n for (let i = 0; i < manifold2.pointCount; ++i) {\n const id = manifold2.points[i].id;\n\n state2[i] = PointState.addState;\n\n for (let j = 0; j < manifold1.pointCount; ++j) {\n if (manifold1.points[j].id.key === id.key) {\n state2[i] = PointState.persistState;\n break;\n }\n }\n }\n}\n\n/**\n * Clipping for contact manifolds. Sutherland-Hodgman clipping.\n */\nexport function clipSegmentToLine(\n vOut: ClipVertex[],\n vIn: ClipVertex[],\n normal: Vec2Value,\n offset: number,\n vertexIndexA: number\n): number {\n // Start with no output points\n let numOut = 0;\n\n // Calculate the distance of end points to the line\n const distance0 = matrix.dotVec2(normal, vIn[0].v) - offset;\n const distance1 = matrix.dotVec2(normal, vIn[1].v) - offset;\n\n // If the points are behind the plane\n if (distance0 <= 0.0)\n vOut[numOut++].set(vIn[0]);\n if (distance1 <= 0.0)\n vOut[numOut++].set(vIn[1]);\n\n // If the points are on different sides of the plane\n if (distance0 * distance1 < 0.0) {\n // Find intersection point of edge and plane\n const interp = distance0 / (distance0 - distance1);\n matrix.combine2Vec2(vOut[numOut].v, 1 - interp, vIn[0].v, interp, vIn[1].v);\n\n // VertexA is hitting edgeB.\n vOut[numOut].id.setFeatures(vertexIndexA, ContactFeatureType.e_vertex, vIn[0].id.indexB, ContactFeatureType.e_face);\n ++numOut;\n }\n\n return numOut;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { ShapeType } from \"../collision/Shape\";\nimport { clamp } from \"../common/Math\";\nimport { TransformValue } from \"../common/Transform\";\nimport { Mat22 } from \"../common/Mat22\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { Manifold, ManifoldType, WorldManifold } from \"../collision/Manifold\";\nimport { testOverlap } from \"../collision/Distance\";\nimport { Fixture } from \"./Fixture\";\nimport { Body } from \"./Body\";\nimport { ContactImpulse, TimeStep } from \"./Solver\";\nimport { Pool } from \"../util/Pool\";\nimport { getTransform } from \"./Position\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n// Solver debugging is normally disabled because the block solver sometimes has to deal with a poorly conditioned effective mass matrix.\n/** @internal */ const DEBUG_SOLVER = false;\n\n/** @internal */ const contactPool = new Pool({\n create() {\n return new Contact();\n },\n release(contact: Contact) {\n contact.recycle();\n }\n});\n\n/** @internal */ const oldManifold = new Manifold();\n\n/** @internal */ const worldManifold = new WorldManifold();\n\n/**\n * A contact edge is used to connect bodies and contacts together in a contact\n * graph where each body is a node and each contact is an edge. A contact edge\n * belongs to a doubly linked list maintained in each attached body. Each\n * contact has two contact nodes, one for each attached body.\n */\nexport class ContactEdge {\n contact: Contact;\n prev: ContactEdge | null = null;\n next: ContactEdge | null = null;\n other: Body | null = null;\n constructor(contact: Contact) {\n this.contact = contact;\n }\n\n /** @internal */\n recycle() {\n this.prev = null;\n this.next = null;\n this.other = null;\n }\n}\n\nexport type EvaluateFunction = (\n manifold: Manifold,\n xfA: TransformValue,\n fixtureA: Fixture,\n indexA: number,\n xfB: TransformValue,\n fixtureB: Fixture,\n indexB: number\n) => void;\n\n/**\n * Friction mixing law. The idea is to allow either fixture to drive the\n * friction to zero. For example, anything slides on ice.\n */\nexport function mixFriction(friction1: number, friction2: number): number {\n return math_sqrt(friction1 * friction2);\n}\n\n/**\n * Restitution mixing law. The idea is allow for anything to bounce off an\n * inelastic surface. For example, a superball bounces on anything.\n */\nexport function mixRestitution(restitution1: number, restitution2: number): number {\n return restitution1 > restitution2 ? restitution1 : restitution2;\n}\n\n// TODO: move this to Settings?\n/** @internal */ const s_registers = [];\n\n// TODO: merge with ManifoldPoint?\nexport class VelocityConstraintPoint {\n rA = matrix.vec2(0, 0);\n rB = matrix.vec2(0, 0);\n normalImpulse = 0;\n tangentImpulse = 0;\n normalMass = 0;\n tangentMass = 0;\n velocityBias = 0;\n\n recycle() {\n matrix.zeroVec2(this.rA);\n matrix.zeroVec2(this.rB);\n this.normalImpulse = 0;\n this.tangentImpulse = 0;\n this.normalMass = 0;\n this.tangentMass = 0;\n this.velocityBias = 0;\n }\n}\n\n/** @internal */ const cA = matrix.vec2(0, 0);\n/** @internal */ const vA = matrix.vec2(0, 0);\n/** @internal */ const cB = matrix.vec2(0, 0);\n/** @internal */ const vB = matrix.vec2(0, 0);\n/** @internal */ const tangent = matrix.vec2(0, 0);\n/** @internal */ const xfA = matrix.transform(0, 0, 0);\n/** @internal */ const xfB = matrix.transform(0, 0, 0);\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const clipPoint = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const rA = matrix.vec2(0, 0);\n/** @internal */ const rB = matrix.vec2(0, 0);\n/** @internal */ const P = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const point = matrix.vec2(0, 0);\n/** @internal */ const dv = matrix.vec2(0, 0);\n/** @internal */ const dv1 = matrix.vec2(0, 0);\n/** @internal */ const dv2 = matrix.vec2(0, 0);\n/** @internal */ const b = matrix.vec2(0, 0);\n/** @internal */ const a = matrix.vec2(0, 0);\n/** @internal */ const x = matrix.vec2(0, 0);\n/** @internal */ const d = matrix.vec2(0, 0);\n/** @internal */ const P1 = matrix.vec2(0, 0);\n/** @internal */ const P2 = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n\n/**\n * The class manages contact between two shapes. A contact exists for each\n * overlapping AABB in the broad-phase (except if filtered). Therefore a contact\n * object may exist that has no contact points.\n */\nexport class Contact {\n // Nodes for connecting bodies.\n /** @internal */ m_nodeA = new ContactEdge(this);\n /** @internal */ m_nodeB = new ContactEdge(this);\n /** @internal */ m_fixtureA: Fixture | null = null;\n /** @internal */ m_fixtureB: Fixture | null = null;\n /** @internal */ m_indexA = -1;\n /** @internal */ m_indexB = -1;\n /** @internal */ m_evaluateFcn: EvaluateFunction | null = null;\n /** @internal */ m_manifold: Manifold = new Manifold();\n /** @internal */ m_prev: Contact | null = null;\n /** @internal */ m_next: Contact | null = null;\n /** @internal */ m_toi = 1.0;\n /** @internal */ m_toiCount = 0;\n // This contact has a valid TOI in m_toi\n /** @internal */ m_toiFlag = false;\n /** @internal */ m_friction = 0.0;\n /** @internal */ m_restitution = 0.0;\n /** @internal */ m_tangentSpeed = 0.0;\n /** @internal This contact can be disabled (by user) */\n m_enabledFlag = true;\n /** @internal Used when crawling contact graph when forming islands. */\n m_islandFlag = false;\n /** @internal Set when the shapes are touching. */\n m_touchingFlag = false;\n /** @internal This contact needs filtering because a fixture filter was changed. */\n m_filterFlag = false;\n /** @internal This bullet contact had a TOI event */\n m_bulletHitFlag = false;\n\n /** @internal Contact reporting impulse object cache */\n m_impulse: ContactImpulse = new ContactImpulse(this);\n\n // VelocityConstraint\n /** @internal */ v_points = [new VelocityConstraintPoint(), new VelocityConstraintPoint()]; // [maxManifoldPoints];\n /** @internal */ v_normal = matrix.vec2(0, 0);\n /** @internal */ v_normalMass: Mat22 = new Mat22();\n /** @internal */ v_K: Mat22 = new Mat22();\n /** @internal */ v_pointCount = 0;\n /** @internal */ v_tangentSpeed = 0;\n /** @internal */ v_friction = 0;\n /** @internal */ v_restitution = 0;\n /** @internal */ v_invMassA = 0;\n /** @internal */ v_invMassB = 0;\n /** @internal */ v_invIA = 0;\n /** @internal */ v_invIB = 0;\n\n // PositionConstraint\n /** @internal */ p_localPoints = [matrix.vec2(0, 0), matrix.vec2(0, 0)]; // [maxManifoldPoints];\n /** @internal */ p_localNormal = matrix.vec2(0, 0);\n /** @internal */ p_localPoint = matrix.vec2(0, 0);\n /** @internal */ p_localCenterA = matrix.vec2(0, 0);\n /** @internal */ p_localCenterB = matrix.vec2(0, 0);\n /** @internal */ p_type = ManifoldType.e_unset;\n /** @internal */ p_radiusA = 0;\n /** @internal */ p_radiusB = 0;\n /** @internal */ p_pointCount = 0;\n /** @internal */ p_invMassA = 0;\n /** @internal */ p_invMassB = 0;\n /** @internal */ p_invIA = 0;\n /** @internal */ p_invIB = 0;\n\n /** @internal */ \n initialize(fA: Fixture, indexA: number, fB: Fixture, indexB: number, evaluateFcn: EvaluateFunction) {\n this.m_fixtureA = fA;\n this.m_fixtureB = fB;\n\n this.m_indexA = indexA;\n this.m_indexB = indexB;\n\n this.m_evaluateFcn = evaluateFcn;\n\n this.m_friction = mixFriction(this.m_fixtureA.m_friction, this.m_fixtureB.m_friction);\n this.m_restitution = mixRestitution(this.m_fixtureA.m_restitution, this.m_fixtureB.m_restitution);\n }\n\n /** @internal */ \n recycle() {\n this.m_nodeA.recycle();\n this.m_nodeB.recycle();\n this.m_fixtureA = null;\n this.m_fixtureB = null;\n this.m_indexA = -1;\n this.m_indexB = -1;\n this.m_evaluateFcn = null;\n this.m_manifold.recycle();\n this.m_prev = null;\n this.m_next = null;\n this.m_toi = 1;\n this.m_toiCount = 0;\n this.m_toiFlag = false;\n this.m_friction = 0;\n this.m_restitution = 0;\n this.m_tangentSpeed = 0;\n this.m_enabledFlag = true;\n this.m_islandFlag = false;\n this.m_touchingFlag = false;\n this.m_filterFlag = false;\n this.m_bulletHitFlag = false;\n\n this.m_impulse.recycle();\n\n // VelocityConstraint\n for(const point of this.v_points) {\n point.recycle();\n }\n matrix.zeroVec2(this.v_normal);\n this.v_normalMass.setZero();\n this.v_K.setZero();\n this.v_pointCount = 0;\n this.v_tangentSpeed = 0;\n this.v_friction = 0;\n this.v_restitution = 0;\n this.v_invMassA = 0;\n this.v_invMassB = 0;\n this.v_invIA = 0;\n this.v_invIB = 0;\n\n // PositionConstraint\n for(const point of this.p_localPoints) {\n matrix.zeroVec2(point);\n }\n matrix.zeroVec2(this.p_localNormal);\n matrix.zeroVec2(this.p_localPoint);\n matrix.zeroVec2(this.p_localCenterA);\n matrix.zeroVec2(this.p_localCenterB);\n this.p_type = ManifoldType.e_unset;\n this.p_radiusA = 0;\n this.p_radiusB = 0;\n this.p_pointCount = 0;\n this.p_invMassA = 0;\n this.p_invMassB = 0;\n this.p_invIA = 0;\n this.p_invIB = 0;\n }\n\n initConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n const manifold = this.m_manifold;\n\n const pointCount = manifold.pointCount;\n if (_ASSERT) console.assert(pointCount > 0);\n\n this.v_invMassA = bodyA.m_invMass;\n this.v_invMassB = bodyB.m_invMass;\n this.v_invIA = bodyA.m_invI;\n this.v_invIB = bodyB.m_invI;\n\n this.v_friction = this.m_friction;\n this.v_restitution = this.m_restitution;\n this.v_tangentSpeed = this.m_tangentSpeed;\n\n this.v_pointCount = pointCount;\n\n this.v_K.setZero();\n this.v_normalMass.setZero();\n\n this.p_invMassA = bodyA.m_invMass;\n this.p_invMassB = bodyB.m_invMass;\n this.p_invIA = bodyA.m_invI;\n this.p_invIB = bodyB.m_invI;\n matrix.copyVec2(this.p_localCenterA, bodyA.m_sweep.localCenter);\n matrix.copyVec2(this.p_localCenterB, bodyB.m_sweep.localCenter);\n\n this.p_radiusA = shapeA.m_radius;\n this.p_radiusB = shapeB.m_radius;\n\n this.p_type = manifold.type;\n matrix.copyVec2(this.p_localNormal, manifold.localNormal);\n matrix.copyVec2(this.p_localPoint, manifold.localPoint);\n this.p_pointCount = pointCount;\n\n for (let j = 0; j < Settings.maxManifoldPoints; ++j) {\n this.v_points[j].recycle();\n matrix.zeroVec2(this.p_localPoints[j]);\n }\n\n for (let j = 0; j < pointCount; ++j) {\n const cp = manifold.points[j];\n const vcp = this.v_points[j];\n if (step.warmStarting) {\n vcp.normalImpulse = step.dtRatio * cp.normalImpulse;\n vcp.tangentImpulse = step.dtRatio * cp.tangentImpulse;\n }\n matrix.copyVec2(this.p_localPoints[j], cp.localPoint);\n }\n }\n\n /**\n * Get the contact manifold. Do not modify the manifold unless you understand\n * the internals of the library.\n */\n getManifold(): Manifold {\n return this.m_manifold;\n }\n\n /**\n * Get the world manifold.\n */\n getWorldManifold(worldManifold: WorldManifold | null): WorldManifold | undefined {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n return this.m_manifold.getWorldManifold(\n worldManifold,\n bodyA.getTransform(), shapeA.m_radius,\n bodyB.getTransform(), shapeB.m_radius\n );\n }\n\n /**\n * Enable/disable this contact. This can be used inside the pre-solve contact\n * listener. The contact is only disabled for the current time step (or sub-step\n * in continuous collisions).\n */\n setEnabled(flag: boolean): void {\n this.m_enabledFlag = !!flag;\n }\n\n /**\n * Has this contact been disabled?\n */\n isEnabled(): boolean {\n return this.m_enabledFlag;\n }\n\n /**\n * Is this contact touching?\n */\n isTouching(): boolean {\n return this.m_touchingFlag;\n }\n\n /**\n * Get the next contact in the world's contact list.\n */\n getNext(): Contact | null {\n return this.m_next;\n }\n\n /**\n * Get fixture A in this contact.\n */\n getFixtureA(): Fixture {\n return this.m_fixtureA;\n }\n\n /**\n * Get fixture B in this contact.\n */\n getFixtureB(): Fixture {\n return this.m_fixtureB;\n }\n\n /**\n * Get the child primitive index for fixture A.\n */\n getChildIndexA(): number {\n return this.m_indexA;\n }\n\n /**\n * Get the child primitive index for fixture B.\n */\n getChildIndexB(): number {\n return this.m_indexB;\n }\n\n /**\n * Flag this contact for filtering. Filtering will occur the next time step.\n */\n flagForFiltering(): void {\n this.m_filterFlag = true;\n }\n\n /**\n * Override the default friction mixture. You can call this in\n * \"pre-solve\" callback. This value persists until set or reset.\n */\n setFriction(friction: number): void {\n this.m_friction = friction;\n }\n\n /**\n * Get the friction.\n */\n getFriction(): number {\n return this.m_friction;\n }\n\n /**\n * Reset the friction mixture to the default value.\n */\n resetFriction(): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_friction = mixFriction(fixtureA.m_friction, fixtureB.m_friction);\n }\n\n /**\n * Override the default restitution mixture. You can call this in\n * \"pre-solve\" callback. The value persists until you set or reset.\n */\n setRestitution(restitution: number): void {\n this.m_restitution = restitution;\n }\n\n /**\n * Get the restitution.\n */\n getRestitution(): number {\n return this.m_restitution;\n }\n\n /**\n * Reset the restitution to the default value.\n */\n resetRestitution(): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_restitution = mixRestitution(fixtureA.m_restitution, fixtureB.m_restitution);\n }\n\n /**\n * Set the desired tangent speed for a conveyor belt behavior. In meters per\n * second.\n */\n setTangentSpeed(speed: number): void {\n this.m_tangentSpeed = speed;\n }\n\n /**\n * Get the desired tangent speed. In meters per second.\n */\n getTangentSpeed(): number {\n return this.m_tangentSpeed;\n }\n\n /**\n * Called by Update method, and implemented by subclasses.\n */\n evaluate(manifold: Manifold, xfA: TransformValue, xfB: TransformValue): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_evaluateFcn(manifold, xfA, fixtureA, this.m_indexA, xfB, fixtureB, this.m_indexB);\n }\n\n /**\n * Updates the contact manifold and touching status.\n *\n * Note: do not assume the fixture AABBs are overlapping or are valid.\n *\n * @param listener.beginContact\n * @param listener.endContact\n * @param listener.preSolve\n */\n update(listener?: {\n beginContact(contact: Contact): void,\n endContact(contact: Contact): void,\n preSolve(contact: Contact, oldManifold: Manifold): void\n }): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n // Re-enable this contact.\n this.m_enabledFlag = true;\n\n let touching = false;\n const wasTouching = this.m_touchingFlag;\n\n const sensorA = fixtureA.m_isSensor;\n const sensorB = fixtureB.m_isSensor;\n const sensor = sensorA || sensorB;\n\n const xfA = bodyA.m_xf;\n const xfB = bodyB.m_xf;\n\n // Is this contact a sensor?\n if (sensor) {\n touching = testOverlap(shapeA, this.m_indexA, shapeB, this.m_indexB, xfA, xfB);\n\n // Sensors don't generate manifolds.\n this.m_manifold.pointCount = 0;\n } else {\n\n oldManifold.recycle();\n oldManifold.set(this.m_manifold);\n this.m_manifold.recycle();\n\n this.evaluate(this.m_manifold, xfA, xfB);\n touching = this.m_manifold.pointCount > 0;\n\n // Match old contact ids to new contact ids and copy the\n // stored impulses to warm start the solver.\n for (let i = 0; i < this.m_manifold.pointCount; ++i) {\n const nmp = this.m_manifold.points[i];\n nmp.normalImpulse = 0.0;\n nmp.tangentImpulse = 0.0;\n\n for (let j = 0; j < oldManifold.pointCount; ++j) {\n const omp = oldManifold.points[j];\n if (omp.id.key === nmp.id.key) {\n nmp.normalImpulse = omp.normalImpulse;\n nmp.tangentImpulse = omp.tangentImpulse;\n break;\n }\n }\n }\n\n if (touching !== wasTouching) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n }\n\n this.m_touchingFlag = touching;\n\n const hasListener = typeof listener === \"object\" && listener !== null;\n\n if (!wasTouching && touching && hasListener) {\n listener.beginContact(this);\n }\n\n if (wasTouching && !touching && hasListener) {\n listener.endContact(this);\n }\n\n if (!sensor && touching && hasListener && oldManifold) {\n listener.preSolve(this, oldManifold);\n }\n }\n\n solvePositionConstraint(step: TimeStep): number {\n return this._solvePositionConstraint(step, null, null);\n }\n\n solvePositionConstraintTOI(step: TimeStep, toiA: Body, toiB: Body): number {\n return this._solvePositionConstraint(step, toiA, toiB);\n }\n\n private _solvePositionConstraint(step: TimeStep, toiA: Body | null, toiB: Body | null): number {\n const toi = toiA !== null && toiB !== null ? true : false;\n let minSeparation = 0.0;\n\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return minSeparation;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return minSeparation;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const localCenterA = this.p_localCenterA;\n const localCenterB = this.p_localCenterB;\n\n let mA = 0.0;\n let iA = 0.0;\n if (!toi || (bodyA === toiA || bodyA === toiB)) {\n mA = this.p_invMassA;\n iA = this.p_invIA;\n }\n\n let mB = 0.0;\n let iB = 0.0;\n if (!toi || (bodyB === toiA || bodyB === toiB)) {\n mB = this.p_invMassB;\n iB = this.p_invIB;\n }\n\n matrix.copyVec2(cA, positionA.c);\n let aA = positionA.a;\n\n matrix.copyVec2(cB, positionB.c);\n let aB = positionB.a;\n\n // Solve normal constraints\n for (let j = 0; j < this.p_pointCount; ++j) {\n getTransform(xfA, localCenterA, cA, aA);\n getTransform(xfB, localCenterB, cB, aB);\n\n // PositionSolverManifold\n let separation: number;\n switch (this.p_type) {\n case ManifoldType.e_circles: {\n matrix.transformVec2(pointA, xfA, this.p_localPoint);\n matrix.transformVec2(pointB, xfB, this.p_localPoints[0]);\n matrix.subVec2(normal, pointB, pointA);\n matrix.normalizeVec2(normal);\n\n matrix.combine2Vec2(point, 0.5, pointA, 0.5, pointB);\n separation = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal) - this.p_radiusA - this.p_radiusB;\n break;\n }\n\n case ManifoldType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.p_localNormal);\n matrix.transformVec2(planePoint, xfA, this.p_localPoint);\n matrix.transformVec2(clipPoint, xfB, this.p_localPoints[j]);\n separation = matrix.dotVec2(clipPoint, normal) - matrix.dotVec2(planePoint, normal) - this.p_radiusA - this.p_radiusB;\n matrix.copyVec2(point, clipPoint);\n break;\n }\n\n case ManifoldType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.p_localNormal);\n matrix.transformVec2(planePoint, xfB, this.p_localPoint);\n matrix.transformVec2(clipPoint, xfA, this.p_localPoints[j]);\n separation = matrix.dotVec2(clipPoint, normal) - matrix.dotVec2(planePoint, normal) - this.p_radiusA - this.p_radiusB;\n matrix.copyVec2(point, clipPoint);\n\n // Ensure normal points from A to B\n matrix.negVec2(normal);\n break;\n }\n // todo: what should we do here?\n default: {\n return minSeparation;\n }\n }\n\n matrix.subVec2(rA, point, cA);\n matrix.subVec2(rB, point, cB);\n\n // Track max constraint error.\n minSeparation = math_min(minSeparation, separation);\n\n const baumgarte = toi ? Settings.toiBaugarte : Settings.baumgarte;\n const linearSlop = Settings.linearSlop;\n const maxLinearCorrection = Settings.maxLinearCorrection;\n\n // Prevent large corrections and allow slop.\n const C = clamp(baumgarte * (separation + linearSlop), -maxLinearCorrection, 0.0);\n\n // Compute the effective mass.\n const rnA = matrix.crossVec2Vec2(rA, normal);\n const rnB = matrix.crossVec2Vec2(rB, normal);\n const K = mA + mB + iA * rnA * rnA + iB * rnB * rnB;\n\n // Compute normal impulse\n const impulse = K > 0.0 ? -C / K : 0.0;\n\n matrix.scaleVec2(P, impulse, normal);\n\n matrix.minusScaleVec2(cA, mA, P);\n aA -= iA * matrix.crossVec2Vec2(rA, P);\n\n matrix.plusScaleVec2(cB, mB, P);\n aB += iB * matrix.crossVec2Vec2(rB, P);\n }\n\n matrix.copyVec2(positionA.c, cA);\n positionA.a = aA;\n\n matrix.copyVec2(positionB.c, cB);\n positionB.a = aB;\n\n return minSeparation;\n }\n\n initVelocityConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const radiusA = this.p_radiusA;\n const radiusB = this.p_radiusB;\n const manifold = this.m_manifold;\n\n const mA = this.v_invMassA;\n const mB = this.v_invMassB;\n const iA = this.v_invIA;\n const iB = this.v_invIB;\n const localCenterA = this.p_localCenterA;\n const localCenterB = this.p_localCenterB;\n\n matrix.copyVec2(cA, positionA.c);\n const aA = positionA.a;\n matrix.copyVec2(vA, velocityA.v);\n const wA = velocityA.w;\n\n matrix.copyVec2(cB, positionB.c);\n const aB = positionB.a;\n matrix.copyVec2(vB, velocityB.v);\n const wB = velocityB.w;\n\n if (_ASSERT) console.assert(manifold.pointCount > 0);\n\n getTransform(xfA, localCenterA, cA, aA);\n getTransform(xfB, localCenterB, cB, aB);\n\n worldManifold.recycle();\n manifold.getWorldManifold(worldManifold, xfA, radiusA, xfB, radiusB);\n\n matrix.copyVec2(this.v_normal, worldManifold.normal);\n\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n const wmp = worldManifold.points[j];\n\n matrix.subVec2(vcp.rA, wmp, cA);\n matrix.subVec2(vcp.rB, wmp, cB);\n\n const rnA = matrix.crossVec2Vec2(vcp.rA, this.v_normal);\n const rnB = matrix.crossVec2Vec2(vcp.rB, this.v_normal);\n\n const kNormal = mA + mB + iA * rnA * rnA + iB * rnB * rnB;\n\n vcp.normalMass = kNormal > 0.0 ? 1.0 / kNormal : 0.0;\n\n matrix.crossVec2Num(tangent, this.v_normal, 1.0);\n\n const rtA = matrix.crossVec2Vec2(vcp.rA, tangent);\n const rtB = matrix.crossVec2Vec2(vcp.rB, tangent);\n\n const kTangent = mA + mB + iA * rtA * rtA + iB * rtB * rtB;\n\n vcp.tangentMass = kTangent > 0.0 ? 1.0 / kTangent : 0.0;\n\n // Setup a velocity bias for restitution.\n vcp.velocityBias = 0.0;\n let vRel = 0;\n vRel += matrix.dotVec2(this.v_normal, vB);\n vRel += matrix.dotVec2(this.v_normal, matrix.crossNumVec2(temp, wB, vcp.rB));\n vRel -= matrix.dotVec2(this.v_normal, vA);\n vRel -= matrix.dotVec2(this.v_normal, matrix.crossNumVec2(temp, wA, vcp.rA));\n if (vRel < -Settings.velocityThreshold) {\n vcp.velocityBias = -this.v_restitution * vRel;\n }\n }\n\n // If we have two points, then prepare the block solver.\n if (this.v_pointCount == 2 && step.blockSolve) {\n const vcp1 = this.v_points[0]; // VelocityConstraintPoint\n const vcp2 = this.v_points[1]; // VelocityConstraintPoint\n\n const rn1A = matrix.crossVec2Vec2(vcp1.rA, this.v_normal);\n const rn1B = matrix.crossVec2Vec2(vcp1.rB, this.v_normal);\n const rn2A = matrix.crossVec2Vec2(vcp2.rA, this.v_normal);\n const rn2B = matrix.crossVec2Vec2(vcp2.rB, this.v_normal);\n\n const k11 = mA + mB + iA * rn1A * rn1A + iB * rn1B * rn1B;\n const k22 = mA + mB + iA * rn2A * rn2A + iB * rn2B * rn2B;\n const k12 = mA + mB + iA * rn1A * rn2A + iB * rn1B * rn2B;\n\n // Ensure a reasonable condition number.\n const k_maxConditionNumber = 1000.0;\n if (k11 * k11 < k_maxConditionNumber * (k11 * k22 - k12 * k12)) {\n // K is safe to invert.\n this.v_K.ex.setNum(k11, k12);\n this.v_K.ey.setNum(k12, k22);\n // this.v_normalMass.set(this.v_K.getInverse());\n const a = this.v_K.ex.x;\n const b = this.v_K.ey.x;\n const c = this.v_K.ex.y;\n const d = this.v_K.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n this.v_normalMass.ex.x = det * d;\n this.v_normalMass.ey.x = -det * b;\n this.v_normalMass.ex.y = -det * c;\n this.v_normalMass.ey.y = det * a;\n\n } else {\n // The constraints are redundant, just use one.\n // TODO_ERIN use deepest?\n this.v_pointCount = 1;\n }\n }\n\n matrix.copyVec2(positionA.c, cA);\n positionA.a = aA;\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n\n matrix.copyVec2(positionB.c, cB);\n positionB.a = aB;\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n warmStartConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const mA = this.v_invMassA;\n const iA = this.v_invIA;\n const mB = this.v_invMassB;\n const iB = this.v_invIB;\n\n matrix.copyVec2(vA, velocityA.v);\n let wA = velocityA.w;\n matrix.copyVec2(vB, velocityB.v);\n let wB = velocityB.w;\n\n matrix.copyVec2(normal, this.v_normal);\n matrix.crossVec2Num(tangent, normal, 1.0);\n\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n\n matrix.combine2Vec2(P, vcp.normalImpulse, normal, vcp.tangentImpulse, tangent);\n\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n matrix.minusScaleVec2(vA, mA, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n matrix.plusScaleVec2(vB, mB, P);\n }\n\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n storeConstraintImpulses(step: TimeStep): void {\n const manifold = this.m_manifold;\n for (let j = 0; j < this.v_pointCount; ++j) {\n manifold.points[j].normalImpulse = this.v_points[j].normalImpulse;\n manifold.points[j].tangentImpulse = this.v_points[j].tangentImpulse;\n }\n }\n\n solveVelocityConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const positionA = bodyA.c_position;\n\n const velocityB = bodyB.c_velocity;\n const positionB = bodyB.c_position;\n\n const mA = this.v_invMassA;\n const iA = this.v_invIA;\n const mB = this.v_invMassB;\n const iB = this.v_invIB;\n\n matrix.copyVec2(vA, velocityA.v);\n let wA = velocityA.w;\n matrix.copyVec2(vB, velocityB.v);\n let wB = velocityB.w;\n\n matrix.copyVec2(normal, this.v_normal);\n matrix.crossVec2Num(tangent, normal, 1.0);\n const friction = this.v_friction;\n\n if (_ASSERT) console.assert(this.v_pointCount == 1 || this.v_pointCount == 2);\n\n // Solve tangent constraints first because non-penetration is more important\n // than friction.\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n\n // Relative velocity at contact\n matrix.zeroVec2(dv);\n matrix.plusVec2(dv, vB);\n matrix.plusVec2(dv, matrix.crossNumVec2(temp, wB, vcp.rB));\n matrix.minusVec2(dv, vA);\n matrix.minusVec2(dv, matrix.crossNumVec2(temp, wA, vcp.rA));\n\n // Compute tangent force\n const vt = matrix.dotVec2(dv, tangent) - this.v_tangentSpeed;\n let lambda = vcp.tangentMass * (-vt);\n\n // Clamp the accumulated force\n const maxFriction = friction * vcp.normalImpulse;\n const newImpulse = clamp(vcp.tangentImpulse + lambda, -maxFriction, maxFriction);\n lambda = newImpulse - vcp.tangentImpulse;\n vcp.tangentImpulse = newImpulse;\n\n // Apply contact impulse\n matrix.scaleVec2(P, lambda, tangent);\n\n matrix.minusScaleVec2(vA, mA, P);\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n\n matrix.plusScaleVec2(vB, mB, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n }\n\n // Solve normal constraints\n if (this.v_pointCount == 1 || step.blockSolve == false) {\n for (let i = 0; i < this.v_pointCount; ++i) {\n const vcp = this.v_points[i]; // VelocityConstraintPoint\n\n // Relative velocity at contact\n matrix.zeroVec2(dv);\n matrix.plusVec2(dv, vB);\n matrix.plusVec2(dv, matrix.crossNumVec2(temp, wB, vcp.rB));\n matrix.minusVec2(dv, vA);\n matrix.minusVec2(dv, matrix.crossNumVec2(temp, wA, vcp.rA));\n\n // Compute normal impulse\n const vn = matrix.dotVec2(dv, normal);\n let lambda = -vcp.normalMass * (vn - vcp.velocityBias);\n\n // Clamp the accumulated impulse\n const newImpulse = math_max(vcp.normalImpulse + lambda, 0.0);\n lambda = newImpulse - vcp.normalImpulse;\n vcp.normalImpulse = newImpulse;\n\n // Apply contact impulse\n matrix.scaleVec2(P, lambda, normal);\n\n matrix.minusScaleVec2(vA, mA, P);\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n\n matrix.plusScaleVec2(vB, mB, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n }\n } else {\n // Block solver developed in collaboration with Dirk Gregorius (back in\n // 01/07 on Box2D_Lite).\n // Build the mini LCP for this contact patch\n //\n // vn = A * x + b, vn >= 0, x >= 0 and vn_i * x_i = 0 with i = 1..2\n //\n // A = J * W * JT and J = ( -n, -r1 x n, n, r2 x n )\n // b = vn0 - velocityBias\n //\n // The system is solved using the \"Total enumeration method\" (s. Murty).\n // The complementary constraint vn_i * x_i\n // implies that we must have in any solution either vn_i = 0 or x_i = 0.\n // So for the 2D contact problem the cases\n // vn1 = 0 and vn2 = 0, x1 = 0 and x2 = 0, x1 = 0 and vn2 = 0, x2 = 0 and\n // vn1 = 0 need to be tested. The first valid\n // solution that satisfies the problem is chosen.\n //\n // In order to account of the accumulated impulse 'a' (because of the\n // iterative nature of the solver which only requires\n // that the accumulated impulse is clamped and not the incremental\n // impulse) we change the impulse variable (x_i).\n //\n // Substitute:\n //\n // x = a + d\n //\n // a := old total impulse\n // x := new total impulse\n // d := incremental impulse\n //\n // For the current iteration we extend the formula for the incremental\n // impulse\n // to compute the new total impulse:\n //\n // vn = A * d + b\n // = A * (x - a) + b\n // = A * x + b - A * a\n // = A * x + b'\n // b' = b - A * a;\n\n const vcp1 = this.v_points[0]; // VelocityConstraintPoint\n const vcp2 = this.v_points[1]; // VelocityConstraintPoint\n\n matrix.setVec2(a, vcp1.normalImpulse, vcp2.normalImpulse);\n if (_ASSERT) console.assert(a.x >= 0.0 && a.y >= 0.0);\n\n // Relative velocity at contact\n // let dv1 = Vec2.zero().add(vB).add(Vec2.crossNumVec2(wB, vcp1.rB)).sub(vA).sub(Vec2.crossNumVec2(wA, vcp1.rA));\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n // let dv2 = Vec2.zero().add(vB).add(Vec2.crossNumVec2(wB, vcp2.rB)).sub(vA).sub(Vec2.crossNumVec2(wA, vcp2.rA));\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n let vn1 = matrix.dotVec2(dv1, normal);\n let vn2 = matrix.dotVec2(dv2, normal);\n\n matrix.setVec2(b, vn1 - vcp1.velocityBias, vn2 - vcp2.velocityBias);\n\n // Compute b'\n // b.sub(Mat22.mulVec2(this.v_K, a));\n b.x -= this.v_K.ex.x * a.x + this.v_K.ey.x * a.y;\n b.y -= this.v_K.ex.y * a.x + this.v_K.ey.y * a.y;\n\n const k_errorTol = 1e-3;\n // NOT_USED(k_errorTol);\n\n while (true) {\n //\n // Case 1: vn = 0\n //\n // 0 = A * x + b'\n //\n // Solve for x:\n //\n // x = - inv(A) * b'\n //\n // const x = Mat22.mulVec2(this.v_normalMass, b).neg();\n matrix.zeroVec2(x);\n x.x = -(this.v_normalMass.ex.x * b.x + this.v_normalMass.ey.x * b.y);\n x.y = -(this.v_normalMass.ex.y * b.x + this.v_normalMass.ey.y * b.y);\n\n if (x.x >= 0.0 && x.y >= 0.0) {\n // Get the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n vn1 = matrix.dotVec2(dv1, normal);\n vn2 = matrix.dotVec2(dv2, normal);\n\n if (_ASSERT) console.assert(math_abs(vn1 - vcp1.velocityBias) < k_errorTol);\n if (_ASSERT) console.assert(math_abs(vn2 - vcp2.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 2: vn1 = 0 and x2 = 0\n //\n // 0 = a11 * x1 + a12 * 0 + b1'\n // vn2 = a21 * x1 + a22 * 0 + b2'\n //\n x.x = -vcp1.normalMass * b.x;\n x.y = 0.0;\n vn1 = 0.0;\n vn2 = this.v_K.ex.y * x.x + b.y;\n\n if (x.x >= 0.0 && vn2 >= 0.0) {\n // Get the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n // Compute normal velocity\n vn1 = matrix.dotVec2(dv1, normal);\n\n if (_ASSERT) console.assert(math_abs(vn1 - vcp1.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 3: vn2 = 0 and x1 = 0\n //\n // vn1 = a11 * 0 + a12 * x2 + b1'\n // 0 = a21 * 0 + a22 * x2 + b2'\n //\n x.x = 0.0;\n x.y = -vcp2.normalMass * b.y;\n vn1 = this.v_K.ey.x * x.y + b.x;\n vn2 = 0.0;\n\n if (x.y >= 0.0 && vn1 >= 0.0) {\n // Resubstitute for the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n vn2 = matrix.dotVec2(dv2, normal);\n\n if (_ASSERT) console.assert(math_abs(vn2 - vcp2.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 4: x1 = 0 and x2 = 0\n //\n // vn1 = b1\n // vn2 = b2;\n //\n x.x = 0.0;\n x.y = 0.0;\n vn1 = b.x;\n vn2 = b.y;\n\n if (vn1 >= 0.0 && vn2 >= 0.0) {\n // Resubstitute for the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n break;\n }\n\n // No solution, give up. This is hit sometimes, but it doesn't seem to\n // matter.\n break;\n }\n }\n\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n /** @internal */\n static addType(type1: ShapeType, type2: ShapeType, callback: EvaluateFunction): void {\n s_registers[type1] = s_registers[type1] || {};\n s_registers[type1][type2] = callback;\n }\n\n /** @internal */\n static create(fixtureA: Fixture, indexA: number, fixtureB: Fixture, indexB: number): Contact | null {\n const typeA = fixtureA.m_shape.m_type;\n const typeB = fixtureB.m_shape.m_type;\n\n const contact = contactPool.allocate();\n let evaluateFcn;\n if (evaluateFcn = s_registers[typeA] && s_registers[typeA][typeB]) {\n contact.initialize(fixtureA, indexA, fixtureB, indexB, evaluateFcn);\n } else if (evaluateFcn = s_registers[typeB] && s_registers[typeB][typeA]) {\n contact.initialize(fixtureB, indexB, fixtureA, indexA, evaluateFcn);\n } else {\n return null;\n }\n\n // Contact creation may swap fixtures.\n fixtureA = contact.m_fixtureA;\n fixtureB = contact.m_fixtureB;\n indexA = contact.getChildIndexA();\n indexB = contact.getChildIndexB();\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n\n // Connect to body A\n contact.m_nodeA.contact = contact;\n contact.m_nodeA.other = bodyB;\n\n contact.m_nodeA.prev = null;\n contact.m_nodeA.next = bodyA.m_contactList;\n if (bodyA.m_contactList != null) {\n bodyA.m_contactList.prev = contact.m_nodeA;\n }\n bodyA.m_contactList = contact.m_nodeA;\n\n // Connect to body B\n contact.m_nodeB.contact = contact;\n contact.m_nodeB.other = bodyA;\n\n contact.m_nodeB.prev = null;\n contact.m_nodeB.next = bodyB.m_contactList;\n if (bodyB.m_contactList != null) {\n bodyB.m_contactList.prev = contact.m_nodeB;\n }\n bodyB.m_contactList = contact.m_nodeB;\n\n // Wake up the bodies\n if (fixtureA.isSensor() == false && fixtureB.isSensor() == false) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n\n return contact;\n }\n\n /** @internal */\n static destroy(contact: Contact, listener: { endContact: (contact: Contact) => void }): void {\n const fixtureA = contact.m_fixtureA;\n const fixtureB = contact.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n if (contact.isTouching()) {\n listener.endContact(contact);\n }\n\n // Remove from body 1\n if (contact.m_nodeA.prev) {\n contact.m_nodeA.prev.next = contact.m_nodeA.next;\n }\n\n if (contact.m_nodeA.next) {\n contact.m_nodeA.next.prev = contact.m_nodeA.prev;\n }\n\n if (contact.m_nodeA == bodyA.m_contactList) {\n bodyA.m_contactList = contact.m_nodeA.next;\n }\n\n // Remove from body 2\n if (contact.m_nodeB.prev) {\n contact.m_nodeB.prev.next = contact.m_nodeB.next;\n }\n\n if (contact.m_nodeB.next) {\n contact.m_nodeB.next.prev = contact.m_nodeB.prev;\n }\n\n if (contact.m_nodeB == bodyB.m_contactList) {\n bodyB.m_contactList = contact.m_nodeB.next;\n }\n\n if (contact.m_manifold.pointCount > 0 && !fixtureA.m_isSensor && !fixtureB.m_isSensor) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n\n // const typeA = fixtureA.getType();\n // const typeB = fixtureB.getType();\n\n // const destroyFcn = s_registers[typeA][typeB].destroyFcn;\n // if (typeof destroyFcn === 'function') {\n // destroyFcn(contact);\n // }\n\n contactPool.release(contact);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../util/options\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { BroadPhase } from \"../collision/BroadPhase\";\nimport { Solver, ContactImpulse, TimeStep } from \"./Solver\";\nimport { Body, BodyDef } from \"./Body\";\nimport { Joint } from \"./Joint\";\nimport { Contact } from \"./Contact\";\nimport { AABBValue, RayCastInput, RayCastOutput } from \"../collision/AABB\";\nimport { Fixture, FixtureProxy } from \"./Fixture\";\nimport { Manifold } from \"../collision/Manifold\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\nexport interface WorldDef {\n /** [default: { x : 0, y : 0}] */\n gravity?: Vec2Value;\n\n /** [default: true] */\n allowSleep?: boolean;\n\n /** [default: true] */\n warmStarting?: boolean;\n\n /** [default: true] */\n continuousPhysics?: boolean;\n\n /** [default: false] */\n subStepping?: boolean;\n\n /** [default: true] */\n blockSolve?: boolean;\n\n /** @internal [8] For the velocity constraint solver. */\n velocityIterations?: number;\n\n /** @internal [3] For the position constraint solver. */\n positionIterations?: number;\n}\n\n/** @internal */ const DEFAULTS: WorldDef = {\n gravity : Vec2.zero(),\n allowSleep : true,\n warmStarting : true,\n continuousPhysics : true,\n subStepping : false,\n blockSolve : true,\n velocityIterations : 8,\n positionIterations : 3\n};\n\n/**\n * Callback function for ray casts, see {@link World.rayCast}.\n *\n * Called for each fixture found in the query.\n * The returned value replaces the ray-cast input maxFraction.\n * You control how the ray cast proceeds by returning a numeric/float value.\n * \n * - `0` to terminate the ray cast\n * - `fraction` to clip the ray cast at current point\n * - `1` don't clip the ray and continue\n * - `-1` (or anything else) to continue\n *\n * @param fixture The fixture hit by the ray\n * @param point The point of initial intersection\n * @param normal The normal vector at the point of intersection\n * @param fraction The fraction along the ray at the point of intersection\n *\n * @returns A number to update the maxFraction\n */\nexport type WorldRayCastCallback = (fixture: Fixture, point: Vec2, normal: Vec2, fraction: number) => number;\n\n/**\n * Called for each fixture found in the query AABB. It may return `false` to terminate the query.\n */\nexport type WorldAABBQueryCallback = (fixture: Fixture) => boolean;\n\ndeclare module \"./World\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(deg: WorldDef): World;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(gravity: Vec2): World;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(): World;\n}\n\n/**\n * The `World` class contains the bodies and joints. It manages all aspects\n * of the simulation and allows for asynchronous queries (like AABB queries\n * and ray-casts). Much of your interactions with Planck.js will be with a\n * World object.\n */\n// @ts-expect-error\nexport class World {\n /** @internal */ m_solver: Solver;\n /** @internal */ m_broadPhase: BroadPhase;\n /** @internal */ m_contactList: Contact | null;\n /** @internal */ m_contactCount: number;\n /** @internal */ m_bodyList: Body | null;\n /** @internal */ m_bodyCount: number;\n /** @internal */ m_jointList: Joint | null;\n /** @internal */ m_jointCount: number;\n /** @internal */ m_stepComplete: boolean;\n /** @internal */ m_allowSleep: boolean;\n /** @internal */ m_gravity: Vec2;\n /** @internal */ m_clearForces: boolean;\n /** @internal */ m_newFixture: boolean;\n /** @internal */ m_locked: boolean;\n /** @internal */ m_warmStarting: boolean;\n /** @internal */ m_continuousPhysics: boolean;\n /** @internal */ m_subStepping: boolean;\n /** @internal */ m_blockSolve: boolean;\n /** @internal */ m_velocityIterations: number;\n /** @internal */ m_positionIterations: number;\n /** @internal */ m_t: number;\n\n /** @internal */ m_step_callback: ((world: World) => unknown)[];\n\n // TODO\n /** @internal */ _listeners: {\n [key: string]: any[]\n };\n\n /**\n * @param def World definition or gravity vector.\n */\n constructor(def?: WorldDef | Vec2Value) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof World)) {\n return new World(def);\n }\n\n this.s_step = new TimeStep();\n\n\n if (!def) {\n def = {};\n } else if (Vec2.isValid(def)) {\n def = { gravity: def as Vec2 };\n }\n\n def = options(def, DEFAULTS) as WorldDef;\n\n this.m_solver = new Solver(this);\n\n this.m_broadPhase = new BroadPhase();\n\n this.m_contactList = null;\n this.m_contactCount = 0;\n\n this.m_bodyList = null;\n this.m_bodyCount = 0;\n\n this.m_jointList = null;\n this.m_jointCount = 0;\n\n this.m_stepComplete = true;\n\n this.m_allowSleep = def.allowSleep;\n this.m_gravity = Vec2.clone(def.gravity);\n\n this.m_clearForces = true;\n this.m_newFixture = false;\n this.m_locked = false;\n\n // These are for debugging the solver.\n this.m_warmStarting = def.warmStarting;\n this.m_continuousPhysics = def.continuousPhysics;\n this.m_subStepping = def.subStepping;\n\n this.m_blockSolve = def.blockSolve;\n this.m_velocityIterations = def.velocityIterations;\n this.m_positionIterations = def.positionIterations;\n\n this.m_t = 0;\n\n this.m_step_callback = [];\n }\n\n /** @internal */\n _serialize(): object {\n const bodies = [];\n const joints = [];\n\n for (let b = this.getBodyList(); b; b = b.getNext()) {\n bodies.push(b);\n }\n\n for (let j = this.getJointList(); j; j = j.getNext()) {\n // @ts-ignore\n if (typeof j._serialize === \"function\") {\n joints.push(j);\n }\n }\n\n return {\n gravity: this.m_gravity,\n bodies,\n joints,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, context: any, restore: any): World {\n if (!data) {\n return new World();\n }\n\n const world = new World(data.gravity);\n\n if (data.bodies) {\n for (let i = data.bodies.length - 1; i >= 0; i -= 1) {\n world._addBody(restore(Body, data.bodies[i], world));\n }\n }\n\n if (data.joints) {\n for (let i = data.joints.length - 1; i >= 0; i--) {\n world.createJoint(restore(Joint, data.joints[i], world));\n }\n }\n\n return world;\n }\n\n /**\n * Get the world body list. With the returned body, use Body.getNext to get the\n * next body in the world list. A null body indicates the end of the list.\n *\n * @return the head of the world body list.\n */\n getBodyList(): Body | null {\n return this.m_bodyList;\n }\n\n /**\n * Get the world joint list. With the returned joint, use Joint.getNext to get\n * the next joint in the world list. A null joint indicates the end of the list.\n *\n * @return the head of the world joint list.\n */\n getJointList(): Joint | null {\n return this.m_jointList;\n }\n\n /**\n * Get the world contact list. With the returned contact, use Contact.getNext to\n * get the next contact in the world list. A null contact indicates the end of\n * the list.\n *\n * Warning: contacts are created and destroyed in the middle of a time step.\n * Use ContactListener to avoid missing contacts.\n *\n * @return the head of the world contact list.\n */\n getContactList(): Contact | null {\n return this.m_contactList;\n }\n\n getBodyCount(): number {\n return this.m_bodyCount;\n }\n\n getJointCount(): number {\n return this.m_jointCount;\n }\n\n /**\n * Get the number of contacts (each may have 0 or more contact points).\n */\n getContactCount(): number {\n return this.m_contactCount;\n }\n\n /**\n * Change the global gravity vector.\n */\n setGravity(gravity: Vec2Value): void {\n this.m_gravity.set(gravity);\n }\n\n /**\n * Get the global gravity vector.\n */\n getGravity(): Vec2 {\n return this.m_gravity;\n }\n\n /**\n * Is the world locked (in the middle of a time step).\n */\n isLocked(): boolean {\n return this.m_locked;\n }\n\n /**\n * Enable/disable sleep.\n */\n setAllowSleeping(flag: boolean): void {\n if (flag == this.m_allowSleep) {\n return;\n }\n\n this.m_allowSleep = flag;\n if (this.m_allowSleep == false) {\n for (let b = this.m_bodyList; b; b = b.m_next) {\n b.setAwake(true);\n }\n }\n }\n\n getAllowSleeping(): boolean {\n return this.m_allowSleep;\n }\n\n /**\n * Enable/disable warm starting. For testing.\n */\n setWarmStarting(flag: boolean): void {\n this.m_warmStarting = flag;\n }\n\n getWarmStarting(): boolean {\n return this.m_warmStarting;\n }\n\n /**\n * Enable/disable continuous physics. For testing.\n */\n setContinuousPhysics(flag: boolean): void {\n this.m_continuousPhysics = flag;\n }\n\n getContinuousPhysics(): boolean {\n return this.m_continuousPhysics;\n }\n\n /**\n * Enable/disable single stepped continuous physics. For testing.\n */\n setSubStepping(flag: boolean): void {\n this.m_subStepping = flag;\n }\n\n getSubStepping(): boolean {\n return this.m_subStepping;\n }\n\n /**\n * Set flag to control automatic clearing of forces after each time step.\n */\n setAutoClearForces(flag: boolean): void {\n this.m_clearForces = flag;\n }\n\n /**\n * Get the flag that controls automatic clearing of forces after each time step.\n */\n getAutoClearForces(): boolean {\n return this.m_clearForces;\n }\n\n /**\n * Manually clear the force buffer on all bodies. By default, forces are cleared\n * automatically after each call to step. The default behavior is modified by\n * calling setAutoClearForces. The purpose of this function is to support\n * sub-stepping. Sub-stepping is often used to maintain a fixed sized time step\n * under a variable frame-rate. When you perform sub-stepping you will disable\n * auto clearing of forces and instead call clearForces after all sub-steps are\n * complete in one pass of your game loop.\n *\n * See {@link World.setAutoClearForces}\n */\n clearForces(): void {\n for (let body = this.m_bodyList; body; body = body.getNext()) {\n body.m_force.setZero();\n body.m_torque = 0.0;\n }\n }\n\n /**\n * Query the world for all fixtures that potentially overlap the provided AABB.\n *\n * @param aabb The query box.\n * @param callback Called for each fixture found in the query AABB. It may return `false` to terminate the query.\n */\n queryAABB(aabb: AABBValue, callback: WorldAABBQueryCallback): void {\n if (_ASSERT) console.assert(typeof callback === \"function\");\n const broadPhase = this.m_broadPhase;\n this.m_broadPhase.query(aabb, function(proxyId: number): boolean { // TODO GC\n const proxy = broadPhase.getUserData(proxyId);\n return callback(proxy.fixture);\n });\n }\n\n /**\n * Ray-cast the world for all fixtures in the path of the ray. Your callback\n * controls whether you get the closest point, any point, or n-points. The\n * ray-cast ignores shapes that contain the starting point.\n *\n * @param point1 The ray starting point\n * @param point2 The ray ending point\n * @param callback A function that is called for each fixture that is hit by the ray. You control how the ray cast proceeds by returning a numeric/float value.\n */\n rayCast(point1: Vec2Value, point2: Vec2Value, callback: WorldRayCastCallback): void {\n if (_ASSERT) console.assert(typeof callback === \"function\");\n const broadPhase = this.m_broadPhase;\n\n this.m_broadPhase.rayCast({\n maxFraction : 1.0,\n p1 : point1,\n p2 : point2\n }, function(input: RayCastInput, proxyId: number): number { // TODO GC\n const proxy = broadPhase.getUserData(proxyId);\n const fixture = proxy.fixture;\n const index = proxy.childIndex;\n // @ts-ignore\n const output: RayCastOutput = {}; // TODO GC\n const hit = fixture.rayCast(output, input, index);\n if (hit) {\n const fraction = output.fraction;\n const point = Vec2.add(Vec2.mulNumVec2((1.0 - fraction), input.p1), Vec2.mulNumVec2(fraction, input.p2));\n return callback(fixture, point, output.normal, fraction);\n }\n return input.maxFraction;\n });\n }\n\n /**\n * Get the number of broad-phase proxies.\n */\n getProxyCount(): number {\n return this.m_broadPhase.getProxyCount();\n }\n\n /**\n * Get the height of broad-phase dynamic tree.\n */\n getTreeHeight(): number {\n return this.m_broadPhase.getTreeHeight();\n }\n\n /**\n * Get the balance of broad-phase dynamic tree.\n */\n getTreeBalance(): number {\n return this.m_broadPhase.getTreeBalance();\n }\n\n /**\n * Get the quality metric of broad-phase dynamic tree. The smaller the better.\n * The minimum is 1.\n */\n getTreeQuality(): number {\n return this.m_broadPhase.getTreeQuality();\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The body shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return;\n }\n\n for (let b = this.m_bodyList; b; b = b.m_next) {\n b.m_xf.p.sub(newOrigin);\n b.m_sweep.c0.sub(newOrigin);\n b.m_sweep.c.sub(newOrigin);\n }\n\n for (let j = this.m_jointList; j; j = j.m_next) {\n j.shiftOrigin(newOrigin);\n }\n\n this.m_broadPhase.shiftOrigin(newOrigin);\n }\n\n /** @internal Used for deserialize. */\n _addBody(body: Body): void {\n if (_ASSERT) console.assert(this.isLocked() === false);\n if (this.isLocked()) {\n return;\n }\n\n // Add to world doubly linked list.\n body.m_prev = null;\n body.m_next = this.m_bodyList;\n if (this.m_bodyList) {\n this.m_bodyList.m_prev = body;\n }\n this.m_bodyList = body;\n ++this.m_bodyCount;\n }\n\n /**\n * Create a rigid body given a definition. No reference to the definition is\n * retained.\n *\n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n createBody(def?: BodyDef): Body;\n createBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createBody(arg1?, arg2?) {\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return null;\n }\n\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n\n const body = new Body(this, def);\n this._addBody(body);\n return body;\n }\n\n createDynamicBody(def?: BodyDef): Body;\n createDynamicBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createDynamicBody(arg1?, arg2?) {\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n def.type = \"dynamic\";\n return this.createBody(def);\n }\n\n createKinematicBody(def?: BodyDef): Body;\n createKinematicBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createKinematicBody(arg1?, arg2?) {\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n def.type = \"kinematic\";\n return this.createBody(def);\n }\n\n /**\n * Destroy a body from the world.\n *\n * Warning: This automatically deletes all associated shapes and joints.\n *\n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n destroyBody(b: Body): boolean {\n if (_ASSERT) console.assert(this.m_bodyCount > 0);\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return;\n }\n\n if (b.m_destroyed) {\n return false;\n }\n\n // Delete the attached joints.\n let je = b.m_jointList;\n while (je) {\n const je0 = je;\n je = je.next;\n\n this.publish(\"remove-joint\", je0.joint);\n this.destroyJoint(je0.joint);\n\n b.m_jointList = je;\n }\n b.m_jointList = null;\n\n // Delete the attached contacts.\n let ce = b.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n\n this.destroyContact(ce0.contact);\n\n b.m_contactList = ce;\n }\n b.m_contactList = null;\n\n // Delete the attached fixtures. This destroys broad-phase proxies.\n let f = b.m_fixtureList;\n while (f) {\n const f0 = f;\n f = f.m_next;\n\n this.publish(\"remove-fixture\", f0);\n f0.destroyProxies(this.m_broadPhase);\n\n b.m_fixtureList = f;\n }\n b.m_fixtureList = null;\n\n // Remove world body list.\n if (b.m_prev) {\n b.m_prev.m_next = b.m_next;\n }\n\n if (b.m_next) {\n b.m_next.m_prev = b.m_prev;\n }\n\n if (b == this.m_bodyList) {\n this.m_bodyList = b.m_next;\n }\n\n b.m_destroyed = true;\n\n --this.m_bodyCount;\n\n this.publish(\"remove-body\", b);\n\n return true;\n }\n\n /**\n * Create a joint to constrain bodies together. No reference to the definition\n * is retained. This may cause the connected bodies to cease colliding.\n *\n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n createJoint(joint: T): T | null {\n if (_ASSERT) console.assert(!!joint.m_bodyA);\n if (_ASSERT) console.assert(!!joint.m_bodyB);\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return null;\n }\n\n // Connect to the world list.\n joint.m_prev = null;\n joint.m_next = this.m_jointList;\n if (this.m_jointList) {\n this.m_jointList.m_prev = joint;\n }\n this.m_jointList = joint;\n ++this.m_jointCount;\n\n // Connect to the bodies' doubly linked lists.\n joint.m_edgeA.joint = joint;\n joint.m_edgeA.other = joint.m_bodyB;\n joint.m_edgeA.prev = null;\n joint.m_edgeA.next = joint.m_bodyA.m_jointList;\n if (joint.m_bodyA.m_jointList)\n joint.m_bodyA.m_jointList.prev = joint.m_edgeA;\n joint.m_bodyA.m_jointList = joint.m_edgeA;\n\n joint.m_edgeB.joint = joint;\n joint.m_edgeB.other = joint.m_bodyA;\n joint.m_edgeB.prev = null;\n joint.m_edgeB.next = joint.m_bodyB.m_jointList;\n if (joint.m_bodyB.m_jointList)\n joint.m_bodyB.m_jointList.prev = joint.m_edgeB;\n joint.m_bodyB.m_jointList = joint.m_edgeB;\n\n // If the joint prevents collisions, then flag any contacts for filtering.\n if (joint.m_collideConnected == false) {\n for (let edge = joint.m_bodyB.getContactList(); edge; edge = edge.next) {\n if (edge.other == joint.m_bodyA) {\n // Flag the contact for filtering at the next time step (where either\n // body is awake).\n edge.contact.flagForFiltering();\n }\n }\n }\n\n // Note: creating a joint doesn't wake the bodies.\n\n return joint;\n }\n\n /**\n * Destroy a joint.\n * \n * Warning: This may cause the connected bodies to begin colliding.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n destroyJoint(joint: Joint): void {\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return;\n }\n\n // Remove from the doubly linked list.\n if (joint.m_prev) {\n joint.m_prev.m_next = joint.m_next;\n }\n\n if (joint.m_next) {\n joint.m_next.m_prev = joint.m_prev;\n }\n\n if (joint == this.m_jointList) {\n this.m_jointList = joint.m_next;\n }\n\n // Disconnect from bodies.\n const bodyA = joint.m_bodyA;\n const bodyB = joint.m_bodyB;\n\n // Wake up connected bodies.\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n\n // Remove from body 1.\n if (joint.m_edgeA.prev) {\n joint.m_edgeA.prev.next = joint.m_edgeA.next;\n }\n\n if (joint.m_edgeA.next) {\n joint.m_edgeA.next.prev = joint.m_edgeA.prev;\n }\n\n if (joint.m_edgeA == bodyA.m_jointList) {\n bodyA.m_jointList = joint.m_edgeA.next;\n }\n\n joint.m_edgeA.prev = null;\n joint.m_edgeA.next = null;\n\n // Remove from body 2\n if (joint.m_edgeB.prev) {\n joint.m_edgeB.prev.next = joint.m_edgeB.next;\n }\n\n if (joint.m_edgeB.next) {\n joint.m_edgeB.next.prev = joint.m_edgeB.prev;\n }\n\n if (joint.m_edgeB == bodyB.m_jointList) {\n bodyB.m_jointList = joint.m_edgeB.next;\n }\n\n joint.m_edgeB.prev = null;\n joint.m_edgeB.next = null;\n\n if (_ASSERT) console.assert(this.m_jointCount > 0);\n --this.m_jointCount;\n\n // If the joint prevents collisions, then flag any contacts for filtering.\n if (joint.m_collideConnected == false) {\n let edge = bodyB.getContactList();\n while (edge) {\n if (edge.other == bodyA) {\n // Flag the contact for filtering at the next time step (where either\n // body is awake).\n edge.contact.flagForFiltering();\n }\n\n edge = edge.next;\n }\n }\n\n this.publish(\"remove-joint\", joint);\n }\n\n /** @internal */\n s_step: TimeStep; // reuse\n\n /**\n * Take a time step. This performs collision detection, integration, and\n * constraint solution.\n *\n * Broad-phase, narrow-phase, solve and solve time of impacts.\n *\n * @param timeStep Time step, this should not vary.\n */\n step(timeStep: number, velocityIterations?: number, positionIterations?: number): void {\n this.publish(\"pre-step\", timeStep);\n\n if ((velocityIterations | 0) !== velocityIterations) {\n // TODO: remove this in future\n velocityIterations = 0;\n }\n\n velocityIterations = velocityIterations || this.m_velocityIterations;\n positionIterations = positionIterations || this.m_positionIterations;\n\n // If new fixtures were added, we need to find the new contacts.\n if (this.m_newFixture) {\n this.findNewContacts();\n this.m_newFixture = false;\n }\n\n this.m_locked = true;\n\n this.s_step.reset(timeStep);\n this.s_step.velocityIterations = velocityIterations;\n this.s_step.positionIterations = positionIterations;\n this.s_step.warmStarting = this.m_warmStarting;\n this.s_step.blockSolve = this.m_blockSolve;\n\n // Update contacts. This is where some contacts are destroyed.\n this.updateContacts();\n\n // Integrate velocities, solve velocity constraints, and integrate positions.\n if (this.m_stepComplete && timeStep > 0.0) {\n this.m_solver.solveWorld(this.s_step);\n\n // Synchronize fixtures, check for out of range bodies.\n for (let b = this.m_bodyList; b; b = b.getNext()) {\n // If a body was not in an island then it did not move.\n if (b.m_islandFlag == false) {\n continue;\n }\n\n if (b.isStatic()) {\n continue;\n }\n\n // Update fixtures (for broad-phase).\n b.synchronizeFixtures();\n }\n // Look for new contacts.\n this.findNewContacts();\n }\n\n // Handle TOI events.\n if (this.m_continuousPhysics && timeStep > 0.0) {\n this.m_solver.solveWorldTOI(this.s_step);\n }\n\n if (this.m_clearForces) {\n this.clearForces();\n }\n\n this.m_locked = false;\n\n let callback: (world: World) => unknown;\n while(callback = this.m_step_callback.shift()) {\n callback(this);\n }\n\n this.publish(\"post-step\", timeStep);\n }\n\n /**\n * Queue a function to be called after ongoing simulation step. If no simulation is in progress call it immediately.\n */\n queueUpdate(callback: (world: World) => unknown): void {\n if (!this.isLocked()) {\n callback(this);\n } else {\n this.m_step_callback.push(callback);\n }\n }\n\n /**\n * @internal\n * Call this method to find new contacts.\n */\n findNewContacts(): void {\n this.m_broadPhase.updatePairs(\n (proxyA: FixtureProxy, proxyB: FixtureProxy) => this.createContact(proxyA, proxyB)\n );\n }\n\n /**\n * @internal\n * Callback for broad-phase.\n */\n createContact(proxyA: FixtureProxy, proxyB: FixtureProxy): void {\n const fixtureA = proxyA.fixture;\n const fixtureB = proxyB.fixture;\n\n const indexA = proxyA.childIndex;\n const indexB = proxyB.childIndex;\n\n const bodyA = fixtureA.getBody();\n const bodyB = fixtureB.getBody();\n\n // Are the fixtures on the same body?\n if (bodyA == bodyB) {\n return;\n }\n\n // TODO_ERIN use a hash table to remove a potential bottleneck when both\n // bodies have a lot of contacts.\n // Does a contact already exist?\n let edge = bodyB.getContactList(); // ContactEdge\n while (edge) {\n if (edge.other == bodyA) {\n const fA = edge.contact.getFixtureA();\n const fB = edge.contact.getFixtureB();\n const iA = edge.contact.getChildIndexA();\n const iB = edge.contact.getChildIndexB();\n\n if (fA == fixtureA && fB == fixtureB && iA == indexA && iB == indexB) {\n // A contact already exists.\n return;\n }\n\n if (fA == fixtureB && fB == fixtureA && iA == indexB && iB == indexA) {\n // A contact already exists.\n return;\n }\n }\n\n edge = edge.next;\n }\n\n if (bodyB.shouldCollide(bodyA) == false) {\n return;\n }\n if (fixtureB.shouldCollide(fixtureA) == false) {\n return;\n }\n\n // Call the factory.\n const contact = Contact.create(fixtureA, indexA, fixtureB, indexB);\n if (contact == null) {\n return;\n }\n\n // Insert into the world.\n contact.m_prev = null;\n if (this.m_contactList != null) {\n contact.m_next = this.m_contactList;\n this.m_contactList.m_prev = contact;\n }\n this.m_contactList = contact;\n\n ++this.m_contactCount;\n }\n\n /**\n * @internal\n * Removes old non-overlapping contacts, applies filters and updates contacts.\n */\n updateContacts(): void {\n // Update awake contacts.\n let c: Contact;\n let next_c = this.m_contactList;\n while (c = next_c) {\n next_c = c.getNext();\n const fixtureA = c.getFixtureA();\n const fixtureB = c.getFixtureB();\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n const bodyA = fixtureA.getBody();\n const bodyB = fixtureB.getBody();\n\n // Is this contact flagged for filtering?\n if (c.m_filterFlag) {\n if (bodyB.shouldCollide(bodyA) == false) {\n this.destroyContact(c);\n continue;\n }\n\n if (fixtureB.shouldCollide(fixtureA) == false) {\n this.destroyContact(c);\n continue;\n }\n\n // Clear the filtering flag.\n c.m_filterFlag = false;\n }\n\n const activeA = bodyA.isAwake() && !bodyA.isStatic();\n const activeB = bodyB.isAwake() && !bodyB.isStatic();\n\n // At least one body must be awake and it must be dynamic or kinematic.\n if (activeA == false && activeB == false) {\n continue;\n }\n\n const proxyIdA = fixtureA.m_proxies[indexA].proxyId;\n const proxyIdB = fixtureB.m_proxies[indexB].proxyId;\n const overlap = this.m_broadPhase.testOverlap(proxyIdA, proxyIdB);\n\n // Here we destroy contacts that cease to overlap in the broad-phase.\n if (overlap == false) {\n this.destroyContact(c);\n continue;\n }\n\n // The contact persists.\n c.update(this);\n }\n }\n\n /** @internal */\n destroyContact(contact: Contact): void {\n // Remove from the world.\n if (contact.m_prev) {\n contact.m_prev.m_next = contact.m_next;\n }\n if (contact.m_next) {\n contact.m_next.m_prev = contact.m_prev;\n }\n if (contact == this.m_contactList) {\n this.m_contactList = contact.m_next;\n }\n\n Contact.destroy(contact, this);\n\n --this.m_contactCount;\n }\n\n\n /**\n * Called when two fixtures begin to touch.\n *\n * Implement contact callbacks to get contact information. You can use these\n * results for things like sounds and game logic. You can also get contact\n * results by traversing the contact lists after the time step. However, you\n * might miss some contacts because continuous physics leads to sub-stepping.\n * Additionally you may receive multiple callbacks for the same contact in a\n * single time step. You should strive to make your callbacks efficient because\n * there may be many callbacks per time step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"begin-contact\", listener: (contact: Contact) => void): World;\n /**\n * Called when two fixtures cease to touch.\n *\n * Implement contact callbacks to get contact information. You can use these\n * results for things like sounds and game logic. You can also get contact\n * results by traversing the contact lists after the time step. However, you\n * might miss some contacts because continuous physics leads to sub-stepping.\n * Additionally you may receive multiple callbacks for the same contact in a\n * single time step. You should strive to make your callbacks efficient because\n * there may be many callbacks per time step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"end-contact\", listener: (contact: Contact) => void): World;\n /**\n * This is called after a contact is updated. This allows you to inspect a\n * contact before it goes to the solver. If you are careful, you can modify the\n * contact manifold (e.g. disable contact). A copy of the old manifold is\n * provided so that you can detect changes. Note: this is called only for awake\n * bodies. Note: this is called even when the number of contact points is zero.\n * Note: this is not called for sensors. Note: if you set the number of contact\n * points to zero, you will not get an end-contact callback. However, you may get\n * a begin-contact callback the next step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"pre-solve\", listener: (contact: Contact, oldManifold: Manifold) => void): World;\n /**\n * This lets you inspect a contact after the solver is finished. This is useful\n * for inspecting impulses. Note: the contact manifold does not include time of\n * impact impulses, which can be arbitrarily large if the sub-step is small.\n * Hence the impulse is provided explicitly in a separate data structure. Note:\n * this is only called for contacts that are touching, solid, and awake.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"post-solve\", listener: (contact: Contact, impulse: ContactImpulse) => void): World;\n /** Listener is called whenever a body is removed. */\n on(name: \"remove-body\", listener: (body: Body) => void): World;\n /** Listener is called whenever a joint is removed implicitly or explicitly. */\n on(name: \"remove-joint\", listener: (joint: Joint) => void): World;\n /** Listener is called whenever a fixture is removed implicitly or explicitly. */\n on(name: \"remove-fixture\", listener: (fixture: Fixture) => void): World;\n /**\n * Register an event listener.\n */\n // tslint:disable-next-line:typedef\n on(name, listener) {\n if (typeof name !== \"string\" || typeof listener !== \"function\") {\n return this;\n }\n if (!this._listeners) {\n this._listeners = {};\n }\n if (!this._listeners[name]) {\n this._listeners[name] = [];\n }\n this._listeners[name].push(listener);\n return this;\n }\n\n off(name: \"begin-contact\", listener: (contact: Contact) => void): World;\n off(name: \"end-contact\", listener: (contact: Contact) => void): World;\n off(name: \"pre-solve\", listener: (contact: Contact, oldManifold: Manifold) => void): World;\n off(name: \"post-solve\", listener: (contact: Contact, impulse: ContactImpulse) => void): World;\n off(name: \"remove-body\", listener: (body: Body) => void): World;\n off(name: \"remove-joint\", listener: (joint: Joint) => void): World;\n off(name: \"remove-fixture\", listener: (fixture: Fixture) => void): World;\n /**\n * Remove an event listener.\n */\n // tslint:disable-next-line:typedef\n off(name, listener) {\n if (typeof name !== \"string\" || typeof listener !== \"function\") {\n return this;\n }\n const listeners = this._listeners && this._listeners[name];\n if (!listeners || !listeners.length) {\n return this;\n }\n const index = listeners.indexOf(listener);\n if (index >= 0) {\n listeners.splice(index, 1);\n }\n return this;\n }\n\n publish(name: string, arg1?: any, arg2?: any, arg3?: any): number {\n const listeners = this._listeners && this._listeners[name];\n if (!listeners || !listeners.length) {\n return 0;\n }\n for (let l = 0; l < listeners.length; l++) {\n listeners[l].call(this, arg1, arg2, arg3);\n }\n return listeners.length;\n }\n\n /** @internal */\n beginContact(contact: Contact): void {\n this.publish(\"begin-contact\", contact);\n }\n\n /** @internal */\n endContact(contact: Contact): void {\n this.publish(\"end-contact\", contact);\n }\n\n /** @internal */\n preSolve(contact: Contact, oldManifold: Manifold): void {\n this.publish(\"pre-solve\", contact, oldManifold);\n }\n\n /** @internal */\n postSolve(contact: Contact, impulse: ContactImpulse): void {\n this.publish(\"post-solve\", contact, impulse);\n }\n\n /**\n * Joints and fixtures are destroyed when their associated body is destroyed.\n * Register a destruction listener so that you may nullify references to these\n * joints and shapes.\n *\n * `function(object)` is called when any joint or fixture is about to\n * be destroyed due to the destruction of one of its attached or parent bodies.\n */\n\n /**\n * Register a contact filter to provide specific control over collision.\n * Otherwise the default filter is used (defaultFilter). The listener is owned\n * by you and must remain in scope.\n *\n * Moved to Fixture.\n */\n}","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/** 3D vector */\nexport interface Vec3Value {\n x: number;\n y: number;\n z: number;\n}\n\ndeclare module \"./Vec3\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(x: number, y: number, z: number): Vec3;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(obj: Vec3Value): Vec3;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(): Vec3;\n}\n\n/** 3D vector */\n// @ts-expect-error\nexport class Vec3 {\n x: number;\n y: number;\n z: number;\n\n constructor(x: number, y: number, z: number);\n constructor(obj: Vec3Value);\n constructor();\n constructor(x?, y?, z?) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Vec3)) {\n return new Vec3(x, y, z);\n }\n if (typeof x === \"undefined\") {\n this.x = 0;\n this.y = 0;\n this.z = 0;\n } else if (typeof x === \"object\") {\n this.x = x.x;\n this.y = x.y;\n this.z = x.z;\n } else {\n this.x = x;\n this.y = y;\n this.z = z;\n }\n if (_ASSERT) Vec3.assert(this);\n }\n\n /** @internal */\n _serialize(): object {\n return {\n x: this.x,\n y: this.y,\n z: this.z\n };\n }\n\n /** @internal */\n static _deserialize(data: any): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = data.x;\n obj.y = data.y;\n obj.z = data.z;\n return obj;\n }\n\n /** @hidden */\n static neo(x: number, y: number, z: number): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = x;\n obj.y = y;\n obj.z = z;\n return obj;\n }\n\n static zero(): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = 0;\n obj.y = 0;\n obj.z = 0;\n return obj;\n }\n\n static clone(v: Vec3Value): Vec3 {\n if (_ASSERT) Vec3.assert(v);\n return Vec3.neo(v.x, v.y, v.z);\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n /** Does this vector contain finite coordinates? */\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.x) && Number.isFinite(obj.y) && Number.isFinite(obj.z);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Vec3.isValid(o), \"Invalid Vec3!\", o);\n }\n\n setZero(): Vec3 {\n this.x = 0.0;\n this.y = 0.0;\n this.z = 0.0;\n return this;\n }\n\n set(x: number, y: number, z: number): Vec3 {\n this.x = x;\n this.y = y;\n this.z = z;\n return this;\n }\n\n add(w: Vec3Value): Vec3 {\n this.x += w.x;\n this.y += w.y;\n this.z += w.z;\n return this;\n }\n\n sub(w: Vec3Value): Vec3 {\n this.x -= w.x;\n this.y -= w.y;\n this.z -= w.z;\n return this;\n }\n\n mul(m: number): Vec3 {\n this.x *= m;\n this.y *= m;\n this.z *= m;\n return this;\n }\n\n static areEqual(v: Vec3Value, w: Vec3Value): boolean {\n if (_ASSERT) Vec3.assert(v);\n if (_ASSERT) Vec3.assert(w);\n return v === w ||\n typeof v === \"object\" && v !== null &&\n typeof w === \"object\" && w !== null &&\n v.x === w.x && v.y === w.y && v.z === w.z;\n }\n\n /** Dot product on two vectors */\n static dot(v: Vec3Value, w: Vec3Value): number {\n return v.x * w.x + v.y * w.y + v.z * w.z;\n }\n\n /** Cross product on two vectors */\n static cross(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(\n v.y * w.z - v.z * w.y,\n v.z * w.x - v.x * w.z,\n v.x * w.y - v.y * w.x\n );\n }\n\n static add(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(v.x + w.x, v.y + w.y, v.z + w.z);\n }\n\n static sub(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(v.x - w.x, v.y - w.y, v.z - w.z);\n }\n\n static mul(v: Vec3Value, m: number): Vec3 {\n return new Vec3(m * v.x, m * v.y, m * v.z);\n }\n\n neg(): Vec3 {\n this.x = -this.x;\n this.y = -this.y;\n this.z = -this.z;\n return this;\n }\n\n static neg(v: Vec3Value): Vec3 {\n return new Vec3(-v.x, -v.y, -v.z);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport * as matrix from \"../../common/Matrix\";\nimport { Shape } from \"../Shape\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { AABB, AABBValue, RayCastInput, RayCastOutput } from \"../AABB\";\nimport { MassData } from \"../../dynamics/Body\";\nimport { DistanceProxy } from \"../Distance\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const v2 = matrix.vec2(0, 0);\n\ndeclare module \"./EdgeShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function EdgeShape(v1?: Vec2Value, v2?: Vec2Value): EdgeShape;\n}\n\n/**\n * A line segment (edge) shape. These can be connected in chains or loops to\n * other edge shapes. The connectivity information is used to ensure correct\n * contact normals.\n */\n// @ts-expect-error\nexport class EdgeShape extends Shape {\n static TYPE = \"edge\" as const;\n /** @hidden */ m_type: \"edge\";\n\n /** @hidden */ m_radius: number;\n\n // These are the edge vertices\n /** @hidden */ m_vertex1: Vec2;\n /** @hidden */ m_vertex2: Vec2;\n\n // Optional adjacent vertices. These are used for smooth collision.\n // Used by chain shape.\n /** @hidden */ m_vertex0: Vec2;\n /** @hidden */ m_vertex3: Vec2;\n /** @hidden */ m_hasVertex0: boolean;\n /** @hidden */ m_hasVertex3: boolean;\n\n constructor(v1?: Vec2Value, v2?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof EdgeShape)) {\n return new EdgeShape(v1, v2);\n }\n\n super();\n\n this.m_type = EdgeShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n\n this.m_vertex1 = v1 ? Vec2.clone(v1) : Vec2.zero();\n this.m_vertex2 = v2 ? Vec2.clone(v2) : Vec2.zero();\n\n this.m_vertex0 = Vec2.zero();\n this.m_vertex3 = Vec2.zero();\n this.m_hasVertex0 = false;\n this.m_hasVertex3 = false;\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n vertex1: this.m_vertex1,\n vertex2: this.m_vertex2,\n\n vertex0: this.m_vertex0,\n vertex3: this.m_vertex3,\n hasVertex0: this.m_hasVertex0,\n hasVertex3: this.m_hasVertex3,\n };\n }\n\n /** @internal */\n static _deserialize(data: any): EdgeShape {\n const shape = new EdgeShape(data.vertex1, data.vertex2);\n if (shape.m_hasVertex0) {\n shape.setPrevVertex(data.vertex0);\n }\n if (shape.m_hasVertex3) {\n shape.setNextVertex(data.vertex3);\n }\n return shape;\n }\n\n /** @hidden */\n _reset(): void {\n // noop\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n getType(): \"edge\" {\n return this.m_type;\n }\n\n /** @internal @deprecated */\n setNext(v?: Vec2Value): EdgeShape {\n return this.setNextVertex(v);\n }\n\n /**\n * Optional next vertex, used for smooth collision.\n */\n setNextVertex(v?: Vec2Value): EdgeShape {\n if (v) {\n this.m_vertex3.setVec2(v);\n this.m_hasVertex3 = true;\n } else {\n this.m_vertex3.setZero();\n this.m_hasVertex3 = false;\n }\n return this;\n }\n\n /**\n * Optional next vertex, used for smooth collision.\n */\n getNextVertex(): Vec2 {\n return this.m_vertex3;\n }\n\n /** @internal @deprecated */\n setPrev(v?: Vec2Value): EdgeShape {\n return this.setPrevVertex(v);\n }\n\n /**\n * Optional prev vertex, used for smooth collision.\n */\n setPrevVertex(v?: Vec2Value): EdgeShape {\n if (v) {\n this.m_vertex0.setVec2(v);\n this.m_hasVertex0 = true;\n } else {\n this.m_vertex0.setZero();\n this.m_hasVertex0 = false;\n }\n return this;\n }\n\n /**\n * Optional prev vertex, used for smooth collision.\n */\n getPrevVertex(): Vec2 {\n return this.m_vertex0;\n }\n\n /**\n * Set this as an isolated edge.\n */\n _set(v1: Vec2Value, v2: Vec2Value): EdgeShape {\n this.m_vertex1.setVec2(v1);\n this.m_vertex2.setVec2(v2);\n this.m_hasVertex0 = false;\n this.m_hasVertex3 = false;\n return this;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): EdgeShape {\n const clone = new EdgeShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_vertex1.setVec2(this.m_vertex1);\n clone.m_vertex2.setVec2(this.m_vertex2);\n clone.m_vertex0.setVec2(this.m_vertex0);\n clone.m_vertex3.setVec2(this.m_vertex3);\n clone.m_hasVertex0 = this.m_hasVertex0;\n clone.m_hasVertex3 = this.m_hasVertex3;\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): false {\n return false;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n // p = p1 + t * d\n // v = v1 + s * e\n // p1 + t * d = v1 + s * e\n // s * e - t * d = p1 - v1\n\n // NOT_USED(childIndex);\n\n // Put the ray into the edge's frame of reference.\n const p1 = Rot.mulTVec2(xf.q, Vec2.sub(input.p1, xf.p));\n const p2 = Rot.mulTVec2(xf.q, Vec2.sub(input.p2, xf.p));\n const d = Vec2.sub(p2, p1);\n\n const v1 = this.m_vertex1;\n const v2 = this.m_vertex2;\n const e = Vec2.sub(v2, v1);\n const normal = Vec2.neo(e.y, -e.x);\n normal.normalize();\n\n // q = p1 + t * d\n // dot(normal, q - v1) = 0\n // dot(normal, p1 - v1) + t * dot(normal, d) = 0\n const numerator = Vec2.dot(normal, Vec2.sub(v1, p1));\n const denominator = Vec2.dot(normal, d);\n\n if (denominator == 0.0) {\n return false;\n }\n\n const t = numerator / denominator;\n if (t < 0.0 || input.maxFraction < t) {\n return false;\n }\n\n const q = Vec2.add(p1, Vec2.mulNumVec2(t, d));\n\n // q = v1 + s * r\n // s = dot(q - v1, r) / dot(r, r)\n const r = Vec2.sub(v2, v1);\n const rr = Vec2.dot(r, r);\n if (rr == 0.0) {\n return false;\n }\n\n const s = Vec2.dot(Vec2.sub(q, v1), r) / rr;\n if (s < 0.0 || 1.0 < s) {\n return false;\n }\n\n output.fraction = t;\n if (numerator > 0.0) {\n output.normal = Rot.mulVec2(xf.q, normal).neg();\n } else {\n output.normal = Rot.mulVec2(xf.q, normal);\n }\n return true;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n matrix.transformVec2(v1, xf, this.m_vertex1);\n matrix.transformVec2(v2, xf, this.m_vertex2);\n\n AABB.combinePoints(aabb, v1, v2);\n AABB.extend(aabb, this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density?: number): void {\n massData.mass = 0.0;\n matrix.combine2Vec2(massData.center, 0.5, this.m_vertex1, 0.5, this.m_vertex2);\n massData.I = 0.0;\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n proxy.m_vertices[0] = this.m_vertex1;\n proxy.m_vertices[1] = this.m_vertex2;\n proxy.m_vertices.length = 2;\n proxy.m_count = 2;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Edge = EdgeShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport type { MassData } from \"../../dynamics/Body\";\nimport { AABBValue, RayCastOutput, RayCastInput, AABB } from \"../AABB\";\nimport { DistanceProxy } from \"../Distance\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Shape } from \"../Shape\";\nimport { EdgeShape } from \"./EdgeShape\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const v2 = matrix.vec2(0, 0);\n\ndeclare module \"./ChainShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function ChainShape(vertices?: Vec2Value[], loop?: boolean): ChainShape;\n}\n\n/**\n * A chain shape is a free form sequence of line segments. The chain has\n * two-sided collision, so you can use inside and outside collision. Therefore,\n * you may use any winding order. Connectivity information is used to create\n * smooth collisions.\n *\n * WARNING: The chain will not collide properly if there are self-intersections.\n */\n// @ts-expect-error\nexport class ChainShape extends Shape {\n static TYPE = \"chain\" as const;\n /** @hidden */ m_type: \"chain\";\n\n /** @hidden */ m_radius: number;\n\n /** @hidden */ m_vertices: Vec2[];\n /** @hidden */ m_count: number;\n /** @hidden */ m_prevVertex: Vec2 | null;\n /** @hidden */ m_nextVertex: Vec2 | null;\n /** @hidden */ m_hasPrevVertex: boolean;\n /** @hidden */ m_hasNextVertex: boolean;\n\n /** @hidden */ m_isLoop: boolean;\n\n constructor(vertices?: Vec2Value[], loop?: boolean) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof ChainShape)) {\n return new ChainShape(vertices, loop);\n }\n\n super();\n\n this.m_type = ChainShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n this.m_vertices = [];\n this.m_count = 0;\n this.m_prevVertex = null;\n this.m_nextVertex = null;\n this.m_hasPrevVertex = false;\n this.m_hasNextVertex = false;\n\n this.m_isLoop = !!loop;\n\n if (vertices && vertices.length) {\n if (loop) {\n this._createLoop(vertices);\n } else {\n this._createChain(vertices);\n }\n }\n }\n\n /** @internal */\n _serialize(): object {\n const data = {\n type: this.m_type,\n vertices: this.m_isLoop ? this.m_vertices.slice(0, this.m_vertices.length - 1) : this.m_vertices,\n isLoop: this.m_isLoop,\n hasPrevVertex: this.m_hasPrevVertex,\n hasNextVertex: this.m_hasNextVertex,\n prevVertex: null as Vec2 | null,\n nextVertex: null as Vec2 | null,\n };\n if (this.m_prevVertex) {\n data.prevVertex = this.m_prevVertex;\n }\n if (this.m_nextVertex) {\n data.nextVertex = this.m_nextVertex;\n }\n return data;\n }\n\n /** @internal */\n static _deserialize(data: any, fixture: any, restore: any): ChainShape {\n const vertices: Vec2[] = [];\n if (data.vertices) {\n for (let i = 0; i < data.vertices.length; i++) {\n vertices.push(restore(Vec2, data.vertices[i]));\n }\n }\n const shape = new ChainShape(vertices, data.isLoop);\n if (data.prevVertex) {\n shape.setPrevVertex(data.prevVertex);\n }\n if (data.nextVertex) {\n shape.setNextVertex(data.nextVertex);\n }\n return shape;\n }\n\n // clear() {\n // this.m_vertices.length = 0;\n // this.m_count = 0;\n // }\n\n getType(): \"chain\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n /**\n * @internal\n * Create a loop. This automatically adjusts connectivity.\n *\n * @param vertices an array of vertices, these are copied\n */\n _createLoop(vertices: Vec2Value[]): ChainShape {\n if (_ASSERT) console.assert(this.m_vertices.length == 0 && this.m_count == 0);\n if (_ASSERT) console.assert(vertices.length >= 3);\n if (vertices.length < 3) {\n return;\n }\n\n for (let i = 1; i < vertices.length; ++i) {\n const v1 = vertices[i - 1];\n const v2 = vertices[i];\n // If the code crashes here, it means your vertices are too close together.\n if (_ASSERT) console.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);\n }\n\n this.m_vertices = [];\n this.m_count = vertices.length + 1;\n for (let i = 0; i < vertices.length; ++i) {\n this.m_vertices[i] = Vec2.clone(vertices[i]);\n }\n this.m_vertices[vertices.length] = Vec2.clone(vertices[0]);\n\n this.m_prevVertex = this.m_vertices[this.m_count - 2];\n this.m_nextVertex = this.m_vertices[1];\n this.m_hasPrevVertex = true;\n this.m_hasNextVertex = true;\n return this;\n }\n\n /**\n * @internal\n * Create a chain with isolated end vertices.\n *\n * @param vertices an array of vertices, these are copied\n */\n _createChain(vertices: Vec2Value[]): ChainShape {\n if (_ASSERT) console.assert(this.m_vertices.length == 0 && this.m_count == 0);\n if (_ASSERT) console.assert(vertices.length >= 2);\n for (let i = 1; i < vertices.length; ++i) {\n const v1 = vertices[i - 1];\n const v2 = vertices[i];\n // If the code crashes here, it means your vertices are too close together.\n if (_ASSERT) console.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);\n }\n\n this.m_vertices = [];\n this.m_count = vertices.length;\n for (let i = 0; i < vertices.length; ++i) {\n this.m_vertices[i] = Vec2.clone(vertices[i]);\n }\n\n this.m_prevVertex = null;\n this.m_nextVertex = null;\n this.m_hasPrevVertex = false;\n this.m_hasNextVertex = false;\n return this;\n }\n\n /** @hidden */\n _reset(): void {\n if (this.m_isLoop) {\n this._createLoop(this.m_vertices.slice(0, this.m_vertices.length - 1));\n } else {\n this._createChain(this.m_vertices);\n }\n }\n\n /**\n * Establish connectivity to a vertex that precedes the first vertex. Don't call\n * this for loops.\n */\n setPrevVertex(prevVertex: Vec2): void {\n // todo: copy or reference\n this.m_prevVertex = prevVertex;\n this.m_hasPrevVertex = true;\n }\n\n getPrevVertex(): Vec2 {\n return this.m_prevVertex;\n }\n\n /**\n * Establish connectivity to a vertex that follows the last vertex. Don't call\n * this for loops.\n */\n setNextVertex(nextVertex: Vec2): void {\n // todo: copy or reference\n this.m_nextVertex = nextVertex;\n this.m_hasNextVertex = true;\n }\n\n getNextVertex(): Vec2 {\n return this.m_nextVertex;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): ChainShape {\n const clone = new ChainShape();\n clone._createChain(this.m_vertices);\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_prevVertex = this.m_prevVertex;\n clone.m_nextVertex = this.m_nextVertex;\n clone.m_hasPrevVertex = this.m_hasPrevVertex;\n clone.m_hasNextVertex = this.m_hasNextVertex;\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): number {\n // edge count = vertex count - 1\n return this.m_count - 1;\n }\n\n // Get a child edge.\n getChildEdge(edge: EdgeShape, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count - 1);\n edge.m_type = EdgeShape.TYPE;\n edge.m_radius = this.m_radius;\n\n edge.m_vertex1 = this.m_vertices[childIndex];\n edge.m_vertex2 = this.m_vertices[childIndex + 1];\n\n if (childIndex > 0) {\n edge.m_vertex0 = this.m_vertices[childIndex - 1];\n edge.m_hasVertex0 = true;\n } else {\n edge.m_vertex0 = this.m_prevVertex;\n edge.m_hasVertex0 = this.m_hasPrevVertex;\n }\n\n if (childIndex < this.m_count - 2) {\n edge.m_vertex3 = this.m_vertices[childIndex + 2];\n edge.m_hasVertex3 = true;\n } else {\n edge.m_vertex3 = this.m_nextVertex;\n edge.m_hasVertex3 = this.m_hasNextVertex;\n }\n }\n\n getVertex(index: number): Vec2 {\n if (_ASSERT) console.assert(0 <= index && index <= this.m_count);\n if (index < this.m_count) {\n return this.m_vertices[index];\n } else {\n return this.m_vertices[0];\n }\n }\n\n isLoop(): boolean {\n return this.m_isLoop;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * This always return false.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): false {\n return false;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n\n const edgeShape = new EdgeShape(this.getVertex(childIndex), this.getVertex(childIndex + 1));\n return edgeShape.rayCast(output, input, xf, 0);\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n\n matrix.transformVec2(v1, xf, this.getVertex(childIndex));\n matrix.transformVec2(v2, xf, this.getVertex(childIndex + 1));\n\n AABB.combinePoints(aabb, v1, v2);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * Chains have zero mass.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density?: number): void {\n massData.mass = 0.0;\n matrix.zeroVec2(massData.center);\n massData.I = 0.0;\n }\n\n computeDistanceProxy(proxy: DistanceProxy, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n proxy.m_vertices[0] = this.getVertex(childIndex);\n proxy.m_vertices[1] = this.getVertex(childIndex + 1);\n proxy.m_count = 2;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Chain = ChainShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport type { MassData } from \"../../dynamics/Body\";\nimport { RayCastOutput, RayCastInput, AABBValue } from \"../AABB\";\nimport { DistanceProxy } from \"../Distance\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Shape } from \"../Shape\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const e = matrix.vec2(0, 0);\n/** @internal */ const e1 = matrix.vec2(0, 0);\n/** @internal */ const e2 = matrix.vec2(0, 0);\n/** @internal */ const center = matrix.vec2(0, 0);\n/** @internal */ const s = matrix.vec2(0, 0);\n\ndeclare module \"./PolygonShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PolygonShape(vertices?: Vec2Value[]): PolygonShape;\n}\n\n/**\n * A convex polygon. It is assumed that the interior of the polygon is to the\n * left of each edge. Polygons have a maximum number of vertices equal to\n * Settings.maxPolygonVertices. In most cases you should not need many vertices\n * for a convex polygon. extends Shape\n */\n// @ts-expect-error\nexport class PolygonShape extends Shape {\n static TYPE = \"polygon\" as const;\n /** @hidden */ m_type: \"polygon\";\n\n /** @hidden */ m_centroid: Vec2;\n /** @hidden */ m_vertices: Vec2[]; // [Settings.maxPolygonVertices]\n /** @hidden */ m_normals: Vec2[]; // [Settings.maxPolygonVertices]\n /** @hidden */ m_count: number;\n /** @hidden */ m_radius: number;\n\n constructor(vertices?: Vec2Value[]) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PolygonShape)) {\n return new PolygonShape(vertices);\n }\n\n super();\n\n this.m_type = PolygonShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n this.m_centroid = Vec2.zero();\n this.m_vertices = [];\n this.m_normals = [];\n this.m_count = 0;\n\n if (vertices && vertices.length) {\n this._set(vertices);\n }\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n vertices: this.m_vertices,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, fixture: any, restore: any): PolygonShape {\n const vertices: Vec2[] = [];\n if (data.vertices) {\n for (let i = 0; i < data.vertices.length; i++) {\n vertices.push(restore(Vec2, data.vertices[i]));\n }\n }\n\n const shape = new PolygonShape(vertices);\n return shape;\n }\n\n getType(): \"polygon\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): PolygonShape {\n const clone = new PolygonShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_count = this.m_count;\n clone.m_centroid.setVec2(this.m_centroid);\n for (let i = 0; i < this.m_count; i++) {\n clone.m_vertices.push(this.m_vertices[i].clone());\n }\n for (let i = 0; i < this.m_normals.length; i++) {\n clone.m_normals.push(this.m_normals[i].clone());\n }\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /** @hidden */\n _reset(): void {\n this._set(this.m_vertices);\n }\n\n /**\n * @internal\n *\n * Create a convex hull from the given array of local points. The count must be\n * in the range [3, Settings.maxPolygonVertices].\n *\n * Warning: the points may be re-ordered, even if they form a convex polygon\n * Warning: collinear points are handled but not removed. Collinear points may\n * lead to poor stacking behavior.\n */\n _set(vertices: Vec2Value[]): void {\n if (_ASSERT) console.assert(3 <= vertices.length && vertices.length <= Settings.maxPolygonVertices);\n if (vertices.length < 3) {\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n let n = math_min(vertices.length, Settings.maxPolygonVertices);\n\n // Perform welding and copy vertices into local buffer.\n const ps: Vec2[] = []; // [Settings.maxPolygonVertices];\n for (let i = 0; i < n; ++i) {\n const v = vertices[i];\n\n let unique = true;\n for (let j = 0; j < ps.length; ++j) {\n if (Vec2.distanceSquared(v, ps[j]) < 0.25 * Settings.linearSlopSquared) {\n unique = false;\n break;\n }\n }\n\n if (unique) {\n ps.push(Vec2.clone(v));\n }\n }\n\n n = ps.length;\n if (n < 3) {\n // Polygon is degenerate.\n if (_ASSERT) console.assert(false);\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n // Create the convex hull using the Gift wrapping algorithm\n // http://en.wikipedia.org/wiki/Gift_wrapping_algorithm\n\n // Find the right most point on the hull (in case of multiple points bottom most is used)\n let i0 = 0;\n let x0 = ps[0].x;\n for (let i = 1; i < n; ++i) {\n const x = ps[i].x;\n if (x > x0 || (x === x0 && ps[i].y < ps[i0].y)) {\n i0 = i;\n x0 = x;\n }\n }\n\n const hull = [] as number[]; // [Settings.maxPolygonVertices];\n let m = 0;\n let ih = i0;\n\n while (true) {\n if (_ASSERT) console.assert(m < Settings.maxPolygonVertices);\n hull[m] = ih;\n\n let ie = 0;\n for (let j = 1; j < n; ++j) {\n if (ie === ih) {\n ie = j;\n continue;\n }\n\n const r = Vec2.sub(ps[ie], ps[hull[m]]);\n const v = Vec2.sub(ps[j], ps[hull[m]]);\n const c = Vec2.crossVec2Vec2(r, v);\n // c < 0 means counter-clockwise wrapping, c > 0 means clockwise wrapping\n if (c < 0.0) {\n ie = j;\n }\n\n // Collinearity check\n if (c === 0.0 && v.lengthSquared() > r.lengthSquared()) {\n ie = j;\n }\n }\n\n ++m;\n ih = ie;\n\n if (ie === i0) {\n break;\n }\n }\n\n if (m < 3) {\n // Polygon is degenerate.\n if (_ASSERT) console.assert(false);\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n this.m_count = m;\n\n // Copy vertices.\n this.m_vertices = [];\n for (let i = 0; i < m; ++i) {\n this.m_vertices[i] = ps[hull[i]];\n }\n\n // Compute normals. Ensure the edges have non-zero length.\n for (let i = 0; i < m; ++i) {\n const i1 = i;\n const i2 = i + 1 < m ? i + 1 : 0;\n const edge = Vec2.sub(this.m_vertices[i2], this.m_vertices[i1]);\n if (_ASSERT) console.assert(edge.lengthSquared() > EPSILON * EPSILON);\n this.m_normals[i] = Vec2.crossVec2Num(edge, 1.0);\n this.m_normals[i].normalize();\n }\n\n // Compute the polygon centroid.\n this.m_centroid = computeCentroid(this.m_vertices, m);\n }\n\n /** @internal */ _setAsBox(hx: number, hy: number, center?: Vec2Value, angle?: number): void {\n // start with right-bottom, counter-clockwise, as in Gift wrapping algorithm in PolygonShape._set()\n this.m_vertices[0] = Vec2.neo(hx, -hy);\n this.m_vertices[1] = Vec2.neo(hx, hy);\n this.m_vertices[2] = Vec2.neo(-hx, hy);\n this.m_vertices[3] = Vec2.neo(-hx, -hy);\n\n this.m_normals[0] = Vec2.neo(1.0, 0.0);\n this.m_normals[1] = Vec2.neo(0.0, 1.0);\n this.m_normals[2] = Vec2.neo(-1.0, 0.0);\n this.m_normals[3] = Vec2.neo(0.0, -1.0);\n\n this.m_count = 4;\n\n if (center && Vec2.isValid(center)) {\n angle = angle || 0;\n\n matrix.copyVec2(this.m_centroid, center);\n\n const xf = Transform.identity();\n xf.p.setVec2(center);\n xf.q.setAngle(angle);\n\n // Transform vertices and normals.\n for (let i = 0; i < this.m_count; ++i) {\n this.m_vertices[i] = Transform.mulVec2(xf, this.m_vertices[i]);\n this.m_normals[i] = Rot.mulVec2(xf.q, this.m_normals[i]);\n }\n }\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): boolean {\n const pLocal = matrix.detransformVec2(temp, xf, p);\n\n for (let i = 0; i < this.m_count; ++i) {\n const dot = matrix.dotVec2(this.m_normals[i], pLocal) - matrix.dotVec2(this.m_normals[i], this.m_vertices[i]);\n if (dot > 0.0) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n\n // Put the ray into the polygon's frame of reference.\n const p1 = Rot.mulTVec2(xf.q, Vec2.sub(input.p1, xf.p));\n const p2 = Rot.mulTVec2(xf.q, Vec2.sub(input.p2, xf.p));\n const d = Vec2.sub(p2, p1);\n\n let lower = 0.0;\n let upper = input.maxFraction;\n\n let index = -1;\n\n for (let i = 0; i < this.m_count; ++i) {\n // p = p1 + a * d\n // dot(normal, p - v) = 0\n // dot(normal, p1 - v) + a * dot(normal, d) = 0\n const numerator = Vec2.dot(this.m_normals[i], Vec2.sub(this.m_vertices[i], p1));\n const denominator = Vec2.dot(this.m_normals[i], d);\n\n if (denominator == 0.0) {\n if (numerator < 0.0) {\n return false;\n }\n } else {\n // Note: we want this predicate without division:\n // lower < numerator / denominator, where denominator < 0\n // Since denominator < 0, we have to flip the inequality:\n // lower < numerator / denominator <==> denominator * lower > numerator.\n if (denominator < 0.0 && numerator < lower * denominator) {\n // Increase lower.\n // The segment enters this half-space.\n lower = numerator / denominator;\n index = i;\n } else if (denominator > 0.0 && numerator < upper * denominator) {\n // Decrease upper.\n // The segment exits this half-space.\n upper = numerator / denominator;\n }\n }\n\n // The use of epsilon here causes the assert on lower to trip\n // in some cases. Apparently the use of epsilon was to make edge\n // shapes work, but now those are handled separately.\n // if (upper < lower - matrix.EPSILON)\n if (upper < lower) {\n return false;\n }\n }\n\n if (_ASSERT) console.assert(0.0 <= lower && lower <= input.maxFraction);\n\n if (index >= 0) {\n output.fraction = lower;\n output.normal = Rot.mulVec2(xf.q, this.m_normals[index]);\n return true;\n }\n\n return false;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (let i = 0; i < this.m_count; ++i) {\n const v = matrix.transformVec2(temp, xf, this.m_vertices[i]);\n minX = math_min(minX, v.x);\n maxX = math_max(maxX, v.x);\n minY = math_min(minY, v.y);\n maxY = math_max(maxY, v.y);\n }\n\n matrix.setVec2(aabb.lowerBound, minX - this.m_radius, minY - this.m_radius);\n matrix.setVec2(aabb.upperBound, maxX + this.m_radius, maxY + this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density: number): void {\n // Polygon mass, centroid, and inertia.\n // Let rho be the polygon density in mass per unit area.\n // Then:\n // mass = rho * int(dA)\n // centroid.x = (1/mass) * rho * int(x * dA)\n // centroid.y = (1/mass) * rho * int(y * dA)\n // I = rho * int((x*x + y*y) * dA)\n //\n // We can compute these integrals by summing all the integrals\n // for each triangle of the polygon. To evaluate the integral\n // for a single triangle, we make a change of variables to\n // the (u,v) coordinates of the triangle:\n // x = x0 + e1x * u + e2x * v\n // y = y0 + e1y * u + e2y * v\n // where 0 <= u && 0 <= v && u + v <= 1.\n //\n // We integrate u from [0,1-v] and then v from [0,1].\n // We also need to use the Jacobian of the transformation:\n // D = cross(e1, e2)\n //\n // Simplification: triangle centroid = (1/3) * (p1 + p2 + p3)\n //\n // The rest of the derivation is handled by computer algebra.\n\n if (_ASSERT) console.assert(this.m_count >= 3);\n\n matrix.zeroVec2(center);\n let area = 0.0;\n let I = 0.0;\n\n // s is the reference point for forming triangles.\n // It's location doesn't change the result (except for rounding error).\n matrix.zeroVec2(s);\n\n // This code would put the reference point inside the polygon.\n for (let i = 0; i < this.m_count; ++i) {\n matrix.plusVec2(s, this.m_vertices[i]);\n }\n matrix.scaleVec2(s, 1.0 / this.m_count, s);\n\n const k_inv3 = 1.0 / 3.0;\n\n for (let i = 0; i < this.m_count; ++i) {\n // Triangle vertices.\n matrix.subVec2(e1, this.m_vertices[i], s);\n if ( i + 1 < this.m_count) {\n matrix.subVec2(e2, this.m_vertices[i + 1], s);\n } else {\n matrix.subVec2(e2, this.m_vertices[0], s);\n }\n\n const D = matrix.crossVec2Vec2(e1, e2);\n\n const triangleArea = 0.5 * D;\n area += triangleArea;\n\n // Area weighted centroid\n matrix.combine2Vec2(temp, triangleArea * k_inv3, e1, triangleArea * k_inv3, e2);\n matrix.plusVec2(center, temp);\n\n const ex1 = e1.x;\n const ey1 = e1.y;\n const ex2 = e2.x;\n const ey2 = e2.y;\n\n const intx2 = ex1 * ex1 + ex2 * ex1 + ex2 * ex2;\n const inty2 = ey1 * ey1 + ey2 * ey1 + ey2 * ey2;\n\n I += (0.25 * k_inv3 * D) * (intx2 + inty2);\n }\n\n // Total mass\n massData.mass = density * area;\n\n // Center of mass\n if (_ASSERT) console.assert(area > EPSILON);\n matrix.scaleVec2(center, 1.0 / area, center);\n matrix.addVec2(massData.center, center, s);\n\n // Inertia tensor relative to the local origin (point s).\n massData.I = density * I;\n\n // Shift to center of mass then to original body origin.\n massData.I += massData.mass * (matrix.dotVec2(massData.center, massData.center) - matrix.dotVec2(center, center));\n }\n\n /**\n * Validate convexity. This is a very time consuming operation.\n * @returns true if valid\n */\n validate(): boolean {\n for (let i = 0; i < this.m_count; ++i) {\n const i1 = i;\n const i2 = i < this.m_count - 1 ? i1 + 1 : 0;\n const p = this.m_vertices[i1];\n matrix.subVec2(e, this.m_vertices[i2], p);\n\n for (let j = 0; j < this.m_count; ++j) {\n if (j == i1 || j == i2) {\n continue;\n }\n\n const c = matrix.crossVec2Vec2(e, matrix.subVec2(temp, this.m_vertices[j], p));\n if (c < 0.0) {\n return false;\n }\n }\n }\n\n return true;\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n for (let i = 0; i < this.m_count; ++i) {\n proxy.m_vertices[i] = this.m_vertices[i];\n }\n proxy.m_vertices.length = this.m_count;\n proxy.m_count = this.m_count;\n proxy.m_radius = this.m_radius;\n }\n}\n\n/** @internal */ function computeCentroid(vs: Vec2[], count: number): Vec2 {\n if (_ASSERT) console.assert(count >= 3);\n\n const c = Vec2.zero();\n let area = 0.0;\n\n // pRef is the reference point for forming triangles.\n // It's location doesn't change the result (except for rounding error).\n const pRef = Vec2.zero();\n if (false) {\n // This code would put the reference point inside the polygon.\n for (let i = 0; i < count; ++i) {\n pRef.add(vs[i]);\n }\n pRef.mul(1.0 / count);\n }\n\n const inv3 = 1.0 / 3.0;\n\n for (let i = 0; i < count; ++i) {\n // Triangle vertices.\n const p1 = pRef;\n const p2 = vs[i];\n const p3 = i + 1 < count ? vs[i + 1] : vs[0];\n\n const e1 = Vec2.sub(p2, p1);\n const e2 = Vec2.sub(p3, p1);\n\n const D = Vec2.crossVec2Vec2(e1, e2);\n\n const triangleArea = 0.5 * D;\n area += triangleArea;\n\n // Area weighted centroid\n matrix.combine3Vec2(temp, 1, p1, 1, p2, 1, p3);\n matrix.plusScaleVec2(c, triangleArea * inv3, temp);\n }\n\n // Centroid\n if (_ASSERT) console.assert(area > EPSILON);\n c.mul(1.0 / area);\n return c;\n}\n\nexport const Polygon = PolygonShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Shape } from \"../Shape\";\nimport { AABBValue, RayCastInput, RayCastOutput } from \"../AABB\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { MassData } from \"../../dynamics/Body\";\nimport { DistanceProxy } from \"../Distance\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_PI = Math.PI;\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n\ndeclare module \"./CircleShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function CircleShape(position: Vec2Value, radius?: number): CircleShape;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function CircleShape(radius?: number): CircleShape;\n}\n\n/** Circle shape. */\n// @ts-expect-error\nexport class CircleShape extends Shape {\n static TYPE = \"circle\" as const;\n /** @hidden */ m_type: \"circle\";\n\n /** @hidden */ m_p: Vec2;\n /** @hidden */ m_radius: number;\n\n constructor(position: Vec2Value, radius?: number);\n constructor(radius?: number);\n constructor(a: any, b?: any) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof CircleShape)) {\n return new CircleShape(a, b);\n }\n\n super();\n\n this.m_type = CircleShape.TYPE;\n this.m_p = Vec2.zero();\n this.m_radius = 1;\n\n if (typeof a === \"object\" && Vec2.isValid(a)) {\n this.m_p.setVec2(a);\n\n if (typeof b === \"number\") {\n this.m_radius = b;\n }\n\n } else if (typeof a === \"number\") {\n this.m_radius = a;\n }\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n p: this.m_p,\n radius: this.m_radius,\n };\n }\n\n /** @internal */\n static _deserialize(data: any): CircleShape {\n return new CircleShape(data.p, data.radius);\n }\n\n /** @hidden */\n _reset(): void {\n // noop\n }\n\n getType(): \"circle\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n getCenter(): Vec2 {\n return this.m_p;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): CircleShape {\n const clone = new CircleShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_p = this.m_p.clone();\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): boolean {\n const center = matrix.transformVec2(temp, xf, this.m_p);\n return matrix.distSqrVec2(p, center) <= this.m_radius * this.m_radius;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n // Collision Detection in Interactive 3D Environments by Gino van den Bergen\n // From Section 3.1.2\n // x = s + a * r\n // norm(x) = radius\n\n const position = Vec2.add(xf.p, Rot.mulVec2(xf.q, this.m_p));\n const s = Vec2.sub(input.p1, position);\n const b = Vec2.dot(s, s) - this.m_radius * this.m_radius;\n\n // Solve quadratic equation.\n const r = Vec2.sub(input.p2, input.p1);\n const c = Vec2.dot(s, r);\n const rr = Vec2.dot(r, r);\n const sigma = c * c - rr * b;\n\n // Check for negative discriminant and short segment.\n if (sigma < 0.0 || rr < EPSILON) {\n return false;\n }\n\n // Find the point of intersection of the line with the circle.\n let a = -(c + math_sqrt(sigma));\n\n // Is the intersection point on the segment?\n if (0.0 <= a && a <= input.maxFraction * rr) {\n a /= rr;\n output.fraction = a;\n output.normal = Vec2.add(s, Vec2.mulNumVec2(a, r));\n output.normal.normalize();\n return true;\n }\n\n return false;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n const p = matrix.transformVec2(temp, xf, this.m_p);\n\n matrix.setVec2(aabb.lowerBound, p.x - this.m_radius, p.y - this.m_radius);\n matrix.setVec2(aabb.upperBound, p.x + this.m_radius, p.y + this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density: number): void {\n massData.mass = density * math_PI * this.m_radius * this.m_radius;\n matrix.copyVec2(massData.center, this.m_p);\n // inertia about the local origin\n massData.I = massData.mass * (0.5 * this.m_radius * this.m_radius + matrix.lengthSqrVec2(this.m_p));\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n proxy.m_vertices[0] = this.m_p;\n proxy.m_vertices.length = 1;\n proxy.m_count = 1;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Circle = CircleShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Distance joint definition. This requires defining an anchor point on both\n * bodies and the non-zero length of the distance joint. The definition uses\n * local anchor points so that the initial configuration can violate the\n * constraint slightly. This helps when saving and loading a game. Warning: Do\n * not use a zero or short length.\n */\nexport interface DistanceJointOpt extends JointOpt {\n /**\n * The mass-spring-damper frequency in Hertz. A value of 0 disables softness.\n */\n frequencyHz?: number;\n /**\n * The damping ratio. 0 = no damping, 1 = critical damping.\n */\n dampingRatio?: number;\n /**\n * Distance length.\n */\n length?: number;\n}\n/**\n * Distance joint definition. This requires defining an anchor point on both\n * bodies and the non-zero length of the distance joint. The definition uses\n * local anchor points so that the initial configuration can violate the\n * constraint slightly. This helps when saving and loading a game. Warning: Do\n * not use a zero or short length.\n */\nexport interface DistanceJointDef extends JointDef, DistanceJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n frequencyHz : 0.0,\n dampingRatio : 0.0\n};\n\ndeclare module \"./DistanceJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function DistanceJoint(def: DistanceJointDef): DistanceJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function DistanceJoint(def: DistanceJointOpt, bodyA: Body, bodyB: Body, anchorA: Vec2Value, anchorB: Vec2Value): DistanceJoint;\n}\n\n/**\n * A distance joint constrains two points on two bodies to remain at a fixed\n * distance from each other. You can view this as a massless, rigid rod.\n */\n// @ts-expect-error\nexport class DistanceJoint extends Joint {\n static TYPE = \"distance-joint\" as const;\n\n // Solver shared\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_length: number;\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_gamma: number;\n /** @internal */ m_bias: number;\n\n // Solver temp\n /** @internal */ m_u: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: number;\n\n /**\n * @param def DistanceJoint definition.\n */\n constructor(def: DistanceJointDef);\n /**\n * @param anchorA Anchor A in global coordination.\n * @param anchorB Anchor B in global coordination.\n */\n constructor(def: DistanceJointOpt, bodyA: Body, bodyB: Body, anchorA?: Vec2Value, anchorB?: Vec2Value);\n constructor(def: DistanceJointDef, bodyA?: Body, bodyB?: Body, anchorA?: Vec2Value, anchorB?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof DistanceJoint)) {\n return new DistanceJoint(def, bodyA, bodyB, anchorA, anchorB);\n }\n\n // order of constructor arguments is changed in v0.2\n if (bodyB && anchorA && (\"m_type\" in anchorA) && (\"x\" in bodyB) && (\"y\" in bodyB)) {\n const temp = bodyB;\n bodyB = anchorA as any as Body;\n anchorA = temp as any as Vec2;\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = DistanceJoint.TYPE;\n\n // Solver shared\n this.m_localAnchorA = Vec2.clone(anchorA ? bodyA.getLocalPoint(anchorA) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchorB ? bodyB.getLocalPoint(anchorB) : def.localAnchorB || Vec2.zero());\n this.m_length = Number.isFinite(def.length) ? def.length :\n Vec2.distance(bodyA.getWorldPoint(this.m_localAnchorA), bodyB.getWorldPoint(this.m_localAnchorB));\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n this.m_impulse = 0.0;\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n\n // 1-D constrained system\n // m (v2 - v1) = lambda\n // v2 + (beta/h) * x1 + gamma * lambda = 0, gamma has units of inverse mass.\n // x2 = x1 + h * v2\n\n // 1-D mass-damper-spring system\n // m (v2 - v1) + h * d * v2 + h * k *\n\n // C = norm(p2 - p1) - L\n // u = (p2 - p1) / norm(p2 - p1)\n // Cdot = dot(u, v2 + cross(w2, r2) - v1 - cross(w1, r1))\n // J = [-u -cross(r1, u) u cross(r2, u)]\n // K = J * invM * JT\n // = invMass1 + invI1 * cross(r1, u)^2 + invMass2 + invI2 * cross(r2, u)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n length: this.m_length,\n\n impulse: this.m_impulse,\n gamma: this.m_gamma,\n bias: this.m_bias,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): DistanceJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new DistanceJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n\n if (def.length > 0) {\n this.m_length = +def.length;\n } else if (def.length < 0) { // don't change length\n } else if (def.anchorA || def.anchorA || def.anchorA || def.anchorA) {\n this.m_length = Vec2.distance(\n this.m_bodyA.getWorldPoint(this.m_localAnchorA),\n this.m_bodyB.getWorldPoint(this.m_localAnchorB)\n );\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the natural length. Manipulating the length can lead to non-physical\n * behavior when the frequency is zero.\n */\n setLength(length: number): void {\n this.m_length = length;\n }\n\n /**\n * Get the natural length.\n */\n getLength(): number {\n return this.m_length;\n }\n\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_u).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n this.m_u = Vec2.sub(Vec2.add(cB, this.m_rB), Vec2.add(cA, this.m_rA));\n\n // Handle singularity.\n const length = this.m_u.length();\n if (length > Settings.linearSlop) {\n this.m_u.mul(1.0 / length);\n } else {\n this.m_u.setNum(0.0, 0.0);\n }\n\n const crAu = Vec2.crossVec2Vec2(this.m_rA, this.m_u);\n const crBu = Vec2.crossVec2Vec2(this.m_rB, this.m_u);\n let invMass = this.m_invMassA + this.m_invIA * crAu * crAu + this.m_invMassB + this.m_invIB * crBu * crBu;\n\n // Compute the effective mass matrix.\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n\n if (this.m_frequencyHz > 0.0) {\n const C = length - this.m_length;\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * this.m_mass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = this.m_mass * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (d + h * k);\n this.m_gamma = this.m_gamma != 0.0 ? 1.0 / this.m_gamma : 0.0;\n this.m_bias = C * h * k * this.m_gamma;\n\n invMass += this.m_gamma;\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n } else {\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n }\n\n if (step.warmStarting) {\n // Scale the impulse to support a variable time step.\n this.m_impulse *= step.dtRatio;\n\n const P = Vec2.mulNumVec2(this.m_impulse, this.m_u);\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Cdot = dot(u, v + cross(w, r))\n const vpA = Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA));\n const vpB = Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB));\n const Cdot = Vec2.dot(this.m_u, vpB) - Vec2.dot(this.m_u, vpA);\n\n const impulse = -this.m_mass * (Cdot + this.m_bias + this.m_gamma * this.m_impulse);\n this.m_impulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_u);\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n if (this.m_frequencyHz > 0.0) {\n // There is no position correction for soft distance constraints.\n return true;\n }\n\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n const u = Vec2.sub(Vec2.add(cB, rB), Vec2.add(cA, rA));\n\n const length = u.normalize();\n const C = clamp(length - this.m_length, -Settings.maxLinearCorrection, Settings.maxLinearCorrection);\n\n const impulse = -this.m_mass * C;\n const P = Vec2.mulNumVec2(impulse, u);\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * Vec2.crossVec2Vec2(rA, P);\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, P);\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return math_abs(C) < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Friction joint definition.\n */\nexport interface FrictionJointOpt extends JointOpt {\n /**\n * The maximum friction force in N.\n */\n maxForce?: number;\n /**\n * The maximum friction torque in N-m.\n */\n maxTorque?: number;\n}\n\n/**\n * Friction joint definition.\n */\nexport interface FrictionJointDef extends JointDef, FrictionJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 0.0,\n maxTorque : 0.0,\n};\n\ndeclare module \"./FrictionJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function FrictionJoint(def: FrictionJointDef): FrictionJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function FrictionJoint(def: FrictionJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): FrictionJoint;\n}\n\n/**\n * Friction joint. This is used for top-down friction. It provides 2D\n * translational friction and angular friction.\n */\n// @ts-expect-error\nexport class FrictionJoint extends Joint {\n static TYPE = \"friction-joint\" as const;\n\n /** @internal */ m_type: \"friction-joint\";\n\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n\n // Solver shared\n /** @internal */ m_linearImpulse: Vec2;\n /** @internal */ m_angularImpulse: number;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_maxTorque: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_linearMass: Mat22;\n /** @internal */ m_angularMass: number;\n\n constructor(def: FrictionJointDef);\n /**\n * @param anchor Anchor in global coordination.\n */\n constructor(def: FrictionJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: FrictionJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof FrictionJoint)) {\n return new FrictionJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = FrictionJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n\n // Solver shared\n this.m_linearImpulse = Vec2.zero();\n this.m_angularImpulse = 0.0;\n this.m_maxForce = def.maxForce;\n this.m_maxTorque = def.maxTorque;\n\n // Point-to-point constraint\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Angle constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n maxForce: this.m_maxForce,\n maxTorque: this.m_maxTorque,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): FrictionJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new FrictionJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.maxTorque)) {\n this.m_maxTorque = def.maxTorque;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the maximum friction force in N.\n */\n setMaxForce(force: number): void {\n if (_ASSERT) console.assert(Number.isFinite(force) && force >= 0.0);\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum friction force in N.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the maximum friction torque in N*m.\n */\n setMaxTorque(torque: number): void {\n if (_ASSERT) console.assert(Number.isFinite(torque) && torque >= 0.0);\n this.m_maxTorque = torque;\n }\n\n /**\n * Get the maximum friction torque in N*m.\n */\n getMaxTorque(): number {\n return this.m_maxTorque;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_linearImpulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_angularImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective mass matrix.\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat22();\n K.ex.x = mA + mB + iA * this.m_rA.y * this.m_rA.y + iB * this.m_rB.y\n * this.m_rB.y;\n K.ex.y = -iA * this.m_rA.x * this.m_rA.y - iB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * this.m_rA.x * this.m_rA.x + iB * this.m_rB.x\n * this.m_rB.x;\n\n this.m_linearMass = K.getInverse();\n\n this.m_angularMass = iA + iB;\n if (this.m_angularMass > 0.0) {\n this.m_angularMass = 1.0 / this.m_angularMass;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_linearImpulse.mul(step.dtRatio);\n this.m_angularImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_linearImpulse.x, this.m_linearImpulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_angularImpulse);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_angularImpulse);\n\n } else {\n this.m_linearImpulse.setZero();\n this.m_angularImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const h = step.dt;\n\n // Solve angular friction\n {\n const Cdot = wB - wA;\n let impulse = -this.m_angularMass * Cdot;\n\n const oldImpulse = this.m_angularImpulse;\n const maxImpulse = h * this.m_maxTorque;\n this.m_angularImpulse = clamp(this.m_angularImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_angularImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve linear friction\n {\n const Cdot = Vec2.sub(\n Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB)),\n Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA))\n );\n\n let impulse = Vec2.neg(Mat22.mulVec2(this.m_linearMass, Cdot));\n const oldImpulse = this.m_linearImpulse;\n this.m_linearImpulse.add(impulse);\n\n const maxImpulse = h * this.m_maxForce;\n\n if (this.m_linearImpulse.lengthSquared() > maxImpulse * maxImpulse) {\n this.m_linearImpulse.normalize();\n this.m_linearImpulse.mul(maxImpulse);\n }\n\n impulse = Vec2.sub(this.m_linearImpulse, oldImpulse);\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { Vec3, Vec3Value } from \"./Vec3\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A 3-by-3 matrix. Stored in column-major order.\n */\nexport class Mat33 {\n ex: Vec3;\n ey: Vec3;\n ez: Vec3;\n\n constructor(a: Vec3Value, b: Vec3Value, c: Vec3Value);\n constructor();\n constructor(a?: Vec3Value, b?: Vec3Value, c?: Vec3Value) {\n if (typeof a === \"object\" && a !== null) {\n this.ex = Vec3.clone(a);\n this.ey = Vec3.clone(b);\n this.ez = Vec3.clone(c);\n } else {\n this.ex = Vec3.zero();\n this.ey = Vec3.zero();\n this.ez = Vec3.zero();\n }\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec3.isValid(obj.ex) && Vec3.isValid(obj.ey) && Vec3.isValid(obj.ez);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Mat33.isValid(o), \"Invalid Mat33!\", o);\n }\n\n /**\n * Set this matrix to all zeros.\n */\n setZero(): Mat33 {\n this.ex.setZero();\n this.ey.setZero();\n this.ez.setZero();\n return this;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases.\n */\n solve33(v: Vec3Value): Vec3 {\n // let det = matrix.dotVec3(this.ex, matrix.newCrossVec3(this.ey, this.ez));\n let cross_x = this.ey.y * this.ez.z - this.ey.z * this.ez.y;\n let cross_y = this.ey.z * this.ez.x - this.ey.x * this.ez.z;\n let cross_z = this.ey.x * this.ez.y - this.ey.y * this.ez.x;\n let det = this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const r = new Vec3();\n // r.x = det * matrix.dotVec3(v, matrix.newCrossVec3(this.ey, this.ez));\n cross_x = this.ey.y * this.ez.z - this.ey.z * this.ez.y;\n cross_y = this.ey.z * this.ez.x - this.ey.x * this.ez.z;\n cross_z = this.ey.x * this.ez.y - this.ey.y * this.ez.x;\n r.x = det * (v.x * cross_x + v.y * cross_y + v.z * cross_z);\n\n // r.y = det * matrix.dotVec3(this.ex, matrix.newCrossVec3(v, this.ez));\n cross_x = v.y * this.ez.z - v.z * this.ez.y;\n cross_y = v.z * this.ez.x - v.x * this.ez.z;\n cross_z = v.x * this.ez.y - v.y * this.ez.x;\n r.y = det * (this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z);\n\n // r.z = det * matrix.dotVec3(this.ex, matrix.newCrossVec3(this.ey, v));\n cross_x = this.ey.y * v.z - this.ey.z * v.y;\n cross_y = this.ey.z * v.x - this.ey.x * v.z;\n cross_z = this.ey.x * v.y - this.ey.y * v.x;\n r.z = det * (this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z);\n return r;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases. Solve only the upper 2-by-2 matrix\n * equation.\n */\n solve22(v: Vec2Value): Vec2 {\n const a11 = this.ex.x;\n const a12 = this.ey.x;\n const a21 = this.ex.y;\n const a22 = this.ey.y;\n let det = a11 * a22 - a12 * a21;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const r = Vec2.zero();\n r.x = det * (a22 * v.x - a12 * v.y);\n r.y = det * (a11 * v.y - a21 * v.x);\n return r;\n }\n\n /**\n * Get the inverse of this matrix as a 2-by-2. Returns the zero matrix if\n * singular.\n */\n getInverse22(M: Mat33): void {\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n M.ex.x = det * d;\n M.ey.x = -det * b;\n M.ex.z = 0.0;\n M.ex.y = -det * c;\n M.ey.y = det * a;\n M.ey.z = 0.0;\n M.ez.x = 0.0;\n M.ez.y = 0.0;\n M.ez.z = 0.0;\n }\n\n /**\n * Get the symmetric inverse of this matrix as a 3-by-3. Returns the zero matrix\n * if singular.\n */\n getSymInverse33(M: Mat33): void {\n let det = Vec3.dot(this.ex, Vec3.cross(this.ey, this.ez));\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const a11 = this.ex.x;\n const a12 = this.ey.x;\n const a13 = this.ez.x;\n const a22 = this.ey.y;\n const a23 = this.ez.y;\n const a33 = this.ez.z;\n\n M.ex.x = det * (a22 * a33 - a23 * a23);\n M.ex.y = det * (a13 * a23 - a12 * a33);\n M.ex.z = det * (a12 * a23 - a13 * a22);\n\n M.ey.x = M.ex.y;\n M.ey.y = det * (a11 * a33 - a13 * a13);\n M.ey.z = det * (a13 * a12 - a11 * a23);\n\n M.ez.x = M.ex.z;\n M.ez.y = M.ey.z;\n M.ez.z = det * (a11 * a22 - a12 * a12);\n }\n\n /**\n * Multiply a matrix times a vector.\n */\n static mul(a: Mat33, b: Vec2Value): Vec2;\n static mul(a: Mat33, b: Vec3Value): Vec3;\n static mul(a, b) {\n if (_ASSERT) Mat33.assert(a);\n if (b && \"z\" in b && \"y\" in b && \"x\" in b) {\n if (_ASSERT) Vec3.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y + a.ez.x * b.z;\n const y = a.ex.y * b.x + a.ey.y * b.y + a.ez.y * b.z;\n const z = a.ex.z * b.x + a.ey.z * b.y + a.ez.z * b.z;\n return new Vec3(x, y, z);\n\n } else if (b && \"y\" in b && \"x\" in b) {\n if (_ASSERT) Vec2.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y;\n const y = a.ex.y * b.x + a.ey.y * b.y;\n return Vec2.neo(x, y);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulVec3(a: Mat33, b: Vec3Value): Vec3 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Vec3.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y + a.ez.x * b.z;\n const y = a.ex.y * b.x + a.ey.y * b.y + a.ez.y * b.z;\n const z = a.ex.z * b.x + a.ey.z * b.y + a.ez.z * b.z;\n return new Vec3(x, y, z);\n }\n\n static mulVec2(a: Mat33, b: Vec2Value): Vec2 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y;\n const y = a.ex.y * b.x + a.ey.y * b.y;\n return Vec2.neo(x, y);\n }\n\n static add(a: Mat33, b: Mat33): Mat33 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Mat33.assert(b);\n return new Mat33(\n Vec3.add(a.ex, b.ex),\n Vec3.add(a.ey, b.ey),\n Vec3.add(a.ez, b.ez)\n );\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n\n\n// todo: use string?\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3,\n} \n\n/**\n * Revolute joint definition. This requires defining an anchor point where the\n * bodies are joined. The definition uses local anchor points so that the\n * initial configuration can violate the constraint slightly. You also need to\n * specify the initial relative angle for joint limits. This helps when saving\n * and loading a game.\n *\n * The local anchor points are measured from the body's origin rather than the\n * center of mass because: 1. you might not know where the center of mass will\n * be. 2. if you add/remove shapes from a body and recompute the mass, the\n * joints will be broken.\n */\nexport interface RevoluteJointOpt extends JointOpt {\n /**\n * The lower angle for the joint limit (radians).\n */\n lowerAngle?: number;\n /**\n * The upper angle for the joint limit (radians).\n */\n upperAngle?: number;\n /**\n * The maximum motor torque used to achieve the desired motor speed. Usually\n * in N-m.\n */\n maxMotorTorque?: number;\n /**\n * The desired motor speed. Usually in radians per second.\n */\n motorSpeed?: number;\n /**\n * A flag to enable joint limits.\n */\n enableLimit?: boolean;\n /**\n * A flag to enable the joint motor.\n */\n enableMotor?: boolean;\n}\n\n/**\n * Revolute joint definition. This requires defining an anchor point where the\n * bodies are joined. The definition uses local anchor points so that the\n * initial configuration can violate the constraint slightly. You also need to\n * specify the initial relative angle for joint limits. This helps when saving\n * and loading a game.\n *\n * The local anchor points are measured from the body's origin rather than the\n * center of mass because: 1. you might not know where the center of mass will\n * be. 2. if you add/remove shapes from a body and recompute the mass, the\n * joints will be broken.\n */\nexport interface RevoluteJointDef extends JointDef, RevoluteJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The bodyB angle minus bodyA angle in the reference state (radians).\n */\n referenceAngle?: number;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n lowerAngle : 0.0,\n upperAngle : 0.0,\n maxMotorTorque : 0.0,\n motorSpeed : 0.0,\n enableLimit : false,\n enableMotor : false\n};\n\ndeclare module \"./RevoluteJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RevoluteJoint(def: RevoluteJointDef): RevoluteJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RevoluteJoint(def: RevoluteJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): RevoluteJoint;\n}\n\n/**\n * A revolute joint constrains two bodies to share a common point while they are\n * free to rotate about the point. The relative rotation about the shared point\n * is the joint angle. You can limit the relative rotation with a joint limit\n * that specifies a lower and upper angle. You can use a motor to drive the\n * relative rotation about the shared point. A maximum motor torque is provided\n * so that infinite forces are not generated.\n */\n// @ts-expect-error\nexport class RevoluteJoint extends Joint {\n static TYPE = \"revolute-joint\" as const;\n\n /** @internal */ m_type: \"revolute-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngle: number;\n /** @internal */ m_impulse: Vec3;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_lowerAngle: number;\n /** @internal */ m_upperAngle: number;\n /** @internal */ m_maxMotorTorque: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableLimit: boolean;\n /** @internal */ m_enableMotor: boolean;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n // effective mass for point-to-point constraint.\n /** @internal */ m_mass: Mat33;\n // effective mass for motor/limit angular constraint.\n /** @internal */ m_motorMass: number;\n /** @internal */ m_limitState: number;\n\n constructor(def: RevoluteJointDef);\n constructor(def: RevoluteJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: RevoluteJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof RevoluteJoint)) {\n return new RevoluteJoint(def, bodyA, bodyB, anchor);\n }\n\n def = def ?? {} as RevoluteJointDef;\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_mass = new Mat33();\n this.m_limitState = LimitState.inactiveLimit;\n\n this.m_type = RevoluteJoint.TYPE;\n\n if (Vec2.isValid(anchor)) {\n this.m_localAnchorA = bodyA.getLocalPoint(anchor);\n } else if (Vec2.isValid(def.localAnchorA)) {\n this.m_localAnchorA = Vec2.clone(def.localAnchorA);\n } else {\n this.m_localAnchorA = Vec2.zero();\n }\n\n if (Vec2.isValid(anchor)) {\n this.m_localAnchorB = bodyB.getLocalPoint(anchor);\n } else if (Vec2.isValid(def.localAnchorB)) {\n this.m_localAnchorB = Vec2.clone(def.localAnchorB);\n } else {\n this.m_localAnchorB = Vec2.zero();\n }\n\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n } else {\n this.m_referenceAngle = bodyB.getAngle() - bodyA.getAngle();\n }\n\n this.m_impulse = new Vec3();\n this.m_motorImpulse = 0.0;\n\n this.m_lowerAngle = def.lowerAngle ?? DEFAULTS.lowerAngle;\n this.m_upperAngle = def.upperAngle ?? DEFAULTS.upperAngle;\n this.m_maxMotorTorque = def.maxMotorTorque ?? DEFAULTS.maxMotorTorque;\n this.m_motorSpeed = def.motorSpeed ?? DEFAULTS.motorSpeed;\n this.m_enableLimit = def.enableLimit ?? DEFAULTS.enableLimit;\n this.m_enableMotor = def.enableMotor ?? DEFAULTS.enableMotor;\n\n // Point-to-point constraint\n // C = p2 - p1\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Motor constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n lowerAngle: this.m_lowerAngle,\n upperAngle: this.m_upperAngle,\n maxMotorTorque: this.m_maxMotorTorque,\n motorSpeed: this.m_motorSpeed,\n enableLimit: this.m_enableLimit,\n enableMotor: this.m_enableMotor,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any):RevoluteJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new RevoluteJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n }\n if (def.enableLimit !== undefined) {\n this.m_enableLimit = def.enableLimit;\n }\n if (Number.isFinite(def.lowerAngle)) {\n this.m_lowerAngle = def.lowerAngle;\n }\n if (Number.isFinite(def.upperAngle)) {\n this.m_upperAngle = def.upperAngle;\n }\n if (Number.isFinite(def.maxMotorTorque)) {\n this.m_maxMotorTorque = def.maxMotorTorque;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n if (def.enableMotor !== undefined) {\n this.m_enableMotor = def.enableMotor;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Get the current joint angle in radians.\n */\n getJointAngle(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n return bB.m_sweep.a - bA.m_sweep.a - this.m_referenceAngle;\n }\n\n /**\n * Get the current joint angle speed in radians per second.\n */\n getJointSpeed(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n return bB.m_angularVelocity - bA.m_angularVelocity;\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Get the current motor torque given the inverse time step. Unit is N*m.\n */\n getMotorTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Set the motor speed in radians per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Get the motor speed in radians per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Set the maximum motor torque, usually in N-m.\n */\n setMaxMotorTorque(torque: number): void {\n if (torque == this.m_maxMotorTorque) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorTorque = torque;\n }\n\n getMaxMotorTorque(): number {\n return this.m_maxMotorTorque;\n }\n\n /**\n * Is the joint limit enabled?\n */\n isLimitEnabled(): boolean {\n return this.m_enableLimit;\n }\n\n /**\n * Enable/disable the joint limit.\n */\n enableLimit(flag: boolean): void {\n if (flag != this.m_enableLimit) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableLimit = flag;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Get the lower joint limit in radians.\n */\n getLowerLimit(): number {\n return this.m_lowerAngle;\n }\n\n /**\n * Get the upper joint limit in radians.\n */\n getUpperLimit(): number {\n return this.m_upperAngle;\n }\n\n /**\n * Set the joint limits in radians.\n */\n setLimits(lower: number, upper: number): void {\n if (_ASSERT) console.assert(lower <= upper);\n\n if (lower != this.m_lowerAngle || upper != this.m_upperAngle) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_impulse.z = 0.0;\n this.m_lowerAngle = lower;\n this.m_upperAngle = upper;\n }\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force given the inverse time step. Unit is N.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.neo(this.m_impulse.x, this.m_impulse.y).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque due to the joint limit given the inverse time step.\n * Unit is N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.z;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const fixedRotation = (iA + iB === 0.0);\n\n this.m_mass.ex.x = mA + mB + this.m_rA.y * this.m_rA.y * iA + this.m_rB.y * this.m_rB.y * iB;\n this.m_mass.ey.x = -this.m_rA.y * this.m_rA.x * iA - this.m_rB.y * this.m_rB.x * iB;\n this.m_mass.ez.x = -this.m_rA.y * iA - this.m_rB.y * iB;\n this.m_mass.ex.y = this.m_mass.ey.x;\n this.m_mass.ey.y = mA + mB + this.m_rA.x * this.m_rA.x * iA + this.m_rB.x * this.m_rB.x * iB;\n this.m_mass.ez.y = this.m_rA.x * iA + this.m_rB.x * iB;\n this.m_mass.ex.z = this.m_mass.ez.x;\n this.m_mass.ey.z = this.m_mass.ez.y;\n this.m_mass.ez.z = iA + iB;\n\n this.m_motorMass = iA + iB;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n\n if (this.m_enableMotor == false || fixedRotation) {\n this.m_motorImpulse = 0.0;\n }\n\n if (this.m_enableLimit && fixedRotation == false) {\n const jointAngle = aB - aA - this.m_referenceAngle;\n\n if (math_abs(this.m_upperAngle - this.m_lowerAngle) < 2.0 * Settings.angularSlop) {\n this.m_limitState = LimitState.equalLimits;\n\n } else if (jointAngle <= this.m_lowerAngle) {\n if (this.m_limitState != LimitState.atLowerLimit) {\n this.m_impulse.z = 0.0;\n }\n this.m_limitState = LimitState.atLowerLimit;\n\n } else if (jointAngle >= this.m_upperAngle) {\n if (this.m_limitState != LimitState.atUpperLimit) {\n this.m_impulse.z = 0.0;\n }\n this.m_limitState = LimitState.atUpperLimit;\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_impulse.mul(step.dtRatio);\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_impulse.x, this.m_impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_motorImpulse + this.m_impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_motorImpulse + this.m_impulse.z);\n\n } else {\n this.m_impulse.setZero();\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const fixedRotation = (iA + iB === 0.0);\n\n // Solve motor constraint.\n if (this.m_enableMotor && this.m_limitState != LimitState.equalLimits && fixedRotation == false) {\n const Cdot = wB - wA - this.m_motorSpeed;\n let impulse = -this.m_motorMass * Cdot;\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorTorque;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve limit constraint.\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit && fixedRotation == false) {\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const Cdot2 = wB - wA;\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const impulse = Vec3.neg(this.m_mass.solve33(Cdot));\n\n if (this.m_limitState == LimitState.equalLimits) {\n this.m_impulse.add(impulse);\n\n } else if (this.m_limitState == LimitState.atLowerLimit) {\n const newImpulse = this.m_impulse.z + impulse.z;\n\n if (newImpulse < 0.0) {\n const rhs = Vec2.combine(-1, Cdot1, this.m_impulse.z, Vec2.neo(this.m_mass.ez.x, this.m_mass.ez.y));\n const reduced = this.m_mass.solve22(rhs);\n impulse.x = reduced.x;\n impulse.y = reduced.y;\n impulse.z = -this.m_impulse.z;\n this.m_impulse.x += reduced.x;\n this.m_impulse.y += reduced.y;\n this.m_impulse.z = 0.0;\n\n } else {\n this.m_impulse.add(impulse);\n }\n\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n const newImpulse = this.m_impulse.z + impulse.z;\n\n if (newImpulse > 0.0) {\n const rhs = Vec2.combine(-1, Cdot1, this.m_impulse.z, Vec2.neo(this.m_mass.ez.x, this.m_mass.ez.y));\n const reduced = this.m_mass.solve22(rhs);\n impulse.x = reduced.x;\n impulse.y = reduced.y;\n impulse.z = -this.m_impulse.z;\n this.m_impulse.x += reduced.x;\n this.m_impulse.y += reduced.y;\n this.m_impulse.z = 0.0;\n\n } else {\n this.m_impulse.add(impulse);\n }\n }\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + impulse.z);\n\n } else {\n // Solve point-to-point constraint\n const Cdot = Vec2.zero();\n Cdot.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const impulse = this.m_mass.solve22(Vec2.neg(Cdot));\n\n this.m_impulse.x += impulse.x;\n this.m_impulse.y += impulse.y;\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n let angularError = 0.0;\n let positionError = 0.0;\n\n const fixedRotation = (this.m_invIA + this.m_invIB == 0.0);\n\n // Solve angular limit constraint.\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit && fixedRotation == false) {\n const angle = aB - aA - this.m_referenceAngle;\n let limitImpulse = 0.0;\n\n if (this.m_limitState == LimitState.equalLimits) {\n // Prevent large angular corrections\n const C = clamp(angle - this.m_lowerAngle, -Settings.maxAngularCorrection, Settings.maxAngularCorrection);\n limitImpulse = -this.m_motorMass * C;\n angularError = math_abs(C);\n\n } else if (this.m_limitState == LimitState.atLowerLimit) {\n let C = angle - this.m_lowerAngle;\n angularError = -C;\n\n // Prevent large angular corrections and allow some slop.\n C = clamp(C + Settings.angularSlop, -Settings.maxAngularCorrection, 0.0);\n limitImpulse = -this.m_motorMass * C;\n\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n let C = angle - this.m_upperAngle;\n angularError = C;\n\n // Prevent large angular corrections and allow some slop.\n C = clamp(C - Settings.angularSlop, 0.0, Settings.maxAngularCorrection);\n limitImpulse = -this.m_motorMass * C;\n }\n\n aA -= this.m_invIA * limitImpulse;\n aB += this.m_invIB * limitImpulse;\n }\n\n // Solve point-to-point constraint.\n {\n qA.setAngle(aA);\n qB.setAngle(aB);\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n const C = Vec2.zero();\n C.addCombine(1, cB, 1, rB);\n C.subCombine(1, cA, 1, rA);\n positionError = C.length();\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat22();\n K.ex.x = mA + mB + iA * rA.y * rA.y + iB * rB.y * rB.y;\n K.ex.y = -iA * rA.x * rA.y - iB * rB.x * rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * rA.x * rA.x + iB * rB.x * rB.x;\n\n const impulse = Vec2.neg(K.solve(C));\n\n cA.subMul(mA, impulse);\n aA -= iA * Vec2.crossVec2Vec2(rA, impulse);\n\n cB.addMul(mB, impulse);\n aB += iB * Vec2.crossVec2Vec2(rB, impulse);\n }\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return positionError <= Settings.linearSlop && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3, \n}\n\n/**\n * Prismatic joint definition. This requires defining a line of motion using an\n * axis and an anchor point. The definition uses local anchor points and a local\n * axis so that the initial configuration can violate the constraint slightly.\n * The joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface PrismaticJointOpt extends JointOpt {\n /**\n * Enable/disable the joint limit.\n */\n enableLimit?: boolean;\n /**\n * The lower translation limit, usually in meters.\n */\n lowerTranslation?: number;\n /**\n * The upper translation limit, usually in meters.\n */\n upperTranslation?: number;\n /**\n * Enable/disable the joint motor.\n */\n enableMotor?: boolean;\n /**\n * The maximum motor torque, usually in N-m.\n */\n maxMotorForce?: number;\n /**\n * The desired motor speed in radians per second.\n */\n motorSpeed?: number;\n}\n\n/**\n * Prismatic joint definition. This requires defining a line of motion using an\n * axis and an anchor point. The definition uses local anchor points and a local\n * axis so that the initial configuration can violate the constraint slightly.\n * The joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface PrismaticJointDef extends JointDef, PrismaticJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The local translation unit axis in bodyA.\n */\n localAxisA: Vec2Value;\n /**\n * referenceAngle The constrained angle between the bodies:\n * bodyB_angle - bodyA_angle.\n */\n referenceAngle?: number;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n enableLimit : false,\n lowerTranslation : 0.0,\n upperTranslation : 0.0,\n enableMotor : false,\n maxMotorForce : 0.0,\n motorSpeed : 0.0\n};\n\ndeclare module \"./PrismaticJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PrismaticJoint(def: PrismaticJointDef): PrismaticJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PrismaticJoint(def: PrismaticJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value, axis: Vec2Value): PrismaticJoint;\n}\n\n/**\n * A prismatic joint. This joint provides one degree of freedom: translation\n * along an axis fixed in bodyA. Relative rotation is prevented. You can use a\n * joint limit to restrict the range of motion and a joint motor to drive the\n * motion or to model joint friction.\n */\n// @ts-expect-error\nexport class PrismaticJoint extends Joint {\n static TYPE = \"prismatic-joint\" as const;\n\n /** @internal */ m_type: \"prismatic-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_localXAxisA: Vec2;\n /** @internal */ m_localYAxisA: Vec2;\n /** @internal */ m_referenceAngle: number;\n /** @internal */ m_impulse: Vec3;\n /** @internal */ m_motorMass: number;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_lowerTranslation: number;\n /** @internal */ m_upperTranslation: number;\n /** @internal */ m_maxMotorForce: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableLimit: boolean;\n /** @internal */ m_enableMotor: boolean;\n /** @internal */ m_limitState: number; // TODO enum\n /** @internal */ m_axis: Vec2;\n /** @internal */ m_perp: Vec2;\n // Solver temp\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_s1: number;\n /** @internal */ m_s2: number;\n /** @internal */ m_a1: number;\n /** @internal */ m_a2: number;\n /** @internal */ m_K: Mat33;\n\n constructor(def: PrismaticJointDef);\n constructor(def: PrismaticJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value, axis?: Vec2Value);\n constructor(def: PrismaticJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value, axis?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PrismaticJoint)) {\n return new PrismaticJoint(def, bodyA, bodyB, anchor, axis);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = PrismaticJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n this.m_localXAxisA = Vec2.clone(axis ? bodyA.getLocalVector(axis) : def.localAxisA || Vec2.neo(1.0, 0.0));\n this.m_localXAxisA.normalize();\n this.m_localYAxisA = Vec2.crossNumVec2(1.0, this.m_localXAxisA);\n this.m_referenceAngle = Number.isFinite(def.referenceAngle) ? def.referenceAngle : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_impulse = new Vec3();\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n\n this.m_lowerTranslation = def.lowerTranslation;\n this.m_upperTranslation = def.upperTranslation;\n this.m_maxMotorForce = def.maxMotorForce;\n this.m_motorSpeed = def.motorSpeed;\n this.m_enableLimit = def.enableLimit;\n this.m_enableMotor = def.enableMotor;\n this.m_limitState = LimitState.inactiveLimit;\n\n this.m_axis = Vec2.zero();\n this.m_perp = Vec2.zero();\n\n this.m_K = new Mat33();\n\n // Linear constraint (point-to-line)\n // d = p2 - p1 = x2 + r2 - x1 - r1\n // C = dot(perp, d)\n // Cdot = dot(d, cross(w1, perp)) + dot(perp, v2 + cross(w2, r2) - v1 -\n // cross(w1, r1))\n // = -dot(perp, v1) - dot(cross(d + r1, perp), w1) + dot(perp, v2) +\n // dot(cross(r2, perp), v2)\n // J = [-perp, -cross(d + r1, perp), perp, cross(r2,perp)]\n //\n // Angular constraint\n // C = a2 - a1 + a_initial\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n //\n // K = J * invM * JT\n //\n // J = [-a -s1 a s2]\n // [0 -1 0 1]\n // a = perp\n // s1 = cross(d + r1, a) = cross(p2 - x1, a)\n // s2 = cross(r2, a) = cross(p2 - x2, a)\n\n // Motor/Limit linear constraint\n // C = dot(ax1, d)\n // Cdot = = -dot(ax1, v1) - dot(cross(d + r1, ax1), w1) + dot(ax1, v2) +\n // dot(cross(r2, ax1), v2)\n // J = [-ax1 -cross(d+r1,ax1) ax1 cross(r2,ax1)]\n\n // Block Solver\n // We develop a block solver that includes the joint limit. This makes the\n // limit stiff (inelastic) even\n // when the mass has poor distribution (leading to large torques about the\n // joint anchor points).\n //\n // The Jacobian has 3 rows:\n // J = [-uT -s1 uT s2] // linear\n // [0 -1 0 1] // angular\n // [-vT -a1 vT a2] // limit\n //\n // u = perp\n // v = axis\n // s1 = cross(d + r1, u), s2 = cross(r2, u)\n // a1 = cross(d + r1, v), a2 = cross(r2, v)\n\n // M * (v2 - v1) = JT * df\n // J * v2 = bias\n //\n // v2 = v1 + invM * JT * df\n // J * (v1 + invM * JT * df) = bias\n // K * df = bias - J * v1 = -Cdot\n // K = J * invM * JT\n // Cdot = J * v1 - bias\n //\n // Now solve for f2.\n // df = f2 - f1\n // K * (f2 - f1) = -Cdot\n // f2 = invK * (-Cdot) + f1\n //\n // Clamp accumulated limit impulse.\n // lower: f2(3) = max(f2(3), 0)\n // upper: f2(3) = min(f2(3), 0)\n //\n // Solve for correct f2(1:2)\n // K(1:2, 1:2) * f2(1:2) = -Cdot(1:2) - K(1:2,3) * f2(3) + K(1:2,1:3) * f1\n // = -Cdot(1:2) - K(1:2,3) * f2(3) + K(1:2,1:2) * f1(1:2) + K(1:2,3) * f1(3)\n // K(1:2, 1:2) * f2(1:2) = -Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3)) +\n // K(1:2,1:2) * f1(1:2)\n // f2(1:2) = invK(1:2,1:2) * (-Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3))) +\n // f1(1:2)\n //\n // Now compute impulse to be applied:\n // df = f2 - f1\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n lowerTranslation: this.m_lowerTranslation,\n upperTranslation: this.m_upperTranslation,\n maxMotorForce: this.m_maxMotorForce,\n motorSpeed: this.m_motorSpeed,\n enableLimit: this.m_enableLimit,\n enableMotor: this.m_enableMotor,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n localAxisA: this.m_localXAxisA,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): PrismaticJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.localAxisA = Vec2.clone(data.localAxisA);\n const joint = new PrismaticJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (def.localAxisA) {\n this.m_localXAxisA.setVec2(def.localAxisA);\n this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1.0, def.localAxisA));\n }\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n }\n if (typeof def.enableLimit !== \"undefined\") {\n this.m_enableLimit = !!def.enableLimit;\n }\n if (Number.isFinite(def.lowerTranslation)) {\n this.m_lowerTranslation = def.lowerTranslation;\n }\n if (Number.isFinite(def.upperTranslation)) {\n this.m_upperTranslation = def.upperTranslation;\n }\n if (typeof def.enableMotor !== \"undefined\") {\n this.m_enableMotor = !!def.enableMotor;\n }\n if (Number.isFinite(def.maxMotorForce)) {\n this.m_maxMotorForce = def.maxMotorForce;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * The local joint axis relative to bodyA.\n */\n getLocalAxisA(): Vec2 {\n return this.m_localXAxisA;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Get the current joint translation, usually in meters.\n */\n getJointTranslation(): number {\n const pA = this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n const pB = this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n const d = Vec2.sub(pB, pA);\n const axis = this.m_bodyA.getWorldVector(this.m_localXAxisA);\n\n const translation = Vec2.dot(d, axis);\n return translation;\n }\n\n /**\n * Get the current joint translation speed, usually in meters per second.\n */\n getJointSpeed(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n\n const rA = Rot.mulVec2(bA.m_xf.q, Vec2.sub(this.m_localAnchorA, bA.m_sweep.localCenter));\n const rB = Rot.mulVec2(bB.m_xf.q, Vec2.sub(this.m_localAnchorB, bB.m_sweep.localCenter));\n const p1 = Vec2.add(bA.m_sweep.c, rA);\n const p2 = Vec2.add(bB.m_sweep.c, rB);\n const d = Vec2.sub(p2, p1);\n const axis = Rot.mulVec2(bA.m_xf.q, this.m_localXAxisA);\n\n const vA = bA.m_linearVelocity;\n const vB = bB.m_linearVelocity;\n const wA = bA.m_angularVelocity;\n const wB = bB.m_angularVelocity;\n\n const speed = Vec2.dot(d, Vec2.crossNumVec2(wA, axis)) + Vec2.dot(axis, Vec2.sub(Vec2.addCrossNumVec2(vB, wB, rB), Vec2.addCrossNumVec2(vA, wA, rA)));\n return speed;\n }\n\n /**\n * Is the joint limit enabled?\n */\n isLimitEnabled(): boolean {\n return this.m_enableLimit;\n }\n\n /**\n * Enable/disable the joint limit.\n */\n enableLimit(flag: boolean): void {\n if (flag != this.m_enableLimit) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableLimit = flag;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Get the lower joint limit, usually in meters.\n */\n getLowerLimit(): number {\n return this.m_lowerTranslation;\n }\n\n /**\n * Get the upper joint limit, usually in meters.\n */\n getUpperLimit(): number {\n return this.m_upperTranslation;\n }\n\n /**\n * Set the joint limits, usually in meters.\n */\n setLimits(lower: number, upper: number): void {\n if (_ASSERT) console.assert(lower <= upper);\n if (lower != this.m_lowerTranslation || upper != this.m_upperTranslation) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_lowerTranslation = lower;\n this.m_upperTranslation = upper;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Set the motor speed, usually in meters per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Set the maximum motor force, usually in N.\n */\n setMaxMotorForce(force: number): void {\n if (force == this.m_maxMotorForce) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorForce = force;\n }\n\n getMaxMotorForce(): number {\n return this.m_maxMotorForce;\n }\n\n /**\n * Get the motor speed, usually in meters per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Get the current motor force given the inverse time step, usually in N.\n */\n getMotorForce(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.combine(this.m_impulse.x, this.m_perp, this.m_motorImpulse + this.m_impulse.z, this.m_axis).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.y;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective masses.\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Compute motor Jacobian and effective mass.\n {\n this.m_axis = Rot.mulVec2(qA, this.m_localXAxisA);\n this.m_a1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_axis);\n this.m_a2 = Vec2.crossVec2Vec2(rB, this.m_axis);\n\n this.m_motorMass = mA + mB + iA * this.m_a1 * this.m_a1 + iB * this.m_a2\n * this.m_a2;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n }\n\n // Prismatic constraint.\n {\n this.m_perp = Rot.mulVec2(qA, this.m_localYAxisA);\n\n this.m_s1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_perp);\n this.m_s2 = Vec2.crossVec2Vec2(rB, this.m_perp);\n\n const s1test = Vec2.crossVec2Vec2(rA, this.m_perp);\n\n const k11 = mA + mB + iA * this.m_s1 * this.m_s1 + iB * this.m_s2 * this.m_s2;\n const k12 = iA * this.m_s1 + iB * this.m_s2;\n const k13 = iA * this.m_s1 * this.m_a1 + iB * this.m_s2 * this.m_a2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n // For bodies with fixed rotation.\n k22 = 1.0;\n }\n const k23 = iA * this.m_a1 + iB * this.m_a2;\n const k33 = mA + mB + iA * this.m_a1 * this.m_a1 + iB * this.m_a2 * this.m_a2;\n\n this.m_K.ex.set(k11, k12, k13);\n this.m_K.ey.set(k12, k22, k23);\n this.m_K.ez.set(k13, k23, k33);\n }\n\n // Compute motor and limit terms.\n if (this.m_enableLimit) {\n\n const jointTranslation = Vec2.dot(this.m_axis, d);\n if (math_abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * Settings.linearSlop) {\n this.m_limitState = LimitState.equalLimits;\n\n } else if (jointTranslation <= this.m_lowerTranslation) {\n if (this.m_limitState != LimitState.atLowerLimit) {\n this.m_limitState = LimitState.atLowerLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else if (jointTranslation >= this.m_upperTranslation) {\n if (this.m_limitState != LimitState.atUpperLimit) {\n this.m_limitState = LimitState.atUpperLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n if (this.m_enableMotor == false) {\n this.m_motorImpulse = 0.0;\n }\n\n if (step.warmStarting) {\n // Account for variable time step.\n this.m_impulse.mul(step.dtRatio);\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.combine(this.m_impulse.x, this.m_perp, this.m_motorImpulse\n + this.m_impulse.z, this.m_axis);\n const LA = this.m_impulse.x * this.m_s1 + this.m_impulse.y\n + (this.m_motorImpulse + this.m_impulse.z) * this.m_a1;\n const LB = this.m_impulse.x * this.m_s2 + this.m_impulse.y\n + (this.m_motorImpulse + this.m_impulse.z) * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n } else {\n this.m_impulse.setZero();\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Solve linear motor constraint.\n if (this.m_enableMotor && this.m_limitState != LimitState.equalLimits) {\n const Cdot = Vec2.dot(this.m_axis, Vec2.sub(vB, vA)) + this.m_a2 * wB\n - this.m_a1 * wA;\n let impulse = this.m_motorMass * (this.m_motorSpeed - Cdot);\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorForce;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse,\n -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_axis);\n const LA = impulse * this.m_a1;\n const LB = impulse * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n const Cdot1 = Vec2.zero();\n Cdot1.x += Vec2.dot(this.m_perp, vB) + this.m_s2 * wB;\n Cdot1.x -= Vec2.dot(this.m_perp, vA) + this.m_s1 * wA;\n Cdot1.y = wB - wA;\n\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit) {\n // Solve prismatic and limit constraint in block form.\n let Cdot2 = 0;\n Cdot2 += Vec2.dot(this.m_axis, vB) + this.m_a2 * wB;\n Cdot2 -= Vec2.dot(this.m_axis, vA) + this.m_a1 * wA;\n\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const f1 = Vec3.clone(this.m_impulse);\n let df = this.m_K.solve33(Vec3.neg(Cdot));\n this.m_impulse.add(df);\n\n if (this.m_limitState == LimitState.atLowerLimit) {\n this.m_impulse.z = math_max(this.m_impulse.z, 0.0);\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n this.m_impulse.z = math_min(this.m_impulse.z, 0.0);\n }\n\n // f2(1:2) = invK(1:2,1:2) * (-Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3))) +\n // f1(1:2)\n const b = Vec2.combine(-1, Cdot1, -(this.m_impulse.z - f1.z), Vec2.neo(this.m_K.ez.x, this.m_K.ez.y));\n const f2r = Vec2.add(this.m_K.solve22(b), Vec2.neo(f1.x, f1.y));\n this.m_impulse.x = f2r.x;\n this.m_impulse.y = f2r.y;\n\n df = Vec3.sub(this.m_impulse, f1);\n\n const P = Vec2.combine(df.x, this.m_perp, df.z, this.m_axis);\n const LA = df.x * this.m_s1 + df.y + df.z * this.m_a1;\n const LB = df.x * this.m_s2 + df.y + df.z * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n } else {\n // Limit is inactive, just solve the prismatic constraint in block form.\n const df = this.m_K.solve22(Vec2.neg(Cdot1));\n this.m_impulse.x += df.x;\n this.m_impulse.y += df.y;\n\n const P = Vec2.mulNumVec2(df.x, this.m_perp);\n const LA = df.x * this.m_s1 + df.y;\n const LB = df.x * this.m_s2 + df.y;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Compute fresh Jacobians\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.sub(Vec2.add(cB, rB), Vec2.add(cA, rA));\n\n const axis = Rot.mulVec2(qA, this.m_localXAxisA);\n const a1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), axis);\n const a2 = Vec2.crossVec2Vec2(rB, axis);\n const perp = Rot.mulVec2(qA, this.m_localYAxisA);\n\n const s1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), perp);\n const s2 = Vec2.crossVec2Vec2(rB, perp);\n\n let impulse = new Vec3();\n const C1 = Vec2.zero();\n C1.x = Vec2.dot(perp, d);\n C1.y = aB - aA - this.m_referenceAngle;\n\n let linearError = math_abs(C1.x);\n const angularError = math_abs(C1.y);\n\n const linearSlop = Settings.linearSlop;\n const maxLinearCorrection = Settings.maxLinearCorrection;\n\n let active = false; // bool\n let C2 = 0.0;\n if (this.m_enableLimit) {\n\n const translation = Vec2.dot(axis, d);\n if (math_abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * linearSlop) {\n // Prevent large angular corrections\n C2 = clamp(translation, -maxLinearCorrection, maxLinearCorrection);\n linearError = math_max(linearError, math_abs(translation));\n active = true;\n\n } else if (translation <= this.m_lowerTranslation) {\n // Prevent large linear corrections and allow some slop.\n C2 = clamp(translation - this.m_lowerTranslation + linearSlop,\n -maxLinearCorrection, 0.0);\n linearError = Math\n .max(linearError, this.m_lowerTranslation - translation);\n active = true;\n\n } else if (translation >= this.m_upperTranslation) {\n // Prevent large linear corrections and allow some slop.\n C2 = clamp(translation - this.m_upperTranslation - linearSlop, 0.0,\n maxLinearCorrection);\n linearError = Math\n .max(linearError, translation - this.m_upperTranslation);\n active = true;\n }\n }\n\n if (active) {\n const k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2;\n const k12 = iA * s1 + iB * s2;\n const k13 = iA * s1 * a1 + iB * s2 * a2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n // For fixed rotation\n k22 = 1.0;\n }\n const k23 = iA * a1 + iB * a2;\n const k33 = mA + mB + iA * a1 * a1 + iB * a2 * a2;\n\n const K = new Mat33();\n K.ex.set(k11, k12, k13);\n K.ey.set(k12, k22, k23);\n K.ez.set(k13, k23, k33);\n\n const C = new Vec3();\n C.x = C1.x;\n C.y = C1.y;\n C.z = C2;\n\n impulse = K.solve33(Vec3.neg(C));\n } else {\n const k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2;\n const k12 = iA * s1 + iB * s2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n k22 = 1.0;\n }\n\n const K = new Mat22();\n K.ex.setNum(k11, k12);\n K.ey.setNum(k12, k22);\n\n const impulse1 = K.solve(Vec2.neg(C1));\n impulse.x = impulse1.x;\n impulse.y = impulse1.y;\n impulse.z = 0.0;\n }\n\n const P = Vec2.combine(impulse.x, perp, impulse.z, axis);\n const LA = impulse.x * s1 + impulse.y + impulse.z * a1;\n const LB = impulse.x * s2 + impulse.y + impulse.z * a2;\n\n cA.subMul(mA, P);\n aA -= iA * LA;\n cB.addMul(mB, P);\n aB += iB * LB;\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return linearError <= Settings.linearSlop\n && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { } from \"../../common/Math\";\nimport { Vec2 } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { RevoluteJoint } from \"./RevoluteJoint\";\nimport { PrismaticJoint } from \"./PrismaticJoint\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Gear joint definition.\n */\nexport interface GearJointOpt extends JointOpt {\n /**\n * The gear ratio. See {@link GearJoint} for explanation.\n */\n ratio?: number;\n}\n\n/**\n * Gear joint definition.\n */\nexport interface GearJointDef extends JointDef, GearJointOpt {\n /**\n * The first revolute/prismatic joint attached to the gear joint.\n */\n joint1: RevoluteJoint | PrismaticJoint;\n /**\n * The second prismatic/revolute joint attached to the gear joint.\n */\n joint2: RevoluteJoint | PrismaticJoint;\n}\n\n/** @internal */ const DEFAULTS = {\n ratio : 1.0\n};\n\ndeclare module \"./GearJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function GearJoint(def: GearJointDef): GearJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function GearJoint(def: GearJointOpt, bodyA: Body, bodyB: Body, joint1: RevoluteJoint | PrismaticJoint, joint2: RevoluteJoint | PrismaticJoint, ratio?: number): GearJoint;\n}\n\n/**\n * A gear joint is used to connect two joints together. Either joint can be a\n * revolute or prismatic joint. You specify a gear ratio to bind the motions\n * together: coordinate1 + ratio * coordinate2 = constant\n *\n * The ratio can be negative or positive. If one joint is a revolute joint and\n * the other joint is a prismatic joint, then the ratio will have units of\n * length or units of 1/length. Warning: You have to manually destroy the gear\n * joint if joint1 or joint2 is destroyed.\n *\n * This definition requires two existing revolute or prismatic joints (any\n * combination will work).\n */\n// @ts-expect-error\nexport class GearJoint extends Joint {\n static TYPE = \"gear-joint\" as const;\n\n /** @internal */ m_type: \"gear-joint\";\n /** @internal */ m_joint1: RevoluteJoint | PrismaticJoint;\n /** @internal */ m_joint2: RevoluteJoint | PrismaticJoint;\n /** @internal */ m_type1: \"revolute-joint\" | \"prismatic-joint\";\n /** @internal */ m_type2: \"revolute-joint\" | \"prismatic-joint\";\n /** @internal */ m_bodyC: Body;\n /** @internal */ m_localAnchorC: Vec2;\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_referenceAngleA: number;\n /** @internal */ m_localAxisC: Vec2;\n /** @internal */ m_bodyD: Body;\n /** @internal */ m_localAnchorD: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngleB: number;\n /** @internal */ m_localAxisD: Vec2;\n /** @internal */ m_ratio: number;\n /** @internal */ m_constant: number;\n /** @internal */ m_impulse: number;\n\n // Solver temp\n /** @internal */ m_lcA: Vec2;\n /** @internal */ m_lcB: Vec2;\n /** @internal */ m_lcC: Vec2;\n /** @internal */ m_lcD: Vec2;\n /** @internal */ m_mA: number;\n /** @internal */ m_mB: number;\n /** @internal */ m_mC: number;\n /** @internal */ m_mD: number;\n /** @internal */ m_iA: number;\n /** @internal */ m_iB: number;\n /** @internal */ m_iC: number;\n /** @internal */ m_iD: number;\n /** @internal */ m_JvAC: Vec2;\n /** @internal */ m_JvBD: Vec2;\n /** @internal */ m_JwA: number;\n /** @internal */ m_JwB: number;\n /** @internal */ m_JwC: number;\n /** @internal */ m_JwD: number;\n /** @internal */ m_mass: number;\n\n constructor(def: GearJointDef);\n constructor(def: GearJointOpt, bodyA: Body, bodyB: Body, joint1: RevoluteJoint | PrismaticJoint, joint2: RevoluteJoint | PrismaticJoint, ratio?: number);\n constructor(def: GearJointDef, bodyA?: Body, bodyB?: Body, joint1?: RevoluteJoint | PrismaticJoint, joint2?: RevoluteJoint | PrismaticJoint, ratio?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof GearJoint)) {\n return new GearJoint(def, bodyA, bodyB, joint1, joint2, ratio);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = GearJoint.TYPE;\n\n if (_ASSERT) console.assert(joint1.m_type === RevoluteJoint.TYPE || joint1.m_type === PrismaticJoint.TYPE);\n if (_ASSERT) console.assert(joint2.m_type === RevoluteJoint.TYPE || joint2.m_type === PrismaticJoint.TYPE);\n\n this.m_joint1 = joint1 ? joint1 : def.joint1;\n this.m_joint2 = joint2 ? joint2 : def.joint2;\n this.m_ratio = Number.isFinite(ratio) ? ratio : def.ratio;\n\n this.m_type1 = this.m_joint1.getType() as \"revolute-joint\" | \"prismatic-joint\";\n this.m_type2 = this.m_joint2.getType() as \"revolute-joint\" | \"prismatic-joint\";\n\n // joint1 connects body A to body C\n // joint2 connects body B to body D\n\n let coordinateA: number;\n let coordinateB: number;\n\n // TODO_ERIN there might be some problem with the joint edges in Joint.\n\n this.m_bodyC = this.m_joint1.getBodyA();\n this.m_bodyA = this.m_joint1.getBodyB();\n\n // Get geometry of joint1\n const xfA = this.m_bodyA.m_xf;\n const aA = this.m_bodyA.m_sweep.a;\n const xfC = this.m_bodyC.m_xf;\n const aC = this.m_bodyC.m_sweep.a;\n\n if (this.m_type1 === RevoluteJoint.TYPE) {\n const revolute = this.m_joint1 as RevoluteJoint;\n this.m_localAnchorC = revolute.m_localAnchorA;\n this.m_localAnchorA = revolute.m_localAnchorB;\n this.m_referenceAngleA = revolute.m_referenceAngle;\n this.m_localAxisC = Vec2.zero();\n\n coordinateA = aA - aC - this.m_referenceAngleA;\n } else {\n const prismatic = this.m_joint1 as PrismaticJoint;\n this.m_localAnchorC = prismatic.m_localAnchorA;\n this.m_localAnchorA = prismatic.m_localAnchorB;\n this.m_referenceAngleA = prismatic.m_referenceAngle;\n this.m_localAxisC = prismatic.m_localXAxisA;\n\n const pC = this.m_localAnchorC;\n const pA = Rot.mulTVec2(xfC.q, Vec2.add(Rot.mulVec2(xfA.q, this.m_localAnchorA), Vec2.sub(xfA.p, xfC.p)));\n coordinateA = Vec2.dot(pA, this.m_localAxisC) - Vec2.dot(pC, this.m_localAxisC);\n }\n\n this.m_bodyD = this.m_joint2.getBodyA();\n this.m_bodyB = this.m_joint2.getBodyB();\n\n // Get geometry of joint2\n const xfB = this.m_bodyB.m_xf;\n const aB = this.m_bodyB.m_sweep.a;\n const xfD = this.m_bodyD.m_xf;\n const aD = this.m_bodyD.m_sweep.a;\n\n if (this.m_type2 === RevoluteJoint.TYPE) {\n const revolute = this.m_joint2 as RevoluteJoint;\n this.m_localAnchorD = revolute.m_localAnchorA;\n this.m_localAnchorB = revolute.m_localAnchorB;\n this.m_referenceAngleB = revolute.m_referenceAngle;\n this.m_localAxisD = Vec2.zero();\n\n coordinateB = aB - aD - this.m_referenceAngleB;\n } else {\n const prismatic = this.m_joint2 as PrismaticJoint;\n this.m_localAnchorD = prismatic.m_localAnchorA;\n this.m_localAnchorB = prismatic.m_localAnchorB;\n this.m_referenceAngleB = prismatic.m_referenceAngle;\n this.m_localAxisD = prismatic.m_localXAxisA;\n\n const pD = this.m_localAnchorD;\n const pB = Rot.mulTVec2(xfD.q, Vec2.add(Rot.mulVec2(xfB.q, this.m_localAnchorB), Vec2.sub(xfB.p, xfD.p)));\n coordinateB = Vec2.dot(pB, this.m_localAxisD) - Vec2.dot(pD, this.m_localAxisD);\n }\n\n this.m_constant = coordinateA + this.m_ratio * coordinateB;\n\n this.m_impulse = 0.0;\n\n // Gear Joint:\n // C0 = (coordinate1 + ratio * coordinate2)_initial\n // C = (coordinate1 + ratio * coordinate2) - C0 = 0\n // J = [J1 ratio * J2]\n // K = J * invM * JT\n // = J1 * invM1 * J1T + ratio * ratio * J2 * invM2 * J2T\n //\n // Revolute:\n // coordinate = rotation\n // Cdot = angularVelocity\n // J = [0 0 1]\n // K = J * invM * JT = invI\n //\n // Prismatic:\n // coordinate = dot(p - pg, ug)\n // Cdot = dot(v + cross(w, r), ug)\n // J = [ug cross(r, ug)]\n // K = J * invM * JT = invMass + invI * cross(r, ug)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n joint1: this.m_joint1,\n joint2: this.m_joint2,\n ratio: this.m_ratio,\n\n // _constant: this.m_constant,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): GearJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.joint1 = restore(Joint, data.joint1, world);\n data.joint2 = restore(Joint, data.joint2, world);\n const joint = new GearJoint(data);\n // if (data._constant) joint.m_constant = data._constant;\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n // todo: implement other fields\n if (Number.isFinite(def.ratio)) {\n this.m_ratio = def.ratio;\n }\n }\n\n /**\n * Get the first joint.\n */\n getJoint1(): Joint {\n return this.m_joint1;\n }\n\n /**\n * Get the second joint.\n */\n getJoint2(): Joint {\n return this.m_joint2;\n }\n\n /**\n * Set the gear ratio.\n */\n setRatio(ratio: number): void {\n if (_ASSERT) console.assert(Number.isFinite(ratio));\n this.m_ratio = ratio;\n }\n\n /**\n * Get the gear ratio.\n */\n getRatio(): number {\n return this.m_ratio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_JvAC).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n const L = this.m_impulse * this.m_JwA;\n return inv_dt * L;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_lcA = this.m_bodyA.m_sweep.localCenter;\n this.m_lcB = this.m_bodyB.m_sweep.localCenter;\n this.m_lcC = this.m_bodyC.m_sweep.localCenter;\n this.m_lcD = this.m_bodyD.m_sweep.localCenter;\n this.m_mA = this.m_bodyA.m_invMass;\n this.m_mB = this.m_bodyB.m_invMass;\n this.m_mC = this.m_bodyC.m_invMass;\n this.m_mD = this.m_bodyD.m_invMass;\n this.m_iA = this.m_bodyA.m_invI;\n this.m_iB = this.m_bodyB.m_invI;\n this.m_iC = this.m_bodyC.m_invI;\n this.m_iD = this.m_bodyD.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const aC = this.m_bodyC.c_position.a;\n const vC = this.m_bodyC.c_velocity.v;\n let wC = this.m_bodyC.c_velocity.w;\n\n const aD = this.m_bodyD.c_position.a;\n const vD = this.m_bodyD.c_velocity.v;\n let wD = this.m_bodyD.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n const qC = Rot.neo(aC);\n const qD = Rot.neo(aD);\n\n this.m_mass = 0.0;\n\n if (this.m_type1 == RevoluteJoint.TYPE) {\n this.m_JvAC = Vec2.zero();\n this.m_JwA = 1.0;\n this.m_JwC = 1.0;\n this.m_mass += this.m_iA + this.m_iC;\n } else {\n const u = Rot.mulVec2(qC, this.m_localAxisC);\n const rC = Rot.mulSub(qC, this.m_localAnchorC, this.m_lcC);\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_lcA);\n this.m_JvAC = u;\n this.m_JwC = Vec2.crossVec2Vec2(rC, u);\n this.m_JwA = Vec2.crossVec2Vec2(rA, u);\n this.m_mass += this.m_mC + this.m_mA + this.m_iC * this.m_JwC * this.m_JwC + this.m_iA * this.m_JwA * this.m_JwA;\n }\n\n if (this.m_type2 == RevoluteJoint.TYPE) {\n this.m_JvBD = Vec2.zero();\n this.m_JwB = this.m_ratio;\n this.m_JwD = this.m_ratio;\n this.m_mass += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD);\n } else {\n const u = Rot.mulVec2(qD, this.m_localAxisD);\n const rD = Rot.mulSub(qD, this.m_localAnchorD, this.m_lcD);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_lcB);\n this.m_JvBD = Vec2.mulNumVec2(this.m_ratio, u);\n this.m_JwD = this.m_ratio * Vec2.crossVec2Vec2(rD, u);\n this.m_JwB = this.m_ratio * Vec2.crossVec2Vec2(rB, u);\n this.m_mass += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * this.m_JwD * this.m_JwD + this.m_iB * this.m_JwB * this.m_JwB;\n }\n\n // Compute effective mass.\n this.m_mass = this.m_mass > 0.0 ? 1.0 / this.m_mass : 0.0;\n\n if (step.warmStarting) {\n vA.addMul(this.m_mA * this.m_impulse, this.m_JvAC);\n wA += this.m_iA * this.m_impulse * this.m_JwA;\n\n vB.addMul(this.m_mB * this.m_impulse, this.m_JvBD);\n wB += this.m_iB * this.m_impulse * this.m_JwB;\n\n vC.subMul(this.m_mC * this.m_impulse, this.m_JvAC);\n wC -= this.m_iC * this.m_impulse * this.m_JwC;\n\n vD.subMul(this.m_mD * this.m_impulse, this.m_JvBD);\n wD -= this.m_iD * this.m_impulse * this.m_JwD;\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n this.m_bodyC.c_velocity.v.setVec2(vC);\n this.m_bodyC.c_velocity.w = wC;\n this.m_bodyD.c_velocity.v.setVec2(vD);\n this.m_bodyD.c_velocity.w = wD;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n const vC = this.m_bodyC.c_velocity.v;\n let wC = this.m_bodyC.c_velocity.w;\n const vD = this.m_bodyD.c_velocity.v;\n let wD = this.m_bodyD.c_velocity.w;\n\n let Cdot = Vec2.dot(this.m_JvAC, vA) - Vec2.dot(this.m_JvAC, vC) + Vec2.dot(this.m_JvBD, vB) - Vec2.dot(this.m_JvBD, vD);\n Cdot += (this.m_JwA * wA - this.m_JwC * wC) + (this.m_JwB * wB - this.m_JwD * wD);\n\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n vA.addMul(this.m_mA * impulse, this.m_JvAC);\n wA += this.m_iA * impulse * this.m_JwA;\n vB.addMul(this.m_mB * impulse, this.m_JvBD);\n wB += this.m_iB * impulse * this.m_JwB;\n vC.subMul(this.m_mC * impulse, this.m_JvAC);\n wC -= this.m_iC * impulse * this.m_JwC;\n vD.subMul(this.m_mD * impulse, this.m_JvBD);\n wD -= this.m_iD * impulse * this.m_JwD;\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n this.m_bodyC.c_velocity.v.setVec2(vC);\n this.m_bodyC.c_velocity.w = wC;\n this.m_bodyD.c_velocity.v.setVec2(vD);\n this.m_bodyD.c_velocity.w = wD;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n const cC = this.m_bodyC.c_position.c;\n let aC = this.m_bodyC.c_position.a;\n const cD = this.m_bodyD.c_position.c;\n let aD = this.m_bodyD.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n const qC = Rot.neo(aC);\n const qD = Rot.neo(aD);\n\n const linearError = 0.0;\n\n let coordinateA: number;\n let coordinateB: number;\n\n let JvAC: Vec2;\n let JvBD: Vec2;\n let JwA: number;\n let JwB: number;\n let JwC: number;\n let JwD: number;\n let mass = 0.0;\n\n if (this.m_type1 == RevoluteJoint.TYPE) {\n JvAC = Vec2.zero();\n JwA = 1.0;\n JwC = 1.0;\n mass += this.m_iA + this.m_iC;\n\n coordinateA = aA - aC - this.m_referenceAngleA;\n } else {\n const u = Rot.mulVec2(qC, this.m_localAxisC);\n const rC = Rot.mulSub(qC, this.m_localAnchorC, this.m_lcC);\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_lcA);\n JvAC = u;\n JwC = Vec2.crossVec2Vec2(rC, u);\n JwA = Vec2.crossVec2Vec2(rA, u);\n mass += this.m_mC + this.m_mA + this.m_iC * JwC * JwC + this.m_iA * JwA * JwA;\n\n const pC = Vec2.sub(this.m_localAnchorC, this.m_lcC);\n const pA = Rot.mulTVec2(qC, Vec2.add(rA, Vec2.sub(cA, cC)));\n coordinateA = Vec2.dot(Vec2.sub(pA, pC), this.m_localAxisC);\n }\n\n if (this.m_type2 == RevoluteJoint.TYPE) {\n JvBD = Vec2.zero();\n JwB = this.m_ratio;\n JwD = this.m_ratio;\n mass += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD);\n\n coordinateB = aB - aD - this.m_referenceAngleB;\n } else {\n const u = Rot.mulVec2(qD, this.m_localAxisD);\n const rD = Rot.mulSub(qD, this.m_localAnchorD, this.m_lcD);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_lcB);\n JvBD = Vec2.mulNumVec2(this.m_ratio, u);\n JwD = this.m_ratio * Vec2.crossVec2Vec2(rD, u);\n JwB = this.m_ratio * Vec2.crossVec2Vec2(rB, u);\n mass += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * JwD * JwD + this.m_iB * JwB * JwB;\n\n const pD = Vec2.sub(this.m_localAnchorD, this.m_lcD);\n const pB = Rot.mulTVec2(qD, Vec2.add(rB, Vec2.sub(cB, cD)));\n coordinateB = Vec2.dot(pB, this.m_localAxisD) - Vec2.dot(pD, this.m_localAxisD);\n }\n\n const C = (coordinateA + this.m_ratio * coordinateB) - this.m_constant;\n\n let impulse = 0.0;\n if (mass > 0.0) {\n impulse = -C / mass;\n }\n\n cA.addMul(this.m_mA * impulse, JvAC);\n aA += this.m_iA * impulse * JwA;\n cB.addMul(this.m_mB * impulse, JvBD);\n aB += this.m_iB * impulse * JwB;\n cC.subMul(this.m_mC * impulse, JvAC);\n aC -= this.m_iC * impulse * JwC;\n cD.subMul(this.m_mD * impulse, JvBD);\n aD -= this.m_iD * impulse * JwD;\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n this.m_bodyC.c_position.c.setVec2(cC);\n this.m_bodyC.c_position.a = aC;\n this.m_bodyD.c_position.c.setVec2(cD);\n this.m_bodyD.c_position.a = aD;\n\n // TODO_ERIN not implemented\n return linearError < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Motor joint definition.\n */\nexport interface MotorJointOpt extends JointOpt {\n /**\n * The bodyB angle minus bodyA angle in radians.\n */\n angularOffset?: number;\n /**\n * The maximum motor force in N.\n */\n maxForce?: number;\n /**\n * The maximum motor torque in N-m.\n */\n maxTorque?: number;\n /**\n * Position correction factor in the range [0,1].\n */\n correctionFactor?: number;\n /**\n * Position of bodyB minus the position of bodyA, in bodyA's frame, in meters.\n */\n linearOffset?: Vec2Value;\n}\n\n/**\n * Motor joint definition.\n */\nexport interface MotorJointDef extends JointDef, MotorJointOpt {\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 1.0,\n maxTorque : 1.0,\n correctionFactor : 0.3\n};\n\ndeclare module \"./MotorJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MotorJoint(def: MotorJointDef): MotorJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MotorJoint(def: MotorJointOpt, bodyA: Body, bodyB: Body): MotorJoint;\n}\n\n/**\n * A motor joint is used to control the relative motion between two bodies. A\n * typical usage is to control the movement of a dynamic body with respect to\n * the ground.\n */\n// @ts-expect-error\nexport class MotorJoint extends Joint {\n static TYPE = \"motor-joint\" as const;\n\n /** @internal */ m_type: \"motor-joint\";\n /** @internal */ m_linearOffset: Vec2;\n /** @internal */ m_angularOffset: number;\n /** @internal */ m_linearImpulse: Vec2;\n /** @internal */ m_angularImpulse: number;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_maxTorque: number;\n /** @internal */ m_correctionFactor: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_linearError: Vec2;\n /** @internal */ m_angularError: number;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_linearMass: Mat22;\n /** @internal */ m_angularMass: number;\n\n constructor(def: MotorJointDef);\n constructor(def: MotorJointOpt, bodyA: Body, bodyB: Body);\n constructor(def: MotorJointDef | MotorJointOpt, bodyA?: Body, bodyB?: Body) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof MotorJoint)) {\n return new MotorJoint(def, bodyA, bodyB);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = MotorJoint.TYPE;\n\n this.m_linearOffset = Vec2.isValid(def.linearOffset) ? Vec2.clone(def.linearOffset) : bodyA.getLocalPoint(bodyB.getPosition());\n this.m_angularOffset = Number.isFinite(def.angularOffset) ? def.angularOffset : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_linearImpulse = Vec2.zero();\n this.m_angularImpulse = 0.0;\n\n this.m_maxForce = def.maxForce;\n this.m_maxTorque = def.maxTorque;\n this.m_correctionFactor = def.correctionFactor;\n\n // Point-to-point constraint\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n //\n // r1 = offset - c1\n // r2 = -c2\n\n // Angle constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n maxForce: this.m_maxForce,\n maxTorque: this.m_maxTorque,\n correctionFactor: this.m_correctionFactor,\n\n linearOffset: this.m_linearOffset,\n angularOffset: this.m_angularOffset,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): MotorJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new MotorJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.angularOffset)) {\n this.m_angularOffset = def.angularOffset;\n }\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.maxTorque)) {\n this.m_maxTorque = def.maxTorque;\n }\n if (Number.isFinite(def.correctionFactor)) {\n this.m_correctionFactor = def.correctionFactor;\n }\n if (Vec2.isValid(def.linearOffset)) {\n this.m_linearOffset.set(def.linearOffset); \n }\n }\n\n /**\n * Set the maximum friction force in N.\n */\n setMaxForce(force: number): void {\n if (_ASSERT) console.assert(Number.isFinite(force) && force >= 0.0);\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum friction force in N.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the maximum friction torque in N*m.\n */\n setMaxTorque(torque: number): void {\n if (_ASSERT) console.assert(Number.isFinite(torque) && torque >= 0.0);\n this.m_maxTorque = torque;\n }\n\n /**\n * Get the maximum friction torque in N*m.\n */\n getMaxTorque(): number {\n return this.m_maxTorque;\n }\n\n /**\n * Set the position correction factor in the range [0,1].\n */\n setCorrectionFactor(factor: number): void {\n if (_ASSERT) console.assert(Number.isFinite(factor) && 0.0 <= factor && factor <= 1.0);\n this.m_correctionFactor = factor;\n }\n\n /**\n * Get the position correction factor in the range [0,1].\n */\n getCorrectionFactor(): number {\n return this.m_correctionFactor;\n }\n\n /**\n * Set/get the target linear offset, in frame A, in meters.\n */\n setLinearOffset(linearOffset: Vec2Value): void {\n if (linearOffset.x != this.m_linearOffset.x || linearOffset.y != this.m_linearOffset.y) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_linearOffset.set(linearOffset);\n }\n }\n\n getLinearOffset(): Vec2 {\n return this.m_linearOffset;\n }\n\n /**\n * Set/get the target angular offset, in radians.\n */\n setAngularOffset(angularOffset: number): void {\n if (angularOffset != this.m_angularOffset) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_angularOffset = angularOffset;\n }\n }\n\n getAngularOffset(): number {\n return this.m_angularOffset;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getPosition();\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getPosition();\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_linearImpulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_angularImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective mass matrix.\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_linearOffset, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.neg(this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Upper 2 by 2 of K for point to point\n const K = new Mat22();\n K.ex.x = mA + mB + iA * this.m_rA.y * this.m_rA.y + iB * this.m_rB.y * this.m_rB.y;\n K.ex.y = -iA * this.m_rA.x * this.m_rA.y - iB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * this.m_rA.x * this.m_rA.x + iB * this.m_rB.x * this.m_rB.x;\n\n this.m_linearMass = K.getInverse();\n\n this.m_angularMass = iA + iB;\n if (this.m_angularMass > 0.0) {\n this.m_angularMass = 1.0 / this.m_angularMass;\n }\n\n this.m_linearError = Vec2.zero();\n this.m_linearError.addCombine(1, cB, 1, this.m_rB);\n this.m_linearError.subCombine(1, cA, 1, this.m_rA);\n\n this.m_angularError = aB - aA - this.m_angularOffset;\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_linearImpulse.mul(step.dtRatio);\n this.m_angularImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_linearImpulse.x, this.m_linearImpulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_angularImpulse);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_angularImpulse);\n\n } else {\n this.m_linearImpulse.setZero();\n this.m_angularImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const h = step.dt;\n const inv_h = step.inv_dt;\n\n // Solve angular friction\n {\n const Cdot = wB - wA + inv_h * this.m_correctionFactor * this.m_angularError;\n let impulse = -this.m_angularMass * Cdot;\n\n const oldImpulse = this.m_angularImpulse;\n const maxImpulse = h * this.m_maxTorque;\n this.m_angularImpulse = clamp(this.m_angularImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_angularImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve linear friction\n {\n const Cdot = Vec2.zero();\n Cdot.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n Cdot.addMul(inv_h * this.m_correctionFactor, this.m_linearError);\n\n let impulse = Vec2.neg(Mat22.mulVec2(this.m_linearMass, Cdot));\n const oldImpulse = Vec2.clone(this.m_linearImpulse);\n this.m_linearImpulse.add(impulse);\n\n const maxImpulse = h * this.m_maxForce;\n\n this.m_linearImpulse.clamp(maxImpulse);\n\n impulse = Vec2.sub(this.m_linearImpulse, oldImpulse);\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Transform } from \"../../common/Transform\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Mouse joint definition. This requires a world target point, tuning\n * parameters, and the time step.\n */\nexport interface MouseJointOpt extends JointOpt {\n /**\n * [maxForce = 0.0] The maximum constraint force that can be exerted to move\n * the candidate body. Usually you will express as some multiple of the\n * weight (multiplier * mass * gravity).\n */\n maxForce?: number;\n /**\n * [frequencyHz = 5.0] The response speed.\n */\n frequencyHz?: number;\n /**\n * [dampingRatio = 0.7] The damping ratio. 0 = no damping, 1 = critical\n * damping.\n */\n dampingRatio?: number;\n}\n\n/**\n * Mouse joint definition. This requires a world target point, tuning\n * parameters, and the time step.\n */\nexport interface MouseJointDef extends JointDef, MouseJointOpt {\n /**\n * The initial world target point. This is assumed to coincide with the body\n * anchor initially.\n */\n target: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 0.0,\n frequencyHz : 5.0,\n dampingRatio : 0.7\n};\n\ndeclare module \"./MouseJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MouseJoint(def: MouseJointDef): MouseJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MouseJoint(def: MouseJointOpt, bodyA: Body, bodyB: Body, target: Vec2Value): MouseJoint;\n}\n\n/**\n * A mouse joint is used to make a point on a body track a specified world\n * point. This a soft constraint with a maximum force. This allows the\n * constraint to stretch and without applying huge forces.\n *\n * You need to call setTarget(target) every time that mouse is \n * moved, to track the new location of the mouse.\n *\n * NOTE: this joint is not documented in the manual because it was developed to\n * be used in the testbed. If you want to learn how to use the mouse joint, look\n * at the testbed.\n */\n// @ts-expect-error\nexport class MouseJoint extends Joint {\n static TYPE = \"mouse-joint\" as const;\n\n /** @internal */ m_type: \"mouse-joint\";\n /** @internal */ m_targetA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_impulse: Vec2;\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n /** @internal */ m_beta: number;\n /** @internal */ m_gamma: number;\n // Solver temp\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: Mat22;\n /** @internal */ m_C: Vec2;\n\n constructor(def: MouseJointDef);\n constructor(def: MouseJointOpt, bodyA: Body, bodyB: Body, target?: Vec2Value);\n constructor(def: MouseJointDef, bodyA?: Body, bodyB?: Body, target?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof MouseJoint)) {\n return new MouseJoint(def, bodyA, bodyB, target);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = MouseJoint.TYPE;\n\n if (_ASSERT) console.assert(Number.isFinite(def.maxForce) && def.maxForce >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.frequencyHz) && def.frequencyHz >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.dampingRatio) && def.dampingRatio >= 0.0);\n\n if (Vec2.isValid(target)) {\n this.m_targetA = Vec2.clone(target);\n } else if (Vec2.isValid(def.target)) {\n this.m_targetA = Vec2.clone(def.target);\n } else {\n this.m_targetA = Vec2.zero();\n }\n\n this.m_localAnchorB = Transform.mulTVec2(bodyB.getTransform(), this.m_targetA);\n\n this.m_maxForce = def.maxForce;\n this.m_impulse = Vec2.zero();\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_beta = 0.0;\n this.m_gamma = 0.0;\n\n // Solver temp\n this.m_rB = Vec2.zero();\n this.m_localCenterB = Vec2.zero();\n this.m_invMassB = 0.0;\n this.m_invIB = 0.0;\n this.m_mass = new Mat22();\n this.m_C = Vec2.zero();\n\n // p = attached point, m = mouse point\n // C = p - m\n // Cdot = v\n // = v + cross(w, r)\n // J = [I r_skew]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n target: this.m_targetA,\n maxForce: this.m_maxForce,\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n _localAnchorB: this.m_localAnchorB,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): MouseJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.target = Vec2.clone(data.target);\n const joint = new MouseJoint(data);\n if (data._localAnchorB) {\n joint.m_localAnchorB = data._localAnchorB;\n }\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * Use this to update the target point.\n */\n setTarget(target: Vec2Value): void {\n if (Vec2.areEqual(target, this.m_targetA)) return;\n this.m_bodyB.setAwake(true);\n this.m_targetA.set(target);\n }\n\n getTarget(): Vec2 {\n return this.m_targetA;\n }\n\n /**\n * Set the maximum force in Newtons.\n */\n setMaxForce(force: number): void {\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum force in Newtons.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the frequency in Hertz.\n */\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n /**\n * Get the frequency in Hertz.\n */\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set the damping ratio (dimensionless).\n */\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n /**\n * Get the damping ratio (dimensionless).\n */\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return Vec2.clone(this.m_targetA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_impulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * 0.0;\n }\n\n /**\n * Shift the origin for any points stored in world coordinates.\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_targetA.sub(newOrigin);\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const position = this.m_bodyB.c_position;\n const velocity = this.m_bodyB.c_velocity;\n\n const cB = position.c;\n const aB = position.a;\n const vB = velocity.v;\n let wB = velocity.w;\n\n const qB = Rot.neo(aB);\n\n const mass = this.m_bodyB.getMass();\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * mass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = mass * (omega * omega);\n\n // magic formulas\n // gamma has units of inverse mass.\n // beta has units of inverse time.\n const h = step.dt;\n if (_ASSERT) console.assert(d + h * k > EPSILON);\n this.m_gamma = h * (d + h * k);\n if (this.m_gamma != 0.0) {\n this.m_gamma = 1.0 / this.m_gamma;\n }\n this.m_beta = h * k * this.m_gamma;\n\n // Compute the effective mass matrix.\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // K = [(1/m1 + 1/m2) * eye(2) - skew(r1) * invI1 * skew(r1) - skew(r2) *\n // invI2 * skew(r2)]\n // = [1/m1+1/m2 0 ] + invI1 * [r1.y*r1.y -r1.x*r1.y] + invI2 * [r1.y*r1.y\n // -r1.x*r1.y]\n // [ 0 1/m1+1/m2] [-r1.x*r1.y r1.x*r1.x] [-r1.x*r1.y r1.x*r1.x]\n const K = new Mat22();\n K.ex.x = this.m_invMassB + this.m_invIB * this.m_rB.y * this.m_rB.y\n + this.m_gamma;\n K.ex.y = -this.m_invIB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = this.m_invMassB + this.m_invIB * this.m_rB.x * this.m_rB.x\n + this.m_gamma;\n\n this.m_mass = K.getInverse();\n\n this.m_C.setVec2(cB);\n this.m_C.addCombine(1, this.m_rB, -1, this.m_targetA);\n this.m_C.mul(this.m_beta);\n\n // Cheat with some damping\n wB *= 0.98;\n\n if (step.warmStarting) {\n this.m_impulse.mul(step.dtRatio);\n vB.addMul(this.m_invMassB, this.m_impulse);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, this.m_impulse);\n\n } else {\n this.m_impulse.setZero();\n }\n\n velocity.v.setVec2(vB);\n velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const velocity = this.m_bodyB.c_velocity;\n const vB = Vec2.clone(velocity.v);\n let wB = velocity.w;\n\n // Cdot = v + cross(w, r)\n\n const Cdot = Vec2.crossNumVec2(wB, this.m_rB);\n Cdot.add(vB);\n\n Cdot.addCombine(1, this.m_C, this.m_gamma, this.m_impulse);\n Cdot.neg();\n\n let impulse = Mat22.mulVec2(this.m_mass, Cdot);\n\n const oldImpulse = Vec2.clone(this.m_impulse);\n this.m_impulse.add(impulse);\n const maxImpulse = step.dt * this.m_maxForce;\n this.m_impulse.clamp(maxImpulse);\n impulse = Vec2.sub(this.m_impulse, oldImpulse);\n\n vB.addMul(this.m_invMassB, impulse);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n\n velocity.v.setVec2(vB);\n velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n\n\n/**\n * Pulley joint definition. This requires two ground anchors, two dynamic body\n * anchor points, and a pulley ratio.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface PulleyJointOpt extends JointOpt {\n}\n\n/**\n * Pulley joint definition. This requires two ground anchors, two dynamic body\n * anchor points, and a pulley ratio.\n */\nexport interface PulleyJointDef extends JointDef, PulleyJointOpt {\n /**\n * The first ground anchor in world coordinates. This point never moves.\n */\n groundAnchorA: Vec2Value;\n /**\n * The second ground anchor in world coordinates. This point never moves.\n */\n groundAnchorB: Vec2Value;\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The reference length for the segment attached to bodyA.\n */\n lengthA: number;\n /**\n * The reference length for the segment attached to bodyB.\n */\n lengthB: number;\n /**\n * The pulley ratio, used to simulate a block-and-tackle.\n */\n ratio: number;\n\n /** @hidden */ anchorA?: Vec2Value;\n /** @hidden */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n collideConnected : true\n};\n\ndeclare module \"./PulleyJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PulleyJoint(def: PulleyJointDef): PulleyJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PulleyJoint(def: PulleyJointOpt, bodyA: Body, bodyB: Body, groundA: Vec2Value, groundB: Vec2Value, anchorA: Vec2Value, anchorB: Vec2Value, ratio: number): PulleyJoint;\n}\n\n/**\n * The pulley joint is connected to two bodies and two fixed ground points. The\n * pulley supports a ratio such that: length1 + ratio * length2 <= constant\n *\n * Yes, the force transmitted is scaled by the ratio.\n *\n * Warning: the pulley joint can get a bit squirrelly by itself. They often work\n * better when combined with prismatic joints. You should also cover the the\n * anchor points with static shapes to prevent one side from going to zero\n * length.\n */\n// @ts-expect-error\nexport class PulleyJoint extends Joint {\n static TYPE = \"pulley-joint\" as const;\n // static MIN_PULLEY_LENGTH: number = 2.0; // TODO where this is used?\n\n /** @internal */ m_type: \"pulley-joint\";\n /** @internal */ m_groundAnchorA: Vec2;\n /** @internal */ m_groundAnchorB: Vec2;\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_lengthA: number;\n /** @internal */ m_lengthB: number;\n /** @internal */ m_ratio: number;\n /** @internal */ m_constant: number;\n /** @internal */ m_impulse: number;\n\n // Solver temp\n /** @internal */ m_uA: Vec2;\n /** @internal */ m_uB: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: number;\n\n constructor(def: PulleyJointDef);\n constructor(def: PulleyJointOpt, bodyA: Body, bodyB: Body, groundA?: Vec2Value, groundB?: Vec2Value, anchorA?: Vec2Value, anchorB?: Vec2Value, ratio?: number);\n constructor(def: PulleyJointDef, bodyA?: Body, bodyB?: Body, groundA?: Vec2Value, groundB?: Vec2Value, anchorA?: Vec2Value, anchorB?: Vec2Value, ratio?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PulleyJoint)) {\n return new PulleyJoint(def, bodyA, bodyB, groundA, groundB, anchorA, anchorB, ratio);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = PulleyJoint.TYPE;\n this.m_groundAnchorA = Vec2.clone(groundA ? groundA : def.groundAnchorA || Vec2.neo(-1.0, 1.0));\n this.m_groundAnchorB = Vec2.clone(groundB ? groundB : def.groundAnchorB || Vec2.neo(1.0, 1.0));\n this.m_localAnchorA = Vec2.clone(anchorA ? bodyA.getLocalPoint(anchorA) : def.localAnchorA || Vec2.neo(-1.0, 0.0));\n this.m_localAnchorB = Vec2.clone(anchorB ? bodyB.getLocalPoint(anchorB) : def.localAnchorB || Vec2.neo(1.0, 0.0));\n this.m_lengthA = Number.isFinite(def.lengthA) ? def.lengthA : Vec2.distance(anchorA, groundA);\n this.m_lengthB = Number.isFinite(def.lengthB) ? def.lengthB : Vec2.distance(anchorB, groundB);\n this.m_ratio = Number.isFinite(ratio) ? ratio : def.ratio;\n\n if (_ASSERT) console.assert(ratio > EPSILON);\n\n this.m_constant = this.m_lengthA + this.m_ratio * this.m_lengthB;\n\n this.m_impulse = 0.0;\n\n // Pulley:\n // length1 = norm(p1 - s1)\n // length2 = norm(p2 - s2)\n // C0 = (length1 + ratio * length2)_initial\n // C = C0 - (length1 + ratio * length2)\n // u1 = (p1 - s1) / norm(p1 - s1)\n // u2 = (p2 - s2) / norm(p2 - s2)\n // Cdot = -dot(u1, v1 + cross(w1, r1)) - ratio * dot(u2, v2 + cross(w2, r2))\n // J = -[u1 cross(r1, u1) ratio * u2 ratio * cross(r2, u2)]\n // K = J * invM * JT\n // = invMass1 + invI1 * cross(r1, u1)^2 + ratio^2 * (invMass2 + invI2 *\n // cross(r2, u2)^2)\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n groundAnchorA: this.m_groundAnchorA,\n groundAnchorB: this.m_groundAnchorB,\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n lengthA: this.m_lengthA,\n lengthB: this.m_lengthB,\n ratio: this.m_ratio,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): PulleyJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new PulleyJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Vec2.isValid(def.groundAnchorA)) {\n this.m_groundAnchorA.set(def.groundAnchorA);\n }\n if (Vec2.isValid(def.groundAnchorB)) {\n this.m_groundAnchorB.set(def.groundAnchorB);\n }\n if (Vec2.isValid(def.localAnchorA)) {\n this.m_localAnchorA.set(def.localAnchorA);\n } else if (Vec2.isValid(def.anchorA)) {\n this.m_localAnchorA.set(this.m_bodyA.getLocalPoint(def.anchorA));\n }\n if (Vec2.isValid(def.localAnchorB)) {\n this.m_localAnchorB.set(def.localAnchorB);\n } else if (Vec2.isValid(def.anchorB)) {\n this.m_localAnchorB.set(this.m_bodyB.getLocalPoint(def.anchorB));\n }\n if (Number.isFinite(def.lengthA)) {\n this.m_lengthA = def.lengthA;\n }\n if (Number.isFinite(def.lengthB)) {\n this.m_lengthB = def.lengthB;\n }\n if (Number.isFinite(def.ratio)) {\n this.m_ratio = def.ratio;\n }\n }\n\n /**\n * Get the first ground anchor.\n */\n getGroundAnchorA(): Vec2 {\n return this.m_groundAnchorA;\n }\n\n /**\n * Get the second ground anchor.\n */\n getGroundAnchorB(): Vec2 {\n return this.m_groundAnchorB;\n }\n\n /**\n * Get the current length of the segment attached to bodyA.\n */\n getLengthA(): number {\n return this.m_lengthA;\n }\n\n /**\n * Get the current length of the segment attached to bodyB.\n */\n getLengthB(): number {\n return this.m_lengthB;\n }\n\n /**\n * Get the pulley ratio.\n */\n getRatio(): number {\n return this.m_ratio;\n }\n\n /**\n * Get the current length of the segment attached to bodyA.\n */\n getCurrentLengthA(): number {\n const p = this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n const s = this.m_groundAnchorA;\n return Vec2.distance(p, s);\n }\n\n /**\n * Get the current length of the segment attached to bodyB.\n */\n getCurrentLengthB(): number {\n const p = this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n const s = this.m_groundAnchorB;\n return Vec2.distance(p, s);\n }\n\n /**\n * Shift the origin for any points stored in world coordinates.\n *\n * @param newOrigin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_groundAnchorA.sub(newOrigin);\n this.m_groundAnchorB.sub(newOrigin);\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_uB).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // Get the pulley axes.\n this.m_uA = Vec2.sub(Vec2.add(cA, this.m_rA), this.m_groundAnchorA);\n this.m_uB = Vec2.sub(Vec2.add(cB, this.m_rB), this.m_groundAnchorB);\n\n const lengthA = this.m_uA.length();\n const lengthB = this.m_uB.length();\n\n if (lengthA > 10.0 * Settings.linearSlop) {\n this.m_uA.mul(1.0 / lengthA);\n } else {\n this.m_uA.setZero();\n }\n\n if (lengthB > 10.0 * Settings.linearSlop) {\n this.m_uB.mul(1.0 / lengthB);\n } else {\n this.m_uB.setZero();\n }\n\n // Compute effective mass.\n const ruA = Vec2.crossVec2Vec2(this.m_rA, this.m_uA);\n const ruB = Vec2.crossVec2Vec2(this.m_rB, this.m_uB);\n\n const mA = this.m_invMassA + this.m_invIA * ruA * ruA;\n const mB = this.m_invMassB + this.m_invIB * ruB * ruB;\n\n this.m_mass = mA + this.m_ratio * this.m_ratio * mB;\n\n if (this.m_mass > 0.0) {\n this.m_mass = 1.0 / this.m_mass;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support variable time steps.\n this.m_impulse *= step.dtRatio;\n\n // Warm starting.\n const PA = Vec2.mulNumVec2(-this.m_impulse, this.m_uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * this.m_impulse, this.m_uB);\n\n vA.addMul(this.m_invMassA, PA);\n wA += this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, PA);\n\n vB.addMul(this.m_invMassB, PB);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, PB);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const vpA = Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA));\n const vpB = Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB));\n\n const Cdot = -Vec2.dot(this.m_uA, vpA) - this.m_ratio * Vec2.dot(this.m_uB, vpB);\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n const PA = Vec2.mulNumVec2(-impulse, this.m_uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * impulse, this.m_uB);\n vA.addMul(this.m_invMassA, PA);\n wA += this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, PA);\n vB.addMul(this.m_invMassB, PB);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, PB);\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // Get the pulley axes.\n const uA = Vec2.sub(Vec2.add(cA, this.m_rA), this.m_groundAnchorA);\n const uB = Vec2.sub(Vec2.add(cB, this.m_rB), this.m_groundAnchorB);\n\n const lengthA = uA.length();\n const lengthB = uB.length();\n\n if (lengthA > 10.0 * Settings.linearSlop) {\n uA.mul(1.0 / lengthA);\n } else {\n uA.setZero();\n }\n\n if (lengthB > 10.0 * Settings.linearSlop) {\n uB.mul(1.0 / lengthB);\n } else {\n uB.setZero();\n }\n\n // Compute effective mass.\n const ruA = Vec2.crossVec2Vec2(rA, uA);\n const ruB = Vec2.crossVec2Vec2(rB, uB);\n\n const mA = this.m_invMassA + this.m_invIA * ruA * ruA;\n const mB = this.m_invMassB + this.m_invIB * ruB * ruB;\n\n let mass = mA + this.m_ratio * this.m_ratio * mB;\n\n if (mass > 0.0) {\n mass = 1.0 / mass;\n }\n\n const C = this.m_constant - lengthA - this.m_ratio * lengthB;\n const linearError = math_abs(C);\n\n const impulse = -mass * C;\n\n const PA = Vec2.mulNumVec2(-impulse, uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * impulse, uB);\n\n cA.addMul(this.m_invMassA, PA);\n aA += this.m_invIA * Vec2.crossVec2Vec2(rA, PA);\n cB.addMul(this.m_invMassB, PB);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, PB);\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return linearError < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_min = Math.min;\n\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3,\n}\n\n/**\n * Rope joint definition. This requires two body anchor points and a maximum\n * lengths. Note: by default the connected objects will not collide. see\n * collideConnected in JointDef.\n */\nexport interface RopeJointOpt extends JointOpt {\n /**\n * The maximum length of the rope.\n * Warning: this must be larger than linearSlop or the joint will have no effect.\n */\n maxLength?: number;\n}\n\n/**\n * Rope joint definition. This requires two body anchor points and a maximum\n * lengths. Note: by default the connected objects will not collide. see\n * collideConnected in JointDef.\n */\nexport interface RopeJointDef extends JointDef, RopeJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxLength : 0.0,\n};\n\ndeclare module \"./RopeJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RopeJoint(def: RopeJointDef): RopeJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RopeJoint(def: RopeJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): RopeJoint;\n}\n\n/**\n * A rope joint enforces a maximum distance between two points on two bodies. It\n * has no other effect.\n *\n * Warning: if you attempt to change the maximum length during the simulation\n * you will get some non-physical behavior.\n *\n * A model that would allow you to dynamically modify the length would have some\n * sponginess, so I chose not to implement it that way. See {@link DistanceJoint} if you\n * want to dynamically control length.\n */\n// @ts-expect-error\nexport class RopeJoint extends Joint {\n static TYPE = \"rope-joint\" as const;\n\n /** @internal */ m_type: \"rope-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n\n /** @internal */ m_maxLength: number;\n\n /** @internal */ m_mass: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_length: number;\n /** @internal */ m_state: number; // TODO enum\n\n // Solver temp\n /** @internal */ m_u: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n\n constructor(def: RopeJointDef);\n constructor(def: RopeJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: RopeJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof RopeJoint)) {\n return new RopeJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = RopeJoint.TYPE;\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.neo(-1.0, 0.0));\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.neo(1.0, 0.0));\n\n this.m_maxLength = def.maxLength;\n\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n this.m_length = 0.0;\n this.m_state = LimitState.inactiveLimit;\n\n // Limit:\n // C = norm(pB - pA) - L\n // u = (pB - pA) / norm(pB - pA)\n // Cdot = dot(u, vB + cross(wB, rB) - vA - cross(wA, rA))\n // J = [-u -cross(rA, u) u cross(rB, u)]\n // K = J * invM * JT\n // = invMassA + invIA * cross(rA, u)^2 + invMassB + invIB * cross(rB, u)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n maxLength: this.m_maxLength,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): RopeJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new RopeJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.maxLength)) {\n this.m_maxLength = def.maxLength;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the maximum length of the rope.\n */\n setMaxLength(length: number): void {\n this.m_maxLength = length;\n }\n\n /**\n * Get the maximum length of the rope.\n */\n getMaxLength(): number {\n return this.m_maxLength;\n }\n\n getLimitState(): number {\n // TODO LimitState\n return this.m_state;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_u).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n this.m_rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n this.m_u = Vec2.zero();\n this.m_u.addCombine(1, cB, 1, this.m_rB);\n this.m_u.subCombine(1, cA, 1, this.m_rA);\n\n this.m_length = this.m_u.length();\n\n const C = this.m_length - this.m_maxLength;\n if (C > 0.0) {\n this.m_state = LimitState.atUpperLimit;\n } else {\n this.m_state = LimitState.inactiveLimit;\n }\n\n if (this.m_length > Settings.linearSlop) {\n this.m_u.mul(1.0 / this.m_length);\n } else {\n this.m_u.setZero();\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n return;\n }\n\n // Compute effective mass.\n const crA = Vec2.crossVec2Vec2(this.m_rA, this.m_u);\n const crB = Vec2.crossVec2Vec2(this.m_rB, this.m_u);\n const invMass = this.m_invMassA + this.m_invIA * crA * crA + this.m_invMassB + this.m_invIB * crB * crB;\n\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n\n if (step.warmStarting) {\n // Scale the impulse to support a variable time step.\n this.m_impulse *= step.dtRatio;\n\n const P = Vec2.mulNumVec2(this.m_impulse, this.m_u);\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Cdot = dot(u, v + cross(w, r))\n const vpA = Vec2.addCrossNumVec2(vA, wA, this.m_rA);\n const vpB = Vec2.addCrossNumVec2(vB, wB, this.m_rB);\n const C = this.m_length - this.m_maxLength;\n let Cdot = Vec2.dot(this.m_u, Vec2.sub(vpB, vpA));\n\n // Predictive constraint.\n if (C < 0.0) {\n Cdot += step.inv_dt * C;\n }\n\n let impulse = -this.m_mass * Cdot;\n const oldImpulse = this.m_impulse;\n this.m_impulse = math_min(0.0, this.m_impulse + impulse);\n impulse = this.m_impulse - oldImpulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_u);\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n const u = Vec2.zero();\n u.addCombine(1, cB, 1, rB);\n u.subCombine(1, cA, 1, rA);\n\n const length = u.normalize();\n let C = length - this.m_maxLength;\n\n C = clamp(C, 0.0, Settings.maxLinearCorrection);\n\n const impulse = -this.m_mass * C;\n const P = Vec2.mulNumVec2(impulse, u);\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * Vec2.crossVec2Vec2(rA, P);\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, P);\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return length - this.m_maxLength < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Weld joint definition. You need to specify local anchor points where they are\n * attached and the relative body angle. The position of the anchor points is\n * important for computing the reaction torque.\n */\nexport interface WeldJointOpt extends JointOpt {\n /**\n * The mass-spring-damper frequency in Hertz. Rotation only. Disable softness\n * with a value of 0.\n */\n frequencyHz?: number;\n /**\n * The damping ratio. 0 = no damping, 1 = critical damping.\n */\n dampingRatio?: number;\n /**\n * The bodyB angle minus bodyA angle in the reference state (radians).\n */\n referenceAngle?: number;\n}\n\n/**\n * Weld joint definition. You need to specify local anchor points where they are\n * attached and the relative body angle. The position of the anchor points is\n * important for computing the reaction torque.\n */\nexport interface WeldJointDef extends JointDef, WeldJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n frequencyHz : 0.0,\n dampingRatio : 0.0,\n};\n\ndeclare module \"./WeldJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WeldJoint(def: WeldJointDef): WeldJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WeldJoint(def: WeldJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): WeldJoint;\n}\n\n/**\n * A weld joint essentially glues two bodies together. A weld joint may distort\n * somewhat because the island constraint solver is approximate.\n */\n// @ts-expect-error\nexport class WeldJoint extends Joint {\n static TYPE = \"weld-joint\" as const;\n\n /** @internal */ m_type: \"weld-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngle: number;\n\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n\n /** @internal */ m_impulse: Vec3;\n\n /** @internal */ m_bias: number;\n /** @internal */ m_gamma: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: Mat33;\n\n constructor(def: WeldJointDef);\n constructor(def: WeldJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: WeldJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof WeldJoint)) {\n return new WeldJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = WeldJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n this.m_referenceAngle = Number.isFinite(def.referenceAngle) ? def.referenceAngle : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_impulse = new Vec3();\n\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n\n // Solver temp\n // todo: do we need to initialize?\n // this.m_rA;\n // this.m_rB;\n // this.m_localCenterA;\n // this.m_localCenterB;\n // this.m_invMassA;\n // this.m_invMassB;\n // this.m_invIA;\n // this.m_invIB;\n this.m_mass = new Mat33();\n\n // Point-to-point constraint\n // C = p2 - p1\n // Cdot = v2 - v1\n // / = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Angle constraint\n // C = angle2 - angle1 - referenceAngle\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): WeldJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new WeldJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Set frequency in Hz.\n */\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n /**\n * Get frequency in Hz.\n */\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set damping ratio.\n */\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n /**\n * Get damping ratio.\n */\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.neo(this.m_impulse.x, this.m_impulse.y).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.z;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat33();\n K.ex.x = mA + mB + this.m_rA.y * this.m_rA.y * iA + this.m_rB.y * this.m_rB.y\n * iB;\n K.ey.x = -this.m_rA.y * this.m_rA.x * iA - this.m_rB.y * this.m_rB.x * iB;\n K.ez.x = -this.m_rA.y * iA - this.m_rB.y * iB;\n K.ex.y = K.ey.x;\n K.ey.y = mA + mB + this.m_rA.x * this.m_rA.x * iA + this.m_rB.x * this.m_rB.x\n * iB;\n K.ez.y = this.m_rA.x * iA + this.m_rB.x * iB;\n K.ex.z = K.ez.x;\n K.ey.z = K.ez.y;\n K.ez.z = iA + iB;\n\n if (this.m_frequencyHz > 0.0) {\n K.getInverse22(this.m_mass);\n\n let invM = iA + iB;\n const m = invM > 0.0 ? 1.0 / invM : 0.0;\n\n const C = aB - aA - this.m_referenceAngle;\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * m * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = m * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (d + h * k);\n this.m_gamma = this.m_gamma != 0.0 ? 1.0 / this.m_gamma : 0.0;\n this.m_bias = C * h * k * this.m_gamma;\n\n invM += this.m_gamma;\n this.m_mass.ez.z = invM != 0.0 ? 1.0 / invM : 0.0;\n } else if (K.ez.z == 0.0) {\n K.getInverse22(this.m_mass);\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n } else {\n K.getSymInverse33(this.m_mass);\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_impulse.mul(step.dtRatio);\n\n const P = Vec2.neo(this.m_impulse.x, this.m_impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_impulse.z);\n\n } else {\n this.m_impulse.setZero();\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n if (this.m_frequencyHz > 0.0) {\n const Cdot2 = wB - wA;\n\n const impulse2 = -this.m_mass.ez.z * (Cdot2 + this.m_bias + this.m_gamma * this.m_impulse.z);\n this.m_impulse.z += impulse2;\n\n wA -= iA * impulse2;\n wB += iB * impulse2;\n\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n\n const impulse1 = Vec2.neg(Mat33.mulVec2(this.m_mass, Cdot1));\n this.m_impulse.x += impulse1.x;\n this.m_impulse.y += impulse1.y;\n\n const P = Vec2.clone(impulse1);\n\n vA.subMul(mA, P);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(mB, P);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, P);\n } else {\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const Cdot2 = wB - wA;\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const impulse = Vec3.neg(Mat33.mulVec3(this.m_mass, Cdot));\n this.m_impulse.add(impulse);\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + impulse.z);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n let positionError: number;\n let angularError: number;\n\n const K = new Mat33();\n K.ex.x = mA + mB + rA.y * rA.y * iA + rB.y * rB.y * iB;\n K.ey.x = -rA.y * rA.x * iA - rB.y * rB.x * iB;\n K.ez.x = -rA.y * iA - rB.y * iB;\n K.ex.y = K.ey.x;\n K.ey.y = mA + mB + rA.x * rA.x * iA + rB.x * rB.x * iB;\n K.ez.y = rA.x * iA + rB.x * iB;\n K.ex.z = K.ez.x;\n K.ey.z = K.ez.y;\n K.ez.z = iA + iB;\n\n if (this.m_frequencyHz > 0.0) {\n const C1 = Vec2.zero();\n C1.addCombine(1, cB, 1, rB);\n C1.subCombine(1, cA, 1, rA);\n\n positionError = C1.length();\n angularError = 0.0;\n\n const P = Vec2.neg(K.solve22(C1));\n\n cA.subMul(mA, P);\n aA -= iA * Vec2.crossVec2Vec2(rA, P);\n\n cB.addMul(mB, P);\n aB += iB * Vec2.crossVec2Vec2(rB, P);\n } else {\n const C1 = Vec2.zero();\n C1.addCombine(1, cB, 1, rB);\n C1.subCombine(1, cA, 1, rA);\n\n const C2 = aB - aA - this.m_referenceAngle;\n\n positionError = C1.length();\n angularError = math_abs(C2);\n\n const C = new Vec3(C1.x, C1.y, C2);\n\n let impulse = new Vec3();\n if (K.ez.z > 0.0) {\n impulse = Vec3.neg(K.solve33(C));\n } else {\n const impulse2 = Vec2.neg(K.solve22(C1));\n impulse.set(impulse2.x, impulse2.y, 0.0);\n }\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n cA.subMul(mA, P);\n aA -= iA * (Vec2.crossVec2Vec2(rA, P) + impulse.z);\n\n cB.addMul(mB, P);\n aB += iB * (Vec2.crossVec2Vec2(rB, P) + impulse.z);\n }\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return positionError <= Settings.linearSlop && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Wheel joint definition. This requires defining a line of motion using an axis\n * and an anchor point. The definition uses local anchor points and a local axis\n * so that the initial configuration can violate the constraint slightly. The\n * joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface WheelJointOpt extends JointOpt {\n /**\n * Enable/disable the joint motor.\n */\n enableMotor?: boolean;\n /**\n * The maximum motor torque, usually in N-m.\n */\n maxMotorTorque?: number;\n /**\n * The desired motor speed in radians per second.\n */\n motorSpeed?: number;\n /**\n * Suspension frequency, zero indicates no suspension.\n */\n frequencyHz?: number;\n /**\n * Suspension damping ratio, one indicates critical damping.\n */\n dampingRatio?: number;\n}\n\n/**\n * Wheel joint definition. This requires defining a line of motion using an axis\n * and an anchor point. The definition uses local anchor points and a local axis\n * so that the initial configuration can violate the constraint slightly. The\n * joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface WheelJointDef extends JointDef, WheelJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The local translation axis in bodyA.\n */\n localAxisA: Vec2Value;\n\n /** @internal renamed to localAxisA */\n localAxis?: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n enableMotor : false,\n maxMotorTorque : 0.0,\n motorSpeed : 0.0,\n frequencyHz : 2.0,\n dampingRatio : 0.7,\n};\n\ndeclare module \"./WheelJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WheelJoint(def: WheelJointDef): WheelJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WheelJoint(def: WheelJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value, axis: Vec2Value): WheelJoint;\n}\n\n/**\n * A wheel joint. This joint provides two degrees of freedom: translation along\n * an axis fixed in bodyA and rotation in the plane. In other words, it is a\n * point to line constraint with a rotational motor and a linear spring/damper.\n * This joint is designed for vehicle suspensions.\n */\n// @ts-expect-error\nexport class WheelJoint extends Joint {\n static TYPE = \"wheel-joint\" as const;\n\n /** @internal */ m_type: \"wheel-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_localXAxisA: Vec2;\n /** @internal */ m_localYAxisA: Vec2;\n\n /** @internal */ m_mass: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_motorMass: number;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_springMass: number;\n /** @internal */ m_springImpulse: number;\n\n /** @internal */ m_maxMotorTorque: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableMotor: boolean;\n\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n\n /** @internal */ m_bias: number;\n /** @internal */ m_gamma: number;\n\n // Solver temp\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n\n /** @internal */ m_ax: Vec2;\n /** @internal */ m_ay: Vec2;\n /** @internal */ m_sAx: number;\n /** @internal */ m_sBx: number;\n /** @internal */ m_sAy: number;\n /** @internal */ m_sBy: number;\n\n constructor(def: WheelJointDef);\n constructor(def: WheelJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value, axis?: Vec2Value);\n constructor(def: WheelJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value, axis?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof WheelJoint)) {\n return new WheelJoint(def, bodyA, bodyB, anchor, axis);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_ax = Vec2.zero();\n this.m_ay = Vec2.zero();\n\n this.m_type = WheelJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n\n if (Vec2.isValid(axis)) {\n this.m_localXAxisA = bodyA.getLocalVector(axis);\n } else if (Vec2.isValid(def.localAxisA)) {\n this.m_localXAxisA = Vec2.clone(def.localAxisA);\n } else if (Vec2.isValid(def.localAxis)) {\n // localAxis is renamed to localAxisA, this is for backward compatibility\n this.m_localXAxisA = Vec2.clone(def.localAxis);\n } else {\n this.m_localXAxisA = Vec2.neo(1.0, 0.0);\n }\n\n this.m_localYAxisA = Vec2.crossNumVec2(1.0, this.m_localXAxisA);\n\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n this.m_springMass = 0.0;\n this.m_springImpulse = 0.0;\n\n this.m_maxMotorTorque = def.maxMotorTorque;\n this.m_motorSpeed = def.motorSpeed;\n this.m_enableMotor = def.enableMotor;\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n\n // Linear constraint (point-to-line)\n // d = pB - pA = xB + rB - xA - rA\n // C = dot(ay, d)\n // Cdot = dot(d, cross(wA, ay)) + dot(ay, vB + cross(wB, rB) - vA - cross(wA,\n // rA))\n // = -dot(ay, vA) - dot(cross(d + rA, ay), wA) + dot(ay, vB) + dot(cross(rB,\n // ay), vB)\n // J = [-ay, -cross(d + rA, ay), ay, cross(rB, ay)]\n\n // Spring linear constraint\n // C = dot(ax, d)\n // Cdot = = -dot(ax, vA) - dot(cross(d + rA, ax), wA) + dot(ax, vB) +\n // dot(cross(rB, ax), vB)\n // J = [-ax -cross(d+rA, ax) ax cross(rB, ax)]\n\n // Motor rotational constraint\n // Cdot = wB - wA\n // J = [0 0 -1 0 0 1]\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n enableMotor: this.m_enableMotor,\n maxMotorTorque: this.m_maxMotorTorque,\n motorSpeed: this.m_motorSpeed,\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n localAxisA: this.m_localXAxisA,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): WheelJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new WheelJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (def.localAxisA) {\n this.m_localXAxisA.setVec2(def.localAxisA);\n this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1.0, def.localAxisA));\n }\n if (def.enableMotor !== undefined) {\n this.m_enableMotor = def.enableMotor;\n }\n if (Number.isFinite(def.maxMotorTorque)) {\n this.m_maxMotorTorque = def.maxMotorTorque;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * The local joint axis relative to bodyA.\n */\n getLocalAxisA(): Vec2 {\n return this.m_localXAxisA;\n }\n\n /**\n * Get the current joint translation, usually in meters.\n */\n getJointTranslation(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n\n const pA = bA.getWorldPoint(this.m_localAnchorA);\n const pB = bB.getWorldPoint(this.m_localAnchorB);\n const d = Vec2.sub(pB, pA);\n const axis = bA.getWorldVector(this.m_localXAxisA);\n\n const translation = Vec2.dot(d, axis);\n return translation;\n }\n\n /**\n * Get the current joint translation speed, usually in meters per second.\n */\n getJointSpeed(): number {\n const wA = this.m_bodyA.m_angularVelocity;\n const wB = this.m_bodyB.m_angularVelocity;\n return wB - wA;\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Set the motor speed, usually in radians per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Get the motor speed, usually in radians per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Set/Get the maximum motor force, usually in N-m.\n */\n setMaxMotorTorque(torque: number): void {\n if (torque == this.m_maxMotorTorque) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorTorque = torque;\n }\n\n getMaxMotorTorque(): number {\n return this.m_maxMotorTorque;\n }\n\n /**\n * Get the current motor torque given the inverse time step, usually in N-m.\n */\n getMotorTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Set/Get the spring frequency in hertz. Setting the frequency to zero disables\n * the spring.\n */\n setSpringFrequencyHz(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n getSpringFrequencyHz(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set/Get the spring damping ratio\n */\n setSpringDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n getSpringDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.combine(this.m_impulse, this.m_ay, this.m_springImpulse, this.m_ax).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective masses.\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n // Point to line constraint\n {\n this.m_ay = Rot.mulVec2(qA, this.m_localYAxisA);\n this.m_sAy = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_ay);\n this.m_sBy = Vec2.crossVec2Vec2(rB, this.m_ay);\n\n this.m_mass = mA + mB + iA * this.m_sAy * this.m_sAy + iB * this.m_sBy\n * this.m_sBy;\n\n if (this.m_mass > 0.0) {\n this.m_mass = 1.0 / this.m_mass;\n }\n }\n\n // Spring constraint\n this.m_springMass = 0.0;\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n if (this.m_frequencyHz > 0.0) {\n this.m_ax = Rot.mulVec2(qA, this.m_localXAxisA);\n this.m_sAx = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_ax);\n this.m_sBx = Vec2.crossVec2Vec2(rB, this.m_ax);\n\n const invMass = mA + mB + iA * this.m_sAx * this.m_sAx + iB * this.m_sBx\n * this.m_sBx;\n\n if (invMass > 0.0) {\n this.m_springMass = 1.0 / invMass;\n\n const C = Vec2.dot(d, this.m_ax);\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const damp = 2.0 * this.m_springMass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = this.m_springMass * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (damp + h * k);\n if (this.m_gamma > 0.0) {\n this.m_gamma = 1.0 / this.m_gamma;\n }\n\n this.m_bias = C * h * k * this.m_gamma;\n\n this.m_springMass = invMass + this.m_gamma;\n if (this.m_springMass > 0.0) {\n this.m_springMass = 1.0 / this.m_springMass;\n }\n }\n } else {\n this.m_springImpulse = 0.0;\n }\n\n // Rotational motor\n if (this.m_enableMotor) {\n this.m_motorMass = iA + iB;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n } else {\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n }\n\n if (step.warmStarting) {\n // Account for variable time step.\n this.m_impulse *= step.dtRatio;\n this.m_springImpulse *= step.dtRatio;\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.combine(this.m_impulse, this.m_ay, this.m_springImpulse, this.m_ax);\n const LA = this.m_impulse * this.m_sAy + this.m_springImpulse * this.m_sAx + this.m_motorImpulse;\n const LB = this.m_impulse * this.m_sBy + this.m_springImpulse * this.m_sBx + this.m_motorImpulse;\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * LA;\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * LB;\n\n } else {\n this.m_impulse = 0.0;\n this.m_springImpulse = 0.0;\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Solve spring constraint\n {\n const Cdot = Vec2.dot(this.m_ax, vB) - Vec2.dot(this.m_ax, vA) + this.m_sBx * wB - this.m_sAx * wA;\n const impulse = -this.m_springMass * (Cdot + this.m_bias + this.m_gamma * this.m_springImpulse);\n this.m_springImpulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_ax);\n const LA = impulse * this.m_sAx;\n const LB = impulse * this.m_sBx;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n // Solve rotational motor constraint\n {\n const Cdot = wB - wA - this.m_motorSpeed;\n let impulse = -this.m_motorMass * Cdot;\n\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorTorque;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve point to line constraint\n {\n const Cdot = Vec2.dot(this.m_ay, vB) - Vec2.dot(this.m_ay, vA) + this.m_sBy * wB - this.m_sAy * wA;\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_ay);\n const LA = impulse * this.m_sAy;\n const LB = impulse * this.m_sBy;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n const ay = Rot.mulVec2(qA, this.m_localYAxisA);\n\n const sAy = Vec2.crossVec2Vec2(Vec2.add(d, rA), ay);\n const sBy = Vec2.crossVec2Vec2(rB, ay);\n\n const C = Vec2.dot(d, ay);\n\n const k = this.m_invMassA + this.m_invMassB + this.m_invIA * this.m_sAy * this.m_sAy + this.m_invIB * this.m_sBy * this.m_sBy;\n\n const impulse = k != 0.0 ? -C / k : 0.0;\n\n const P = Vec2.mulNumVec2(impulse, ay);\n const LA = impulse * sAy;\n const LB = impulse * sBy;\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * LA;\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * LB;\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return math_abs(C) <= Settings.linearSlop;\n }\n\n}\n","import { World } from \"../dynamics/World\";\nimport { Body } from \"../dynamics/Body\";\nimport { Joint } from \"../dynamics/Joint\";\nimport { Fixture } from \"../dynamics/Fixture\";\nimport { Shape } from \"../collision/Shape\";\nimport { Vec2 } from \"../common/Vec2\";\nimport { Vec3 } from \"../common/Vec3\";\nimport { ChainShape } from \"../collision/shape/ChainShape\";\n// import { BoxShape } from \"../collision/shape/BoxShape\";\nimport { EdgeShape } from \"../collision/shape/EdgeShape\";\nimport { PolygonShape } from \"../collision/shape/PolygonShape\";\nimport { CircleShape } from \"../collision/shape/CircleShape\";\nimport { DistanceJoint } from \"../dynamics/joint/DistanceJoint\";\nimport { FrictionJoint } from \"../dynamics/joint/FrictionJoint\";\nimport { GearJoint } from \"../dynamics/joint/GearJoint\";\nimport { MotorJoint } from \"../dynamics/joint/MotorJoint\";\nimport { MouseJoint } from \"../dynamics/joint/MouseJoint\";\nimport { PrismaticJoint } from \"../dynamics/joint/PrismaticJoint\";\nimport { PulleyJoint } from \"../dynamics/joint/PulleyJoint\";\nimport { RevoluteJoint } from \"../dynamics/joint/RevoluteJoint\";\nimport { RopeJoint } from \"../dynamics/joint/RopeJoint\";\nimport { WeldJoint } from \"../dynamics/joint/WeldJoint\";\nimport { WheelJoint } from \"../dynamics/joint/WheelJoint\";\n\nlet SID = 0;\n\n// Classes to be serialized as reference objects\nconst SERIALIZE_REF_TYPES = {\n \"World\": World,\n \"Body\": Body,\n \"Joint\": Joint,\n \"Fixture\": Fixture,\n \"Shape\": Shape,\n};\n\n// For deserializing reference objects by reference type\nconst DESERIALIZE_BY_REF_TYPE = {\n \"Vec2\": Vec2,\n \"Vec3\": Vec3,\n \"World\": World,\n \"Body\": Body,\n \"Joint\": Joint,\n \"Fixture\": Fixture,\n \"Shape\": Shape,\n};\n\n// For deserializing data objects by type field\nconst DESERIALIZE_BY_TYPE_FIELD = {\n [Body.STATIC]: Body,\n [Body.DYNAMIC]: Body,\n [Body.KINEMATIC]: Body,\n [ChainShape.TYPE]: ChainShape,\n // [BoxShape.TYPE]: BoxShape,\n [PolygonShape.TYPE]: PolygonShape,\n [EdgeShape.TYPE]: EdgeShape,\n [CircleShape.TYPE]: CircleShape,\n [DistanceJoint.TYPE]: DistanceJoint,\n [FrictionJoint.TYPE]: FrictionJoint,\n [GearJoint.TYPE]: GearJoint,\n [MotorJoint.TYPE]: MotorJoint,\n [MouseJoint.TYPE]: MouseJoint,\n [PrismaticJoint.TYPE]: PrismaticJoint,\n [PulleyJoint.TYPE]: PulleyJoint,\n [RevoluteJoint.TYPE]: RevoluteJoint,\n [RopeJoint.TYPE]: RopeJoint,\n [WeldJoint.TYPE]: WeldJoint,\n [WheelJoint.TYPE]: WheelJoint,\n};\n\n// dummy types\ntype DataType = any;\ntype ObjectType = any;\ntype ClassName = any;\n\ntype SerializedType = object[];\n\ntype RefType = {\n refIndex: number,\n refType: string,\n};\n\ntype SerializerOptions = {\n rootClass: ClassName,\n preSerialize?: (obj: ObjectType) => DataType,\n postSerialize?: (data: DataType, obj: any) => DataType,\n preDeserialize?: (data: DataType) => DataType,\n postDeserialize?: (obj: ObjectType, data: DataType) => ObjectType,\n};\n\nconst DEFAULT_OPTIONS: SerializerOptions = {\n rootClass: World,\n preSerialize: function(obj) { return obj; },\n postSerialize: function(data, obj) { return data; },\n preDeserialize: function(data: DataType) { return data; },\n postDeserialize: function(obj, data) { return obj; },\n};\n\ntype DeserializeChildCallback = (classHint: any, obj: any, context: any) => any;\ntype ClassDeserializerMethod = (data: any, context: any, deserialize: DeserializeChildCallback) => any;\n\nexport class Serializer {\n private options: SerializerOptions;\n constructor(options: SerializerOptions) {\n this.options = {\n ...DEFAULT_OPTIONS,\n ...options,\n };\n }\n\n toJson = (root: T): SerializedType => {\n const preSerialize = this.options.preSerialize;\n const postSerialize = this.options.postSerialize;\n const json = [];\n\n // Breadth-first ref serialization queue\n const refQueue = [root];\n\n const refMemoById: Record = {};\n\n function addToRefQueue(value: any, typeName: string) {\n value.__sid = value.__sid || ++SID;\n if (!refMemoById[value.__sid]) {\n refQueue.push(value);\n const index = json.length + refQueue.length;\n const ref = {\n refIndex: index,\n refType: typeName\n };\n refMemoById[value.__sid] = ref;\n }\n return refMemoById[value.__sid];\n }\n\n function serializeWithHooks(obj: ObjectType) {\n obj = preSerialize(obj);\n let data = obj._serialize();\n data = postSerialize(data, obj);\n return data;\n }\n\n // traverse the object graph\n // ref objects are pushed into the queue\n // other objects are serialize in-place \n function traverse(value: any, noRefType = false) {\n if (typeof value !== \"object\" || value === null) {\n return value;\n }\n // object with _serialize function\n if (typeof value._serialize === \"function\") {\n if (!noRefType) {\n for (const typeName in SERIALIZE_REF_TYPES) {\n if (value instanceof SERIALIZE_REF_TYPES[typeName]) {\n return addToRefQueue(value, typeName);\n }\n }\n }\n // object with _serialize function\n value = serializeWithHooks(value);\n }\n // recursive for arrays any objects\n if (Array.isArray(value)) {\n const newValue = [];\n for (let key = 0; key < value.length; key++) {\n newValue[key] = traverse(value[key]);\n }\n value = newValue;\n\n } else {\n const newValue = {};\n for (const key in value) {\n if (value.hasOwnProperty(key)) {\n newValue[key] = traverse(value[key]);\n }\n }\n value = newValue;\n }\n return value;\n }\n\n while (refQueue.length) {\n const obj = refQueue.shift();\n const str = traverse(obj, true);\n json.push(str);\n }\n\n return json;\n };\n\n fromJson = (json: SerializedType): T => {\n const preDeserialize = this.options.preDeserialize;\n const postDeserialize = this.options.postDeserialize;\n const rootClass = this.options.rootClass;\n\n const deserializedRefMemoByIndex: Record = {};\n\n function deserializeWithHooks(classHint: ClassName, data: DataType, context: any): ObjectType {\n if (!classHint || !classHint._deserialize) {\n classHint = DESERIALIZE_BY_TYPE_FIELD[data.type];\n }\n const deserializer = classHint && classHint._deserialize;\n if (!deserializer) {\n return;\n }\n data = preDeserialize(data);\n const classDeserializeFn = classHint._deserialize as ClassDeserializerMethod;\n let obj = classDeserializeFn(data, context, deserializeChild);\n obj = postDeserialize(obj, data);\n return obj;\n }\n\n /**\n * Recursive callback function to deserialize a child data object or reference object.\n * \n * @param classHint suggested class to deserialize obj to\n * @param dataOrRef data or reference object\n * @param context for example world when deserializing bodies and joints\n */\n function deserializeChild(classHint: ClassName, dataOrRef: DataType | RefType, context: any) {\n const isRefObject = dataOrRef.refIndex && dataOrRef.refType;\n if (!isRefObject) {\n return deserializeWithHooks(classHint, dataOrRef, context); \n }\n const ref = dataOrRef as RefType;\n if (DESERIALIZE_BY_REF_TYPE[ref.refType]) {\n classHint = DESERIALIZE_BY_REF_TYPE[ref.refType];\n }\n const refIndex = ref.refIndex;\n if (!deserializedRefMemoByIndex[refIndex]) {\n const data = json[refIndex];\n const obj = deserializeWithHooks(classHint, data, context);\n deserializedRefMemoByIndex[refIndex] = obj;\n }\n return deserializedRefMemoByIndex[refIndex];\n }\n\n const root = deserializeWithHooks(rootClass, json[0], null);\n\n return root;\n };\n\n static toJson: (root: World) => SerializedType;\n static fromJson: (json: SerializedType) => World;\n}\n\nconst worldSerializer = new Serializer({\n rootClass: World,\n});\n\nSerializer.fromJson = worldSerializer.fromJson;\nSerializer.toJson = worldSerializer.toJson;\n","import type { AABBValue } from \"../collision/AABB\";\nimport type { World } from \"../dynamics/World\";\nimport type { Joint } from \"../dynamics/Joint\";\nimport type { Fixture } from \"../dynamics/Fixture\";\nimport type { Body } from \"../dynamics/Body\";\n\nexport interface Style {\n stroke?: string;\n fill?: string;\n lineWidth?: number;\n}\n\ntype KEY = \"0\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" |\n \"8\" | \"9\" | \"A\" | \"B\" | \"C\" | \"D\" | \"E\" | \"F\" | \"G\" |\n \"H\" | \"I\" | \"J\" | \"K\" | \"L\" | \"M\" | \"N\" | \"O\" | \"P\" |\n \"Q\" | \"R\" | \"S\" | \"T\" | \"U\" | \"V\" | \"W\" | \"X\" | \"Y\" |\n \"Z\" | \"right\" | \"left\" | \"up\" | \"down\" | \"fire\";\n\nexport type ActiveKeys = { [key in KEY]?: boolean };\n\ntype TestbedMountOptions = { [key: string]: any };\n\nexport abstract class Testbed {\n /**\n * Mounts testbed. Call start with a world to start simulation and rendering.\n */\n static mount(options?: TestbedMountOptions): Testbed {\n throw new Error(\"Not implemented\");\n }\n\n /**\n * Mounts testbed if needed, then starts simulation and rendering.\n * \n * If you need to customize testbed before starting, first run `const testbed = Testbed.mount()` and then `testbed.start()`.\n */\n static start(world: World): Testbed {\n const testbed = Testbed.mount();\n testbed.start(world);\n return testbed;\n }\n\n /** World viewbox width. */\n width: number = 80;\n\n /** World viewbox height. */\n height: number = 60;\n\n /** World viewbox center vertical offset. */\n x: number = 0;\n\n /** World viewbox center horizontal offset. */\n y: number = -10;\n\n /** @hidden */\n scaleY: number = -1;\n\n /** World simulation step frequency */\n hz: number = 60;\n\n /** World simulation speed, default is 1 */\n speed: number = 1;\n\n background: string = \"#222222\";\n\n mouseForce?: number;\n activeKeys: ActiveKeys = {};\n\n /** callback, to be implemented by user */\n step = (dt: number, t: number): void => {\n return;\n };\n\n /** callback, to be implemented by user */\n keydown = (keyCode: number, label: string): void => {\n return;\n };\n\n /** callback, to be implemented by user */\n keyup = (keyCode: number, label: string): void => {\n return;\n };\n\n abstract status(name: string, value: any): void;\n abstract status(value: object | string): void;\n\n abstract info(text: string): void;\n\n color(r: number, g: number, b: number): string {\n r = r * 256 | 0;\n g = g * 256 | 0;\n b = b * 256 | 0;\n return \"rgb(\" + r + \", \" + g + \", \" + b + \")\";\n }\n\n abstract drawPoint(p: {x: number, y: number}, r: any, color: string): void;\n abstract drawCircle(p: {x: number, y: number}, r: number, color: string): void;\n abstract drawEdge(a: {x: number, y: number}, b: {x: number, y: number}, color: string): void;\n abstract drawSegment(a: {x: number, y: number}, b: {x: number, y: number}, color: string): void;\n abstract drawPolygon(points: Array<{x: number, y: number}>, color: string): void;\n abstract drawAABB(aabb: AABBValue, color: string): void;\n\n abstract start(world: World): void;\n\n abstract findOne(query: string): (Body | Joint | Fixture | null);\n abstract findAll(query: string): (Body | Joint | Fixture)[];\n}\n\ntype TestbedFactoryOptions = string | TestbedMountOptions;\n\n/** @deprecated */\ntype TestbedCallback = (testbed: Testbed) => (World | undefined);\n\n/** @deprecated */\nexport function testbed(callback: TestbedCallback): void;\n/** @deprecated */\nexport function testbed(options: TestbedFactoryOptions, callback: TestbedCallback): void;\n/** @internal */\nexport function testbed(a?: any, b?: any) {\n let callback: TestbedCallback | undefined;\n let options;\n if (typeof a === \"function\") {\n callback = a;\n options = b;\n } else if (typeof b === \"function\") {\n callback = b;\n options = a;\n } else {\n options = a ?? b;\n }\n const testbed = Testbed.mount(options);\n if (callback) {\n // this is for backwards compatibility\n const world = callback(testbed) || (testbed as any).world;\n testbed.start(world);\n } else {\n return testbed;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { Vec2Value } from \"../../common/Vec2\";\nimport { PolygonShape } from \"./PolygonShape\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\ndeclare module \"./BoxShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function BoxShape(halfWidth: number, halfHeight: number, center?: Vec2Value, angle?: number): BoxShape;\n}\n\n/**\n * A rectangle polygon which extend PolygonShape.\n */\n// @ts-expect-error\nexport class BoxShape extends PolygonShape {\n // note that box is serialized/deserialized as polygon\n static TYPE = \"polygon\" as const;\n\n /**\n * \n * @param halfWidth \n * @param halfHeight \n * @param center coordinate of the center of the box relative to the body\n * @param angle angle of the box relative to the body\n */\n constructor(halfWidth: number, halfHeight: number, center?: Vec2Value, angle?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof BoxShape)) {\n return new BoxShape(halfWidth, halfHeight, center, angle);\n }\n\n super();\n\n this._setAsBox(halfWidth, halfHeight, center, angle);\n }\n}\n\nexport const Box = BoxShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { CircleShape } from \"./CircleShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(CircleShape.TYPE, CircleShape.TYPE, CircleCircleContact);\n\n/** @internal */ function CircleCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == CircleShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n CollideCircles(manifold, fixtureA.getShape() as CircleShape, xfA, fixtureB.getShape() as CircleShape, xfB);\n}\n\n/** @internal */ const pA = matrix.vec2(0, 0);\n/** @internal */ const pB = matrix.vec2(0, 0);\n\nexport const CollideCircles = function (manifold: Manifold, circleA: CircleShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n matrix.transformVec2(pA, xfA, circleA.m_p);\n matrix.transformVec2(pB, xfB, circleB.m_p);\n\n const distSqr = matrix.distSqrVec2(pB, pA);\n const rA = circleA.m_radius;\n const rB = circleB.m_radius;\n const radius = rA + rB;\n if (distSqr > radius * radius) {\n return;\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.copyVec2(manifold.localPoint, circleA.m_p);\n matrix.zeroVec2(manifold.localNormal);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { TransformValue } from \"../../common/Transform\";\nimport * as matrix from \"../../common/Matrix\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { EdgeShape } from \"./EdgeShape\";\nimport { ChainShape } from \"./ChainShape\";\nimport { CircleShape } from \"./CircleShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(EdgeShape.TYPE, CircleShape.TYPE, EdgeCircleContact);\nContact.addType(ChainShape.TYPE, CircleShape.TYPE, ChainCircleContact);\n\n/** @internal */ function EdgeCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == EdgeShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n\n const shapeA = fixtureA.getShape() as EdgeShape;\n const shapeB = fixtureB.getShape() as CircleShape;\n\n CollideEdgeCircle(manifold, shapeA, xfA, shapeB, xfB);\n}\n\nfunction ChainCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == ChainShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n\n const chain = fixtureA.getShape() as ChainShape;\n const edge = new EdgeShape();\n chain.getChildEdge(edge, indexA);\n\n const shapeA = edge;\n const shapeB = fixtureB.getShape() as CircleShape;\n\n CollideEdgeCircle(manifold, shapeA, xfA, shapeB, xfB);\n}\n\n/** @internal */ const e = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const e1 = matrix.vec2(0, 0);\n/** @internal */ const e2 = matrix.vec2(0, 0);\n/** @internal */ const Q = matrix.vec2(0, 0);\n/** @internal */ const P = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n\n// Compute contact points for edge versus circle.\n// This accounts for edge connectivity.\nexport const CollideEdgeCircle = function (manifold: Manifold, edgeA: EdgeShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n // Compute circle in frame of edge\n matrix.retransformVec2(Q, xfB, xfA, circleB.m_p);\n\n const A = edgeA.m_vertex1;\n const B = edgeA.m_vertex2;\n matrix.subVec2(e, B, A);\n\n // Barycentric coordinates\n const u = matrix.dotVec2(e, B) - matrix.dotVec2(e, Q);\n const v = matrix.dotVec2(e, Q) - matrix.dotVec2(e, A);\n\n const radius = edgeA.m_radius + circleB.m_radius;\n\n // Region A\n if (v <= 0.0) {\n matrix.copyVec2(P, A);\n const dd = matrix.distSqrVec2(Q, A);\n if (dd > radius * radius) {\n return;\n }\n\n // Is there an edge connected to A?\n if (edgeA.m_hasVertex0) {\n const A1 = edgeA.m_vertex0;\n const B1 = A;\n matrix.subVec2(e1, B1, A1);\n const u1 = matrix.dotVec2(e1, B1) - matrix.dotVec2(e1, Q);\n\n // Is the circle in Region AB of the previous edge?\n if (u1 > 0.0) {\n return;\n }\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.zeroVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, P);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n return;\n }\n\n // Region B\n if (u <= 0.0) {\n matrix.copyVec2(P, B);\n const dd = matrix.distSqrVec2(Q, P);\n if (dd > radius * radius) {\n return;\n }\n\n // Is there an edge connected to B?\n if (edgeA.m_hasVertex3) {\n const B2 = edgeA.m_vertex3;\n const A2 = B;\n matrix.subVec2(e2, B2, A2);\n const v2 = matrix.dotVec2(e2, Q) - matrix.dotVec2(e2, A2);\n\n // Is the circle in Region AB of the next edge?\n if (v2 > 0.0) {\n return;\n }\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.zeroVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, P);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(1, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n\n return;\n }\n\n // Region AB\n const den = matrix.lengthSqrVec2(e);\n if (_ASSERT) console.assert(den > 0.0);\n matrix.combine2Vec2(P, u / den, A, v / den, B);\n const dd = matrix.distSqrVec2(Q, P);\n if (dd > radius * radius) {\n return;\n }\n\n matrix.crossNumVec2(n, 1, e);\n if (matrix.dotVec2(n, Q) - matrix.dotVec2(n, A) < 0.0) {\n matrix.negVec2(n);\n }\n matrix.normalizeVec2(n);\n\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, n);\n matrix.copyVec2(manifold.localPoint, A);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_face, 0, ContactFeatureType.e_vertex);\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { TransformValue } from \"../../common/Transform\";\nimport * as matrix from \"../../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Manifold, clipSegmentToLine, ClipVertex, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/** @internal */ const incidentEdge = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints1 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints2 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipSegmentToLineNormal = matrix.vec2(0, 0);\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const v11 = matrix.vec2(0, 0);\n/** @internal */ const v12 = matrix.vec2(0, 0);\n/** @internal */ const localTangent = matrix.vec2(0, 0);\n/** @internal */ const localNormal = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const tangent = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const normal1 = matrix.vec2(0, 0);\n\n\nContact.addType(PolygonShape.TYPE, PolygonShape.TYPE, PolygonContact);\n\n/** @internal */ function PolygonContact(\n manifold: Manifold,\n xfA: TransformValue,\n fixtureA: Fixture,\n indexA: number,\n xfB: TransformValue,\n fixtureB: Fixture,\n indexB: number,\n): void {\n if (_ASSERT) console.assert(fixtureA.getType() == PolygonShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == PolygonShape.TYPE);\n CollidePolygons(manifold, fixtureA.getShape() as PolygonShape, xfA, fixtureB.getShape() as PolygonShape, xfB);\n}\n\n/** @internal */ interface MaxSeparation {\n maxSeparation: number;\n bestIndex: number;\n}\n\n/**\n * Find the max separation between poly1 and poly2 using edge normals from\n * poly1.\n */\n/** @internal */ function findMaxSeparation(\n poly1: PolygonShape,\n xf1: TransformValue,\n poly2: PolygonShape,\n xf2: TransformValue,\n output: MaxSeparation,\n): void {\n const count1 = poly1.m_count;\n const count2 = poly2.m_count;\n const n1s = poly1.m_normals;\n const v1s = poly1.m_vertices;\n const v2s = poly2.m_vertices;\n\n matrix.detransformTransform(xf, xf2, xf1);\n\n let bestIndex = 0;\n let maxSeparation = -Infinity;\n for (let i = 0; i < count1; ++i) {\n // Get poly1 normal in frame2.\n matrix.rotVec2(n, xf.q, n1s[i]);\n matrix.transformVec2(v1, xf, v1s[i]);\n\n // Find deepest point for normal i.\n let si = Infinity;\n for (let j = 0; j < count2; ++j) {\n const sij = matrix.dotVec2(n, v2s[j]) - matrix.dotVec2(n, v1);\n if (sij < si) {\n si = sij;\n }\n }\n\n if (si > maxSeparation) {\n maxSeparation = si;\n bestIndex = i;\n }\n }\n\n // used to keep last FindMaxSeparation call values\n output.maxSeparation = maxSeparation;\n output.bestIndex = bestIndex;\n}\n\n/** @internal */ function findIncidentEdge(\n clipVertex: ClipVertex[],\n poly1: PolygonShape,\n xf1: TransformValue,\n edge1: number,\n poly2: PolygonShape,\n xf2: TransformValue,\n): void {\n const normals1 = poly1.m_normals;\n\n const count2 = poly2.m_count;\n const vertices2 = poly2.m_vertices;\n const normals2 = poly2.m_normals;\n\n if (_ASSERT) console.assert(0 <= edge1 && edge1 < poly1.m_count);\n\n // Get the normal of the reference edge in poly2's frame.\n matrix.rerotVec2(normal1, xf2.q, xf1.q, normals1[edge1]);\n\n // Find the incident edge on poly2.\n let index = 0;\n let minDot = Infinity;\n for (let i = 0; i < count2; ++i) {\n const dot = matrix.dotVec2(normal1, normals2[i]);\n if (dot < minDot) {\n minDot = dot;\n index = i;\n }\n }\n\n // Build the clip vertices for the incident edge.\n const i1 = index;\n const i2 = i1 + 1 < count2 ? i1 + 1 : 0;\n\n matrix.transformVec2(clipVertex[0].v, xf2, vertices2[i1]);\n clipVertex[0].id.setFeatures(edge1, ContactFeatureType.e_face, i1, ContactFeatureType.e_vertex);\n\n matrix.transformVec2(clipVertex[1].v, xf2, vertices2[i2]);\n clipVertex[1].id.setFeatures(edge1, ContactFeatureType.e_face, i2, ContactFeatureType.e_vertex);\n}\n\n/** @internal */ const maxSeparation = {\n maxSeparation: 0,\n bestIndex: 0,\n};\n\n/**\n *\n * Find edge normal of max separation on A - return if separating axis is found
\n * Find edge normal of max separation on B - return if separation axis is found
\n * Choose reference edge as min(minA, minB)
\n * Find incident edge
\n * Clip\n *\n * The normal points from 1 to 2\n */\nexport const CollidePolygons = function (\n manifold: Manifold,\n polyA: PolygonShape,\n xfA: TransformValue,\n polyB: PolygonShape,\n xfB: TransformValue,\n): void {\n manifold.pointCount = 0;\n const totalRadius = polyA.m_radius + polyB.m_radius;\n\n findMaxSeparation(polyA, xfA, polyB, xfB, maxSeparation);\n const edgeA = maxSeparation.bestIndex;\n const separationA = maxSeparation.maxSeparation;\n if (separationA > totalRadius)\n return;\n\n findMaxSeparation(polyB, xfB, polyA, xfA, maxSeparation);\n const edgeB = maxSeparation.bestIndex;\n const separationB = maxSeparation.maxSeparation;\n if (separationB > totalRadius)\n return;\n\n let poly1: PolygonShape; // reference polygon\n let poly2: PolygonShape; // incident polygon\n let xf1: TransformValue;\n let xf2: TransformValue;\n let edge1: number; // reference edge\n let flip: boolean;\n const k_tol = 0.1 * Settings.linearSlop;\n\n if (separationB > separationA + k_tol) {\n poly1 = polyB;\n poly2 = polyA;\n xf1 = xfB;\n xf2 = xfA;\n edge1 = edgeB;\n manifold.type = ManifoldType.e_faceB;\n flip = true;\n } else {\n poly1 = polyA;\n poly2 = polyB;\n xf1 = xfA;\n xf2 = xfB;\n edge1 = edgeA;\n manifold.type = ManifoldType.e_faceA;\n flip = false;\n }\n\n incidentEdge[0].recycle();\n incidentEdge[1].recycle();\n findIncidentEdge(incidentEdge, poly1, xf1, edge1, poly2, xf2);\n\n const count1 = poly1.m_count;\n const vertices1 = poly1.m_vertices;\n\n const iv1 = edge1;\n const iv2 = edge1 + 1 < count1 ? edge1 + 1 : 0;\n\n matrix.copyVec2(v11, vertices1[iv1]);\n matrix.copyVec2(v12, vertices1[iv2]);\n\n matrix.subVec2(localTangent, v12, v11);\n matrix.normalizeVec2(localTangent);\n\n matrix.crossVec2Num(localNormal, localTangent, 1.0);\n matrix.combine2Vec2(planePoint, 0.5, v11, 0.5, v12);\n\n matrix.rotVec2(tangent, xf1.q, localTangent);\n matrix.crossVec2Num(normal, tangent, 1.0);\n\n matrix.transformVec2(v11, xf1, v11);\n matrix.transformVec2(v12, xf1, v12);\n\n // Face offset.\n const frontOffset = matrix.dotVec2(normal, v11);\n\n // Side offsets, extended by polytope skin thickness.\n const sideOffset1 = -matrix.dotVec2(tangent, v11) + totalRadius;\n const sideOffset2 = matrix.dotVec2(tangent, v12) + totalRadius;\n\n // Clip incident edge against extruded edge1 side edges.\n clipPoints1[0].recycle();\n clipPoints1[1].recycle();\n clipPoints2[0].recycle();\n clipPoints2[1].recycle();\n\n // Clip to box side 1\n matrix.setVec2(clipSegmentToLineNormal, -tangent.x, -tangent.y);\n const np1 = clipSegmentToLine(clipPoints1, incidentEdge, clipSegmentToLineNormal, sideOffset1, iv1);\n\n if (np1 < 2) {\n return;\n }\n\n // Clip to negative box side 1\n matrix.setVec2(clipSegmentToLineNormal, tangent.x, tangent.y);\n const np2 = clipSegmentToLine(clipPoints2, clipPoints1, clipSegmentToLineNormal, sideOffset2, iv2);\n\n if (np2 < 2) {\n return;\n }\n\n // Now clipPoints2 contains the clipped points.\n matrix.copyVec2(manifold.localNormal, localNormal);\n matrix.copyVec2(manifold.localPoint, planePoint);\n\n let pointCount = 0;\n for (let i = 0; i < clipPoints2.length/* maxManifoldPoints */; ++i) {\n const separation = matrix.dotVec2(normal, clipPoints2[i].v) - frontOffset;\n\n if (separation <= totalRadius) {\n const cp = manifold.points[pointCount];\n matrix.detransformVec2(cp.localPoint, xf2, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n if (flip) {\n // Swap features\n cp.id.swapFeatures();\n }\n ++pointCount;\n }\n }\n\n manifold.pointCount = pointCount;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { EPSILON } from \"../../common/Math\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { CircleShape } from \"./CircleShape\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(PolygonShape.TYPE, CircleShape.TYPE, PolygonCircleContact);\n\n/** @internal */ function PolygonCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == PolygonShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n CollidePolygonCircle(manifold, fixtureA.getShape() as PolygonShape, xfA, fixtureB.getShape() as CircleShape, xfB);\n}\n\n/** @internal */ const cLocal = matrix.vec2(0, 0);\n/** @internal */ const faceCenter = matrix.vec2(0, 0);\n\nexport const CollidePolygonCircle = function (manifold: Manifold, polygonA: PolygonShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n // Compute circle position in the frame of the polygon.\n matrix.retransformVec2(cLocal, xfB, xfA, circleB.m_p);\n\n // Find the min separating edge.\n let normalIndex = 0;\n let separation = -Infinity;\n const radius = polygonA.m_radius + circleB.m_radius;\n const vertexCount = polygonA.m_count;\n const vertices = polygonA.m_vertices;\n const normals = polygonA.m_normals;\n\n for (let i = 0; i < vertexCount; ++i) {\n const s = matrix.dotVec2(normals[i], cLocal) - matrix.dotVec2(normals[i], vertices[i]);\n\n if (s > radius) {\n // Early out.\n return;\n }\n\n if (s > separation) {\n separation = s;\n normalIndex = i;\n }\n }\n\n // Vertices that subtend the incident face.\n const vertIndex1 = normalIndex;\n const vertIndex2 = vertIndex1 + 1 < vertexCount ? vertIndex1 + 1 : 0;\n const v1 = vertices[vertIndex1];\n const v2 = vertices[vertIndex2];\n\n // If the center is inside the polygon ...\n if (separation < EPSILON) {\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, normals[normalIndex]);\n matrix.combine2Vec2(manifold.localPoint, 0.5, v1, 0.5, v2);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n return;\n }\n\n // Compute barycentric coordinates\n // u1 = (cLocal - v1) dot (v2 - v1))\n const u1 = matrix.dotVec2(cLocal, v2) - matrix.dotVec2(cLocal, v1) - matrix.dotVec2(v1, v2) + matrix.dotVec2(v1, v1);\n // u2 = (cLocal - v2) dot (v1 - v2)\n const u2 = matrix.dotVec2(cLocal, v1) - matrix.dotVec2(cLocal, v2) - matrix.dotVec2(v2, v1) + matrix.dotVec2(v2, v2);\n if (u1 <= 0.0) {\n if (matrix.distSqrVec2(cLocal, v1) > radius * radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.subVec2(manifold.localNormal, cLocal, v1);\n matrix.normalizeVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, v1);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n } else if (u2 <= 0.0) {\n if (matrix.distSqrVec2(cLocal, v2) > radius * radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.subVec2(manifold.localNormal, cLocal, v2);\n matrix.normalizeVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, v2);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n } else {\n matrix.combine2Vec2(faceCenter, 0.5, v1, 0.5, v2);\n const separation = matrix.dotVec2(cLocal, normals[vertIndex1]) - matrix.dotVec2(faceCenter, normals[vertIndex1]);\n if (separation > radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, normals[vertIndex1]);\n matrix.copyVec2(manifold.localPoint, faceCenter);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n }\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { Manifold, clipSegmentToLine, ClipVertex, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { EdgeShape } from \"./EdgeShape\";\nimport { ChainShape } from \"./ChainShape\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_min = Math.min;\n\nContact.addType(EdgeShape.TYPE, PolygonShape.TYPE, EdgePolygonContact);\nContact.addType(ChainShape.TYPE, PolygonShape.TYPE, ChainPolygonContact);\n\n/** @internal */ function EdgePolygonContact(manifold: Manifold, xfA: TransformValue, fA: Fixture, indexA: number, xfB: TransformValue, fB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fA.getType() == EdgeShape.TYPE);\n if (_ASSERT) console.assert(fB.getType() == PolygonShape.TYPE);\n\n CollideEdgePolygon(manifold, fA.getShape() as EdgeShape, xfA, fB.getShape() as PolygonShape, xfB);\n}\n\n// reused\n/** @internal */ const edge_reuse = new EdgeShape();\n\n/** @internal */ function ChainPolygonContact(manifold: Manifold, xfA: TransformValue, fA: Fixture, indexA: number, xfB: TransformValue, fB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fA.getType() == ChainShape.TYPE);\n if (_ASSERT) console.assert(fB.getType() == PolygonShape.TYPE);\n\n const chain = fA.getShape() as ChainShape;\n chain.getChildEdge(edge_reuse, indexA);\n\n CollideEdgePolygon(manifold, edge_reuse, xfA, fB.getShape() as PolygonShape, xfB);\n}\n\n/** @internal */ enum EPAxisType {\n e_unknown = -1,\n e_edgeA = 1,\n e_edgeB = 2,\n}\n\n// unused?\n/** @internal */ enum VertexType {\n e_isolated = 0,\n e_concave = 1,\n e_convex = 2,\n}\n\n/**\n * This structure is used to keep track of the best separating axis.\n */\n/** @internal */ class EPAxis {\n type: EPAxisType;\n index: number;\n separation: number;\n}\n\n/**\n * This holds polygon B expressed in frame A.\n */\n/** @internal */ class TempPolygon {\n vertices: Vec2Value[] = []; // [Settings.maxPolygonVertices]\n normals: Vec2Value[] = []; // [Settings.maxPolygonVertices];\n count: number = 0;\n constructor() {\n for (let i = 0; i < Settings.maxPolygonVertices; i++) {\n this.vertices.push(matrix.vec2(0, 0));\n this.normals.push(matrix.vec2(0, 0));\n }\n }\n}\n\n/**\n * Reference face used for clipping\n */\n/** @internal */ class ReferenceFace {\n i1: number;\n i2: number;\n readonly v1 = matrix.vec2(0 ,0);\n readonly v2 = matrix.vec2(0 ,0);\n readonly normal = matrix.vec2(0 ,0);\n readonly sideNormal1 = matrix.vec2(0 ,0);\n sideOffset1: number;\n readonly sideNormal2 = matrix.vec2(0 ,0);\n sideOffset2: number;\n recycle() {\n matrix.zeroVec2(this.v1);\n matrix.zeroVec2(this.v2);\n matrix.zeroVec2(this.normal);\n matrix.zeroVec2(this.sideNormal1);\n matrix.zeroVec2(this.sideNormal2);\n }\n}\n\n// reused\n/** @internal */ const clipPoints1 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints2 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const ie = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const edgeAxis = new EPAxis();\n/** @internal */ const polygonAxis = new EPAxis();\n/** @internal */ const polygonBA = new TempPolygon();\n/** @internal */ const rf = new ReferenceFace();\n/** @internal */ const centroidB = matrix.vec2(0, 0);\n/** @internal */ const edge0 = matrix.vec2(0, 0);\n/** @internal */ const edge1 = matrix.vec2(0, 0);\n/** @internal */ const edge2 = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const normal0 = matrix.vec2(0, 0);\n/** @internal */ const normal1 = matrix.vec2(0, 0);\n/** @internal */ const normal2 = matrix.vec2(0, 0);\n/** @internal */ const lowerLimit = matrix.vec2(0, 0);\n/** @internal */ const upperLimit = matrix.vec2(0, 0);\n/** @internal */ const perp = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n\n/**\n * This function collides and edge and a polygon, taking into account edge\n * adjacency.\n */\nexport const CollideEdgePolygon = function (manifold: Manifold, edgeA: EdgeShape, xfA: TransformValue, polygonB: PolygonShape, xfB: TransformValue): void {\n // Algorithm:\n // 1. Classify v1 and v2\n // 2. Classify polygon centroid as front or back\n // 3. Flip normal if necessary\n // 4. Initialize normal range to [-pi, pi] about face normal\n // 5. Adjust normal range according to adjacent edges\n // 6. Visit each separating axes, only accept axes within the range\n // 7. Return if _any_ axis indicates separation\n // 8. Clip\n\n // let m_type1: VertexType;\n // let m_type2: VertexType;\n\n matrix.detransformTransform(xf, xfA, xfB);\n matrix.transformVec2(centroidB, xf, polygonB.m_centroid);\n\n const v0 = edgeA.m_vertex0;\n const v1 = edgeA.m_vertex1;\n const v2 = edgeA.m_vertex2;\n const v3 = edgeA.m_vertex3;\n\n const hasVertex0 = edgeA.m_hasVertex0;\n const hasVertex3 = edgeA.m_hasVertex3;\n\n matrix.subVec2(edge1, v2, v1);\n matrix.normalizeVec2(edge1);\n matrix.setVec2(normal1, edge1.y, -edge1.x);\n const offset1 = matrix.dotVec2(normal1, centroidB) - matrix.dotVec2(normal1, v1);\n let offset0 = 0.0;\n let offset2 = 0.0;\n let convex1 = false;\n let convex2 = false;\n\n matrix.zeroVec2(normal0);\n matrix.zeroVec2(normal2);\n\n // Is there a preceding edge?\n if (hasVertex0) {\n matrix.subVec2(edge0, v1, v0);\n matrix.normalizeVec2(edge0);\n matrix.setVec2(normal0, edge0.y, -edge0.x);\n convex1 = matrix.crossVec2Vec2(edge0, edge1) >= 0.0;\n offset0 = Vec2.dot(normal0, centroidB) - Vec2.dot(normal0, v0);\n }\n\n // Is there a following edge?\n if (hasVertex3) {\n matrix.subVec2(edge2, v3, v2);\n matrix.normalizeVec2(edge2);\n matrix.setVec2(normal2, edge2.y, -edge2.x);\n convex2 = Vec2.crossVec2Vec2(edge1, edge2) > 0.0;\n offset2 = Vec2.dot(normal2, centroidB) - Vec2.dot(normal2, v2);\n }\n\n let front: boolean;\n matrix.zeroVec2(normal);\n matrix.zeroVec2(lowerLimit);\n matrix.zeroVec2(upperLimit);\n\n // Determine front or back collision. Determine collision normal limits.\n if (hasVertex0 && hasVertex3) {\n if (convex1 && convex2) {\n front = offset0 >= 0.0 || offset1 >= 0.0 || offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else if (convex1) {\n front = offset0 >= 0.0 || (offset1 >= 0.0 && offset2 >= 0.0);\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else if (convex2) {\n front = offset2 >= 0.0 || (offset0 >= 0.0 && offset1 >= 0.0);\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n } else {\n front = offset0 >= 0.0 && offset1 >= 0.0 && offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n }\n } else if (hasVertex0) {\n if (convex1) {\n front = offset0 >= 0.0 || offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else {\n front = offset0 >= 0.0 && offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n }\n } else if (hasVertex3) {\n if (convex2) {\n front = offset1 >= 0.0 || offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal1);\n }\n } else {\n front = offset1 >= 0.0 && offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.copyVec2(upperLimit, normal1);\n }\n }\n } else {\n front = offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal1);\n }\n }\n\n // Get polygonB in frameA\n polygonBA.count = polygonB.m_count;\n for (let i = 0; i < polygonB.m_count; ++i) {\n matrix.transformVec2(polygonBA.vertices[i], xf, polygonB.m_vertices[i]);\n matrix.rotVec2(polygonBA.normals[i], xf.q, polygonB.m_normals[i]);\n }\n\n const radius = polygonB.m_radius + edgeA.m_radius;\n\n manifold.pointCount = 0;\n\n { // ComputeEdgeSeparation\n edgeAxis.type = EPAxisType.e_edgeA;\n edgeAxis.index = front ? 0 : 1;\n edgeAxis.separation = Infinity;\n\n for (let i = 0; i < polygonBA.count; ++i) {\n const v = polygonBA.vertices[i];\n const s = matrix.dotVec2(normal, v) - matrix.dotVec2(normal, v1);\n if (s < edgeAxis.separation) {\n edgeAxis.separation = s;\n }\n }\n }\n\n // If no valid normal can be found than this edge should not collide.\n // @ts-ignore todo: why we need this if here?\n if (edgeAxis.type == EPAxisType.e_unknown) {\n return;\n }\n\n if (edgeAxis.separation > radius) {\n return;\n }\n\n { // ComputePolygonSeparation\n polygonAxis.type = EPAxisType.e_unknown;\n polygonAxis.index = -1;\n polygonAxis.separation = -Infinity;\n\n matrix.setVec2(perp, -normal.y, normal.x);\n\n for (let i = 0; i < polygonBA.count; ++i) {\n matrix.scaleVec2(n, -1, polygonBA.normals[i]);\n\n const s1 = matrix.dotVec2(n, polygonBA.vertices[i]) - matrix.dotVec2(n, v1);\n const s2 = matrix.dotVec2(n, polygonBA.vertices[i]) - matrix.dotVec2(n, v2);\n const s = math_min(s1, s2);\n\n if (s > radius) {\n // No collision\n polygonAxis.type = EPAxisType.e_edgeB;\n polygonAxis.index = i;\n polygonAxis.separation = s;\n break;\n }\n\n // Adjacency\n if (matrix.dotVec2(n, perp) >= 0.0) {\n if (matrix.dotVec2(n, normal) - matrix.dotVec2(upperLimit, normal) < -Settings.angularSlop) {\n continue;\n }\n } else {\n if (matrix.dotVec2(n, normal) - matrix.dotVec2(lowerLimit, normal) < -Settings.angularSlop) {\n continue;\n }\n }\n\n if (s > polygonAxis.separation) {\n polygonAxis.type = EPAxisType.e_edgeB;\n polygonAxis.index = i;\n polygonAxis.separation = s;\n }\n }\n }\n\n if (polygonAxis.type != EPAxisType.e_unknown && polygonAxis.separation > radius) {\n return;\n }\n\n // Use hysteresis for jitter reduction.\n const k_relativeTol = 0.98;\n const k_absoluteTol = 0.001;\n\n let primaryAxis: EPAxis;\n if (polygonAxis.type == EPAxisType.e_unknown) {\n primaryAxis = edgeAxis;\n } else if (polygonAxis.separation > k_relativeTol * edgeAxis.separation + k_absoluteTol) {\n primaryAxis = polygonAxis;\n } else {\n primaryAxis = edgeAxis;\n }\n\n ie[0].recycle();\n ie[1].recycle();\n\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n manifold.type = ManifoldType.e_faceA;\n\n // Search for the polygon normal that is most anti-parallel to the edge\n // normal.\n let bestIndex = 0;\n let bestValue = matrix.dotVec2(normal, polygonBA.normals[0]);\n for (let i = 1; i < polygonBA.count; ++i) {\n const value = matrix.dotVec2(normal, polygonBA.normals[i]);\n if (value < bestValue) {\n bestValue = value;\n bestIndex = i;\n }\n }\n\n const i1 = bestIndex;\n const i2 = i1 + 1 < polygonBA.count ? i1 + 1 : 0;\n\n matrix.copyVec2(ie[0].v, polygonBA.vertices[i1]);\n ie[0].id.setFeatures(0, ContactFeatureType.e_face, i1, ContactFeatureType.e_vertex);\n\n matrix.copyVec2(ie[1].v, polygonBA.vertices[i2]);\n ie[1].id.setFeatures(0, ContactFeatureType.e_face, i2, ContactFeatureType.e_vertex);\n\n if (front) {\n rf.i1 = 0;\n rf.i2 = 1;\n matrix.copyVec2(rf.v1, v1);\n matrix.copyVec2(rf.v2, v2);\n matrix.copyVec2(rf.normal, normal1);\n } else {\n rf.i1 = 1;\n rf.i2 = 0;\n matrix.copyVec2(rf.v1, v2);\n matrix.copyVec2(rf.v2, v1);\n matrix.scaleVec2(rf.normal, -1, normal1);\n }\n } else {\n manifold.type = ManifoldType.e_faceB;\n\n matrix.copyVec2(ie[0].v, v1);\n ie[0].id.setFeatures(0, ContactFeatureType.e_vertex, primaryAxis.index, ContactFeatureType.e_face);\n\n matrix.copyVec2(ie[1].v, v2);\n ie[1].id.setFeatures(0, ContactFeatureType.e_vertex, primaryAxis.index, ContactFeatureType.e_face);\n\n rf.i1 = primaryAxis.index;\n rf.i2 = rf.i1 + 1 < polygonBA.count ? rf.i1 + 1 : 0;\n matrix.copyVec2(rf.v1, polygonBA.vertices[rf.i1]);\n matrix.copyVec2(rf.v2, polygonBA.vertices[rf.i2]);\n matrix.copyVec2(rf.normal, polygonBA.normals[rf.i1]);\n }\n\n matrix.setVec2(rf.sideNormal1, rf.normal.y, -rf.normal.x);\n matrix.setVec2(rf.sideNormal2, -rf.sideNormal1.x, -rf.sideNormal1.y);\n rf.sideOffset1 = matrix.dotVec2(rf.sideNormal1, rf.v1);\n rf.sideOffset2 = matrix.dotVec2(rf.sideNormal2, rf.v2);\n\n // Clip incident edge against extruded edge1 side edges.\n clipPoints1[0].recycle();\n clipPoints1[1].recycle();\n clipPoints2[0].recycle();\n clipPoints2[1].recycle();\n\n // Clip to box side 1\n const np1 = clipSegmentToLine(clipPoints1, ie, rf.sideNormal1, rf.sideOffset1, rf.i1);\n\n if (np1 < Settings.maxManifoldPoints) {\n return;\n }\n\n // Clip to negative box side 1\n const np2 = clipSegmentToLine(clipPoints2, clipPoints1, rf.sideNormal2, rf.sideOffset2, rf.i2);\n\n if (np2 < Settings.maxManifoldPoints) {\n return;\n }\n\n // Now clipPoints2 contains the clipped points.\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n matrix.copyVec2(manifold.localNormal, rf.normal);\n matrix.copyVec2(manifold.localPoint, rf.v1);\n } else {\n matrix.copyVec2(manifold.localNormal, polygonB.m_normals[rf.i1]);\n matrix.copyVec2(manifold.localPoint, polygonB.m_vertices[rf.i1]);\n }\n\n let pointCount = 0;\n for (let i = 0; i < Settings.maxManifoldPoints; ++i) {\n const separation = matrix.dotVec2(rf.normal, clipPoints2[i].v) - matrix.dotVec2(rf.normal, rf.v1);\n\n if (separation <= radius) {\n const cp = manifold.points[pointCount]; // ManifoldPoint\n\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n matrix.detransformVec2(cp.localPoint, xf, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n } else {\n matrix.copyVec2(cp.localPoint, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n cp.id.swapFeatures();\n }\n\n ++pointCount;\n }\n }\n\n manifold.pointCount = pointCount;\n};\n","import { CollidePolygons } from \"./collision/shape/CollidePolygon\";\nimport { Settings } from \"./Settings\";\nimport { Sweep } from \"./common/Sweep\";\nimport { DynamicTree } from \"./collision/DynamicTree\";\nimport { Manifold } from \"./collision/Manifold\";\nimport { Distance } from \"./collision/Distance\";\nimport { TimeOfImpact } from \"./collision/TimeOfImpact\";\nimport { stats } from \"./util/stats\";\n\n/** @hidden @deprecated Merged with main namespace */\nexport const internal = {\n CollidePolygons,\n Settings,\n Sweep,\n Manifold,\n Distance,\n TimeOfImpact,\n DynamicTree,\n stats\n};\n"],"names":["d","b","__assign","s","n","input","output","x","math_abs","math_sqrt","math_max","math_min","Vec2","v","a","AABB","normal","temp","math_PI","Settings","SettingsInternal","Pool","TreeNode","DynamicTree","c","Iterator","BroadPhase","displacement","math_sin","math_cos","transform","xf","math_atan2","Rot","matrix.vec2","Sweep","matrix.zeroVec2","matrix.transformVec2","matrix.copyVec2","localCenter","matrix.setRotAngle","matrix.combine2Vec2","matrix.minusVec2","matrix.rotVec2","Transform","rotation","Velocity","Position","Shape","FixtureProxy","Fixture","matrix.subVec2","matrix.transform","Body","matrix.plusScaleVec2","matrix.scaleVec2","matrix.dotVec2","matrix.crossNumVec2","matrix.plusVec2","point","JointEdge","Joint","DistanceInput","DistanceOutput","SimplexCache","cache","xfA","xfB","matrix.lengthSqrVec2","matrix.derotVec2","matrix.distVec2","rA","rB","matrix.normalizeVec2","matrix.minusScaleVec2","DistanceProxy","SimplexVertex","Simplex","v1","v2","matrix.setVec2","matrix.crossVec2Vec2","pA","pB","matrix.combine3Vec2","matrix.copyTransform","ShapeCastInput","ShapeCastOutput","simplex","pointA","pointB","TOIInput","TOIOutputState","TOIOutput","SeparationFunctionType","SeparationFunction","matrix.normalizeVec2Length","matrix.crossVec2Num","matrix.negVec2","TimeStep","ContactImpulse","Solver","matrix.mulVec2","Mat22","cA","cB","planePoint","clipPoint","ManifoldType","ContactFeatureType","PointState","ClipVertex","Manifold","ManifoldPoint","ContactID","WorldManifold","ContactEdge","VelocityConstraintPoint","tangent","P","Contact","_a","worldManifold","DEFAULTS","World","oldManifold","Vec3","EdgeShape","e","ChainShape","e1","e2","PolygonShape","ie","center","matrix.detransformVec2","matrix.addVec2","CircleShape","matrix.distSqrVec2","DistanceJoint","vA","vB","FrictionJoint","Mat33","LimitState","RevoluteJoint","PrismaticJoint","translation","perp","GearJoint","MotorJoint","MouseJoint","PulleyJoint","RopeJoint","WeldJoint","WheelJoint","Serializer","options","obj","Testbed","testbed","BoxShape","matrix.retransformVec2","clipPoints1","clipPoints2","normal1","matrix.detransformTransform","maxSeparation","edge1","matrix.rerotVec2","EPAxisType","VertexType","EPAxis","TempPolygon","ReferenceFace","s2"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,MAAI,gBAAgB,SAASA,IAAGC,IAAG;AAC/B,oBAAgB,OAAO,kBAClB,EAAE,WAAW,CAAA,eAAgB,SAAS,SAAUD,IAAGC,IAAG;AAAE,MAAAD,GAAE,YAAYC;AAAA,IAAE,KACzE,SAAUD,IAAGC,IAAG;AAAE,eAAS,KAAKA,GAAG,KAAI,OAAO,UAAU,eAAe,KAAKA,IAAG,CAAC,EAAG,CAAAD,GAAE,CAAC,IAAIC,GAAE,CAAC;AAAA;AACjG,WAAO,cAAcD,IAAGC,EAAC;AAAA,EAC7B;AAEO,WAAS,UAAUD,IAAGC,IAAG;AAC5B,QAAI,OAAOA,OAAM,cAAcA,OAAM;AACjC,YAAM,IAAI,UAAU,yBAAyB,OAAOA,EAAC,IAAI,+BAA+B;AAC5F,kBAAcD,IAAGC,EAAC;A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ACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","x_google_ignoreList":[0]} \ No newline at end of file diff --git a/dist/planck.min.js b/dist/planck.min.js index 8ecd3ff7..db87fde9 100644 --- a/dist/planck.min.js +++ b/dist/planck.min.js @@ -1,6 +1,6 @@ (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports):typeof define==="function"&&define.amd?define(["exports"],factory):(global=typeof globalThis!=="undefined"?globalThis:global||self,factory(global.planck={}))})(this,(function(exports2){"use strict"; /** - * Planck.js v1.1.6 + * Planck.js v1.2.0 * @license The MIT license * @copyright Copyright (c) 2024 Erin Catto, Ali Shakiba * @@ -35,4 +35,4 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ***************************************************************************** */var extendStatics=function(d2,b2){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d3,b3){d3.__proto__=b3}||function(d3,b3){for(var p in b3)if(Object.prototype.hasOwnProperty.call(b3,p))d3[p]=b3[p]};return extendStatics(d2,b2)};function __extends(d2,b2){if(typeof b2!=="function"&&b2!==null)throw new TypeError("Class extends value "+String(b2)+" is not a constructor or null");extendStatics(d2,b2);function __(){this.constructor=d2}d2.prototype=b2===null?Object.create(b2):(__.prototype=b2.prototype,new __)}var __assign=function(){__assign=Object.assign||function __assign2(t){for(var s2,i=1,n2=arguments.length;i>1;x2|=x2>>2;x2|=x2>>4;x2|=x2>>8;x2|=x2>>16;return x2+1}function isPowerOfTwo(x2){return x2>0&&(x2&x2-1)===0}function mod(num,min,max){if(typeof min==="undefined"){max=1;min=0}else if(typeof max==="undefined"){max=min;min=0}if(max>min){num=(num-min)%(max-min);return num+(num<0?max:min)}else{num=(num-max)%(min-max);return num+(num<=0?min:max)}}function clamp(num,min,max){if(nummax){return max}else{return num}}function random(min,max){if(typeof min==="undefined"){max=1;min=0}else if(typeof max==="undefined"){max=min;min=0}return min===max?min:math_random()*(max-min)+min}var math=Object.create(Math);math.EPSILON=EPSILON;math.isFinite=isFinite;math.nextPowerOfTwo=nextPowerOfTwo;math.isPowerOfTwo=isPowerOfTwo;math.mod=mod;math.clamp=clamp;math.random=random;var math_abs$9=Math.abs;var math_sqrt$5=Math.sqrt;var math_max$8=Math.max;var math_min$8=Math.min;var Vec2=function(){function Vec22(x2,y){if(!(this instanceof Vec22)){return new Vec22(x2,y)}if(typeof x2==="undefined"){this.x=0;this.y=0}else if(typeof x2==="object"){this.x=x2.x;this.y=x2.y}else{this.x=x2;this.y=y}}Vec22.prototype._serialize=function(){return{x:this.x,y:this.y}};Vec22._deserialize=function(data){var obj=Object.create(Vec22.prototype);obj.x=data.x;obj.y=data.y;return obj};Vec22.zero=function(){var obj=Object.create(Vec22.prototype);obj.x=0;obj.y=0;return obj};Vec22.neo=function(x2,y){var obj=Object.create(Vec22.prototype);obj.x=x2;obj.y=y;return obj};Vec22.clone=function(v3){return Vec22.neo(v3.x,v3.y)};Vec22.prototype.toString=function(){return JSON.stringify(this)};Vec22.isValid=function(obj){if(obj===null||typeof obj==="undefined"){return false}return Number.isFinite(obj.x)&&Number.isFinite(obj.y)};Vec22.assert=function(o){};Vec22.prototype.clone=function(){return Vec22.clone(this)};Vec22.prototype.setZero=function(){this.x=0;this.y=0;return this};Vec22.prototype.set=function(x2,y){if(typeof x2==="object"){this.x=x2.x;this.y=x2.y}else{this.x=x2;this.y=y}return this};Vec22.prototype.setNum=function(x2,y){this.x=x2;this.y=y;return this};Vec22.prototype.setVec2=function(value){this.x=value.x;this.y=value.y;return this};Vec22.prototype.wSet=function(a2,v3,b2,w){if(typeof b2!=="undefined"||typeof w!=="undefined"){return this.setCombine(a2,v3,b2,w)}else{return this.setMul(a2,v3)}};Vec22.prototype.setCombine=function(a2,v3,b2,w){var x2=a2*v3.x+b2*w.x;var y=a2*v3.y+b2*w.y;this.x=x2;this.y=y;return this};Vec22.prototype.setMul=function(a2,v3){var x2=a2*v3.x;var y=a2*v3.y;this.x=x2;this.y=y;return this};Vec22.prototype.add=function(w){this.x+=w.x;this.y+=w.y;return this};Vec22.prototype.wAdd=function(a2,v3,b2,w){if(typeof b2!=="undefined"||typeof w!=="undefined"){return this.addCombine(a2,v3,b2,w)}else{return this.addMul(a2,v3)}};Vec22.prototype.addCombine=function(a2,v3,b2,w){var x2=a2*v3.x+b2*w.x;var y=a2*v3.y+b2*w.y;this.x+=x2;this.y+=y;return this};Vec22.prototype.addMul=function(a2,v3){var x2=a2*v3.x;var y=a2*v3.y;this.x+=x2;this.y+=y;return this};Vec22.prototype.wSub=function(a2,v3,b2,w){if(typeof b2!=="undefined"||typeof w!=="undefined"){return this.subCombine(a2,v3,b2,w)}else{return this.subMul(a2,v3)}};Vec22.prototype.subCombine=function(a2,v3,b2,w){var x2=a2*v3.x+b2*w.x;var y=a2*v3.y+b2*w.y;this.x-=x2;this.y-=y;return this};Vec22.prototype.subMul=function(a2,v3){var x2=a2*v3.x;var y=a2*v3.y;this.x-=x2;this.y-=y;return this};Vec22.prototype.sub=function(w){this.x-=w.x;this.y-=w.y;return this};Vec22.prototype.mul=function(m){this.x*=m;this.y*=m;return this};Vec22.prototype.length=function(){return Vec22.lengthOf(this)};Vec22.prototype.lengthSquared=function(){return Vec22.lengthSquared(this)};Vec22.prototype.normalize=function(){var length=this.length();if(lengthmax*max){var scale=max/math_sqrt$5(lengthSqr);this.x*=scale;this.y*=scale}return this};Vec22.clamp=function(v3,max){var r=Vec22.neo(v3.x,v3.y);r.clamp(max);return r};Vec22.clampVec2=function(v3,min,max){return{x:clamp(v3.x,min===null||min===void 0?void 0:min.x,max===null||max===void 0?void 0:max.x),y:clamp(v3.y,min===null||min===void 0?void 0:min.y,max===null||max===void 0?void 0:max.y)}};Vec22.scaleFn=function(x2,y){return function(v3){return Vec22.neo(v3.x*x2,v3.y*y)}};Vec22.translateFn=function(x2,y){return function(v3){return Vec22.neo(v3.x+x2,v3.y+y)}};return Vec22}();var math_max$7=Math.max;var math_min$7=Math.min;var AABB=function(){function AABB2(lower,upper){if(!(this instanceof AABB2)){return new AABB2(lower,upper)}this.lowerBound=Vec2.zero();this.upperBound=Vec2.zero();if(typeof lower==="object"){this.lowerBound.setVec2(lower)}if(typeof upper==="object"){this.upperBound.setVec2(upper)}else if(typeof lower==="object"){this.upperBound.setVec2(lower)}}AABB2.prototype.isValid=function(){return AABB2.isValid(this)};AABB2.isValid=function(obj){if(obj===null||typeof obj==="undefined"){return false}return Vec2.isValid(obj.lowerBound)&&Vec2.isValid(obj.upperBound)&&Vec2.sub(obj.upperBound,obj.lowerBound).lengthSquared()>=0};AABB2.assert=function(o){};AABB2.prototype.getCenter=function(){return Vec2.neo((this.lowerBound.x+this.upperBound.x)*.5,(this.lowerBound.y+this.upperBound.y)*.5)};AABB2.prototype.getExtents=function(){return Vec2.neo((this.upperBound.x-this.lowerBound.x)*.5,(this.upperBound.y-this.lowerBound.y)*.5)};AABB2.prototype.getPerimeter=function(){return 2*(this.upperBound.x-this.lowerBound.x+this.upperBound.y-this.lowerBound.y)};AABB2.prototype.combine=function(a2,b2){b2=b2||this;var lowerA=a2.lowerBound;var upperA=a2.upperBound;var lowerB=b2.lowerBound;var upperB=b2.upperBound;var lowerX=math_min$7(lowerA.x,lowerB.x);var lowerY=math_min$7(lowerA.y,lowerB.y);var upperX=math_max$7(upperB.x,upperA.x);var upperY=math_max$7(upperB.y,upperA.y);this.lowerBound.setNum(lowerX,lowerY);this.upperBound.setNum(upperX,upperY)};AABB2.prototype.combinePoints=function(a2,b2){this.lowerBound.setNum(math_min$7(a2.x,b2.x),math_min$7(a2.y,b2.y));this.upperBound.setNum(math_max$7(a2.x,b2.x),math_max$7(a2.y,b2.y))};AABB2.prototype.set=function(aabb){this.lowerBound.setNum(aabb.lowerBound.x,aabb.lowerBound.y);this.upperBound.setNum(aabb.upperBound.x,aabb.upperBound.y)};AABB2.prototype.contains=function(aabb){var result=true;result=result&&this.lowerBound.x<=aabb.lowerBound.x;result=result&&this.lowerBound.y<=aabb.lowerBound.y;result=result&&aabb.upperBound.x<=this.upperBound.x;result=result&&aabb.upperBound.y<=this.upperBound.y;return result};AABB2.prototype.extend=function(value){AABB2.extend(this,value);return this};AABB2.extend=function(out,value){out.lowerBound.x-=value;out.lowerBound.y-=value;out.upperBound.x+=value;out.upperBound.y+=value;return out};AABB2.testOverlap=function(a2,b2){var d1x=b2.lowerBound.x-a2.upperBound.x;var d2x=a2.lowerBound.x-b2.upperBound.x;var d1y=b2.lowerBound.y-a2.upperBound.y;var d2y=a2.lowerBound.y-b2.upperBound.y;if(d1x>0||d1y>0||d2x>0||d2y>0){return false}return true};AABB2.areEqual=function(a2,b2){return Vec2.areEqual(a2.lowerBound,b2.lowerBound)&&Vec2.areEqual(a2.upperBound,b2.upperBound)};AABB2.diff=function(a2,b2){var wD=math_max$7(0,math_min$7(a2.upperBound.x,b2.upperBound.x)-math_max$7(b2.lowerBound.x,a2.lowerBound.x));var hD=math_max$7(0,math_min$7(a2.upperBound.y,b2.upperBound.y)-math_max$7(b2.lowerBound.y,a2.lowerBound.y));var wA=a2.upperBound.x-a2.lowerBound.x;var hA=a2.upperBound.y-a2.lowerBound.y;var wB=b2.upperBound.x-b2.lowerBound.x;var hB=b2.upperBound.y-b2.lowerBound.y;return wA*hA+wB*hB-wD*hD};AABB2.prototype.rayCast=function(output2,input2){var tmin=-Infinity;var tmax=Infinity;var p=input2.p1;var d2=Vec2.sub(input2.p2,input2.p1);var absD=Vec2.abs(d2);var normal3=Vec2.zero();for(var f="x";f!==null;f=f==="x"?"y":null){if(absD.xt2){var temp3=t1;t1=t2;t2=temp3;s2=1}if(t1>tmin){normal3.setZero();normal3[f]=s2;tmin=t1}tmax=math_min$7(tmax,t2);if(tmin>tmax){return false}}}if(tmin<0||input2.maxFraction0){item=this._list.shift()}else{this._createCount++;if(this._hasCreateFn){item=this._createFn()}else{item={}}}this._allocateCount++;if(this._hasAllocateFn){this._allocateFn(item)}return item};Pool2.prototype.release=function(item){if(this._list.length"+this._allocateCount+" <"+this._releaseCount+" -"+this._disposeCount+" ="+this._list.length+"/"+this._max};return Pool2}();var math_abs$8=Math.abs;var math_max$6=Math.max;var TreeNode=function(){function TreeNode2(id){this.aabb=new AABB;this.userData=null;this.parent=null;this.child1=null;this.child2=null;this.height=-1;this.id=id}TreeNode2.prototype.toString=function(){return this.id+": "+this.userData};TreeNode2.prototype.isLeaf=function(){return this.child1==null};return TreeNode2}();var poolTreeNode=new Pool({create:function(){return new TreeNode},release:function(node){node.userData=null;node.parent=null;node.child1=null;node.child2=null;node.height=-1;node.id=void 0}});var DynamicTree=function(){function DynamicTree2(){this.inputPool=new Pool({create:function(){return{}},release:function(stack){}});this.stackPool=new Pool({create:function(){return[]},release:function(stack){stack.length=0}});this.iteratorPool=new Pool({create:function(){return new Iterator},release:function(iterator){iterator.close()}});this.m_root=null;this.m_nodes={};this.m_lastProxyId=0}DynamicTree2.prototype.getUserData=function(id){var node=this.m_nodes[id];return node.userData};DynamicTree2.prototype.getFatAABB=function(id){var node=this.m_nodes[id];return node.aabb};DynamicTree2.prototype.allocateNode=function(){var node=poolTreeNode.allocate();node.id=++this.m_lastProxyId;this.m_nodes[node.id]=node;return node};DynamicTree2.prototype.freeNode=function(node){delete this.m_nodes[node.id];poolTreeNode.release(node)};DynamicTree2.prototype.createProxy=function(aabb,userData){var node=this.allocateNode();node.aabb.set(aabb);AABB.extend(node.aabb,SettingsInternal.aabbExtension);node.userData=userData;node.height=0;this.insertLeaf(node);return node.id};DynamicTree2.prototype.destroyProxy=function(id){var node=this.m_nodes[id];this.removeLeaf(node);this.freeNode(node)};DynamicTree2.prototype.moveProxy=function(id,aabb,d2){var node=this.m_nodes[id];if(node.aabb.contains(aabb)){return false}this.removeLeaf(node);node.aabb.set(aabb);aabb=node.aabb;AABB.extend(aabb,SettingsInternal.aabbExtension);if(d2.x<0){aabb.lowerBound.x+=d2.x*SettingsInternal.aabbMultiplier}else{aabb.upperBound.x+=d2.x*SettingsInternal.aabbMultiplier}if(d2.y<0){aabb.lowerBound.y+=d2.y*SettingsInternal.aabbMultiplier}else{aabb.upperBound.y+=d2.y*SettingsInternal.aabbMultiplier}this.insertLeaf(node);return true};DynamicTree2.prototype.insertLeaf=function(leaf){if(this.m_root==null){this.m_root=leaf;this.m_root.parent=null;return}var leafAABB=leaf.aabb;var index=this.m_root;while(!index.isLeaf()){var child1=index.child1;var child2=index.child2;var area=index.aabb.getPerimeter();var combinedArea=AABB.combinedPerimeter(index.aabb,leafAABB);var cost=2*combinedArea;var inheritanceCost=2*(combinedArea-area);var newArea1=AABB.combinedPerimeter(leafAABB,child1.aabb);var cost1=newArea1+inheritanceCost;if(!child1.isLeaf()){var oldArea=child1.aabb.getPerimeter();cost1-=oldArea}var newArea2=AABB.combinedPerimeter(leafAABB,child2.aabb);var cost2=newArea2+inheritanceCost;if(!child2.isLeaf()){var oldArea=child2.aabb.getPerimeter();cost2-=oldArea}if(cost1){var F=C.child1;var G=C.child2;C.child1=A;C.parent=A.parent;A.parent=C;if(C.parent!=null){if(C.parent.child1===iA){C.parent.child1=C}else{C.parent.child2=C}}else{this.m_root=C}if(F.height>G.height){C.child2=F;A.child2=G;G.parent=A;A.aabb.combine(B.aabb,G.aabb);C.aabb.combine(A.aabb,F.aabb);A.height=1+math_max$6(B.height,G.height);C.height=1+math_max$6(A.height,F.height)}else{C.child2=G;A.child2=F;F.parent=A;A.aabb.combine(B.aabb,F.aabb);C.aabb.combine(A.aabb,G.aabb);A.height=1+math_max$6(B.height,F.height);C.height=1+math_max$6(A.height,G.height)}return C}if(balance<-1){var D=B.child1;var E=B.child2;B.child1=A;B.parent=A.parent;A.parent=B;if(B.parent!=null){if(B.parent.child1===A){B.parent.child1=B}else{B.parent.child2=B}}else{this.m_root=B}if(D.height>E.height){B.child2=D;A.child1=E;E.parent=A;A.aabb.combine(C.aabb,E.aabb);B.aabb.combine(A.aabb,D.aabb);A.height=1+math_max$6(C.height,E.height);B.height=1+math_max$6(A.height,D.height)}else{B.child2=E;A.child1=D;D.parent=A;A.aabb.combine(C.aabb,D.aabb);B.aabb.combine(A.aabb,E.aabb);A.height=1+math_max$6(C.height,D.height);B.height=1+math_max$6(A.height,E.height)}return B}return A};DynamicTree2.prototype.getHeight=function(){if(this.m_root==null){return 0}return this.m_root.height};DynamicTree2.prototype.getAreaRatio=function(){if(this.m_root==null){return 0}var root=this.m_root;var rootArea=root.aabb.getPerimeter();var totalArea=0;var node;var it=this.iteratorPool.allocate().preorder(this.m_root);while(node=it.next()){if(node.height<0){continue}totalArea+=node.aabb.getPerimeter()}this.iteratorPool.release(it);return totalArea/rootArea};DynamicTree2.prototype.computeHeight=function(id){var node;if(typeof id!=="undefined"){node=this.m_nodes[id]}else{node=this.m_root}if(node.isLeaf()){return 0}var height1=this.computeHeight(node.child1.id);var height2=this.computeHeight(node.child2.id);return 1+math_max$6(height1,height2)};DynamicTree2.prototype.validateStructure=function(node){if(node==null){return}if(node===this.m_root);var child1=node.child1;var child2=node.child2;if(node.isLeaf()){return}this.validateStructure(child1);this.validateStructure(child2)};DynamicTree2.prototype.validateMetrics=function(node){if(node==null){return}var child1=node.child1;var child2=node.child2;if(node.isLeaf()){return}child1.height;child2.height;var aabb=new AABB;aabb.combine(child1.aabb,child2.aabb);this.validateMetrics(child1);this.validateMetrics(child2)};DynamicTree2.prototype.validate=function(){return};DynamicTree2.prototype.getMaxBalance=function(){var maxBalance=0;var node;var it=this.iteratorPool.allocate().preorder(this.m_root);while(node=it.next()){if(node.height<=1){continue}var balance=math_abs$8(node.child2.height-node.child1.height);maxBalance=math_max$6(maxBalance,balance)}this.iteratorPool.release(it);return maxBalance};DynamicTree2.prototype.rebuildBottomUp=function(){var nodes=[];var count=0;var node;var it=this.iteratorPool.allocate().preorder(this.m_root);while(node=it.next()){if(node.height<0){continue}if(node.isLeaf()){node.parent=null;nodes[count]=node;++count}else{this.freeNode(node)}}this.iteratorPool.release(it);while(count>1){var minCost=Infinity;var iMin=-1;var jMin=-1;for(var i=0;i0){var node=stack.pop();if(node==null){continue}if(AABB.testOverlap(node.aabb,aabb)){if(node.isLeaf()){var proceed=queryCallback(node.id);if(proceed===false){return}}else{stack.push(node.child1);stack.push(node.child2)}}}this.stackPool.release(stack)};DynamicTree2.prototype.rayCast=function(input2,rayCastCallback){var p1=input2.p1;var p2=input2.p2;var r=Vec2.sub(p2,p1);r.normalize();var v3=Vec2.crossNumVec2(1,r);var abs_v=Vec2.abs(v3);var maxFraction=input2.maxFraction;var segmentAABB=new AABB;var t=Vec2.combine(1-maxFraction,p1,maxFraction,p2);segmentAABB.combinePoints(p1,t);var stack=this.stackPool.allocate();var subInput=this.inputPool.allocate();stack.push(this.m_root);while(stack.length>0){var node=stack.pop();if(node==null){continue}if(AABB.testOverlap(node.aabb,segmentAABB)===false){continue}var c2=node.aabb.getCenter();var h=node.aabb.getExtents();var separation=math_abs$8(Vec2.dot(v3,Vec2.sub(p1,c2)))-Vec2.dot(abs_v,h);if(separation>0){continue}if(node.isLeaf()){subInput.p1=Vec2.clone(input2.p1);subInput.p2=Vec2.clone(input2.p2);subInput.maxFraction=maxFraction;var value=rayCastCallback(subInput,node.id);if(value===0){break}else if(value>0){maxFraction=value;t=Vec2.combine(1-maxFraction,p1,maxFraction,p2);segmentAABB.combinePoints(p1,t)}}else{stack.push(node.child1);stack.push(node.child2)}}this.stackPool.release(stack);this.inputPool.release(subInput)};return DynamicTree2}();var Iterator=function(){function Iterator2(){this.parents=[];this.states=[]}Iterator2.prototype.preorder=function(root){this.parents.length=0;this.parents.push(root);this.states.length=0;this.states.push(0);return this};Iterator2.prototype.next=function(){while(this.parents.length>0){var i=this.parents.length-1;var node=this.parents[i];if(this.states[i]===0){this.states[i]=1;return node}if(this.states[i]===1){this.states[i]=2;if(node.child1){this.parents.push(node.child1);this.states.push(1);return node.child1}}if(this.states[i]===2){this.states[i]=3;if(node.child2){this.parents.push(node.child2);this.states.push(1);return node.child2}}this.parents.pop();this.states.pop()}};Iterator2.prototype.close=function(){this.parents.length=0};return Iterator2}();var math_max$5=Math.max;var math_min$6=Math.min;var BroadPhase=function(){function BroadPhase2(){var _this=this;this.m_tree=new DynamicTree;this.m_moveBuffer=[];this.query=function(aabb,queryCallback){_this.m_tree.query(aabb,queryCallback)};this.queryCallback=function(proxyId){if(proxyId===_this.m_queryProxyId){return true}var proxyIdA=math_min$6(proxyId,_this.m_queryProxyId);var proxyIdB=math_max$5(proxyId,_this.m_queryProxyId);var userDataA=_this.m_tree.getUserData(proxyIdA);var userDataB=_this.m_tree.getUserData(proxyIdB);_this.m_callback(userDataA,userDataB);return true}}BroadPhase2.prototype.getUserData=function(proxyId){return this.m_tree.getUserData(proxyId)};BroadPhase2.prototype.testOverlap=function(proxyIdA,proxyIdB){var aabbA=this.m_tree.getFatAABB(proxyIdA);var aabbB=this.m_tree.getFatAABB(proxyIdB);return AABB.testOverlap(aabbA,aabbB)};BroadPhase2.prototype.getFatAABB=function(proxyId){return this.m_tree.getFatAABB(proxyId)};BroadPhase2.prototype.getProxyCount=function(){return this.m_moveBuffer.length};BroadPhase2.prototype.getTreeHeight=function(){return this.m_tree.getHeight()};BroadPhase2.prototype.getTreeBalance=function(){return this.m_tree.getMaxBalance()};BroadPhase2.prototype.getTreeQuality=function(){return this.m_tree.getAreaRatio()};BroadPhase2.prototype.rayCast=function(input2,rayCastCallback){this.m_tree.rayCast(input2,rayCastCallback)};BroadPhase2.prototype.shiftOrigin=function(newOrigin){this.m_tree.shiftOrigin(newOrigin)};BroadPhase2.prototype.createProxy=function(aabb,userData){var proxyId=this.m_tree.createProxy(aabb,userData);this.bufferMove(proxyId);return proxyId};BroadPhase2.prototype.destroyProxy=function(proxyId){this.unbufferMove(proxyId);this.m_tree.destroyProxy(proxyId)};BroadPhase2.prototype.moveProxy=function(proxyId,aabb,displacement2){var changed=this.m_tree.moveProxy(proxyId,aabb,displacement2);if(changed){this.bufferMove(proxyId)}};BroadPhase2.prototype.touchProxy=function(proxyId){this.bufferMove(proxyId)};BroadPhase2.prototype.bufferMove=function(proxyId){this.m_moveBuffer.push(proxyId)};BroadPhase2.prototype.unbufferMove=function(proxyId){for(var i=0;i0){this.m_queryProxyId=this.m_moveBuffer.pop();if(this.m_queryProxyId===null){continue}var fatAABB=this.m_tree.getFatAABB(this.m_queryProxyId);this.m_tree.query(fatAABB,this.queryCallback)}};return BroadPhase2}();var math_sin$2=Math.sin;var math_cos$2=Math.cos;var math_sqrt$4=Math.sqrt;function vec2(x2,y){return{x:x2,y:y}}function rotation(angle){return{s:math_sin$2(angle),c:math_cos$2(angle)}}function setVec2(out,x2,y){out.x=x2;out.y=y;return out}function copyVec2(out,w){out.x=w.x;out.y=w.y;return out}function zeroVec2(out){out.x=0;out.y=0;return out}function negVec2(out){out.x=-out.x;out.y=-out.y;return out}function plusVec2(out,w){out.x+=w.x;out.y+=w.y;return out}function addVec2(out,v3,w){out.x=v3.x+w.x;out.y=v3.x+w.y;return out}function minusVec2(out,w){out.x-=w.x;out.y-=w.y;return out}function subVec2(out,v3,w){out.x=v3.x-w.x;out.y=v3.y-w.y;return out}function mulVec2(out,m){out.x*=m;out.y*=m;return out}function scaleVec2(out,m,w){out.x=m*w.x;out.y=m*w.y;return out}function plusScaleVec2(out,m,w){out.x+=m*w.x;out.y+=m*w.y;return out}function minusScaleVec2(out,m,w){out.x-=m*w.x;out.y-=m*w.y;return out}function combine2Vec2(out,am,a2,bm,b2){out.x=am*a2.x+bm*b2.x;out.y=am*a2.y+bm*b2.y;return out}function combine3Vec2(out,am,a2,bm,b2,cm,c2){out.x=am*a2.x+bm*b2.x+cm*c2.x;out.y=am*a2.y+bm*b2.y+cm*c2.y;return out}function normalizeVec2Length(out){var length=math_sqrt$4(out.x*out.x+out.y*out.y);if(length!==0){var invLength=1/length;out.x*=invLength;out.y*=invLength}return length}function normalizeVec2(out){var length=math_sqrt$4(out.x*out.x+out.y*out.y);if(length>0){var invLength=1/length;out.x*=invLength;out.y*=invLength}return out}function crossVec2Num(out,v3,w){var x2=w*v3.y;var y=-w*v3.x;out.x=x2;out.y=y;return out}function crossNumVec2(out,w,v3){var x2=-w*v3.y;var y=w*v3.x;out.x=x2;out.y=y;return out}function crossVec2Vec2(a2,b2){return a2.x*b2.y-a2.y*b2.x}function dotVec2(a2,b2){return a2.x*b2.x+a2.y*b2.y}function lengthSqrVec2(a2){return a2.x*a2.x+a2.y*a2.y}function distVec2(a2,b2){var dx=a2.x-b2.x;var dy=a2.y-b2.y;return math_sqrt$4(dx*dx+dy*dy)}function distSqrVec2(a2,b2){var dx=a2.x-b2.x;var dy=a2.y-b2.y;return dx*dx+dy*dy}function setRotAngle(out,a2){out.c=math_cos$2(a2);out.s=math_sin$2(a2);return out}function rotVec2(out,q,v3){out.x=q.c*v3.x-q.s*v3.y;out.y=q.s*v3.x+q.c*v3.y;return out}function derotVec2(out,q,v3){var x2=q.c*v3.x+q.s*v3.y;var y=-q.s*v3.x+q.c*v3.y;out.x=x2;out.y=y;return out}function rerotVec2(out,before,after,v3){var x0=before.c*v3.x+before.s*v3.y;var y0=-before.s*v3.x+before.c*v3.y;var x2=after.c*x0-after.s*y0;var y=after.s*x0+after.c*y0;out.x=x2;out.y=y;return out}function transform(x2,y,a2){return{p:vec2(x2,y),q:rotation(a2)}}function copyTransform(out,transform2){out.p.x=transform2.p.x;out.p.y=transform2.p.y;out.q.s=transform2.q.s;out.q.c=transform2.q.c;return out}function transformVec2(out,xf2,v3){var x2=xf2.q.c*v3.x-xf2.q.s*v3.y+xf2.p.x;var y=xf2.q.s*v3.x+xf2.q.c*v3.y+xf2.p.y;out.x=x2;out.y=y;return out}function detransformVec2(out,xf2,v3){var px=v3.x-xf2.p.x;var py=v3.y-xf2.p.y;var x2=xf2.q.c*px+xf2.q.s*py;var y=-xf2.q.s*px+xf2.q.c*py;out.x=x2;out.y=y;return out}function retransformVec2(out,from,to,v3){var x0=from.q.c*v3.x-from.q.s*v3.y+from.p.x;var y0=from.q.s*v3.x+from.q.c*v3.y+from.p.y;var px=x0-to.p.x;var py=y0-to.p.y;var x2=to.q.c*px+to.q.s*py;var y=-to.q.s*px+to.q.c*py;out.x=x2;out.y=y;return out}function detransformTransform(out,a2,b2){var c2=a2.q.c*b2.q.c+a2.q.s*b2.q.s;var s2=a2.q.c*b2.q.s-a2.q.s*b2.q.c;var x2=a2.q.c*(b2.p.x-a2.p.x)+a2.q.s*(b2.p.y-a2.p.y);var y=-a2.q.s*(b2.p.x-a2.p.x)+a2.q.c*(b2.p.y-a2.p.y);out.q.c=c2;out.q.s=s2;out.p.x=x2;out.p.y=y;return out}var math_sin$1=Math.sin;var math_cos$1=Math.cos;var math_atan2$1=Math.atan2;var Rot=function(){function Rot2(angle){if(!(this instanceof Rot2)){return new Rot2(angle)}if(typeof angle==="number"){this.setAngle(angle)}else if(typeof angle==="object"){this.setRot(angle)}else{this.setIdentity()}}Rot2.neo=function(angle){var obj=Object.create(Rot2.prototype);obj.setAngle(angle);return obj};Rot2.clone=function(rot){var obj=Object.create(Rot2.prototype);obj.s=rot.s;obj.c=rot.c;return obj};Rot2.identity=function(){var obj=Object.create(Rot2.prototype);obj.s=0;obj.c=1;return obj};Rot2.isValid=function(obj){if(obj===null||typeof obj==="undefined"){return false}return Number.isFinite(obj.s)&&Number.isFinite(obj.c)};Rot2.assert=function(o){};Rot2.prototype.setIdentity=function(){this.s=0;this.c=1};Rot2.prototype.set=function(angle){if(typeof angle==="object"){this.s=angle.s;this.c=angle.c}else{this.s=math_sin$1(angle);this.c=math_cos$1(angle)}};Rot2.prototype.setRot=function(angle){this.s=angle.s;this.c=angle.c};Rot2.prototype.setAngle=function(angle){this.s=math_sin$1(angle);this.c=math_cos$1(angle)};Rot2.prototype.getAngle=function(){return math_atan2$1(this.s,this.c)};Rot2.prototype.getXAxis=function(){return Vec2.neo(this.c,this.s)};Rot2.prototype.getYAxis=function(){return Vec2.neo(-this.s,this.c)};Rot2.mul=function(rot,m){if("c"in m&&"s"in m){var qr=Rot2.identity();qr.s=rot.s*m.c+rot.c*m.s;qr.c=rot.c*m.c-rot.s*m.s;return qr}else if("x"in m&&"y"in m){return Vec2.neo(rot.c*m.x-rot.s*m.y,rot.s*m.x+rot.c*m.y)}};Rot2.mulRot=function(rot,m){var qr=Rot2.identity();qr.s=rot.s*m.c+rot.c*m.s;qr.c=rot.c*m.c-rot.s*m.s;return qr};Rot2.mulVec2=function(rot,m){return Vec2.neo(rot.c*m.x-rot.s*m.y,rot.s*m.x+rot.c*m.y)};Rot2.mulSub=function(rot,v3,w){var x2=rot.c*(v3.x-w.x)-rot.s*(v3.y-w.y);var y=rot.s*(v3.x-w.x)+rot.c*(v3.y-w.y);return Vec2.neo(x2,y)};Rot2.mulT=function(rot,m){if("c"in m&&"s"in m){var qr=Rot2.identity();qr.s=rot.c*m.s-rot.s*m.c;qr.c=rot.c*m.c+rot.s*m.s;return qr}else if("x"in m&&"y"in m){return Vec2.neo(rot.c*m.x+rot.s*m.y,-rot.s*m.x+rot.c*m.y)}};Rot2.mulTRot=function(rot,m){var qr=Rot2.identity();qr.s=rot.c*m.s-rot.s*m.c;qr.c=rot.c*m.c+rot.s*m.s;return qr};Rot2.mulTVec2=function(rot,m){return Vec2.neo(rot.c*m.x+rot.s*m.y,-rot.s*m.x+rot.c*m.y)};return Rot2}();var math_atan2=Math.atan2;var math_PI$5=Math.PI;var temp$7=vec2(0,0);var Sweep=function(){function Sweep2(){this.localCenter=Vec2.zero();this.c=Vec2.zero();this.a=0;this.alpha0=0;this.c0=Vec2.zero();this.a0=0}Sweep2.prototype.recycle=function(){zeroVec2(this.localCenter);zeroVec2(this.c);this.a=0;this.alpha0=0;zeroVec2(this.c0);this.a0=0};Sweep2.prototype.setTransform=function(xf2){transformVec2(temp$7,xf2,this.localCenter);copyVec2(this.c,temp$7);copyVec2(this.c0,temp$7);this.a=this.a0=math_atan2(xf2.q.s,xf2.q.c)};Sweep2.prototype.setLocalCenter=function(localCenter2,xf2){copyVec2(this.localCenter,localCenter2);transformVec2(temp$7,xf2,this.localCenter);copyVec2(this.c,temp$7);copyVec2(this.c0,temp$7)};Sweep2.prototype.getTransform=function(xf2,beta){if(beta===void 0){beta=0}setRotAngle(xf2.q,(1-beta)*this.a0+beta*this.a);combine2Vec2(xf2.p,1-beta,this.c0,beta,this.c);minusVec2(xf2.p,rotVec2(temp$7,xf2.q,this.localCenter))};Sweep2.prototype.advance=function(alpha){var beta=(alpha-this.alpha0)/(1-this.alpha0);combine2Vec2(this.c0,beta,this.c,1-beta,this.c0);this.a0=beta*this.a+(1-beta)*this.a0;this.alpha0=alpha};Sweep2.prototype.forward=function(){this.a0=this.a;copyVec2(this.c0,this.c)};Sweep2.prototype.normalize=function(){var a0=mod(this.a0,-math_PI$5,+math_PI$5);this.a-=this.a0-a0;this.a0=a0};Sweep2.prototype.set=function(that){copyVec2(this.localCenter,that.localCenter);copyVec2(this.c,that.c);this.a=that.a;this.alpha0=that.alpha0;copyVec2(this.c0,that.c0);this.a0=that.a0};return Sweep2}();var Transform=function(){function Transform2(position,rotation2){if(!(this instanceof Transform2)){return new Transform2(position,rotation2)}this.p=Vec2.zero();this.q=Rot.identity();if(typeof position!=="undefined"){this.p.setVec2(position)}if(typeof rotation2!=="undefined"){this.q.setAngle(rotation2)}}Transform2.clone=function(xf2){var obj=Object.create(Transform2.prototype);obj.p=Vec2.clone(xf2.p);obj.q=Rot.clone(xf2.q);return obj};Transform2.neo=function(position,rotation2){var obj=Object.create(Transform2.prototype);obj.p=Vec2.clone(position);obj.q=Rot.clone(rotation2);return obj};Transform2.identity=function(){var obj=Object.create(Transform2.prototype);obj.p=Vec2.zero();obj.q=Rot.identity();return obj};Transform2.prototype.setIdentity=function(){this.p.setZero();this.q.setIdentity()};Transform2.prototype.set=function(a2,b2){if(typeof b2==="undefined"){this.p.set(a2.p);this.q.set(a2.q)}else{this.p.set(a2);this.q.set(b2)}};Transform2.prototype.setNum=function(position,rotation2){this.p.setVec2(position);this.q.setAngle(rotation2)};Transform2.prototype.setTransform=function(xf2){this.p.setVec2(xf2.p);this.q.setRot(xf2.q)};Transform2.isValid=function(obj){if(obj===null||typeof obj==="undefined"){return false}return Vec2.isValid(obj.p)&&Rot.isValid(obj.q)};Transform2.assert=function(o){};Transform2.mul=function(a2,b2){if(Array.isArray(b2)){var arr=[];for(var i=0;i0}var collideA=(that.m_filterMaskBits&this.m_filterCategoryBits)!==0;var collideB=(that.m_filterCategoryBits&this.m_filterMaskBits)!==0;var collide=collideA&&collideB;return collide};return Fixture2}();var STATIC="static";var KINEMATIC="kinematic";var DYNAMIC="dynamic";var oldCenter=vec2(0,0);var localCenter=vec2(0,0);var shift=vec2(0,0);var temp$6=vec2(0,0);var xf$2=transform(0,0,0);var BodyDefDefault={type:STATIC,position:Vec2.zero(),angle:0,linearVelocity:Vec2.zero(),angularVelocity:0,linearDamping:0,angularDamping:0,fixedRotation:false,bullet:false,gravityScale:1,allowSleep:true,awake:true,active:true,userData:null};var Body=function(){function Body2(world,def){this.style={};this.appData={};def=options(def,BodyDefDefault);this.m_world=world;this.m_awakeFlag=def.awake;this.m_autoSleepFlag=def.allowSleep;this.m_bulletFlag=def.bullet;this.m_fixedRotationFlag=def.fixedRotation;this.m_activeFlag=def.active;this.m_islandFlag=false;this.m_toiFlag=false;this.m_userData=def.userData;this.m_type=def.type;if(this.m_type==DYNAMIC){this.m_mass=1;this.m_invMass=1}else{this.m_mass=0;this.m_invMass=0}this.m_I=0;this.m_invI=0;this.m_xf=Transform.identity();this.m_xf.p.setVec2(def.position);this.m_xf.q.setAngle(def.angle);this.m_sweep=new Sweep;this.m_sweep.setTransform(this.m_xf);this.c_velocity=new Velocity;this.c_position=new Position;this.m_force=Vec2.zero();this.m_torque=0;this.m_linearVelocity=Vec2.clone(def.linearVelocity);this.m_angularVelocity=def.angularVelocity;this.m_linearDamping=def.linearDamping;this.m_angularDamping=def.angularDamping;this.m_gravityScale=def.gravityScale;this.m_sleepTime=0;this.m_jointList=null;this.m_contactList=null;this.m_fixtureList=null;this.m_prev=null;this.m_next=null;this.m_destroyed=false;if(typeof def.style==="object"&&def.style!==null){this.style=def.style}}Body2.prototype._serialize=function(){var fixtures=[];for(var f=this.m_fixtureList;f;f=f.m_next){fixtures.push(f)}return{type:this.m_type,bullet:this.m_bulletFlag,position:this.m_xf.p,angle:this.m_xf.q.getAngle(),linearVelocity:this.m_linearVelocity,angularVelocity:this.m_angularVelocity,fixtures:fixtures}};Body2._deserialize=function(data,world,restore){var body=new Body2(world,data);if(data.fixtures){for(var i=data.fixtures.length-1;i>=0;i--){var fixture=restore(Fixture,data.fixtures[i],body);body._addFixture(fixture)}}return body};Body2.prototype.isWorldLocked=function(){return this.m_world&&this.m_world.isLocked()?true:false};Body2.prototype.getWorld=function(){return this.m_world};Body2.prototype.getNext=function(){return this.m_next};Body2.prototype.setUserData=function(data){this.m_userData=data};Body2.prototype.getUserData=function(){return this.m_userData};Body2.prototype.getFixtureList=function(){return this.m_fixtureList};Body2.prototype.getJointList=function(){return this.m_jointList};Body2.prototype.getContactList=function(){return this.m_contactList};Body2.prototype.isStatic=function(){return this.m_type==STATIC};Body2.prototype.isDynamic=function(){return this.m_type==DYNAMIC};Body2.prototype.isKinematic=function(){return this.m_type==KINEMATIC};Body2.prototype.setStatic=function(){this.setType(STATIC);return this};Body2.prototype.setDynamic=function(){this.setType(DYNAMIC);return this};Body2.prototype.setKinematic=function(){this.setType(KINEMATIC);return this};Body2.prototype.getType=function(){return this.m_type};Body2.prototype.setType=function(type){if(this.isWorldLocked()==true){return}if(this.m_type==type){return}this.m_type=type;this.resetMassData();if(this.m_type==STATIC){this.m_linearVelocity.setZero();this.m_angularVelocity=0;this.m_sweep.forward();this.synchronizeFixtures()}this.setAwake(true);this.m_force.setZero();this.m_torque=0;var ce=this.m_contactList;while(ce){var ce0=ce;ce=ce.next;this.m_world.destroyContact(ce0.contact)}this.m_contactList=null;var broadPhase=this.m_world.m_broadPhase;for(var f=this.m_fixtureList;f;f=f.m_next){for(var i=0;i0){this.setAwake(true)}this.m_linearVelocity.setVec2(v3)};Body2.prototype.getAngularVelocity=function(){return this.m_angularVelocity};Body2.prototype.setAngularVelocity=function(w){if(this.m_type==STATIC){return}if(w*w>0){this.setAwake(true)}this.m_angularVelocity=w};Body2.prototype.getLinearDamping=function(){return this.m_linearDamping};Body2.prototype.setLinearDamping=function(linearDamping){this.m_linearDamping=linearDamping};Body2.prototype.getAngularDamping=function(){return this.m_angularDamping};Body2.prototype.setAngularDamping=function(angularDamping){this.m_angularDamping=angularDamping};Body2.prototype.getGravityScale=function(){return this.m_gravityScale};Body2.prototype.setGravityScale=function(scale){this.m_gravityScale=scale};Body2.prototype.getMass=function(){return this.m_mass};Body2.prototype.getInertia=function(){return this.m_I+this.m_mass*Vec2.dot(this.m_sweep.localCenter,this.m_sweep.localCenter)};Body2.prototype.getMassData=function(data){data.mass=this.m_mass;data.I=this.getInertia();copyVec2(data.center,this.m_sweep.localCenter)};Body2.prototype.resetMassData=function(){this.m_mass=0;this.m_invMass=0;this.m_I=0;this.m_invI=0;zeroVec2(this.m_sweep.localCenter);if(this.isStatic()||this.isKinematic()){copyVec2(this.m_sweep.c0,this.m_xf.p);copyVec2(this.m_sweep.c,this.m_xf.p);this.m_sweep.a0=this.m_sweep.a;return}zeroVec2(localCenter);for(var f=this.m_fixtureList;f;f=f.m_next){if(f.m_density==0){continue}var massData={mass:0,center:vec2(0,0),I:0};f.getMassData(massData);this.m_mass+=massData.mass;plusScaleVec2(localCenter,massData.mass,massData.center);this.m_I+=massData.I}if(this.m_mass>0){this.m_invMass=1/this.m_mass;scaleVec2(localCenter,this.m_invMass,localCenter)}else{this.m_mass=1;this.m_invMass=1}if(this.m_I>0&&this.m_fixedRotationFlag==false){this.m_I-=this.m_mass*dotVec2(localCenter,localCenter);this.m_invI=1/this.m_I}else{this.m_I=0;this.m_invI=0}copyVec2(oldCenter,this.m_sweep.c);this.m_sweep.setLocalCenter(localCenter,this.m_xf);subVec2(shift,this.m_sweep.c,oldCenter);crossNumVec2(temp$6,this.m_angularVelocity,shift);plusVec2(this.m_linearVelocity,temp$6)};Body2.prototype.setMassData=function(massData){if(this.isWorldLocked()==true){return}if(this.m_type!=DYNAMIC){return}this.m_invMass=0;this.m_I=0;this.m_invI=0;this.m_mass=massData.mass;if(this.m_mass<=0){this.m_mass=1}this.m_invMass=1/this.m_mass;if(massData.I>0&&this.m_fixedRotationFlag==false){this.m_I=massData.I-this.m_mass*dotVec2(massData.center,massData.center);this.m_invI=1/this.m_I}copyVec2(oldCenter,this.m_sweep.c);this.m_sweep.setLocalCenter(massData.center,this.m_xf);subVec2(shift,this.m_sweep.c,oldCenter);crossNumVec2(temp$6,this.m_angularVelocity,shift);plusVec2(this.m_linearVelocity,temp$6)};Body2.prototype.applyForce=function(force,point2,wake){if(wake===void 0){wake=true}if(this.m_type!=DYNAMIC){return}if(wake&&this.m_awakeFlag==false){this.setAwake(true)}if(this.m_awakeFlag){this.m_force.add(force);this.m_torque+=Vec2.crossVec2Vec2(Vec2.sub(point2,this.m_sweep.c),force)}};Body2.prototype.applyForceToCenter=function(force,wake){if(wake===void 0){wake=true}if(this.m_type!=DYNAMIC){return}if(wake&&this.m_awakeFlag==false){this.setAwake(true)}if(this.m_awakeFlag){this.m_force.add(force)}};Body2.prototype.applyTorque=function(torque,wake){if(wake===void 0){wake=true}if(this.m_type!=DYNAMIC){return}if(wake&&this.m_awakeFlag==false){this.setAwake(true)}if(this.m_awakeFlag){this.m_torque+=torque}};Body2.prototype.applyLinearImpulse=function(impulse,point2,wake){if(wake===void 0){wake=true}if(this.m_type!=DYNAMIC){return}if(wake&&this.m_awakeFlag==false){this.setAwake(true)}if(this.m_awakeFlag){this.m_linearVelocity.addMul(this.m_invMass,impulse);this.m_angularVelocity+=this.m_invI*Vec2.crossVec2Vec2(Vec2.sub(point2,this.m_sweep.c),impulse)}};Body2.prototype.applyAngularImpulse=function(impulse,wake){if(wake===void 0){wake=true}if(this.m_type!=DYNAMIC){return}if(wake&&this.m_awakeFlag==false){this.setAwake(true)}if(this.m_awakeFlag){this.m_angularVelocity+=this.m_invI*impulse}};Body2.prototype.shouldCollide=function(that){if(this.m_type!=DYNAMIC&&that.m_type!=DYNAMIC){return false}for(var jn=this.m_jointList;jn;jn=jn.next){if(jn.other==that){if(jn.joint.m_collideConnected==false){return false}}}return true};Body2.prototype._addFixture=function(fixture){if(this.isWorldLocked()==true){return null}if(this.m_activeFlag){var broadPhase=this.m_world.m_broadPhase;fixture.createProxies(broadPhase,this.m_xf)}fixture.m_next=this.m_fixtureList;this.m_fixtureList=fixture;if(fixture.m_density>0){this.resetMassData()}this.m_world.m_newFixture=true;return fixture};Body2.prototype.createFixture=function(shape,fixdef){if(this.isWorldLocked()==true){return null}var fixture=new Fixture(this,shape,fixdef);this._addFixture(fixture);return fixture};Body2.prototype.destroyFixture=function(fixture){if(this.isWorldLocked()==true){return}if(this.m_fixtureList===fixture){this.m_fixtureList=fixture.m_next}else{var node=this.m_fixtureList;while(node!=null){if(node.m_next===fixture){node.m_next=fixture.m_next;break}node=node.m_next}}var edge=this.m_contactList;while(edge){var c2=edge.contact;edge=edge.next;var fixtureA=c2.getFixtureA();var fixtureB=c2.getFixtureB();if(fixture==fixtureA||fixture==fixtureB){this.m_world.destroyContact(c2)}}if(this.m_activeFlag){var broadPhase=this.m_world.m_broadPhase;fixture.destroyProxies(broadPhase)}fixture.m_body=null;fixture.m_next=null;this.m_world.publish("remove-fixture",fixture);this.resetMassData()};Body2.prototype.getWorldPoint=function(localPoint){return Transform.mulVec2(this.m_xf,localPoint)};Body2.prototype.getWorldVector=function(localVector){return Rot.mulVec2(this.m_xf.q,localVector)};Body2.prototype.getLocalPoint=function(worldPoint){return Transform.mulTVec2(this.m_xf,worldPoint)};Body2.prototype.getLocalVector=function(worldVector){return Rot.mulTVec2(this.m_xf.q,worldVector)};Body2.STATIC="static";Body2.KINEMATIC="kinematic";Body2.DYNAMIC="dynamic";return Body2}();var JointEdge=function(){function JointEdge2(){this.other=null;this.joint=null;this.prev=null;this.next=null}return JointEdge2}();var Joint=function(){function Joint2(def,bodyA,bodyB){this.m_type="unknown-joint";this.m_prev=null;this.m_next=null;this.m_edgeA=new JointEdge;this.m_edgeB=new JointEdge;this.m_islandFlag=false;this.style={};this.appData={};bodyA="bodyA"in def?def.bodyA:bodyA;bodyB="bodyB"in def?def.bodyB:bodyB;this.m_bodyA=bodyA;this.m_bodyB=bodyB;this.m_collideConnected=!!def.collideConnected;this.m_userData=def.userData;if(typeof def.style==="object"&&def.style!==null){this.style=def.style}}Joint2.prototype.isActive=function(){return this.m_bodyA.isActive()&&this.m_bodyB.isActive()};Joint2.prototype.getType=function(){return this.m_type};Joint2.prototype.getBodyA=function(){return this.m_bodyA};Joint2.prototype.getBodyB=function(){return this.m_bodyB};Joint2.prototype.getNext=function(){return this.m_next};Joint2.prototype.getUserData=function(){return this.m_userData};Joint2.prototype.setUserData=function(data){this.m_userData=data};Joint2.prototype.getCollideConnected=function(){return this.m_collideConnected};Joint2.prototype.shiftOrigin=function(newOrigin){};Joint2.prototype._resetAnchors=function(def){return this._reset(def)};return Joint2}();var stats={gjkCalls:0,gjkIters:0,gjkMaxIters:0,toiTime:0,toiMaxTime:0,toiCalls:0,toiIters:0,toiMaxIters:0,toiRootIters:0,toiMaxRootIters:0,toString:function(newline){newline=typeof newline==="string"?newline:"\n";var string="";for(var name_1 in this){if(typeof this[name_1]!=="function"&&typeof this[name_1]!=="object"){string+=name_1+": "+this[name_1]+newline}}return string}};var now=function(){return Date.now()};var diff=function(time){return Date.now()-time};const Timer={now:now,diff:diff};var math_max$4=Math.max;var temp$5=vec2(0,0);var normal$4=vec2(0,0);var e12=vec2(0,0);var e13=vec2(0,0);var e23=vec2(0,0);var temp1=vec2(0,0);var temp2=vec2(0,0);stats.gjkCalls=0;stats.gjkIters=0;stats.gjkMaxIters=0;var DistanceInput=function(){function DistanceInput2(){this.proxyA=new DistanceProxy;this.proxyB=new DistanceProxy;this.transformA=Transform.identity();this.transformB=Transform.identity();this.useRadii=false}DistanceInput2.prototype.recycle=function(){this.proxyA.recycle();this.proxyB.recycle();this.transformA.setIdentity();this.transformB.setIdentity();this.useRadii=false};return DistanceInput2}();var DistanceOutput=function(){function DistanceOutput2(){this.pointA=vec2(0,0);this.pointB=vec2(0,0);this.distance=0;this.iterations=0}DistanceOutput2.prototype.recycle=function(){zeroVec2(this.pointA);zeroVec2(this.pointB);this.distance=0;this.iterations=0};return DistanceOutput2}();var SimplexCache=function(){function SimplexCache2(){this.metric=0;this.indexA=[];this.indexB=[];this.count=0}SimplexCache2.prototype.recycle=function(){this.metric=0;this.indexA.length=0;this.indexB.length=0;this.count=0};return SimplexCache2}();var Distance=function(output2,cache2,input2){++stats.gjkCalls;var proxyA=input2.proxyA;var proxyB=input2.proxyB;var xfA2=input2.transformA;var xfB2=input2.transformB;simplex.recycle();simplex.readCache(cache2,proxyA,xfA2,proxyB,xfB2);var vertices=simplex.m_v;var k_maxIters=SettingsInternal.maxDistanceIterations;var saveA=[];var saveB=[];var saveCount=0;var iter=0;while(iterrA2+rB2&&output2.distance>EPSILON){output2.distance-=rA2+rB2;subVec2(normal$4,output2.pointB,output2.pointA);normalizeVec2(normal$4);plusScaleVec2(output2.pointA,rA2,normal$4);minusScaleVec2(output2.pointB,rB2,normal$4)}else{var p=subVec2(temp$5,output2.pointA,output2.pointB);copyVec2(output2.pointA,p);copyVec2(output2.pointB,p);output2.distance=0}}};var DistanceProxy=function(){function DistanceProxy2(){this.m_vertices=[];this.m_count=0;this.m_radius=0}DistanceProxy2.prototype.recycle=function(){this.m_vertices.length=0;this.m_count=0;this.m_radius=0};DistanceProxy2.prototype.getVertexCount=function(){return this.m_count};DistanceProxy2.prototype.getVertex=function(index){return this.m_vertices[index]};DistanceProxy2.prototype.getSupport=function(d2){var bestIndex=-1;var bestValue=-Infinity;for(var i=0;ibestValue){bestIndex=i;bestValue=value}}return bestIndex};DistanceProxy2.prototype.getSupportVertex=function(d2){return this.m_vertices[this.getSupport(d2)]};DistanceProxy2.prototype.set=function(shape,index){shape.computeDistanceProxy(this,index)};DistanceProxy2.prototype.setVertices=function(vertices,count,radius){this.m_vertices=vertices;this.m_count=count;this.m_radius=radius};return DistanceProxy2}();var SimplexVertex=function(){function SimplexVertex2(){this.wA=vec2(0,0);this.indexA=0;this.wB=vec2(0,0);this.indexB=0;this.w=vec2(0,0);this.a=0}SimplexVertex2.prototype.recycle=function(){this.indexA=0;this.indexB=0;zeroVec2(this.wA);zeroVec2(this.wB);zeroVec2(this.w);this.a=0};SimplexVertex2.prototype.set=function(v3){this.indexA=v3.indexA;this.indexB=v3.indexB;copyVec2(this.wA,v3.wA);copyVec2(this.wB,v3.wB);copyVec2(this.w,v3.w);this.a=v3.a};return SimplexVertex2}();var searchDirection_reuse=vec2(0,0);var closestPoint_reuse=vec2(0,0);var Simplex=function(){function Simplex2(){this.m_v1=new SimplexVertex;this.m_v2=new SimplexVertex;this.m_v3=new SimplexVertex;this.m_v=[this.m_v1,this.m_v2,this.m_v3]}Simplex2.prototype.recycle=function(){this.m_v1.recycle();this.m_v2.recycle();this.m_v3.recycle();this.m_count=0};Simplex2.prototype.toString=function(){if(this.m_count===3){return["+"+this.m_count,this.m_v1.a,this.m_v1.wA.x,this.m_v1.wA.y,this.m_v1.wB.x,this.m_v1.wB.y,this.m_v2.a,this.m_v2.wA.x,this.m_v2.wA.y,this.m_v2.wB.x,this.m_v2.wB.y,this.m_v3.a,this.m_v3.wA.x,this.m_v3.wA.y,this.m_v3.wB.x,this.m_v3.wB.y].toString()}else if(this.m_count===2){return["+"+this.m_count,this.m_v1.a,this.m_v1.wA.x,this.m_v1.wA.y,this.m_v1.wB.x,this.m_v1.wB.y,this.m_v2.a,this.m_v2.wA.x,this.m_v2.wA.y,this.m_v2.wB.x,this.m_v2.wB.y].toString()}else if(this.m_count===1){return["+"+this.m_count,this.m_v1.a,this.m_v1.wA.x,this.m_v1.wA.y,this.m_v1.wB.x,this.m_v1.wB.y].toString()}else{return"+"+this.m_count}};Simplex2.prototype.readCache=function(cache2,proxyA,transformA,proxyB,transformB){this.m_count=cache2.count;for(var i=0;i1){var metric1=cache2.metric;var metric2=this.getMetric();if(metric2<.5*metric1||2*metric10){return setVec2(searchDirection_reuse,-e12.y,e12.x)}else{return setVec2(searchDirection_reuse,e12.y,-e12.x)}}default:return zeroVec2(searchDirection_reuse)}};Simplex2.prototype.getClosestPoint=function(){var v13=this.m_v1;var v22=this.m_v2;this.m_v3;switch(this.m_count){case 0:return zeroVec2(closestPoint_reuse);case 1:return copyVec2(closestPoint_reuse,v13.w);case 2:return combine2Vec2(closestPoint_reuse,v13.a,v13.w,v22.a,v22.w);case 3:return zeroVec2(closestPoint_reuse);default:return zeroVec2(closestPoint_reuse)}};Simplex2.prototype.getWitnessPoints=function(pA2,pB2){var v13=this.m_v1;var v22=this.m_v2;var v3=this.m_v3;switch(this.m_count){case 0:break;case 1:copyVec2(pA2,v13.wA);copyVec2(pB2,v13.wB);break;case 2:combine2Vec2(pA2,v13.a,v13.wA,v22.a,v22.wA);combine2Vec2(pB2,v13.a,v13.wB,v22.a,v22.wB);break;case 3:combine3Vec2(pA2,v13.a,v13.wA,v22.a,v22.wA,v3.a,v3.wA);copyVec2(pB2,pA2);break}};Simplex2.prototype.getMetric=function(){switch(this.m_count){case 0:return 0;case 1:return 0;case 2:return distVec2(this.m_v1.w,this.m_v2.w);case 3:return crossVec2Vec2(subVec2(temp1,this.m_v2.w,this.m_v1.w),subVec2(temp2,this.m_v3.w,this.m_v1.w));default:return 0}};Simplex2.prototype.solve=function(){switch(this.m_count){case 1:break;case 2:this.solve2();break;case 3:this.solve3();break}};Simplex2.prototype.solve2=function(){var w1=this.m_v1.w;var w2=this.m_v2.w;subVec2(e12,w2,w1);var d12_2=-dotVec2(w1,e12);if(d12_2<=0){this.m_v1.a=1;this.m_count=1;return}var d12_1=dotVec2(w2,e12);if(d12_1<=0){this.m_v2.a=1;this.m_count=1;this.m_v1.set(this.m_v2);return}var inv_d12=1/(d12_1+d12_2);this.m_v1.a=d12_1*inv_d12;this.m_v2.a=d12_2*inv_d12;this.m_count=2};Simplex2.prototype.solve3=function(){var w1=this.m_v1.w;var w2=this.m_v2.w;var w3=this.m_v3.w;subVec2(e12,w2,w1);var w1e12=dotVec2(w1,e12);var w2e12=dotVec2(w2,e12);var d12_1=w2e12;var d12_2=-w1e12;subVec2(e13,w3,w1);var w1e13=dotVec2(w1,e13);var w3e13=dotVec2(w3,e13);var d13_1=w3e13;var d13_2=-w1e13;subVec2(e23,w3,w2);var w2e23=dotVec2(w2,e23);var w3e23=dotVec2(w3,e23);var d23_1=w3e23;var d23_2=-w2e23;var n123=crossVec2Vec2(e12,e13);var d123_1=n123*crossVec2Vec2(w2,w3);var d123_2=n123*crossVec2Vec2(w3,w1);var d123_3=n123*crossVec2Vec2(w1,w2);if(d12_2<=0&&d13_2<=0){this.m_v1.a=1;this.m_count=1;return}if(d12_1>0&&d12_2>0&&d123_3<=0){var inv_d12=1/(d12_1+d12_2);this.m_v1.a=d12_1*inv_d12;this.m_v2.a=d12_2*inv_d12;this.m_count=2;return}if(d13_1>0&&d13_2>0&&d123_2<=0){var inv_d13=1/(d13_1+d13_2);this.m_v1.a=d13_1*inv_d13;this.m_v3.a=d13_2*inv_d13;this.m_count=2;this.m_v2.set(this.m_v3);return}if(d12_1<=0&&d23_2<=0){this.m_v2.a=1;this.m_count=1;this.m_v1.set(this.m_v2);return}if(d13_1<=0&&d23_1<=0){this.m_v3.a=1;this.m_count=1;this.m_v1.set(this.m_v3);return}if(d23_1>0&&d23_2>0&&d123_1<=0){var inv_d23=1/(d23_1+d23_2);this.m_v2.a=d23_1*inv_d23;this.m_v3.a=d23_2*inv_d23;this.m_count=2;this.m_v1.set(this.m_v3);return}var inv_d123=1/(d123_1+d123_2+d123_3);this.m_v1.a=d123_1*inv_d123;this.m_v2.a=d123_2*inv_d123;this.m_v3.a=d123_3*inv_d123;this.m_count=3};return Simplex2}();var simplex=new Simplex;var input$1=new DistanceInput;var cache$1=new SimplexCache;var output$1=new DistanceOutput;var testOverlap=function(shapeA,indexA,shapeB,indexB,xfA2,xfB2){input$1.recycle();input$1.proxyA.set(shapeA,indexA);input$1.proxyB.set(shapeB,indexB);copyTransform(input$1.transformA,xfA2);copyTransform(input$1.transformB,xfB2);input$1.useRadii=true;output$1.recycle();cache$1.recycle();Distance(output$1,cache$1,input$1);return output$1.distance<10*EPSILON};Distance.testOverlap=testOverlap;Distance.Input=DistanceInput;Distance.Output=DistanceOutput;Distance.Proxy=DistanceProxy;Distance.Cache=SimplexCache;var ShapeCastInput=function(){function ShapeCastInput2(){this.proxyA=new DistanceProxy;this.proxyB=new DistanceProxy;this.transformA=Transform.identity();this.transformB=Transform.identity();this.translationB=Vec2.zero()}ShapeCastInput2.prototype.recycle=function(){this.proxyA.recycle();this.proxyB.recycle();this.transformA.setIdentity();this.transformB.setIdentity();zeroVec2(this.translationB)};return ShapeCastInput2}();var ShapeCastOutput=function(){function ShapeCastOutput2(){this.point=Vec2.zero();this.normal=Vec2.zero();this.lambda=1;this.iterations=0}return ShapeCastOutput2}();var ShapeCast=function(output2,input2){output2.iterations=0;output2.lambda=1;output2.normal.setZero();output2.point.setZero();var proxyA=input2.proxyA;var proxyB=input2.proxyB;var radiusA=math_max$4(proxyA.m_radius,SettingsInternal.polygonRadius);var radiusB=math_max$4(proxyB.m_radius,SettingsInternal.polygonRadius);var radius=radiusA+radiusB;var xfA2=input2.transformA;var xfB2=input2.transformB;var r=input2.translationB;var n2=Vec2.zero();var lambda=0;var simplex2=new Simplex;simplex2.m_count=0;var vertices=simplex2.m_v;var indexA=proxyA.getSupport(Rot.mulTVec2(xfA2.q,Vec2.neg(r)));var wA=Transform.mulVec2(xfA2,proxyA.getVertex(indexA));var indexB=proxyB.getSupport(Rot.mulTVec2(xfB2.q,r));var wB=Transform.mulVec2(xfB2,proxyB.getVertex(indexB));var v3=Vec2.sub(wA,wB);var sigma=math_max$4(SettingsInternal.polygonRadius,radius-SettingsInternal.polygonRadius);var tolerance=.5*SettingsInternal.linearSlop;var k_maxIters=20;var iter=0;while(itertolerance){output2.iterations+=1;indexA=proxyA.getSupport(Rot.mulTVec2(xfA2.q,Vec2.neg(v3)));wA=Transform.mulVec2(xfA2,proxyA.getVertex(indexA));indexB=proxyB.getSupport(Rot.mulTVec2(xfB2.q,v3));wB=Transform.mulVec2(xfB2,proxyB.getVertex(indexB));var p=Vec2.sub(wA,wB);v3.normalize();var vp=Vec2.dot(v3,p);var vr=Vec2.dot(v3,r);if(vp-sigma>lambda*vr){if(vr<=0){return false}lambda=(vp-sigma)/vr;if(lambda>1){return false}n2.setMul(-1,v3);simplex2.m_count=0}var vertex=vertices[simplex2.m_count];vertex.indexA=indexB;vertex.wA=Vec2.combine(1,wB,lambda,r);vertex.indexB=indexA;vertex.wB=wA;vertex.w=Vec2.sub(vertex.wB,vertex.wA);vertex.a=1;simplex2.m_count+=1;switch(simplex2.m_count){case 1:break;case 2:simplex2.solve2();break;case 3:simplex2.solve3();break}if(simplex2.m_count==3){return false}v3.setVec2(simplex2.getClosestPoint());++iter}if(iter==0){return false}var pointA2=Vec2.zero();var pointB2=Vec2.zero();simplex2.getWitnessPoints(pointB2,pointA2);if(v3.lengthSquared()>0){n2.setMul(-1,v3);n2.normalize()}output2.point=Vec2.combine(1,pointA2,radiusA,n2);output2.normal=n2;output2.lambda=lambda;output2.iterations=iter;return true};var math_abs$7=Math.abs;var math_max$3=Math.max;var TOIInput=function(){function TOIInput2(){this.proxyA=new DistanceProxy;this.proxyB=new DistanceProxy;this.sweepA=new Sweep;this.sweepB=new Sweep}TOIInput2.prototype.recycle=function(){this.proxyA.recycle();this.proxyB.recycle();this.sweepA.recycle();this.sweepB.recycle();this.tMax=-1};return TOIInput2}();exports2.TOIOutputState=void 0;(function(TOIOutputState2){TOIOutputState2[TOIOutputState2["e_unset"]=-1]="e_unset";TOIOutputState2[TOIOutputState2["e_unknown"]=0]="e_unknown";TOIOutputState2[TOIOutputState2["e_failed"]=1]="e_failed";TOIOutputState2[TOIOutputState2["e_overlapped"]=2]="e_overlapped";TOIOutputState2[TOIOutputState2["e_touching"]=3]="e_touching";TOIOutputState2[TOIOutputState2["e_separated"]=4]="e_separated"})(exports2.TOIOutputState||(exports2.TOIOutputState={}));var TOIOutput=function(){function TOIOutput2(){this.state=exports2.TOIOutputState.e_unset;this.t=-1}TOIOutput2.prototype.recycle=function(){this.state=exports2.TOIOutputState.e_unset;this.t=-1};return TOIOutput2}();stats.toiTime=0;stats.toiMaxTime=0;stats.toiCalls=0;stats.toiIters=0;stats.toiMaxIters=0;stats.toiRootIters=0;stats.toiMaxRootIters=0;var distanceInput=new DistanceInput;var distanceOutput=new DistanceOutput;var cache=new SimplexCache;var xfA$1=transform(0,0,0);var xfB$1=transform(0,0,0);var temp$4=vec2(0,0);var pointA$2=vec2(0,0);var pointB$2=vec2(0,0);var normal$3=vec2(0,0);var axisA=vec2(0,0);var axisB=vec2(0,0);var localPointA=vec2(0,0);var localPointB=vec2(0,0);var TimeOfImpact=function(output2,input2){var timer=Timer.now();++stats.toiCalls;output2.state=exports2.TOIOutputState.e_unknown;output2.t=input2.tMax;var proxyA=input2.proxyA;var proxyB=input2.proxyB;var sweepA=input2.sweepA;var sweepB=input2.sweepB;sweepA.normalize();sweepB.normalize();var tMax=input2.tMax;var totalRadius=proxyA.m_radius+proxyB.m_radius;var target=math_max$3(SettingsInternal.linearSlop,totalRadius-3*SettingsInternal.linearSlop);var tolerance=.25*SettingsInternal.linearSlop;var t1=0;var k_maxIterations=SettingsInternal.maxTOIIterations;var iter=0;cache.recycle();distanceInput.proxyA.setVertices(proxyA.m_vertices,proxyA.m_count,proxyA.m_radius);distanceInput.proxyB.setVertices(proxyB.m_vertices,proxyB.m_count,proxyB.m_radius);distanceInput.useRadii=false;while(true){sweepA.getTransform(xfA$1,t1);sweepB.getTransform(xfB$1,t1);copyTransform(distanceInput.transformA,xfA$1);copyTransform(distanceInput.transformB,xfB$1);Distance(distanceOutput,cache,distanceInput);if(distanceOutput.distance<=0){output2.state=exports2.TOIOutputState.e_overlapped;output2.t=0;break}if(distanceOutput.distancetarget+tolerance){output2.state=exports2.TOIOutputState.e_separated;output2.t=tMax;done=true;break}if(s2>target-tolerance){t1=t2;break}var s1=separationFunction.evaluate(t1);if(s1target){a1=t;s1=s3}else{a2=t;s2=s3}if(rootIterCount===50){break}}stats.toiMaxRootIters=math_max$3(stats.toiMaxRootIters,rootIterCount);++pushBackIter;if(pushBackIter===SettingsInternal.maxPolygonVertices){break}}++iter;++stats.toiIters;if(done){break}if(iter===k_maxIterations){output2.state=exports2.TOIOutputState.e_failed;output2.t=t1;break}}stats.toiMaxIters=math_max$3(stats.toiMaxIters,iter);var time=Timer.diff(timer);stats.toiMaxTime=math_max$3(stats.toiMaxTime,time);stats.toiTime+=time;separationFunction.recycle()};var SeparationFunctionType;(function(SeparationFunctionType2){SeparationFunctionType2[SeparationFunctionType2["e_unset"]=-1]="e_unset";SeparationFunctionType2[SeparationFunctionType2["e_points"]=1]="e_points";SeparationFunctionType2[SeparationFunctionType2["e_faceA"]=2]="e_faceA";SeparationFunctionType2[SeparationFunctionType2["e_faceB"]=3]="e_faceB"})(SeparationFunctionType||(SeparationFunctionType={}));var SeparationFunction=function(){function SeparationFunction2(){this.m_proxyA=null;this.m_proxyB=null;this.m_sweepA=null;this.m_sweepB=null;this.m_type=SeparationFunctionType.e_unset;this.m_localPoint=vec2(0,0);this.m_axis=vec2(0,0);this.indexA=-1;this.indexB=-1}SeparationFunction2.prototype.recycle=function(){this.m_proxyA=null;this.m_proxyB=null;this.m_sweepA=null;this.m_sweepB=null;this.m_type=SeparationFunctionType.e_unset;zeroVec2(this.m_localPoint);zeroVec2(this.m_axis);this.indexA=-1;this.indexB=-1};SeparationFunction2.prototype.initialize=function(cache2,proxyA,sweepA,proxyB,sweepB,t1){var count=cache2.count;this.m_proxyA=proxyA;this.m_proxyB=proxyB;this.m_sweepA=sweepA;this.m_sweepB=sweepB;this.m_sweepA.getTransform(xfA$1,t1);this.m_sweepB.getTransform(xfB$1,t1);if(count===1){this.m_type=SeparationFunctionType.e_points;var localPointA_1=this.m_proxyA.getVertex(cache2.indexA[0]);var localPointB_1=this.m_proxyB.getVertex(cache2.indexB[0]);transformVec2(pointA$2,xfA$1,localPointA_1);transformVec2(pointB$2,xfB$1,localPointB_1);subVec2(this.m_axis,pointB$2,pointA$2);var s2=normalizeVec2Length(this.m_axis);return s2}else if(cache2.indexA[0]===cache2.indexA[1]){this.m_type=SeparationFunctionType.e_faceB;var localPointB1=proxyB.getVertex(cache2.indexB[0]);var localPointB2=proxyB.getVertex(cache2.indexB[1]);crossVec2Num(this.m_axis,subVec2(temp$4,localPointB2,localPointB1),1);normalizeVec2(this.m_axis);rotVec2(normal$3,xfB$1.q,this.m_axis);combine2Vec2(this.m_localPoint,.5,localPointB1,.5,localPointB2);transformVec2(pointB$2,xfB$1,this.m_localPoint);var localPointA_2=proxyA.getVertex(cache2.indexA[0]);var pointA_1=Transform.mulVec2(xfA$1,localPointA_2);var s2=dotVec2(pointA_1,normal$3)-dotVec2(pointB$2,normal$3);if(s2<0){negVec2(this.m_axis);s2=-s2}return s2}else{this.m_type=SeparationFunctionType.e_faceA;var localPointA1=this.m_proxyA.getVertex(cache2.indexA[0]);var localPointA2=this.m_proxyA.getVertex(cache2.indexA[1]);crossVec2Num(this.m_axis,subVec2(temp$4,localPointA2,localPointA1),1);normalizeVec2(this.m_axis);rotVec2(normal$3,xfA$1.q,this.m_axis);combine2Vec2(this.m_localPoint,.5,localPointA1,.5,localPointA2);transformVec2(pointA$2,xfA$1,this.m_localPoint);var localPointB_2=this.m_proxyB.getVertex(cache2.indexB[0]);transformVec2(pointB$2,xfB$1,localPointB_2);var s2=dotVec2(pointB$2,normal$3)-dotVec2(pointA$2,normal$3);if(s2<0){negVec2(this.m_axis);s2=-s2}return s2}};SeparationFunction2.prototype.compute=function(find,t){this.m_sweepA.getTransform(xfA$1,t);this.m_sweepB.getTransform(xfB$1,t);switch(this.m_type){case SeparationFunctionType.e_points:{if(find){derotVec2(axisA,xfA$1.q,this.m_axis);derotVec2(axisB,xfB$1.q,scaleVec2(temp$4,-1,this.m_axis));this.indexA=this.m_proxyA.getSupport(axisA);this.indexB=this.m_proxyB.getSupport(axisB)}copyVec2(localPointA,this.m_proxyA.getVertex(this.indexA));copyVec2(localPointB,this.m_proxyB.getVertex(this.indexB));transformVec2(pointA$2,xfA$1,localPointA);transformVec2(pointB$2,xfB$1,localPointB);var sep=dotVec2(pointB$2,this.m_axis)-dotVec2(pointA$2,this.m_axis);return sep}case SeparationFunctionType.e_faceA:{rotVec2(normal$3,xfA$1.q,this.m_axis);transformVec2(pointA$2,xfA$1,this.m_localPoint);if(find){derotVec2(axisB,xfB$1.q,scaleVec2(temp$4,-1,normal$3));this.indexA=-1;this.indexB=this.m_proxyB.getSupport(axisB)}copyVec2(localPointB,this.m_proxyB.getVertex(this.indexB));transformVec2(pointB$2,xfB$1,localPointB);var sep=dotVec2(pointB$2,normal$3)-dotVec2(pointA$2,normal$3);return sep}case SeparationFunctionType.e_faceB:{rotVec2(normal$3,xfB$1.q,this.m_axis);transformVec2(pointB$2,xfB$1,this.m_localPoint);if(find){derotVec2(axisA,xfA$1.q,scaleVec2(temp$4,-1,normal$3));this.indexB=-1;this.indexA=this.m_proxyA.getSupport(axisA)}copyVec2(localPointA,this.m_proxyA.getVertex(this.indexA));transformVec2(pointA$2,xfA$1,localPointA);var sep=dotVec2(pointA$2,normal$3)-dotVec2(pointB$2,normal$3);return sep}default:if(find){this.indexA=-1;this.indexB=-1}return 0}};SeparationFunction2.prototype.findMinSeparation=function(t){return this.compute(true,t)};SeparationFunction2.prototype.evaluate=function(t){return this.compute(false,t)};return SeparationFunction2}();var separationFunction=new SeparationFunction;TimeOfImpact.Input=TOIInput;TimeOfImpact.Output=TOIOutput;var math_abs$6=Math.abs;var math_sqrt$3=Math.sqrt;var math_min$5=Math.min;var TimeStep=function(){function TimeStep2(){this.dt=0;this.inv_dt=0;this.velocityIterations=0;this.positionIterations=0;this.warmStarting=false;this.blockSolve=true;this.inv_dt0=0;this.dtRatio=1}TimeStep2.prototype.reset=function(dt){if(this.dt>0){this.inv_dt0=this.inv_dt}this.dt=dt;this.inv_dt=dt==0?0:1/dt;this.dtRatio=dt*this.inv_dt0};return TimeStep2}();var s_subStep=new TimeStep;var c=vec2(0,0);var v=vec2(0,0);var translation=vec2(0,0);var input=new TOIInput;var output=new TOIOutput;var backup=new Sweep;var backup1=new Sweep;var backup2=new Sweep;var ContactImpulse=function(){function ContactImpulse2(contact){this.contact=contact;this.normals=[];this.tangents=[]}ContactImpulse2.prototype.recycle=function(){this.normals.length=0;this.tangents.length=0};Object.defineProperty(ContactImpulse2.prototype,"normalImpulses",{get:function(){var contact=this.contact;var normals=this.normals;normals.length=0;for(var p=0;p0){var b2=stack.pop();this.addBody(b2);b2.m_awakeFlag=true;if(b2.isStatic()){continue}for(var ce=b2.m_contactList;ce;ce=ce.next){var contact=ce.contact;if(contact.m_islandFlag){continue}if(contact.isEnabled()==false||contact.isTouching()==false){continue}var sensorA=contact.m_fixtureA.m_isSensor;var sensorB=contact.m_fixtureB.m_isSensor;if(sensorA||sensorB){continue}this.addContact(contact);contact.m_islandFlag=true;var other=ce.other;if(other.m_islandFlag){continue}stack.push(other);other.m_islandFlag=true}for(var je=b2.m_jointList;je;je=je.next){if(je.joint.m_islandFlag==true){continue}var other=je.other;if(other.isActive()==false){continue}this.addJoint(je.joint);je.joint.m_islandFlag=true;if(other.m_islandFlag){continue}stack.push(other);other.m_islandFlag=true}}this.solveIsland(step);for(var i=0;iSettingsInternal.maxTranslationSquared){var ratio=SettingsInternal.maxTranslation/math_sqrt$3(translationLengthSqr);mulVec2(v,ratio)}var rotation2=h*w;if(rotation2*rotation2>SettingsInternal.maxRotationSquared){var ratio=SettingsInternal.maxRotation/math_abs$6(rotation2);w*=ratio}plusScaleVec2(c,h,v);a2+=h*w;copyVec2(body.c_position.c,c);body.c_position.a=a2;copyVec2(body.c_velocity.v,v);body.c_velocity.w=w}var positionSolved=false;for(var i=0;i=-3*SettingsInternal.linearSlop;var jointsOkay=true;for(var j=0;jangTolSqr||lengthSqrVec2(body.m_linearVelocity)>linTolSqr){body.m_sleepTime=0;minSleepTime=0}else{body.m_sleepTime+=h;minSleepTime=math_min$5(minSleepTime,body.m_sleepTime)}}if(minSleepTime>=SettingsInternal.timeToSleep&&positionSolved){for(var i=0;iSettingsInternal.maxSubSteps){continue}var alpha=1;if(c_3.m_toiFlag){alpha=c_3.m_toi}else{var fA_1=c_3.getFixtureA();var fB_1=c_3.getFixtureB();if(fA_1.isSensor()||fB_1.isSensor()){continue}var bA_1=fA_1.getBody();var bB_1=fB_1.getBody();var activeA=bA_1.isAwake()&&!bA_1.isStatic();var activeB=bB_1.isAwake()&&!bB_1.isStatic();if(activeA==false&&activeB==false){continue}var collideA=bA_1.isBullet()||!bA_1.isDynamic();var collideB=bB_1.isBullet()||!bB_1.isDynamic();if(collideA==false&&collideB==false){continue}var alpha0=bA_1.m_sweep.alpha0;if(bA_1.m_sweep.alpha0=-1.5*SettingsInternal.linearSlop;if(contactsOkay){break}}var i;copyVec2(toiA.m_sweep.c0,toiA.c_position.c);toiA.m_sweep.a0=toiA.c_position.a;copyVec2(toiB.m_sweep.c0,toiB.c_position.c);toiB.m_sweep.a0=toiB.c_position.a;for(var i=0;iSettingsInternal.maxTranslationSquared){var ratio=SettingsInternal.maxTranslation/math_sqrt$3(translationLengthSqr);mulVec2(v,ratio)}var rotation2=h*w;if(rotation2*rotation2>SettingsInternal.maxRotationSquared){var ratio=SettingsInternal.maxRotation/math_abs$6(rotation2);w*=ratio}plusScaleVec2(c,h,v);a2+=h*w;copyVec2(body.c_position.c,c);body.c_position.a=a2;copyVec2(body.c_velocity.v,v);body.c_velocity.w=w;copyVec2(body.m_sweep.c,c);body.m_sweep.a=a2;copyVec2(body.m_linearVelocity,v);body.m_angularVelocity=w;body.synchronizeTransform()}this.postSolveIsland()};Solver2.prototype.postSolveIsland=function(){for(var c_5=0;c_5EPSILON*EPSILON){var length_1=math_sqrt$2(lengthSqr);scaleVec2(normal3,1/length_1,dist)}combine2Vec2(cA$1,1,pointA$1,radiusA,normal3);combine2Vec2(cB$1,1,pointB$1,-radiusB,normal3);combine2Vec2(points[0],.5,cA$1,.5,cB$1);separations[0]=dotVec2(subVec2(temp$3,cB$1,cA$1),normal3);break}case exports2.ManifoldType.e_faceA:{rotVec2(normal3,xfA2.q,this.localNormal);transformVec2(planePoint$2,xfA2,this.localPoint);for(var i=0;irestitution2?restitution1:restitution2}var s_registers=[];var VelocityConstraintPoint=function(){function VelocityConstraintPoint2(){this.rA=vec2(0,0);this.rB=vec2(0,0);this.normalImpulse=0;this.tangentImpulse=0;this.normalMass=0;this.tangentMass=0;this.velocityBias=0}VelocityConstraintPoint2.prototype.recycle=function(){zeroVec2(this.rA);zeroVec2(this.rB);this.normalImpulse=0;this.tangentImpulse=0;this.normalMass=0;this.tangentMass=0;this.velocityBias=0};return VelocityConstraintPoint2}();var cA=vec2(0,0);var vA=vec2(0,0);var cB=vec2(0,0);var vB=vec2(0,0);var tangent$1=vec2(0,0);var xfA=transform(0,0,0);var xfB=transform(0,0,0);var pointA=vec2(0,0);var pointB=vec2(0,0);var clipPoint=vec2(0,0);var planePoint$1=vec2(0,0);var rA=vec2(0,0);var rB=vec2(0,0);var P$1=vec2(0,0);var normal$2=vec2(0,0);var point=vec2(0,0);var dv=vec2(0,0);var dv1=vec2(0,0);var dv2=vec2(0,0);var b=vec2(0,0);var a=vec2(0,0);var x=vec2(0,0);var d=vec2(0,0);var P1=vec2(0,0);var P2=vec2(0,0);var temp$2=vec2(0,0);var Contact=function(){function Contact2(){this.m_nodeA=new ContactEdge(this);this.m_nodeB=new ContactEdge(this);this.m_fixtureA=null;this.m_fixtureB=null;this.m_indexA=-1;this.m_indexB=-1;this.m_evaluateFcn=null;this.m_manifold=new Manifold;this.m_prev=null;this.m_next=null;this.m_toi=1;this.m_toiCount=0;this.m_toiFlag=false;this.m_friction=0;this.m_restitution=0;this.m_tangentSpeed=0;this.m_enabledFlag=true;this.m_islandFlag=false;this.m_touchingFlag=false;this.m_filterFlag=false;this.m_bulletHitFlag=false;this.m_impulse=new ContactImpulse(this);this.v_points=[new VelocityConstraintPoint,new VelocityConstraintPoint];this.v_normal=vec2(0,0);this.v_normalMass=new Mat22;this.v_K=new Mat22;this.v_pointCount=0;this.v_tangentSpeed=0;this.v_friction=0;this.v_restitution=0;this.v_invMassA=0;this.v_invMassB=0;this.v_invIA=0;this.v_invIB=0;this.p_localPoints=[vec2(0,0),vec2(0,0)];this.p_localNormal=vec2(0,0);this.p_localPoint=vec2(0,0);this.p_localCenterA=vec2(0,0);this.p_localCenterB=vec2(0,0);this.p_type=exports2.ManifoldType.e_unset;this.p_radiusA=0;this.p_radiusB=0;this.p_pointCount=0;this.p_invMassA=0;this.p_invMassB=0;this.p_invIA=0;this.p_invIB=0}Contact2.prototype.initialize=function(fA,indexA,fB,indexB,evaluateFcn){this.m_fixtureA=fA;this.m_fixtureB=fB;this.m_indexA=indexA;this.m_indexB=indexB;this.m_evaluateFcn=evaluateFcn;this.m_friction=mixFriction(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction);this.m_restitution=mixRestitution(this.m_fixtureA.m_restitution,this.m_fixtureB.m_restitution)};Contact2.prototype.recycle=function(){this.m_nodeA.recycle();this.m_nodeB.recycle();this.m_fixtureA=null;this.m_fixtureB=null;this.m_indexA=-1;this.m_indexB=-1;this.m_evaluateFcn=null;this.m_manifold.recycle();this.m_prev=null;this.m_next=null;this.m_toi=1;this.m_toiCount=0;this.m_toiFlag=false;this.m_friction=0;this.m_restitution=0;this.m_tangentSpeed=0;this.m_enabledFlag=true;this.m_islandFlag=false;this.m_touchingFlag=false;this.m_filterFlag=false;this.m_bulletHitFlag=false;this.m_impulse.recycle();for(var _i=0,_a2=this.v_points;_i<_a2.length;_i++){var point_1=_a2[_i];point_1.recycle()}zeroVec2(this.v_normal);this.v_normalMass.setZero();this.v_K.setZero();this.v_pointCount=0;this.v_tangentSpeed=0;this.v_friction=0;this.v_restitution=0;this.v_invMassA=0;this.v_invMassB=0;this.v_invIA=0;this.v_invIB=0;for(var _b=0,_c=this.p_localPoints;_b<_c.length;_b++){var point_2=_c[_b];zeroVec2(point_2)}zeroVec2(this.p_localNormal);zeroVec2(this.p_localPoint);zeroVec2(this.p_localCenterA);zeroVec2(this.p_localCenterB);this.p_type=exports2.ManifoldType.e_unset;this.p_radiusA=0;this.p_radiusB=0;this.p_pointCount=0;this.p_invMassA=0;this.p_invMassB=0;this.p_invIA=0;this.p_invIB=0};Contact2.prototype.initConstraint=function(step){var fixtureA=this.m_fixtureA;var fixtureB=this.m_fixtureB;if(fixtureA===null||fixtureB===null)return;var bodyA=fixtureA.m_body;var bodyB=fixtureB.m_body;if(bodyA===null||bodyB===null)return;var shapeA=fixtureA.m_shape;var shapeB=fixtureB.m_shape;if(shapeA===null||shapeB===null)return;var manifold=this.m_manifold;var pointCount=manifold.pointCount;this.v_invMassA=bodyA.m_invMass;this.v_invMassB=bodyB.m_invMass;this.v_invIA=bodyA.m_invI;this.v_invIB=bodyB.m_invI;this.v_friction=this.m_friction;this.v_restitution=this.m_restitution;this.v_tangentSpeed=this.m_tangentSpeed;this.v_pointCount=pointCount;this.v_K.setZero();this.v_normalMass.setZero();this.p_invMassA=bodyA.m_invMass;this.p_invMassB=bodyB.m_invMass;this.p_invIA=bodyA.m_invI;this.p_invIB=bodyB.m_invI;copyVec2(this.p_localCenterA,bodyA.m_sweep.localCenter);copyVec2(this.p_localCenterB,bodyB.m_sweep.localCenter);this.p_radiusA=shapeA.m_radius;this.p_radiusB=shapeB.m_radius;this.p_type=manifold.type;copyVec2(this.p_localNormal,manifold.localNormal);copyVec2(this.p_localPoint,manifold.localPoint);this.p_pointCount=pointCount;for(var j=0;j0;for(var i=0;i0?-C/K:0;scaleVec2(P$1,impulse,normal$2);minusScaleVec2(cA,mA,P$1);aA-=iA*crossVec2Vec2(rA,P$1);plusScaleVec2(cB,mB,P$1);aB+=iB*crossVec2Vec2(rB,P$1)}copyVec2(positionA.c,cA);positionA.a=aA;copyVec2(positionB.c,cB);positionB.a=aB;return minSeparation};Contact2.prototype.initVelocityConstraint=function(step){var fixtureA=this.m_fixtureA;var fixtureB=this.m_fixtureB;if(fixtureA===null||fixtureB===null)return;var bodyA=fixtureA.m_body;var bodyB=fixtureB.m_body;if(bodyA===null||bodyB===null)return;var velocityA=bodyA.c_velocity;var velocityB=bodyB.c_velocity;var positionA=bodyA.c_position;var positionB=bodyB.c_position;var radiusA=this.p_radiusA;var radiusB=this.p_radiusB;var manifold=this.m_manifold;var mA=this.v_invMassA;var mB=this.v_invMassB;var iA=this.v_invIA;var iB=this.v_invIB;var localCenterA=this.p_localCenterA;var localCenterB=this.p_localCenterB;copyVec2(cA,positionA.c);var aA=positionA.a;copyVec2(vA,velocityA.v);var wA=velocityA.w;copyVec2(cB,positionB.c);var aB=positionB.a;copyVec2(vB,velocityB.v);var wB=velocityB.w;getTransform(xfA,localCenterA,cA,aA);getTransform(xfB,localCenterB,cB,aB);worldManifold.recycle();manifold.getWorldManifold(worldManifold,xfA,radiusA,xfB,radiusB);copyVec2(this.v_normal,worldManifold.normal);for(var j=0;j0?1/kNormal:0;crossVec2Num(tangent$1,this.v_normal,1);var rtA=crossVec2Vec2(vcp.rA,tangent$1);var rtB=crossVec2Vec2(vcp.rB,tangent$1);var kTangent=mA+mB+iA*rtA*rtA+iB*rtB*rtB;vcp.tangentMass=kTangent>0?1/kTangent:0;vcp.velocityBias=0;var vRel=0;vRel+=dotVec2(this.v_normal,vB);vRel+=dotVec2(this.v_normal,crossNumVec2(temp$2,wB,vcp.rB));vRel-=dotVec2(this.v_normal,vA);vRel-=dotVec2(this.v_normal,crossNumVec2(temp$2,wA,vcp.rA));if(vRel<-SettingsInternal.velocityThreshold){vcp.velocityBias=-this.v_restitution*vRel}}if(this.v_pointCount==2&&step.blockSolve){var vcp1=this.v_points[0];var vcp2=this.v_points[1];var rn1A=crossVec2Vec2(vcp1.rA,this.v_normal);var rn1B=crossVec2Vec2(vcp1.rB,this.v_normal);var rn2A=crossVec2Vec2(vcp2.rA,this.v_normal);var rn2B=crossVec2Vec2(vcp2.rB,this.v_normal);var k11=mA+mB+iA*rn1A*rn1A+iB*rn1B*rn1B;var k22=mA+mB+iA*rn2A*rn2A+iB*rn2B*rn2B;var k12=mA+mB+iA*rn1A*rn2A+iB*rn1B*rn2B;var k_maxConditionNumber=1e3;if(k11*k11=0&&x.y>=0){subVec2(d,x,a);scaleVec2(P1,d.x,normal$2);scaleVec2(P2,d.y,normal$2);combine3Vec2(vA,-mA,P1,-mA,P2,1,vA);wA-=iA*(crossVec2Vec2(vcp1.rA,P1)+crossVec2Vec2(vcp2.rA,P2));combine3Vec2(vB,mB,P1,mB,P2,1,vB);wB+=iB*(crossVec2Vec2(vcp1.rB,P1)+crossVec2Vec2(vcp2.rB,P2));vcp1.normalImpulse=x.x;vcp2.normalImpulse=x.y;break}x.x=-vcp1.normalMass*b.x;x.y=0;vn1=0;vn2=this.v_K.ex.y*x.x+b.y;if(x.x>=0&&vn2>=0){subVec2(d,x,a);scaleVec2(P1,d.x,normal$2);scaleVec2(P2,d.y,normal$2);combine3Vec2(vA,-mA,P1,-mA,P2,1,vA);wA-=iA*(crossVec2Vec2(vcp1.rA,P1)+crossVec2Vec2(vcp2.rA,P2));combine3Vec2(vB,mB,P1,mB,P2,1,vB);wB+=iB*(crossVec2Vec2(vcp1.rB,P1)+crossVec2Vec2(vcp2.rB,P2));vcp1.normalImpulse=x.x;vcp2.normalImpulse=x.y;break}x.x=0;x.y=-vcp2.normalMass*b.y;vn1=this.v_K.ey.x*x.y+b.x;vn2=0;if(x.y>=0&&vn1>=0){subVec2(d,x,a);scaleVec2(P1,d.x,normal$2);scaleVec2(P2,d.y,normal$2);combine3Vec2(vA,-mA,P1,-mA,P2,1,vA);wA-=iA*(crossVec2Vec2(vcp1.rA,P1)+crossVec2Vec2(vcp2.rA,P2));combine3Vec2(vB,mB,P1,mB,P2,1,vB);wB+=iB*(crossVec2Vec2(vcp1.rB,P1)+crossVec2Vec2(vcp2.rB,P2));vcp1.normalImpulse=x.x;vcp2.normalImpulse=x.y;break}x.x=0;x.y=0;vn1=b.x;vn2=b.y;if(vn1>=0&&vn2>=0){subVec2(d,x,a);scaleVec2(P1,d.x,normal$2);scaleVec2(P2,d.y,normal$2);combine3Vec2(vA,-mA,P1,-mA,P2,1,vA);wA-=iA*(crossVec2Vec2(vcp1.rA,P1)+crossVec2Vec2(vcp2.rA,P2));combine3Vec2(vB,mB,P1,mB,P2,1,vB);wB+=iB*(crossVec2Vec2(vcp1.rB,P1)+crossVec2Vec2(vcp2.rB,P2));vcp1.normalImpulse=x.x;vcp2.normalImpulse=x.y;break}break}}copyVec2(velocityA.v,vA);velocityA.w=wA;copyVec2(velocityB.v,vB);velocityB.w=wB};Contact2.addType=function(type1,type2,callback){s_registers[type1]=s_registers[type1]||{};s_registers[type1][type2]=callback};Contact2.create=function(fixtureA,indexA,fixtureB,indexB){var typeA=fixtureA.m_shape.m_type;var typeB=fixtureB.m_shape.m_type;var contact=contactPool.allocate();var evaluateFcn;if(evaluateFcn=s_registers[typeA]&&s_registers[typeA][typeB]){contact.initialize(fixtureA,indexA,fixtureB,indexB,evaluateFcn)}else if(evaluateFcn=s_registers[typeB]&&s_registers[typeB][typeA]){contact.initialize(fixtureB,indexB,fixtureA,indexA,evaluateFcn)}else{return null}fixtureA=contact.m_fixtureA;fixtureB=contact.m_fixtureB;indexA=contact.getChildIndexA();indexB=contact.getChildIndexB();var bodyA=fixtureA.m_body;var bodyB=fixtureB.m_body;contact.m_nodeA.contact=contact;contact.m_nodeA.other=bodyB;contact.m_nodeA.prev=null;contact.m_nodeA.next=bodyA.m_contactList;if(bodyA.m_contactList!=null){bodyA.m_contactList.prev=contact.m_nodeA}bodyA.m_contactList=contact.m_nodeA;contact.m_nodeB.contact=contact;contact.m_nodeB.other=bodyA;contact.m_nodeB.prev=null;contact.m_nodeB.next=bodyB.m_contactList;if(bodyB.m_contactList!=null){bodyB.m_contactList.prev=contact.m_nodeB}bodyB.m_contactList=contact.m_nodeB;if(fixtureA.isSensor()==false&&fixtureB.isSensor()==false){bodyA.setAwake(true);bodyB.setAwake(true)}return contact};Contact2.destroy=function(contact,listener){var fixtureA=contact.m_fixtureA;var fixtureB=contact.m_fixtureB;if(fixtureA===null||fixtureB===null)return;var bodyA=fixtureA.m_body;var bodyB=fixtureB.m_body;if(bodyA===null||bodyB===null)return;if(contact.isTouching()){listener.endContact(contact)}if(contact.m_nodeA.prev){contact.m_nodeA.prev.next=contact.m_nodeA.next}if(contact.m_nodeA.next){contact.m_nodeA.next.prev=contact.m_nodeA.prev}if(contact.m_nodeA==bodyA.m_contactList){bodyA.m_contactList=contact.m_nodeA.next}if(contact.m_nodeB.prev){contact.m_nodeB.prev.next=contact.m_nodeB.next}if(contact.m_nodeB.next){contact.m_nodeB.next.prev=contact.m_nodeB.prev}if(contact.m_nodeB==bodyB.m_contactList){bodyB.m_contactList=contact.m_nodeB.next}if(contact.m_manifold.pointCount>0&&!fixtureA.m_isSensor&&!fixtureB.m_isSensor){bodyA.setAwake(true);bodyB.setAwake(true)}contactPool.release(contact)};return Contact2}();var DEFAULTS$b={gravity:Vec2.zero(),allowSleep:true,warmStarting:true,continuousPhysics:true,subStepping:false,blockSolve:true,velocityIterations:8,positionIterations:3};var World=function(){function World2(def){if(!(this instanceof World2)){return new World2(def)}this.s_step=new TimeStep;if(!def){def={}}else if(Vec2.isValid(def)){def={gravity:def}}def=options(def,DEFAULTS$b);this.m_solver=new Solver(this);this.m_broadPhase=new BroadPhase;this.m_contactList=null;this.m_contactCount=0;this.m_bodyList=null;this.m_bodyCount=0;this.m_jointList=null;this.m_jointCount=0;this.m_stepComplete=true;this.m_allowSleep=def.allowSleep;this.m_gravity=Vec2.clone(def.gravity);this.m_clearForces=true;this.m_newFixture=false;this.m_locked=false;this.m_warmStarting=def.warmStarting;this.m_continuousPhysics=def.continuousPhysics;this.m_subStepping=def.subStepping;this.m_blockSolve=def.blockSolve;this.m_velocityIterations=def.velocityIterations;this.m_positionIterations=def.positionIterations;this.m_t=0}World2.prototype._serialize=function(){var bodies=[];var joints=[];for(var b2=this.getBodyList();b2;b2=b2.getNext()){bodies.push(b2)}for(var j=this.getJointList();j;j=j.getNext()){if(typeof j._serialize==="function"){joints.push(j)}}return{gravity:this.m_gravity,bodies:bodies,joints:joints}};World2._deserialize=function(data,context,restore){if(!data){return new World2}var world=new World2(data.gravity);if(data.bodies){for(var i=data.bodies.length-1;i>=0;i-=1){world._addBody(restore(Body,data.bodies[i],world))}}if(data.joints){for(var i=data.joints.length-1;i>=0;i--){world.createJoint(restore(Joint,data.joints[i],world))}}return world};World2.prototype.getBodyList=function(){return this.m_bodyList};World2.prototype.getJointList=function(){return this.m_jointList};World2.prototype.getContactList=function(){return this.m_contactList};World2.prototype.getBodyCount=function(){return this.m_bodyCount};World2.prototype.getJointCount=function(){return this.m_jointCount};World2.prototype.getContactCount=function(){return this.m_contactCount};World2.prototype.setGravity=function(gravity){this.m_gravity.set(gravity)};World2.prototype.getGravity=function(){return this.m_gravity};World2.prototype.isLocked=function(){return this.m_locked};World2.prototype.setAllowSleeping=function(flag){if(flag==this.m_allowSleep){return}this.m_allowSleep=flag;if(this.m_allowSleep==false){for(var b2=this.m_bodyList;b2;b2=b2.m_next){b2.setAwake(true)}}};World2.prototype.getAllowSleeping=function(){return this.m_allowSleep};World2.prototype.setWarmStarting=function(flag){this.m_warmStarting=flag};World2.prototype.getWarmStarting=function(){return this.m_warmStarting};World2.prototype.setContinuousPhysics=function(flag){this.m_continuousPhysics=flag};World2.prototype.getContinuousPhysics=function(){return this.m_continuousPhysics};World2.prototype.setSubStepping=function(flag){this.m_subStepping=flag};World2.prototype.getSubStepping=function(){return this.m_subStepping};World2.prototype.setAutoClearForces=function(flag){this.m_clearForces=flag};World2.prototype.getAutoClearForces=function(){return this.m_clearForces};World2.prototype.clearForces=function(){for(var body=this.m_bodyList;body;body=body.getNext()){body.m_force.setZero();body.m_torque=0}};World2.prototype.queryAABB=function(aabb,callback){var broadPhase=this.m_broadPhase;this.m_broadPhase.query(aabb,(function(proxyId){var proxy=broadPhase.getUserData(proxyId);return callback(proxy.fixture)}))};World2.prototype.rayCast=function(point1,point2,callback){var broadPhase=this.m_broadPhase;this.m_broadPhase.rayCast({maxFraction:1,p1:point1,p2:point2},(function(input2,proxyId){var proxy=broadPhase.getUserData(proxyId);var fixture=proxy.fixture;var index=proxy.childIndex;var output2={};var hit=fixture.rayCast(output2,input2,index);if(hit){var fraction=output2.fraction;var point3=Vec2.add(Vec2.mulNumVec2(1-fraction,input2.p1),Vec2.mulNumVec2(fraction,input2.p2));return callback(fixture,point3,output2.normal,fraction)}return input2.maxFraction}))};World2.prototype.getProxyCount=function(){return this.m_broadPhase.getProxyCount()};World2.prototype.getTreeHeight=function(){return this.m_broadPhase.getTreeHeight()};World2.prototype.getTreeBalance=function(){return this.m_broadPhase.getTreeBalance()};World2.prototype.getTreeQuality=function(){return this.m_broadPhase.getTreeQuality()};World2.prototype.shiftOrigin=function(newOrigin){if(this.m_locked){return}for(var b2=this.m_bodyList;b2;b2=b2.m_next){b2.m_xf.p.sub(newOrigin);b2.m_sweep.c0.sub(newOrigin);b2.m_sweep.c.sub(newOrigin)}for(var j=this.m_jointList;j;j=j.m_next){j.shiftOrigin(newOrigin)}this.m_broadPhase.shiftOrigin(newOrigin)};World2.prototype._addBody=function(body){if(this.isLocked()){return}body.m_prev=null;body.m_next=this.m_bodyList;if(this.m_bodyList){this.m_bodyList.m_prev=body}this.m_bodyList=body;++this.m_bodyCount};World2.prototype.createBody=function(arg1,arg2){if(this.isLocked()){return null}var def={};if(!arg1);else if(Vec2.isValid(arg1)){def={position:arg1,angle:arg2}}else if(typeof arg1==="object"){def=arg1}var body=new Body(this,def);this._addBody(body);return body};World2.prototype.createDynamicBody=function(arg1,arg2){var def={};if(!arg1);else if(Vec2.isValid(arg1)){def={position:arg1,angle:arg2}}else if(typeof arg1==="object"){def=arg1}def.type="dynamic";return this.createBody(def)};World2.prototype.createKinematicBody=function(arg1,arg2){var def={};if(!arg1);else if(Vec2.isValid(arg1)){def={position:arg1,angle:arg2}}else if(typeof arg1==="object"){def=arg1}def.type="kinematic";return this.createBody(def)};World2.prototype.destroyBody=function(b2){if(this.isLocked()){return}if(b2.m_destroyed){return false}var je=b2.m_jointList;while(je){var je0=je;je=je.next;this.publish("remove-joint",je0.joint);this.destroyJoint(je0.joint);b2.m_jointList=je}b2.m_jointList=null;var ce=b2.m_contactList;while(ce){var ce0=ce;ce=ce.next;this.destroyContact(ce0.contact);b2.m_contactList=ce}b2.m_contactList=null;var f=b2.m_fixtureList;while(f){var f0=f;f=f.m_next;this.publish("remove-fixture",f0);f0.destroyProxies(this.m_broadPhase);b2.m_fixtureList=f}b2.m_fixtureList=null;if(b2.m_prev){b2.m_prev.m_next=b2.m_next}if(b2.m_next){b2.m_next.m_prev=b2.m_prev}if(b2==this.m_bodyList){this.m_bodyList=b2.m_next}b2.m_destroyed=true;--this.m_bodyCount;this.publish("remove-body",b2);return true};World2.prototype.createJoint=function(joint){if(this.isLocked()){return null}joint.m_prev=null;joint.m_next=this.m_jointList;if(this.m_jointList){this.m_jointList.m_prev=joint}this.m_jointList=joint;++this.m_jointCount;joint.m_edgeA.joint=joint;joint.m_edgeA.other=joint.m_bodyB;joint.m_edgeA.prev=null;joint.m_edgeA.next=joint.m_bodyA.m_jointList;if(joint.m_bodyA.m_jointList)joint.m_bodyA.m_jointList.prev=joint.m_edgeA;joint.m_bodyA.m_jointList=joint.m_edgeA;joint.m_edgeB.joint=joint;joint.m_edgeB.other=joint.m_bodyA;joint.m_edgeB.prev=null;joint.m_edgeB.next=joint.m_bodyB.m_jointList;if(joint.m_bodyB.m_jointList)joint.m_bodyB.m_jointList.prev=joint.m_edgeB;joint.m_bodyB.m_jointList=joint.m_edgeB;if(joint.m_collideConnected==false){for(var edge=joint.m_bodyB.getContactList();edge;edge=edge.next){if(edge.other==joint.m_bodyA){edge.contact.flagForFiltering()}}}return joint};World2.prototype.destroyJoint=function(joint){if(this.isLocked()){return}if(joint.m_prev){joint.m_prev.m_next=joint.m_next}if(joint.m_next){joint.m_next.m_prev=joint.m_prev}if(joint==this.m_jointList){this.m_jointList=joint.m_next}var bodyA=joint.m_bodyA;var bodyB=joint.m_bodyB;bodyA.setAwake(true);bodyB.setAwake(true);if(joint.m_edgeA.prev){joint.m_edgeA.prev.next=joint.m_edgeA.next}if(joint.m_edgeA.next){joint.m_edgeA.next.prev=joint.m_edgeA.prev}if(joint.m_edgeA==bodyA.m_jointList){bodyA.m_jointList=joint.m_edgeA.next}joint.m_edgeA.prev=null;joint.m_edgeA.next=null;if(joint.m_edgeB.prev){joint.m_edgeB.prev.next=joint.m_edgeB.next}if(joint.m_edgeB.next){joint.m_edgeB.next.prev=joint.m_edgeB.prev}if(joint.m_edgeB==bodyB.m_jointList){bodyB.m_jointList=joint.m_edgeB.next}joint.m_edgeB.prev=null;joint.m_edgeB.next=null;--this.m_jointCount;if(joint.m_collideConnected==false){var edge=bodyB.getContactList();while(edge){if(edge.other==bodyA){edge.contact.flagForFiltering()}edge=edge.next}}this.publish("remove-joint",joint)};World2.prototype.step=function(timeStep,velocityIterations,positionIterations){this.publish("pre-step",timeStep);if((velocityIterations|0)!==velocityIterations){velocityIterations=0}velocityIterations=velocityIterations||this.m_velocityIterations;positionIterations=positionIterations||this.m_positionIterations;if(this.m_newFixture){this.findNewContacts();this.m_newFixture=false}this.m_locked=true;this.s_step.reset(timeStep);this.s_step.velocityIterations=velocityIterations;this.s_step.positionIterations=positionIterations;this.s_step.warmStarting=this.m_warmStarting;this.s_step.blockSolve=this.m_blockSolve;this.updateContacts();if(this.m_stepComplete&&timeStep>0){this.m_solver.solveWorld(this.s_step);for(var b2=this.m_bodyList;b2;b2=b2.getNext()){if(b2.m_islandFlag==false){continue}if(b2.isStatic()){continue}b2.synchronizeFixtures()}this.findNewContacts()}if(this.m_continuousPhysics&&timeStep>0){this.m_solver.solveWorldTOI(this.s_step)}if(this.m_clearForces){this.clearForces()}this.m_locked=false;this.publish("post-step",timeStep)};World2.prototype.findNewContacts=function(){var _this=this;this.m_broadPhase.updatePairs((function(proxyA,proxyB){return _this.createContact(proxyA,proxyB)}))};World2.prototype.createContact=function(proxyA,proxyB){var fixtureA=proxyA.fixture;var fixtureB=proxyB.fixture;var indexA=proxyA.childIndex;var indexB=proxyB.childIndex;var bodyA=fixtureA.getBody();var bodyB=fixtureB.getBody();if(bodyA==bodyB){return}var edge=bodyB.getContactList();while(edge){if(edge.other==bodyA){var fA=edge.contact.getFixtureA();var fB=edge.contact.getFixtureB();var iA=edge.contact.getChildIndexA();var iB=edge.contact.getChildIndexB();if(fA==fixtureA&&fB==fixtureB&&iA==indexA&&iB==indexB){return}if(fA==fixtureB&&fB==fixtureA&&iA==indexB&&iB==indexA){return}}edge=edge.next}if(bodyB.shouldCollide(bodyA)==false){return}if(fixtureB.shouldCollide(fixtureA)==false){return}var contact=Contact.create(fixtureA,indexA,fixtureB,indexB);if(contact==null){return}contact.m_prev=null;if(this.m_contactList!=null){contact.m_next=this.m_contactList;this.m_contactList.m_prev=contact}this.m_contactList=contact;++this.m_contactCount};World2.prototype.updateContacts=function(){var c2;var next_c=this.m_contactList;while(c2=next_c){next_c=c2.getNext();var fixtureA=c2.getFixtureA();var fixtureB=c2.getFixtureB();var indexA=c2.getChildIndexA();var indexB=c2.getChildIndexB();var bodyA=fixtureA.getBody();var bodyB=fixtureB.getBody();if(c2.m_filterFlag){if(bodyB.shouldCollide(bodyA)==false){this.destroyContact(c2);continue}if(fixtureB.shouldCollide(fixtureA)==false){this.destroyContact(c2);continue}c2.m_filterFlag=false}var activeA=bodyA.isAwake()&&!bodyA.isStatic();var activeB=bodyB.isAwake()&&!bodyB.isStatic();if(activeA==false&&activeB==false){continue}var proxyIdA=fixtureA.m_proxies[indexA].proxyId;var proxyIdB=fixtureB.m_proxies[indexB].proxyId;var overlap=this.m_broadPhase.testOverlap(proxyIdA,proxyIdB);if(overlap==false){this.destroyContact(c2);continue}c2.update(this)}};World2.prototype.destroyContact=function(contact){if(contact.m_prev){contact.m_prev.m_next=contact.m_next}if(contact.m_next){contact.m_next.m_prev=contact.m_prev}if(contact==this.m_contactList){this.m_contactList=contact.m_next}Contact.destroy(contact,this);--this.m_contactCount};World2.prototype.on=function(name,listener){if(typeof name!=="string"||typeof listener!=="function"){return this}if(!this._listeners){this._listeners={}}if(!this._listeners[name]){this._listeners[name]=[]}this._listeners[name].push(listener);return this};World2.prototype.off=function(name,listener){if(typeof name!=="string"||typeof listener!=="function"){return this}var listeners=this._listeners&&this._listeners[name];if(!listeners||!listeners.length){return this}var index=listeners.indexOf(listener);if(index>=0){listeners.splice(index,1)}return this};World2.prototype.publish=function(name,arg1,arg2,arg3){var listeners=this._listeners&&this._listeners[name];if(!listeners||!listeners.length){return 0}for(var l=0;l0){output2.normal=Rot.mulVec2(xf2.q,normal3).neg()}else{output2.normal=Rot.mulVec2(xf2.q,normal3)}return true};EdgeShape2.prototype.computeAABB=function(aabb,xf2,childIndex){transformVec2(v1$2,xf2,this.m_vertex1);transformVec2(v2$1,xf2,this.m_vertex2);AABB.combinePoints(aabb,v1$2,v2$1);AABB.extend(aabb,this.m_radius)};EdgeShape2.prototype.computeMass=function(massData,density){massData.mass=0;combine2Vec2(massData.center,.5,this.m_vertex1,.5,this.m_vertex2);massData.I=0};EdgeShape2.prototype.computeDistanceProxy=function(proxy){proxy.m_vertices[0]=this.m_vertex1;proxy.m_vertices[1]=this.m_vertex2;proxy.m_vertices.length=2;proxy.m_count=2;proxy.m_radius=this.m_radius};EdgeShape2.TYPE="edge";return EdgeShape2}(Shape);var Edge=EdgeShape;var v1$1=vec2(0,0);var v2=vec2(0,0);var ChainShape=function(_super){__extends(ChainShape2,_super);function ChainShape2(vertices,loop){var _this=this;if(!(_this instanceof ChainShape2)){return new ChainShape2(vertices,loop)}_this=_super.call(this)||this;_this.m_type=ChainShape2.TYPE;_this.m_radius=SettingsInternal.polygonRadius;_this.m_vertices=[];_this.m_count=0;_this.m_prevVertex=null;_this.m_nextVertex=null;_this.m_hasPrevVertex=false;_this.m_hasNextVertex=false;_this.m_isLoop=!!loop;if(vertices&&vertices.length){if(loop){_this._createLoop(vertices)}else{_this._createChain(vertices)}}return _this}ChainShape2.prototype._serialize=function(){var data={type:this.m_type,vertices:this.m_isLoop?this.m_vertices.slice(0,this.m_vertices.length-1):this.m_vertices,isLoop:this.m_isLoop,hasPrevVertex:this.m_hasPrevVertex,hasNextVertex:this.m_hasNextVertex,prevVertex:null,nextVertex:null};if(this.m_prevVertex){data.prevVertex=this.m_prevVertex}if(this.m_nextVertex){data.nextVertex=this.m_nextVertex}return data};ChainShape2._deserialize=function(data,fixture,restore){var vertices=[];if(data.vertices){for(var i=0;i0){edge.m_vertex0=this.m_vertices[childIndex-1];edge.m_hasVertex0=true}else{edge.m_vertex0=this.m_prevVertex;edge.m_hasVertex0=this.m_hasPrevVertex}if(childIndexx0||x2===x0&&ps[i].yr.lengthSquared()){ie2=j}}++m;ih=ie2;if(ie2===i0){break}}if(m<3){this._setAsBox(1,1);return}this.m_count=m;this.m_vertices=[];for(var i=0;i0){return false}}return true};PolygonShape2.prototype.rayCast=function(output2,input2,xf2,childIndex){var p1=Rot.mulTVec2(xf2.q,Vec2.sub(input2.p1,xf2.p));var p2=Rot.mulTVec2(xf2.q,Vec2.sub(input2.p2,xf2.p));var d2=Vec2.sub(p2,p1);var lower=0;var upper=input2.maxFraction;var index=-1;for(var i=0;i0&&numerator=0){output2.fraction=lower;output2.normal=Rot.mulVec2(xf2.q,this.m_normals[index]);return true}return false};PolygonShape2.prototype.computeAABB=function(aabb,xf2,childIndex){var minX=Infinity;var minY=Infinity;var maxX=-Infinity;var maxY=-Infinity;for(var i=0;i0){this.m_length=+def.length}else if(def.length<0);else if(def.anchorA||def.anchorA||def.anchorA||def.anchorA){this.m_length=Vec2.distance(this.m_bodyA.getWorldPoint(this.m_localAnchorA),this.m_bodyB.getWorldPoint(this.m_localAnchorB))}if(Number.isFinite(def.frequencyHz)){this.m_frequencyHz=def.frequencyHz}if(Number.isFinite(def.dampingRatio)){this.m_dampingRatio=def.dampingRatio}};DistanceJoint2.prototype.getLocalAnchorA=function(){return this.m_localAnchorA};DistanceJoint2.prototype.getLocalAnchorB=function(){return this.m_localAnchorB};DistanceJoint2.prototype.setLength=function(length){this.m_length=length};DistanceJoint2.prototype.getLength=function(){return this.m_length};DistanceJoint2.prototype.setFrequency=function(hz){this.m_frequencyHz=hz};DistanceJoint2.prototype.getFrequency=function(){return this.m_frequencyHz};DistanceJoint2.prototype.setDampingRatio=function(ratio){this.m_dampingRatio=ratio};DistanceJoint2.prototype.getDampingRatio=function(){return this.m_dampingRatio};DistanceJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};DistanceJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};DistanceJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.mulNumVec2(this.m_impulse,this.m_u).mul(inv_dt)};DistanceJoint2.prototype.getReactionTorque=function(inv_dt){return 0};DistanceJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter;this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);this.m_rA=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));this.m_rB=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));this.m_u=Vec2.sub(Vec2.add(cB2,this.m_rB),Vec2.add(cA2,this.m_rA));var length=this.m_u.length();if(length>SettingsInternal.linearSlop){this.m_u.mul(1/length)}else{this.m_u.setNum(0,0)}var crAu=Vec2.crossVec2Vec2(this.m_rA,this.m_u);var crBu=Vec2.crossVec2Vec2(this.m_rB,this.m_u);var invMass=this.m_invMassA+this.m_invIA*crAu*crAu+this.m_invMassB+this.m_invIB*crBu*crBu;this.m_mass=invMass!=0?1/invMass:0;if(this.m_frequencyHz>0){var C=length-this.m_length;var omega=2*math_PI$3*this.m_frequencyHz;var d2=2*this.m_mass*this.m_dampingRatio*omega;var k=this.m_mass*omega*omega;var h=step.dt;this.m_gamma=h*(d2+h*k);this.m_gamma=this.m_gamma!=0?1/this.m_gamma:0;this.m_bias=C*h*k*this.m_gamma;invMass+=this.m_gamma;this.m_mass=invMass!=0?1/invMass:0}else{this.m_gamma=0;this.m_bias=0}if(step.warmStarting){this.m_impulse*=step.dtRatio;var P3=Vec2.mulNumVec2(this.m_impulse,this.m_u);vA2.subMul(this.m_invMassA,P3);wA-=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,P3);vB2.addMul(this.m_invMassB,P3);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,P3)}else{this.m_impulse=0}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};DistanceJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var vpA=Vec2.add(vA2,Vec2.crossNumVec2(wA,this.m_rA));var vpB=Vec2.add(vB2,Vec2.crossNumVec2(wB,this.m_rB));var Cdot=Vec2.dot(this.m_u,vpB)-Vec2.dot(this.m_u,vpA);var impulse=-this.m_mass*(Cdot+this.m_bias+this.m_gamma*this.m_impulse);this.m_impulse+=impulse;var P3=Vec2.mulNumVec2(impulse,this.m_u);vA2.subMul(this.m_invMassA,P3);wA-=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,P3);vB2.addMul(this.m_invMassB,P3);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,P3);this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};DistanceJoint2.prototype.solvePositionConstraints=function(step){if(this.m_frequencyHz>0){return true}var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulSub(qA,this.m_localAnchorA,this.m_localCenterA);var rB2=Rot.mulSub(qB,this.m_localAnchorB,this.m_localCenterB);var u=Vec2.sub(Vec2.add(cB2,rB2),Vec2.add(cA2,rA2));var length=u.normalize();var C=clamp(length-this.m_length,-SettingsInternal.maxLinearCorrection,SettingsInternal.maxLinearCorrection);var impulse=-this.m_mass*C;var P3=Vec2.mulNumVec2(impulse,u);cA2.subMul(this.m_invMassA,P3);aA-=this.m_invIA*Vec2.crossVec2Vec2(rA2,P3);cB2.addMul(this.m_invMassB,P3);aB+=this.m_invIB*Vec2.crossVec2Vec2(rB2,P3);this.m_bodyA.c_position.c.setVec2(cA2);this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c.setVec2(cB2);this.m_bodyB.c_position.a=aB;return math_abs$5(C)0){this.m_angularMass=1/this.m_angularMass}if(step.warmStarting){this.m_linearImpulse.mul(step.dtRatio);this.m_angularImpulse*=step.dtRatio;var P3=Vec2.neo(this.m_linearImpulse.x,this.m_linearImpulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+this.m_angularImpulse);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+this.m_angularImpulse)}else{this.m_linearImpulse.setZero();this.m_angularImpulse=0}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};FrictionJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var h=step.dt;{var Cdot=wB-wA;var impulse=-this.m_angularMass*Cdot;var oldImpulse=this.m_angularImpulse;var maxImpulse=h*this.m_maxTorque;this.m_angularImpulse=clamp(this.m_angularImpulse+impulse,-maxImpulse,maxImpulse);impulse=this.m_angularImpulse-oldImpulse;wA-=iA*impulse;wB+=iB*impulse}{var Cdot=Vec2.sub(Vec2.add(vB2,Vec2.crossNumVec2(wB,this.m_rB)),Vec2.add(vA2,Vec2.crossNumVec2(wA,this.m_rA)));var impulse=Vec2.neg(Mat22.mulVec2(this.m_linearMass,Cdot));var oldImpulse=this.m_linearImpulse;this.m_linearImpulse.add(impulse);var maxImpulse=h*this.m_maxForce;if(this.m_linearImpulse.lengthSquared()>maxImpulse*maxImpulse){this.m_linearImpulse.normalize();this.m_linearImpulse.mul(maxImpulse)}impulse=Vec2.sub(this.m_linearImpulse,oldImpulse);vA2.subMul(mA,impulse);wA-=iA*Vec2.crossVec2Vec2(this.m_rA,impulse);vB2.addMul(mB,impulse);wB+=iB*Vec2.crossVec2Vec2(this.m_rB,impulse)}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};FrictionJoint2.prototype.solvePositionConstraints=function(step){return true};FrictionJoint2.TYPE="friction-joint";return FrictionJoint2}(Joint);var Mat33=function(){function Mat332(a2,b2,c2){if(typeof a2==="object"&&a2!==null){this.ex=Vec3.clone(a2);this.ey=Vec3.clone(b2);this.ez=Vec3.clone(c2)}else{this.ex=Vec3.zero();this.ey=Vec3.zero();this.ez=Vec3.zero()}}Mat332.prototype.toString=function(){return JSON.stringify(this)};Mat332.isValid=function(obj){if(obj===null||typeof obj==="undefined"){return false}return Vec3.isValid(obj.ex)&&Vec3.isValid(obj.ey)&&Vec3.isValid(obj.ez)};Mat332.assert=function(o){};Mat332.prototype.setZero=function(){this.ex.setZero();this.ey.setZero();this.ez.setZero();return this};Mat332.prototype.solve33=function(v3){var cross_x=this.ey.y*this.ez.z-this.ey.z*this.ez.y;var cross_y=this.ey.z*this.ez.x-this.ey.x*this.ez.z;var cross_z=this.ey.x*this.ez.y-this.ey.y*this.ez.x;var det=this.ex.x*cross_x+this.ex.y*cross_y+this.ex.z*cross_z;if(det!==0){det=1/det}var r=new Vec3;cross_x=this.ey.y*this.ez.z-this.ey.z*this.ez.y;cross_y=this.ey.z*this.ez.x-this.ey.x*this.ez.z;cross_z=this.ey.x*this.ez.y-this.ey.y*this.ez.x;r.x=det*(v3.x*cross_x+v3.y*cross_y+v3.z*cross_z);cross_x=v3.y*this.ez.z-v3.z*this.ez.y;cross_y=v3.z*this.ez.x-v3.x*this.ez.z;cross_z=v3.x*this.ez.y-v3.y*this.ez.x;r.y=det*(this.ex.x*cross_x+this.ex.y*cross_y+this.ex.z*cross_z);cross_x=this.ey.y*v3.z-this.ey.z*v3.y;cross_y=this.ey.z*v3.x-this.ey.x*v3.z;cross_z=this.ey.x*v3.y-this.ey.y*v3.x;r.z=det*(this.ex.x*cross_x+this.ex.y*cross_y+this.ex.z*cross_z);return r};Mat332.prototype.solve22=function(v3){var a11=this.ex.x;var a12=this.ey.x;var a21=this.ex.y;var a22=this.ey.y;var det=a11*a22-a12*a21;if(det!==0){det=1/det}var r=Vec2.zero();r.x=det*(a22*v3.x-a12*v3.y);r.y=det*(a11*v3.y-a21*v3.x);return r};Mat332.prototype.getInverse22=function(M){var a2=this.ex.x;var b2=this.ey.x;var c2=this.ex.y;var d2=this.ey.y;var det=a2*d2-b2*c2;if(det!==0){det=1/det}M.ex.x=det*d2;M.ey.x=-det*b2;M.ex.z=0;M.ex.y=-det*c2;M.ey.y=det*a2;M.ey.z=0;M.ez.x=0;M.ez.y=0;M.ez.z=0};Mat332.prototype.getSymInverse33=function(M){var det=Vec3.dot(this.ex,Vec3.cross(this.ey,this.ez));if(det!==0){det=1/det}var a11=this.ex.x;var a12=this.ey.x;var a13=this.ez.x;var a22=this.ey.y;var a23=this.ez.y;var a33=this.ez.z;M.ex.x=det*(a22*a33-a23*a23);M.ex.y=det*(a13*a23-a12*a33);M.ex.z=det*(a12*a23-a13*a22);M.ey.x=M.ex.y;M.ey.y=det*(a11*a33-a13*a13);M.ey.z=det*(a13*a12-a11*a23);M.ez.x=M.ex.z;M.ez.y=M.ey.z;M.ez.z=det*(a11*a22-a12*a12)};Mat332.mul=function(a2,b2){if(b2&&"z"in b2&&"y"in b2&&"x"in b2){var x2=a2.ex.x*b2.x+a2.ey.x*b2.y+a2.ez.x*b2.z;var y=a2.ex.y*b2.x+a2.ey.y*b2.y+a2.ez.y*b2.z;var z=a2.ex.z*b2.x+a2.ey.z*b2.y+a2.ez.z*b2.z;return new Vec3(x2,y,z)}else if(b2&&"y"in b2&&"x"in b2){var x2=a2.ex.x*b2.x+a2.ey.x*b2.y;var y=a2.ex.y*b2.x+a2.ey.y*b2.y;return Vec2.neo(x2,y)}};Mat332.mulVec3=function(a2,b2){var x2=a2.ex.x*b2.x+a2.ey.x*b2.y+a2.ez.x*b2.z;var y=a2.ex.y*b2.x+a2.ey.y*b2.y+a2.ez.y*b2.z;var z=a2.ex.z*b2.x+a2.ey.z*b2.y+a2.ez.z*b2.z;return new Vec3(x2,y,z)};Mat332.mulVec2=function(a2,b2){var x2=a2.ex.x*b2.x+a2.ey.x*b2.y;var y=a2.ex.y*b2.x+a2.ey.y*b2.y;return Vec2.neo(x2,y)};Mat332.add=function(a2,b2){return new Mat332(Vec3.add(a2.ex,b2.ex),Vec3.add(a2.ey,b2.ey),Vec3.add(a2.ez,b2.ez))};return Mat332}();var math_abs$4=Math.abs;var LimitState$2;(function(LimitState2){LimitState2[LimitState2["inactiveLimit"]=0]="inactiveLimit";LimitState2[LimitState2["atLowerLimit"]=1]="atLowerLimit";LimitState2[LimitState2["atUpperLimit"]=2]="atUpperLimit";LimitState2[LimitState2["equalLimits"]=3]="equalLimits"})(LimitState$2||(LimitState$2={}));var DEFAULTS$8={lowerAngle:0,upperAngle:0,maxMotorTorque:0,motorSpeed:0,enableLimit:false,enableMotor:false};var RevoluteJoint=function(_super){__extends(RevoluteJoint2,_super);function RevoluteJoint2(def,bodyA,bodyB,anchor){var _this=this;var _a2,_b,_c,_d,_e,_f;if(!(_this instanceof RevoluteJoint2)){return new RevoluteJoint2(def,bodyA,bodyB,anchor)}def=def!==null&&def!==void 0?def:{};_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_mass=new Mat33;_this.m_limitState=LimitState$2.inactiveLimit;_this.m_type=RevoluteJoint2.TYPE;if(Vec2.isValid(anchor)){_this.m_localAnchorA=bodyA.getLocalPoint(anchor)}else if(Vec2.isValid(def.localAnchorA)){_this.m_localAnchorA=Vec2.clone(def.localAnchorA)}else{_this.m_localAnchorA=Vec2.zero()}if(Vec2.isValid(anchor)){_this.m_localAnchorB=bodyB.getLocalPoint(anchor)}else if(Vec2.isValid(def.localAnchorB)){_this.m_localAnchorB=Vec2.clone(def.localAnchorB)}else{_this.m_localAnchorB=Vec2.zero()}if(Number.isFinite(def.referenceAngle)){_this.m_referenceAngle=def.referenceAngle}else{_this.m_referenceAngle=bodyB.getAngle()-bodyA.getAngle()}_this.m_impulse=new Vec3;_this.m_motorImpulse=0;_this.m_lowerAngle=(_a2=def.lowerAngle)!==null&&_a2!==void 0?_a2:DEFAULTS$8.lowerAngle;_this.m_upperAngle=(_b=def.upperAngle)!==null&&_b!==void 0?_b:DEFAULTS$8.upperAngle;_this.m_maxMotorTorque=(_c=def.maxMotorTorque)!==null&&_c!==void 0?_c:DEFAULTS$8.maxMotorTorque;_this.m_motorSpeed=(_d=def.motorSpeed)!==null&&_d!==void 0?_d:DEFAULTS$8.motorSpeed;_this.m_enableLimit=(_e=def.enableLimit)!==null&&_e!==void 0?_e:DEFAULTS$8.enableLimit;_this.m_enableMotor=(_f=def.enableMotor)!==null&&_f!==void 0?_f:DEFAULTS$8.enableMotor;return _this}RevoluteJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,lowerAngle:this.m_lowerAngle,upperAngle:this.m_upperAngle,maxMotorTorque:this.m_maxMotorTorque,motorSpeed:this.m_motorSpeed,enableLimit:this.m_enableLimit,enableMotor:this.m_enableMotor,localAnchorA:this.m_localAnchorA,localAnchorB:this.m_localAnchorB,referenceAngle:this.m_referenceAngle}};RevoluteJoint2._deserialize=function(data,world,restore){data=__assign({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);var joint=new RevoluteJoint2(data);return joint};RevoluteJoint2.prototype._reset=function(def){if(def.anchorA){this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA))}else if(def.localAnchorA){this.m_localAnchorA.setVec2(def.localAnchorA)}if(def.anchorB){this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB))}else if(def.localAnchorB){this.m_localAnchorB.setVec2(def.localAnchorB)}if(Number.isFinite(def.referenceAngle)){this.m_referenceAngle=def.referenceAngle}if(def.enableLimit!==void 0){this.m_enableLimit=def.enableLimit}if(Number.isFinite(def.lowerAngle)){this.m_lowerAngle=def.lowerAngle}if(Number.isFinite(def.upperAngle)){this.m_upperAngle=def.upperAngle}if(Number.isFinite(def.maxMotorTorque)){this.m_maxMotorTorque=def.maxMotorTorque}if(Number.isFinite(def.motorSpeed)){this.m_motorSpeed=def.motorSpeed}if(def.enableMotor!==void 0){this.m_enableMotor=def.enableMotor}};RevoluteJoint2.prototype.getLocalAnchorA=function(){return this.m_localAnchorA};RevoluteJoint2.prototype.getLocalAnchorB=function(){return this.m_localAnchorB};RevoluteJoint2.prototype.getReferenceAngle=function(){return this.m_referenceAngle};RevoluteJoint2.prototype.getJointAngle=function(){var bA=this.m_bodyA;var bB=this.m_bodyB;return bB.m_sweep.a-bA.m_sweep.a-this.m_referenceAngle};RevoluteJoint2.prototype.getJointSpeed=function(){var bA=this.m_bodyA;var bB=this.m_bodyB;return bB.m_angularVelocity-bA.m_angularVelocity};RevoluteJoint2.prototype.isMotorEnabled=function(){return this.m_enableMotor};RevoluteJoint2.prototype.enableMotor=function(flag){if(flag==this.m_enableMotor)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_enableMotor=flag};RevoluteJoint2.prototype.getMotorTorque=function(inv_dt){return inv_dt*this.m_motorImpulse};RevoluteJoint2.prototype.setMotorSpeed=function(speed){if(speed==this.m_motorSpeed)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_motorSpeed=speed};RevoluteJoint2.prototype.getMotorSpeed=function(){return this.m_motorSpeed};RevoluteJoint2.prototype.setMaxMotorTorque=function(torque){if(torque==this.m_maxMotorTorque)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_maxMotorTorque=torque};RevoluteJoint2.prototype.getMaxMotorTorque=function(){return this.m_maxMotorTorque};RevoluteJoint2.prototype.isLimitEnabled=function(){return this.m_enableLimit};RevoluteJoint2.prototype.enableLimit=function(flag){if(flag!=this.m_enableLimit){this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_enableLimit=flag;this.m_impulse.z=0}};RevoluteJoint2.prototype.getLowerLimit=function(){return this.m_lowerAngle};RevoluteJoint2.prototype.getUpperLimit=function(){return this.m_upperAngle};RevoluteJoint2.prototype.setLimits=function(lower,upper){if(lower!=this.m_lowerAngle||upper!=this.m_upperAngle){this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_impulse.z=0;this.m_lowerAngle=lower;this.m_upperAngle=upper}};RevoluteJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};RevoluteJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};RevoluteJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.neo(this.m_impulse.x,this.m_impulse.y).mul(inv_dt)};RevoluteJoint2.prototype.getReactionTorque=function(inv_dt){return inv_dt*this.m_impulse.z};RevoluteJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter;this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);this.m_rA=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));this.m_rB=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var fixedRotation=iA+iB===0;this.m_mass.ex.x=mA+mB+this.m_rA.y*this.m_rA.y*iA+this.m_rB.y*this.m_rB.y*iB;this.m_mass.ey.x=-this.m_rA.y*this.m_rA.x*iA-this.m_rB.y*this.m_rB.x*iB;this.m_mass.ez.x=-this.m_rA.y*iA-this.m_rB.y*iB;this.m_mass.ex.y=this.m_mass.ey.x;this.m_mass.ey.y=mA+mB+this.m_rA.x*this.m_rA.x*iA+this.m_rB.x*this.m_rB.x*iB;this.m_mass.ez.y=this.m_rA.x*iA+this.m_rB.x*iB;this.m_mass.ex.z=this.m_mass.ez.x;this.m_mass.ey.z=this.m_mass.ez.y;this.m_mass.ez.z=iA+iB;this.m_motorMass=iA+iB;if(this.m_motorMass>0){this.m_motorMass=1/this.m_motorMass}if(this.m_enableMotor==false||fixedRotation){this.m_motorImpulse=0}if(this.m_enableLimit&&fixedRotation==false){var jointAngle=aB-aA-this.m_referenceAngle;if(math_abs$4(this.m_upperAngle-this.m_lowerAngle)<2*SettingsInternal.angularSlop){this.m_limitState=LimitState$2.equalLimits}else if(jointAngle<=this.m_lowerAngle){if(this.m_limitState!=LimitState$2.atLowerLimit){this.m_impulse.z=0}this.m_limitState=LimitState$2.atLowerLimit}else if(jointAngle>=this.m_upperAngle){if(this.m_limitState!=LimitState$2.atUpperLimit){this.m_impulse.z=0}this.m_limitState=LimitState$2.atUpperLimit}else{this.m_limitState=LimitState$2.inactiveLimit;this.m_impulse.z=0}}else{this.m_limitState=LimitState$2.inactiveLimit}if(step.warmStarting){this.m_impulse.mul(step.dtRatio);this.m_motorImpulse*=step.dtRatio;var P3=Vec2.neo(this.m_impulse.x,this.m_impulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+this.m_motorImpulse+this.m_impulse.z);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+this.m_motorImpulse+this.m_impulse.z)}else{this.m_impulse.setZero();this.m_motorImpulse=0}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};RevoluteJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var fixedRotation=iA+iB===0;if(this.m_enableMotor&&this.m_limitState!=LimitState$2.equalLimits&&fixedRotation==false){var Cdot=wB-wA-this.m_motorSpeed;var impulse=-this.m_motorMass*Cdot;var oldImpulse=this.m_motorImpulse;var maxImpulse=step.dt*this.m_maxMotorTorque;this.m_motorImpulse=clamp(this.m_motorImpulse+impulse,-maxImpulse,maxImpulse);impulse=this.m_motorImpulse-oldImpulse;wA-=iA*impulse;wB+=iB*impulse}if(this.m_enableLimit&&this.m_limitState!=LimitState$2.inactiveLimit&&fixedRotation==false){var Cdot1=Vec2.zero();Cdot1.addCombine(1,vB2,1,Vec2.crossNumVec2(wB,this.m_rB));Cdot1.subCombine(1,vA2,1,Vec2.crossNumVec2(wA,this.m_rA));var Cdot2=wB-wA;var Cdot=new Vec3(Cdot1.x,Cdot1.y,Cdot2);var impulse=Vec3.neg(this.m_mass.solve33(Cdot));if(this.m_limitState==LimitState$2.equalLimits){this.m_impulse.add(impulse)}else if(this.m_limitState==LimitState$2.atLowerLimit){var newImpulse=this.m_impulse.z+impulse.z;if(newImpulse<0){var rhs=Vec2.combine(-1,Cdot1,this.m_impulse.z,Vec2.neo(this.m_mass.ez.x,this.m_mass.ez.y));var reduced=this.m_mass.solve22(rhs);impulse.x=reduced.x;impulse.y=reduced.y;impulse.z=-this.m_impulse.z;this.m_impulse.x+=reduced.x;this.m_impulse.y+=reduced.y;this.m_impulse.z=0}else{this.m_impulse.add(impulse)}}else if(this.m_limitState==LimitState$2.atUpperLimit){var newImpulse=this.m_impulse.z+impulse.z;if(newImpulse>0){var rhs=Vec2.combine(-1,Cdot1,this.m_impulse.z,Vec2.neo(this.m_mass.ez.x,this.m_mass.ez.y));var reduced=this.m_mass.solve22(rhs);impulse.x=reduced.x;impulse.y=reduced.y;impulse.z=-this.m_impulse.z;this.m_impulse.x+=reduced.x;this.m_impulse.y+=reduced.y;this.m_impulse.z=0}else{this.m_impulse.add(impulse)}}var P3=Vec2.neo(impulse.x,impulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+impulse.z);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+impulse.z)}else{var Cdot=Vec2.zero();Cdot.addCombine(1,vB2,1,Vec2.crossNumVec2(wB,this.m_rB));Cdot.subCombine(1,vA2,1,Vec2.crossNumVec2(wA,this.m_rA));var impulse=this.m_mass.solve22(Vec2.neg(Cdot));this.m_impulse.x+=impulse.x;this.m_impulse.y+=impulse.y;vA2.subMul(mA,impulse);wA-=iA*Vec2.crossVec2Vec2(this.m_rA,impulse);vB2.addMul(mB,impulse);wB+=iB*Vec2.crossVec2Vec2(this.m_rB,impulse)}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};RevoluteJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var angularError=0;var positionError=0;var fixedRotation=this.m_invIA+this.m_invIB==0;if(this.m_enableLimit&&this.m_limitState!=LimitState$2.inactiveLimit&&fixedRotation==false){var angle=aB-aA-this.m_referenceAngle;var limitImpulse=0;if(this.m_limitState==LimitState$2.equalLimits){var C=clamp(angle-this.m_lowerAngle,-SettingsInternal.maxAngularCorrection,SettingsInternal.maxAngularCorrection);limitImpulse=-this.m_motorMass*C;angularError=math_abs$4(C)}else if(this.m_limitState==LimitState$2.atLowerLimit){var C=angle-this.m_lowerAngle;angularError=-C;C=clamp(C+SettingsInternal.angularSlop,-SettingsInternal.maxAngularCorrection,0);limitImpulse=-this.m_motorMass*C}else if(this.m_limitState==LimitState$2.atUpperLimit){var C=angle-this.m_upperAngle;angularError=C;C=clamp(C-SettingsInternal.angularSlop,0,SettingsInternal.maxAngularCorrection);limitImpulse=-this.m_motorMass*C}aA-=this.m_invIA*limitImpulse;aB+=this.m_invIB*limitImpulse}{qA.setAngle(aA);qB.setAngle(aB);var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var C=Vec2.zero();C.addCombine(1,cB2,1,rB2);C.subCombine(1,cA2,1,rA2);positionError=C.length();var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var K=new Mat22;K.ex.x=mA+mB+iA*rA2.y*rA2.y+iB*rB2.y*rB2.y;K.ex.y=-iA*rA2.x*rA2.y-iB*rB2.x*rB2.y;K.ey.x=K.ex.y;K.ey.y=mA+mB+iA*rA2.x*rA2.x+iB*rB2.x*rB2.x;var impulse=Vec2.neg(K.solve(C));cA2.subMul(mA,impulse);aA-=iA*Vec2.crossVec2Vec2(rA2,impulse);cB2.addMul(mB,impulse);aB+=iB*Vec2.crossVec2Vec2(rB2,impulse)}this.m_bodyA.c_position.c.setVec2(cA2);this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c.setVec2(cB2);this.m_bodyB.c_position.a=aB;return positionError<=SettingsInternal.linearSlop&&angularError<=SettingsInternal.angularSlop};RevoluteJoint2.TYPE="revolute-joint";return RevoluteJoint2}(Joint);var math_abs$3=Math.abs;var math_max=Math.max;var math_min$2=Math.min;var LimitState$1;(function(LimitState2){LimitState2[LimitState2["inactiveLimit"]=0]="inactiveLimit";LimitState2[LimitState2["atLowerLimit"]=1]="atLowerLimit";LimitState2[LimitState2["atUpperLimit"]=2]="atUpperLimit";LimitState2[LimitState2["equalLimits"]=3]="equalLimits"})(LimitState$1||(LimitState$1={}));var DEFAULTS$7={enableLimit:false,lowerTranslation:0,upperTranslation:0,enableMotor:false,maxMotorForce:0,motorSpeed:0};var PrismaticJoint=function(_super){__extends(PrismaticJoint2,_super);function PrismaticJoint2(def,bodyA,bodyB,anchor,axis){var _this=this;if(!(_this instanceof PrismaticJoint2)){return new PrismaticJoint2(def,bodyA,bodyB,anchor,axis)}def=options(def,DEFAULTS$7);_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_type=PrismaticJoint2.TYPE;_this.m_localAnchorA=Vec2.clone(anchor?bodyA.getLocalPoint(anchor):def.localAnchorA||Vec2.zero());_this.m_localAnchorB=Vec2.clone(anchor?bodyB.getLocalPoint(anchor):def.localAnchorB||Vec2.zero());_this.m_localXAxisA=Vec2.clone(axis?bodyA.getLocalVector(axis):def.localAxisA||Vec2.neo(1,0));_this.m_localXAxisA.normalize();_this.m_localYAxisA=Vec2.crossNumVec2(1,_this.m_localXAxisA);_this.m_referenceAngle=Number.isFinite(def.referenceAngle)?def.referenceAngle:bodyB.getAngle()-bodyA.getAngle();_this.m_impulse=new Vec3;_this.m_motorMass=0;_this.m_motorImpulse=0;_this.m_lowerTranslation=def.lowerTranslation;_this.m_upperTranslation=def.upperTranslation;_this.m_maxMotorForce=def.maxMotorForce;_this.m_motorSpeed=def.motorSpeed;_this.m_enableLimit=def.enableLimit;_this.m_enableMotor=def.enableMotor;_this.m_limitState=LimitState$1.inactiveLimit;_this.m_axis=Vec2.zero();_this.m_perp=Vec2.zero();_this.m_K=new Mat33;return _this}PrismaticJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,lowerTranslation:this.m_lowerTranslation,upperTranslation:this.m_upperTranslation,maxMotorForce:this.m_maxMotorForce,motorSpeed:this.m_motorSpeed,enableLimit:this.m_enableLimit,enableMotor:this.m_enableMotor,localAnchorA:this.m_localAnchorA,localAnchorB:this.m_localAnchorB,localAxisA:this.m_localXAxisA,referenceAngle:this.m_referenceAngle}};PrismaticJoint2._deserialize=function(data,world,restore){data=__assign({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);data.localAxisA=Vec2.clone(data.localAxisA);var joint=new PrismaticJoint2(data);return joint};PrismaticJoint2.prototype._reset=function(def){if(def.anchorA){this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA))}else if(def.localAnchorA){this.m_localAnchorA.setVec2(def.localAnchorA)}if(def.anchorB){this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB))}else if(def.localAnchorB){this.m_localAnchorB.setVec2(def.localAnchorB)}if(def.localAxisA){this.m_localXAxisA.setVec2(def.localAxisA);this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1,def.localAxisA))}if(Number.isFinite(def.referenceAngle)){this.m_referenceAngle=def.referenceAngle}if(typeof def.enableLimit!=="undefined"){this.m_enableLimit=!!def.enableLimit}if(Number.isFinite(def.lowerTranslation)){this.m_lowerTranslation=def.lowerTranslation}if(Number.isFinite(def.upperTranslation)){this.m_upperTranslation=def.upperTranslation}if(typeof def.enableMotor!=="undefined"){this.m_enableMotor=!!def.enableMotor}if(Number.isFinite(def.maxMotorForce)){this.m_maxMotorForce=def.maxMotorForce}if(Number.isFinite(def.motorSpeed)){this.m_motorSpeed=def.motorSpeed}};PrismaticJoint2.prototype.getLocalAnchorA=function(){return this.m_localAnchorA};PrismaticJoint2.prototype.getLocalAnchorB=function(){return this.m_localAnchorB};PrismaticJoint2.prototype.getLocalAxisA=function(){return this.m_localXAxisA};PrismaticJoint2.prototype.getReferenceAngle=function(){return this.m_referenceAngle};PrismaticJoint2.prototype.getJointTranslation=function(){var pA2=this.m_bodyA.getWorldPoint(this.m_localAnchorA);var pB2=this.m_bodyB.getWorldPoint(this.m_localAnchorB);var d2=Vec2.sub(pB2,pA2);var axis=this.m_bodyA.getWorldVector(this.m_localXAxisA);var translation2=Vec2.dot(d2,axis);return translation2};PrismaticJoint2.prototype.getJointSpeed=function(){var bA=this.m_bodyA;var bB=this.m_bodyB;var rA2=Rot.mulVec2(bA.m_xf.q,Vec2.sub(this.m_localAnchorA,bA.m_sweep.localCenter));var rB2=Rot.mulVec2(bB.m_xf.q,Vec2.sub(this.m_localAnchorB,bB.m_sweep.localCenter));var p1=Vec2.add(bA.m_sweep.c,rA2);var p2=Vec2.add(bB.m_sweep.c,rB2);var d2=Vec2.sub(p2,p1);var axis=Rot.mulVec2(bA.m_xf.q,this.m_localXAxisA);var vA2=bA.m_linearVelocity;var vB2=bB.m_linearVelocity;var wA=bA.m_angularVelocity;var wB=bB.m_angularVelocity;var speed=Vec2.dot(d2,Vec2.crossNumVec2(wA,axis))+Vec2.dot(axis,Vec2.sub(Vec2.addCrossNumVec2(vB2,wB,rB2),Vec2.addCrossNumVec2(vA2,wA,rA2)));return speed};PrismaticJoint2.prototype.isLimitEnabled=function(){return this.m_enableLimit};PrismaticJoint2.prototype.enableLimit=function(flag){if(flag!=this.m_enableLimit){this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_enableLimit=flag;this.m_impulse.z=0}};PrismaticJoint2.prototype.getLowerLimit=function(){return this.m_lowerTranslation};PrismaticJoint2.prototype.getUpperLimit=function(){return this.m_upperTranslation};PrismaticJoint2.prototype.setLimits=function(lower,upper){if(lower!=this.m_lowerTranslation||upper!=this.m_upperTranslation){this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_lowerTranslation=lower;this.m_upperTranslation=upper;this.m_impulse.z=0}};PrismaticJoint2.prototype.isMotorEnabled=function(){return this.m_enableMotor};PrismaticJoint2.prototype.enableMotor=function(flag){if(flag==this.m_enableMotor)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_enableMotor=flag};PrismaticJoint2.prototype.setMotorSpeed=function(speed){if(speed==this.m_motorSpeed)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_motorSpeed=speed};PrismaticJoint2.prototype.setMaxMotorForce=function(force){if(force==this.m_maxMotorForce)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_maxMotorForce=force};PrismaticJoint2.prototype.getMaxMotorForce=function(){return this.m_maxMotorForce};PrismaticJoint2.prototype.getMotorSpeed=function(){return this.m_motorSpeed};PrismaticJoint2.prototype.getMotorForce=function(inv_dt){return inv_dt*this.m_motorImpulse};PrismaticJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};PrismaticJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};PrismaticJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.combine(this.m_impulse.x,this.m_perp,this.m_motorImpulse+this.m_impulse.z,this.m_axis).mul(inv_dt)};PrismaticJoint2.prototype.getReactionTorque=function(inv_dt){return inv_dt*this.m_impulse.y};PrismaticJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter;this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var d2=Vec2.zero();d2.addCombine(1,cB2,1,rB2);d2.subCombine(1,cA2,1,rA2);var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;{this.m_axis=Rot.mulVec2(qA,this.m_localXAxisA);this.m_a1=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),this.m_axis);this.m_a2=Vec2.crossVec2Vec2(rB2,this.m_axis);this.m_motorMass=mA+mB+iA*this.m_a1*this.m_a1+iB*this.m_a2*this.m_a2;if(this.m_motorMass>0){this.m_motorMass=1/this.m_motorMass}}{this.m_perp=Rot.mulVec2(qA,this.m_localYAxisA);this.m_s1=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),this.m_perp);this.m_s2=Vec2.crossVec2Vec2(rB2,this.m_perp);Vec2.crossVec2Vec2(rA2,this.m_perp);var k11=mA+mB+iA*this.m_s1*this.m_s1+iB*this.m_s2*this.m_s2;var k12=iA*this.m_s1+iB*this.m_s2;var k13=iA*this.m_s1*this.m_a1+iB*this.m_s2*this.m_a2;var k22=iA+iB;if(k22==0){k22=1}var k23=iA*this.m_a1+iB*this.m_a2;var k33=mA+mB+iA*this.m_a1*this.m_a1+iB*this.m_a2*this.m_a2;this.m_K.ex.set(k11,k12,k13);this.m_K.ey.set(k12,k22,k23);this.m_K.ez.set(k13,k23,k33)}if(this.m_enableLimit){var jointTranslation=Vec2.dot(this.m_axis,d2);if(math_abs$3(this.m_upperTranslation-this.m_lowerTranslation)<2*SettingsInternal.linearSlop){this.m_limitState=LimitState$1.equalLimits}else if(jointTranslation<=this.m_lowerTranslation){if(this.m_limitState!=LimitState$1.atLowerLimit){this.m_limitState=LimitState$1.atLowerLimit;this.m_impulse.z=0}}else if(jointTranslation>=this.m_upperTranslation){if(this.m_limitState!=LimitState$1.atUpperLimit){this.m_limitState=LimitState$1.atUpperLimit;this.m_impulse.z=0}}else{this.m_limitState=LimitState$1.inactiveLimit;this.m_impulse.z=0}}else{this.m_limitState=LimitState$1.inactiveLimit;this.m_impulse.z=0}if(this.m_enableMotor==false){this.m_motorImpulse=0}if(step.warmStarting){this.m_impulse.mul(step.dtRatio);this.m_motorImpulse*=step.dtRatio;var P3=Vec2.combine(this.m_impulse.x,this.m_perp,this.m_motorImpulse+this.m_impulse.z,this.m_axis);var LA=this.m_impulse.x*this.m_s1+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a1;var LB=this.m_impulse.x*this.m_s2+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a2;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}else{this.m_impulse.setZero();this.m_motorImpulse=0}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};PrismaticJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;if(this.m_enableMotor&&this.m_limitState!=LimitState$1.equalLimits){var Cdot=Vec2.dot(this.m_axis,Vec2.sub(vB2,vA2))+this.m_a2*wB-this.m_a1*wA;var impulse=this.m_motorMass*(this.m_motorSpeed-Cdot);var oldImpulse=this.m_motorImpulse;var maxImpulse=step.dt*this.m_maxMotorForce;this.m_motorImpulse=clamp(this.m_motorImpulse+impulse,-maxImpulse,maxImpulse);impulse=this.m_motorImpulse-oldImpulse;var P3=Vec2.mulNumVec2(impulse,this.m_axis);var LA=impulse*this.m_a1;var LB=impulse*this.m_a2;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}var Cdot1=Vec2.zero();Cdot1.x+=Vec2.dot(this.m_perp,vB2)+this.m_s2*wB;Cdot1.x-=Vec2.dot(this.m_perp,vA2)+this.m_s1*wA;Cdot1.y=wB-wA;if(this.m_enableLimit&&this.m_limitState!=LimitState$1.inactiveLimit){var Cdot2=0;Cdot2+=Vec2.dot(this.m_axis,vB2)+this.m_a2*wB;Cdot2-=Vec2.dot(this.m_axis,vA2)+this.m_a1*wA;var Cdot=new Vec3(Cdot1.x,Cdot1.y,Cdot2);var f1=Vec3.clone(this.m_impulse);var df=this.m_K.solve33(Vec3.neg(Cdot));this.m_impulse.add(df);if(this.m_limitState==LimitState$1.atLowerLimit){this.m_impulse.z=math_max(this.m_impulse.z,0)}else if(this.m_limitState==LimitState$1.atUpperLimit){this.m_impulse.z=math_min$2(this.m_impulse.z,0)}var b2=Vec2.combine(-1,Cdot1,-(this.m_impulse.z-f1.z),Vec2.neo(this.m_K.ez.x,this.m_K.ez.y));var f2r=Vec2.add(this.m_K.solve22(b2),Vec2.neo(f1.x,f1.y));this.m_impulse.x=f2r.x;this.m_impulse.y=f2r.y;df=Vec3.sub(this.m_impulse,f1);var P3=Vec2.combine(df.x,this.m_perp,df.z,this.m_axis);var LA=df.x*this.m_s1+df.y+df.z*this.m_a1;var LB=df.x*this.m_s2+df.y+df.z*this.m_a2;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}else{var df=this.m_K.solve22(Vec2.neg(Cdot1));this.m_impulse.x+=df.x;this.m_impulse.y+=df.y;var P3=Vec2.mulNumVec2(df.x,this.m_perp);var LA=df.x*this.m_s1+df.y;var LB=df.x*this.m_s2+df.y;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};PrismaticJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var d2=Vec2.sub(Vec2.add(cB2,rB2),Vec2.add(cA2,rA2));var axis=Rot.mulVec2(qA,this.m_localXAxisA);var a1=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),axis);var a2=Vec2.crossVec2Vec2(rB2,axis);var perp2=Rot.mulVec2(qA,this.m_localYAxisA);var s1=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),perp2);var s2=Vec2.crossVec2Vec2(rB2,perp2);var impulse=new Vec3;var C1=Vec2.zero();C1.x=Vec2.dot(perp2,d2);C1.y=aB-aA-this.m_referenceAngle;var linearError=math_abs$3(C1.x);var angularError=math_abs$3(C1.y);var linearSlop=SettingsInternal.linearSlop;var maxLinearCorrection=SettingsInternal.maxLinearCorrection;var active=false;var C2=0;if(this.m_enableLimit){var translation2=Vec2.dot(axis,d2);if(math_abs$3(this.m_upperTranslation-this.m_lowerTranslation)<2*linearSlop){C2=clamp(translation2,-maxLinearCorrection,maxLinearCorrection);linearError=math_max(linearError,math_abs$3(translation2));active=true}else if(translation2<=this.m_lowerTranslation){C2=clamp(translation2-this.m_lowerTranslation+linearSlop,-maxLinearCorrection,0);linearError=Math.max(linearError,this.m_lowerTranslation-translation2);active=true}else if(translation2>=this.m_upperTranslation){C2=clamp(translation2-this.m_upperTranslation-linearSlop,0,maxLinearCorrection);linearError=Math.max(linearError,translation2-this.m_upperTranslation);active=true}}if(active){var k11=mA+mB+iA*s1*s1+iB*s2*s2;var k12=iA*s1+iB*s2;var k13=iA*s1*a1+iB*s2*a2;var k22=iA+iB;if(k22==0){k22=1}var k23=iA*a1+iB*a2;var k33=mA+mB+iA*a1*a1+iB*a2*a2;var K=new Mat33;K.ex.set(k11,k12,k13);K.ey.set(k12,k22,k23);K.ez.set(k13,k23,k33);var C=new Vec3;C.x=C1.x;C.y=C1.y;C.z=C2;impulse=K.solve33(Vec3.neg(C))}else{var k11=mA+mB+iA*s1*s1+iB*s2*s2;var k12=iA*s1+iB*s2;var k22=iA+iB;if(k22==0){k22=1}var K=new Mat22;K.ex.setNum(k11,k12);K.ey.setNum(k12,k22);var impulse1=K.solve(Vec2.neg(C1));impulse.x=impulse1.x;impulse.y=impulse1.y;impulse.z=0}var P3=Vec2.combine(impulse.x,perp2,impulse.z,axis);var LA=impulse.x*s1+impulse.y+impulse.z*a1;var LB=impulse.x*s2+impulse.y+impulse.z*a2;cA2.subMul(mA,P3);aA-=iA*LA;cB2.addMul(mB,P3);aB+=iB*LB;this.m_bodyA.c_position.c=cA2;this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c=cB2;this.m_bodyB.c_position.a=aB;return linearError<=SettingsInternal.linearSlop&&angularError<=SettingsInternal.angularSlop};PrismaticJoint2.TYPE="prismatic-joint";return PrismaticJoint2}(Joint);var DEFAULTS$6={ratio:1};var GearJoint=function(_super){__extends(GearJoint2,_super);function GearJoint2(def,bodyA,bodyB,joint1,joint2,ratio){var _this=this;if(!(_this instanceof GearJoint2)){return new GearJoint2(def,bodyA,bodyB,joint1,joint2,ratio)}def=options(def,DEFAULTS$6);_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_type=GearJoint2.TYPE;_this.m_joint1=joint1?joint1:def.joint1;_this.m_joint2=joint2?joint2:def.joint2;_this.m_ratio=Number.isFinite(ratio)?ratio:def.ratio;_this.m_type1=_this.m_joint1.getType();_this.m_type2=_this.m_joint2.getType();var coordinateA;var coordinateB;_this.m_bodyC=_this.m_joint1.getBodyA();_this.m_bodyA=_this.m_joint1.getBodyB();var xfA2=_this.m_bodyA.m_xf;var aA=_this.m_bodyA.m_sweep.a;var xfC=_this.m_bodyC.m_xf;var aC=_this.m_bodyC.m_sweep.a;if(_this.m_type1===RevoluteJoint.TYPE){var revolute=_this.m_joint1;_this.m_localAnchorC=revolute.m_localAnchorA;_this.m_localAnchorA=revolute.m_localAnchorB;_this.m_referenceAngleA=revolute.m_referenceAngle;_this.m_localAxisC=Vec2.zero();coordinateA=aA-aC-_this.m_referenceAngleA}else{var prismatic=_this.m_joint1;_this.m_localAnchorC=prismatic.m_localAnchorA;_this.m_localAnchorA=prismatic.m_localAnchorB;_this.m_referenceAngleA=prismatic.m_referenceAngle;_this.m_localAxisC=prismatic.m_localXAxisA;var pC=_this.m_localAnchorC;var pA2=Rot.mulTVec2(xfC.q,Vec2.add(Rot.mulVec2(xfA2.q,_this.m_localAnchorA),Vec2.sub(xfA2.p,xfC.p)));coordinateA=Vec2.dot(pA2,_this.m_localAxisC)-Vec2.dot(pC,_this.m_localAxisC)}_this.m_bodyD=_this.m_joint2.getBodyA();_this.m_bodyB=_this.m_joint2.getBodyB();var xfB2=_this.m_bodyB.m_xf;var aB=_this.m_bodyB.m_sweep.a;var xfD=_this.m_bodyD.m_xf;var aD=_this.m_bodyD.m_sweep.a;if(_this.m_type2===RevoluteJoint.TYPE){var revolute=_this.m_joint2;_this.m_localAnchorD=revolute.m_localAnchorA;_this.m_localAnchorB=revolute.m_localAnchorB;_this.m_referenceAngleB=revolute.m_referenceAngle;_this.m_localAxisD=Vec2.zero();coordinateB=aB-aD-_this.m_referenceAngleB}else{var prismatic=_this.m_joint2;_this.m_localAnchorD=prismatic.m_localAnchorA;_this.m_localAnchorB=prismatic.m_localAnchorB;_this.m_referenceAngleB=prismatic.m_referenceAngle;_this.m_localAxisD=prismatic.m_localXAxisA;var pD=_this.m_localAnchorD;var pB2=Rot.mulTVec2(xfD.q,Vec2.add(Rot.mulVec2(xfB2.q,_this.m_localAnchorB),Vec2.sub(xfB2.p,xfD.p)));coordinateB=Vec2.dot(pB2,_this.m_localAxisD)-Vec2.dot(pD,_this.m_localAxisD)}_this.m_constant=coordinateA+_this.m_ratio*coordinateB;_this.m_impulse=0;return _this}GearJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,joint1:this.m_joint1,joint2:this.m_joint2,ratio:this.m_ratio}};GearJoint2._deserialize=function(data,world,restore){data=__assign({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);data.joint1=restore(Joint,data.joint1,world);data.joint2=restore(Joint,data.joint2,world);var joint=new GearJoint2(data);return joint};GearJoint2.prototype._reset=function(def){if(Number.isFinite(def.ratio)){this.m_ratio=def.ratio}};GearJoint2.prototype.getJoint1=function(){return this.m_joint1};GearJoint2.prototype.getJoint2=function(){return this.m_joint2};GearJoint2.prototype.setRatio=function(ratio){this.m_ratio=ratio};GearJoint2.prototype.getRatio=function(){return this.m_ratio};GearJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};GearJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};GearJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.mulNumVec2(this.m_impulse,this.m_JvAC).mul(inv_dt)};GearJoint2.prototype.getReactionTorque=function(inv_dt){var L=this.m_impulse*this.m_JwA;return inv_dt*L};GearJoint2.prototype.initVelocityConstraints=function(step){this.m_lcA=this.m_bodyA.m_sweep.localCenter;this.m_lcB=this.m_bodyB.m_sweep.localCenter;this.m_lcC=this.m_bodyC.m_sweep.localCenter;this.m_lcD=this.m_bodyD.m_sweep.localCenter;this.m_mA=this.m_bodyA.m_invMass;this.m_mB=this.m_bodyB.m_invMass;this.m_mC=this.m_bodyC.m_invMass;this.m_mD=this.m_bodyD.m_invMass;this.m_iA=this.m_bodyA.m_invI;this.m_iB=this.m_bodyB.m_invI;this.m_iC=this.m_bodyC.m_invI;this.m_iD=this.m_bodyD.m_invI;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var aC=this.m_bodyC.c_position.a;var vC=this.m_bodyC.c_velocity.v;var wC=this.m_bodyC.c_velocity.w;var aD=this.m_bodyD.c_position.a;var vD=this.m_bodyD.c_velocity.v;var wD=this.m_bodyD.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var qC=Rot.neo(aC);var qD=Rot.neo(aD);this.m_mass=0;if(this.m_type1==RevoluteJoint.TYPE){this.m_JvAC=Vec2.zero();this.m_JwA=1;this.m_JwC=1;this.m_mass+=this.m_iA+this.m_iC}else{var u=Rot.mulVec2(qC,this.m_localAxisC);var rC=Rot.mulSub(qC,this.m_localAnchorC,this.m_lcC);var rA2=Rot.mulSub(qA,this.m_localAnchorA,this.m_lcA);this.m_JvAC=u;this.m_JwC=Vec2.crossVec2Vec2(rC,u);this.m_JwA=Vec2.crossVec2Vec2(rA2,u);this.m_mass+=this.m_mC+this.m_mA+this.m_iC*this.m_JwC*this.m_JwC+this.m_iA*this.m_JwA*this.m_JwA}if(this.m_type2==RevoluteJoint.TYPE){this.m_JvBD=Vec2.zero();this.m_JwB=this.m_ratio;this.m_JwD=this.m_ratio;this.m_mass+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD)}else{var u=Rot.mulVec2(qD,this.m_localAxisD);var rD=Rot.mulSub(qD,this.m_localAnchorD,this.m_lcD);var rB2=Rot.mulSub(qB,this.m_localAnchorB,this.m_lcB);this.m_JvBD=Vec2.mulNumVec2(this.m_ratio,u);this.m_JwD=this.m_ratio*Vec2.crossVec2Vec2(rD,u);this.m_JwB=this.m_ratio*Vec2.crossVec2Vec2(rB2,u);this.m_mass+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*this.m_JwD*this.m_JwD+this.m_iB*this.m_JwB*this.m_JwB}this.m_mass=this.m_mass>0?1/this.m_mass:0;if(step.warmStarting){vA2.addMul(this.m_mA*this.m_impulse,this.m_JvAC);wA+=this.m_iA*this.m_impulse*this.m_JwA;vB2.addMul(this.m_mB*this.m_impulse,this.m_JvBD);wB+=this.m_iB*this.m_impulse*this.m_JwB;vC.subMul(this.m_mC*this.m_impulse,this.m_JvAC);wC-=this.m_iC*this.m_impulse*this.m_JwC;vD.subMul(this.m_mD*this.m_impulse,this.m_JvBD);wD-=this.m_iD*this.m_impulse*this.m_JwD}else{this.m_impulse=0}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB;this.m_bodyC.c_velocity.v.setVec2(vC);this.m_bodyC.c_velocity.w=wC;this.m_bodyD.c_velocity.v.setVec2(vD);this.m_bodyD.c_velocity.w=wD};GearJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var vC=this.m_bodyC.c_velocity.v;var wC=this.m_bodyC.c_velocity.w;var vD=this.m_bodyD.c_velocity.v;var wD=this.m_bodyD.c_velocity.w;var Cdot=Vec2.dot(this.m_JvAC,vA2)-Vec2.dot(this.m_JvAC,vC)+Vec2.dot(this.m_JvBD,vB2)-Vec2.dot(this.m_JvBD,vD);Cdot+=this.m_JwA*wA-this.m_JwC*wC+(this.m_JwB*wB-this.m_JwD*wD);var impulse=-this.m_mass*Cdot;this.m_impulse+=impulse;vA2.addMul(this.m_mA*impulse,this.m_JvAC);wA+=this.m_iA*impulse*this.m_JwA;vB2.addMul(this.m_mB*impulse,this.m_JvBD);wB+=this.m_iB*impulse*this.m_JwB;vC.subMul(this.m_mC*impulse,this.m_JvAC);wC-=this.m_iC*impulse*this.m_JwC;vD.subMul(this.m_mD*impulse,this.m_JvBD);wD-=this.m_iD*impulse*this.m_JwD;this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB;this.m_bodyC.c_velocity.v.setVec2(vC);this.m_bodyC.c_velocity.w=wC;this.m_bodyD.c_velocity.v.setVec2(vD);this.m_bodyD.c_velocity.w=wD};GearJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var cC=this.m_bodyC.c_position.c;var aC=this.m_bodyC.c_position.a;var cD=this.m_bodyD.c_position.c;var aD=this.m_bodyD.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var qC=Rot.neo(aC);var qD=Rot.neo(aD);var linearError=0;var coordinateA;var coordinateB;var JvAC;var JvBD;var JwA;var JwB;var JwC;var JwD;var mass=0;if(this.m_type1==RevoluteJoint.TYPE){JvAC=Vec2.zero();JwA=1;JwC=1;mass+=this.m_iA+this.m_iC;coordinateA=aA-aC-this.m_referenceAngleA}else{var u=Rot.mulVec2(qC,this.m_localAxisC);var rC=Rot.mulSub(qC,this.m_localAnchorC,this.m_lcC);var rA2=Rot.mulSub(qA,this.m_localAnchorA,this.m_lcA);JvAC=u;JwC=Vec2.crossVec2Vec2(rC,u);JwA=Vec2.crossVec2Vec2(rA2,u);mass+=this.m_mC+this.m_mA+this.m_iC*JwC*JwC+this.m_iA*JwA*JwA;var pC=Vec2.sub(this.m_localAnchorC,this.m_lcC);var pA2=Rot.mulTVec2(qC,Vec2.add(rA2,Vec2.sub(cA2,cC)));coordinateA=Vec2.dot(Vec2.sub(pA2,pC),this.m_localAxisC)}if(this.m_type2==RevoluteJoint.TYPE){JvBD=Vec2.zero();JwB=this.m_ratio;JwD=this.m_ratio;mass+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD);coordinateB=aB-aD-this.m_referenceAngleB}else{var u=Rot.mulVec2(qD,this.m_localAxisD);var rD=Rot.mulSub(qD,this.m_localAnchorD,this.m_lcD);var rB2=Rot.mulSub(qB,this.m_localAnchorB,this.m_lcB);JvBD=Vec2.mulNumVec2(this.m_ratio,u);JwD=this.m_ratio*Vec2.crossVec2Vec2(rD,u);JwB=this.m_ratio*Vec2.crossVec2Vec2(rB2,u);mass+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*JwD*JwD+this.m_iB*JwB*JwB;var pD=Vec2.sub(this.m_localAnchorD,this.m_lcD);var pB2=Rot.mulTVec2(qD,Vec2.add(rB2,Vec2.sub(cB2,cD)));coordinateB=Vec2.dot(pB2,this.m_localAxisD)-Vec2.dot(pD,this.m_localAxisD)}var C=coordinateA+this.m_ratio*coordinateB-this.m_constant;var impulse=0;if(mass>0){impulse=-C/mass}cA2.addMul(this.m_mA*impulse,JvAC);aA+=this.m_iA*impulse*JwA;cB2.addMul(this.m_mB*impulse,JvBD);aB+=this.m_iB*impulse*JwB;cC.subMul(this.m_mC*impulse,JvAC);aC-=this.m_iC*impulse*JwC;cD.subMul(this.m_mD*impulse,JvBD);aD-=this.m_iD*impulse*JwD;this.m_bodyA.c_position.c.setVec2(cA2);this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c.setVec2(cB2);this.m_bodyB.c_position.a=aB;this.m_bodyC.c_position.c.setVec2(cC);this.m_bodyC.c_position.a=aC;this.m_bodyD.c_position.c.setVec2(cD);this.m_bodyD.c_position.a=aD;return linearError0){this.m_angularMass=1/this.m_angularMass}this.m_linearError=Vec2.zero();this.m_linearError.addCombine(1,cB2,1,this.m_rB);this.m_linearError.subCombine(1,cA2,1,this.m_rA);this.m_angularError=aB-aA-this.m_angularOffset;if(step.warmStarting){this.m_linearImpulse.mul(step.dtRatio);this.m_angularImpulse*=step.dtRatio;var P3=Vec2.neo(this.m_linearImpulse.x,this.m_linearImpulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+this.m_angularImpulse);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+this.m_angularImpulse)}else{this.m_linearImpulse.setZero();this.m_angularImpulse=0}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};MotorJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var h=step.dt;var inv_h=step.inv_dt;{var Cdot=wB-wA+inv_h*this.m_correctionFactor*this.m_angularError;var impulse=-this.m_angularMass*Cdot;var oldImpulse=this.m_angularImpulse;var maxImpulse=h*this.m_maxTorque;this.m_angularImpulse=clamp(this.m_angularImpulse+impulse,-maxImpulse,maxImpulse);impulse=this.m_angularImpulse-oldImpulse;wA-=iA*impulse;wB+=iB*impulse}{var Cdot=Vec2.zero();Cdot.addCombine(1,vB2,1,Vec2.crossNumVec2(wB,this.m_rB));Cdot.subCombine(1,vA2,1,Vec2.crossNumVec2(wA,this.m_rA));Cdot.addMul(inv_h*this.m_correctionFactor,this.m_linearError);var impulse=Vec2.neg(Mat22.mulVec2(this.m_linearMass,Cdot));var oldImpulse=Vec2.clone(this.m_linearImpulse);this.m_linearImpulse.add(impulse);var maxImpulse=h*this.m_maxForce;this.m_linearImpulse.clamp(maxImpulse);impulse=Vec2.sub(this.m_linearImpulse,oldImpulse);vA2.subMul(mA,impulse);wA-=iA*Vec2.crossVec2Vec2(this.m_rA,impulse);vB2.addMul(mB,impulse);wB+=iB*Vec2.crossVec2Vec2(this.m_rB,impulse)}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};MotorJoint2.prototype.solvePositionConstraints=function(step){return true};MotorJoint2.TYPE="motor-joint";return MotorJoint2}(Joint);var math_PI$2=Math.PI;var DEFAULTS$4={maxForce:0,frequencyHz:5,dampingRatio:.7};var MouseJoint=function(_super){__extends(MouseJoint2,_super);function MouseJoint2(def,bodyA,bodyB,target){var _this=this;if(!(_this instanceof MouseJoint2)){return new MouseJoint2(def,bodyA,bodyB,target)}def=options(def,DEFAULTS$4);_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_type=MouseJoint2.TYPE;if(Vec2.isValid(target)){_this.m_targetA=Vec2.clone(target)}else if(Vec2.isValid(def.target)){_this.m_targetA=Vec2.clone(def.target)}else{_this.m_targetA=Vec2.zero()}_this.m_localAnchorB=Transform.mulTVec2(bodyB.getTransform(),_this.m_targetA);_this.m_maxForce=def.maxForce;_this.m_impulse=Vec2.zero();_this.m_frequencyHz=def.frequencyHz;_this.m_dampingRatio=def.dampingRatio;_this.m_beta=0;_this.m_gamma=0;_this.m_rB=Vec2.zero();_this.m_localCenterB=Vec2.zero();_this.m_invMassB=0;_this.m_invIB=0;_this.m_mass=new Mat22;_this.m_C=Vec2.zero();return _this}MouseJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,target:this.m_targetA,maxForce:this.m_maxForce,frequencyHz:this.m_frequencyHz,dampingRatio:this.m_dampingRatio,_localAnchorB:this.m_localAnchorB}};MouseJoint2._deserialize=function(data,world,restore){data=__assign({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);data.target=Vec2.clone(data.target);var joint=new MouseJoint2(data);if(data._localAnchorB){joint.m_localAnchorB=data._localAnchorB}return joint};MouseJoint2.prototype._reset=function(def){if(Number.isFinite(def.maxForce)){this.m_maxForce=def.maxForce}if(Number.isFinite(def.frequencyHz)){this.m_frequencyHz=def.frequencyHz}if(Number.isFinite(def.dampingRatio)){this.m_dampingRatio=def.dampingRatio}};MouseJoint2.prototype.setTarget=function(target){if(Vec2.areEqual(target,this.m_targetA))return;this.m_bodyB.setAwake(true);this.m_targetA.set(target)};MouseJoint2.prototype.getTarget=function(){return this.m_targetA};MouseJoint2.prototype.setMaxForce=function(force){this.m_maxForce=force};MouseJoint2.prototype.getMaxForce=function(){return this.m_maxForce};MouseJoint2.prototype.setFrequency=function(hz){this.m_frequencyHz=hz};MouseJoint2.prototype.getFrequency=function(){return this.m_frequencyHz};MouseJoint2.prototype.setDampingRatio=function(ratio){this.m_dampingRatio=ratio};MouseJoint2.prototype.getDampingRatio=function(){return this.m_dampingRatio};MouseJoint2.prototype.getAnchorA=function(){return Vec2.clone(this.m_targetA)};MouseJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};MouseJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.mulNumVec2(inv_dt,this.m_impulse)};MouseJoint2.prototype.getReactionTorque=function(inv_dt){return inv_dt*0};MouseJoint2.prototype.shiftOrigin=function(newOrigin){this.m_targetA.sub(newOrigin)};MouseJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIB=this.m_bodyB.m_invI;var position=this.m_bodyB.c_position;var velocity=this.m_bodyB.c_velocity;var cB2=position.c;var aB=position.a;var vB2=velocity.v;var wB=velocity.w;var qB=Rot.neo(aB);var mass=this.m_bodyB.getMass();var omega=2*math_PI$2*this.m_frequencyHz;var d2=2*mass*this.m_dampingRatio*omega;var k=mass*(omega*omega);var h=step.dt;this.m_gamma=h*(d2+h*k);if(this.m_gamma!=0){this.m_gamma=1/this.m_gamma}this.m_beta=h*k*this.m_gamma;this.m_rB=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var K=new Mat22;K.ex.x=this.m_invMassB+this.m_invIB*this.m_rB.y*this.m_rB.y+this.m_gamma;K.ex.y=-this.m_invIB*this.m_rB.x*this.m_rB.y;K.ey.x=K.ex.y;K.ey.y=this.m_invMassB+this.m_invIB*this.m_rB.x*this.m_rB.x+this.m_gamma;this.m_mass=K.getInverse();this.m_C.setVec2(cB2);this.m_C.addCombine(1,this.m_rB,-1,this.m_targetA);this.m_C.mul(this.m_beta);wB*=.98;if(step.warmStarting){this.m_impulse.mul(step.dtRatio);vB2.addMul(this.m_invMassB,this.m_impulse);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,this.m_impulse)}else{this.m_impulse.setZero()}velocity.v.setVec2(vB2);velocity.w=wB};MouseJoint2.prototype.solveVelocityConstraints=function(step){var velocity=this.m_bodyB.c_velocity;var vB2=Vec2.clone(velocity.v);var wB=velocity.w;var Cdot=Vec2.crossNumVec2(wB,this.m_rB);Cdot.add(vB2);Cdot.addCombine(1,this.m_C,this.m_gamma,this.m_impulse);Cdot.neg();var impulse=Mat22.mulVec2(this.m_mass,Cdot);var oldImpulse=Vec2.clone(this.m_impulse);this.m_impulse.add(impulse);var maxImpulse=step.dt*this.m_maxForce;this.m_impulse.clamp(maxImpulse);impulse=Vec2.sub(this.m_impulse,oldImpulse);vB2.addMul(this.m_invMassB,impulse);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,impulse);velocity.v.setVec2(vB2);velocity.w=wB};MouseJoint2.prototype.solvePositionConstraints=function(step){return true};MouseJoint2.TYPE="mouse-joint";return MouseJoint2}(Joint);var math_abs$2=Math.abs;var DEFAULTS$3={collideConnected:true};var PulleyJoint=function(_super){__extends(PulleyJoint2,_super);function PulleyJoint2(def,bodyA,bodyB,groundA,groundB,anchorA,anchorB,ratio){var _this=this;if(!(_this instanceof PulleyJoint2)){return new PulleyJoint2(def,bodyA,bodyB,groundA,groundB,anchorA,anchorB,ratio)}def=options(def,DEFAULTS$3);_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_type=PulleyJoint2.TYPE;_this.m_groundAnchorA=Vec2.clone(groundA?groundA:def.groundAnchorA||Vec2.neo(-1,1));_this.m_groundAnchorB=Vec2.clone(groundB?groundB:def.groundAnchorB||Vec2.neo(1,1));_this.m_localAnchorA=Vec2.clone(anchorA?bodyA.getLocalPoint(anchorA):def.localAnchorA||Vec2.neo(-1,0));_this.m_localAnchorB=Vec2.clone(anchorB?bodyB.getLocalPoint(anchorB):def.localAnchorB||Vec2.neo(1,0));_this.m_lengthA=Number.isFinite(def.lengthA)?def.lengthA:Vec2.distance(anchorA,groundA);_this.m_lengthB=Number.isFinite(def.lengthB)?def.lengthB:Vec2.distance(anchorB,groundB);_this.m_ratio=Number.isFinite(ratio)?ratio:def.ratio;_this.m_constant=_this.m_lengthA+_this.m_ratio*_this.m_lengthB;_this.m_impulse=0;return _this}PulleyJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,groundAnchorA:this.m_groundAnchorA,groundAnchorB:this.m_groundAnchorB,localAnchorA:this.m_localAnchorA,localAnchorB:this.m_localAnchorB,lengthA:this.m_lengthA,lengthB:this.m_lengthB,ratio:this.m_ratio}};PulleyJoint2._deserialize=function(data,world,restore){data=__assign({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);var joint=new PulleyJoint2(data);return joint};PulleyJoint2.prototype._reset=function(def){if(Vec2.isValid(def.groundAnchorA)){this.m_groundAnchorA.set(def.groundAnchorA)}if(Vec2.isValid(def.groundAnchorB)){this.m_groundAnchorB.set(def.groundAnchorB)}if(Vec2.isValid(def.localAnchorA)){this.m_localAnchorA.set(def.localAnchorA)}else if(Vec2.isValid(def.anchorA)){this.m_localAnchorA.set(this.m_bodyA.getLocalPoint(def.anchorA))}if(Vec2.isValid(def.localAnchorB)){this.m_localAnchorB.set(def.localAnchorB)}else if(Vec2.isValid(def.anchorB)){this.m_localAnchorB.set(this.m_bodyB.getLocalPoint(def.anchorB))}if(Number.isFinite(def.lengthA)){this.m_lengthA=def.lengthA}if(Number.isFinite(def.lengthB)){this.m_lengthB=def.lengthB}if(Number.isFinite(def.ratio)){this.m_ratio=def.ratio}};PulleyJoint2.prototype.getGroundAnchorA=function(){return this.m_groundAnchorA};PulleyJoint2.prototype.getGroundAnchorB=function(){return this.m_groundAnchorB};PulleyJoint2.prototype.getLengthA=function(){return this.m_lengthA};PulleyJoint2.prototype.getLengthB=function(){return this.m_lengthB};PulleyJoint2.prototype.getRatio=function(){return this.m_ratio};PulleyJoint2.prototype.getCurrentLengthA=function(){var p=this.m_bodyA.getWorldPoint(this.m_localAnchorA);var s2=this.m_groundAnchorA;return Vec2.distance(p,s2)};PulleyJoint2.prototype.getCurrentLengthB=function(){var p=this.m_bodyB.getWorldPoint(this.m_localAnchorB);var s2=this.m_groundAnchorB;return Vec2.distance(p,s2)};PulleyJoint2.prototype.shiftOrigin=function(newOrigin){this.m_groundAnchorA.sub(newOrigin);this.m_groundAnchorB.sub(newOrigin)};PulleyJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};PulleyJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};PulleyJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.mulNumVec2(this.m_impulse,this.m_uB).mul(inv_dt)};PulleyJoint2.prototype.getReactionTorque=function(inv_dt){return 0};PulleyJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter;this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);this.m_rA=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));this.m_rB=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));this.m_uA=Vec2.sub(Vec2.add(cA2,this.m_rA),this.m_groundAnchorA);this.m_uB=Vec2.sub(Vec2.add(cB2,this.m_rB),this.m_groundAnchorB);var lengthA=this.m_uA.length();var lengthB=this.m_uB.length();if(lengthA>10*SettingsInternal.linearSlop){this.m_uA.mul(1/lengthA)}else{this.m_uA.setZero()}if(lengthB>10*SettingsInternal.linearSlop){this.m_uB.mul(1/lengthB)}else{this.m_uB.setZero()}var ruA=Vec2.crossVec2Vec2(this.m_rA,this.m_uA);var ruB=Vec2.crossVec2Vec2(this.m_rB,this.m_uB);var mA=this.m_invMassA+this.m_invIA*ruA*ruA;var mB=this.m_invMassB+this.m_invIB*ruB*ruB;this.m_mass=mA+this.m_ratio*this.m_ratio*mB;if(this.m_mass>0){this.m_mass=1/this.m_mass}if(step.warmStarting){this.m_impulse*=step.dtRatio;var PA=Vec2.mulNumVec2(-this.m_impulse,this.m_uA);var PB=Vec2.mulNumVec2(-this.m_ratio*this.m_impulse,this.m_uB);vA2.addMul(this.m_invMassA,PA);wA+=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,PA);vB2.addMul(this.m_invMassB,PB);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,PB)}else{this.m_impulse=0}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};PulleyJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var vpA=Vec2.add(vA2,Vec2.crossNumVec2(wA,this.m_rA));var vpB=Vec2.add(vB2,Vec2.crossNumVec2(wB,this.m_rB));var Cdot=-Vec2.dot(this.m_uA,vpA)-this.m_ratio*Vec2.dot(this.m_uB,vpB);var impulse=-this.m_mass*Cdot;this.m_impulse+=impulse;var PA=Vec2.mulNumVec2(-impulse,this.m_uA);var PB=Vec2.mulNumVec2(-this.m_ratio*impulse,this.m_uB);vA2.addMul(this.m_invMassA,PA);wA+=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,PA);vB2.addMul(this.m_invMassB,PB);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,PB);this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};PulleyJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var uA=Vec2.sub(Vec2.add(cA2,this.m_rA),this.m_groundAnchorA);var uB=Vec2.sub(Vec2.add(cB2,this.m_rB),this.m_groundAnchorB);var lengthA=uA.length();var lengthB=uB.length();if(lengthA>10*SettingsInternal.linearSlop){uA.mul(1/lengthA)}else{uA.setZero()}if(lengthB>10*SettingsInternal.linearSlop){uB.mul(1/lengthB)}else{uB.setZero()}var ruA=Vec2.crossVec2Vec2(rA2,uA);var ruB=Vec2.crossVec2Vec2(rB2,uB);var mA=this.m_invMassA+this.m_invIA*ruA*ruA;var mB=this.m_invMassB+this.m_invIB*ruB*ruB;var mass=mA+this.m_ratio*this.m_ratio*mB;if(mass>0){mass=1/mass}var C=this.m_constant-lengthA-this.m_ratio*lengthB;var linearError=math_abs$2(C);var impulse=-mass*C;var PA=Vec2.mulNumVec2(-impulse,uA);var PB=Vec2.mulNumVec2(-this.m_ratio*impulse,uB);cA2.addMul(this.m_invMassA,PA);aA+=this.m_invIA*Vec2.crossVec2Vec2(rA2,PA);cB2.addMul(this.m_invMassB,PB);aB+=this.m_invIB*Vec2.crossVec2Vec2(rB2,PB);this.m_bodyA.c_position.c=cA2;this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c=cB2;this.m_bodyB.c_position.a=aB;return linearError0){this.m_state=LimitState.atUpperLimit}else{this.m_state=LimitState.inactiveLimit}if(this.m_length>SettingsInternal.linearSlop){this.m_u.mul(1/this.m_length)}else{this.m_u.setZero();this.m_mass=0;this.m_impulse=0;return}var crA=Vec2.crossVec2Vec2(this.m_rA,this.m_u);var crB=Vec2.crossVec2Vec2(this.m_rB,this.m_u);var invMass=this.m_invMassA+this.m_invIA*crA*crA+this.m_invMassB+this.m_invIB*crB*crB;this.m_mass=invMass!=0?1/invMass:0;if(step.warmStarting){this.m_impulse*=step.dtRatio;var P3=Vec2.mulNumVec2(this.m_impulse,this.m_u);vA2.subMul(this.m_invMassA,P3);wA-=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,P3);vB2.addMul(this.m_invMassB,P3);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,P3)}else{this.m_impulse=0}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};RopeJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var vpA=Vec2.addCrossNumVec2(vA2,wA,this.m_rA);var vpB=Vec2.addCrossNumVec2(vB2,wB,this.m_rB);var C=this.m_length-this.m_maxLength;var Cdot=Vec2.dot(this.m_u,Vec2.sub(vpB,vpA));if(C<0){Cdot+=step.inv_dt*C}var impulse=-this.m_mass*Cdot;var oldImpulse=this.m_impulse;this.m_impulse=math_min$1(0,this.m_impulse+impulse);impulse=this.m_impulse-oldImpulse;var P3=Vec2.mulNumVec2(impulse,this.m_u);vA2.subMul(this.m_invMassA,P3);wA-=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,P3);vB2.addMul(this.m_invMassB,P3);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,P3);this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};RopeJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulSub(qA,this.m_localAnchorA,this.m_localCenterA);var rB2=Rot.mulSub(qB,this.m_localAnchorB,this.m_localCenterB);var u=Vec2.zero();u.addCombine(1,cB2,1,rB2);u.subCombine(1,cA2,1,rA2);var length=u.normalize();var C=length-this.m_maxLength;C=clamp(C,0,SettingsInternal.maxLinearCorrection);var impulse=-this.m_mass*C;var P3=Vec2.mulNumVec2(impulse,u);cA2.subMul(this.m_invMassA,P3);aA-=this.m_invIA*Vec2.crossVec2Vec2(rA2,P3);cB2.addMul(this.m_invMassB,P3);aB+=this.m_invIB*Vec2.crossVec2Vec2(rB2,P3);this.m_bodyA.c_position.c.setVec2(cA2);this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c.setVec2(cB2);this.m_bodyB.c_position.a=aB;return length-this.m_maxLength0){K.getInverse22(this.m_mass);var invM=iA+iB;var m=invM>0?1/invM:0;var C=aB-aA-this.m_referenceAngle;var omega=2*math_PI$1*this.m_frequencyHz;var d2=2*m*this.m_dampingRatio*omega;var k=m*omega*omega;var h=step.dt;this.m_gamma=h*(d2+h*k);this.m_gamma=this.m_gamma!=0?1/this.m_gamma:0;this.m_bias=C*h*k*this.m_gamma;invM+=this.m_gamma;this.m_mass.ez.z=invM!=0?1/invM:0}else if(K.ez.z==0){K.getInverse22(this.m_mass);this.m_gamma=0;this.m_bias=0}else{K.getSymInverse33(this.m_mass);this.m_gamma=0;this.m_bias=0}if(step.warmStarting){this.m_impulse.mul(step.dtRatio);var P3=Vec2.neo(this.m_impulse.x,this.m_impulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+this.m_impulse.z);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+this.m_impulse.z)}else{this.m_impulse.setZero()}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};WeldJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;if(this.m_frequencyHz>0){var Cdot2=wB-wA;var impulse2=-this.m_mass.ez.z*(Cdot2+this.m_bias+this.m_gamma*this.m_impulse.z);this.m_impulse.z+=impulse2;wA-=iA*impulse2;wB+=iB*impulse2;var Cdot1=Vec2.zero();Cdot1.addCombine(1,vB2,1,Vec2.crossNumVec2(wB,this.m_rB));Cdot1.subCombine(1,vA2,1,Vec2.crossNumVec2(wA,this.m_rA));var impulse1=Vec2.neg(Mat33.mulVec2(this.m_mass,Cdot1));this.m_impulse.x+=impulse1.x;this.m_impulse.y+=impulse1.y;var P3=Vec2.clone(impulse1);vA2.subMul(mA,P3);wA-=iA*Vec2.crossVec2Vec2(this.m_rA,P3);vB2.addMul(mB,P3);wB+=iB*Vec2.crossVec2Vec2(this.m_rB,P3)}else{var Cdot1=Vec2.zero();Cdot1.addCombine(1,vB2,1,Vec2.crossNumVec2(wB,this.m_rB));Cdot1.subCombine(1,vA2,1,Vec2.crossNumVec2(wA,this.m_rA));var Cdot2=wB-wA;var Cdot=new Vec3(Cdot1.x,Cdot1.y,Cdot2);var impulse=Vec3.neg(Mat33.mulVec3(this.m_mass,Cdot));this.m_impulse.add(impulse);var P3=Vec2.neo(impulse.x,impulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+impulse.z);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+impulse.z)}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};WeldJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var positionError;var angularError;var K=new Mat33;K.ex.x=mA+mB+rA2.y*rA2.y*iA+rB2.y*rB2.y*iB;K.ey.x=-rA2.y*rA2.x*iA-rB2.y*rB2.x*iB;K.ez.x=-rA2.y*iA-rB2.y*iB;K.ex.y=K.ey.x;K.ey.y=mA+mB+rA2.x*rA2.x*iA+rB2.x*rB2.x*iB;K.ez.y=rA2.x*iA+rB2.x*iB;K.ex.z=K.ez.x;K.ey.z=K.ez.y;K.ez.z=iA+iB;if(this.m_frequencyHz>0){var C1=Vec2.zero();C1.addCombine(1,cB2,1,rB2);C1.subCombine(1,cA2,1,rA2);positionError=C1.length();angularError=0;var P3=Vec2.neg(K.solve22(C1));cA2.subMul(mA,P3);aA-=iA*Vec2.crossVec2Vec2(rA2,P3);cB2.addMul(mB,P3);aB+=iB*Vec2.crossVec2Vec2(rB2,P3)}else{var C1=Vec2.zero();C1.addCombine(1,cB2,1,rB2);C1.subCombine(1,cA2,1,rA2);var C2=aB-aA-this.m_referenceAngle;positionError=C1.length();angularError=math_abs$1(C2);var C=new Vec3(C1.x,C1.y,C2);var impulse=new Vec3;if(K.ez.z>0){impulse=Vec3.neg(K.solve33(C))}else{var impulse2=Vec2.neg(K.solve22(C1));impulse.set(impulse2.x,impulse2.y,0)}var P3=Vec2.neo(impulse.x,impulse.y);cA2.subMul(mA,P3);aA-=iA*(Vec2.crossVec2Vec2(rA2,P3)+impulse.z);cB2.addMul(mB,P3);aB+=iB*(Vec2.crossVec2Vec2(rB2,P3)+impulse.z)}this.m_bodyA.c_position.c=cA2;this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c=cB2;this.m_bodyB.c_position.a=aB;return positionError<=SettingsInternal.linearSlop&&angularError<=SettingsInternal.angularSlop};WeldJoint2.TYPE="weld-joint";return WeldJoint2}(Joint);var math_abs=Math.abs;var math_PI=Math.PI;var DEFAULTS={enableMotor:false,maxMotorTorque:0,motorSpeed:0,frequencyHz:2,dampingRatio:.7};var WheelJoint=function(_super){__extends(WheelJoint2,_super);function WheelJoint2(def,bodyA,bodyB,anchor,axis){var _this=this;if(!(_this instanceof WheelJoint2)){return new WheelJoint2(def,bodyA,bodyB,anchor,axis)}def=options(def,DEFAULTS);_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_ax=Vec2.zero();_this.m_ay=Vec2.zero();_this.m_type=WheelJoint2.TYPE;_this.m_localAnchorA=Vec2.clone(anchor?bodyA.getLocalPoint(anchor):def.localAnchorA||Vec2.zero());_this.m_localAnchorB=Vec2.clone(anchor?bodyB.getLocalPoint(anchor):def.localAnchorB||Vec2.zero());if(Vec2.isValid(axis)){_this.m_localXAxisA=bodyA.getLocalVector(axis)}else if(Vec2.isValid(def.localAxisA)){_this.m_localXAxisA=Vec2.clone(def.localAxisA)}else if(Vec2.isValid(def.localAxis)){_this.m_localXAxisA=Vec2.clone(def.localAxis)}else{_this.m_localXAxisA=Vec2.neo(1,0)}_this.m_localYAxisA=Vec2.crossNumVec2(1,_this.m_localXAxisA);_this.m_mass=0;_this.m_impulse=0;_this.m_motorMass=0;_this.m_motorImpulse=0;_this.m_springMass=0;_this.m_springImpulse=0;_this.m_maxMotorTorque=def.maxMotorTorque;_this.m_motorSpeed=def.motorSpeed;_this.m_enableMotor=def.enableMotor;_this.m_frequencyHz=def.frequencyHz;_this.m_dampingRatio=def.dampingRatio;_this.m_bias=0;_this.m_gamma=0;return _this}WheelJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,enableMotor:this.m_enableMotor,maxMotorTorque:this.m_maxMotorTorque,motorSpeed:this.m_motorSpeed,frequencyHz:this.m_frequencyHz,dampingRatio:this.m_dampingRatio,localAnchorA:this.m_localAnchorA,localAnchorB:this.m_localAnchorB,localAxisA:this.m_localXAxisA}};WheelJoint2._deserialize=function(data,world,restore){data=__assign({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);var joint=new WheelJoint2(data);return joint};WheelJoint2.prototype._reset=function(def){if(def.anchorA){this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA))}else if(def.localAnchorA){this.m_localAnchorA.setVec2(def.localAnchorA)}if(def.anchorB){this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB))}else if(def.localAnchorB){this.m_localAnchorB.setVec2(def.localAnchorB)}if(def.localAxisA){this.m_localXAxisA.setVec2(def.localAxisA);this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1,def.localAxisA))}if(def.enableMotor!==void 0){this.m_enableMotor=def.enableMotor}if(Number.isFinite(def.maxMotorTorque)){this.m_maxMotorTorque=def.maxMotorTorque}if(Number.isFinite(def.motorSpeed)){this.m_motorSpeed=def.motorSpeed}if(Number.isFinite(def.frequencyHz)){this.m_frequencyHz=def.frequencyHz}if(Number.isFinite(def.dampingRatio)){this.m_dampingRatio=def.dampingRatio}};WheelJoint2.prototype.getLocalAnchorA=function(){return this.m_localAnchorA};WheelJoint2.prototype.getLocalAnchorB=function(){return this.m_localAnchorB};WheelJoint2.prototype.getLocalAxisA=function(){return this.m_localXAxisA};WheelJoint2.prototype.getJointTranslation=function(){var bA=this.m_bodyA;var bB=this.m_bodyB;var pA2=bA.getWorldPoint(this.m_localAnchorA);var pB2=bB.getWorldPoint(this.m_localAnchorB);var d2=Vec2.sub(pB2,pA2);var axis=bA.getWorldVector(this.m_localXAxisA);var translation2=Vec2.dot(d2,axis);return translation2};WheelJoint2.prototype.getJointSpeed=function(){var wA=this.m_bodyA.m_angularVelocity;var wB=this.m_bodyB.m_angularVelocity;return wB-wA};WheelJoint2.prototype.isMotorEnabled=function(){return this.m_enableMotor};WheelJoint2.prototype.enableMotor=function(flag){if(flag==this.m_enableMotor)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_enableMotor=flag};WheelJoint2.prototype.setMotorSpeed=function(speed){if(speed==this.m_motorSpeed)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_motorSpeed=speed};WheelJoint2.prototype.getMotorSpeed=function(){return this.m_motorSpeed};WheelJoint2.prototype.setMaxMotorTorque=function(torque){if(torque==this.m_maxMotorTorque)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_maxMotorTorque=torque};WheelJoint2.prototype.getMaxMotorTorque=function(){return this.m_maxMotorTorque};WheelJoint2.prototype.getMotorTorque=function(inv_dt){return inv_dt*this.m_motorImpulse};WheelJoint2.prototype.setSpringFrequencyHz=function(hz){this.m_frequencyHz=hz};WheelJoint2.prototype.getSpringFrequencyHz=function(){return this.m_frequencyHz};WheelJoint2.prototype.setSpringDampingRatio=function(ratio){this.m_dampingRatio=ratio};WheelJoint2.prototype.getSpringDampingRatio=function(){return this.m_dampingRatio};WheelJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};WheelJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};WheelJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.combine(this.m_impulse,this.m_ay,this.m_springImpulse,this.m_ax).mul(inv_dt)};WheelJoint2.prototype.getReactionTorque=function(inv_dt){return inv_dt*this.m_motorImpulse};WheelJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter;this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var d2=Vec2.zero();d2.addCombine(1,cB2,1,rB2);d2.subCombine(1,cA2,1,rA2);{this.m_ay=Rot.mulVec2(qA,this.m_localYAxisA);this.m_sAy=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),this.m_ay);this.m_sBy=Vec2.crossVec2Vec2(rB2,this.m_ay);this.m_mass=mA+mB+iA*this.m_sAy*this.m_sAy+iB*this.m_sBy*this.m_sBy;if(this.m_mass>0){this.m_mass=1/this.m_mass}}this.m_springMass=0;this.m_bias=0;this.m_gamma=0;if(this.m_frequencyHz>0){this.m_ax=Rot.mulVec2(qA,this.m_localXAxisA);this.m_sAx=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),this.m_ax);this.m_sBx=Vec2.crossVec2Vec2(rB2,this.m_ax);var invMass=mA+mB+iA*this.m_sAx*this.m_sAx+iB*this.m_sBx*this.m_sBx;if(invMass>0){this.m_springMass=1/invMass;var C=Vec2.dot(d2,this.m_ax);var omega=2*math_PI*this.m_frequencyHz;var damp=2*this.m_springMass*this.m_dampingRatio*omega;var k=this.m_springMass*omega*omega;var h=step.dt;this.m_gamma=h*(damp+h*k);if(this.m_gamma>0){this.m_gamma=1/this.m_gamma}this.m_bias=C*h*k*this.m_gamma;this.m_springMass=invMass+this.m_gamma;if(this.m_springMass>0){this.m_springMass=1/this.m_springMass}}}else{this.m_springImpulse=0}if(this.m_enableMotor){this.m_motorMass=iA+iB;if(this.m_motorMass>0){this.m_motorMass=1/this.m_motorMass}}else{this.m_motorMass=0;this.m_motorImpulse=0}if(step.warmStarting){this.m_impulse*=step.dtRatio;this.m_springImpulse*=step.dtRatio;this.m_motorImpulse*=step.dtRatio;var P3=Vec2.combine(this.m_impulse,this.m_ay,this.m_springImpulse,this.m_ax);var LA=this.m_impulse*this.m_sAy+this.m_springImpulse*this.m_sAx+this.m_motorImpulse;var LB=this.m_impulse*this.m_sBy+this.m_springImpulse*this.m_sBx+this.m_motorImpulse;vA2.subMul(this.m_invMassA,P3);wA-=this.m_invIA*LA;vB2.addMul(this.m_invMassB,P3);wB+=this.m_invIB*LB}else{this.m_impulse=0;this.m_springImpulse=0;this.m_motorImpulse=0}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};WheelJoint2.prototype.solveVelocityConstraints=function(step){var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;{var Cdot=Vec2.dot(this.m_ax,vB2)-Vec2.dot(this.m_ax,vA2)+this.m_sBx*wB-this.m_sAx*wA;var impulse=-this.m_springMass*(Cdot+this.m_bias+this.m_gamma*this.m_springImpulse);this.m_springImpulse+=impulse;var P3=Vec2.mulNumVec2(impulse,this.m_ax);var LA=impulse*this.m_sAx;var LB=impulse*this.m_sBx;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}{var Cdot=wB-wA-this.m_motorSpeed;var impulse=-this.m_motorMass*Cdot;var oldImpulse=this.m_motorImpulse;var maxImpulse=step.dt*this.m_maxMotorTorque;this.m_motorImpulse=clamp(this.m_motorImpulse+impulse,-maxImpulse,maxImpulse);impulse=this.m_motorImpulse-oldImpulse;wA-=iA*impulse;wB+=iB*impulse}{var Cdot=Vec2.dot(this.m_ay,vB2)-Vec2.dot(this.m_ay,vA2)+this.m_sBy*wB-this.m_sAy*wA;var impulse=-this.m_mass*Cdot;this.m_impulse+=impulse;var P3=Vec2.mulNumVec2(impulse,this.m_ay);var LA=impulse*this.m_sAy;var LB=impulse*this.m_sBy;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};WheelJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var d2=Vec2.zero();d2.addCombine(1,cB2,1,rB2);d2.subCombine(1,cA2,1,rA2);var ay=Rot.mulVec2(qA,this.m_localYAxisA);var sAy=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),ay);var sBy=Vec2.crossVec2Vec2(rB2,ay);var C=Vec2.dot(d2,ay);var k=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_sAy*this.m_sAy+this.m_invIB*this.m_sBy*this.m_sBy;var impulse=k!=0?-C/k:0;var P3=Vec2.mulNumVec2(impulse,ay);var LA=impulse*sAy;var LB=impulse*sBy;cA2.subMul(this.m_invMassA,P3);aA-=this.m_invIA*LA;cB2.addMul(this.m_invMassB,P3);aB+=this.m_invIB*LB;this.m_bodyA.c_position.c.setVec2(cA2);this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c.setVec2(cB2);this.m_bodyB.c_position.a=aB;return math_abs(C)<=SettingsInternal.linearSlop};WheelJoint2.TYPE="wheel-joint";return WheelJoint2}(Joint);var _a;var SID=0;var SERIALIZE_REF_TYPES={World:World,Body:Body,Joint:Joint,Fixture:Fixture,Shape:Shape};var DESERIALIZE_BY_REF_TYPE={Vec2:Vec2,Vec3:Vec3,World:World,Body:Body,Joint:Joint,Fixture:Fixture,Shape:Shape};var DESERIALIZE_BY_TYPE_FIELD=(_a={},_a[Body.STATIC]=Body,_a[Body.DYNAMIC]=Body,_a[Body.KINEMATIC]=Body,_a[ChainShape.TYPE]=ChainShape,_a[PolygonShape.TYPE]=PolygonShape,_a[EdgeShape.TYPE]=EdgeShape,_a[CircleShape.TYPE]=CircleShape,_a[DistanceJoint.TYPE]=DistanceJoint,_a[FrictionJoint.TYPE]=FrictionJoint,_a[GearJoint.TYPE]=GearJoint,_a[MotorJoint.TYPE]=MotorJoint,_a[MouseJoint.TYPE]=MouseJoint,_a[PrismaticJoint.TYPE]=PrismaticJoint,_a[PulleyJoint.TYPE]=PulleyJoint,_a[RevoluteJoint.TYPE]=RevoluteJoint,_a[RopeJoint.TYPE]=RopeJoint,_a[WeldJoint.TYPE]=WeldJoint,_a[WheelJoint.TYPE]=WheelJoint,_a);var DEFAULT_OPTIONS={rootClass:World,preSerialize:function(obj){return obj},postSerialize:function(data,obj){return data},preDeserialize:function(data){return data},postDeserialize:function(obj,data){return obj}};var Serializer=function(){function Serializer2(options2){var _this=this;this.toJson=function(root){var preSerialize=_this.options.preSerialize;var postSerialize=_this.options.postSerialize;var json=[];var refQueue=[root];var refMemoById={};function addToRefQueue(value,typeName){value.__sid=value.__sid||++SID;if(!refMemoById[value.__sid]){refQueue.push(value);var index=json.length+refQueue.length;var ref={refIndex:index,refType:typeName};refMemoById[value.__sid]=ref}return refMemoById[value.__sid]}function serializeWithHooks(obj2){obj2=preSerialize(obj2);var data=obj2._serialize();data=postSerialize(data,obj2);return data}function traverse(value,noRefType){if(noRefType===void 0){noRefType=false}if(typeof value!=="object"||value===null){return value}if(typeof value._serialize==="function"){if(!noRefType){for(var typeName in SERIALIZE_REF_TYPES){if(value instanceof SERIALIZE_REF_TYPES[typeName]){return addToRefQueue(value,typeName)}}}value=serializeWithHooks(value)}if(Array.isArray(value)){var newValue=[];for(var key=0;keyradius*radius){return}manifold.type=exports2.ManifoldType.e_circles;copyVec2(manifold.localPoint,circleA.m_p);zeroVec2(manifold.localNormal);manifold.pointCount=1;copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex)};Contact.addType(EdgeShape.TYPE,CircleShape.TYPE,EdgeCircleContact);Contact.addType(ChainShape.TYPE,CircleShape.TYPE,ChainCircleContact);function EdgeCircleContact(manifold,xfA2,fixtureA,indexA,xfB2,fixtureB,indexB){var shapeA=fixtureA.getShape();var shapeB=fixtureB.getShape();CollideEdgeCircle(manifold,shapeA,xfA2,shapeB,xfB2)}function ChainCircleContact(manifold,xfA2,fixtureA,indexA,xfB2,fixtureB,indexB){var chain=fixtureA.getShape();var edge=new EdgeShape;chain.getChildEdge(edge,indexA);var shapeA=edge;var shapeB=fixtureB.getShape();CollideEdgeCircle(manifold,shapeA,xfA2,shapeB,xfB2)}var e=vec2(0,0);var e1=vec2(0,0);var e2=vec2(0,0);var Q=vec2(0,0);var P=vec2(0,0);var n$2=vec2(0,0);var CollideEdgeCircle=function(manifold,edgeA,xfA2,circleB,xfB2){manifold.pointCount=0;retransformVec2(Q,xfB2,xfA2,circleB.m_p);var A=edgeA.m_vertex1;var B=edgeA.m_vertex2;subVec2(e,B,A);var u=dotVec2(e,B)-dotVec2(e,Q);var v3=dotVec2(e,Q)-dotVec2(e,A);var radius=edgeA.m_radius+circleB.m_radius;if(v3<=0){copyVec2(P,A);var dd_1=distSqrVec2(Q,A);if(dd_1>radius*radius){return}if(edgeA.m_hasVertex0){var A1=edgeA.m_vertex0;var B1=A;subVec2(e1,B1,A1);var u1=dotVec2(e1,B1)-dotVec2(e1,Q);if(u1>0){return}}manifold.type=exports2.ManifoldType.e_circles;zeroVec2(manifold.localNormal);copyVec2(manifold.localPoint,P);manifold.pointCount=1;copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex);return}if(u<=0){copyVec2(P,B);var dd_2=distSqrVec2(Q,P);if(dd_2>radius*radius){return}if(edgeA.m_hasVertex3){var B2=edgeA.m_vertex3;var A2=B;subVec2(e2,B2,A2);var v22=dotVec2(e2,Q)-dotVec2(e2,A2);if(v22>0){return}}manifold.type=exports2.ManifoldType.e_circles;zeroVec2(manifold.localNormal);copyVec2(manifold.localPoint,P);manifold.pointCount=1;copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(1,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex);return}var den=lengthSqrVec2(e);combine2Vec2(P,u/den,A,v3/den,B);var dd=distSqrVec2(Q,P);if(dd>radius*radius){return}crossNumVec2(n$2,1,e);if(dotVec2(n$2,Q)-dotVec2(n$2,A)<0){negVec2(n$2)}normalizeVec2(n$2);manifold.type=exports2.ManifoldType.e_faceA;copyVec2(manifold.localNormal,n$2);copyVec2(manifold.localPoint,A);manifold.pointCount=1;copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_face,0,exports2.ContactFeatureType.e_vertex)};var incidentEdge=[new ClipVertex,new ClipVertex];var clipPoints1$1=[new ClipVertex,new ClipVertex];var clipPoints2$1=[new ClipVertex,new ClipVertex];var clipSegmentToLineNormal=vec2(0,0);var v1=vec2(0,0);var n$1=vec2(0,0);var xf$1=transform(0,0,0);var v11=vec2(0,0);var v12=vec2(0,0);var localTangent=vec2(0,0);var localNormal=vec2(0,0);var planePoint=vec2(0,0);var tangent=vec2(0,0);var normal$1=vec2(0,0);var normal1$1=vec2(0,0);Contact.addType(PolygonShape.TYPE,PolygonShape.TYPE,PolygonContact);function PolygonContact(manifold,xfA2,fixtureA,indexA,xfB2,fixtureB,indexB){CollidePolygons(manifold,fixtureA.getShape(),xfA2,fixtureB.getShape(),xfB2)}function findMaxSeparation(poly1,xf1,poly2,xf2,output2){var count1=poly1.m_count;var count2=poly2.m_count;var n1s=poly1.m_normals;var v1s=poly1.m_vertices;var v2s=poly2.m_vertices;detransformTransform(xf$1,xf2,xf1);var bestIndex=0;var maxSeparation2=-Infinity;for(var i=0;imaxSeparation2){maxSeparation2=si;bestIndex=i}}output2.maxSeparation=maxSeparation2;output2.bestIndex=bestIndex}function findIncidentEdge(clipVertex,poly1,xf1,edge12,poly2,xf2){var normals1=poly1.m_normals;var count2=poly2.m_count;var vertices2=poly2.m_vertices;var normals2=poly2.m_normals;rerotVec2(normal1$1,xf2.q,xf1.q,normals1[edge12]);var index=0;var minDot=Infinity;for(var i=0;itotalRadius)return;findMaxSeparation(polyB,xfB2,polyA,xfA2,maxSeparation);var edgeB=maxSeparation.bestIndex;var separationB=maxSeparation.maxSeparation;if(separationB>totalRadius)return;var poly1;var poly2;var xf1;var xf2;var edge12;var flip;var k_tol=.1*SettingsInternal.linearSlop;if(separationB>separationA+k_tol){poly1=polyB;poly2=polyA;xf1=xfB2;xf2=xfA2;edge12=edgeB;manifold.type=exports2.ManifoldType.e_faceB;flip=true}else{poly1=polyA;poly2=polyB;xf1=xfA2;xf2=xfB2;edge12=edgeA;manifold.type=exports2.ManifoldType.e_faceA;flip=false}incidentEdge[0].recycle();incidentEdge[1].recycle();findIncidentEdge(incidentEdge,poly1,xf1,edge12,poly2,xf2);var count1=poly1.m_count;var vertices1=poly1.m_vertices;var iv1=edge12;var iv2=edge12+1radius){return}if(s2>separation){separation=s2;normalIndex=i}}var vertIndex1=normalIndex;var vertIndex2=vertIndex1+1radius*radius){return}manifold.pointCount=1;manifold.type=exports2.ManifoldType.e_faceA;subVec2(manifold.localNormal,cLocal,v13);normalizeVec2(manifold.localNormal);copyVec2(manifold.localPoint,v13);copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex)}else if(u2<=0){if(distSqrVec2(cLocal,v22)>radius*radius){return}manifold.pointCount=1;manifold.type=exports2.ManifoldType.e_faceA;subVec2(manifold.localNormal,cLocal,v22);normalizeVec2(manifold.localNormal);copyVec2(manifold.localPoint,v22);copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex)}else{combine2Vec2(faceCenter,.5,v13,.5,v22);var separation_1=dotVec2(cLocal,normals[vertIndex1])-dotVec2(faceCenter,normals[vertIndex1]);if(separation_1>radius){return}manifold.pointCount=1;manifold.type=exports2.ManifoldType.e_faceA;copyVec2(manifold.localNormal,normals[vertIndex1]);copyVec2(manifold.localPoint,faceCenter);copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex)}};var math_min=Math.min;Contact.addType(EdgeShape.TYPE,PolygonShape.TYPE,EdgePolygonContact);Contact.addType(ChainShape.TYPE,PolygonShape.TYPE,ChainPolygonContact);function EdgePolygonContact(manifold,xfA2,fA,indexA,xfB2,fB,indexB){CollideEdgePolygon(manifold,fA.getShape(),xfA2,fB.getShape(),xfB2)}var edge_reuse=new EdgeShape;function ChainPolygonContact(manifold,xfA2,fA,indexA,xfB2,fB,indexB){var chain=fA.getShape();chain.getChildEdge(edge_reuse,indexA);CollideEdgePolygon(manifold,edge_reuse,xfA2,fB.getShape(),xfB2)}var EPAxisType;(function(EPAxisType2){EPAxisType2[EPAxisType2["e_unknown"]=-1]="e_unknown";EPAxisType2[EPAxisType2["e_edgeA"]=1]="e_edgeA";EPAxisType2[EPAxisType2["e_edgeB"]=2]="e_edgeB"})(EPAxisType||(EPAxisType={}));var VertexType;(function(VertexType2){VertexType2[VertexType2["e_isolated"]=0]="e_isolated";VertexType2[VertexType2["e_concave"]=1]="e_concave";VertexType2[VertexType2["e_convex"]=2]="e_convex"})(VertexType||(VertexType={}));var EPAxis=function(){function EPAxis2(){}return EPAxis2}();var TempPolygon=function(){function TempPolygon2(){this.vertices=[];this.normals=[];this.count=0;for(var i=0;i=0;offset0=Vec2.dot(normal0,centroidB)-Vec2.dot(normal0,v0)}if(hasVertex3){subVec2(edge2,v3,v22);normalizeVec2(edge2);setVec2(normal2,edge2.y,-edge2.x);convex2=Vec2.crossVec2Vec2(edge1,edge2)>0;offset2=Vec2.dot(normal2,centroidB)-Vec2.dot(normal2,v22)}var front;zeroVec2(normal);zeroVec2(lowerLimit);zeroVec2(upperLimit);if(hasVertex0&&hasVertex3){if(convex1&&convex2){front=offset0>=0||offset1>=0||offset2>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal0);copyVec2(upperLimit,normal2)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal1);scaleVec2(upperLimit,-1,normal1)}}else if(convex1){front=offset0>=0||offset1>=0&&offset2>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal0);copyVec2(upperLimit,normal1)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal2);scaleVec2(upperLimit,-1,normal1)}}else if(convex2){front=offset2>=0||offset0>=0&&offset1>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal1);copyVec2(upperLimit,normal2)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal1);scaleVec2(upperLimit,-1,normal0)}}else{front=offset0>=0&&offset1>=0&&offset2>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal1);copyVec2(upperLimit,normal1)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal2);scaleVec2(upperLimit,-1,normal0)}}}else if(hasVertex0){if(convex1){front=offset0>=0||offset1>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal0);scaleVec2(upperLimit,-1,normal1)}else{scaleVec2(normal,-1,normal1);copyVec2(lowerLimit,normal1);scaleVec2(upperLimit,-1,normal1)}}else{front=offset0>=0&&offset1>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal1);scaleVec2(upperLimit,-1,normal1)}else{scaleVec2(normal,-1,normal1);copyVec2(lowerLimit,normal1);scaleVec2(upperLimit,-1,normal0)}}}else if(hasVertex3){if(convex2){front=offset1>=0||offset2>=0;if(front){copyVec2(normal,normal1);scaleVec2(lowerLimit,-1,normal1);copyVec2(upperLimit,normal2)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal1);copyVec2(upperLimit,normal1)}}else{front=offset1>=0&&offset2>=0;if(front){copyVec2(normal,normal1);scaleVec2(lowerLimit,-1,normal1);copyVec2(upperLimit,normal1)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal2);copyVec2(upperLimit,normal1)}}}else{front=offset1>=0;if(front){copyVec2(normal,normal1);scaleVec2(lowerLimit,-1,normal1);scaleVec2(upperLimit,-1,normal1)}else{scaleVec2(normal,-1,normal1);copyVec2(lowerLimit,normal1);copyVec2(upperLimit,normal1)}}polygonBA.count=polygonB.m_count;for(var i=0;iradius){return}{polygonAxis.type=EPAxisType.e_unknown;polygonAxis.index=-1;polygonAxis.separation=-Infinity;setVec2(perp,-normal.y,normal.x);for(var i=0;iradius){polygonAxis.type=EPAxisType.e_edgeB;polygonAxis.index=i;polygonAxis.separation=s2;break}if(dotVec2(n,perp)>=0){if(dotVec2(n,normal)-dotVec2(upperLimit,normal)<-SettingsInternal.angularSlop){continue}}else{if(dotVec2(n,normal)-dotVec2(lowerLimit,normal)<-SettingsInternal.angularSlop){continue}}if(s2>polygonAxis.separation){polygonAxis.type=EPAxisType.e_edgeB;polygonAxis.index=i;polygonAxis.separation=s2}}}if(polygonAxis.type!=EPAxisType.e_unknown&&polygonAxis.separation>radius){return}var k_relativeTol=.98;var k_absoluteTol=.001;var primaryAxis;if(polygonAxis.type==EPAxisType.e_unknown){primaryAxis=edgeAxis}else if(polygonAxis.separation>k_relativeTol*edgeAxis.separation+k_absoluteTol){primaryAxis=polygonAxis}else{primaryAxis=edgeAxis}ie[0].recycle();ie[1].recycle();if(primaryAxis.type==EPAxisType.e_edgeA){manifold.type=exports2.ManifoldType.e_faceA;var bestIndex=0;var bestValue=dotVec2(normal,polygonBA.normals[0]);for(var i=1;i>1;x2|=x2>>2;x2|=x2>>4;x2|=x2>>8;x2|=x2>>16;return x2+1}function isPowerOfTwo(x2){return x2>0&&(x2&x2-1)===0}function mod(num,min,max){if(typeof min==="undefined"){max=1;min=0}else if(typeof max==="undefined"){max=min;min=0}if(max>min){num=(num-min)%(max-min);return num+(num<0?max:min)}else{num=(num-max)%(min-max);return num+(num<=0?min:max)}}function clamp(num,min,max){if(nummax){return max}else{return num}}function random(min,max){if(typeof min==="undefined"){max=1;min=0}else if(typeof max==="undefined"){max=min;min=0}return min===max?min:math_random()*(max-min)+min}var math=Object.create(Math);math.EPSILON=EPSILON;math.isFinite=isFinite;math.nextPowerOfTwo=nextPowerOfTwo;math.isPowerOfTwo=isPowerOfTwo;math.mod=mod;math.clamp=clamp;math.random=random;var math_abs$9=Math.abs;var math_sqrt$5=Math.sqrt;var math_max$8=Math.max;var math_min$8=Math.min;var Vec2=function(){function Vec22(x2,y){if(!(this instanceof Vec22)){return new Vec22(x2,y)}if(typeof x2==="undefined"){this.x=0;this.y=0}else if(typeof x2==="object"){this.x=x2.x;this.y=x2.y}else{this.x=x2;this.y=y}}Vec22.prototype._serialize=function(){return{x:this.x,y:this.y}};Vec22._deserialize=function(data){var obj=Object.create(Vec22.prototype);obj.x=data.x;obj.y=data.y;return obj};Vec22.zero=function(){var obj=Object.create(Vec22.prototype);obj.x=0;obj.y=0;return obj};Vec22.neo=function(x2,y){var obj=Object.create(Vec22.prototype);obj.x=x2;obj.y=y;return obj};Vec22.clone=function(v3){return Vec22.neo(v3.x,v3.y)};Vec22.prototype.toString=function(){return JSON.stringify(this)};Vec22.isValid=function(obj){if(obj===null||typeof obj==="undefined"){return false}return Number.isFinite(obj.x)&&Number.isFinite(obj.y)};Vec22.assert=function(o){};Vec22.prototype.clone=function(){return Vec22.clone(this)};Vec22.prototype.setZero=function(){this.x=0;this.y=0;return this};Vec22.prototype.set=function(x2,y){if(typeof x2==="object"){this.x=x2.x;this.y=x2.y}else{this.x=x2;this.y=y}return this};Vec22.prototype.setNum=function(x2,y){this.x=x2;this.y=y;return this};Vec22.prototype.setVec2=function(value){this.x=value.x;this.y=value.y;return this};Vec22.prototype.wSet=function(a2,v3,b2,w){if(typeof b2!=="undefined"||typeof w!=="undefined"){return this.setCombine(a2,v3,b2,w)}else{return this.setMul(a2,v3)}};Vec22.prototype.setCombine=function(a2,v3,b2,w){var x2=a2*v3.x+b2*w.x;var y=a2*v3.y+b2*w.y;this.x=x2;this.y=y;return this};Vec22.prototype.setMul=function(a2,v3){var x2=a2*v3.x;var y=a2*v3.y;this.x=x2;this.y=y;return this};Vec22.prototype.add=function(w){this.x+=w.x;this.y+=w.y;return this};Vec22.prototype.wAdd=function(a2,v3,b2,w){if(typeof b2!=="undefined"||typeof w!=="undefined"){return this.addCombine(a2,v3,b2,w)}else{return this.addMul(a2,v3)}};Vec22.prototype.addCombine=function(a2,v3,b2,w){var x2=a2*v3.x+b2*w.x;var y=a2*v3.y+b2*w.y;this.x+=x2;this.y+=y;return this};Vec22.prototype.addMul=function(a2,v3){var x2=a2*v3.x;var y=a2*v3.y;this.x+=x2;this.y+=y;return this};Vec22.prototype.wSub=function(a2,v3,b2,w){if(typeof b2!=="undefined"||typeof w!=="undefined"){return this.subCombine(a2,v3,b2,w)}else{return this.subMul(a2,v3)}};Vec22.prototype.subCombine=function(a2,v3,b2,w){var x2=a2*v3.x+b2*w.x;var y=a2*v3.y+b2*w.y;this.x-=x2;this.y-=y;return this};Vec22.prototype.subMul=function(a2,v3){var x2=a2*v3.x;var y=a2*v3.y;this.x-=x2;this.y-=y;return this};Vec22.prototype.sub=function(w){this.x-=w.x;this.y-=w.y;return this};Vec22.prototype.mul=function(m){this.x*=m;this.y*=m;return this};Vec22.prototype.length=function(){return Vec22.lengthOf(this)};Vec22.prototype.lengthSquared=function(){return Vec22.lengthSquared(this)};Vec22.prototype.normalize=function(){var length=this.length();if(lengthmax*max){var scale=max/math_sqrt$5(lengthSqr);this.x*=scale;this.y*=scale}return this};Vec22.clamp=function(v3,max){var r=Vec22.neo(v3.x,v3.y);r.clamp(max);return r};Vec22.clampVec2=function(v3,min,max){return{x:clamp(v3.x,min===null||min===void 0?void 0:min.x,max===null||max===void 0?void 0:max.x),y:clamp(v3.y,min===null||min===void 0?void 0:min.y,max===null||max===void 0?void 0:max.y)}};Vec22.scaleFn=function(x2,y){return function(v3){return Vec22.neo(v3.x*x2,v3.y*y)}};Vec22.translateFn=function(x2,y){return function(v3){return Vec22.neo(v3.x+x2,v3.y+y)}};return Vec22}();var math_max$7=Math.max;var math_min$7=Math.min;var AABB=function(){function AABB2(lower,upper){if(!(this instanceof AABB2)){return new AABB2(lower,upper)}this.lowerBound=Vec2.zero();this.upperBound=Vec2.zero();if(typeof lower==="object"){this.lowerBound.setVec2(lower)}if(typeof upper==="object"){this.upperBound.setVec2(upper)}else if(typeof lower==="object"){this.upperBound.setVec2(lower)}}AABB2.prototype.isValid=function(){return AABB2.isValid(this)};AABB2.isValid=function(obj){if(obj===null||typeof obj==="undefined"){return false}return Vec2.isValid(obj.lowerBound)&&Vec2.isValid(obj.upperBound)&&Vec2.sub(obj.upperBound,obj.lowerBound).lengthSquared()>=0};AABB2.assert=function(o){};AABB2.prototype.getCenter=function(){return Vec2.neo((this.lowerBound.x+this.upperBound.x)*.5,(this.lowerBound.y+this.upperBound.y)*.5)};AABB2.prototype.getExtents=function(){return Vec2.neo((this.upperBound.x-this.lowerBound.x)*.5,(this.upperBound.y-this.lowerBound.y)*.5)};AABB2.prototype.getPerimeter=function(){return 2*(this.upperBound.x-this.lowerBound.x+this.upperBound.y-this.lowerBound.y)};AABB2.prototype.combine=function(a2,b2){b2=b2||this;var lowerA=a2.lowerBound;var upperA=a2.upperBound;var lowerB=b2.lowerBound;var upperB=b2.upperBound;var lowerX=math_min$7(lowerA.x,lowerB.x);var lowerY=math_min$7(lowerA.y,lowerB.y);var upperX=math_max$7(upperB.x,upperA.x);var upperY=math_max$7(upperB.y,upperA.y);this.lowerBound.setNum(lowerX,lowerY);this.upperBound.setNum(upperX,upperY)};AABB2.prototype.combinePoints=function(a2,b2){this.lowerBound.setNum(math_min$7(a2.x,b2.x),math_min$7(a2.y,b2.y));this.upperBound.setNum(math_max$7(a2.x,b2.x),math_max$7(a2.y,b2.y))};AABB2.prototype.set=function(aabb){this.lowerBound.setNum(aabb.lowerBound.x,aabb.lowerBound.y);this.upperBound.setNum(aabb.upperBound.x,aabb.upperBound.y)};AABB2.prototype.contains=function(aabb){var result=true;result=result&&this.lowerBound.x<=aabb.lowerBound.x;result=result&&this.lowerBound.y<=aabb.lowerBound.y;result=result&&aabb.upperBound.x<=this.upperBound.x;result=result&&aabb.upperBound.y<=this.upperBound.y;return result};AABB2.prototype.extend=function(value){AABB2.extend(this,value);return this};AABB2.extend=function(out,value){out.lowerBound.x-=value;out.lowerBound.y-=value;out.upperBound.x+=value;out.upperBound.y+=value;return out};AABB2.testOverlap=function(a2,b2){var d1x=b2.lowerBound.x-a2.upperBound.x;var d2x=a2.lowerBound.x-b2.upperBound.x;var d1y=b2.lowerBound.y-a2.upperBound.y;var d2y=a2.lowerBound.y-b2.upperBound.y;if(d1x>0||d1y>0||d2x>0||d2y>0){return false}return true};AABB2.areEqual=function(a2,b2){return Vec2.areEqual(a2.lowerBound,b2.lowerBound)&&Vec2.areEqual(a2.upperBound,b2.upperBound)};AABB2.diff=function(a2,b2){var wD=math_max$7(0,math_min$7(a2.upperBound.x,b2.upperBound.x)-math_max$7(b2.lowerBound.x,a2.lowerBound.x));var hD=math_max$7(0,math_min$7(a2.upperBound.y,b2.upperBound.y)-math_max$7(b2.lowerBound.y,a2.lowerBound.y));var wA=a2.upperBound.x-a2.lowerBound.x;var hA=a2.upperBound.y-a2.lowerBound.y;var wB=b2.upperBound.x-b2.lowerBound.x;var hB=b2.upperBound.y-b2.lowerBound.y;return wA*hA+wB*hB-wD*hD};AABB2.prototype.rayCast=function(output2,input2){var tmin=-Infinity;var tmax=Infinity;var p=input2.p1;var d2=Vec2.sub(input2.p2,input2.p1);var absD=Vec2.abs(d2);var normal3=Vec2.zero();for(var f="x";f!==null;f=f==="x"?"y":null){if(absD.xt2){var temp3=t1;t1=t2;t2=temp3;s2=1}if(t1>tmin){normal3.setZero();normal3[f]=s2;tmin=t1}tmax=math_min$7(tmax,t2);if(tmin>tmax){return false}}}if(tmin<0||input2.maxFraction0){item=this._list.shift()}else{this._createCount++;if(this._hasCreateFn){item=this._createFn()}else{item={}}}this._allocateCount++;if(this._hasAllocateFn){this._allocateFn(item)}return item};Pool2.prototype.release=function(item){if(this._list.length"+this._allocateCount+" <"+this._releaseCount+" -"+this._disposeCount+" ="+this._list.length+"/"+this._max};return Pool2}();var math_abs$8=Math.abs;var math_max$6=Math.max;var TreeNode=function(){function TreeNode2(id){this.aabb=new AABB;this.userData=null;this.parent=null;this.child1=null;this.child2=null;this.height=-1;this.id=id}TreeNode2.prototype.toString=function(){return this.id+": "+this.userData};TreeNode2.prototype.isLeaf=function(){return this.child1==null};return TreeNode2}();var poolTreeNode=new Pool({create:function(){return new TreeNode},release:function(node){node.userData=null;node.parent=null;node.child1=null;node.child2=null;node.height=-1;node.id=void 0}});var DynamicTree=function(){function DynamicTree2(){this.inputPool=new Pool({create:function(){return{}},release:function(stack){}});this.stackPool=new Pool({create:function(){return[]},release:function(stack){stack.length=0}});this.iteratorPool=new Pool({create:function(){return new Iterator},release:function(iterator){iterator.close()}});this.m_root=null;this.m_nodes={};this.m_lastProxyId=0}DynamicTree2.prototype.getUserData=function(id){var node=this.m_nodes[id];return node.userData};DynamicTree2.prototype.getFatAABB=function(id){var node=this.m_nodes[id];return node.aabb};DynamicTree2.prototype.allocateNode=function(){var node=poolTreeNode.allocate();node.id=++this.m_lastProxyId;this.m_nodes[node.id]=node;return node};DynamicTree2.prototype.freeNode=function(node){delete this.m_nodes[node.id];poolTreeNode.release(node)};DynamicTree2.prototype.createProxy=function(aabb,userData){var node=this.allocateNode();node.aabb.set(aabb);AABB.extend(node.aabb,SettingsInternal.aabbExtension);node.userData=userData;node.height=0;this.insertLeaf(node);return node.id};DynamicTree2.prototype.destroyProxy=function(id){var node=this.m_nodes[id];this.removeLeaf(node);this.freeNode(node)};DynamicTree2.prototype.moveProxy=function(id,aabb,d2){var node=this.m_nodes[id];if(node.aabb.contains(aabb)){return false}this.removeLeaf(node);node.aabb.set(aabb);aabb=node.aabb;AABB.extend(aabb,SettingsInternal.aabbExtension);if(d2.x<0){aabb.lowerBound.x+=d2.x*SettingsInternal.aabbMultiplier}else{aabb.upperBound.x+=d2.x*SettingsInternal.aabbMultiplier}if(d2.y<0){aabb.lowerBound.y+=d2.y*SettingsInternal.aabbMultiplier}else{aabb.upperBound.y+=d2.y*SettingsInternal.aabbMultiplier}this.insertLeaf(node);return true};DynamicTree2.prototype.insertLeaf=function(leaf){if(this.m_root==null){this.m_root=leaf;this.m_root.parent=null;return}var leafAABB=leaf.aabb;var index=this.m_root;while(!index.isLeaf()){var child1=index.child1;var child2=index.child2;var area=index.aabb.getPerimeter();var combinedArea=AABB.combinedPerimeter(index.aabb,leafAABB);var cost=2*combinedArea;var inheritanceCost=2*(combinedArea-area);var newArea1=AABB.combinedPerimeter(leafAABB,child1.aabb);var cost1=newArea1+inheritanceCost;if(!child1.isLeaf()){var oldArea=child1.aabb.getPerimeter();cost1-=oldArea}var newArea2=AABB.combinedPerimeter(leafAABB,child2.aabb);var cost2=newArea2+inheritanceCost;if(!child2.isLeaf()){var oldArea=child2.aabb.getPerimeter();cost2-=oldArea}if(cost1){var F=C.child1;var G=C.child2;C.child1=A;C.parent=A.parent;A.parent=C;if(C.parent!=null){if(C.parent.child1===iA){C.parent.child1=C}else{C.parent.child2=C}}else{this.m_root=C}if(F.height>G.height){C.child2=F;A.child2=G;G.parent=A;A.aabb.combine(B.aabb,G.aabb);C.aabb.combine(A.aabb,F.aabb);A.height=1+math_max$6(B.height,G.height);C.height=1+math_max$6(A.height,F.height)}else{C.child2=G;A.child2=F;F.parent=A;A.aabb.combine(B.aabb,F.aabb);C.aabb.combine(A.aabb,G.aabb);A.height=1+math_max$6(B.height,F.height);C.height=1+math_max$6(A.height,G.height)}return C}if(balance<-1){var D=B.child1;var E=B.child2;B.child1=A;B.parent=A.parent;A.parent=B;if(B.parent!=null){if(B.parent.child1===A){B.parent.child1=B}else{B.parent.child2=B}}else{this.m_root=B}if(D.height>E.height){B.child2=D;A.child1=E;E.parent=A;A.aabb.combine(C.aabb,E.aabb);B.aabb.combine(A.aabb,D.aabb);A.height=1+math_max$6(C.height,E.height);B.height=1+math_max$6(A.height,D.height)}else{B.child2=E;A.child1=D;D.parent=A;A.aabb.combine(C.aabb,D.aabb);B.aabb.combine(A.aabb,E.aabb);A.height=1+math_max$6(C.height,D.height);B.height=1+math_max$6(A.height,E.height)}return B}return A};DynamicTree2.prototype.getHeight=function(){if(this.m_root==null){return 0}return this.m_root.height};DynamicTree2.prototype.getAreaRatio=function(){if(this.m_root==null){return 0}var root=this.m_root;var rootArea=root.aabb.getPerimeter();var totalArea=0;var node;var it=this.iteratorPool.allocate().preorder(this.m_root);while(node=it.next()){if(node.height<0){continue}totalArea+=node.aabb.getPerimeter()}this.iteratorPool.release(it);return totalArea/rootArea};DynamicTree2.prototype.computeHeight=function(id){var node;if(typeof id!=="undefined"){node=this.m_nodes[id]}else{node=this.m_root}if(node.isLeaf()){return 0}var height1=this.computeHeight(node.child1.id);var height2=this.computeHeight(node.child2.id);return 1+math_max$6(height1,height2)};DynamicTree2.prototype.validateStructure=function(node){if(node==null){return}if(node===this.m_root);var child1=node.child1;var child2=node.child2;if(node.isLeaf()){return}this.validateStructure(child1);this.validateStructure(child2)};DynamicTree2.prototype.validateMetrics=function(node){if(node==null){return}var child1=node.child1;var child2=node.child2;if(node.isLeaf()){return}child1.height;child2.height;var aabb=new AABB;aabb.combine(child1.aabb,child2.aabb);this.validateMetrics(child1);this.validateMetrics(child2)};DynamicTree2.prototype.validate=function(){return};DynamicTree2.prototype.getMaxBalance=function(){var maxBalance=0;var node;var it=this.iteratorPool.allocate().preorder(this.m_root);while(node=it.next()){if(node.height<=1){continue}var balance=math_abs$8(node.child2.height-node.child1.height);maxBalance=math_max$6(maxBalance,balance)}this.iteratorPool.release(it);return maxBalance};DynamicTree2.prototype.rebuildBottomUp=function(){var nodes=[];var count=0;var node;var it=this.iteratorPool.allocate().preorder(this.m_root);while(node=it.next()){if(node.height<0){continue}if(node.isLeaf()){node.parent=null;nodes[count]=node;++count}else{this.freeNode(node)}}this.iteratorPool.release(it);while(count>1){var minCost=Infinity;var iMin=-1;var jMin=-1;for(var i=0;i0){var node=stack.pop();if(node==null){continue}if(AABB.testOverlap(node.aabb,aabb)){if(node.isLeaf()){var proceed=queryCallback(node.id);if(proceed===false){return}}else{stack.push(node.child1);stack.push(node.child2)}}}this.stackPool.release(stack)};DynamicTree2.prototype.rayCast=function(input2,rayCastCallback){var p1=input2.p1;var p2=input2.p2;var r=Vec2.sub(p2,p1);r.normalize();var v3=Vec2.crossNumVec2(1,r);var abs_v=Vec2.abs(v3);var maxFraction=input2.maxFraction;var segmentAABB=new AABB;var t=Vec2.combine(1-maxFraction,p1,maxFraction,p2);segmentAABB.combinePoints(p1,t);var stack=this.stackPool.allocate();var subInput=this.inputPool.allocate();stack.push(this.m_root);while(stack.length>0){var node=stack.pop();if(node==null){continue}if(AABB.testOverlap(node.aabb,segmentAABB)===false){continue}var c2=node.aabb.getCenter();var h=node.aabb.getExtents();var separation=math_abs$8(Vec2.dot(v3,Vec2.sub(p1,c2)))-Vec2.dot(abs_v,h);if(separation>0){continue}if(node.isLeaf()){subInput.p1=Vec2.clone(input2.p1);subInput.p2=Vec2.clone(input2.p2);subInput.maxFraction=maxFraction;var value=rayCastCallback(subInput,node.id);if(value===0){break}else if(value>0){maxFraction=value;t=Vec2.combine(1-maxFraction,p1,maxFraction,p2);segmentAABB.combinePoints(p1,t)}}else{stack.push(node.child1);stack.push(node.child2)}}this.stackPool.release(stack);this.inputPool.release(subInput)};return DynamicTree2}();var Iterator=function(){function Iterator2(){this.parents=[];this.states=[]}Iterator2.prototype.preorder=function(root){this.parents.length=0;this.parents.push(root);this.states.length=0;this.states.push(0);return this};Iterator2.prototype.next=function(){while(this.parents.length>0){var i=this.parents.length-1;var node=this.parents[i];if(this.states[i]===0){this.states[i]=1;return node}if(this.states[i]===1){this.states[i]=2;if(node.child1){this.parents.push(node.child1);this.states.push(1);return node.child1}}if(this.states[i]===2){this.states[i]=3;if(node.child2){this.parents.push(node.child2);this.states.push(1);return node.child2}}this.parents.pop();this.states.pop()}};Iterator2.prototype.close=function(){this.parents.length=0};return Iterator2}();var math_max$5=Math.max;var math_min$6=Math.min;var BroadPhase=function(){function BroadPhase2(){var _this=this;this.m_tree=new DynamicTree;this.m_moveBuffer=[];this.query=function(aabb,queryCallback){_this.m_tree.query(aabb,queryCallback)};this.queryCallback=function(proxyId){if(proxyId===_this.m_queryProxyId){return true}var proxyIdA=math_min$6(proxyId,_this.m_queryProxyId);var proxyIdB=math_max$5(proxyId,_this.m_queryProxyId);var userDataA=_this.m_tree.getUserData(proxyIdA);var userDataB=_this.m_tree.getUserData(proxyIdB);_this.m_callback(userDataA,userDataB);return true}}BroadPhase2.prototype.getUserData=function(proxyId){return this.m_tree.getUserData(proxyId)};BroadPhase2.prototype.testOverlap=function(proxyIdA,proxyIdB){var aabbA=this.m_tree.getFatAABB(proxyIdA);var aabbB=this.m_tree.getFatAABB(proxyIdB);return AABB.testOverlap(aabbA,aabbB)};BroadPhase2.prototype.getFatAABB=function(proxyId){return this.m_tree.getFatAABB(proxyId)};BroadPhase2.prototype.getProxyCount=function(){return this.m_moveBuffer.length};BroadPhase2.prototype.getTreeHeight=function(){return this.m_tree.getHeight()};BroadPhase2.prototype.getTreeBalance=function(){return this.m_tree.getMaxBalance()};BroadPhase2.prototype.getTreeQuality=function(){return this.m_tree.getAreaRatio()};BroadPhase2.prototype.rayCast=function(input2,rayCastCallback){this.m_tree.rayCast(input2,rayCastCallback)};BroadPhase2.prototype.shiftOrigin=function(newOrigin){this.m_tree.shiftOrigin(newOrigin)};BroadPhase2.prototype.createProxy=function(aabb,userData){var proxyId=this.m_tree.createProxy(aabb,userData);this.bufferMove(proxyId);return proxyId};BroadPhase2.prototype.destroyProxy=function(proxyId){this.unbufferMove(proxyId);this.m_tree.destroyProxy(proxyId)};BroadPhase2.prototype.moveProxy=function(proxyId,aabb,displacement2){var changed=this.m_tree.moveProxy(proxyId,aabb,displacement2);if(changed){this.bufferMove(proxyId)}};BroadPhase2.prototype.touchProxy=function(proxyId){this.bufferMove(proxyId)};BroadPhase2.prototype.bufferMove=function(proxyId){this.m_moveBuffer.push(proxyId)};BroadPhase2.prototype.unbufferMove=function(proxyId){for(var i=0;i0){this.m_queryProxyId=this.m_moveBuffer.pop();if(this.m_queryProxyId===null){continue}var fatAABB=this.m_tree.getFatAABB(this.m_queryProxyId);this.m_tree.query(fatAABB,this.queryCallback)}};return BroadPhase2}();var math_sin$2=Math.sin;var math_cos$2=Math.cos;var math_sqrt$4=Math.sqrt;function vec2(x2,y){return{x:x2,y:y}}function rotation(angle){return{s:math_sin$2(angle),c:math_cos$2(angle)}}function setVec2(out,x2,y){out.x=x2;out.y=y;return out}function copyVec2(out,w){out.x=w.x;out.y=w.y;return out}function zeroVec2(out){out.x=0;out.y=0;return out}function negVec2(out){out.x=-out.x;out.y=-out.y;return out}function plusVec2(out,w){out.x+=w.x;out.y+=w.y;return out}function addVec2(out,v3,w){out.x=v3.x+w.x;out.y=v3.x+w.y;return out}function minusVec2(out,w){out.x-=w.x;out.y-=w.y;return out}function subVec2(out,v3,w){out.x=v3.x-w.x;out.y=v3.y-w.y;return out}function mulVec2(out,m){out.x*=m;out.y*=m;return out}function scaleVec2(out,m,w){out.x=m*w.x;out.y=m*w.y;return out}function plusScaleVec2(out,m,w){out.x+=m*w.x;out.y+=m*w.y;return out}function minusScaleVec2(out,m,w){out.x-=m*w.x;out.y-=m*w.y;return out}function combine2Vec2(out,am,a2,bm,b2){out.x=am*a2.x+bm*b2.x;out.y=am*a2.y+bm*b2.y;return out}function combine3Vec2(out,am,a2,bm,b2,cm,c2){out.x=am*a2.x+bm*b2.x+cm*c2.x;out.y=am*a2.y+bm*b2.y+cm*c2.y;return out}function normalizeVec2Length(out){var length=math_sqrt$4(out.x*out.x+out.y*out.y);if(length!==0){var invLength=1/length;out.x*=invLength;out.y*=invLength}return length}function normalizeVec2(out){var length=math_sqrt$4(out.x*out.x+out.y*out.y);if(length>0){var invLength=1/length;out.x*=invLength;out.y*=invLength}return out}function crossVec2Num(out,v3,w){var x2=w*v3.y;var y=-w*v3.x;out.x=x2;out.y=y;return out}function crossNumVec2(out,w,v3){var x2=-w*v3.y;var y=w*v3.x;out.x=x2;out.y=y;return out}function crossVec2Vec2(a2,b2){return a2.x*b2.y-a2.y*b2.x}function dotVec2(a2,b2){return a2.x*b2.x+a2.y*b2.y}function lengthSqrVec2(a2){return a2.x*a2.x+a2.y*a2.y}function distVec2(a2,b2){var dx=a2.x-b2.x;var dy=a2.y-b2.y;return math_sqrt$4(dx*dx+dy*dy)}function distSqrVec2(a2,b2){var dx=a2.x-b2.x;var dy=a2.y-b2.y;return dx*dx+dy*dy}function setRotAngle(out,a2){out.c=math_cos$2(a2);out.s=math_sin$2(a2);return out}function rotVec2(out,q,v3){out.x=q.c*v3.x-q.s*v3.y;out.y=q.s*v3.x+q.c*v3.y;return out}function derotVec2(out,q,v3){var x2=q.c*v3.x+q.s*v3.y;var y=-q.s*v3.x+q.c*v3.y;out.x=x2;out.y=y;return out}function rerotVec2(out,before,after,v3){var x0=before.c*v3.x+before.s*v3.y;var y0=-before.s*v3.x+before.c*v3.y;var x2=after.c*x0-after.s*y0;var y=after.s*x0+after.c*y0;out.x=x2;out.y=y;return out}function transform(x2,y,a2){return{p:vec2(x2,y),q:rotation(a2)}}function copyTransform(out,transform2){out.p.x=transform2.p.x;out.p.y=transform2.p.y;out.q.s=transform2.q.s;out.q.c=transform2.q.c;return out}function transformVec2(out,xf2,v3){var x2=xf2.q.c*v3.x-xf2.q.s*v3.y+xf2.p.x;var y=xf2.q.s*v3.x+xf2.q.c*v3.y+xf2.p.y;out.x=x2;out.y=y;return out}function detransformVec2(out,xf2,v3){var px=v3.x-xf2.p.x;var py=v3.y-xf2.p.y;var x2=xf2.q.c*px+xf2.q.s*py;var y=-xf2.q.s*px+xf2.q.c*py;out.x=x2;out.y=y;return out}function retransformVec2(out,from,to,v3){var x0=from.q.c*v3.x-from.q.s*v3.y+from.p.x;var y0=from.q.s*v3.x+from.q.c*v3.y+from.p.y;var px=x0-to.p.x;var py=y0-to.p.y;var x2=to.q.c*px+to.q.s*py;var y=-to.q.s*px+to.q.c*py;out.x=x2;out.y=y;return out}function detransformTransform(out,a2,b2){var c2=a2.q.c*b2.q.c+a2.q.s*b2.q.s;var s2=a2.q.c*b2.q.s-a2.q.s*b2.q.c;var x2=a2.q.c*(b2.p.x-a2.p.x)+a2.q.s*(b2.p.y-a2.p.y);var y=-a2.q.s*(b2.p.x-a2.p.x)+a2.q.c*(b2.p.y-a2.p.y);out.q.c=c2;out.q.s=s2;out.p.x=x2;out.p.y=y;return out}var math_sin$1=Math.sin;var math_cos$1=Math.cos;var math_atan2$1=Math.atan2;var Rot=function(){function Rot2(angle){if(!(this instanceof Rot2)){return new Rot2(angle)}if(typeof angle==="number"){this.setAngle(angle)}else if(typeof angle==="object"){this.setRot(angle)}else{this.setIdentity()}}Rot2.neo=function(angle){var obj=Object.create(Rot2.prototype);obj.setAngle(angle);return obj};Rot2.clone=function(rot){var obj=Object.create(Rot2.prototype);obj.s=rot.s;obj.c=rot.c;return obj};Rot2.identity=function(){var obj=Object.create(Rot2.prototype);obj.s=0;obj.c=1;return obj};Rot2.isValid=function(obj){if(obj===null||typeof obj==="undefined"){return false}return Number.isFinite(obj.s)&&Number.isFinite(obj.c)};Rot2.assert=function(o){};Rot2.prototype.setIdentity=function(){this.s=0;this.c=1};Rot2.prototype.set=function(angle){if(typeof angle==="object"){this.s=angle.s;this.c=angle.c}else{this.s=math_sin$1(angle);this.c=math_cos$1(angle)}};Rot2.prototype.setRot=function(angle){this.s=angle.s;this.c=angle.c};Rot2.prototype.setAngle=function(angle){this.s=math_sin$1(angle);this.c=math_cos$1(angle)};Rot2.prototype.getAngle=function(){return math_atan2$1(this.s,this.c)};Rot2.prototype.getXAxis=function(){return Vec2.neo(this.c,this.s)};Rot2.prototype.getYAxis=function(){return Vec2.neo(-this.s,this.c)};Rot2.mul=function(rot,m){if("c"in m&&"s"in m){var qr=Rot2.identity();qr.s=rot.s*m.c+rot.c*m.s;qr.c=rot.c*m.c-rot.s*m.s;return qr}else if("x"in m&&"y"in m){return Vec2.neo(rot.c*m.x-rot.s*m.y,rot.s*m.x+rot.c*m.y)}};Rot2.mulRot=function(rot,m){var qr=Rot2.identity();qr.s=rot.s*m.c+rot.c*m.s;qr.c=rot.c*m.c-rot.s*m.s;return qr};Rot2.mulVec2=function(rot,m){return Vec2.neo(rot.c*m.x-rot.s*m.y,rot.s*m.x+rot.c*m.y)};Rot2.mulSub=function(rot,v3,w){var x2=rot.c*(v3.x-w.x)-rot.s*(v3.y-w.y);var y=rot.s*(v3.x-w.x)+rot.c*(v3.y-w.y);return Vec2.neo(x2,y)};Rot2.mulT=function(rot,m){if("c"in m&&"s"in m){var qr=Rot2.identity();qr.s=rot.c*m.s-rot.s*m.c;qr.c=rot.c*m.c+rot.s*m.s;return qr}else if("x"in m&&"y"in m){return Vec2.neo(rot.c*m.x+rot.s*m.y,-rot.s*m.x+rot.c*m.y)}};Rot2.mulTRot=function(rot,m){var qr=Rot2.identity();qr.s=rot.c*m.s-rot.s*m.c;qr.c=rot.c*m.c+rot.s*m.s;return qr};Rot2.mulTVec2=function(rot,m){return Vec2.neo(rot.c*m.x+rot.s*m.y,-rot.s*m.x+rot.c*m.y)};return Rot2}();var math_atan2=Math.atan2;var math_PI$5=Math.PI;var temp$7=vec2(0,0);var Sweep=function(){function Sweep2(){this.localCenter=Vec2.zero();this.c=Vec2.zero();this.a=0;this.alpha0=0;this.c0=Vec2.zero();this.a0=0}Sweep2.prototype.recycle=function(){zeroVec2(this.localCenter);zeroVec2(this.c);this.a=0;this.alpha0=0;zeroVec2(this.c0);this.a0=0};Sweep2.prototype.setTransform=function(xf2){transformVec2(temp$7,xf2,this.localCenter);copyVec2(this.c,temp$7);copyVec2(this.c0,temp$7);this.a=this.a0=math_atan2(xf2.q.s,xf2.q.c)};Sweep2.prototype.setLocalCenter=function(localCenter2,xf2){copyVec2(this.localCenter,localCenter2);transformVec2(temp$7,xf2,this.localCenter);copyVec2(this.c,temp$7);copyVec2(this.c0,temp$7)};Sweep2.prototype.getTransform=function(xf2,beta){if(beta===void 0){beta=0}setRotAngle(xf2.q,(1-beta)*this.a0+beta*this.a);combine2Vec2(xf2.p,1-beta,this.c0,beta,this.c);minusVec2(xf2.p,rotVec2(temp$7,xf2.q,this.localCenter))};Sweep2.prototype.advance=function(alpha){var beta=(alpha-this.alpha0)/(1-this.alpha0);combine2Vec2(this.c0,beta,this.c,1-beta,this.c0);this.a0=beta*this.a+(1-beta)*this.a0;this.alpha0=alpha};Sweep2.prototype.forward=function(){this.a0=this.a;copyVec2(this.c0,this.c)};Sweep2.prototype.normalize=function(){var a0=mod(this.a0,-math_PI$5,+math_PI$5);this.a-=this.a0-a0;this.a0=a0};Sweep2.prototype.set=function(that){copyVec2(this.localCenter,that.localCenter);copyVec2(this.c,that.c);this.a=that.a;this.alpha0=that.alpha0;copyVec2(this.c0,that.c0);this.a0=that.a0};return Sweep2}();var Transform=function(){function Transform2(position,rotation2){if(!(this instanceof Transform2)){return new Transform2(position,rotation2)}this.p=Vec2.zero();this.q=Rot.identity();if(typeof position!=="undefined"){this.p.setVec2(position)}if(typeof rotation2!=="undefined"){this.q.setAngle(rotation2)}}Transform2.clone=function(xf2){var obj=Object.create(Transform2.prototype);obj.p=Vec2.clone(xf2.p);obj.q=Rot.clone(xf2.q);return obj};Transform2.neo=function(position,rotation2){var obj=Object.create(Transform2.prototype);obj.p=Vec2.clone(position);obj.q=Rot.clone(rotation2);return obj};Transform2.identity=function(){var obj=Object.create(Transform2.prototype);obj.p=Vec2.zero();obj.q=Rot.identity();return obj};Transform2.prototype.setIdentity=function(){this.p.setZero();this.q.setIdentity()};Transform2.prototype.set=function(a2,b2){if(typeof b2==="undefined"){this.p.set(a2.p);this.q.set(a2.q)}else{this.p.set(a2);this.q.set(b2)}};Transform2.prototype.setNum=function(position,rotation2){this.p.setVec2(position);this.q.setAngle(rotation2)};Transform2.prototype.setTransform=function(xf2){this.p.setVec2(xf2.p);this.q.setRot(xf2.q)};Transform2.isValid=function(obj){if(obj===null||typeof obj==="undefined"){return false}return Vec2.isValid(obj.p)&&Rot.isValid(obj.q)};Transform2.assert=function(o){};Transform2.mul=function(a2,b2){if(Array.isArray(b2)){var arr=[];for(var i=0;i0}var collideA=(that.m_filterMaskBits&this.m_filterCategoryBits)!==0;var collideB=(that.m_filterCategoryBits&this.m_filterMaskBits)!==0;var collide=collideA&&collideB;return collide};return Fixture2}();var STATIC="static";var KINEMATIC="kinematic";var DYNAMIC="dynamic";var oldCenter=vec2(0,0);var localCenter=vec2(0,0);var shift=vec2(0,0);var temp$6=vec2(0,0);var xf$2=transform(0,0,0);var BodyDefDefault={type:STATIC,position:Vec2.zero(),angle:0,linearVelocity:Vec2.zero(),angularVelocity:0,linearDamping:0,angularDamping:0,fixedRotation:false,bullet:false,gravityScale:1,allowSleep:true,awake:true,active:true,userData:null};var Body=function(){function Body2(world,def){this.style={};this.appData={};def=options(def,BodyDefDefault);this.m_world=world;this.m_awakeFlag=def.awake;this.m_autoSleepFlag=def.allowSleep;this.m_bulletFlag=def.bullet;this.m_fixedRotationFlag=def.fixedRotation;this.m_activeFlag=def.active;this.m_islandFlag=false;this.m_toiFlag=false;this.m_userData=def.userData;this.m_type=def.type;if(this.m_type==DYNAMIC){this.m_mass=1;this.m_invMass=1}else{this.m_mass=0;this.m_invMass=0}this.m_I=0;this.m_invI=0;this.m_xf=Transform.identity();this.m_xf.p.setVec2(def.position);this.m_xf.q.setAngle(def.angle);this.m_sweep=new Sweep;this.m_sweep.setTransform(this.m_xf);this.c_velocity=new Velocity;this.c_position=new Position;this.m_force=Vec2.zero();this.m_torque=0;this.m_linearVelocity=Vec2.clone(def.linearVelocity);this.m_angularVelocity=def.angularVelocity;this.m_linearDamping=def.linearDamping;this.m_angularDamping=def.angularDamping;this.m_gravityScale=def.gravityScale;this.m_sleepTime=0;this.m_jointList=null;this.m_contactList=null;this.m_fixtureList=null;this.m_prev=null;this.m_next=null;this.m_destroyed=false;if(typeof def.style==="object"&&def.style!==null){this.style=def.style}}Body2.prototype._serialize=function(){var fixtures=[];for(var f=this.m_fixtureList;f;f=f.m_next){fixtures.push(f)}return{type:this.m_type,bullet:this.m_bulletFlag,position:this.m_xf.p,angle:this.m_xf.q.getAngle(),linearVelocity:this.m_linearVelocity,angularVelocity:this.m_angularVelocity,fixtures:fixtures}};Body2._deserialize=function(data,world,restore){var body=new Body2(world,data);if(data.fixtures){for(var i=data.fixtures.length-1;i>=0;i--){var fixture=restore(Fixture,data.fixtures[i],body);body._addFixture(fixture)}}return body};Body2.prototype.isWorldLocked=function(){return this.m_world&&this.m_world.isLocked()?true:false};Body2.prototype.getWorld=function(){return this.m_world};Body2.prototype.getNext=function(){return this.m_next};Body2.prototype.setUserData=function(data){this.m_userData=data};Body2.prototype.getUserData=function(){return this.m_userData};Body2.prototype.getFixtureList=function(){return this.m_fixtureList};Body2.prototype.getJointList=function(){return this.m_jointList};Body2.prototype.getContactList=function(){return this.m_contactList};Body2.prototype.isStatic=function(){return this.m_type==STATIC};Body2.prototype.isDynamic=function(){return this.m_type==DYNAMIC};Body2.prototype.isKinematic=function(){return this.m_type==KINEMATIC};Body2.prototype.setStatic=function(){this.setType(STATIC);return this};Body2.prototype.setDynamic=function(){this.setType(DYNAMIC);return this};Body2.prototype.setKinematic=function(){this.setType(KINEMATIC);return this};Body2.prototype.getType=function(){return this.m_type};Body2.prototype.setType=function(type){if(this.isWorldLocked()==true){return}if(this.m_type==type){return}this.m_type=type;this.resetMassData();if(this.m_type==STATIC){this.m_linearVelocity.setZero();this.m_angularVelocity=0;this.m_sweep.forward();this.synchronizeFixtures()}this.setAwake(true);this.m_force.setZero();this.m_torque=0;var ce=this.m_contactList;while(ce){var ce0=ce;ce=ce.next;this.m_world.destroyContact(ce0.contact)}this.m_contactList=null;var broadPhase=this.m_world.m_broadPhase;for(var f=this.m_fixtureList;f;f=f.m_next){for(var i=0;i0){this.setAwake(true)}this.m_linearVelocity.setVec2(v3)};Body2.prototype.getAngularVelocity=function(){return this.m_angularVelocity};Body2.prototype.setAngularVelocity=function(w){if(this.m_type==STATIC){return}if(w*w>0){this.setAwake(true)}this.m_angularVelocity=w};Body2.prototype.getLinearDamping=function(){return this.m_linearDamping};Body2.prototype.setLinearDamping=function(linearDamping){this.m_linearDamping=linearDamping};Body2.prototype.getAngularDamping=function(){return this.m_angularDamping};Body2.prototype.setAngularDamping=function(angularDamping){this.m_angularDamping=angularDamping};Body2.prototype.getGravityScale=function(){return this.m_gravityScale};Body2.prototype.setGravityScale=function(scale){this.m_gravityScale=scale};Body2.prototype.getMass=function(){return this.m_mass};Body2.prototype.getInertia=function(){return this.m_I+this.m_mass*Vec2.dot(this.m_sweep.localCenter,this.m_sweep.localCenter)};Body2.prototype.getMassData=function(data){data.mass=this.m_mass;data.I=this.getInertia();copyVec2(data.center,this.m_sweep.localCenter)};Body2.prototype.resetMassData=function(){this.m_mass=0;this.m_invMass=0;this.m_I=0;this.m_invI=0;zeroVec2(this.m_sweep.localCenter);if(this.isStatic()||this.isKinematic()){copyVec2(this.m_sweep.c0,this.m_xf.p);copyVec2(this.m_sweep.c,this.m_xf.p);this.m_sweep.a0=this.m_sweep.a;return}zeroVec2(localCenter);for(var f=this.m_fixtureList;f;f=f.m_next){if(f.m_density==0){continue}var massData={mass:0,center:vec2(0,0),I:0};f.getMassData(massData);this.m_mass+=massData.mass;plusScaleVec2(localCenter,massData.mass,massData.center);this.m_I+=massData.I}if(this.m_mass>0){this.m_invMass=1/this.m_mass;scaleVec2(localCenter,this.m_invMass,localCenter)}else{this.m_mass=1;this.m_invMass=1}if(this.m_I>0&&this.m_fixedRotationFlag==false){this.m_I-=this.m_mass*dotVec2(localCenter,localCenter);this.m_invI=1/this.m_I}else{this.m_I=0;this.m_invI=0}copyVec2(oldCenter,this.m_sweep.c);this.m_sweep.setLocalCenter(localCenter,this.m_xf);subVec2(shift,this.m_sweep.c,oldCenter);crossNumVec2(temp$6,this.m_angularVelocity,shift);plusVec2(this.m_linearVelocity,temp$6)};Body2.prototype.setMassData=function(massData){if(this.isWorldLocked()==true){return}if(this.m_type!=DYNAMIC){return}this.m_invMass=0;this.m_I=0;this.m_invI=0;this.m_mass=massData.mass;if(this.m_mass<=0){this.m_mass=1}this.m_invMass=1/this.m_mass;if(massData.I>0&&this.m_fixedRotationFlag==false){this.m_I=massData.I-this.m_mass*dotVec2(massData.center,massData.center);this.m_invI=1/this.m_I}copyVec2(oldCenter,this.m_sweep.c);this.m_sweep.setLocalCenter(massData.center,this.m_xf);subVec2(shift,this.m_sweep.c,oldCenter);crossNumVec2(temp$6,this.m_angularVelocity,shift);plusVec2(this.m_linearVelocity,temp$6)};Body2.prototype.applyForce=function(force,point2,wake){if(wake===void 0){wake=true}if(this.m_type!=DYNAMIC){return}if(wake&&this.m_awakeFlag==false){this.setAwake(true)}if(this.m_awakeFlag){this.m_force.add(force);this.m_torque+=Vec2.crossVec2Vec2(Vec2.sub(point2,this.m_sweep.c),force)}};Body2.prototype.applyForceToCenter=function(force,wake){if(wake===void 0){wake=true}if(this.m_type!=DYNAMIC){return}if(wake&&this.m_awakeFlag==false){this.setAwake(true)}if(this.m_awakeFlag){this.m_force.add(force)}};Body2.prototype.applyTorque=function(torque,wake){if(wake===void 0){wake=true}if(this.m_type!=DYNAMIC){return}if(wake&&this.m_awakeFlag==false){this.setAwake(true)}if(this.m_awakeFlag){this.m_torque+=torque}};Body2.prototype.applyLinearImpulse=function(impulse,point2,wake){if(wake===void 0){wake=true}if(this.m_type!=DYNAMIC){return}if(wake&&this.m_awakeFlag==false){this.setAwake(true)}if(this.m_awakeFlag){this.m_linearVelocity.addMul(this.m_invMass,impulse);this.m_angularVelocity+=this.m_invI*Vec2.crossVec2Vec2(Vec2.sub(point2,this.m_sweep.c),impulse)}};Body2.prototype.applyAngularImpulse=function(impulse,wake){if(wake===void 0){wake=true}if(this.m_type!=DYNAMIC){return}if(wake&&this.m_awakeFlag==false){this.setAwake(true)}if(this.m_awakeFlag){this.m_angularVelocity+=this.m_invI*impulse}};Body2.prototype.shouldCollide=function(that){if(this.m_type!=DYNAMIC&&that.m_type!=DYNAMIC){return false}for(var jn=this.m_jointList;jn;jn=jn.next){if(jn.other==that){if(jn.joint.m_collideConnected==false){return false}}}return true};Body2.prototype._addFixture=function(fixture){if(this.isWorldLocked()==true){return null}if(this.m_activeFlag){var broadPhase=this.m_world.m_broadPhase;fixture.createProxies(broadPhase,this.m_xf)}fixture.m_next=this.m_fixtureList;this.m_fixtureList=fixture;if(fixture.m_density>0){this.resetMassData()}this.m_world.m_newFixture=true;return fixture};Body2.prototype.createFixture=function(shape,fixdef){if(this.isWorldLocked()==true){return null}var fixture=new Fixture(this,shape,fixdef);this._addFixture(fixture);return fixture};Body2.prototype.destroyFixture=function(fixture){if(this.isWorldLocked()==true){return}if(this.m_fixtureList===fixture){this.m_fixtureList=fixture.m_next}else{var node=this.m_fixtureList;while(node!=null){if(node.m_next===fixture){node.m_next=fixture.m_next;break}node=node.m_next}}var edge=this.m_contactList;while(edge){var c2=edge.contact;edge=edge.next;var fixtureA=c2.getFixtureA();var fixtureB=c2.getFixtureB();if(fixture==fixtureA||fixture==fixtureB){this.m_world.destroyContact(c2)}}if(this.m_activeFlag){var broadPhase=this.m_world.m_broadPhase;fixture.destroyProxies(broadPhase)}fixture.m_body=null;fixture.m_next=null;this.m_world.publish("remove-fixture",fixture);this.resetMassData()};Body2.prototype.getWorldPoint=function(localPoint){return Transform.mulVec2(this.m_xf,localPoint)};Body2.prototype.getWorldVector=function(localVector){return Rot.mulVec2(this.m_xf.q,localVector)};Body2.prototype.getLocalPoint=function(worldPoint){return Transform.mulTVec2(this.m_xf,worldPoint)};Body2.prototype.getLocalVector=function(worldVector){return Rot.mulTVec2(this.m_xf.q,worldVector)};Body2.STATIC="static";Body2.KINEMATIC="kinematic";Body2.DYNAMIC="dynamic";return Body2}();var JointEdge=function(){function JointEdge2(){this.other=null;this.joint=null;this.prev=null;this.next=null}return JointEdge2}();var Joint=function(){function Joint2(def,bodyA,bodyB){this.m_type="unknown-joint";this.m_prev=null;this.m_next=null;this.m_edgeA=new JointEdge;this.m_edgeB=new JointEdge;this.m_islandFlag=false;this.style={};this.appData={};bodyA="bodyA"in def?def.bodyA:bodyA;bodyB="bodyB"in def?def.bodyB:bodyB;this.m_bodyA=bodyA;this.m_bodyB=bodyB;this.m_collideConnected=!!def.collideConnected;this.m_userData=def.userData;if(typeof def.style==="object"&&def.style!==null){this.style=def.style}}Joint2.prototype.isActive=function(){return this.m_bodyA.isActive()&&this.m_bodyB.isActive()};Joint2.prototype.getType=function(){return this.m_type};Joint2.prototype.getBodyA=function(){return this.m_bodyA};Joint2.prototype.getBodyB=function(){return this.m_bodyB};Joint2.prototype.getNext=function(){return this.m_next};Joint2.prototype.getUserData=function(){return this.m_userData};Joint2.prototype.setUserData=function(data){this.m_userData=data};Joint2.prototype.getCollideConnected=function(){return this.m_collideConnected};Joint2.prototype.shiftOrigin=function(newOrigin){};Joint2.prototype._resetAnchors=function(def){return this._reset(def)};return Joint2}();var stats={gjkCalls:0,gjkIters:0,gjkMaxIters:0,toiTime:0,toiMaxTime:0,toiCalls:0,toiIters:0,toiMaxIters:0,toiRootIters:0,toiMaxRootIters:0,toString:function(newline){newline=typeof newline==="string"?newline:"\n";var string="";for(var name_1 in this){if(typeof this[name_1]!=="function"&&typeof this[name_1]!=="object"){string+=name_1+": "+this[name_1]+newline}}return string}};var now=function(){return Date.now()};var diff=function(time){return Date.now()-time};const Timer={now:now,diff:diff};var math_max$4=Math.max;var temp$5=vec2(0,0);var normal$4=vec2(0,0);var e12=vec2(0,0);var e13=vec2(0,0);var e23=vec2(0,0);var temp1=vec2(0,0);var temp2=vec2(0,0);stats.gjkCalls=0;stats.gjkIters=0;stats.gjkMaxIters=0;var DistanceInput=function(){function DistanceInput2(){this.proxyA=new DistanceProxy;this.proxyB=new DistanceProxy;this.transformA=Transform.identity();this.transformB=Transform.identity();this.useRadii=false}DistanceInput2.prototype.recycle=function(){this.proxyA.recycle();this.proxyB.recycle();this.transformA.setIdentity();this.transformB.setIdentity();this.useRadii=false};return DistanceInput2}();var DistanceOutput=function(){function DistanceOutput2(){this.pointA=vec2(0,0);this.pointB=vec2(0,0);this.distance=0;this.iterations=0}DistanceOutput2.prototype.recycle=function(){zeroVec2(this.pointA);zeroVec2(this.pointB);this.distance=0;this.iterations=0};return DistanceOutput2}();var SimplexCache=function(){function SimplexCache2(){this.metric=0;this.indexA=[];this.indexB=[];this.count=0}SimplexCache2.prototype.recycle=function(){this.metric=0;this.indexA.length=0;this.indexB.length=0;this.count=0};return SimplexCache2}();var Distance=function(output2,cache2,input2){++stats.gjkCalls;var proxyA=input2.proxyA;var proxyB=input2.proxyB;var xfA2=input2.transformA;var xfB2=input2.transformB;simplex.recycle();simplex.readCache(cache2,proxyA,xfA2,proxyB,xfB2);var vertices=simplex.m_v;var k_maxIters=SettingsInternal.maxDistanceIterations;var saveA=[];var saveB=[];var saveCount=0;var iter=0;while(iterrA2+rB2&&output2.distance>EPSILON){output2.distance-=rA2+rB2;subVec2(normal$4,output2.pointB,output2.pointA);normalizeVec2(normal$4);plusScaleVec2(output2.pointA,rA2,normal$4);minusScaleVec2(output2.pointB,rB2,normal$4)}else{var p=subVec2(temp$5,output2.pointA,output2.pointB);copyVec2(output2.pointA,p);copyVec2(output2.pointB,p);output2.distance=0}}};var DistanceProxy=function(){function DistanceProxy2(){this.m_vertices=[];this.m_count=0;this.m_radius=0}DistanceProxy2.prototype.recycle=function(){this.m_vertices.length=0;this.m_count=0;this.m_radius=0};DistanceProxy2.prototype.getVertexCount=function(){return this.m_count};DistanceProxy2.prototype.getVertex=function(index){return this.m_vertices[index]};DistanceProxy2.prototype.getSupport=function(d2){var bestIndex=-1;var bestValue=-Infinity;for(var i=0;ibestValue){bestIndex=i;bestValue=value}}return bestIndex};DistanceProxy2.prototype.getSupportVertex=function(d2){return this.m_vertices[this.getSupport(d2)]};DistanceProxy2.prototype.set=function(shape,index){shape.computeDistanceProxy(this,index)};DistanceProxy2.prototype.setVertices=function(vertices,count,radius){this.m_vertices=vertices;this.m_count=count;this.m_radius=radius};return DistanceProxy2}();var SimplexVertex=function(){function SimplexVertex2(){this.wA=vec2(0,0);this.indexA=0;this.wB=vec2(0,0);this.indexB=0;this.w=vec2(0,0);this.a=0}SimplexVertex2.prototype.recycle=function(){this.indexA=0;this.indexB=0;zeroVec2(this.wA);zeroVec2(this.wB);zeroVec2(this.w);this.a=0};SimplexVertex2.prototype.set=function(v3){this.indexA=v3.indexA;this.indexB=v3.indexB;copyVec2(this.wA,v3.wA);copyVec2(this.wB,v3.wB);copyVec2(this.w,v3.w);this.a=v3.a};return SimplexVertex2}();var searchDirection_reuse=vec2(0,0);var closestPoint_reuse=vec2(0,0);var Simplex=function(){function Simplex2(){this.m_v1=new SimplexVertex;this.m_v2=new SimplexVertex;this.m_v3=new SimplexVertex;this.m_v=[this.m_v1,this.m_v2,this.m_v3]}Simplex2.prototype.recycle=function(){this.m_v1.recycle();this.m_v2.recycle();this.m_v3.recycle();this.m_count=0};Simplex2.prototype.toString=function(){if(this.m_count===3){return["+"+this.m_count,this.m_v1.a,this.m_v1.wA.x,this.m_v1.wA.y,this.m_v1.wB.x,this.m_v1.wB.y,this.m_v2.a,this.m_v2.wA.x,this.m_v2.wA.y,this.m_v2.wB.x,this.m_v2.wB.y,this.m_v3.a,this.m_v3.wA.x,this.m_v3.wA.y,this.m_v3.wB.x,this.m_v3.wB.y].toString()}else if(this.m_count===2){return["+"+this.m_count,this.m_v1.a,this.m_v1.wA.x,this.m_v1.wA.y,this.m_v1.wB.x,this.m_v1.wB.y,this.m_v2.a,this.m_v2.wA.x,this.m_v2.wA.y,this.m_v2.wB.x,this.m_v2.wB.y].toString()}else if(this.m_count===1){return["+"+this.m_count,this.m_v1.a,this.m_v1.wA.x,this.m_v1.wA.y,this.m_v1.wB.x,this.m_v1.wB.y].toString()}else{return"+"+this.m_count}};Simplex2.prototype.readCache=function(cache2,proxyA,transformA,proxyB,transformB){this.m_count=cache2.count;for(var i=0;i1){var metric1=cache2.metric;var metric2=this.getMetric();if(metric2<.5*metric1||2*metric10){return setVec2(searchDirection_reuse,-e12.y,e12.x)}else{return setVec2(searchDirection_reuse,e12.y,-e12.x)}}default:return zeroVec2(searchDirection_reuse)}};Simplex2.prototype.getClosestPoint=function(){var v13=this.m_v1;var v22=this.m_v2;this.m_v3;switch(this.m_count){case 0:return zeroVec2(closestPoint_reuse);case 1:return copyVec2(closestPoint_reuse,v13.w);case 2:return combine2Vec2(closestPoint_reuse,v13.a,v13.w,v22.a,v22.w);case 3:return zeroVec2(closestPoint_reuse);default:return zeroVec2(closestPoint_reuse)}};Simplex2.prototype.getWitnessPoints=function(pA2,pB2){var v13=this.m_v1;var v22=this.m_v2;var v3=this.m_v3;switch(this.m_count){case 0:break;case 1:copyVec2(pA2,v13.wA);copyVec2(pB2,v13.wB);break;case 2:combine2Vec2(pA2,v13.a,v13.wA,v22.a,v22.wA);combine2Vec2(pB2,v13.a,v13.wB,v22.a,v22.wB);break;case 3:combine3Vec2(pA2,v13.a,v13.wA,v22.a,v22.wA,v3.a,v3.wA);copyVec2(pB2,pA2);break}};Simplex2.prototype.getMetric=function(){switch(this.m_count){case 0:return 0;case 1:return 0;case 2:return distVec2(this.m_v1.w,this.m_v2.w);case 3:return crossVec2Vec2(subVec2(temp1,this.m_v2.w,this.m_v1.w),subVec2(temp2,this.m_v3.w,this.m_v1.w));default:return 0}};Simplex2.prototype.solve=function(){switch(this.m_count){case 1:break;case 2:this.solve2();break;case 3:this.solve3();break}};Simplex2.prototype.solve2=function(){var w1=this.m_v1.w;var w2=this.m_v2.w;subVec2(e12,w2,w1);var d12_2=-dotVec2(w1,e12);if(d12_2<=0){this.m_v1.a=1;this.m_count=1;return}var d12_1=dotVec2(w2,e12);if(d12_1<=0){this.m_v2.a=1;this.m_count=1;this.m_v1.set(this.m_v2);return}var inv_d12=1/(d12_1+d12_2);this.m_v1.a=d12_1*inv_d12;this.m_v2.a=d12_2*inv_d12;this.m_count=2};Simplex2.prototype.solve3=function(){var w1=this.m_v1.w;var w2=this.m_v2.w;var w3=this.m_v3.w;subVec2(e12,w2,w1);var w1e12=dotVec2(w1,e12);var w2e12=dotVec2(w2,e12);var d12_1=w2e12;var d12_2=-w1e12;subVec2(e13,w3,w1);var w1e13=dotVec2(w1,e13);var w3e13=dotVec2(w3,e13);var d13_1=w3e13;var d13_2=-w1e13;subVec2(e23,w3,w2);var w2e23=dotVec2(w2,e23);var w3e23=dotVec2(w3,e23);var d23_1=w3e23;var d23_2=-w2e23;var n123=crossVec2Vec2(e12,e13);var d123_1=n123*crossVec2Vec2(w2,w3);var d123_2=n123*crossVec2Vec2(w3,w1);var d123_3=n123*crossVec2Vec2(w1,w2);if(d12_2<=0&&d13_2<=0){this.m_v1.a=1;this.m_count=1;return}if(d12_1>0&&d12_2>0&&d123_3<=0){var inv_d12=1/(d12_1+d12_2);this.m_v1.a=d12_1*inv_d12;this.m_v2.a=d12_2*inv_d12;this.m_count=2;return}if(d13_1>0&&d13_2>0&&d123_2<=0){var inv_d13=1/(d13_1+d13_2);this.m_v1.a=d13_1*inv_d13;this.m_v3.a=d13_2*inv_d13;this.m_count=2;this.m_v2.set(this.m_v3);return}if(d12_1<=0&&d23_2<=0){this.m_v2.a=1;this.m_count=1;this.m_v1.set(this.m_v2);return}if(d13_1<=0&&d23_1<=0){this.m_v3.a=1;this.m_count=1;this.m_v1.set(this.m_v3);return}if(d23_1>0&&d23_2>0&&d123_1<=0){var inv_d23=1/(d23_1+d23_2);this.m_v2.a=d23_1*inv_d23;this.m_v3.a=d23_2*inv_d23;this.m_count=2;this.m_v1.set(this.m_v3);return}var inv_d123=1/(d123_1+d123_2+d123_3);this.m_v1.a=d123_1*inv_d123;this.m_v2.a=d123_2*inv_d123;this.m_v3.a=d123_3*inv_d123;this.m_count=3};return Simplex2}();var simplex=new Simplex;var input$1=new DistanceInput;var cache$1=new SimplexCache;var output$1=new DistanceOutput;var testOverlap=function(shapeA,indexA,shapeB,indexB,xfA2,xfB2){input$1.recycle();input$1.proxyA.set(shapeA,indexA);input$1.proxyB.set(shapeB,indexB);copyTransform(input$1.transformA,xfA2);copyTransform(input$1.transformB,xfB2);input$1.useRadii=true;output$1.recycle();cache$1.recycle();Distance(output$1,cache$1,input$1);return output$1.distance<10*EPSILON};Distance.testOverlap=testOverlap;Distance.Input=DistanceInput;Distance.Output=DistanceOutput;Distance.Proxy=DistanceProxy;Distance.Cache=SimplexCache;var ShapeCastInput=function(){function ShapeCastInput2(){this.proxyA=new DistanceProxy;this.proxyB=new DistanceProxy;this.transformA=Transform.identity();this.transformB=Transform.identity();this.translationB=Vec2.zero()}ShapeCastInput2.prototype.recycle=function(){this.proxyA.recycle();this.proxyB.recycle();this.transformA.setIdentity();this.transformB.setIdentity();zeroVec2(this.translationB)};return ShapeCastInput2}();var ShapeCastOutput=function(){function ShapeCastOutput2(){this.point=Vec2.zero();this.normal=Vec2.zero();this.lambda=1;this.iterations=0}return ShapeCastOutput2}();var ShapeCast=function(output2,input2){output2.iterations=0;output2.lambda=1;output2.normal.setZero();output2.point.setZero();var proxyA=input2.proxyA;var proxyB=input2.proxyB;var radiusA=math_max$4(proxyA.m_radius,SettingsInternal.polygonRadius);var radiusB=math_max$4(proxyB.m_radius,SettingsInternal.polygonRadius);var radius=radiusA+radiusB;var xfA2=input2.transformA;var xfB2=input2.transformB;var r=input2.translationB;var n2=Vec2.zero();var lambda=0;var simplex2=new Simplex;simplex2.m_count=0;var vertices=simplex2.m_v;var indexA=proxyA.getSupport(Rot.mulTVec2(xfA2.q,Vec2.neg(r)));var wA=Transform.mulVec2(xfA2,proxyA.getVertex(indexA));var indexB=proxyB.getSupport(Rot.mulTVec2(xfB2.q,r));var wB=Transform.mulVec2(xfB2,proxyB.getVertex(indexB));var v3=Vec2.sub(wA,wB);var sigma=math_max$4(SettingsInternal.polygonRadius,radius-SettingsInternal.polygonRadius);var tolerance=.5*SettingsInternal.linearSlop;var k_maxIters=20;var iter=0;while(itertolerance){output2.iterations+=1;indexA=proxyA.getSupport(Rot.mulTVec2(xfA2.q,Vec2.neg(v3)));wA=Transform.mulVec2(xfA2,proxyA.getVertex(indexA));indexB=proxyB.getSupport(Rot.mulTVec2(xfB2.q,v3));wB=Transform.mulVec2(xfB2,proxyB.getVertex(indexB));var p=Vec2.sub(wA,wB);v3.normalize();var vp=Vec2.dot(v3,p);var vr=Vec2.dot(v3,r);if(vp-sigma>lambda*vr){if(vr<=0){return false}lambda=(vp-sigma)/vr;if(lambda>1){return false}n2.setMul(-1,v3);simplex2.m_count=0}var vertex=vertices[simplex2.m_count];vertex.indexA=indexB;vertex.wA=Vec2.combine(1,wB,lambda,r);vertex.indexB=indexA;vertex.wB=wA;vertex.w=Vec2.sub(vertex.wB,vertex.wA);vertex.a=1;simplex2.m_count+=1;switch(simplex2.m_count){case 1:break;case 2:simplex2.solve2();break;case 3:simplex2.solve3();break}if(simplex2.m_count==3){return false}v3.setVec2(simplex2.getClosestPoint());++iter}if(iter==0){return false}var pointA2=Vec2.zero();var pointB2=Vec2.zero();simplex2.getWitnessPoints(pointB2,pointA2);if(v3.lengthSquared()>0){n2.setMul(-1,v3);n2.normalize()}output2.point=Vec2.combine(1,pointA2,radiusA,n2);output2.normal=n2;output2.lambda=lambda;output2.iterations=iter;return true};var math_abs$7=Math.abs;var math_max$3=Math.max;var TOIInput=function(){function TOIInput2(){this.proxyA=new DistanceProxy;this.proxyB=new DistanceProxy;this.sweepA=new Sweep;this.sweepB=new Sweep}TOIInput2.prototype.recycle=function(){this.proxyA.recycle();this.proxyB.recycle();this.sweepA.recycle();this.sweepB.recycle();this.tMax=-1};return TOIInput2}();exports2.TOIOutputState=void 0;(function(TOIOutputState2){TOIOutputState2[TOIOutputState2["e_unset"]=-1]="e_unset";TOIOutputState2[TOIOutputState2["e_unknown"]=0]="e_unknown";TOIOutputState2[TOIOutputState2["e_failed"]=1]="e_failed";TOIOutputState2[TOIOutputState2["e_overlapped"]=2]="e_overlapped";TOIOutputState2[TOIOutputState2["e_touching"]=3]="e_touching";TOIOutputState2[TOIOutputState2["e_separated"]=4]="e_separated"})(exports2.TOIOutputState||(exports2.TOIOutputState={}));var TOIOutput=function(){function TOIOutput2(){this.state=exports2.TOIOutputState.e_unset;this.t=-1}TOIOutput2.prototype.recycle=function(){this.state=exports2.TOIOutputState.e_unset;this.t=-1};return TOIOutput2}();stats.toiTime=0;stats.toiMaxTime=0;stats.toiCalls=0;stats.toiIters=0;stats.toiMaxIters=0;stats.toiRootIters=0;stats.toiMaxRootIters=0;var distanceInput=new DistanceInput;var distanceOutput=new DistanceOutput;var cache=new SimplexCache;var xfA$1=transform(0,0,0);var xfB$1=transform(0,0,0);var temp$4=vec2(0,0);var pointA$2=vec2(0,0);var pointB$2=vec2(0,0);var normal$3=vec2(0,0);var axisA=vec2(0,0);var axisB=vec2(0,0);var localPointA=vec2(0,0);var localPointB=vec2(0,0);var TimeOfImpact=function(output2,input2){var timer=Timer.now();++stats.toiCalls;output2.state=exports2.TOIOutputState.e_unknown;output2.t=input2.tMax;var proxyA=input2.proxyA;var proxyB=input2.proxyB;var sweepA=input2.sweepA;var sweepB=input2.sweepB;sweepA.normalize();sweepB.normalize();var tMax=input2.tMax;var totalRadius=proxyA.m_radius+proxyB.m_radius;var target=math_max$3(SettingsInternal.linearSlop,totalRadius-3*SettingsInternal.linearSlop);var tolerance=.25*SettingsInternal.linearSlop;var t1=0;var k_maxIterations=SettingsInternal.maxTOIIterations;var iter=0;cache.recycle();distanceInput.proxyA.setVertices(proxyA.m_vertices,proxyA.m_count,proxyA.m_radius);distanceInput.proxyB.setVertices(proxyB.m_vertices,proxyB.m_count,proxyB.m_radius);distanceInput.useRadii=false;while(true){sweepA.getTransform(xfA$1,t1);sweepB.getTransform(xfB$1,t1);copyTransform(distanceInput.transformA,xfA$1);copyTransform(distanceInput.transformB,xfB$1);Distance(distanceOutput,cache,distanceInput);if(distanceOutput.distance<=0){output2.state=exports2.TOIOutputState.e_overlapped;output2.t=0;break}if(distanceOutput.distancetarget+tolerance){output2.state=exports2.TOIOutputState.e_separated;output2.t=tMax;done=true;break}if(s2>target-tolerance){t1=t2;break}var s1=separationFunction.evaluate(t1);if(s1target){a1=t;s1=s3}else{a2=t;s2=s3}if(rootIterCount===50){break}}stats.toiMaxRootIters=math_max$3(stats.toiMaxRootIters,rootIterCount);++pushBackIter;if(pushBackIter===SettingsInternal.maxPolygonVertices){break}}++iter;++stats.toiIters;if(done){break}if(iter===k_maxIterations){output2.state=exports2.TOIOutputState.e_failed;output2.t=t1;break}}stats.toiMaxIters=math_max$3(stats.toiMaxIters,iter);var time=Timer.diff(timer);stats.toiMaxTime=math_max$3(stats.toiMaxTime,time);stats.toiTime+=time;separationFunction.recycle()};var SeparationFunctionType;(function(SeparationFunctionType2){SeparationFunctionType2[SeparationFunctionType2["e_unset"]=-1]="e_unset";SeparationFunctionType2[SeparationFunctionType2["e_points"]=1]="e_points";SeparationFunctionType2[SeparationFunctionType2["e_faceA"]=2]="e_faceA";SeparationFunctionType2[SeparationFunctionType2["e_faceB"]=3]="e_faceB"})(SeparationFunctionType||(SeparationFunctionType={}));var SeparationFunction=function(){function SeparationFunction2(){this.m_proxyA=null;this.m_proxyB=null;this.m_sweepA=null;this.m_sweepB=null;this.m_type=SeparationFunctionType.e_unset;this.m_localPoint=vec2(0,0);this.m_axis=vec2(0,0);this.indexA=-1;this.indexB=-1}SeparationFunction2.prototype.recycle=function(){this.m_proxyA=null;this.m_proxyB=null;this.m_sweepA=null;this.m_sweepB=null;this.m_type=SeparationFunctionType.e_unset;zeroVec2(this.m_localPoint);zeroVec2(this.m_axis);this.indexA=-1;this.indexB=-1};SeparationFunction2.prototype.initialize=function(cache2,proxyA,sweepA,proxyB,sweepB,t1){var count=cache2.count;this.m_proxyA=proxyA;this.m_proxyB=proxyB;this.m_sweepA=sweepA;this.m_sweepB=sweepB;this.m_sweepA.getTransform(xfA$1,t1);this.m_sweepB.getTransform(xfB$1,t1);if(count===1){this.m_type=SeparationFunctionType.e_points;var localPointA_1=this.m_proxyA.getVertex(cache2.indexA[0]);var localPointB_1=this.m_proxyB.getVertex(cache2.indexB[0]);transformVec2(pointA$2,xfA$1,localPointA_1);transformVec2(pointB$2,xfB$1,localPointB_1);subVec2(this.m_axis,pointB$2,pointA$2);var s2=normalizeVec2Length(this.m_axis);return s2}else if(cache2.indexA[0]===cache2.indexA[1]){this.m_type=SeparationFunctionType.e_faceB;var localPointB1=proxyB.getVertex(cache2.indexB[0]);var localPointB2=proxyB.getVertex(cache2.indexB[1]);crossVec2Num(this.m_axis,subVec2(temp$4,localPointB2,localPointB1),1);normalizeVec2(this.m_axis);rotVec2(normal$3,xfB$1.q,this.m_axis);combine2Vec2(this.m_localPoint,.5,localPointB1,.5,localPointB2);transformVec2(pointB$2,xfB$1,this.m_localPoint);var localPointA_2=proxyA.getVertex(cache2.indexA[0]);var pointA_1=Transform.mulVec2(xfA$1,localPointA_2);var s2=dotVec2(pointA_1,normal$3)-dotVec2(pointB$2,normal$3);if(s2<0){negVec2(this.m_axis);s2=-s2}return s2}else{this.m_type=SeparationFunctionType.e_faceA;var localPointA1=this.m_proxyA.getVertex(cache2.indexA[0]);var localPointA2=this.m_proxyA.getVertex(cache2.indexA[1]);crossVec2Num(this.m_axis,subVec2(temp$4,localPointA2,localPointA1),1);normalizeVec2(this.m_axis);rotVec2(normal$3,xfA$1.q,this.m_axis);combine2Vec2(this.m_localPoint,.5,localPointA1,.5,localPointA2);transformVec2(pointA$2,xfA$1,this.m_localPoint);var localPointB_2=this.m_proxyB.getVertex(cache2.indexB[0]);transformVec2(pointB$2,xfB$1,localPointB_2);var s2=dotVec2(pointB$2,normal$3)-dotVec2(pointA$2,normal$3);if(s2<0){negVec2(this.m_axis);s2=-s2}return s2}};SeparationFunction2.prototype.compute=function(find,t){this.m_sweepA.getTransform(xfA$1,t);this.m_sweepB.getTransform(xfB$1,t);switch(this.m_type){case SeparationFunctionType.e_points:{if(find){derotVec2(axisA,xfA$1.q,this.m_axis);derotVec2(axisB,xfB$1.q,scaleVec2(temp$4,-1,this.m_axis));this.indexA=this.m_proxyA.getSupport(axisA);this.indexB=this.m_proxyB.getSupport(axisB)}copyVec2(localPointA,this.m_proxyA.getVertex(this.indexA));copyVec2(localPointB,this.m_proxyB.getVertex(this.indexB));transformVec2(pointA$2,xfA$1,localPointA);transformVec2(pointB$2,xfB$1,localPointB);var sep=dotVec2(pointB$2,this.m_axis)-dotVec2(pointA$2,this.m_axis);return sep}case SeparationFunctionType.e_faceA:{rotVec2(normal$3,xfA$1.q,this.m_axis);transformVec2(pointA$2,xfA$1,this.m_localPoint);if(find){derotVec2(axisB,xfB$1.q,scaleVec2(temp$4,-1,normal$3));this.indexA=-1;this.indexB=this.m_proxyB.getSupport(axisB)}copyVec2(localPointB,this.m_proxyB.getVertex(this.indexB));transformVec2(pointB$2,xfB$1,localPointB);var sep=dotVec2(pointB$2,normal$3)-dotVec2(pointA$2,normal$3);return sep}case SeparationFunctionType.e_faceB:{rotVec2(normal$3,xfB$1.q,this.m_axis);transformVec2(pointB$2,xfB$1,this.m_localPoint);if(find){derotVec2(axisA,xfA$1.q,scaleVec2(temp$4,-1,normal$3));this.indexB=-1;this.indexA=this.m_proxyA.getSupport(axisA)}copyVec2(localPointA,this.m_proxyA.getVertex(this.indexA));transformVec2(pointA$2,xfA$1,localPointA);var sep=dotVec2(pointA$2,normal$3)-dotVec2(pointB$2,normal$3);return sep}default:if(find){this.indexA=-1;this.indexB=-1}return 0}};SeparationFunction2.prototype.findMinSeparation=function(t){return this.compute(true,t)};SeparationFunction2.prototype.evaluate=function(t){return this.compute(false,t)};return SeparationFunction2}();var separationFunction=new SeparationFunction;TimeOfImpact.Input=TOIInput;TimeOfImpact.Output=TOIOutput;var math_abs$6=Math.abs;var math_sqrt$3=Math.sqrt;var math_min$5=Math.min;var TimeStep=function(){function TimeStep2(){this.dt=0;this.inv_dt=0;this.velocityIterations=0;this.positionIterations=0;this.warmStarting=false;this.blockSolve=true;this.inv_dt0=0;this.dtRatio=1}TimeStep2.prototype.reset=function(dt){if(this.dt>0){this.inv_dt0=this.inv_dt}this.dt=dt;this.inv_dt=dt==0?0:1/dt;this.dtRatio=dt*this.inv_dt0};return TimeStep2}();var s_subStep=new TimeStep;var c=vec2(0,0);var v=vec2(0,0);var translation=vec2(0,0);var input=new TOIInput;var output=new TOIOutput;var backup=new Sweep;var backup1=new Sweep;var backup2=new Sweep;var ContactImpulse=function(){function ContactImpulse2(contact){this.contact=contact;this.normals=[];this.tangents=[]}ContactImpulse2.prototype.recycle=function(){this.normals.length=0;this.tangents.length=0};Object.defineProperty(ContactImpulse2.prototype,"normalImpulses",{get:function(){var contact=this.contact;var normals=this.normals;normals.length=0;for(var p=0;p0){var b2=stack.pop();this.addBody(b2);b2.m_awakeFlag=true;if(b2.isStatic()){continue}for(var ce=b2.m_contactList;ce;ce=ce.next){var contact=ce.contact;if(contact.m_islandFlag){continue}if(contact.isEnabled()==false||contact.isTouching()==false){continue}var sensorA=contact.m_fixtureA.m_isSensor;var sensorB=contact.m_fixtureB.m_isSensor;if(sensorA||sensorB){continue}this.addContact(contact);contact.m_islandFlag=true;var other=ce.other;if(other.m_islandFlag){continue}stack.push(other);other.m_islandFlag=true}for(var je=b2.m_jointList;je;je=je.next){if(je.joint.m_islandFlag==true){continue}var other=je.other;if(other.isActive()==false){continue}this.addJoint(je.joint);je.joint.m_islandFlag=true;if(other.m_islandFlag){continue}stack.push(other);other.m_islandFlag=true}}this.solveIsland(step);for(var i=0;iSettingsInternal.maxTranslationSquared){var ratio=SettingsInternal.maxTranslation/math_sqrt$3(translationLengthSqr);mulVec2(v,ratio)}var rotation2=h*w;if(rotation2*rotation2>SettingsInternal.maxRotationSquared){var ratio=SettingsInternal.maxRotation/math_abs$6(rotation2);w*=ratio}plusScaleVec2(c,h,v);a2+=h*w;copyVec2(body.c_position.c,c);body.c_position.a=a2;copyVec2(body.c_velocity.v,v);body.c_velocity.w=w}var positionSolved=false;for(var i=0;i=-3*SettingsInternal.linearSlop;var jointsOkay=true;for(var j=0;jangTolSqr||lengthSqrVec2(body.m_linearVelocity)>linTolSqr){body.m_sleepTime=0;minSleepTime=0}else{body.m_sleepTime+=h;minSleepTime=math_min$5(minSleepTime,body.m_sleepTime)}}if(minSleepTime>=SettingsInternal.timeToSleep&&positionSolved){for(var i=0;iSettingsInternal.maxSubSteps){continue}var alpha=1;if(c_3.m_toiFlag){alpha=c_3.m_toi}else{var fA_1=c_3.getFixtureA();var fB_1=c_3.getFixtureB();if(fA_1.isSensor()||fB_1.isSensor()){continue}var bA_1=fA_1.getBody();var bB_1=fB_1.getBody();var activeA=bA_1.isAwake()&&!bA_1.isStatic();var activeB=bB_1.isAwake()&&!bB_1.isStatic();if(activeA==false&&activeB==false){continue}var collideA=bA_1.isBullet()||!bA_1.isDynamic();var collideB=bB_1.isBullet()||!bB_1.isDynamic();if(collideA==false&&collideB==false){continue}var alpha0=bA_1.m_sweep.alpha0;if(bA_1.m_sweep.alpha0=-1.5*SettingsInternal.linearSlop;if(contactsOkay){break}}var i;copyVec2(toiA.m_sweep.c0,toiA.c_position.c);toiA.m_sweep.a0=toiA.c_position.a;copyVec2(toiB.m_sweep.c0,toiB.c_position.c);toiB.m_sweep.a0=toiB.c_position.a;for(var i=0;iSettingsInternal.maxTranslationSquared){var ratio=SettingsInternal.maxTranslation/math_sqrt$3(translationLengthSqr);mulVec2(v,ratio)}var rotation2=h*w;if(rotation2*rotation2>SettingsInternal.maxRotationSquared){var ratio=SettingsInternal.maxRotation/math_abs$6(rotation2);w*=ratio}plusScaleVec2(c,h,v);a2+=h*w;copyVec2(body.c_position.c,c);body.c_position.a=a2;copyVec2(body.c_velocity.v,v);body.c_velocity.w=w;copyVec2(body.m_sweep.c,c);body.m_sweep.a=a2;copyVec2(body.m_linearVelocity,v);body.m_angularVelocity=w;body.synchronizeTransform()}this.postSolveIsland()};Solver2.prototype.postSolveIsland=function(){for(var c_5=0;c_5EPSILON*EPSILON){var length_1=math_sqrt$2(lengthSqr);scaleVec2(normal3,1/length_1,dist)}combine2Vec2(cA$1,1,pointA$1,radiusA,normal3);combine2Vec2(cB$1,1,pointB$1,-radiusB,normal3);combine2Vec2(points[0],.5,cA$1,.5,cB$1);separations[0]=dotVec2(subVec2(temp$3,cB$1,cA$1),normal3);break}case exports2.ManifoldType.e_faceA:{rotVec2(normal3,xfA2.q,this.localNormal);transformVec2(planePoint$2,xfA2,this.localPoint);for(var i=0;irestitution2?restitution1:restitution2}var s_registers=[];var VelocityConstraintPoint=function(){function VelocityConstraintPoint2(){this.rA=vec2(0,0);this.rB=vec2(0,0);this.normalImpulse=0;this.tangentImpulse=0;this.normalMass=0;this.tangentMass=0;this.velocityBias=0}VelocityConstraintPoint2.prototype.recycle=function(){zeroVec2(this.rA);zeroVec2(this.rB);this.normalImpulse=0;this.tangentImpulse=0;this.normalMass=0;this.tangentMass=0;this.velocityBias=0};return VelocityConstraintPoint2}();var cA=vec2(0,0);var vA=vec2(0,0);var cB=vec2(0,0);var vB=vec2(0,0);var tangent$1=vec2(0,0);var xfA=transform(0,0,0);var xfB=transform(0,0,0);var pointA=vec2(0,0);var pointB=vec2(0,0);var clipPoint=vec2(0,0);var planePoint$1=vec2(0,0);var rA=vec2(0,0);var rB=vec2(0,0);var P$1=vec2(0,0);var normal$2=vec2(0,0);var point=vec2(0,0);var dv=vec2(0,0);var dv1=vec2(0,0);var dv2=vec2(0,0);var b=vec2(0,0);var a=vec2(0,0);var x=vec2(0,0);var d=vec2(0,0);var P1=vec2(0,0);var P2=vec2(0,0);var temp$2=vec2(0,0);var Contact=function(){function Contact2(){this.m_nodeA=new ContactEdge(this);this.m_nodeB=new ContactEdge(this);this.m_fixtureA=null;this.m_fixtureB=null;this.m_indexA=-1;this.m_indexB=-1;this.m_evaluateFcn=null;this.m_manifold=new Manifold;this.m_prev=null;this.m_next=null;this.m_toi=1;this.m_toiCount=0;this.m_toiFlag=false;this.m_friction=0;this.m_restitution=0;this.m_tangentSpeed=0;this.m_enabledFlag=true;this.m_islandFlag=false;this.m_touchingFlag=false;this.m_filterFlag=false;this.m_bulletHitFlag=false;this.m_impulse=new ContactImpulse(this);this.v_points=[new VelocityConstraintPoint,new VelocityConstraintPoint];this.v_normal=vec2(0,0);this.v_normalMass=new Mat22;this.v_K=new Mat22;this.v_pointCount=0;this.v_tangentSpeed=0;this.v_friction=0;this.v_restitution=0;this.v_invMassA=0;this.v_invMassB=0;this.v_invIA=0;this.v_invIB=0;this.p_localPoints=[vec2(0,0),vec2(0,0)];this.p_localNormal=vec2(0,0);this.p_localPoint=vec2(0,0);this.p_localCenterA=vec2(0,0);this.p_localCenterB=vec2(0,0);this.p_type=exports2.ManifoldType.e_unset;this.p_radiusA=0;this.p_radiusB=0;this.p_pointCount=0;this.p_invMassA=0;this.p_invMassB=0;this.p_invIA=0;this.p_invIB=0}Contact2.prototype.initialize=function(fA,indexA,fB,indexB,evaluateFcn){this.m_fixtureA=fA;this.m_fixtureB=fB;this.m_indexA=indexA;this.m_indexB=indexB;this.m_evaluateFcn=evaluateFcn;this.m_friction=mixFriction(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction);this.m_restitution=mixRestitution(this.m_fixtureA.m_restitution,this.m_fixtureB.m_restitution)};Contact2.prototype.recycle=function(){this.m_nodeA.recycle();this.m_nodeB.recycle();this.m_fixtureA=null;this.m_fixtureB=null;this.m_indexA=-1;this.m_indexB=-1;this.m_evaluateFcn=null;this.m_manifold.recycle();this.m_prev=null;this.m_next=null;this.m_toi=1;this.m_toiCount=0;this.m_toiFlag=false;this.m_friction=0;this.m_restitution=0;this.m_tangentSpeed=0;this.m_enabledFlag=true;this.m_islandFlag=false;this.m_touchingFlag=false;this.m_filterFlag=false;this.m_bulletHitFlag=false;this.m_impulse.recycle();for(var _i=0,_a2=this.v_points;_i<_a2.length;_i++){var point_1=_a2[_i];point_1.recycle()}zeroVec2(this.v_normal);this.v_normalMass.setZero();this.v_K.setZero();this.v_pointCount=0;this.v_tangentSpeed=0;this.v_friction=0;this.v_restitution=0;this.v_invMassA=0;this.v_invMassB=0;this.v_invIA=0;this.v_invIB=0;for(var _b=0,_c=this.p_localPoints;_b<_c.length;_b++){var point_2=_c[_b];zeroVec2(point_2)}zeroVec2(this.p_localNormal);zeroVec2(this.p_localPoint);zeroVec2(this.p_localCenterA);zeroVec2(this.p_localCenterB);this.p_type=exports2.ManifoldType.e_unset;this.p_radiusA=0;this.p_radiusB=0;this.p_pointCount=0;this.p_invMassA=0;this.p_invMassB=0;this.p_invIA=0;this.p_invIB=0};Contact2.prototype.initConstraint=function(step){var fixtureA=this.m_fixtureA;var fixtureB=this.m_fixtureB;if(fixtureA===null||fixtureB===null)return;var bodyA=fixtureA.m_body;var bodyB=fixtureB.m_body;if(bodyA===null||bodyB===null)return;var shapeA=fixtureA.m_shape;var shapeB=fixtureB.m_shape;if(shapeA===null||shapeB===null)return;var manifold=this.m_manifold;var pointCount=manifold.pointCount;this.v_invMassA=bodyA.m_invMass;this.v_invMassB=bodyB.m_invMass;this.v_invIA=bodyA.m_invI;this.v_invIB=bodyB.m_invI;this.v_friction=this.m_friction;this.v_restitution=this.m_restitution;this.v_tangentSpeed=this.m_tangentSpeed;this.v_pointCount=pointCount;this.v_K.setZero();this.v_normalMass.setZero();this.p_invMassA=bodyA.m_invMass;this.p_invMassB=bodyB.m_invMass;this.p_invIA=bodyA.m_invI;this.p_invIB=bodyB.m_invI;copyVec2(this.p_localCenterA,bodyA.m_sweep.localCenter);copyVec2(this.p_localCenterB,bodyB.m_sweep.localCenter);this.p_radiusA=shapeA.m_radius;this.p_radiusB=shapeB.m_radius;this.p_type=manifold.type;copyVec2(this.p_localNormal,manifold.localNormal);copyVec2(this.p_localPoint,manifold.localPoint);this.p_pointCount=pointCount;for(var j=0;j0;for(var i=0;i0?-C/K:0;scaleVec2(P$1,impulse,normal$2);minusScaleVec2(cA,mA,P$1);aA-=iA*crossVec2Vec2(rA,P$1);plusScaleVec2(cB,mB,P$1);aB+=iB*crossVec2Vec2(rB,P$1)}copyVec2(positionA.c,cA);positionA.a=aA;copyVec2(positionB.c,cB);positionB.a=aB;return minSeparation};Contact2.prototype.initVelocityConstraint=function(step){var fixtureA=this.m_fixtureA;var fixtureB=this.m_fixtureB;if(fixtureA===null||fixtureB===null)return;var bodyA=fixtureA.m_body;var bodyB=fixtureB.m_body;if(bodyA===null||bodyB===null)return;var velocityA=bodyA.c_velocity;var velocityB=bodyB.c_velocity;var positionA=bodyA.c_position;var positionB=bodyB.c_position;var radiusA=this.p_radiusA;var radiusB=this.p_radiusB;var manifold=this.m_manifold;var mA=this.v_invMassA;var mB=this.v_invMassB;var iA=this.v_invIA;var iB=this.v_invIB;var localCenterA=this.p_localCenterA;var localCenterB=this.p_localCenterB;copyVec2(cA,positionA.c);var aA=positionA.a;copyVec2(vA,velocityA.v);var wA=velocityA.w;copyVec2(cB,positionB.c);var aB=positionB.a;copyVec2(vB,velocityB.v);var wB=velocityB.w;getTransform(xfA,localCenterA,cA,aA);getTransform(xfB,localCenterB,cB,aB);worldManifold.recycle();manifold.getWorldManifold(worldManifold,xfA,radiusA,xfB,radiusB);copyVec2(this.v_normal,worldManifold.normal);for(var j=0;j0?1/kNormal:0;crossVec2Num(tangent$1,this.v_normal,1);var rtA=crossVec2Vec2(vcp.rA,tangent$1);var rtB=crossVec2Vec2(vcp.rB,tangent$1);var kTangent=mA+mB+iA*rtA*rtA+iB*rtB*rtB;vcp.tangentMass=kTangent>0?1/kTangent:0;vcp.velocityBias=0;var vRel=0;vRel+=dotVec2(this.v_normal,vB);vRel+=dotVec2(this.v_normal,crossNumVec2(temp$2,wB,vcp.rB));vRel-=dotVec2(this.v_normal,vA);vRel-=dotVec2(this.v_normal,crossNumVec2(temp$2,wA,vcp.rA));if(vRel<-SettingsInternal.velocityThreshold){vcp.velocityBias=-this.v_restitution*vRel}}if(this.v_pointCount==2&&step.blockSolve){var vcp1=this.v_points[0];var vcp2=this.v_points[1];var rn1A=crossVec2Vec2(vcp1.rA,this.v_normal);var rn1B=crossVec2Vec2(vcp1.rB,this.v_normal);var rn2A=crossVec2Vec2(vcp2.rA,this.v_normal);var rn2B=crossVec2Vec2(vcp2.rB,this.v_normal);var k11=mA+mB+iA*rn1A*rn1A+iB*rn1B*rn1B;var k22=mA+mB+iA*rn2A*rn2A+iB*rn2B*rn2B;var k12=mA+mB+iA*rn1A*rn2A+iB*rn1B*rn2B;var k_maxConditionNumber=1e3;if(k11*k11=0&&x.y>=0){subVec2(d,x,a);scaleVec2(P1,d.x,normal$2);scaleVec2(P2,d.y,normal$2);combine3Vec2(vA,-mA,P1,-mA,P2,1,vA);wA-=iA*(crossVec2Vec2(vcp1.rA,P1)+crossVec2Vec2(vcp2.rA,P2));combine3Vec2(vB,mB,P1,mB,P2,1,vB);wB+=iB*(crossVec2Vec2(vcp1.rB,P1)+crossVec2Vec2(vcp2.rB,P2));vcp1.normalImpulse=x.x;vcp2.normalImpulse=x.y;break}x.x=-vcp1.normalMass*b.x;x.y=0;vn1=0;vn2=this.v_K.ex.y*x.x+b.y;if(x.x>=0&&vn2>=0){subVec2(d,x,a);scaleVec2(P1,d.x,normal$2);scaleVec2(P2,d.y,normal$2);combine3Vec2(vA,-mA,P1,-mA,P2,1,vA);wA-=iA*(crossVec2Vec2(vcp1.rA,P1)+crossVec2Vec2(vcp2.rA,P2));combine3Vec2(vB,mB,P1,mB,P2,1,vB);wB+=iB*(crossVec2Vec2(vcp1.rB,P1)+crossVec2Vec2(vcp2.rB,P2));vcp1.normalImpulse=x.x;vcp2.normalImpulse=x.y;break}x.x=0;x.y=-vcp2.normalMass*b.y;vn1=this.v_K.ey.x*x.y+b.x;vn2=0;if(x.y>=0&&vn1>=0){subVec2(d,x,a);scaleVec2(P1,d.x,normal$2);scaleVec2(P2,d.y,normal$2);combine3Vec2(vA,-mA,P1,-mA,P2,1,vA);wA-=iA*(crossVec2Vec2(vcp1.rA,P1)+crossVec2Vec2(vcp2.rA,P2));combine3Vec2(vB,mB,P1,mB,P2,1,vB);wB+=iB*(crossVec2Vec2(vcp1.rB,P1)+crossVec2Vec2(vcp2.rB,P2));vcp1.normalImpulse=x.x;vcp2.normalImpulse=x.y;break}x.x=0;x.y=0;vn1=b.x;vn2=b.y;if(vn1>=0&&vn2>=0){subVec2(d,x,a);scaleVec2(P1,d.x,normal$2);scaleVec2(P2,d.y,normal$2);combine3Vec2(vA,-mA,P1,-mA,P2,1,vA);wA-=iA*(crossVec2Vec2(vcp1.rA,P1)+crossVec2Vec2(vcp2.rA,P2));combine3Vec2(vB,mB,P1,mB,P2,1,vB);wB+=iB*(crossVec2Vec2(vcp1.rB,P1)+crossVec2Vec2(vcp2.rB,P2));vcp1.normalImpulse=x.x;vcp2.normalImpulse=x.y;break}break}}copyVec2(velocityA.v,vA);velocityA.w=wA;copyVec2(velocityB.v,vB);velocityB.w=wB};Contact2.addType=function(type1,type2,callback){s_registers[type1]=s_registers[type1]||{};s_registers[type1][type2]=callback};Contact2.create=function(fixtureA,indexA,fixtureB,indexB){var typeA=fixtureA.m_shape.m_type;var typeB=fixtureB.m_shape.m_type;var contact=contactPool.allocate();var evaluateFcn;if(evaluateFcn=s_registers[typeA]&&s_registers[typeA][typeB]){contact.initialize(fixtureA,indexA,fixtureB,indexB,evaluateFcn)}else if(evaluateFcn=s_registers[typeB]&&s_registers[typeB][typeA]){contact.initialize(fixtureB,indexB,fixtureA,indexA,evaluateFcn)}else{return null}fixtureA=contact.m_fixtureA;fixtureB=contact.m_fixtureB;indexA=contact.getChildIndexA();indexB=contact.getChildIndexB();var bodyA=fixtureA.m_body;var bodyB=fixtureB.m_body;contact.m_nodeA.contact=contact;contact.m_nodeA.other=bodyB;contact.m_nodeA.prev=null;contact.m_nodeA.next=bodyA.m_contactList;if(bodyA.m_contactList!=null){bodyA.m_contactList.prev=contact.m_nodeA}bodyA.m_contactList=contact.m_nodeA;contact.m_nodeB.contact=contact;contact.m_nodeB.other=bodyA;contact.m_nodeB.prev=null;contact.m_nodeB.next=bodyB.m_contactList;if(bodyB.m_contactList!=null){bodyB.m_contactList.prev=contact.m_nodeB}bodyB.m_contactList=contact.m_nodeB;if(fixtureA.isSensor()==false&&fixtureB.isSensor()==false){bodyA.setAwake(true);bodyB.setAwake(true)}return contact};Contact2.destroy=function(contact,listener){var fixtureA=contact.m_fixtureA;var fixtureB=contact.m_fixtureB;if(fixtureA===null||fixtureB===null)return;var bodyA=fixtureA.m_body;var bodyB=fixtureB.m_body;if(bodyA===null||bodyB===null)return;if(contact.isTouching()){listener.endContact(contact)}if(contact.m_nodeA.prev){contact.m_nodeA.prev.next=contact.m_nodeA.next}if(contact.m_nodeA.next){contact.m_nodeA.next.prev=contact.m_nodeA.prev}if(contact.m_nodeA==bodyA.m_contactList){bodyA.m_contactList=contact.m_nodeA.next}if(contact.m_nodeB.prev){contact.m_nodeB.prev.next=contact.m_nodeB.next}if(contact.m_nodeB.next){contact.m_nodeB.next.prev=contact.m_nodeB.prev}if(contact.m_nodeB==bodyB.m_contactList){bodyB.m_contactList=contact.m_nodeB.next}if(contact.m_manifold.pointCount>0&&!fixtureA.m_isSensor&&!fixtureB.m_isSensor){bodyA.setAwake(true);bodyB.setAwake(true)}contactPool.release(contact)};return Contact2}();var DEFAULTS$b={gravity:Vec2.zero(),allowSleep:true,warmStarting:true,continuousPhysics:true,subStepping:false,blockSolve:true,velocityIterations:8,positionIterations:3};var World=function(){function World2(def){if(!(this instanceof World2)){return new World2(def)}this.s_step=new TimeStep;if(!def){def={}}else if(Vec2.isValid(def)){def={gravity:def}}def=options(def,DEFAULTS$b);this.m_solver=new Solver(this);this.m_broadPhase=new BroadPhase;this.m_contactList=null;this.m_contactCount=0;this.m_bodyList=null;this.m_bodyCount=0;this.m_jointList=null;this.m_jointCount=0;this.m_stepComplete=true;this.m_allowSleep=def.allowSleep;this.m_gravity=Vec2.clone(def.gravity);this.m_clearForces=true;this.m_newFixture=false;this.m_locked=false;this.m_warmStarting=def.warmStarting;this.m_continuousPhysics=def.continuousPhysics;this.m_subStepping=def.subStepping;this.m_blockSolve=def.blockSolve;this.m_velocityIterations=def.velocityIterations;this.m_positionIterations=def.positionIterations;this.m_t=0;this.m_step_callback=[]}World2.prototype._serialize=function(){var bodies=[];var joints=[];for(var b2=this.getBodyList();b2;b2=b2.getNext()){bodies.push(b2)}for(var j=this.getJointList();j;j=j.getNext()){if(typeof j._serialize==="function"){joints.push(j)}}return{gravity:this.m_gravity,bodies:bodies,joints:joints}};World2._deserialize=function(data,context,restore){if(!data){return new World2}var world=new World2(data.gravity);if(data.bodies){for(var i=data.bodies.length-1;i>=0;i-=1){world._addBody(restore(Body,data.bodies[i],world))}}if(data.joints){for(var i=data.joints.length-1;i>=0;i--){world.createJoint(restore(Joint,data.joints[i],world))}}return world};World2.prototype.getBodyList=function(){return this.m_bodyList};World2.prototype.getJointList=function(){return this.m_jointList};World2.prototype.getContactList=function(){return this.m_contactList};World2.prototype.getBodyCount=function(){return this.m_bodyCount};World2.prototype.getJointCount=function(){return this.m_jointCount};World2.prototype.getContactCount=function(){return this.m_contactCount};World2.prototype.setGravity=function(gravity){this.m_gravity.set(gravity)};World2.prototype.getGravity=function(){return this.m_gravity};World2.prototype.isLocked=function(){return this.m_locked};World2.prototype.setAllowSleeping=function(flag){if(flag==this.m_allowSleep){return}this.m_allowSleep=flag;if(this.m_allowSleep==false){for(var b2=this.m_bodyList;b2;b2=b2.m_next){b2.setAwake(true)}}};World2.prototype.getAllowSleeping=function(){return this.m_allowSleep};World2.prototype.setWarmStarting=function(flag){this.m_warmStarting=flag};World2.prototype.getWarmStarting=function(){return this.m_warmStarting};World2.prototype.setContinuousPhysics=function(flag){this.m_continuousPhysics=flag};World2.prototype.getContinuousPhysics=function(){return this.m_continuousPhysics};World2.prototype.setSubStepping=function(flag){this.m_subStepping=flag};World2.prototype.getSubStepping=function(){return this.m_subStepping};World2.prototype.setAutoClearForces=function(flag){this.m_clearForces=flag};World2.prototype.getAutoClearForces=function(){return this.m_clearForces};World2.prototype.clearForces=function(){for(var body=this.m_bodyList;body;body=body.getNext()){body.m_force.setZero();body.m_torque=0}};World2.prototype.queryAABB=function(aabb,callback){var broadPhase=this.m_broadPhase;this.m_broadPhase.query(aabb,(function(proxyId){var proxy=broadPhase.getUserData(proxyId);return callback(proxy.fixture)}))};World2.prototype.rayCast=function(point1,point2,callback){var broadPhase=this.m_broadPhase;this.m_broadPhase.rayCast({maxFraction:1,p1:point1,p2:point2},(function(input2,proxyId){var proxy=broadPhase.getUserData(proxyId);var fixture=proxy.fixture;var index=proxy.childIndex;var output2={};var hit=fixture.rayCast(output2,input2,index);if(hit){var fraction=output2.fraction;var point3=Vec2.add(Vec2.mulNumVec2(1-fraction,input2.p1),Vec2.mulNumVec2(fraction,input2.p2));return callback(fixture,point3,output2.normal,fraction)}return input2.maxFraction}))};World2.prototype.getProxyCount=function(){return this.m_broadPhase.getProxyCount()};World2.prototype.getTreeHeight=function(){return this.m_broadPhase.getTreeHeight()};World2.prototype.getTreeBalance=function(){return this.m_broadPhase.getTreeBalance()};World2.prototype.getTreeQuality=function(){return this.m_broadPhase.getTreeQuality()};World2.prototype.shiftOrigin=function(newOrigin){if(this.isLocked()){return}for(var b2=this.m_bodyList;b2;b2=b2.m_next){b2.m_xf.p.sub(newOrigin);b2.m_sweep.c0.sub(newOrigin);b2.m_sweep.c.sub(newOrigin)}for(var j=this.m_jointList;j;j=j.m_next){j.shiftOrigin(newOrigin)}this.m_broadPhase.shiftOrigin(newOrigin)};World2.prototype._addBody=function(body){if(this.isLocked()){return}body.m_prev=null;body.m_next=this.m_bodyList;if(this.m_bodyList){this.m_bodyList.m_prev=body}this.m_bodyList=body;++this.m_bodyCount};World2.prototype.createBody=function(arg1,arg2){if(this.isLocked()){return null}var def={};if(!arg1);else if(Vec2.isValid(arg1)){def={position:arg1,angle:arg2}}else if(typeof arg1==="object"){def=arg1}var body=new Body(this,def);this._addBody(body);return body};World2.prototype.createDynamicBody=function(arg1,arg2){var def={};if(!arg1);else if(Vec2.isValid(arg1)){def={position:arg1,angle:arg2}}else if(typeof arg1==="object"){def=arg1}def.type="dynamic";return this.createBody(def)};World2.prototype.createKinematicBody=function(arg1,arg2){var def={};if(!arg1);else if(Vec2.isValid(arg1)){def={position:arg1,angle:arg2}}else if(typeof arg1==="object"){def=arg1}def.type="kinematic";return this.createBody(def)};World2.prototype.destroyBody=function(b2){if(this.isLocked()){return}if(b2.m_destroyed){return false}var je=b2.m_jointList;while(je){var je0=je;je=je.next;this.publish("remove-joint",je0.joint);this.destroyJoint(je0.joint);b2.m_jointList=je}b2.m_jointList=null;var ce=b2.m_contactList;while(ce){var ce0=ce;ce=ce.next;this.destroyContact(ce0.contact);b2.m_contactList=ce}b2.m_contactList=null;var f=b2.m_fixtureList;while(f){var f0=f;f=f.m_next;this.publish("remove-fixture",f0);f0.destroyProxies(this.m_broadPhase);b2.m_fixtureList=f}b2.m_fixtureList=null;if(b2.m_prev){b2.m_prev.m_next=b2.m_next}if(b2.m_next){b2.m_next.m_prev=b2.m_prev}if(b2==this.m_bodyList){this.m_bodyList=b2.m_next}b2.m_destroyed=true;--this.m_bodyCount;this.publish("remove-body",b2);return true};World2.prototype.createJoint=function(joint){if(this.isLocked()){return null}joint.m_prev=null;joint.m_next=this.m_jointList;if(this.m_jointList){this.m_jointList.m_prev=joint}this.m_jointList=joint;++this.m_jointCount;joint.m_edgeA.joint=joint;joint.m_edgeA.other=joint.m_bodyB;joint.m_edgeA.prev=null;joint.m_edgeA.next=joint.m_bodyA.m_jointList;if(joint.m_bodyA.m_jointList)joint.m_bodyA.m_jointList.prev=joint.m_edgeA;joint.m_bodyA.m_jointList=joint.m_edgeA;joint.m_edgeB.joint=joint;joint.m_edgeB.other=joint.m_bodyA;joint.m_edgeB.prev=null;joint.m_edgeB.next=joint.m_bodyB.m_jointList;if(joint.m_bodyB.m_jointList)joint.m_bodyB.m_jointList.prev=joint.m_edgeB;joint.m_bodyB.m_jointList=joint.m_edgeB;if(joint.m_collideConnected==false){for(var edge=joint.m_bodyB.getContactList();edge;edge=edge.next){if(edge.other==joint.m_bodyA){edge.contact.flagForFiltering()}}}return joint};World2.prototype.destroyJoint=function(joint){if(this.isLocked()){return}if(joint.m_prev){joint.m_prev.m_next=joint.m_next}if(joint.m_next){joint.m_next.m_prev=joint.m_prev}if(joint==this.m_jointList){this.m_jointList=joint.m_next}var bodyA=joint.m_bodyA;var bodyB=joint.m_bodyB;bodyA.setAwake(true);bodyB.setAwake(true);if(joint.m_edgeA.prev){joint.m_edgeA.prev.next=joint.m_edgeA.next}if(joint.m_edgeA.next){joint.m_edgeA.next.prev=joint.m_edgeA.prev}if(joint.m_edgeA==bodyA.m_jointList){bodyA.m_jointList=joint.m_edgeA.next}joint.m_edgeA.prev=null;joint.m_edgeA.next=null;if(joint.m_edgeB.prev){joint.m_edgeB.prev.next=joint.m_edgeB.next}if(joint.m_edgeB.next){joint.m_edgeB.next.prev=joint.m_edgeB.prev}if(joint.m_edgeB==bodyB.m_jointList){bodyB.m_jointList=joint.m_edgeB.next}joint.m_edgeB.prev=null;joint.m_edgeB.next=null;--this.m_jointCount;if(joint.m_collideConnected==false){var edge=bodyB.getContactList();while(edge){if(edge.other==bodyA){edge.contact.flagForFiltering()}edge=edge.next}}this.publish("remove-joint",joint)};World2.prototype.step=function(timeStep,velocityIterations,positionIterations){this.publish("pre-step",timeStep);if((velocityIterations|0)!==velocityIterations){velocityIterations=0}velocityIterations=velocityIterations||this.m_velocityIterations;positionIterations=positionIterations||this.m_positionIterations;if(this.m_newFixture){this.findNewContacts();this.m_newFixture=false}this.m_locked=true;this.s_step.reset(timeStep);this.s_step.velocityIterations=velocityIterations;this.s_step.positionIterations=positionIterations;this.s_step.warmStarting=this.m_warmStarting;this.s_step.blockSolve=this.m_blockSolve;this.updateContacts();if(this.m_stepComplete&&timeStep>0){this.m_solver.solveWorld(this.s_step);for(var b2=this.m_bodyList;b2;b2=b2.getNext()){if(b2.m_islandFlag==false){continue}if(b2.isStatic()){continue}b2.synchronizeFixtures()}this.findNewContacts()}if(this.m_continuousPhysics&&timeStep>0){this.m_solver.solveWorldTOI(this.s_step)}if(this.m_clearForces){this.clearForces()}this.m_locked=false;var callback;while(callback=this.m_step_callback.shift()){callback(this)}this.publish("post-step",timeStep)};World2.prototype.queueUpdate=function(callback){if(!this.isLocked()){callback(this)}else{this.m_step_callback.push(callback)}};World2.prototype.findNewContacts=function(){var _this=this;this.m_broadPhase.updatePairs((function(proxyA,proxyB){return _this.createContact(proxyA,proxyB)}))};World2.prototype.createContact=function(proxyA,proxyB){var fixtureA=proxyA.fixture;var fixtureB=proxyB.fixture;var indexA=proxyA.childIndex;var indexB=proxyB.childIndex;var bodyA=fixtureA.getBody();var bodyB=fixtureB.getBody();if(bodyA==bodyB){return}var edge=bodyB.getContactList();while(edge){if(edge.other==bodyA){var fA=edge.contact.getFixtureA();var fB=edge.contact.getFixtureB();var iA=edge.contact.getChildIndexA();var iB=edge.contact.getChildIndexB();if(fA==fixtureA&&fB==fixtureB&&iA==indexA&&iB==indexB){return}if(fA==fixtureB&&fB==fixtureA&&iA==indexB&&iB==indexA){return}}edge=edge.next}if(bodyB.shouldCollide(bodyA)==false){return}if(fixtureB.shouldCollide(fixtureA)==false){return}var contact=Contact.create(fixtureA,indexA,fixtureB,indexB);if(contact==null){return}contact.m_prev=null;if(this.m_contactList!=null){contact.m_next=this.m_contactList;this.m_contactList.m_prev=contact}this.m_contactList=contact;++this.m_contactCount};World2.prototype.updateContacts=function(){var c2;var next_c=this.m_contactList;while(c2=next_c){next_c=c2.getNext();var fixtureA=c2.getFixtureA();var fixtureB=c2.getFixtureB();var indexA=c2.getChildIndexA();var indexB=c2.getChildIndexB();var bodyA=fixtureA.getBody();var bodyB=fixtureB.getBody();if(c2.m_filterFlag){if(bodyB.shouldCollide(bodyA)==false){this.destroyContact(c2);continue}if(fixtureB.shouldCollide(fixtureA)==false){this.destroyContact(c2);continue}c2.m_filterFlag=false}var activeA=bodyA.isAwake()&&!bodyA.isStatic();var activeB=bodyB.isAwake()&&!bodyB.isStatic();if(activeA==false&&activeB==false){continue}var proxyIdA=fixtureA.m_proxies[indexA].proxyId;var proxyIdB=fixtureB.m_proxies[indexB].proxyId;var overlap=this.m_broadPhase.testOverlap(proxyIdA,proxyIdB);if(overlap==false){this.destroyContact(c2);continue}c2.update(this)}};World2.prototype.destroyContact=function(contact){if(contact.m_prev){contact.m_prev.m_next=contact.m_next}if(contact.m_next){contact.m_next.m_prev=contact.m_prev}if(contact==this.m_contactList){this.m_contactList=contact.m_next}Contact.destroy(contact,this);--this.m_contactCount};World2.prototype.on=function(name,listener){if(typeof name!=="string"||typeof listener!=="function"){return this}if(!this._listeners){this._listeners={}}if(!this._listeners[name]){this._listeners[name]=[]}this._listeners[name].push(listener);return this};World2.prototype.off=function(name,listener){if(typeof name!=="string"||typeof listener!=="function"){return this}var listeners=this._listeners&&this._listeners[name];if(!listeners||!listeners.length){return this}var index=listeners.indexOf(listener);if(index>=0){listeners.splice(index,1)}return this};World2.prototype.publish=function(name,arg1,arg2,arg3){var listeners=this._listeners&&this._listeners[name];if(!listeners||!listeners.length){return 0}for(var l=0;l0){output2.normal=Rot.mulVec2(xf2.q,normal3).neg()}else{output2.normal=Rot.mulVec2(xf2.q,normal3)}return true};EdgeShape2.prototype.computeAABB=function(aabb,xf2,childIndex){transformVec2(v1$2,xf2,this.m_vertex1);transformVec2(v2$1,xf2,this.m_vertex2);AABB.combinePoints(aabb,v1$2,v2$1);AABB.extend(aabb,this.m_radius)};EdgeShape2.prototype.computeMass=function(massData,density){massData.mass=0;combine2Vec2(massData.center,.5,this.m_vertex1,.5,this.m_vertex2);massData.I=0};EdgeShape2.prototype.computeDistanceProxy=function(proxy){proxy.m_vertices[0]=this.m_vertex1;proxy.m_vertices[1]=this.m_vertex2;proxy.m_vertices.length=2;proxy.m_count=2;proxy.m_radius=this.m_radius};EdgeShape2.TYPE="edge";return EdgeShape2}(Shape);var Edge=EdgeShape;var v1$1=vec2(0,0);var v2=vec2(0,0);var ChainShape=function(_super){__extends(ChainShape2,_super);function ChainShape2(vertices,loop){var _this=this;if(!(_this instanceof ChainShape2)){return new ChainShape2(vertices,loop)}_this=_super.call(this)||this;_this.m_type=ChainShape2.TYPE;_this.m_radius=SettingsInternal.polygonRadius;_this.m_vertices=[];_this.m_count=0;_this.m_prevVertex=null;_this.m_nextVertex=null;_this.m_hasPrevVertex=false;_this.m_hasNextVertex=false;_this.m_isLoop=!!loop;if(vertices&&vertices.length){if(loop){_this._createLoop(vertices)}else{_this._createChain(vertices)}}return _this}ChainShape2.prototype._serialize=function(){var data={type:this.m_type,vertices:this.m_isLoop?this.m_vertices.slice(0,this.m_vertices.length-1):this.m_vertices,isLoop:this.m_isLoop,hasPrevVertex:this.m_hasPrevVertex,hasNextVertex:this.m_hasNextVertex,prevVertex:null,nextVertex:null};if(this.m_prevVertex){data.prevVertex=this.m_prevVertex}if(this.m_nextVertex){data.nextVertex=this.m_nextVertex}return data};ChainShape2._deserialize=function(data,fixture,restore){var vertices=[];if(data.vertices){for(var i=0;i0){edge.m_vertex0=this.m_vertices[childIndex-1];edge.m_hasVertex0=true}else{edge.m_vertex0=this.m_prevVertex;edge.m_hasVertex0=this.m_hasPrevVertex}if(childIndexx0||x2===x0&&ps[i].yr.lengthSquared()){ie2=j}}++m;ih=ie2;if(ie2===i0){break}}if(m<3){this._setAsBox(1,1);return}this.m_count=m;this.m_vertices=[];for(var i=0;i0){return false}}return true};PolygonShape2.prototype.rayCast=function(output2,input2,xf2,childIndex){var p1=Rot.mulTVec2(xf2.q,Vec2.sub(input2.p1,xf2.p));var p2=Rot.mulTVec2(xf2.q,Vec2.sub(input2.p2,xf2.p));var d2=Vec2.sub(p2,p1);var lower=0;var upper=input2.maxFraction;var index=-1;for(var i=0;i0&&numerator=0){output2.fraction=lower;output2.normal=Rot.mulVec2(xf2.q,this.m_normals[index]);return true}return false};PolygonShape2.prototype.computeAABB=function(aabb,xf2,childIndex){var minX=Infinity;var minY=Infinity;var maxX=-Infinity;var maxY=-Infinity;for(var i=0;i0){this.m_length=+def.length}else if(def.length<0);else if(def.anchorA||def.anchorA||def.anchorA||def.anchorA){this.m_length=Vec2.distance(this.m_bodyA.getWorldPoint(this.m_localAnchorA),this.m_bodyB.getWorldPoint(this.m_localAnchorB))}if(Number.isFinite(def.frequencyHz)){this.m_frequencyHz=def.frequencyHz}if(Number.isFinite(def.dampingRatio)){this.m_dampingRatio=def.dampingRatio}};DistanceJoint2.prototype.getLocalAnchorA=function(){return this.m_localAnchorA};DistanceJoint2.prototype.getLocalAnchorB=function(){return this.m_localAnchorB};DistanceJoint2.prototype.setLength=function(length){this.m_length=length};DistanceJoint2.prototype.getLength=function(){return this.m_length};DistanceJoint2.prototype.setFrequency=function(hz){this.m_frequencyHz=hz};DistanceJoint2.prototype.getFrequency=function(){return this.m_frequencyHz};DistanceJoint2.prototype.setDampingRatio=function(ratio){this.m_dampingRatio=ratio};DistanceJoint2.prototype.getDampingRatio=function(){return this.m_dampingRatio};DistanceJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};DistanceJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};DistanceJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.mulNumVec2(this.m_impulse,this.m_u).mul(inv_dt)};DistanceJoint2.prototype.getReactionTorque=function(inv_dt){return 0};DistanceJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter;this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);this.m_rA=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));this.m_rB=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));this.m_u=Vec2.sub(Vec2.add(cB2,this.m_rB),Vec2.add(cA2,this.m_rA));var length=this.m_u.length();if(length>SettingsInternal.linearSlop){this.m_u.mul(1/length)}else{this.m_u.setNum(0,0)}var crAu=Vec2.crossVec2Vec2(this.m_rA,this.m_u);var crBu=Vec2.crossVec2Vec2(this.m_rB,this.m_u);var invMass=this.m_invMassA+this.m_invIA*crAu*crAu+this.m_invMassB+this.m_invIB*crBu*crBu;this.m_mass=invMass!=0?1/invMass:0;if(this.m_frequencyHz>0){var C=length-this.m_length;var omega=2*math_PI$3*this.m_frequencyHz;var d2=2*this.m_mass*this.m_dampingRatio*omega;var k=this.m_mass*omega*omega;var h=step.dt;this.m_gamma=h*(d2+h*k);this.m_gamma=this.m_gamma!=0?1/this.m_gamma:0;this.m_bias=C*h*k*this.m_gamma;invMass+=this.m_gamma;this.m_mass=invMass!=0?1/invMass:0}else{this.m_gamma=0;this.m_bias=0}if(step.warmStarting){this.m_impulse*=step.dtRatio;var P3=Vec2.mulNumVec2(this.m_impulse,this.m_u);vA2.subMul(this.m_invMassA,P3);wA-=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,P3);vB2.addMul(this.m_invMassB,P3);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,P3)}else{this.m_impulse=0}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};DistanceJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var vpA=Vec2.add(vA2,Vec2.crossNumVec2(wA,this.m_rA));var vpB=Vec2.add(vB2,Vec2.crossNumVec2(wB,this.m_rB));var Cdot=Vec2.dot(this.m_u,vpB)-Vec2.dot(this.m_u,vpA);var impulse=-this.m_mass*(Cdot+this.m_bias+this.m_gamma*this.m_impulse);this.m_impulse+=impulse;var P3=Vec2.mulNumVec2(impulse,this.m_u);vA2.subMul(this.m_invMassA,P3);wA-=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,P3);vB2.addMul(this.m_invMassB,P3);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,P3);this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};DistanceJoint2.prototype.solvePositionConstraints=function(step){if(this.m_frequencyHz>0){return true}var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulSub(qA,this.m_localAnchorA,this.m_localCenterA);var rB2=Rot.mulSub(qB,this.m_localAnchorB,this.m_localCenterB);var u=Vec2.sub(Vec2.add(cB2,rB2),Vec2.add(cA2,rA2));var length=u.normalize();var C=clamp(length-this.m_length,-SettingsInternal.maxLinearCorrection,SettingsInternal.maxLinearCorrection);var impulse=-this.m_mass*C;var P3=Vec2.mulNumVec2(impulse,u);cA2.subMul(this.m_invMassA,P3);aA-=this.m_invIA*Vec2.crossVec2Vec2(rA2,P3);cB2.addMul(this.m_invMassB,P3);aB+=this.m_invIB*Vec2.crossVec2Vec2(rB2,P3);this.m_bodyA.c_position.c.setVec2(cA2);this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c.setVec2(cB2);this.m_bodyB.c_position.a=aB;return math_abs$5(C)0){this.m_angularMass=1/this.m_angularMass}if(step.warmStarting){this.m_linearImpulse.mul(step.dtRatio);this.m_angularImpulse*=step.dtRatio;var P3=Vec2.neo(this.m_linearImpulse.x,this.m_linearImpulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+this.m_angularImpulse);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+this.m_angularImpulse)}else{this.m_linearImpulse.setZero();this.m_angularImpulse=0}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};FrictionJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var h=step.dt;{var Cdot=wB-wA;var impulse=-this.m_angularMass*Cdot;var oldImpulse=this.m_angularImpulse;var maxImpulse=h*this.m_maxTorque;this.m_angularImpulse=clamp(this.m_angularImpulse+impulse,-maxImpulse,maxImpulse);impulse=this.m_angularImpulse-oldImpulse;wA-=iA*impulse;wB+=iB*impulse}{var Cdot=Vec2.sub(Vec2.add(vB2,Vec2.crossNumVec2(wB,this.m_rB)),Vec2.add(vA2,Vec2.crossNumVec2(wA,this.m_rA)));var impulse=Vec2.neg(Mat22.mulVec2(this.m_linearMass,Cdot));var oldImpulse=this.m_linearImpulse;this.m_linearImpulse.add(impulse);var maxImpulse=h*this.m_maxForce;if(this.m_linearImpulse.lengthSquared()>maxImpulse*maxImpulse){this.m_linearImpulse.normalize();this.m_linearImpulse.mul(maxImpulse)}impulse=Vec2.sub(this.m_linearImpulse,oldImpulse);vA2.subMul(mA,impulse);wA-=iA*Vec2.crossVec2Vec2(this.m_rA,impulse);vB2.addMul(mB,impulse);wB+=iB*Vec2.crossVec2Vec2(this.m_rB,impulse)}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};FrictionJoint2.prototype.solvePositionConstraints=function(step){return true};FrictionJoint2.TYPE="friction-joint";return FrictionJoint2}(Joint);var Mat33=function(){function Mat332(a2,b2,c2){if(typeof a2==="object"&&a2!==null){this.ex=Vec3.clone(a2);this.ey=Vec3.clone(b2);this.ez=Vec3.clone(c2)}else{this.ex=Vec3.zero();this.ey=Vec3.zero();this.ez=Vec3.zero()}}Mat332.prototype.toString=function(){return JSON.stringify(this)};Mat332.isValid=function(obj){if(obj===null||typeof obj==="undefined"){return false}return Vec3.isValid(obj.ex)&&Vec3.isValid(obj.ey)&&Vec3.isValid(obj.ez)};Mat332.assert=function(o){};Mat332.prototype.setZero=function(){this.ex.setZero();this.ey.setZero();this.ez.setZero();return this};Mat332.prototype.solve33=function(v3){var cross_x=this.ey.y*this.ez.z-this.ey.z*this.ez.y;var cross_y=this.ey.z*this.ez.x-this.ey.x*this.ez.z;var cross_z=this.ey.x*this.ez.y-this.ey.y*this.ez.x;var det=this.ex.x*cross_x+this.ex.y*cross_y+this.ex.z*cross_z;if(det!==0){det=1/det}var r=new Vec3;cross_x=this.ey.y*this.ez.z-this.ey.z*this.ez.y;cross_y=this.ey.z*this.ez.x-this.ey.x*this.ez.z;cross_z=this.ey.x*this.ez.y-this.ey.y*this.ez.x;r.x=det*(v3.x*cross_x+v3.y*cross_y+v3.z*cross_z);cross_x=v3.y*this.ez.z-v3.z*this.ez.y;cross_y=v3.z*this.ez.x-v3.x*this.ez.z;cross_z=v3.x*this.ez.y-v3.y*this.ez.x;r.y=det*(this.ex.x*cross_x+this.ex.y*cross_y+this.ex.z*cross_z);cross_x=this.ey.y*v3.z-this.ey.z*v3.y;cross_y=this.ey.z*v3.x-this.ey.x*v3.z;cross_z=this.ey.x*v3.y-this.ey.y*v3.x;r.z=det*(this.ex.x*cross_x+this.ex.y*cross_y+this.ex.z*cross_z);return r};Mat332.prototype.solve22=function(v3){var a11=this.ex.x;var a12=this.ey.x;var a21=this.ex.y;var a22=this.ey.y;var det=a11*a22-a12*a21;if(det!==0){det=1/det}var r=Vec2.zero();r.x=det*(a22*v3.x-a12*v3.y);r.y=det*(a11*v3.y-a21*v3.x);return r};Mat332.prototype.getInverse22=function(M){var a2=this.ex.x;var b2=this.ey.x;var c2=this.ex.y;var d2=this.ey.y;var det=a2*d2-b2*c2;if(det!==0){det=1/det}M.ex.x=det*d2;M.ey.x=-det*b2;M.ex.z=0;M.ex.y=-det*c2;M.ey.y=det*a2;M.ey.z=0;M.ez.x=0;M.ez.y=0;M.ez.z=0};Mat332.prototype.getSymInverse33=function(M){var det=Vec3.dot(this.ex,Vec3.cross(this.ey,this.ez));if(det!==0){det=1/det}var a11=this.ex.x;var a12=this.ey.x;var a13=this.ez.x;var a22=this.ey.y;var a23=this.ez.y;var a33=this.ez.z;M.ex.x=det*(a22*a33-a23*a23);M.ex.y=det*(a13*a23-a12*a33);M.ex.z=det*(a12*a23-a13*a22);M.ey.x=M.ex.y;M.ey.y=det*(a11*a33-a13*a13);M.ey.z=det*(a13*a12-a11*a23);M.ez.x=M.ex.z;M.ez.y=M.ey.z;M.ez.z=det*(a11*a22-a12*a12)};Mat332.mul=function(a2,b2){if(b2&&"z"in b2&&"y"in b2&&"x"in b2){var x2=a2.ex.x*b2.x+a2.ey.x*b2.y+a2.ez.x*b2.z;var y=a2.ex.y*b2.x+a2.ey.y*b2.y+a2.ez.y*b2.z;var z=a2.ex.z*b2.x+a2.ey.z*b2.y+a2.ez.z*b2.z;return new Vec3(x2,y,z)}else if(b2&&"y"in b2&&"x"in b2){var x2=a2.ex.x*b2.x+a2.ey.x*b2.y;var y=a2.ex.y*b2.x+a2.ey.y*b2.y;return Vec2.neo(x2,y)}};Mat332.mulVec3=function(a2,b2){var x2=a2.ex.x*b2.x+a2.ey.x*b2.y+a2.ez.x*b2.z;var y=a2.ex.y*b2.x+a2.ey.y*b2.y+a2.ez.y*b2.z;var z=a2.ex.z*b2.x+a2.ey.z*b2.y+a2.ez.z*b2.z;return new Vec3(x2,y,z)};Mat332.mulVec2=function(a2,b2){var x2=a2.ex.x*b2.x+a2.ey.x*b2.y;var y=a2.ex.y*b2.x+a2.ey.y*b2.y;return Vec2.neo(x2,y)};Mat332.add=function(a2,b2){return new Mat332(Vec3.add(a2.ex,b2.ex),Vec3.add(a2.ey,b2.ey),Vec3.add(a2.ez,b2.ez))};return Mat332}();var math_abs$4=Math.abs;var LimitState$2;(function(LimitState2){LimitState2[LimitState2["inactiveLimit"]=0]="inactiveLimit";LimitState2[LimitState2["atLowerLimit"]=1]="atLowerLimit";LimitState2[LimitState2["atUpperLimit"]=2]="atUpperLimit";LimitState2[LimitState2["equalLimits"]=3]="equalLimits"})(LimitState$2||(LimitState$2={}));var DEFAULTS$8={lowerAngle:0,upperAngle:0,maxMotorTorque:0,motorSpeed:0,enableLimit:false,enableMotor:false};var RevoluteJoint=function(_super){__extends(RevoluteJoint2,_super);function RevoluteJoint2(def,bodyA,bodyB,anchor){var _this=this;var _a2,_b,_c,_d,_e,_f;if(!(_this instanceof RevoluteJoint2)){return new RevoluteJoint2(def,bodyA,bodyB,anchor)}def=def!==null&&def!==void 0?def:{};_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_mass=new Mat33;_this.m_limitState=LimitState$2.inactiveLimit;_this.m_type=RevoluteJoint2.TYPE;if(Vec2.isValid(anchor)){_this.m_localAnchorA=bodyA.getLocalPoint(anchor)}else if(Vec2.isValid(def.localAnchorA)){_this.m_localAnchorA=Vec2.clone(def.localAnchorA)}else{_this.m_localAnchorA=Vec2.zero()}if(Vec2.isValid(anchor)){_this.m_localAnchorB=bodyB.getLocalPoint(anchor)}else if(Vec2.isValid(def.localAnchorB)){_this.m_localAnchorB=Vec2.clone(def.localAnchorB)}else{_this.m_localAnchorB=Vec2.zero()}if(Number.isFinite(def.referenceAngle)){_this.m_referenceAngle=def.referenceAngle}else{_this.m_referenceAngle=bodyB.getAngle()-bodyA.getAngle()}_this.m_impulse=new Vec3;_this.m_motorImpulse=0;_this.m_lowerAngle=(_a2=def.lowerAngle)!==null&&_a2!==void 0?_a2:DEFAULTS$8.lowerAngle;_this.m_upperAngle=(_b=def.upperAngle)!==null&&_b!==void 0?_b:DEFAULTS$8.upperAngle;_this.m_maxMotorTorque=(_c=def.maxMotorTorque)!==null&&_c!==void 0?_c:DEFAULTS$8.maxMotorTorque;_this.m_motorSpeed=(_d=def.motorSpeed)!==null&&_d!==void 0?_d:DEFAULTS$8.motorSpeed;_this.m_enableLimit=(_e=def.enableLimit)!==null&&_e!==void 0?_e:DEFAULTS$8.enableLimit;_this.m_enableMotor=(_f=def.enableMotor)!==null&&_f!==void 0?_f:DEFAULTS$8.enableMotor;return _this}RevoluteJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,lowerAngle:this.m_lowerAngle,upperAngle:this.m_upperAngle,maxMotorTorque:this.m_maxMotorTorque,motorSpeed:this.m_motorSpeed,enableLimit:this.m_enableLimit,enableMotor:this.m_enableMotor,localAnchorA:this.m_localAnchorA,localAnchorB:this.m_localAnchorB,referenceAngle:this.m_referenceAngle}};RevoluteJoint2._deserialize=function(data,world,restore){data=__assign({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);var joint=new RevoluteJoint2(data);return joint};RevoluteJoint2.prototype._reset=function(def){if(def.anchorA){this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA))}else if(def.localAnchorA){this.m_localAnchorA.setVec2(def.localAnchorA)}if(def.anchorB){this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB))}else if(def.localAnchorB){this.m_localAnchorB.setVec2(def.localAnchorB)}if(Number.isFinite(def.referenceAngle)){this.m_referenceAngle=def.referenceAngle}if(def.enableLimit!==void 0){this.m_enableLimit=def.enableLimit}if(Number.isFinite(def.lowerAngle)){this.m_lowerAngle=def.lowerAngle}if(Number.isFinite(def.upperAngle)){this.m_upperAngle=def.upperAngle}if(Number.isFinite(def.maxMotorTorque)){this.m_maxMotorTorque=def.maxMotorTorque}if(Number.isFinite(def.motorSpeed)){this.m_motorSpeed=def.motorSpeed}if(def.enableMotor!==void 0){this.m_enableMotor=def.enableMotor}};RevoluteJoint2.prototype.getLocalAnchorA=function(){return this.m_localAnchorA};RevoluteJoint2.prototype.getLocalAnchorB=function(){return this.m_localAnchorB};RevoluteJoint2.prototype.getReferenceAngle=function(){return this.m_referenceAngle};RevoluteJoint2.prototype.getJointAngle=function(){var bA=this.m_bodyA;var bB=this.m_bodyB;return bB.m_sweep.a-bA.m_sweep.a-this.m_referenceAngle};RevoluteJoint2.prototype.getJointSpeed=function(){var bA=this.m_bodyA;var bB=this.m_bodyB;return bB.m_angularVelocity-bA.m_angularVelocity};RevoluteJoint2.prototype.isMotorEnabled=function(){return this.m_enableMotor};RevoluteJoint2.prototype.enableMotor=function(flag){if(flag==this.m_enableMotor)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_enableMotor=flag};RevoluteJoint2.prototype.getMotorTorque=function(inv_dt){return inv_dt*this.m_motorImpulse};RevoluteJoint2.prototype.setMotorSpeed=function(speed){if(speed==this.m_motorSpeed)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_motorSpeed=speed};RevoluteJoint2.prototype.getMotorSpeed=function(){return this.m_motorSpeed};RevoluteJoint2.prototype.setMaxMotorTorque=function(torque){if(torque==this.m_maxMotorTorque)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_maxMotorTorque=torque};RevoluteJoint2.prototype.getMaxMotorTorque=function(){return this.m_maxMotorTorque};RevoluteJoint2.prototype.isLimitEnabled=function(){return this.m_enableLimit};RevoluteJoint2.prototype.enableLimit=function(flag){if(flag!=this.m_enableLimit){this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_enableLimit=flag;this.m_impulse.z=0}};RevoluteJoint2.prototype.getLowerLimit=function(){return this.m_lowerAngle};RevoluteJoint2.prototype.getUpperLimit=function(){return this.m_upperAngle};RevoluteJoint2.prototype.setLimits=function(lower,upper){if(lower!=this.m_lowerAngle||upper!=this.m_upperAngle){this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_impulse.z=0;this.m_lowerAngle=lower;this.m_upperAngle=upper}};RevoluteJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};RevoluteJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};RevoluteJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.neo(this.m_impulse.x,this.m_impulse.y).mul(inv_dt)};RevoluteJoint2.prototype.getReactionTorque=function(inv_dt){return inv_dt*this.m_impulse.z};RevoluteJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter;this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);this.m_rA=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));this.m_rB=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var fixedRotation=iA+iB===0;this.m_mass.ex.x=mA+mB+this.m_rA.y*this.m_rA.y*iA+this.m_rB.y*this.m_rB.y*iB;this.m_mass.ey.x=-this.m_rA.y*this.m_rA.x*iA-this.m_rB.y*this.m_rB.x*iB;this.m_mass.ez.x=-this.m_rA.y*iA-this.m_rB.y*iB;this.m_mass.ex.y=this.m_mass.ey.x;this.m_mass.ey.y=mA+mB+this.m_rA.x*this.m_rA.x*iA+this.m_rB.x*this.m_rB.x*iB;this.m_mass.ez.y=this.m_rA.x*iA+this.m_rB.x*iB;this.m_mass.ex.z=this.m_mass.ez.x;this.m_mass.ey.z=this.m_mass.ez.y;this.m_mass.ez.z=iA+iB;this.m_motorMass=iA+iB;if(this.m_motorMass>0){this.m_motorMass=1/this.m_motorMass}if(this.m_enableMotor==false||fixedRotation){this.m_motorImpulse=0}if(this.m_enableLimit&&fixedRotation==false){var jointAngle=aB-aA-this.m_referenceAngle;if(math_abs$4(this.m_upperAngle-this.m_lowerAngle)<2*SettingsInternal.angularSlop){this.m_limitState=LimitState$2.equalLimits}else if(jointAngle<=this.m_lowerAngle){if(this.m_limitState!=LimitState$2.atLowerLimit){this.m_impulse.z=0}this.m_limitState=LimitState$2.atLowerLimit}else if(jointAngle>=this.m_upperAngle){if(this.m_limitState!=LimitState$2.atUpperLimit){this.m_impulse.z=0}this.m_limitState=LimitState$2.atUpperLimit}else{this.m_limitState=LimitState$2.inactiveLimit;this.m_impulse.z=0}}else{this.m_limitState=LimitState$2.inactiveLimit}if(step.warmStarting){this.m_impulse.mul(step.dtRatio);this.m_motorImpulse*=step.dtRatio;var P3=Vec2.neo(this.m_impulse.x,this.m_impulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+this.m_motorImpulse+this.m_impulse.z);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+this.m_motorImpulse+this.m_impulse.z)}else{this.m_impulse.setZero();this.m_motorImpulse=0}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};RevoluteJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var fixedRotation=iA+iB===0;if(this.m_enableMotor&&this.m_limitState!=LimitState$2.equalLimits&&fixedRotation==false){var Cdot=wB-wA-this.m_motorSpeed;var impulse=-this.m_motorMass*Cdot;var oldImpulse=this.m_motorImpulse;var maxImpulse=step.dt*this.m_maxMotorTorque;this.m_motorImpulse=clamp(this.m_motorImpulse+impulse,-maxImpulse,maxImpulse);impulse=this.m_motorImpulse-oldImpulse;wA-=iA*impulse;wB+=iB*impulse}if(this.m_enableLimit&&this.m_limitState!=LimitState$2.inactiveLimit&&fixedRotation==false){var Cdot1=Vec2.zero();Cdot1.addCombine(1,vB2,1,Vec2.crossNumVec2(wB,this.m_rB));Cdot1.subCombine(1,vA2,1,Vec2.crossNumVec2(wA,this.m_rA));var Cdot2=wB-wA;var Cdot=new Vec3(Cdot1.x,Cdot1.y,Cdot2);var impulse=Vec3.neg(this.m_mass.solve33(Cdot));if(this.m_limitState==LimitState$2.equalLimits){this.m_impulse.add(impulse)}else if(this.m_limitState==LimitState$2.atLowerLimit){var newImpulse=this.m_impulse.z+impulse.z;if(newImpulse<0){var rhs=Vec2.combine(-1,Cdot1,this.m_impulse.z,Vec2.neo(this.m_mass.ez.x,this.m_mass.ez.y));var reduced=this.m_mass.solve22(rhs);impulse.x=reduced.x;impulse.y=reduced.y;impulse.z=-this.m_impulse.z;this.m_impulse.x+=reduced.x;this.m_impulse.y+=reduced.y;this.m_impulse.z=0}else{this.m_impulse.add(impulse)}}else if(this.m_limitState==LimitState$2.atUpperLimit){var newImpulse=this.m_impulse.z+impulse.z;if(newImpulse>0){var rhs=Vec2.combine(-1,Cdot1,this.m_impulse.z,Vec2.neo(this.m_mass.ez.x,this.m_mass.ez.y));var reduced=this.m_mass.solve22(rhs);impulse.x=reduced.x;impulse.y=reduced.y;impulse.z=-this.m_impulse.z;this.m_impulse.x+=reduced.x;this.m_impulse.y+=reduced.y;this.m_impulse.z=0}else{this.m_impulse.add(impulse)}}var P3=Vec2.neo(impulse.x,impulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+impulse.z);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+impulse.z)}else{var Cdot=Vec2.zero();Cdot.addCombine(1,vB2,1,Vec2.crossNumVec2(wB,this.m_rB));Cdot.subCombine(1,vA2,1,Vec2.crossNumVec2(wA,this.m_rA));var impulse=this.m_mass.solve22(Vec2.neg(Cdot));this.m_impulse.x+=impulse.x;this.m_impulse.y+=impulse.y;vA2.subMul(mA,impulse);wA-=iA*Vec2.crossVec2Vec2(this.m_rA,impulse);vB2.addMul(mB,impulse);wB+=iB*Vec2.crossVec2Vec2(this.m_rB,impulse)}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};RevoluteJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var angularError=0;var positionError=0;var fixedRotation=this.m_invIA+this.m_invIB==0;if(this.m_enableLimit&&this.m_limitState!=LimitState$2.inactiveLimit&&fixedRotation==false){var angle=aB-aA-this.m_referenceAngle;var limitImpulse=0;if(this.m_limitState==LimitState$2.equalLimits){var C=clamp(angle-this.m_lowerAngle,-SettingsInternal.maxAngularCorrection,SettingsInternal.maxAngularCorrection);limitImpulse=-this.m_motorMass*C;angularError=math_abs$4(C)}else if(this.m_limitState==LimitState$2.atLowerLimit){var C=angle-this.m_lowerAngle;angularError=-C;C=clamp(C+SettingsInternal.angularSlop,-SettingsInternal.maxAngularCorrection,0);limitImpulse=-this.m_motorMass*C}else if(this.m_limitState==LimitState$2.atUpperLimit){var C=angle-this.m_upperAngle;angularError=C;C=clamp(C-SettingsInternal.angularSlop,0,SettingsInternal.maxAngularCorrection);limitImpulse=-this.m_motorMass*C}aA-=this.m_invIA*limitImpulse;aB+=this.m_invIB*limitImpulse}{qA.setAngle(aA);qB.setAngle(aB);var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var C=Vec2.zero();C.addCombine(1,cB2,1,rB2);C.subCombine(1,cA2,1,rA2);positionError=C.length();var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var K=new Mat22;K.ex.x=mA+mB+iA*rA2.y*rA2.y+iB*rB2.y*rB2.y;K.ex.y=-iA*rA2.x*rA2.y-iB*rB2.x*rB2.y;K.ey.x=K.ex.y;K.ey.y=mA+mB+iA*rA2.x*rA2.x+iB*rB2.x*rB2.x;var impulse=Vec2.neg(K.solve(C));cA2.subMul(mA,impulse);aA-=iA*Vec2.crossVec2Vec2(rA2,impulse);cB2.addMul(mB,impulse);aB+=iB*Vec2.crossVec2Vec2(rB2,impulse)}this.m_bodyA.c_position.c.setVec2(cA2);this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c.setVec2(cB2);this.m_bodyB.c_position.a=aB;return positionError<=SettingsInternal.linearSlop&&angularError<=SettingsInternal.angularSlop};RevoluteJoint2.TYPE="revolute-joint";return RevoluteJoint2}(Joint);var math_abs$3=Math.abs;var math_max=Math.max;var math_min$2=Math.min;var LimitState$1;(function(LimitState2){LimitState2[LimitState2["inactiveLimit"]=0]="inactiveLimit";LimitState2[LimitState2["atLowerLimit"]=1]="atLowerLimit";LimitState2[LimitState2["atUpperLimit"]=2]="atUpperLimit";LimitState2[LimitState2["equalLimits"]=3]="equalLimits"})(LimitState$1||(LimitState$1={}));var DEFAULTS$7={enableLimit:false,lowerTranslation:0,upperTranslation:0,enableMotor:false,maxMotorForce:0,motorSpeed:0};var PrismaticJoint=function(_super){__extends(PrismaticJoint2,_super);function PrismaticJoint2(def,bodyA,bodyB,anchor,axis){var _this=this;if(!(_this instanceof PrismaticJoint2)){return new PrismaticJoint2(def,bodyA,bodyB,anchor,axis)}def=options(def,DEFAULTS$7);_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_type=PrismaticJoint2.TYPE;_this.m_localAnchorA=Vec2.clone(anchor?bodyA.getLocalPoint(anchor):def.localAnchorA||Vec2.zero());_this.m_localAnchorB=Vec2.clone(anchor?bodyB.getLocalPoint(anchor):def.localAnchorB||Vec2.zero());_this.m_localXAxisA=Vec2.clone(axis?bodyA.getLocalVector(axis):def.localAxisA||Vec2.neo(1,0));_this.m_localXAxisA.normalize();_this.m_localYAxisA=Vec2.crossNumVec2(1,_this.m_localXAxisA);_this.m_referenceAngle=Number.isFinite(def.referenceAngle)?def.referenceAngle:bodyB.getAngle()-bodyA.getAngle();_this.m_impulse=new Vec3;_this.m_motorMass=0;_this.m_motorImpulse=0;_this.m_lowerTranslation=def.lowerTranslation;_this.m_upperTranslation=def.upperTranslation;_this.m_maxMotorForce=def.maxMotorForce;_this.m_motorSpeed=def.motorSpeed;_this.m_enableLimit=def.enableLimit;_this.m_enableMotor=def.enableMotor;_this.m_limitState=LimitState$1.inactiveLimit;_this.m_axis=Vec2.zero();_this.m_perp=Vec2.zero();_this.m_K=new Mat33;return _this}PrismaticJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,lowerTranslation:this.m_lowerTranslation,upperTranslation:this.m_upperTranslation,maxMotorForce:this.m_maxMotorForce,motorSpeed:this.m_motorSpeed,enableLimit:this.m_enableLimit,enableMotor:this.m_enableMotor,localAnchorA:this.m_localAnchorA,localAnchorB:this.m_localAnchorB,localAxisA:this.m_localXAxisA,referenceAngle:this.m_referenceAngle}};PrismaticJoint2._deserialize=function(data,world,restore){data=__assign({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);data.localAxisA=Vec2.clone(data.localAxisA);var joint=new PrismaticJoint2(data);return joint};PrismaticJoint2.prototype._reset=function(def){if(def.anchorA){this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA))}else if(def.localAnchorA){this.m_localAnchorA.setVec2(def.localAnchorA)}if(def.anchorB){this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB))}else if(def.localAnchorB){this.m_localAnchorB.setVec2(def.localAnchorB)}if(def.localAxisA){this.m_localXAxisA.setVec2(def.localAxisA);this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1,def.localAxisA))}if(Number.isFinite(def.referenceAngle)){this.m_referenceAngle=def.referenceAngle}if(typeof def.enableLimit!=="undefined"){this.m_enableLimit=!!def.enableLimit}if(Number.isFinite(def.lowerTranslation)){this.m_lowerTranslation=def.lowerTranslation}if(Number.isFinite(def.upperTranslation)){this.m_upperTranslation=def.upperTranslation}if(typeof def.enableMotor!=="undefined"){this.m_enableMotor=!!def.enableMotor}if(Number.isFinite(def.maxMotorForce)){this.m_maxMotorForce=def.maxMotorForce}if(Number.isFinite(def.motorSpeed)){this.m_motorSpeed=def.motorSpeed}};PrismaticJoint2.prototype.getLocalAnchorA=function(){return this.m_localAnchorA};PrismaticJoint2.prototype.getLocalAnchorB=function(){return this.m_localAnchorB};PrismaticJoint2.prototype.getLocalAxisA=function(){return this.m_localXAxisA};PrismaticJoint2.prototype.getReferenceAngle=function(){return this.m_referenceAngle};PrismaticJoint2.prototype.getJointTranslation=function(){var pA2=this.m_bodyA.getWorldPoint(this.m_localAnchorA);var pB2=this.m_bodyB.getWorldPoint(this.m_localAnchorB);var d2=Vec2.sub(pB2,pA2);var axis=this.m_bodyA.getWorldVector(this.m_localXAxisA);var translation2=Vec2.dot(d2,axis);return translation2};PrismaticJoint2.prototype.getJointSpeed=function(){var bA=this.m_bodyA;var bB=this.m_bodyB;var rA2=Rot.mulVec2(bA.m_xf.q,Vec2.sub(this.m_localAnchorA,bA.m_sweep.localCenter));var rB2=Rot.mulVec2(bB.m_xf.q,Vec2.sub(this.m_localAnchorB,bB.m_sweep.localCenter));var p1=Vec2.add(bA.m_sweep.c,rA2);var p2=Vec2.add(bB.m_sweep.c,rB2);var d2=Vec2.sub(p2,p1);var axis=Rot.mulVec2(bA.m_xf.q,this.m_localXAxisA);var vA2=bA.m_linearVelocity;var vB2=bB.m_linearVelocity;var wA=bA.m_angularVelocity;var wB=bB.m_angularVelocity;var speed=Vec2.dot(d2,Vec2.crossNumVec2(wA,axis))+Vec2.dot(axis,Vec2.sub(Vec2.addCrossNumVec2(vB2,wB,rB2),Vec2.addCrossNumVec2(vA2,wA,rA2)));return speed};PrismaticJoint2.prototype.isLimitEnabled=function(){return this.m_enableLimit};PrismaticJoint2.prototype.enableLimit=function(flag){if(flag!=this.m_enableLimit){this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_enableLimit=flag;this.m_impulse.z=0}};PrismaticJoint2.prototype.getLowerLimit=function(){return this.m_lowerTranslation};PrismaticJoint2.prototype.getUpperLimit=function(){return this.m_upperTranslation};PrismaticJoint2.prototype.setLimits=function(lower,upper){if(lower!=this.m_lowerTranslation||upper!=this.m_upperTranslation){this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_lowerTranslation=lower;this.m_upperTranslation=upper;this.m_impulse.z=0}};PrismaticJoint2.prototype.isMotorEnabled=function(){return this.m_enableMotor};PrismaticJoint2.prototype.enableMotor=function(flag){if(flag==this.m_enableMotor)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_enableMotor=flag};PrismaticJoint2.prototype.setMotorSpeed=function(speed){if(speed==this.m_motorSpeed)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_motorSpeed=speed};PrismaticJoint2.prototype.setMaxMotorForce=function(force){if(force==this.m_maxMotorForce)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_maxMotorForce=force};PrismaticJoint2.prototype.getMaxMotorForce=function(){return this.m_maxMotorForce};PrismaticJoint2.prototype.getMotorSpeed=function(){return this.m_motorSpeed};PrismaticJoint2.prototype.getMotorForce=function(inv_dt){return inv_dt*this.m_motorImpulse};PrismaticJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};PrismaticJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};PrismaticJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.combine(this.m_impulse.x,this.m_perp,this.m_motorImpulse+this.m_impulse.z,this.m_axis).mul(inv_dt)};PrismaticJoint2.prototype.getReactionTorque=function(inv_dt){return inv_dt*this.m_impulse.y};PrismaticJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter;this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var d2=Vec2.zero();d2.addCombine(1,cB2,1,rB2);d2.subCombine(1,cA2,1,rA2);var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;{this.m_axis=Rot.mulVec2(qA,this.m_localXAxisA);this.m_a1=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),this.m_axis);this.m_a2=Vec2.crossVec2Vec2(rB2,this.m_axis);this.m_motorMass=mA+mB+iA*this.m_a1*this.m_a1+iB*this.m_a2*this.m_a2;if(this.m_motorMass>0){this.m_motorMass=1/this.m_motorMass}}{this.m_perp=Rot.mulVec2(qA,this.m_localYAxisA);this.m_s1=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),this.m_perp);this.m_s2=Vec2.crossVec2Vec2(rB2,this.m_perp);Vec2.crossVec2Vec2(rA2,this.m_perp);var k11=mA+mB+iA*this.m_s1*this.m_s1+iB*this.m_s2*this.m_s2;var k12=iA*this.m_s1+iB*this.m_s2;var k13=iA*this.m_s1*this.m_a1+iB*this.m_s2*this.m_a2;var k22=iA+iB;if(k22==0){k22=1}var k23=iA*this.m_a1+iB*this.m_a2;var k33=mA+mB+iA*this.m_a1*this.m_a1+iB*this.m_a2*this.m_a2;this.m_K.ex.set(k11,k12,k13);this.m_K.ey.set(k12,k22,k23);this.m_K.ez.set(k13,k23,k33)}if(this.m_enableLimit){var jointTranslation=Vec2.dot(this.m_axis,d2);if(math_abs$3(this.m_upperTranslation-this.m_lowerTranslation)<2*SettingsInternal.linearSlop){this.m_limitState=LimitState$1.equalLimits}else if(jointTranslation<=this.m_lowerTranslation){if(this.m_limitState!=LimitState$1.atLowerLimit){this.m_limitState=LimitState$1.atLowerLimit;this.m_impulse.z=0}}else if(jointTranslation>=this.m_upperTranslation){if(this.m_limitState!=LimitState$1.atUpperLimit){this.m_limitState=LimitState$1.atUpperLimit;this.m_impulse.z=0}}else{this.m_limitState=LimitState$1.inactiveLimit;this.m_impulse.z=0}}else{this.m_limitState=LimitState$1.inactiveLimit;this.m_impulse.z=0}if(this.m_enableMotor==false){this.m_motorImpulse=0}if(step.warmStarting){this.m_impulse.mul(step.dtRatio);this.m_motorImpulse*=step.dtRatio;var P3=Vec2.combine(this.m_impulse.x,this.m_perp,this.m_motorImpulse+this.m_impulse.z,this.m_axis);var LA=this.m_impulse.x*this.m_s1+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a1;var LB=this.m_impulse.x*this.m_s2+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a2;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}else{this.m_impulse.setZero();this.m_motorImpulse=0}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};PrismaticJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;if(this.m_enableMotor&&this.m_limitState!=LimitState$1.equalLimits){var Cdot=Vec2.dot(this.m_axis,Vec2.sub(vB2,vA2))+this.m_a2*wB-this.m_a1*wA;var impulse=this.m_motorMass*(this.m_motorSpeed-Cdot);var oldImpulse=this.m_motorImpulse;var maxImpulse=step.dt*this.m_maxMotorForce;this.m_motorImpulse=clamp(this.m_motorImpulse+impulse,-maxImpulse,maxImpulse);impulse=this.m_motorImpulse-oldImpulse;var P3=Vec2.mulNumVec2(impulse,this.m_axis);var LA=impulse*this.m_a1;var LB=impulse*this.m_a2;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}var Cdot1=Vec2.zero();Cdot1.x+=Vec2.dot(this.m_perp,vB2)+this.m_s2*wB;Cdot1.x-=Vec2.dot(this.m_perp,vA2)+this.m_s1*wA;Cdot1.y=wB-wA;if(this.m_enableLimit&&this.m_limitState!=LimitState$1.inactiveLimit){var Cdot2=0;Cdot2+=Vec2.dot(this.m_axis,vB2)+this.m_a2*wB;Cdot2-=Vec2.dot(this.m_axis,vA2)+this.m_a1*wA;var Cdot=new Vec3(Cdot1.x,Cdot1.y,Cdot2);var f1=Vec3.clone(this.m_impulse);var df=this.m_K.solve33(Vec3.neg(Cdot));this.m_impulse.add(df);if(this.m_limitState==LimitState$1.atLowerLimit){this.m_impulse.z=math_max(this.m_impulse.z,0)}else if(this.m_limitState==LimitState$1.atUpperLimit){this.m_impulse.z=math_min$2(this.m_impulse.z,0)}var b2=Vec2.combine(-1,Cdot1,-(this.m_impulse.z-f1.z),Vec2.neo(this.m_K.ez.x,this.m_K.ez.y));var f2r=Vec2.add(this.m_K.solve22(b2),Vec2.neo(f1.x,f1.y));this.m_impulse.x=f2r.x;this.m_impulse.y=f2r.y;df=Vec3.sub(this.m_impulse,f1);var P3=Vec2.combine(df.x,this.m_perp,df.z,this.m_axis);var LA=df.x*this.m_s1+df.y+df.z*this.m_a1;var LB=df.x*this.m_s2+df.y+df.z*this.m_a2;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}else{var df=this.m_K.solve22(Vec2.neg(Cdot1));this.m_impulse.x+=df.x;this.m_impulse.y+=df.y;var P3=Vec2.mulNumVec2(df.x,this.m_perp);var LA=df.x*this.m_s1+df.y;var LB=df.x*this.m_s2+df.y;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};PrismaticJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var d2=Vec2.sub(Vec2.add(cB2,rB2),Vec2.add(cA2,rA2));var axis=Rot.mulVec2(qA,this.m_localXAxisA);var a1=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),axis);var a2=Vec2.crossVec2Vec2(rB2,axis);var perp2=Rot.mulVec2(qA,this.m_localYAxisA);var s1=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),perp2);var s2=Vec2.crossVec2Vec2(rB2,perp2);var impulse=new Vec3;var C1=Vec2.zero();C1.x=Vec2.dot(perp2,d2);C1.y=aB-aA-this.m_referenceAngle;var linearError=math_abs$3(C1.x);var angularError=math_abs$3(C1.y);var linearSlop=SettingsInternal.linearSlop;var maxLinearCorrection=SettingsInternal.maxLinearCorrection;var active=false;var C2=0;if(this.m_enableLimit){var translation2=Vec2.dot(axis,d2);if(math_abs$3(this.m_upperTranslation-this.m_lowerTranslation)<2*linearSlop){C2=clamp(translation2,-maxLinearCorrection,maxLinearCorrection);linearError=math_max(linearError,math_abs$3(translation2));active=true}else if(translation2<=this.m_lowerTranslation){C2=clamp(translation2-this.m_lowerTranslation+linearSlop,-maxLinearCorrection,0);linearError=Math.max(linearError,this.m_lowerTranslation-translation2);active=true}else if(translation2>=this.m_upperTranslation){C2=clamp(translation2-this.m_upperTranslation-linearSlop,0,maxLinearCorrection);linearError=Math.max(linearError,translation2-this.m_upperTranslation);active=true}}if(active){var k11=mA+mB+iA*s1*s1+iB*s2*s2;var k12=iA*s1+iB*s2;var k13=iA*s1*a1+iB*s2*a2;var k22=iA+iB;if(k22==0){k22=1}var k23=iA*a1+iB*a2;var k33=mA+mB+iA*a1*a1+iB*a2*a2;var K=new Mat33;K.ex.set(k11,k12,k13);K.ey.set(k12,k22,k23);K.ez.set(k13,k23,k33);var C=new Vec3;C.x=C1.x;C.y=C1.y;C.z=C2;impulse=K.solve33(Vec3.neg(C))}else{var k11=mA+mB+iA*s1*s1+iB*s2*s2;var k12=iA*s1+iB*s2;var k22=iA+iB;if(k22==0){k22=1}var K=new Mat22;K.ex.setNum(k11,k12);K.ey.setNum(k12,k22);var impulse1=K.solve(Vec2.neg(C1));impulse.x=impulse1.x;impulse.y=impulse1.y;impulse.z=0}var P3=Vec2.combine(impulse.x,perp2,impulse.z,axis);var LA=impulse.x*s1+impulse.y+impulse.z*a1;var LB=impulse.x*s2+impulse.y+impulse.z*a2;cA2.subMul(mA,P3);aA-=iA*LA;cB2.addMul(mB,P3);aB+=iB*LB;this.m_bodyA.c_position.c=cA2;this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c=cB2;this.m_bodyB.c_position.a=aB;return linearError<=SettingsInternal.linearSlop&&angularError<=SettingsInternal.angularSlop};PrismaticJoint2.TYPE="prismatic-joint";return PrismaticJoint2}(Joint);var DEFAULTS$6={ratio:1};var GearJoint=function(_super){__extends(GearJoint2,_super);function GearJoint2(def,bodyA,bodyB,joint1,joint2,ratio){var _this=this;if(!(_this instanceof GearJoint2)){return new GearJoint2(def,bodyA,bodyB,joint1,joint2,ratio)}def=options(def,DEFAULTS$6);_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_type=GearJoint2.TYPE;_this.m_joint1=joint1?joint1:def.joint1;_this.m_joint2=joint2?joint2:def.joint2;_this.m_ratio=Number.isFinite(ratio)?ratio:def.ratio;_this.m_type1=_this.m_joint1.getType();_this.m_type2=_this.m_joint2.getType();var coordinateA;var coordinateB;_this.m_bodyC=_this.m_joint1.getBodyA();_this.m_bodyA=_this.m_joint1.getBodyB();var xfA2=_this.m_bodyA.m_xf;var aA=_this.m_bodyA.m_sweep.a;var xfC=_this.m_bodyC.m_xf;var aC=_this.m_bodyC.m_sweep.a;if(_this.m_type1===RevoluteJoint.TYPE){var revolute=_this.m_joint1;_this.m_localAnchorC=revolute.m_localAnchorA;_this.m_localAnchorA=revolute.m_localAnchorB;_this.m_referenceAngleA=revolute.m_referenceAngle;_this.m_localAxisC=Vec2.zero();coordinateA=aA-aC-_this.m_referenceAngleA}else{var prismatic=_this.m_joint1;_this.m_localAnchorC=prismatic.m_localAnchorA;_this.m_localAnchorA=prismatic.m_localAnchorB;_this.m_referenceAngleA=prismatic.m_referenceAngle;_this.m_localAxisC=prismatic.m_localXAxisA;var pC=_this.m_localAnchorC;var pA2=Rot.mulTVec2(xfC.q,Vec2.add(Rot.mulVec2(xfA2.q,_this.m_localAnchorA),Vec2.sub(xfA2.p,xfC.p)));coordinateA=Vec2.dot(pA2,_this.m_localAxisC)-Vec2.dot(pC,_this.m_localAxisC)}_this.m_bodyD=_this.m_joint2.getBodyA();_this.m_bodyB=_this.m_joint2.getBodyB();var xfB2=_this.m_bodyB.m_xf;var aB=_this.m_bodyB.m_sweep.a;var xfD=_this.m_bodyD.m_xf;var aD=_this.m_bodyD.m_sweep.a;if(_this.m_type2===RevoluteJoint.TYPE){var revolute=_this.m_joint2;_this.m_localAnchorD=revolute.m_localAnchorA;_this.m_localAnchorB=revolute.m_localAnchorB;_this.m_referenceAngleB=revolute.m_referenceAngle;_this.m_localAxisD=Vec2.zero();coordinateB=aB-aD-_this.m_referenceAngleB}else{var prismatic=_this.m_joint2;_this.m_localAnchorD=prismatic.m_localAnchorA;_this.m_localAnchorB=prismatic.m_localAnchorB;_this.m_referenceAngleB=prismatic.m_referenceAngle;_this.m_localAxisD=prismatic.m_localXAxisA;var pD=_this.m_localAnchorD;var pB2=Rot.mulTVec2(xfD.q,Vec2.add(Rot.mulVec2(xfB2.q,_this.m_localAnchorB),Vec2.sub(xfB2.p,xfD.p)));coordinateB=Vec2.dot(pB2,_this.m_localAxisD)-Vec2.dot(pD,_this.m_localAxisD)}_this.m_constant=coordinateA+_this.m_ratio*coordinateB;_this.m_impulse=0;return _this}GearJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,joint1:this.m_joint1,joint2:this.m_joint2,ratio:this.m_ratio}};GearJoint2._deserialize=function(data,world,restore){data=__assign({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);data.joint1=restore(Joint,data.joint1,world);data.joint2=restore(Joint,data.joint2,world);var joint=new GearJoint2(data);return joint};GearJoint2.prototype._reset=function(def){if(Number.isFinite(def.ratio)){this.m_ratio=def.ratio}};GearJoint2.prototype.getJoint1=function(){return this.m_joint1};GearJoint2.prototype.getJoint2=function(){return this.m_joint2};GearJoint2.prototype.setRatio=function(ratio){this.m_ratio=ratio};GearJoint2.prototype.getRatio=function(){return this.m_ratio};GearJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};GearJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};GearJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.mulNumVec2(this.m_impulse,this.m_JvAC).mul(inv_dt)};GearJoint2.prototype.getReactionTorque=function(inv_dt){var L=this.m_impulse*this.m_JwA;return inv_dt*L};GearJoint2.prototype.initVelocityConstraints=function(step){this.m_lcA=this.m_bodyA.m_sweep.localCenter;this.m_lcB=this.m_bodyB.m_sweep.localCenter;this.m_lcC=this.m_bodyC.m_sweep.localCenter;this.m_lcD=this.m_bodyD.m_sweep.localCenter;this.m_mA=this.m_bodyA.m_invMass;this.m_mB=this.m_bodyB.m_invMass;this.m_mC=this.m_bodyC.m_invMass;this.m_mD=this.m_bodyD.m_invMass;this.m_iA=this.m_bodyA.m_invI;this.m_iB=this.m_bodyB.m_invI;this.m_iC=this.m_bodyC.m_invI;this.m_iD=this.m_bodyD.m_invI;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var aC=this.m_bodyC.c_position.a;var vC=this.m_bodyC.c_velocity.v;var wC=this.m_bodyC.c_velocity.w;var aD=this.m_bodyD.c_position.a;var vD=this.m_bodyD.c_velocity.v;var wD=this.m_bodyD.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var qC=Rot.neo(aC);var qD=Rot.neo(aD);this.m_mass=0;if(this.m_type1==RevoluteJoint.TYPE){this.m_JvAC=Vec2.zero();this.m_JwA=1;this.m_JwC=1;this.m_mass+=this.m_iA+this.m_iC}else{var u=Rot.mulVec2(qC,this.m_localAxisC);var rC=Rot.mulSub(qC,this.m_localAnchorC,this.m_lcC);var rA2=Rot.mulSub(qA,this.m_localAnchorA,this.m_lcA);this.m_JvAC=u;this.m_JwC=Vec2.crossVec2Vec2(rC,u);this.m_JwA=Vec2.crossVec2Vec2(rA2,u);this.m_mass+=this.m_mC+this.m_mA+this.m_iC*this.m_JwC*this.m_JwC+this.m_iA*this.m_JwA*this.m_JwA}if(this.m_type2==RevoluteJoint.TYPE){this.m_JvBD=Vec2.zero();this.m_JwB=this.m_ratio;this.m_JwD=this.m_ratio;this.m_mass+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD)}else{var u=Rot.mulVec2(qD,this.m_localAxisD);var rD=Rot.mulSub(qD,this.m_localAnchorD,this.m_lcD);var rB2=Rot.mulSub(qB,this.m_localAnchorB,this.m_lcB);this.m_JvBD=Vec2.mulNumVec2(this.m_ratio,u);this.m_JwD=this.m_ratio*Vec2.crossVec2Vec2(rD,u);this.m_JwB=this.m_ratio*Vec2.crossVec2Vec2(rB2,u);this.m_mass+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*this.m_JwD*this.m_JwD+this.m_iB*this.m_JwB*this.m_JwB}this.m_mass=this.m_mass>0?1/this.m_mass:0;if(step.warmStarting){vA2.addMul(this.m_mA*this.m_impulse,this.m_JvAC);wA+=this.m_iA*this.m_impulse*this.m_JwA;vB2.addMul(this.m_mB*this.m_impulse,this.m_JvBD);wB+=this.m_iB*this.m_impulse*this.m_JwB;vC.subMul(this.m_mC*this.m_impulse,this.m_JvAC);wC-=this.m_iC*this.m_impulse*this.m_JwC;vD.subMul(this.m_mD*this.m_impulse,this.m_JvBD);wD-=this.m_iD*this.m_impulse*this.m_JwD}else{this.m_impulse=0}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB;this.m_bodyC.c_velocity.v.setVec2(vC);this.m_bodyC.c_velocity.w=wC;this.m_bodyD.c_velocity.v.setVec2(vD);this.m_bodyD.c_velocity.w=wD};GearJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var vC=this.m_bodyC.c_velocity.v;var wC=this.m_bodyC.c_velocity.w;var vD=this.m_bodyD.c_velocity.v;var wD=this.m_bodyD.c_velocity.w;var Cdot=Vec2.dot(this.m_JvAC,vA2)-Vec2.dot(this.m_JvAC,vC)+Vec2.dot(this.m_JvBD,vB2)-Vec2.dot(this.m_JvBD,vD);Cdot+=this.m_JwA*wA-this.m_JwC*wC+(this.m_JwB*wB-this.m_JwD*wD);var impulse=-this.m_mass*Cdot;this.m_impulse+=impulse;vA2.addMul(this.m_mA*impulse,this.m_JvAC);wA+=this.m_iA*impulse*this.m_JwA;vB2.addMul(this.m_mB*impulse,this.m_JvBD);wB+=this.m_iB*impulse*this.m_JwB;vC.subMul(this.m_mC*impulse,this.m_JvAC);wC-=this.m_iC*impulse*this.m_JwC;vD.subMul(this.m_mD*impulse,this.m_JvBD);wD-=this.m_iD*impulse*this.m_JwD;this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB;this.m_bodyC.c_velocity.v.setVec2(vC);this.m_bodyC.c_velocity.w=wC;this.m_bodyD.c_velocity.v.setVec2(vD);this.m_bodyD.c_velocity.w=wD};GearJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var cC=this.m_bodyC.c_position.c;var aC=this.m_bodyC.c_position.a;var cD=this.m_bodyD.c_position.c;var aD=this.m_bodyD.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var qC=Rot.neo(aC);var qD=Rot.neo(aD);var linearError=0;var coordinateA;var coordinateB;var JvAC;var JvBD;var JwA;var JwB;var JwC;var JwD;var mass=0;if(this.m_type1==RevoluteJoint.TYPE){JvAC=Vec2.zero();JwA=1;JwC=1;mass+=this.m_iA+this.m_iC;coordinateA=aA-aC-this.m_referenceAngleA}else{var u=Rot.mulVec2(qC,this.m_localAxisC);var rC=Rot.mulSub(qC,this.m_localAnchorC,this.m_lcC);var rA2=Rot.mulSub(qA,this.m_localAnchorA,this.m_lcA);JvAC=u;JwC=Vec2.crossVec2Vec2(rC,u);JwA=Vec2.crossVec2Vec2(rA2,u);mass+=this.m_mC+this.m_mA+this.m_iC*JwC*JwC+this.m_iA*JwA*JwA;var pC=Vec2.sub(this.m_localAnchorC,this.m_lcC);var pA2=Rot.mulTVec2(qC,Vec2.add(rA2,Vec2.sub(cA2,cC)));coordinateA=Vec2.dot(Vec2.sub(pA2,pC),this.m_localAxisC)}if(this.m_type2==RevoluteJoint.TYPE){JvBD=Vec2.zero();JwB=this.m_ratio;JwD=this.m_ratio;mass+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD);coordinateB=aB-aD-this.m_referenceAngleB}else{var u=Rot.mulVec2(qD,this.m_localAxisD);var rD=Rot.mulSub(qD,this.m_localAnchorD,this.m_lcD);var rB2=Rot.mulSub(qB,this.m_localAnchorB,this.m_lcB);JvBD=Vec2.mulNumVec2(this.m_ratio,u);JwD=this.m_ratio*Vec2.crossVec2Vec2(rD,u);JwB=this.m_ratio*Vec2.crossVec2Vec2(rB2,u);mass+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*JwD*JwD+this.m_iB*JwB*JwB;var pD=Vec2.sub(this.m_localAnchorD,this.m_lcD);var pB2=Rot.mulTVec2(qD,Vec2.add(rB2,Vec2.sub(cB2,cD)));coordinateB=Vec2.dot(pB2,this.m_localAxisD)-Vec2.dot(pD,this.m_localAxisD)}var C=coordinateA+this.m_ratio*coordinateB-this.m_constant;var impulse=0;if(mass>0){impulse=-C/mass}cA2.addMul(this.m_mA*impulse,JvAC);aA+=this.m_iA*impulse*JwA;cB2.addMul(this.m_mB*impulse,JvBD);aB+=this.m_iB*impulse*JwB;cC.subMul(this.m_mC*impulse,JvAC);aC-=this.m_iC*impulse*JwC;cD.subMul(this.m_mD*impulse,JvBD);aD-=this.m_iD*impulse*JwD;this.m_bodyA.c_position.c.setVec2(cA2);this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c.setVec2(cB2);this.m_bodyB.c_position.a=aB;this.m_bodyC.c_position.c.setVec2(cC);this.m_bodyC.c_position.a=aC;this.m_bodyD.c_position.c.setVec2(cD);this.m_bodyD.c_position.a=aD;return linearError0){this.m_angularMass=1/this.m_angularMass}this.m_linearError=Vec2.zero();this.m_linearError.addCombine(1,cB2,1,this.m_rB);this.m_linearError.subCombine(1,cA2,1,this.m_rA);this.m_angularError=aB-aA-this.m_angularOffset;if(step.warmStarting){this.m_linearImpulse.mul(step.dtRatio);this.m_angularImpulse*=step.dtRatio;var P3=Vec2.neo(this.m_linearImpulse.x,this.m_linearImpulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+this.m_angularImpulse);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+this.m_angularImpulse)}else{this.m_linearImpulse.setZero();this.m_angularImpulse=0}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};MotorJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var h=step.dt;var inv_h=step.inv_dt;{var Cdot=wB-wA+inv_h*this.m_correctionFactor*this.m_angularError;var impulse=-this.m_angularMass*Cdot;var oldImpulse=this.m_angularImpulse;var maxImpulse=h*this.m_maxTorque;this.m_angularImpulse=clamp(this.m_angularImpulse+impulse,-maxImpulse,maxImpulse);impulse=this.m_angularImpulse-oldImpulse;wA-=iA*impulse;wB+=iB*impulse}{var Cdot=Vec2.zero();Cdot.addCombine(1,vB2,1,Vec2.crossNumVec2(wB,this.m_rB));Cdot.subCombine(1,vA2,1,Vec2.crossNumVec2(wA,this.m_rA));Cdot.addMul(inv_h*this.m_correctionFactor,this.m_linearError);var impulse=Vec2.neg(Mat22.mulVec2(this.m_linearMass,Cdot));var oldImpulse=Vec2.clone(this.m_linearImpulse);this.m_linearImpulse.add(impulse);var maxImpulse=h*this.m_maxForce;this.m_linearImpulse.clamp(maxImpulse);impulse=Vec2.sub(this.m_linearImpulse,oldImpulse);vA2.subMul(mA,impulse);wA-=iA*Vec2.crossVec2Vec2(this.m_rA,impulse);vB2.addMul(mB,impulse);wB+=iB*Vec2.crossVec2Vec2(this.m_rB,impulse)}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};MotorJoint2.prototype.solvePositionConstraints=function(step){return true};MotorJoint2.TYPE="motor-joint";return MotorJoint2}(Joint);var math_PI$2=Math.PI;var DEFAULTS$4={maxForce:0,frequencyHz:5,dampingRatio:.7};var MouseJoint=function(_super){__extends(MouseJoint2,_super);function MouseJoint2(def,bodyA,bodyB,target){var _this=this;if(!(_this instanceof MouseJoint2)){return new MouseJoint2(def,bodyA,bodyB,target)}def=options(def,DEFAULTS$4);_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_type=MouseJoint2.TYPE;if(Vec2.isValid(target)){_this.m_targetA=Vec2.clone(target)}else if(Vec2.isValid(def.target)){_this.m_targetA=Vec2.clone(def.target)}else{_this.m_targetA=Vec2.zero()}_this.m_localAnchorB=Transform.mulTVec2(bodyB.getTransform(),_this.m_targetA);_this.m_maxForce=def.maxForce;_this.m_impulse=Vec2.zero();_this.m_frequencyHz=def.frequencyHz;_this.m_dampingRatio=def.dampingRatio;_this.m_beta=0;_this.m_gamma=0;_this.m_rB=Vec2.zero();_this.m_localCenterB=Vec2.zero();_this.m_invMassB=0;_this.m_invIB=0;_this.m_mass=new Mat22;_this.m_C=Vec2.zero();return _this}MouseJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,target:this.m_targetA,maxForce:this.m_maxForce,frequencyHz:this.m_frequencyHz,dampingRatio:this.m_dampingRatio,_localAnchorB:this.m_localAnchorB}};MouseJoint2._deserialize=function(data,world,restore){data=__assign({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);data.target=Vec2.clone(data.target);var joint=new MouseJoint2(data);if(data._localAnchorB){joint.m_localAnchorB=data._localAnchorB}return joint};MouseJoint2.prototype._reset=function(def){if(Number.isFinite(def.maxForce)){this.m_maxForce=def.maxForce}if(Number.isFinite(def.frequencyHz)){this.m_frequencyHz=def.frequencyHz}if(Number.isFinite(def.dampingRatio)){this.m_dampingRatio=def.dampingRatio}};MouseJoint2.prototype.setTarget=function(target){if(Vec2.areEqual(target,this.m_targetA))return;this.m_bodyB.setAwake(true);this.m_targetA.set(target)};MouseJoint2.prototype.getTarget=function(){return this.m_targetA};MouseJoint2.prototype.setMaxForce=function(force){this.m_maxForce=force};MouseJoint2.prototype.getMaxForce=function(){return this.m_maxForce};MouseJoint2.prototype.setFrequency=function(hz){this.m_frequencyHz=hz};MouseJoint2.prototype.getFrequency=function(){return this.m_frequencyHz};MouseJoint2.prototype.setDampingRatio=function(ratio){this.m_dampingRatio=ratio};MouseJoint2.prototype.getDampingRatio=function(){return this.m_dampingRatio};MouseJoint2.prototype.getAnchorA=function(){return Vec2.clone(this.m_targetA)};MouseJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};MouseJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.mulNumVec2(inv_dt,this.m_impulse)};MouseJoint2.prototype.getReactionTorque=function(inv_dt){return inv_dt*0};MouseJoint2.prototype.shiftOrigin=function(newOrigin){this.m_targetA.sub(newOrigin)};MouseJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIB=this.m_bodyB.m_invI;var position=this.m_bodyB.c_position;var velocity=this.m_bodyB.c_velocity;var cB2=position.c;var aB=position.a;var vB2=velocity.v;var wB=velocity.w;var qB=Rot.neo(aB);var mass=this.m_bodyB.getMass();var omega=2*math_PI$2*this.m_frequencyHz;var d2=2*mass*this.m_dampingRatio*omega;var k=mass*(omega*omega);var h=step.dt;this.m_gamma=h*(d2+h*k);if(this.m_gamma!=0){this.m_gamma=1/this.m_gamma}this.m_beta=h*k*this.m_gamma;this.m_rB=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var K=new Mat22;K.ex.x=this.m_invMassB+this.m_invIB*this.m_rB.y*this.m_rB.y+this.m_gamma;K.ex.y=-this.m_invIB*this.m_rB.x*this.m_rB.y;K.ey.x=K.ex.y;K.ey.y=this.m_invMassB+this.m_invIB*this.m_rB.x*this.m_rB.x+this.m_gamma;this.m_mass=K.getInverse();this.m_C.setVec2(cB2);this.m_C.addCombine(1,this.m_rB,-1,this.m_targetA);this.m_C.mul(this.m_beta);wB*=.98;if(step.warmStarting){this.m_impulse.mul(step.dtRatio);vB2.addMul(this.m_invMassB,this.m_impulse);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,this.m_impulse)}else{this.m_impulse.setZero()}velocity.v.setVec2(vB2);velocity.w=wB};MouseJoint2.prototype.solveVelocityConstraints=function(step){var velocity=this.m_bodyB.c_velocity;var vB2=Vec2.clone(velocity.v);var wB=velocity.w;var Cdot=Vec2.crossNumVec2(wB,this.m_rB);Cdot.add(vB2);Cdot.addCombine(1,this.m_C,this.m_gamma,this.m_impulse);Cdot.neg();var impulse=Mat22.mulVec2(this.m_mass,Cdot);var oldImpulse=Vec2.clone(this.m_impulse);this.m_impulse.add(impulse);var maxImpulse=step.dt*this.m_maxForce;this.m_impulse.clamp(maxImpulse);impulse=Vec2.sub(this.m_impulse,oldImpulse);vB2.addMul(this.m_invMassB,impulse);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,impulse);velocity.v.setVec2(vB2);velocity.w=wB};MouseJoint2.prototype.solvePositionConstraints=function(step){return true};MouseJoint2.TYPE="mouse-joint";return MouseJoint2}(Joint);var math_abs$2=Math.abs;var DEFAULTS$3={collideConnected:true};var PulleyJoint=function(_super){__extends(PulleyJoint2,_super);function PulleyJoint2(def,bodyA,bodyB,groundA,groundB,anchorA,anchorB,ratio){var _this=this;if(!(_this instanceof PulleyJoint2)){return new PulleyJoint2(def,bodyA,bodyB,groundA,groundB,anchorA,anchorB,ratio)}def=options(def,DEFAULTS$3);_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_type=PulleyJoint2.TYPE;_this.m_groundAnchorA=Vec2.clone(groundA?groundA:def.groundAnchorA||Vec2.neo(-1,1));_this.m_groundAnchorB=Vec2.clone(groundB?groundB:def.groundAnchorB||Vec2.neo(1,1));_this.m_localAnchorA=Vec2.clone(anchorA?bodyA.getLocalPoint(anchorA):def.localAnchorA||Vec2.neo(-1,0));_this.m_localAnchorB=Vec2.clone(anchorB?bodyB.getLocalPoint(anchorB):def.localAnchorB||Vec2.neo(1,0));_this.m_lengthA=Number.isFinite(def.lengthA)?def.lengthA:Vec2.distance(anchorA,groundA);_this.m_lengthB=Number.isFinite(def.lengthB)?def.lengthB:Vec2.distance(anchorB,groundB);_this.m_ratio=Number.isFinite(ratio)?ratio:def.ratio;_this.m_constant=_this.m_lengthA+_this.m_ratio*_this.m_lengthB;_this.m_impulse=0;return _this}PulleyJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,groundAnchorA:this.m_groundAnchorA,groundAnchorB:this.m_groundAnchorB,localAnchorA:this.m_localAnchorA,localAnchorB:this.m_localAnchorB,lengthA:this.m_lengthA,lengthB:this.m_lengthB,ratio:this.m_ratio}};PulleyJoint2._deserialize=function(data,world,restore){data=__assign({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);var joint=new PulleyJoint2(data);return joint};PulleyJoint2.prototype._reset=function(def){if(Vec2.isValid(def.groundAnchorA)){this.m_groundAnchorA.set(def.groundAnchorA)}if(Vec2.isValid(def.groundAnchorB)){this.m_groundAnchorB.set(def.groundAnchorB)}if(Vec2.isValid(def.localAnchorA)){this.m_localAnchorA.set(def.localAnchorA)}else if(Vec2.isValid(def.anchorA)){this.m_localAnchorA.set(this.m_bodyA.getLocalPoint(def.anchorA))}if(Vec2.isValid(def.localAnchorB)){this.m_localAnchorB.set(def.localAnchorB)}else if(Vec2.isValid(def.anchorB)){this.m_localAnchorB.set(this.m_bodyB.getLocalPoint(def.anchorB))}if(Number.isFinite(def.lengthA)){this.m_lengthA=def.lengthA}if(Number.isFinite(def.lengthB)){this.m_lengthB=def.lengthB}if(Number.isFinite(def.ratio)){this.m_ratio=def.ratio}};PulleyJoint2.prototype.getGroundAnchorA=function(){return this.m_groundAnchorA};PulleyJoint2.prototype.getGroundAnchorB=function(){return this.m_groundAnchorB};PulleyJoint2.prototype.getLengthA=function(){return this.m_lengthA};PulleyJoint2.prototype.getLengthB=function(){return this.m_lengthB};PulleyJoint2.prototype.getRatio=function(){return this.m_ratio};PulleyJoint2.prototype.getCurrentLengthA=function(){var p=this.m_bodyA.getWorldPoint(this.m_localAnchorA);var s2=this.m_groundAnchorA;return Vec2.distance(p,s2)};PulleyJoint2.prototype.getCurrentLengthB=function(){var p=this.m_bodyB.getWorldPoint(this.m_localAnchorB);var s2=this.m_groundAnchorB;return Vec2.distance(p,s2)};PulleyJoint2.prototype.shiftOrigin=function(newOrigin){this.m_groundAnchorA.sub(newOrigin);this.m_groundAnchorB.sub(newOrigin)};PulleyJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};PulleyJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};PulleyJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.mulNumVec2(this.m_impulse,this.m_uB).mul(inv_dt)};PulleyJoint2.prototype.getReactionTorque=function(inv_dt){return 0};PulleyJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter;this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);this.m_rA=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));this.m_rB=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));this.m_uA=Vec2.sub(Vec2.add(cA2,this.m_rA),this.m_groundAnchorA);this.m_uB=Vec2.sub(Vec2.add(cB2,this.m_rB),this.m_groundAnchorB);var lengthA=this.m_uA.length();var lengthB=this.m_uB.length();if(lengthA>10*SettingsInternal.linearSlop){this.m_uA.mul(1/lengthA)}else{this.m_uA.setZero()}if(lengthB>10*SettingsInternal.linearSlop){this.m_uB.mul(1/lengthB)}else{this.m_uB.setZero()}var ruA=Vec2.crossVec2Vec2(this.m_rA,this.m_uA);var ruB=Vec2.crossVec2Vec2(this.m_rB,this.m_uB);var mA=this.m_invMassA+this.m_invIA*ruA*ruA;var mB=this.m_invMassB+this.m_invIB*ruB*ruB;this.m_mass=mA+this.m_ratio*this.m_ratio*mB;if(this.m_mass>0){this.m_mass=1/this.m_mass}if(step.warmStarting){this.m_impulse*=step.dtRatio;var PA=Vec2.mulNumVec2(-this.m_impulse,this.m_uA);var PB=Vec2.mulNumVec2(-this.m_ratio*this.m_impulse,this.m_uB);vA2.addMul(this.m_invMassA,PA);wA+=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,PA);vB2.addMul(this.m_invMassB,PB);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,PB)}else{this.m_impulse=0}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};PulleyJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var vpA=Vec2.add(vA2,Vec2.crossNumVec2(wA,this.m_rA));var vpB=Vec2.add(vB2,Vec2.crossNumVec2(wB,this.m_rB));var Cdot=-Vec2.dot(this.m_uA,vpA)-this.m_ratio*Vec2.dot(this.m_uB,vpB);var impulse=-this.m_mass*Cdot;this.m_impulse+=impulse;var PA=Vec2.mulNumVec2(-impulse,this.m_uA);var PB=Vec2.mulNumVec2(-this.m_ratio*impulse,this.m_uB);vA2.addMul(this.m_invMassA,PA);wA+=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,PA);vB2.addMul(this.m_invMassB,PB);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,PB);this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};PulleyJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var uA=Vec2.sub(Vec2.add(cA2,this.m_rA),this.m_groundAnchorA);var uB=Vec2.sub(Vec2.add(cB2,this.m_rB),this.m_groundAnchorB);var lengthA=uA.length();var lengthB=uB.length();if(lengthA>10*SettingsInternal.linearSlop){uA.mul(1/lengthA)}else{uA.setZero()}if(lengthB>10*SettingsInternal.linearSlop){uB.mul(1/lengthB)}else{uB.setZero()}var ruA=Vec2.crossVec2Vec2(rA2,uA);var ruB=Vec2.crossVec2Vec2(rB2,uB);var mA=this.m_invMassA+this.m_invIA*ruA*ruA;var mB=this.m_invMassB+this.m_invIB*ruB*ruB;var mass=mA+this.m_ratio*this.m_ratio*mB;if(mass>0){mass=1/mass}var C=this.m_constant-lengthA-this.m_ratio*lengthB;var linearError=math_abs$2(C);var impulse=-mass*C;var PA=Vec2.mulNumVec2(-impulse,uA);var PB=Vec2.mulNumVec2(-this.m_ratio*impulse,uB);cA2.addMul(this.m_invMassA,PA);aA+=this.m_invIA*Vec2.crossVec2Vec2(rA2,PA);cB2.addMul(this.m_invMassB,PB);aB+=this.m_invIB*Vec2.crossVec2Vec2(rB2,PB);this.m_bodyA.c_position.c=cA2;this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c=cB2;this.m_bodyB.c_position.a=aB;return linearError0){this.m_state=LimitState.atUpperLimit}else{this.m_state=LimitState.inactiveLimit}if(this.m_length>SettingsInternal.linearSlop){this.m_u.mul(1/this.m_length)}else{this.m_u.setZero();this.m_mass=0;this.m_impulse=0;return}var crA=Vec2.crossVec2Vec2(this.m_rA,this.m_u);var crB=Vec2.crossVec2Vec2(this.m_rB,this.m_u);var invMass=this.m_invMassA+this.m_invIA*crA*crA+this.m_invMassB+this.m_invIB*crB*crB;this.m_mass=invMass!=0?1/invMass:0;if(step.warmStarting){this.m_impulse*=step.dtRatio;var P3=Vec2.mulNumVec2(this.m_impulse,this.m_u);vA2.subMul(this.m_invMassA,P3);wA-=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,P3);vB2.addMul(this.m_invMassB,P3);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,P3)}else{this.m_impulse=0}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};RopeJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var vpA=Vec2.addCrossNumVec2(vA2,wA,this.m_rA);var vpB=Vec2.addCrossNumVec2(vB2,wB,this.m_rB);var C=this.m_length-this.m_maxLength;var Cdot=Vec2.dot(this.m_u,Vec2.sub(vpB,vpA));if(C<0){Cdot+=step.inv_dt*C}var impulse=-this.m_mass*Cdot;var oldImpulse=this.m_impulse;this.m_impulse=math_min$1(0,this.m_impulse+impulse);impulse=this.m_impulse-oldImpulse;var P3=Vec2.mulNumVec2(impulse,this.m_u);vA2.subMul(this.m_invMassA,P3);wA-=this.m_invIA*Vec2.crossVec2Vec2(this.m_rA,P3);vB2.addMul(this.m_invMassB,P3);wB+=this.m_invIB*Vec2.crossVec2Vec2(this.m_rB,P3);this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};RopeJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulSub(qA,this.m_localAnchorA,this.m_localCenterA);var rB2=Rot.mulSub(qB,this.m_localAnchorB,this.m_localCenterB);var u=Vec2.zero();u.addCombine(1,cB2,1,rB2);u.subCombine(1,cA2,1,rA2);var length=u.normalize();var C=length-this.m_maxLength;C=clamp(C,0,SettingsInternal.maxLinearCorrection);var impulse=-this.m_mass*C;var P3=Vec2.mulNumVec2(impulse,u);cA2.subMul(this.m_invMassA,P3);aA-=this.m_invIA*Vec2.crossVec2Vec2(rA2,P3);cB2.addMul(this.m_invMassB,P3);aB+=this.m_invIB*Vec2.crossVec2Vec2(rB2,P3);this.m_bodyA.c_position.c.setVec2(cA2);this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c.setVec2(cB2);this.m_bodyB.c_position.a=aB;return length-this.m_maxLength0){K.getInverse22(this.m_mass);var invM=iA+iB;var m=invM>0?1/invM:0;var C=aB-aA-this.m_referenceAngle;var omega=2*math_PI$1*this.m_frequencyHz;var d2=2*m*this.m_dampingRatio*omega;var k=m*omega*omega;var h=step.dt;this.m_gamma=h*(d2+h*k);this.m_gamma=this.m_gamma!=0?1/this.m_gamma:0;this.m_bias=C*h*k*this.m_gamma;invM+=this.m_gamma;this.m_mass.ez.z=invM!=0?1/invM:0}else if(K.ez.z==0){K.getInverse22(this.m_mass);this.m_gamma=0;this.m_bias=0}else{K.getSymInverse33(this.m_mass);this.m_gamma=0;this.m_bias=0}if(step.warmStarting){this.m_impulse.mul(step.dtRatio);var P3=Vec2.neo(this.m_impulse.x,this.m_impulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+this.m_impulse.z);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+this.m_impulse.z)}else{this.m_impulse.setZero()}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};WeldJoint2.prototype.solveVelocityConstraints=function(step){var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;if(this.m_frequencyHz>0){var Cdot2=wB-wA;var impulse2=-this.m_mass.ez.z*(Cdot2+this.m_bias+this.m_gamma*this.m_impulse.z);this.m_impulse.z+=impulse2;wA-=iA*impulse2;wB+=iB*impulse2;var Cdot1=Vec2.zero();Cdot1.addCombine(1,vB2,1,Vec2.crossNumVec2(wB,this.m_rB));Cdot1.subCombine(1,vA2,1,Vec2.crossNumVec2(wA,this.m_rA));var impulse1=Vec2.neg(Mat33.mulVec2(this.m_mass,Cdot1));this.m_impulse.x+=impulse1.x;this.m_impulse.y+=impulse1.y;var P3=Vec2.clone(impulse1);vA2.subMul(mA,P3);wA-=iA*Vec2.crossVec2Vec2(this.m_rA,P3);vB2.addMul(mB,P3);wB+=iB*Vec2.crossVec2Vec2(this.m_rB,P3)}else{var Cdot1=Vec2.zero();Cdot1.addCombine(1,vB2,1,Vec2.crossNumVec2(wB,this.m_rB));Cdot1.subCombine(1,vA2,1,Vec2.crossNumVec2(wA,this.m_rA));var Cdot2=wB-wA;var Cdot=new Vec3(Cdot1.x,Cdot1.y,Cdot2);var impulse=Vec3.neg(Mat33.mulVec3(this.m_mass,Cdot));this.m_impulse.add(impulse);var P3=Vec2.neo(impulse.x,impulse.y);vA2.subMul(mA,P3);wA-=iA*(Vec2.crossVec2Vec2(this.m_rA,P3)+impulse.z);vB2.addMul(mB,P3);wB+=iB*(Vec2.crossVec2Vec2(this.m_rB,P3)+impulse.z)}this.m_bodyA.c_velocity.v=vA2;this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v=vB2;this.m_bodyB.c_velocity.w=wB};WeldJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var positionError;var angularError;var K=new Mat33;K.ex.x=mA+mB+rA2.y*rA2.y*iA+rB2.y*rB2.y*iB;K.ey.x=-rA2.y*rA2.x*iA-rB2.y*rB2.x*iB;K.ez.x=-rA2.y*iA-rB2.y*iB;K.ex.y=K.ey.x;K.ey.y=mA+mB+rA2.x*rA2.x*iA+rB2.x*rB2.x*iB;K.ez.y=rA2.x*iA+rB2.x*iB;K.ex.z=K.ez.x;K.ey.z=K.ez.y;K.ez.z=iA+iB;if(this.m_frequencyHz>0){var C1=Vec2.zero();C1.addCombine(1,cB2,1,rB2);C1.subCombine(1,cA2,1,rA2);positionError=C1.length();angularError=0;var P3=Vec2.neg(K.solve22(C1));cA2.subMul(mA,P3);aA-=iA*Vec2.crossVec2Vec2(rA2,P3);cB2.addMul(mB,P3);aB+=iB*Vec2.crossVec2Vec2(rB2,P3)}else{var C1=Vec2.zero();C1.addCombine(1,cB2,1,rB2);C1.subCombine(1,cA2,1,rA2);var C2=aB-aA-this.m_referenceAngle;positionError=C1.length();angularError=math_abs$1(C2);var C=new Vec3(C1.x,C1.y,C2);var impulse=new Vec3;if(K.ez.z>0){impulse=Vec3.neg(K.solve33(C))}else{var impulse2=Vec2.neg(K.solve22(C1));impulse.set(impulse2.x,impulse2.y,0)}var P3=Vec2.neo(impulse.x,impulse.y);cA2.subMul(mA,P3);aA-=iA*(Vec2.crossVec2Vec2(rA2,P3)+impulse.z);cB2.addMul(mB,P3);aB+=iB*(Vec2.crossVec2Vec2(rB2,P3)+impulse.z)}this.m_bodyA.c_position.c=cA2;this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c=cB2;this.m_bodyB.c_position.a=aB;return positionError<=SettingsInternal.linearSlop&&angularError<=SettingsInternal.angularSlop};WeldJoint2.TYPE="weld-joint";return WeldJoint2}(Joint);var math_abs=Math.abs;var math_PI=Math.PI;var DEFAULTS={enableMotor:false,maxMotorTorque:0,motorSpeed:0,frequencyHz:2,dampingRatio:.7};var WheelJoint=function(_super){__extends(WheelJoint2,_super);function WheelJoint2(def,bodyA,bodyB,anchor,axis){var _this=this;if(!(_this instanceof WheelJoint2)){return new WheelJoint2(def,bodyA,bodyB,anchor,axis)}def=options(def,DEFAULTS);_this=_super.call(this,def,bodyA,bodyB)||this;bodyA=_this.m_bodyA;bodyB=_this.m_bodyB;_this.m_ax=Vec2.zero();_this.m_ay=Vec2.zero();_this.m_type=WheelJoint2.TYPE;_this.m_localAnchorA=Vec2.clone(anchor?bodyA.getLocalPoint(anchor):def.localAnchorA||Vec2.zero());_this.m_localAnchorB=Vec2.clone(anchor?bodyB.getLocalPoint(anchor):def.localAnchorB||Vec2.zero());if(Vec2.isValid(axis)){_this.m_localXAxisA=bodyA.getLocalVector(axis)}else if(Vec2.isValid(def.localAxisA)){_this.m_localXAxisA=Vec2.clone(def.localAxisA)}else if(Vec2.isValid(def.localAxis)){_this.m_localXAxisA=Vec2.clone(def.localAxis)}else{_this.m_localXAxisA=Vec2.neo(1,0)}_this.m_localYAxisA=Vec2.crossNumVec2(1,_this.m_localXAxisA);_this.m_mass=0;_this.m_impulse=0;_this.m_motorMass=0;_this.m_motorImpulse=0;_this.m_springMass=0;_this.m_springImpulse=0;_this.m_maxMotorTorque=def.maxMotorTorque;_this.m_motorSpeed=def.motorSpeed;_this.m_enableMotor=def.enableMotor;_this.m_frequencyHz=def.frequencyHz;_this.m_dampingRatio=def.dampingRatio;_this.m_bias=0;_this.m_gamma=0;return _this}WheelJoint2.prototype._serialize=function(){return{type:this.m_type,bodyA:this.m_bodyA,bodyB:this.m_bodyB,collideConnected:this.m_collideConnected,enableMotor:this.m_enableMotor,maxMotorTorque:this.m_maxMotorTorque,motorSpeed:this.m_motorSpeed,frequencyHz:this.m_frequencyHz,dampingRatio:this.m_dampingRatio,localAnchorA:this.m_localAnchorA,localAnchorB:this.m_localAnchorB,localAxisA:this.m_localXAxisA}};WheelJoint2._deserialize=function(data,world,restore){data=__assign({},data);data.bodyA=restore(Body,data.bodyA,world);data.bodyB=restore(Body,data.bodyB,world);var joint=new WheelJoint2(data);return joint};WheelJoint2.prototype._reset=function(def){if(def.anchorA){this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA))}else if(def.localAnchorA){this.m_localAnchorA.setVec2(def.localAnchorA)}if(def.anchorB){this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB))}else if(def.localAnchorB){this.m_localAnchorB.setVec2(def.localAnchorB)}if(def.localAxisA){this.m_localXAxisA.setVec2(def.localAxisA);this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1,def.localAxisA))}if(def.enableMotor!==void 0){this.m_enableMotor=def.enableMotor}if(Number.isFinite(def.maxMotorTorque)){this.m_maxMotorTorque=def.maxMotorTorque}if(Number.isFinite(def.motorSpeed)){this.m_motorSpeed=def.motorSpeed}if(Number.isFinite(def.frequencyHz)){this.m_frequencyHz=def.frequencyHz}if(Number.isFinite(def.dampingRatio)){this.m_dampingRatio=def.dampingRatio}};WheelJoint2.prototype.getLocalAnchorA=function(){return this.m_localAnchorA};WheelJoint2.prototype.getLocalAnchorB=function(){return this.m_localAnchorB};WheelJoint2.prototype.getLocalAxisA=function(){return this.m_localXAxisA};WheelJoint2.prototype.getJointTranslation=function(){var bA=this.m_bodyA;var bB=this.m_bodyB;var pA2=bA.getWorldPoint(this.m_localAnchorA);var pB2=bB.getWorldPoint(this.m_localAnchorB);var d2=Vec2.sub(pB2,pA2);var axis=bA.getWorldVector(this.m_localXAxisA);var translation2=Vec2.dot(d2,axis);return translation2};WheelJoint2.prototype.getJointSpeed=function(){var wA=this.m_bodyA.m_angularVelocity;var wB=this.m_bodyB.m_angularVelocity;return wB-wA};WheelJoint2.prototype.isMotorEnabled=function(){return this.m_enableMotor};WheelJoint2.prototype.enableMotor=function(flag){if(flag==this.m_enableMotor)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_enableMotor=flag};WheelJoint2.prototype.setMotorSpeed=function(speed){if(speed==this.m_motorSpeed)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_motorSpeed=speed};WheelJoint2.prototype.getMotorSpeed=function(){return this.m_motorSpeed};WheelJoint2.prototype.setMaxMotorTorque=function(torque){if(torque==this.m_maxMotorTorque)return;this.m_bodyA.setAwake(true);this.m_bodyB.setAwake(true);this.m_maxMotorTorque=torque};WheelJoint2.prototype.getMaxMotorTorque=function(){return this.m_maxMotorTorque};WheelJoint2.prototype.getMotorTorque=function(inv_dt){return inv_dt*this.m_motorImpulse};WheelJoint2.prototype.setSpringFrequencyHz=function(hz){this.m_frequencyHz=hz};WheelJoint2.prototype.getSpringFrequencyHz=function(){return this.m_frequencyHz};WheelJoint2.prototype.setSpringDampingRatio=function(ratio){this.m_dampingRatio=ratio};WheelJoint2.prototype.getSpringDampingRatio=function(){return this.m_dampingRatio};WheelJoint2.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)};WheelJoint2.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)};WheelJoint2.prototype.getReactionForce=function(inv_dt){return Vec2.combine(this.m_impulse,this.m_ay,this.m_springImpulse,this.m_ax).mul(inv_dt)};WheelJoint2.prototype.getReactionTorque=function(inv_dt){return inv_dt*this.m_motorImpulse};WheelJoint2.prototype.initVelocityConstraints=function(step){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter;this.m_localCenterB=this.m_bodyB.m_sweep.localCenter;this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var d2=Vec2.zero();d2.addCombine(1,cB2,1,rB2);d2.subCombine(1,cA2,1,rA2);{this.m_ay=Rot.mulVec2(qA,this.m_localYAxisA);this.m_sAy=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),this.m_ay);this.m_sBy=Vec2.crossVec2Vec2(rB2,this.m_ay);this.m_mass=mA+mB+iA*this.m_sAy*this.m_sAy+iB*this.m_sBy*this.m_sBy;if(this.m_mass>0){this.m_mass=1/this.m_mass}}this.m_springMass=0;this.m_bias=0;this.m_gamma=0;if(this.m_frequencyHz>0){this.m_ax=Rot.mulVec2(qA,this.m_localXAxisA);this.m_sAx=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),this.m_ax);this.m_sBx=Vec2.crossVec2Vec2(rB2,this.m_ax);var invMass=mA+mB+iA*this.m_sAx*this.m_sAx+iB*this.m_sBx*this.m_sBx;if(invMass>0){this.m_springMass=1/invMass;var C=Vec2.dot(d2,this.m_ax);var omega=2*math_PI*this.m_frequencyHz;var damp=2*this.m_springMass*this.m_dampingRatio*omega;var k=this.m_springMass*omega*omega;var h=step.dt;this.m_gamma=h*(damp+h*k);if(this.m_gamma>0){this.m_gamma=1/this.m_gamma}this.m_bias=C*h*k*this.m_gamma;this.m_springMass=invMass+this.m_gamma;if(this.m_springMass>0){this.m_springMass=1/this.m_springMass}}}else{this.m_springImpulse=0}if(this.m_enableMotor){this.m_motorMass=iA+iB;if(this.m_motorMass>0){this.m_motorMass=1/this.m_motorMass}}else{this.m_motorMass=0;this.m_motorImpulse=0}if(step.warmStarting){this.m_impulse*=step.dtRatio;this.m_springImpulse*=step.dtRatio;this.m_motorImpulse*=step.dtRatio;var P3=Vec2.combine(this.m_impulse,this.m_ay,this.m_springImpulse,this.m_ax);var LA=this.m_impulse*this.m_sAy+this.m_springImpulse*this.m_sAx+this.m_motorImpulse;var LB=this.m_impulse*this.m_sBy+this.m_springImpulse*this.m_sBx+this.m_motorImpulse;vA2.subMul(this.m_invMassA,P3);wA-=this.m_invIA*LA;vB2.addMul(this.m_invMassB,P3);wB+=this.m_invIB*LB}else{this.m_impulse=0;this.m_springImpulse=0;this.m_motorImpulse=0}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};WheelJoint2.prototype.solveVelocityConstraints=function(step){var mA=this.m_invMassA;var mB=this.m_invMassB;var iA=this.m_invIA;var iB=this.m_invIB;var vA2=this.m_bodyA.c_velocity.v;var wA=this.m_bodyA.c_velocity.w;var vB2=this.m_bodyB.c_velocity.v;var wB=this.m_bodyB.c_velocity.w;{var Cdot=Vec2.dot(this.m_ax,vB2)-Vec2.dot(this.m_ax,vA2)+this.m_sBx*wB-this.m_sAx*wA;var impulse=-this.m_springMass*(Cdot+this.m_bias+this.m_gamma*this.m_springImpulse);this.m_springImpulse+=impulse;var P3=Vec2.mulNumVec2(impulse,this.m_ax);var LA=impulse*this.m_sAx;var LB=impulse*this.m_sBx;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}{var Cdot=wB-wA-this.m_motorSpeed;var impulse=-this.m_motorMass*Cdot;var oldImpulse=this.m_motorImpulse;var maxImpulse=step.dt*this.m_maxMotorTorque;this.m_motorImpulse=clamp(this.m_motorImpulse+impulse,-maxImpulse,maxImpulse);impulse=this.m_motorImpulse-oldImpulse;wA-=iA*impulse;wB+=iB*impulse}{var Cdot=Vec2.dot(this.m_ay,vB2)-Vec2.dot(this.m_ay,vA2)+this.m_sBy*wB-this.m_sAy*wA;var impulse=-this.m_mass*Cdot;this.m_impulse+=impulse;var P3=Vec2.mulNumVec2(impulse,this.m_ay);var LA=impulse*this.m_sAy;var LB=impulse*this.m_sBy;vA2.subMul(mA,P3);wA-=iA*LA;vB2.addMul(mB,P3);wB+=iB*LB}this.m_bodyA.c_velocity.v.setVec2(vA2);this.m_bodyA.c_velocity.w=wA;this.m_bodyB.c_velocity.v.setVec2(vB2);this.m_bodyB.c_velocity.w=wB};WheelJoint2.prototype.solvePositionConstraints=function(step){var cA2=this.m_bodyA.c_position.c;var aA=this.m_bodyA.c_position.a;var cB2=this.m_bodyB.c_position.c;var aB=this.m_bodyB.c_position.a;var qA=Rot.neo(aA);var qB=Rot.neo(aB);var rA2=Rot.mulVec2(qA,Vec2.sub(this.m_localAnchorA,this.m_localCenterA));var rB2=Rot.mulVec2(qB,Vec2.sub(this.m_localAnchorB,this.m_localCenterB));var d2=Vec2.zero();d2.addCombine(1,cB2,1,rB2);d2.subCombine(1,cA2,1,rA2);var ay=Rot.mulVec2(qA,this.m_localYAxisA);var sAy=Vec2.crossVec2Vec2(Vec2.add(d2,rA2),ay);var sBy=Vec2.crossVec2Vec2(rB2,ay);var C=Vec2.dot(d2,ay);var k=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_sAy*this.m_sAy+this.m_invIB*this.m_sBy*this.m_sBy;var impulse=k!=0?-C/k:0;var P3=Vec2.mulNumVec2(impulse,ay);var LA=impulse*sAy;var LB=impulse*sBy;cA2.subMul(this.m_invMassA,P3);aA-=this.m_invIA*LA;cB2.addMul(this.m_invMassB,P3);aB+=this.m_invIB*LB;this.m_bodyA.c_position.c.setVec2(cA2);this.m_bodyA.c_position.a=aA;this.m_bodyB.c_position.c.setVec2(cB2);this.m_bodyB.c_position.a=aB;return math_abs(C)<=SettingsInternal.linearSlop};WheelJoint2.TYPE="wheel-joint";return WheelJoint2}(Joint);var _a;var SID=0;var SERIALIZE_REF_TYPES={World:World,Body:Body,Joint:Joint,Fixture:Fixture,Shape:Shape};var DESERIALIZE_BY_REF_TYPE={Vec2:Vec2,Vec3:Vec3,World:World,Body:Body,Joint:Joint,Fixture:Fixture,Shape:Shape};var DESERIALIZE_BY_TYPE_FIELD=(_a={},_a[Body.STATIC]=Body,_a[Body.DYNAMIC]=Body,_a[Body.KINEMATIC]=Body,_a[ChainShape.TYPE]=ChainShape,_a[PolygonShape.TYPE]=PolygonShape,_a[EdgeShape.TYPE]=EdgeShape,_a[CircleShape.TYPE]=CircleShape,_a[DistanceJoint.TYPE]=DistanceJoint,_a[FrictionJoint.TYPE]=FrictionJoint,_a[GearJoint.TYPE]=GearJoint,_a[MotorJoint.TYPE]=MotorJoint,_a[MouseJoint.TYPE]=MouseJoint,_a[PrismaticJoint.TYPE]=PrismaticJoint,_a[PulleyJoint.TYPE]=PulleyJoint,_a[RevoluteJoint.TYPE]=RevoluteJoint,_a[RopeJoint.TYPE]=RopeJoint,_a[WeldJoint.TYPE]=WeldJoint,_a[WheelJoint.TYPE]=WheelJoint,_a);var DEFAULT_OPTIONS={rootClass:World,preSerialize:function(obj){return obj},postSerialize:function(data,obj){return data},preDeserialize:function(data){return data},postDeserialize:function(obj,data){return obj}};var Serializer=function(){function Serializer2(options2){var _this=this;this.toJson=function(root){var preSerialize=_this.options.preSerialize;var postSerialize=_this.options.postSerialize;var json=[];var refQueue=[root];var refMemoById={};function addToRefQueue(value,typeName){value.__sid=value.__sid||++SID;if(!refMemoById[value.__sid]){refQueue.push(value);var index=json.length+refQueue.length;var ref={refIndex:index,refType:typeName};refMemoById[value.__sid]=ref}return refMemoById[value.__sid]}function serializeWithHooks(obj2){obj2=preSerialize(obj2);var data=obj2._serialize();data=postSerialize(data,obj2);return data}function traverse(value,noRefType){if(noRefType===void 0){noRefType=false}if(typeof value!=="object"||value===null){return value}if(typeof value._serialize==="function"){if(!noRefType){for(var typeName in SERIALIZE_REF_TYPES){if(value instanceof SERIALIZE_REF_TYPES[typeName]){return addToRefQueue(value,typeName)}}}value=serializeWithHooks(value)}if(Array.isArray(value)){var newValue=[];for(var key=0;keyradius*radius){return}manifold.type=exports2.ManifoldType.e_circles;copyVec2(manifold.localPoint,circleA.m_p);zeroVec2(manifold.localNormal);manifold.pointCount=1;copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex)};Contact.addType(EdgeShape.TYPE,CircleShape.TYPE,EdgeCircleContact);Contact.addType(ChainShape.TYPE,CircleShape.TYPE,ChainCircleContact);function EdgeCircleContact(manifold,xfA2,fixtureA,indexA,xfB2,fixtureB,indexB){var shapeA=fixtureA.getShape();var shapeB=fixtureB.getShape();CollideEdgeCircle(manifold,shapeA,xfA2,shapeB,xfB2)}function ChainCircleContact(manifold,xfA2,fixtureA,indexA,xfB2,fixtureB,indexB){var chain=fixtureA.getShape();var edge=new EdgeShape;chain.getChildEdge(edge,indexA);var shapeA=edge;var shapeB=fixtureB.getShape();CollideEdgeCircle(manifold,shapeA,xfA2,shapeB,xfB2)}var e=vec2(0,0);var e1=vec2(0,0);var e2=vec2(0,0);var Q=vec2(0,0);var P=vec2(0,0);var n$2=vec2(0,0);var CollideEdgeCircle=function(manifold,edgeA,xfA2,circleB,xfB2){manifold.pointCount=0;retransformVec2(Q,xfB2,xfA2,circleB.m_p);var A=edgeA.m_vertex1;var B=edgeA.m_vertex2;subVec2(e,B,A);var u=dotVec2(e,B)-dotVec2(e,Q);var v3=dotVec2(e,Q)-dotVec2(e,A);var radius=edgeA.m_radius+circleB.m_radius;if(v3<=0){copyVec2(P,A);var dd_1=distSqrVec2(Q,A);if(dd_1>radius*radius){return}if(edgeA.m_hasVertex0){var A1=edgeA.m_vertex0;var B1=A;subVec2(e1,B1,A1);var u1=dotVec2(e1,B1)-dotVec2(e1,Q);if(u1>0){return}}manifold.type=exports2.ManifoldType.e_circles;zeroVec2(manifold.localNormal);copyVec2(manifold.localPoint,P);manifold.pointCount=1;copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex);return}if(u<=0){copyVec2(P,B);var dd_2=distSqrVec2(Q,P);if(dd_2>radius*radius){return}if(edgeA.m_hasVertex3){var B2=edgeA.m_vertex3;var A2=B;subVec2(e2,B2,A2);var v22=dotVec2(e2,Q)-dotVec2(e2,A2);if(v22>0){return}}manifold.type=exports2.ManifoldType.e_circles;zeroVec2(manifold.localNormal);copyVec2(manifold.localPoint,P);manifold.pointCount=1;copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(1,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex);return}var den=lengthSqrVec2(e);combine2Vec2(P,u/den,A,v3/den,B);var dd=distSqrVec2(Q,P);if(dd>radius*radius){return}crossNumVec2(n$2,1,e);if(dotVec2(n$2,Q)-dotVec2(n$2,A)<0){negVec2(n$2)}normalizeVec2(n$2);manifold.type=exports2.ManifoldType.e_faceA;copyVec2(manifold.localNormal,n$2);copyVec2(manifold.localPoint,A);manifold.pointCount=1;copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_face,0,exports2.ContactFeatureType.e_vertex)};var incidentEdge=[new ClipVertex,new ClipVertex];var clipPoints1$1=[new ClipVertex,new ClipVertex];var clipPoints2$1=[new ClipVertex,new ClipVertex];var clipSegmentToLineNormal=vec2(0,0);var v1=vec2(0,0);var n$1=vec2(0,0);var xf$1=transform(0,0,0);var v11=vec2(0,0);var v12=vec2(0,0);var localTangent=vec2(0,0);var localNormal=vec2(0,0);var planePoint=vec2(0,0);var tangent=vec2(0,0);var normal$1=vec2(0,0);var normal1$1=vec2(0,0);Contact.addType(PolygonShape.TYPE,PolygonShape.TYPE,PolygonContact);function PolygonContact(manifold,xfA2,fixtureA,indexA,xfB2,fixtureB,indexB){CollidePolygons(manifold,fixtureA.getShape(),xfA2,fixtureB.getShape(),xfB2)}function findMaxSeparation(poly1,xf1,poly2,xf2,output2){var count1=poly1.m_count;var count2=poly2.m_count;var n1s=poly1.m_normals;var v1s=poly1.m_vertices;var v2s=poly2.m_vertices;detransformTransform(xf$1,xf2,xf1);var bestIndex=0;var maxSeparation2=-Infinity;for(var i=0;imaxSeparation2){maxSeparation2=si;bestIndex=i}}output2.maxSeparation=maxSeparation2;output2.bestIndex=bestIndex}function findIncidentEdge(clipVertex,poly1,xf1,edge12,poly2,xf2){var normals1=poly1.m_normals;var count2=poly2.m_count;var vertices2=poly2.m_vertices;var normals2=poly2.m_normals;rerotVec2(normal1$1,xf2.q,xf1.q,normals1[edge12]);var index=0;var minDot=Infinity;for(var i=0;itotalRadius)return;findMaxSeparation(polyB,xfB2,polyA,xfA2,maxSeparation);var edgeB=maxSeparation.bestIndex;var separationB=maxSeparation.maxSeparation;if(separationB>totalRadius)return;var poly1;var poly2;var xf1;var xf2;var edge12;var flip;var k_tol=.1*SettingsInternal.linearSlop;if(separationB>separationA+k_tol){poly1=polyB;poly2=polyA;xf1=xfB2;xf2=xfA2;edge12=edgeB;manifold.type=exports2.ManifoldType.e_faceB;flip=true}else{poly1=polyA;poly2=polyB;xf1=xfA2;xf2=xfB2;edge12=edgeA;manifold.type=exports2.ManifoldType.e_faceA;flip=false}incidentEdge[0].recycle();incidentEdge[1].recycle();findIncidentEdge(incidentEdge,poly1,xf1,edge12,poly2,xf2);var count1=poly1.m_count;var vertices1=poly1.m_vertices;var iv1=edge12;var iv2=edge12+1radius){return}if(s2>separation){separation=s2;normalIndex=i}}var vertIndex1=normalIndex;var vertIndex2=vertIndex1+1radius*radius){return}manifold.pointCount=1;manifold.type=exports2.ManifoldType.e_faceA;subVec2(manifold.localNormal,cLocal,v13);normalizeVec2(manifold.localNormal);copyVec2(manifold.localPoint,v13);copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex)}else if(u2<=0){if(distSqrVec2(cLocal,v22)>radius*radius){return}manifold.pointCount=1;manifold.type=exports2.ManifoldType.e_faceA;subVec2(manifold.localNormal,cLocal,v22);normalizeVec2(manifold.localNormal);copyVec2(manifold.localPoint,v22);copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex)}else{combine2Vec2(faceCenter,.5,v13,.5,v22);var separation_1=dotVec2(cLocal,normals[vertIndex1])-dotVec2(faceCenter,normals[vertIndex1]);if(separation_1>radius){return}manifold.pointCount=1;manifold.type=exports2.ManifoldType.e_faceA;copyVec2(manifold.localNormal,normals[vertIndex1]);copyVec2(manifold.localPoint,faceCenter);copyVec2(manifold.points[0].localPoint,circleB.m_p);manifold.points[0].id.setFeatures(0,exports2.ContactFeatureType.e_vertex,0,exports2.ContactFeatureType.e_vertex)}};var math_min=Math.min;Contact.addType(EdgeShape.TYPE,PolygonShape.TYPE,EdgePolygonContact);Contact.addType(ChainShape.TYPE,PolygonShape.TYPE,ChainPolygonContact);function EdgePolygonContact(manifold,xfA2,fA,indexA,xfB2,fB,indexB){CollideEdgePolygon(manifold,fA.getShape(),xfA2,fB.getShape(),xfB2)}var edge_reuse=new EdgeShape;function ChainPolygonContact(manifold,xfA2,fA,indexA,xfB2,fB,indexB){var chain=fA.getShape();chain.getChildEdge(edge_reuse,indexA);CollideEdgePolygon(manifold,edge_reuse,xfA2,fB.getShape(),xfB2)}var EPAxisType;(function(EPAxisType2){EPAxisType2[EPAxisType2["e_unknown"]=-1]="e_unknown";EPAxisType2[EPAxisType2["e_edgeA"]=1]="e_edgeA";EPAxisType2[EPAxisType2["e_edgeB"]=2]="e_edgeB"})(EPAxisType||(EPAxisType={}));var VertexType;(function(VertexType2){VertexType2[VertexType2["e_isolated"]=0]="e_isolated";VertexType2[VertexType2["e_concave"]=1]="e_concave";VertexType2[VertexType2["e_convex"]=2]="e_convex"})(VertexType||(VertexType={}));var EPAxis=function(){function EPAxis2(){}return EPAxis2}();var TempPolygon=function(){function TempPolygon2(){this.vertices=[];this.normals=[];this.count=0;for(var i=0;i=0;offset0=Vec2.dot(normal0,centroidB)-Vec2.dot(normal0,v0)}if(hasVertex3){subVec2(edge2,v3,v22);normalizeVec2(edge2);setVec2(normal2,edge2.y,-edge2.x);convex2=Vec2.crossVec2Vec2(edge1,edge2)>0;offset2=Vec2.dot(normal2,centroidB)-Vec2.dot(normal2,v22)}var front;zeroVec2(normal);zeroVec2(lowerLimit);zeroVec2(upperLimit);if(hasVertex0&&hasVertex3){if(convex1&&convex2){front=offset0>=0||offset1>=0||offset2>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal0);copyVec2(upperLimit,normal2)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal1);scaleVec2(upperLimit,-1,normal1)}}else if(convex1){front=offset0>=0||offset1>=0&&offset2>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal0);copyVec2(upperLimit,normal1)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal2);scaleVec2(upperLimit,-1,normal1)}}else if(convex2){front=offset2>=0||offset0>=0&&offset1>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal1);copyVec2(upperLimit,normal2)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal1);scaleVec2(upperLimit,-1,normal0)}}else{front=offset0>=0&&offset1>=0&&offset2>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal1);copyVec2(upperLimit,normal1)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal2);scaleVec2(upperLimit,-1,normal0)}}}else if(hasVertex0){if(convex1){front=offset0>=0||offset1>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal0);scaleVec2(upperLimit,-1,normal1)}else{scaleVec2(normal,-1,normal1);copyVec2(lowerLimit,normal1);scaleVec2(upperLimit,-1,normal1)}}else{front=offset0>=0&&offset1>=0;if(front){copyVec2(normal,normal1);copyVec2(lowerLimit,normal1);scaleVec2(upperLimit,-1,normal1)}else{scaleVec2(normal,-1,normal1);copyVec2(lowerLimit,normal1);scaleVec2(upperLimit,-1,normal0)}}}else if(hasVertex3){if(convex2){front=offset1>=0||offset2>=0;if(front){copyVec2(normal,normal1);scaleVec2(lowerLimit,-1,normal1);copyVec2(upperLimit,normal2)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal1);copyVec2(upperLimit,normal1)}}else{front=offset1>=0&&offset2>=0;if(front){copyVec2(normal,normal1);scaleVec2(lowerLimit,-1,normal1);copyVec2(upperLimit,normal1)}else{scaleVec2(normal,-1,normal1);scaleVec2(lowerLimit,-1,normal2);copyVec2(upperLimit,normal1)}}}else{front=offset1>=0;if(front){copyVec2(normal,normal1);scaleVec2(lowerLimit,-1,normal1);scaleVec2(upperLimit,-1,normal1)}else{scaleVec2(normal,-1,normal1);copyVec2(lowerLimit,normal1);copyVec2(upperLimit,normal1)}}polygonBA.count=polygonB.m_count;for(var i=0;iradius){return}{polygonAxis.type=EPAxisType.e_unknown;polygonAxis.index=-1;polygonAxis.separation=-Infinity;setVec2(perp,-normal.y,normal.x);for(var i=0;iradius){polygonAxis.type=EPAxisType.e_edgeB;polygonAxis.index=i;polygonAxis.separation=s2;break}if(dotVec2(n,perp)>=0){if(dotVec2(n,normal)-dotVec2(upperLimit,normal)<-SettingsInternal.angularSlop){continue}}else{if(dotVec2(n,normal)-dotVec2(lowerLimit,normal)<-SettingsInternal.angularSlop){continue}}if(s2>polygonAxis.separation){polygonAxis.type=EPAxisType.e_edgeB;polygonAxis.index=i;polygonAxis.separation=s2}}}if(polygonAxis.type!=EPAxisType.e_unknown&&polygonAxis.separation>radius){return}var k_relativeTol=.98;var k_absoluteTol=.001;var primaryAxis;if(polygonAxis.type==EPAxisType.e_unknown){primaryAxis=edgeAxis}else if(polygonAxis.separation>k_relativeTol*edgeAxis.separation+k_absoluteTol){primaryAxis=polygonAxis}else{primaryAxis=edgeAxis}ie[0].recycle();ie[1].recycle();if(primaryAxis.type==EPAxisType.e_edgeA){manifold.type=exports2.ManifoldType.e_faceA;var bestIndex=0;var bestValue=dotVec2(normal,polygonBA.normals[0]);for(var i=1;i= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from) {\r\n for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)\r\n to[j] = from[i];\r\n return to;\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","/** @internal */\nexport const options = function(input: T, defaults: object): T {\n if (input === null || typeof input === \"undefined\") {\n // tslint:disable-next-line:no-object-literal-type-assertion\n input = {} as T;\n }\n\n const output = {...input};\n\n // tslint:disable-next-line:no-for-in\n for (const key in defaults) {\n if (defaults.hasOwnProperty(key) && typeof input[key] === \"undefined\") {\n output[key] = defaults[key];\n }\n }\n\n if (typeof Object.getOwnPropertySymbols === \"function\") {\n const symbols = Object.getOwnPropertySymbols(defaults);\n for (let i = 0; i < symbols.length; i++) {\n const symbol = symbols[i];\n if (defaults.propertyIsEnumerable(symbol) && typeof input[symbol] === \"undefined\") {\n output[symbol] = defaults[symbol];\n }\n }\n }\n\n return output;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_random = Math.random;\n\n\nexport const EPSILON = 1e-9;\n\n/** @internal @deprecated */\nexport const isFinite = Number.isFinite;\n\n/**\n * @deprecated\n * Next Largest Power of 2 Given a binary integer value x, the next largest\n * power of 2 can be computed by a SWAR algorithm that recursively \"folds\" the\n * upper bits into the lower bits. This process yields a bit vector with the\n * same most significant 1 as x, but all 1's below it. Adding 1 to that value\n * yields the next largest power of 2. For a 32-bit value:\n */\nexport function nextPowerOfTwo(x: number): number {\n x |= (x >> 1);\n x |= (x >> 2);\n x |= (x >> 4);\n x |= (x >> 8);\n x |= (x >> 16);\n return x + 1;\n}\n\n/** @deprecated */\nexport function isPowerOfTwo(x: number): boolean {\n return x > 0 && (x & (x - 1)) === 0;\n}\n\n/** @deprecated */\nexport function mod(num: number, min?: number, max?: number): number {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n if (max > min) {\n num = (num - min) % (max - min);\n return num + (num < 0 ? max : min);\n } else {\n num = (num - max) % (min - max);\n return num + (num <= 0 ? min : max);\n }\n}\n\n/**\n * @deprecated\n * Returns a min if num is less than min, and max if more than max, otherwise returns num.\n */\nexport function clamp(num: number, min: number, max: number): number {\n if (num < min) {\n return min;\n } else if (num > max) {\n return max;\n } else {\n return num;\n }\n}\n\n/**\n * @deprecated\n * Returns a random number between min and max when two arguments are provided.\n * If one arg is provided between 0 to max.\n * If one arg is passed between 0 to 1.\n */\nexport function random(min?: number, max?: number): number {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n return min === max ? min : math_random() * (max - min) + min;\n}\n\n/** @ignore */\nexport const math = Object.create(Math);\nmath.EPSILON = EPSILON;\nmath.isFinite = isFinite;\nmath.nextPowerOfTwo = nextPowerOfTwo;\nmath.isPowerOfTwo = isPowerOfTwo;\nmath.mod = mod;\nmath.clamp = clamp;\nmath.random = random;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { clamp, EPSILON } from \"./Math\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/** 2D vector */\nexport interface Vec2Value {\n x: number;\n y: number;\n}\n\ndeclare module \"./Vec2\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(x: number, y: number): Vec2;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(obj: Vec2Value): Vec2;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(): Vec2;\n}\n\n/** 2D vector */\n// @ts-expect-error\nexport class Vec2 {\n x: number;\n y: number;\n\n constructor(x: number, y: number);\n constructor(obj: Vec2Value);\n constructor();\n // tslint:disable-next-line:typedef\n constructor(x?, y?) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Vec2)) {\n return new Vec2(x, y);\n }\n if (typeof x === \"undefined\") {\n this.x = 0;\n this.y = 0;\n } else if (typeof x === \"object\") {\n this.x = x.x;\n this.y = x.y;\n } else {\n this.x = x;\n this.y = y;\n }\n if (_ASSERT) Vec2.assert(this);\n }\n\n /** @internal */\n _serialize(): object {\n return {\n x: this.x,\n y: this.y\n };\n }\n\n /** @internal */\n static _deserialize(data: any): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = data.x;\n obj.y = data.y;\n return obj;\n }\n\n static zero(): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = 0;\n obj.y = 0;\n return obj;\n }\n\n /** @hidden */\n static neo(x: number, y: number): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = x;\n obj.y = y;\n return obj;\n }\n\n static clone(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(v.x, v.y);\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n /**\n * Does this vector contain finite coordinates?\n */\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.x) && Number.isFinite(obj.y);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Vec2.isValid(o), \"Invalid Vec2!\", o);\n }\n\n clone(): Vec2 {\n return Vec2.clone(this);\n }\n\n /**\n * Set this vector to all zeros.\n *\n * @returns this\n */\n setZero(): Vec2 {\n this.x = 0.0;\n this.y = 0.0;\n return this;\n }\n\n set(x: number, y: number): Vec2;\n set(value: Vec2Value): Vec2;\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n // tslint:disable-next-line:typedef\n set(x, y?) {\n if (typeof x === \"object\") {\n if (_ASSERT) Vec2.assert(x);\n this.x = x.x;\n this.y = x.y;\n } else {\n if (_ASSERT) console.assert(Number.isFinite(x));\n if (_ASSERT) console.assert(Number.isFinite(y));\n this.x = x;\n this.y = y;\n }\n return this;\n }\n\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n setNum(x: number, y: number) {\n if (_ASSERT) console.assert(Number.isFinite(x));\n if (_ASSERT) console.assert(Number.isFinite(y));\n this.x = x;\n this.y = y;\n\n return this;\n }\n\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n setVec2(value: Vec2Value) {\n if (_ASSERT) Vec2.assert(value);\n this.x = value.x;\n this.y = value.y;\n\n return this;\n }\n\n /** @internal @deprecated Use setCombine or setMul */\n wSet(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.setCombine(a, v, b, w);\n } else {\n return this.setMul(a, v);\n }\n }\n\n /**\n * Set linear combination of v and w: `a * v + b * w`\n */\n setCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x = x;\n this.y = y;\n return this;\n }\n\n setMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x = x;\n this.y = y;\n return this;\n }\n\n /**\n * Add a vector to this vector.\n *\n * @returns this\n */\n add(w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(w);\n this.x += w.x;\n this.y += w.y;\n return this;\n }\n\n /** @internal @deprecated Use addCombine or addMul */\n wAdd(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.addCombine(a, v, b, w);\n } else {\n return this.addMul(a, v);\n }\n }\n\n /**\n * Add linear combination of v and w: `a * v + b * w`\n */\n addCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x += x;\n this.y += y;\n return this;\n }\n\n addMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x += x;\n this.y += y;\n return this;\n }\n\n /**\n * @deprecated Use subCombine or subMul\n */\n wSub(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.subCombine(a, v, b, w);\n } else {\n return this.subMul(a, v);\n }}\n\n /**\n * Subtract linear combination of v and w: `a * v + b * w`\n */\n subCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x -= x;\n this.y -= y;\n return this;\n }\n\n subMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x -= x;\n this.y -= y;\n return this;\n }\n\n /**\n * Subtract a vector from this vector\n *\n * @returns this\n */\n sub(w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(w);\n this.x -= w.x;\n this.y -= w.y;\n return this;\n }\n\n /**\n * Multiply this vector by a scalar.\n *\n * @returns this\n */\n mul(m: number): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(m));\n this.x *= m;\n this.y *= m;\n return this;\n }\n\n /**\n * Get the length of this vector (the norm).\n *\n * For performance, use this instead of lengthSquared (if possible).\n */\n length(): number {\n return Vec2.lengthOf(this);\n }\n\n /**\n * Get the length squared.\n */\n lengthSquared(): number {\n return Vec2.lengthSquared(this);\n }\n\n /**\n * Convert this vector into a unit vector.\n *\n * @returns old length\n */\n normalize(): number {\n const length = this.length();\n if (length < EPSILON) {\n return 0.0;\n }\n const invLength = 1.0 / length;\n this.x *= invLength;\n this.y *= invLength;\n return length;\n }\n\n /**\n * Returns a new unit vector from the provided vector.\n *\n * @returns new unit vector\n */\n static normalize(v: Vec2Value): Vec2 {\n const length = Vec2.lengthOf(v);\n if (length < EPSILON) {\n return Vec2.zero();\n }\n const invLength = 1.0 / length;\n return Vec2.neo(v.x * invLength, v.y * invLength);\n }\n\n /**\n * Get the length of this vector (the norm).\n *\n * For performance, use this instead of lengthSquared (if possible).\n */\n static lengthOf(v: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n return math_sqrt(v.x * v.x + v.y * v.y);\n }\n\n /**\n * Get the length squared.\n */\n static lengthSquared(v: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n return v.x * v.x + v.y * v.y;\n }\n\n static distance(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n const dx = v.x - w.x;\n const dy = v.y - w.y;\n return math_sqrt(dx * dx + dy * dy);\n }\n\n static distanceSquared(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n const dx = v.x - w.x;\n const dy = v.y - w.y;\n return dx * dx + dy * dy;\n }\n\n static areEqual(v: Vec2Value, w: Vec2Value): boolean {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v === w || typeof w === \"object\" && w !== null && v.x === w.x && v.y === w.y;\n }\n\n /**\n * Get the skew vector such that dot(skew_vec, other) == cross(vec, other)\n */\n static skew(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(-v.y, v.x);\n }\n\n /** Dot product on two vectors */\n static dot(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.x + v.y * w.y;\n }\n\n /** Cross product between two vectors */\n static cross(v: Vec2Value, w: Vec2Value): number;\n /** Cross product between a vector and a scalar */\n static cross(v: Vec2Value, w: number): Vec2;\n /** Cross product between a scalar and a vector */\n static cross(v: number, w: Vec2Value): Vec2;\n static cross(v: any, w: any): any {\n if (typeof w === \"number\") {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y, -w * v.x);\n\n } else if (typeof v === \"number\") {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y, v * w.x);\n\n } else {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.y - v.y * w.x;\n }\n }\n\n /** Cross product on two vectors */\n static crossVec2Vec2(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.y - v.y * w.x;\n }\n\n /** Cross product on a vector and a scalar */\n static crossVec2Num(v: Vec2Value, w: number): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y, -w * v.x);\n }\n\n /** Cross product on a vector and a scalar */\n static crossNumVec2(v: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y, v * w.x);\n }\n\n /** Returns `a + (v x w)` */\n static addCross(a: Vec2Value, v: Vec2Value, w: number): Vec2;\n /** Returns `a + (v x w)` */\n static addCross(a: Vec2Value, v: number, w: Vec2Value): Vec2;\n static addCross(a: Vec2Value, v: any, w: any): Vec2 {\n if (typeof w === \"number\") {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y + a.x, -w * v.x + a.y);\n\n } else if (typeof v === \"number\") {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y + a.x, v * w.x + a.y);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n /**\n * Returns `a + (v x w)`\n */\n static addCrossVec2Num(a: Vec2Value, v: Vec2Value, w: number): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y + a.x, -w * v.x + a.y);\n }\n\n /**\n * Returns `a + (v x w)`\n */\n static addCrossNumVec2(a: Vec2Value, v: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y + a.x, v * w.x + a.y);\n }\n\n static add(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(v.x + w.x, v.y + w.y);\n }\n\n /** @hidden @deprecated */\n static wAdd(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return Vec2.combine(a, v, b, w);\n } else {\n return Vec2.mulNumVec2(a, v);\n }\n }\n\n static combine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n return Vec2.zero().setCombine(a, v, b, w);\n }\n\n static sub(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(v.x - w.x, v.y - w.y);\n }\n\n static mul(a: Vec2Value, b: number): Vec2;\n static mul(a: number, b: Vec2Value): Vec2;\n static mul(a: any, b: any): Vec2 {\n if (typeof a === \"object\") {\n if (_ASSERT) Vec2.assert(a);\n if (_ASSERT) console.assert(Number.isFinite(b));\n return Vec2.neo(a.x * b, a.y * b);\n\n } else if (typeof b === \"object\") {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(b);\n return Vec2.neo(a * b.x, a * b.y);\n }\n }\n\n static mulVec2Num(a: Vec2Value, b: number): Vec2 {\n if (_ASSERT) Vec2.assert(a);\n if (_ASSERT) console.assert(Number.isFinite(b));\n return Vec2.neo(a.x * b, a.y * b);\n }\n\n static mulNumVec2(a: number, b: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(b);\n return Vec2.neo(a * b.x, a * b.y);\n }\n\n neg(): Vec2 {\n this.x = -this.x;\n this.y = -this.y;\n return this;\n }\n\n static neg(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(-v.x, -v.y);\n }\n\n static abs(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(math_abs(v.x), math_abs(v.y));\n }\n\n static mid(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo((v.x + w.x) * 0.5, (v.y + w.y) * 0.5);\n }\n\n static upper(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(math_max(v.x, w.x), math_max(v.y, w.y));\n }\n\n static lower(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(math_min(v.x, w.x), math_min(v.y, w.y));\n }\n\n clamp(max: number): Vec2 {\n const lengthSqr = this.x * this.x + this.y * this.y;\n if (lengthSqr > max * max) {\n const scale = max / math_sqrt(lengthSqr);\n this.x *= scale;\n this.y *= scale;\n }\n return this;\n }\n\n static clamp(v: Vec2Value, max: number): Vec2 {\n const r = Vec2.neo(v.x, v.y);\n r.clamp(max);\n return r;\n }\n\n /** @hidden */\n static clampVec2(v: Vec2Value, min?: Vec2Value, max?: Vec2Value): Vec2Value {\n return {\n x: clamp(v.x, min?.x, max?.x),\n y: clamp(v.y, min?.y, max?.y)\n };\n }\n\n /** @hidden @deprecated */\n static scaleFn(x: number, y: number) {\n // todo: this was used in examples, remove in the future\n return function(v: Vec2Value): Vec2 {\n return Vec2.neo(v.x * x, v.y * y);\n };\n }\n\n /** @hidden @deprecated */\n static translateFn(x: number, y: number) {\n // todo: this was used in examples, remove in the future\n return function(v: Vec2Value): Vec2 {\n return Vec2.neo(v.x + x, v.y + y);\n };\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { EPSILON } from \"../common/Math\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n/**\n * Ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n */\nexport interface RayCastInput {\n p1: Vec2Value;\n p2: Vec2Value;\n maxFraction: number;\n}\n\nexport type RayCastCallback = (subInput: RayCastInput, id: number) => number;\n\n/**\n * Ray-cast output data. The ray hits at `p1 + fraction * (p2 - p1)`,\n * where `p1` and `p2` come from RayCastInput.\n */\nexport interface RayCastOutput {\n normal: Vec2;\n fraction: number;\n}\n\n/** Axis-aligned bounding box */\nexport interface AABBValue {\n lowerBound: Vec2Value;\n upperBound: Vec2Value;\n}\n\ndeclare module \"./AABB\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function AABB(lower?: Vec2Value, upper?: Vec2Value): AABB;\n}\n\n/** Axis-aligned bounding box */\n// @ts-expect-error\nexport class AABB {\n lowerBound: Vec2;\n upperBound: Vec2;\n\n constructor(lower?: Vec2Value, upper?: Vec2Value) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof AABB)) {\n return new AABB(lower, upper);\n }\n\n this.lowerBound = Vec2.zero();\n this.upperBound = Vec2.zero();\n\n if (typeof lower === \"object\") {\n this.lowerBound.setVec2(lower);\n }\n if (typeof upper === \"object\") {\n this.upperBound.setVec2(upper);\n } else if (typeof lower === \"object\") {\n this.upperBound.setVec2(lower);\n }\n }\n\n /**\n * Verify that the bounds are sorted.\n */\n isValid(): boolean {\n return AABB.isValid(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.lowerBound) && Vec2.isValid(obj.upperBound) && Vec2.sub(obj.upperBound, obj.lowerBound).lengthSquared() >= 0;\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!AABB.isValid(o), \"Invalid AABB!\", o);\n }\n\n /**\n * Get the center of the AABB.\n */\n getCenter(): Vec2 {\n return Vec2.neo((this.lowerBound.x + this.upperBound.x) * 0.5, (this.lowerBound.y + this.upperBound.y) * 0.5);\n }\n\n /**\n * Get the extents of the AABB (half-widths).\n */\n getExtents(): Vec2 {\n return Vec2.neo((this.upperBound.x - this.lowerBound.x) * 0.5, (this.upperBound.y - this.lowerBound.y) * 0.5);\n }\n\n /**\n * Get the perimeter length.\n */\n getPerimeter(): number {\n return 2.0 * (this.upperBound.x - this.lowerBound.x + this.upperBound.y - this.lowerBound.y);\n }\n\n /**\n * Combine one or two AABB into this one.\n */\n combine(a: AABBValue, b?: AABBValue): void {\n b = b || this;\n\n const lowerA = a.lowerBound;\n const upperA = a.upperBound;\n const lowerB = b.lowerBound;\n const upperB = b.upperBound;\n\n const lowerX = math_min(lowerA.x, lowerB.x);\n const lowerY = math_min(lowerA.y, lowerB.y);\n const upperX = math_max(upperB.x, upperA.x);\n const upperY = math_max(upperB.y, upperA.y);\n\n this.lowerBound.setNum(lowerX, lowerY);\n this.upperBound.setNum(upperX, upperY);\n }\n\n combinePoints(a: Vec2Value, b: Vec2Value): void {\n this.lowerBound.setNum(math_min(a.x, b.x), math_min(a.y, b.y));\n this.upperBound.setNum(math_max(a.x, b.x), math_max(a.y, b.y));\n }\n\n set(aabb: AABBValue): void {\n this.lowerBound.setNum(aabb.lowerBound.x, aabb.lowerBound.y);\n this.upperBound.setNum(aabb.upperBound.x, aabb.upperBound.y);\n }\n\n contains(aabb: AABBValue): boolean {\n let result = true;\n result = result && this.lowerBound.x <= aabb.lowerBound.x;\n result = result && this.lowerBound.y <= aabb.lowerBound.y;\n result = result && aabb.upperBound.x <= this.upperBound.x;\n result = result && aabb.upperBound.y <= this.upperBound.y;\n return result;\n }\n\n extend(value: number): AABB {\n AABB.extend(this, value);\n return this;\n }\n\n static extend(out: AABBValue, value: number): AABBValue {\n out.lowerBound.x -= value;\n out.lowerBound.y -= value;\n out.upperBound.x += value;\n out.upperBound.y += value;\n return out;\n }\n\n static testOverlap(a: AABBValue, b: AABBValue): boolean {\n const d1x = b.lowerBound.x - a.upperBound.x;\n const d2x = a.lowerBound.x - b.upperBound.x;\n\n const d1y = b.lowerBound.y - a.upperBound.y;\n const d2y = a.lowerBound.y - b.upperBound.y;\n\n if (d1x > 0 || d1y > 0 || d2x > 0 || d2y > 0) {\n return false;\n }\n return true;\n }\n\n static areEqual(a: AABBValue, b: AABBValue): boolean {\n return Vec2.areEqual(a.lowerBound, b.lowerBound) && Vec2.areEqual(a.upperBound, b.upperBound);\n }\n\n static diff(a: AABBValue, b: AABBValue): number {\n const wD = math_max(0, math_min(a.upperBound.x, b.upperBound.x) - math_max(b.lowerBound.x, a.lowerBound.x));\n const hD = math_max(0, math_min(a.upperBound.y, b.upperBound.y) - math_max(b.lowerBound.y, a.lowerBound.y));\n\n const wA = a.upperBound.x - a.lowerBound.x;\n const hA = a.upperBound.y - a.lowerBound.y;\n\n const wB = b.upperBound.x - b.lowerBound.x;\n const hB = b.upperBound.y - b.lowerBound.y;\n\n return wA * hA + wB * hB - wD * hD;\n }\n\n rayCast(output: RayCastOutput, input: RayCastInput): boolean {\n // From Real-time Collision Detection, p179.\n\n let tmin = -Infinity;\n let tmax = Infinity;\n\n const p = input.p1;\n const d = Vec2.sub(input.p2, input.p1);\n const absD = Vec2.abs(d);\n\n const normal = Vec2.zero();\n\n for (let f: \"x\" | \"y\" = \"x\"; f !== null; f = (f === \"x\" ? \"y\" : null)) {\n if (absD.x < EPSILON) {\n // Parallel.\n if (p[f] < this.lowerBound[f] || this.upperBound[f] < p[f]) {\n return false;\n }\n } else {\n const inv_d = 1.0 / d[f];\n let t1 = (this.lowerBound[f] - p[f]) * inv_d;\n let t2 = (this.upperBound[f] - p[f]) * inv_d;\n\n // Sign of the normal vector.\n let s = -1.0;\n\n if (t1 > t2) {\n const temp = t1;\n t1 = t2;\n t2 = temp;\n s = 1.0;\n }\n\n // Push the min up\n if (t1 > tmin) {\n normal.setZero();\n normal[f] = s;\n tmin = t1;\n }\n\n // Pull the max down\n tmax = math_min(tmax, t2);\n\n if (tmin > tmax) {\n return false;\n }\n }\n }\n\n // Does the ray start inside the box?\n // Does the ray intersect beyond the max fraction?\n if (tmin < 0.0 || input.maxFraction < tmin) {\n return false;\n }\n\n // Intersection.\n output.fraction = tmin;\n output.normal = normal;\n return true;\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static combinePoints(out: AABBValue, a: Vec2Value, b: Vec2Value): AABBValue {\n out.lowerBound.x = math_min(a.x, b.x);\n out.lowerBound.y = math_min(a.y, b.y);\n out.upperBound.x = math_max(a.x, b.x);\n out.upperBound.y = math_max(a.y, b.y);\n return out;\n }\n\n static combinedPerimeter(a: AABBValue, b: AABBValue) {\n const lx = math_min(a.lowerBound.x, b.lowerBound.x);\n const ly = math_min(a.lowerBound.y, b.lowerBound.y);\n const ux = math_max(a.upperBound.x, b.upperBound.x);\n const uy = math_max(a.upperBound.y, b.upperBound.y);\n return 2.0 * (ux - lx + uy - ly); \n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Tuning constants based on meters-kilograms-seconds (MKS) units.\n * \n * Some tolerances are absolute and some are relative. Absolute tolerances use MKS units.\n */\nexport class Settings {\n /**\n * You can use this to change the length scale used by your game.\n * \n * For example for inches you could use 39.4.\n */\n static lengthUnitsPerMeter = 1.0;\n \n // Collision\n /**\n * The maximum number of contact points between two convex shapes. Do not change\n * this value.\n */\n static maxManifoldPoints: number = 2;\n\n /**\n * The maximum number of vertices on a convex polygon. You cannot increase this\n * too much because BlockAllocator has a maximum object size.\n */\n static maxPolygonVertices: number = 12;\n\n /**\n * This is used to fatten AABBs in the dynamic tree. This allows proxies to move\n * by a small amount without triggering a tree adjustment. This is in meters.\n */\n static aabbExtension: number = 0.1;\n\n /**\n * This is used to fatten AABBs in the dynamic tree. This is used to predict the\n * future position based on the current displacement. This is a dimensionless\n * multiplier.\n */\n static aabbMultiplier: number = 2.0;\n\n /**\n * A small length used as a collision and constraint tolerance. Usually it is\n * chosen to be numerically significant, but visually insignificant.\n */\n static linearSlop: number = 0.005;\n\n /**\n * A small angle used as a collision and constraint tolerance. Usually it is\n * chosen to be numerically significant, but visually insignificant.\n */\n static angularSlop: number = (2.0 / 180.0 * math_PI);\n\n /**\n * The radius of the polygon/edge shape skin. This should not be modified.\n * Making this smaller means polygons will have an insufficient buffer for\n * continuous collision. Making it larger may create artifacts for vertex\n * collision.\n */\n static get polygonRadius(): number { return 2.0 * Settings.linearSlop; }\n\n /**\n * Maximum number of sub-steps per contact in continuous physics simulation.\n */\n static maxSubSteps: number = 8;\n\n // Dynamics\n\n /**\n * Maximum number of contacts to be handled to solve a TOI impact.\n */\n static maxTOIContacts: number = 32;\n\n /**\n * Maximum iterations to solve a TOI.\n */\n static maxTOIIterations: number = 20;\n\n /**\n * Maximum iterations to find Distance.\n */\n static maxDistanceIterations: number = 20;\n\n /**\n * A velocity threshold for elastic collisions. Any collision with a relative\n * linear velocity below this threshold will be treated as inelastic.\n */\n static velocityThreshold: number = 1.0;\n\n /**\n * The maximum linear position correction used when solving constraints. This\n * helps to prevent overshoot.\n */\n static maxLinearCorrection: number = 0.2;\n\n /**\n * The maximum angular position correction used when solving constraints. This\n * helps to prevent overshoot.\n */\n static maxAngularCorrection: number = (8.0 / 180.0 * math_PI);\n\n /**\n * The maximum linear velocity of a body. This limit is very large and is used\n * to prevent numerical problems. You shouldn't need to adjust Settings.\n */\n static maxTranslation: number = 2.0;\n\n /**\n * The maximum angular velocity of a body. This limit is very large and is used\n * to prevent numerical problems. You shouldn't need to adjust Settings.\n */\n static maxRotation: number = (0.5 * math_PI);\n\n /**\n * This scale factor controls how fast overlap is resolved. Ideally this would\n * be 1 so that overlap is removed in one time step. However using values close\n * to 1 often lead to overshoot.\n */\n static baumgarte: number = 0.2;\n static toiBaugarte: number = 0.75;\n\n // Sleep\n\n /**\n * The time that a body must be still before it will go to sleep.\n */\n static timeToSleep: number = 0.5;\n\n /**\n * A body cannot sleep if its linear velocity is above this tolerance.\n */\n static linearSleepTolerance: number = 0.01;\n\n /**\n * A body cannot sleep if its angular velocity is above this tolerance.\n */\n static angularSleepTolerance: number = (2.0 / 180.0 * math_PI);\n}\n\n/** @internal */\nexport class SettingsInternal {\n static get maxManifoldPoints() {\n return Settings.maxManifoldPoints;\n }\n static get maxPolygonVertices() {\n return Settings.maxPolygonVertices;\n }\n static get aabbExtension() {\n return Settings.aabbExtension * Settings.lengthUnitsPerMeter;\n }\n static get aabbMultiplier() {\n return Settings.aabbMultiplier;\n }\n static get linearSlop() {\n return Settings.linearSlop * Settings.lengthUnitsPerMeter;\n }\n static get linearSlopSquared() {\n return Settings.linearSlop * Settings.lengthUnitsPerMeter * Settings.linearSlop * Settings.lengthUnitsPerMeter;\n }\n static get angularSlop() {\n return Settings.angularSlop;\n }\n static get polygonRadius() {\n return 2.0 * Settings.linearSlop;\n }\n static get maxSubSteps() {\n return Settings.maxSubSteps;\n }\n static get maxTOIContacts() {\n return Settings.maxTOIContacts;\n }\n static get maxTOIIterations() {\n return Settings.maxTOIIterations;\n }\n static get maxDistanceIterations() {\n return Settings.maxDistanceIterations;\n }\n static get velocityThreshold() {\n return Settings.velocityThreshold * Settings.lengthUnitsPerMeter;\n }\n static get maxLinearCorrection() {\n return Settings.maxLinearCorrection * Settings.lengthUnitsPerMeter;\n }\n static get maxAngularCorrection() {\n return Settings.maxAngularCorrection;\n }\n static get maxTranslation() {\n return Settings.maxTranslation * Settings.lengthUnitsPerMeter;\n }\n static get maxTranslationSquared() {\n return Settings.maxTranslation * Settings.lengthUnitsPerMeter * Settings.maxTranslation * Settings.lengthUnitsPerMeter;\n }\n static get maxRotation() {\n return Settings.maxRotation;\n }\n static get maxRotationSquared() {\n return Settings.maxRotation * Settings.maxRotation;\n }\n static get baumgarte() {\n return Settings.baumgarte;\n }\n static get toiBaugarte() {\n return Settings.toiBaugarte;\n }\n static get timeToSleep() {\n return Settings.timeToSleep;\n }\n static get linearSleepTolerance() {\n return Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter;\n }\n static get linearSleepToleranceSqr() {\n return Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter * Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter;\n }\n static get angularSleepTolerance() {\n return Settings.angularSleepTolerance;\n }\n static get angularSleepToleranceSqr() {\n return Settings.angularSleepTolerance * Settings.angularSleepTolerance;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */\nexport interface PoolOptions {\n max?: number,\n create?: () => T,\n /** Called when an object is being re-allocated. */\n allocate?: (item: T) => void,\n /** Called when an object is returned to pool. */\n release?: (item: T) => void,\n /** Called when an object is returned to the pool but will be disposed from pool. */\n dispose?: (item: T) => T,\n}\n\n/** @internal */\nexport class Pool {\n _list: T[] = [];\n _max: number = Infinity;\n\n _createFn: () => T;\n _hasCreateFn: boolean = false;\n _createCount: number = 0;\n\n _allocateFn: (item: T) => void;\n _hasAllocateFn: boolean = false;\n _allocateCount: number = 0;\n\n _releaseFn: (item: T) => void;\n _hasReleaseFn: boolean = false;\n _releaseCount: number = 0;\n\n _disposeFn: (item: T) => T;\n _hasDisposeFn: boolean = false;\n _disposeCount: number = 0;\n\n constructor(opts: PoolOptions) {\n this._list = [];\n this._max = opts.max || this._max;\n\n this._createFn = opts.create;\n this._hasCreateFn = typeof this._createFn === \"function\";\n this._allocateFn = opts.allocate;\n this._hasAllocateFn = typeof this._allocateFn === \"function\";\n this._releaseFn = opts.release;\n this._hasReleaseFn = typeof this._releaseFn === \"function\";\n this._disposeFn = opts.dispose;\n this._hasDisposeFn = typeof this._disposeFn === \"function\";\n }\n\n max(n?: number): number | Pool {\n if (typeof n === \"number\") {\n this._max = n;\n return this;\n }\n return this._max;\n }\n\n size(): number {\n return this._list.length;\n }\n\n allocate(): T {\n let item: T;\n if (this._list.length > 0) {\n item = this._list.shift();\n } else {\n this._createCount++;\n if (this._hasCreateFn) {\n item = this._createFn();\n } else {\n // tslint:disable-next-line:no-object-literal-type-assertion\n item = {} as T;\n }\n }\n this._allocateCount++;\n if (this._hasAllocateFn) {\n this._allocateFn(item);\n }\n return item;\n }\n\n release(item: T): void {\n if (this._list.length < this._max) {\n this._releaseCount++;\n if (this._hasReleaseFn) {\n this._releaseFn(item);\n }\n this._list.push(item);\n } else {\n this._disposeCount++;\n if (this._hasDisposeFn) {\n item = this._disposeFn(item);\n }\n }\n }\n\n toString(): string {\n return \" +\" + this._createCount + \" >\" + this._allocateCount + \" <\" + this._releaseCount + \" -\"\n + this._disposeCount + \" =\" + this._list.length + \"/\" + this._max;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { Pool } from \"../util/Pool\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { AABB, AABBValue, RayCastCallback, RayCastInput } from \"./AABB\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n\n\nexport type DynamicTreeQueryCallback = (nodeId: number) => boolean;\n\n/**\n * A node in the dynamic tree. The client does not interact with this directly.\n */\nexport class TreeNode {\n id: number;\n /** Enlarged AABB */\n aabb: AABB = new AABB();\n userData: T = null;\n parent: TreeNode = null;\n child1: TreeNode = null;\n child2: TreeNode = null;\n /** 0: leaf, -1: free node */\n height: number = -1;\n\n constructor(id?: number) {\n this.id = id;\n }\n\n /** @internal */\n toString(): string {\n return this.id + \": \" + this.userData;\n }\n\n isLeaf(): boolean {\n return this.child1 == null;\n }\n}\n\n/** @internal */ const poolTreeNode = new Pool>({\n create(): TreeNode {\n return new TreeNode();\n },\n release(node: TreeNode) {\n node.userData = null;\n node.parent = null;\n node.child1 = null;\n node.child2 = null;\n node.height = -1;\n node.id = undefined;\n }\n});\n\n/**\n * A dynamic AABB tree broad-phase, inspired by Nathanael Presson's btDbvt. A\n * dynamic tree arranges data in a binary tree to accelerate queries such as\n * volume queries and ray casts. Leafs are proxies with an AABB. In the tree we\n * expand the proxy AABB by `aabbExtension` so that the proxy AABB is bigger\n * than the client object. This allows the client object to move by small\n * amounts without triggering a tree update.\n *\n * Nodes are pooled and relocatable, so we use node indices rather than\n * pointers.\n */\nexport class DynamicTree {\n m_root: TreeNode;\n m_lastProxyId: number;\n m_nodes: {\n [id: number]: TreeNode\n };\n\n constructor() {\n this.m_root = null;\n this.m_nodes = {};\n this.m_lastProxyId = 0;\n }\n\n /**\n * Get proxy user data.\n *\n * @return the proxy user data or 0 if the id is invalid.\n */\n getUserData(id: number): T {\n const node = this.m_nodes[id];\n if (_ASSERT) console.assert(!!node);\n return node.userData;\n }\n\n /**\n * Get the fat AABB for a node id.\n *\n * @return the proxy user data or 0 if the id is invalid.\n */\n getFatAABB(id: number): AABB {\n const node = this.m_nodes[id];\n if (_ASSERT) console.assert(!!node);\n return node.aabb;\n }\n\n allocateNode(): TreeNode {\n const node = poolTreeNode.allocate();\n node.id = ++this.m_lastProxyId;\n this.m_nodes[node.id] = node;\n return node;\n }\n\n freeNode(node: TreeNode): void {\n // tslint:disable-next-line:no-dynamic-delete\n delete this.m_nodes[node.id];\n poolTreeNode.release(node);\n }\n\n /**\n * Create a proxy in the tree as a leaf node. We return the index of the node\n * instead of a pointer so that we can grow the node pool.\n *\n * Create a proxy. Provide a tight fitting AABB and a userData pointer.\n */\n createProxy(aabb: AABBValue, userData: T): number {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n\n const node = this.allocateNode();\n\n node.aabb.set(aabb);\n\n // Fatten the aabb.\n AABB.extend(node.aabb, Settings.aabbExtension);\n\n node.userData = userData;\n node.height = 0;\n\n this.insertLeaf(node);\n\n return node.id;\n }\n\n /**\n * Destroy a proxy. This asserts if the id is invalid.\n */\n destroyProxy(id: number): void {\n const node = this.m_nodes[id];\n\n if (_ASSERT) console.assert(!!node);\n if (_ASSERT) console.assert(node.isLeaf());\n\n this.removeLeaf(node);\n this.freeNode(node);\n }\n\n /**\n * Move a proxy with a swepted AABB. If the proxy has moved outside of its\n * fattened AABB, then the proxy is removed from the tree and re-inserted.\n * Otherwise the function returns immediately.\n *\n * @param d Displacement\n *\n * @return true if the proxy was re-inserted.\n */\n moveProxy(id: number, aabb: AABBValue, d: Vec2Value): boolean {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n if (_ASSERT) console.assert(!d || Vec2.isValid(d));\n\n const node = this.m_nodes[id];\n\n if (_ASSERT) console.assert(!!node);\n if (_ASSERT) console.assert(node.isLeaf());\n\n if (node.aabb.contains(aabb)) {\n return false;\n }\n\n this.removeLeaf(node);\n\n node.aabb.set(aabb);\n\n // Extend AABB.\n aabb = node.aabb;\n AABB.extend(aabb, Settings.aabbExtension);\n\n // Predict AABB displacement.\n // const d = Vec2.mul(Settings.aabbMultiplier, displacement);\n\n if (d.x < 0.0) {\n aabb.lowerBound.x += d.x * Settings.aabbMultiplier;\n } else {\n aabb.upperBound.x += d.x * Settings.aabbMultiplier;\n }\n\n if (d.y < 0.0) {\n aabb.lowerBound.y += d.y * Settings.aabbMultiplier;\n } else {\n aabb.upperBound.y += d.y * Settings.aabbMultiplier;\n }\n\n this.insertLeaf(node);\n\n return true;\n }\n\n insertLeaf(leaf: TreeNode): void {\n if (_ASSERT) console.assert(AABB.isValid(leaf.aabb));\n\n if (this.m_root == null) {\n this.m_root = leaf;\n this.m_root.parent = null;\n return;\n }\n\n // Find the best sibling for this node\n const leafAABB = leaf.aabb;\n let index = this.m_root;\n while (!index.isLeaf()) {\n const child1 = index.child1;\n const child2 = index.child2;\n\n const area = index.aabb.getPerimeter();\n\n const combinedArea = AABB.combinedPerimeter(index.aabb, leafAABB);\n\n // Cost of creating a new parent for this node and the new leaf\n const cost = 2.0 * combinedArea;\n\n // Minimum cost of pushing the leaf further down the tree\n const inheritanceCost = 2.0 * (combinedArea - area);\n\n // Cost of descending into child1\n const newArea1 = AABB.combinedPerimeter(leafAABB, child1.aabb);\n let cost1 = newArea1 + inheritanceCost;\n if (!child1.isLeaf()) {\n const oldArea = child1.aabb.getPerimeter();\n cost1 -= oldArea;\n }\n\n // Cost of descending into child2\n const newArea2 = AABB.combinedPerimeter(leafAABB, child2.aabb);\n let cost2 = newArea2 + inheritanceCost;\n if (!child2.isLeaf()) {\n const oldArea = child2.aabb.getPerimeter();\n cost2 -= oldArea;\n }\n\n // Descend according to the minimum cost.\n if (cost < cost1 && cost < cost2) {\n break;\n }\n\n // Descend\n if (cost1 < cost2) {\n index = child1;\n } else {\n index = child2;\n }\n }\n\n const sibling = index;\n\n // Create a new parent.\n const oldParent = sibling.parent;\n const newParent = this.allocateNode();\n newParent.parent = oldParent;\n newParent.userData = null;\n newParent.aabb.combine(leafAABB, sibling.aabb);\n newParent.height = sibling.height + 1;\n\n if (oldParent != null) {\n // The sibling was not the root.\n if (oldParent.child1 === sibling) {\n oldParent.child1 = newParent;\n } else {\n oldParent.child2 = newParent;\n }\n\n newParent.child1 = sibling;\n newParent.child2 = leaf;\n sibling.parent = newParent;\n leaf.parent = newParent;\n } else {\n // The sibling was the root.\n newParent.child1 = sibling;\n newParent.child2 = leaf;\n sibling.parent = newParent;\n leaf.parent = newParent;\n this.m_root = newParent;\n }\n\n // Walk back up the tree fixing heights and AABBs\n index = leaf.parent;\n while (index != null) {\n index = this.balance(index);\n\n const child1 = index.child1;\n const child2 = index.child2;\n\n if (_ASSERT) console.assert(child1 != null);\n if (_ASSERT) console.assert(child2 != null);\n\n index.height = 1 + math_max(child1.height, child2.height);\n index.aabb.combine(child1.aabb, child2.aabb);\n\n index = index.parent;\n }\n\n // validate();\n }\n\n removeLeaf(leaf: TreeNode): void {\n if (leaf === this.m_root) {\n this.m_root = null;\n return;\n }\n\n const parent = leaf.parent;\n const grandParent = parent.parent;\n let sibling;\n if (parent.child1 === leaf) {\n sibling = parent.child2;\n } else {\n sibling = parent.child1;\n }\n\n if (grandParent != null) {\n // Destroy parent and connect sibling to grandParent.\n if (grandParent.child1 === parent) {\n grandParent.child1 = sibling;\n } else {\n grandParent.child2 = sibling;\n }\n sibling.parent = grandParent;\n this.freeNode(parent);\n\n // Adjust ancestor bounds.\n let index = grandParent;\n while (index != null) {\n index = this.balance(index);\n\n const child1 = index.child1;\n const child2 = index.child2;\n\n index.aabb.combine(child1.aabb, child2.aabb);\n index.height = 1 + math_max(child1.height, child2.height);\n\n index = index.parent;\n }\n } else {\n this.m_root = sibling;\n sibling.parent = null;\n this.freeNode(parent);\n }\n\n // validate();\n }\n\n /**\n * Perform a left or right rotation if node A is imbalanced. Returns the new\n * root index.\n */\n balance(iA: TreeNode): TreeNode {\n if (_ASSERT) console.assert(iA != null);\n\n const A = iA;\n if (A.isLeaf() || A.height < 2) {\n return iA;\n }\n\n const B = A.child1;\n const C = A.child2;\n\n const balance = C.height - B.height;\n\n // Rotate C up\n if (balance > 1) {\n const F = C.child1;\n const G = C.child2;\n\n // Swap A and C\n C.child1 = A;\n C.parent = A.parent;\n A.parent = C;\n\n // A's old parent should point to C\n if (C.parent != null) {\n if (C.parent.child1 === iA) {\n C.parent.child1 = C;\n } else {\n C.parent.child2 = C;\n }\n } else {\n this.m_root = C;\n }\n\n // Rotate\n if (F.height > G.height) {\n C.child2 = F;\n A.child2 = G;\n G.parent = A;\n A.aabb.combine(B.aabb, G.aabb);\n C.aabb.combine(A.aabb, F.aabb);\n\n A.height = 1 + math_max(B.height, G.height);\n C.height = 1 + math_max(A.height, F.height);\n } else {\n C.child2 = G;\n A.child2 = F;\n F.parent = A;\n A.aabb.combine(B.aabb, F.aabb);\n C.aabb.combine(A.aabb, G.aabb);\n\n A.height = 1 + math_max(B.height, F.height);\n C.height = 1 + math_max(A.height, G.height);\n }\n\n return C;\n }\n\n // Rotate B up\n if (balance < -1) {\n const D = B.child1;\n const E = B.child2;\n\n // Swap A and B\n B.child1 = A;\n B.parent = A.parent;\n A.parent = B;\n\n // A's old parent should point to B\n if (B.parent != null) {\n if (B.parent.child1 === A) {\n B.parent.child1 = B;\n } else {\n B.parent.child2 = B;\n }\n } else {\n this.m_root = B;\n }\n\n // Rotate\n if (D.height > E.height) {\n B.child2 = D;\n A.child1 = E;\n E.parent = A;\n A.aabb.combine(C.aabb, E.aabb);\n B.aabb.combine(A.aabb, D.aabb);\n\n A.height = 1 + math_max(C.height, E.height);\n B.height = 1 + math_max(A.height, D.height);\n } else {\n B.child2 = E;\n A.child1 = D;\n D.parent = A;\n A.aabb.combine(C.aabb, D.aabb);\n B.aabb.combine(A.aabb, E.aabb);\n\n A.height = 1 + math_max(C.height, D.height);\n B.height = 1 + math_max(A.height, E.height);\n }\n\n return B;\n }\n\n return A;\n }\n\n /**\n * Compute the height of the binary tree in O(N) time. Should not be called\n * often.\n */\n getHeight(): number {\n if (this.m_root == null) {\n return 0;\n }\n\n return this.m_root.height;\n }\n\n /**\n * Get the ratio of the sum of the node areas to the root area.\n */\n getAreaRatio(): number {\n if (this.m_root == null) {\n return 0.0;\n }\n\n const root = this.m_root;\n const rootArea = root.aabb.getPerimeter();\n\n let totalArea = 0.0;\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height < 0) {\n // Free node in pool\n continue;\n }\n\n totalArea += node.aabb.getPerimeter();\n }\n\n this.iteratorPool.release(it);\n\n return totalArea / rootArea;\n }\n\n /**\n * Compute the height of a sub-tree.\n */\n computeHeight(id?: number): number {\n let node;\n if (typeof id !== \"undefined\") {\n node = this.m_nodes[id];\n } else {\n node = this.m_root;\n }\n\n // if (_ASSERT) console.assert(0 <= id && id < this.m_nodeCapacity);\n\n if (node.isLeaf()) {\n return 0;\n }\n\n const height1 = this.computeHeight(node.child1.id);\n const height2 = this.computeHeight(node.child2.id);\n return 1 + math_max(height1, height2);\n }\n\n validateStructure(node: TreeNode): void {\n if (node == null) {\n return;\n }\n\n if (node === this.m_root) {\n if (_ASSERT) console.assert(node.parent == null);\n }\n\n const child1 = node.child1;\n const child2 = node.child2;\n\n if (node.isLeaf()) {\n if (_ASSERT) console.assert(child1 == null);\n if (_ASSERT) console.assert(child2 == null);\n if (_ASSERT) console.assert(node.height === 0);\n return;\n }\n\n // if (_ASSERT) console.assert(0 <= child1 && child1 < this.m_nodeCapacity);\n // if (_ASSERT) console.assert(0 <= child2 && child2 < this.m_nodeCapacity);\n\n if (_ASSERT) console.assert(child1.parent === node);\n if (_ASSERT) console.assert(child2.parent === node);\n\n this.validateStructure(child1);\n this.validateStructure(child2);\n }\n\n validateMetrics(node: TreeNode): void {\n if (node == null) {\n return;\n }\n\n const child1 = node.child1;\n const child2 = node.child2;\n\n if (node.isLeaf()) {\n if (_ASSERT) console.assert(child1 == null);\n if (_ASSERT) console.assert(child2 == null);\n if (_ASSERT) console.assert(node.height === 0);\n return;\n }\n\n // if (_ASSERT) console.assert(0 <= child1 && child1 < this.m_nodeCapacity);\n // if (_ASSERT) console.assert(0 <= child2 && child2 < this.m_nodeCapacity);\n\n const height1 = child1.height;\n const height2 = child2.height;\n const height = 1 + math_max(height1, height2);\n if (_ASSERT) console.assert(node.height === height);\n\n const aabb = new AABB();\n aabb.combine(child1.aabb, child2.aabb);\n\n if (_ASSERT) console.assert(AABB.areEqual(aabb, node.aabb));\n\n this.validateMetrics(child1);\n this.validateMetrics(child2);\n }\n\n /**\n * Validate this tree. For testing.\n */\n validate(): void {\n if (!_ASSERT) return;\n this.validateStructure(this.m_root);\n this.validateMetrics(this.m_root);\n\n console.assert(this.getHeight() === this.computeHeight());\n }\n\n /**\n * Get the maximum balance of an node in the tree. The balance is the difference\n * in height of the two children of a node.\n */\n getMaxBalance(): number {\n let maxBalance = 0;\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height <= 1) {\n continue;\n }\n\n if (_ASSERT) console.assert(!node.isLeaf());\n\n const balance = math_abs(node.child2.height - node.child1.height);\n maxBalance = math_max(maxBalance, balance);\n }\n this.iteratorPool.release(it);\n\n return maxBalance;\n }\n\n /**\n * Build an optimal tree. Very expensive. For testing.\n */\n rebuildBottomUp(): void {\n const nodes = [];\n let count = 0;\n\n // Build array of leaves. Free the rest.\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height < 0) {\n // free node in pool\n continue;\n }\n\n if (node.isLeaf()) {\n node.parent = null;\n nodes[count] = node;\n ++count;\n } else {\n this.freeNode(node);\n }\n }\n this.iteratorPool.release(it);\n\n while (count > 1) {\n let minCost = Infinity;\n let iMin = -1;\n let jMin = -1;\n for (let i = 0; i < count; ++i) {\n const aabbi = nodes[i].aabb;\n for (let j = i + 1; j < count; ++j) {\n const aabbj = nodes[j].aabb;\n const cost = AABB.combinedPerimeter(aabbi, aabbj);\n if (cost < minCost) {\n iMin = i;\n jMin = j;\n minCost = cost;\n }\n }\n }\n\n const child1 = nodes[iMin];\n const child2 = nodes[jMin];\n\n const parent = this.allocateNode();\n parent.child1 = child1;\n parent.child2 = child2;\n parent.height = 1 + math_max(child1.height, child2.height);\n parent.aabb.combine(child1.aabb, child2.aabb);\n parent.parent = null;\n\n child1.parent = parent;\n child2.parent = parent;\n\n nodes[jMin] = nodes[count - 1];\n nodes[iMin] = parent;\n --count;\n }\n\n this.m_root = nodes[0];\n\n if (_ASSERT) this.validate();\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n // Build array of leaves. Free the rest.\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n const aabb = node.aabb;\n aabb.lowerBound.x -= newOrigin.x;\n aabb.lowerBound.y -= newOrigin.y;\n aabb.upperBound.x -= newOrigin.x;\n aabb.upperBound.y -= newOrigin.y;\n }\n this.iteratorPool.release(it);\n }\n\n /**\n * Query an AABB for overlapping proxies. The callback class is called for each\n * proxy that overlaps the supplied AABB.\n */\n query(aabb: AABBValue, queryCallback: DynamicTreeQueryCallback): void {\n if (_ASSERT) console.assert(typeof queryCallback === \"function\");\n const stack = this.stackPool.allocate();\n\n stack.push(this.m_root);\n while (stack.length > 0) {\n const node = stack.pop();\n if (node == null) {\n continue;\n }\n\n if (AABB.testOverlap(node.aabb, aabb)) {\n if (node.isLeaf()) {\n const proceed = queryCallback(node.id);\n if (proceed === false) {\n return;\n }\n } else {\n stack.push(node.child1);\n stack.push(node.child2);\n }\n }\n }\n\n this.stackPool.release(stack);\n }\n\n /**\n * Ray-cast against the proxies in the tree. This relies on the callback to\n * perform a exact ray-cast in the case were the proxy contains a shape. The\n * callback also performs the any collision filtering. This has performance\n * roughly equal to k * log(n), where k is the number of collisions and n is the\n * number of proxies in the tree.\n *\n * @param input The ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n * @param rayCastCallback A function that is called for each proxy that is hit by the ray. If the return value is a positive number it will update the maxFraction of the ray cast input, and if it is zero it will terminate they ray cast.\n */\n rayCast(input: RayCastInput, rayCastCallback: RayCastCallback): void {\n // TODO: GC\n if (_ASSERT) console.assert(typeof rayCastCallback === \"function\");\n const p1 = input.p1;\n const p2 = input.p2;\n const r = Vec2.sub(p2, p1);\n if (_ASSERT) console.assert(r.lengthSquared() > 0.0);\n r.normalize();\n\n // v is perpendicular to the segment.\n const v = Vec2.crossNumVec2(1.0, r);\n const abs_v = Vec2.abs(v);\n\n // Separating axis for segment (Gino, p80).\n // |dot(v, p1 - c)| > dot(|v|, h)\n\n let maxFraction = input.maxFraction;\n\n // Build a bounding box for the segment.\n const segmentAABB = new AABB();\n let t = Vec2.combine((1 - maxFraction), p1, maxFraction, p2);\n segmentAABB.combinePoints(p1, t);\n\n const stack = this.stackPool.allocate();\n const subInput = this.inputPool.allocate();\n\n stack.push(this.m_root);\n while (stack.length > 0) {\n const node = stack.pop();\n if (node == null) {\n continue;\n }\n\n if (AABB.testOverlap(node.aabb, segmentAABB) === false) {\n continue;\n }\n\n // Separating axis for segment (Gino, p80).\n // |dot(v, p1 - c)| > dot(|v|, h)\n const c = node.aabb.getCenter();\n const h = node.aabb.getExtents();\n const separation = math_abs(Vec2.dot(v, Vec2.sub(p1, c))) - Vec2.dot(abs_v, h);\n if (separation > 0.0) {\n continue;\n }\n\n if (node.isLeaf()) {\n subInput.p1 = Vec2.clone(input.p1);\n subInput.p2 = Vec2.clone(input.p2);\n subInput.maxFraction = maxFraction;\n\n const value = rayCastCallback(subInput, node.id);\n\n if (value === 0.0) {\n // The client has terminated the ray cast.\n break;\n } else if (value > 0.0) {\n // update segment bounding box.\n maxFraction = value;\n t = Vec2.combine((1 - maxFraction), p1, maxFraction, p2);\n segmentAABB.combinePoints(p1, t);\n }\n } else {\n stack.push(node.child1);\n stack.push(node.child2);\n }\n }\n this.stackPool.release(stack);\n this.inputPool.release(subInput);\n }\n\n private inputPool: Pool = new Pool({\n create(): RayCastInput {\n // tslint:disable-next-line:no-object-literal-type-assertion\n return {} as RayCastInput;\n },\n release(stack: RayCastInput): void {\n }\n });\n\n private stackPool: Pool>> = new Pool>>({\n create(): Array> {\n return [];\n },\n release(stack: Array>): void {\n stack.length = 0;\n }\n });\n\n private iteratorPool: Pool> = new Pool>({\n create(): Iterator {\n return new Iterator();\n },\n release(iterator: Iterator): void {\n iterator.close();\n }\n });\n\n}\n\n/** @internal */\nclass Iterator {\n parents: Array> = [];\n states: number[] = [];\n preorder(root: TreeNode): Iterator {\n this.parents.length = 0;\n this.parents.push(root);\n this.states.length = 0;\n this.states.push(0);\n return this;\n }\n next(): TreeNode {\n while (this.parents.length > 0) {\n const i = this.parents.length - 1;\n const node = this.parents[i];\n if (this.states[i] === 0) {\n this.states[i] = 1;\n return node;\n }\n if (this.states[i] === 1) {\n this.states[i] = 2;\n if (node.child1) {\n this.parents.push(node.child1);\n this.states.push(1);\n return node.child1;\n }\n }\n if (this.states[i] === 2) {\n this.states[i] = 3;\n if (node.child2) {\n this.parents.push(node.child2);\n this.states.push(1);\n return node.child2;\n }\n }\n this.parents.pop();\n this.states.pop();\n }\n }\n close(): void {\n this.parents.length = 0;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2Value } from \"../common/Vec2\";\nimport { AABB, AABBValue, RayCastCallback, RayCastInput } from \"./AABB\";\nimport { DynamicTree, DynamicTreeQueryCallback } from \"./DynamicTree\";\nimport { FixtureProxy } from \"../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/**\n * The broad-phase wraps and extends a dynamic-tree to keep track of moved\n * objects and query them on update.\n */\nexport class BroadPhase {\n m_tree: DynamicTree = new DynamicTree();\n m_moveBuffer: number[] = [];\n\n m_callback: (userDataA: any, userDataB: any) => void;\n m_queryProxyId: number;\n\n /**\n * Get user data from a proxy. Returns null if the id is invalid.\n */\n getUserData(proxyId: number): FixtureProxy {\n return this.m_tree.getUserData(proxyId);\n }\n\n /**\n * Test overlap of fat AABBs.\n */\n testOverlap(proxyIdA: number, proxyIdB: number): boolean {\n const aabbA = this.m_tree.getFatAABB(proxyIdA);\n const aabbB = this.m_tree.getFatAABB(proxyIdB);\n return AABB.testOverlap(aabbA, aabbB);\n }\n\n /**\n * Get the fat AABB for a proxy.\n */\n getFatAABB(proxyId: number): AABB {\n return this.m_tree.getFatAABB(proxyId);\n }\n\n /**\n * Get the number of proxies.\n */\n getProxyCount(): number {\n return this.m_moveBuffer.length;\n }\n\n /**\n * Get the height of the embedded tree.\n */\n getTreeHeight(): number {\n return this.m_tree.getHeight();\n }\n\n /**\n * Get the balance (integer) of the embedded tree.\n */\n getTreeBalance(): number {\n return this.m_tree.getMaxBalance();\n }\n\n /**\n * Get the quality metric of the embedded tree.\n */\n getTreeQuality(): number {\n return this.m_tree.getAreaRatio();\n }\n\n /**\n * Query an AABB for overlapping proxies. The callback class is called for each\n * proxy that overlaps the supplied AABB.\n */\n query = (aabb: AABBValue, queryCallback: DynamicTreeQueryCallback): void => {\n this.m_tree.query(aabb, queryCallback);\n };\n\n /**\n * Ray-cast against the proxies in the tree. This relies on the callback to\n * perform a exact ray-cast in the case were the proxy contains a shape. The\n * callback also performs the any collision filtering. This has performance\n * roughly equal to k * log(n), where k is the number of collisions and n is the\n * number of proxies in the tree.\n *\n * @param input The ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n * @param rayCastCallback A function that is called for each proxy that is hit by the ray. If the return value is a positive number it will update the maxFraction of the ray cast input, and if it is zero it will terminate they ray cast.\n */\n rayCast(input: RayCastInput, rayCastCallback: RayCastCallback): void {\n this.m_tree.rayCast(input, rayCastCallback);\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_tree.shiftOrigin(newOrigin);\n }\n\n /**\n * Create a proxy with an initial AABB. Pairs are not reported until UpdatePairs\n * is called.\n */\n createProxy(aabb: AABBValue, userData: FixtureProxy): number {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n const proxyId = this.m_tree.createProxy(aabb, userData);\n this.bufferMove(proxyId);\n return proxyId;\n }\n\n /**\n * Destroy a proxy. It is up to the client to remove any pairs.\n */\n destroyProxy(proxyId: number): void {\n this.unbufferMove(proxyId);\n this.m_tree.destroyProxy(proxyId);\n }\n\n /**\n * Call moveProxy as many times as you like, then when you are done call\n * UpdatePairs to finalized the proxy pairs (for your time step).\n */\n moveProxy(proxyId: number, aabb: AABB, displacement: Vec2Value): void {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n const changed = this.m_tree.moveProxy(proxyId, aabb, displacement);\n if (changed) {\n this.bufferMove(proxyId);\n }\n }\n\n /**\n * Call to trigger a re-processing of it's pairs on the next call to\n * UpdatePairs.\n */\n touchProxy(proxyId: number): void {\n this.bufferMove(proxyId);\n }\n\n bufferMove(proxyId: number): void {\n this.m_moveBuffer.push(proxyId);\n }\n\n unbufferMove(proxyId: number): void {\n for (let i = 0; i < this.m_moveBuffer.length; ++i) {\n if (this.m_moveBuffer[i] === proxyId) {\n this.m_moveBuffer[i] = null;\n }\n }\n }\n\n /**\n * Update the pairs. This results in pair callbacks. This can only add pairs.\n */\n updatePairs(addPairCallback: (userDataA: FixtureProxy, userDataB: FixtureProxy) => void): void {\n if (_ASSERT) console.assert(typeof addPairCallback === \"function\");\n this.m_callback = addPairCallback;\n\n // Perform tree queries for all moving proxies.\n while (this.m_moveBuffer.length > 0) {\n this.m_queryProxyId = this.m_moveBuffer.pop();\n if (this.m_queryProxyId === null) {\n continue;\n }\n\n // We have to query the tree with the fat AABB so that\n // we don't fail to create a pair that may touch later.\n const fatAABB = this.m_tree.getFatAABB(this.m_queryProxyId);\n\n // Query tree, create pairs and add them pair buffer.\n this.m_tree.query(fatAABB, this.queryCallback);\n }\n\n // Try to keep the tree balanced.\n // this.m_tree.rebalance(4);\n }\n\n queryCallback = (proxyId: number): boolean => {\n // A proxy cannot form a pair with itself.\n if (proxyId === this.m_queryProxyId) {\n return true;\n }\n\n const proxyIdA = math_min(proxyId, this.m_queryProxyId);\n const proxyIdB = math_max(proxyId, this.m_queryProxyId);\n\n // TODO: Skip any duplicate pairs.\n\n const userDataA = this.m_tree.getUserData(proxyIdA);\n const userDataB = this.m_tree.getUserData(proxyIdB);\n\n // Send the pairs back to the client.\n this.m_callback(userDataA, userDataB);\n\n return true;\n };\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n/** @internal */ const math_sqrt = Math.sqrt;\n\n\nimport { RotValue } from \"./Rot\";\nimport { TransformValue } from \"./Transform\";\nimport { Vec2Value } from \"./Vec2\";\nimport { Vec3Value } from \"./Vec3\";\n\nexport function vec2(x: number, y: number): Vec2Value {\n return { x, y };\n}\n\nexport function vec3(x: number, y: number, z: number): Vec3Value {\n return { x, y, z };\n}\n\nexport function rotation(angle: number): RotValue {\n return { s: math_sin(angle), c: math_cos(angle) };\n}\n\nexport function setVec2(out: Vec2Value, x: number, y: number): Vec2Value {\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function copyVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = w.x;\n out.y = w.y;\n return out;\n}\n\nexport function zeroVec2(out: Vec2Value): Vec2Value {\n out.x = 0;\n out.y = 0;\n return out;\n}\n\nexport function negVec2(out: Vec2Value): Vec2Value {\n out.x = -out.x;\n out.y = -out.y;\n return out;\n}\n\nexport function plusVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x += w.x;\n out.y += w.y;\n return out;\n}\n\nexport function addVec2(out: Vec2Value, v: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = v.x + w.x;\n out.y = v.x + w.y;\n return out;\n}\n\nexport function minusVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x -= w.x;\n out.y -= w.y;\n return out;\n}\n\nexport function subVec2(out: Vec2Value, v: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = v.x - w.x;\n out.y = v.y - w.y;\n return out;\n}\n\nexport function mulVec2(out: Vec2Value, m: number): Vec2Value {\n out.x *= m;\n out.y *= m;\n return out;\n}\n\nexport function scaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x = m * w.x;\n out.y = m * w.y;\n return out;\n}\n\nexport function plusScaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x += m * w.x;\n out.y += m * w.y;\n return out;\n}\n\nexport function minusScaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x -= m * w.x;\n out.y -= m * w.y;\n return out;\n}\n\nexport function combine2Vec2(out: Vec2Value, am: number, a: Vec2Value, bm: number, b: Vec2Value): Vec2Value {\n out.x = am * a.x + bm * b.x;\n out.y = am * a.y + bm * b.y;\n return out;\n}\n\nexport function combine3Vec2(out: Vec2Value, am: number, a: Vec2Value, bm: number, b: Vec2Value, cm: number, c: Vec2Value): Vec2Value {\n out.x = am * a.x + bm * b.x + cm * c.x;\n out.y = am * a.y + bm * b.y + cm * c.y;\n return out;\n}\n\nexport function normalizeVec2Length(out: Vec2Value): number {\n const length = math_sqrt(out.x * out.x + out.y * out.y);\n if (length !== 0) {\n const invLength = 1 / length;\n out.x *= invLength;\n out.y *= invLength;\n }\n return length;\n}\n\nexport function normalizeVec2(out: Vec2Value): Vec2Value {\n const length = math_sqrt(out.x * out.x + out.y * out.y);\n if (length > 0) {\n const invLength = 1 / length;\n out.x *= invLength;\n out.y *= invLength;\n }\n return out;\n}\n\nexport function crossVec2Num(out: Vec2Value, v: Vec2Value, w: number): Vec2Value {\n const x = w * v.y;\n const y = -w * v.x;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function crossNumVec2(out: Vec2Value, w: number, v: Vec2Value): Vec2Value {\n const x = -w * v.y;\n const y = w * v.x;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function crossVec2Vec2(a: Vec2Value, b: Vec2Value): number {\n return a.x * b.y - a.y * b.x;\n}\n\nexport function dotVec2(a: Vec2Value, b: Vec2Value): number {\n return a.x * b.x + a.y * b.y;\n}\n\nexport function lengthVec2(a: Vec2Value): number {\n return math_sqrt(a.x * a.x + a.y * a.y);\n}\n\nexport function lengthSqrVec2(a: Vec2Value): number {\n return a.x * a.x + a.y * a.y;\n}\n\nexport function distVec2(a: Vec2Value, b: Vec2Value): number {\n const dx = a.x - b.x;\n const dy = a.y - b.y;\n return math_sqrt(dx * dx + dy * dy);\n}\n\nexport function distSqrVec2(a: Vec2Value, b: Vec2Value): number {\n const dx = a.x - b.x;\n const dy = a.y - b.y;\n return dx * dx + dy * dy;\n}\n\nexport function dotVec3(v: Vec3Value, w: Vec3Value): number {\n return v.x * w.x + v.y * w.y + v.z * w.z;\n}\n\nexport function setRotAngle(out: RotValue, a: number): RotValue {\n out.c = math_cos(a);\n out.s = math_sin(a);\n return out;\n}\n\nexport function rotVec2(out: Vec2Value, q: RotValue, v: Vec2Value): Vec2Value {\n out.x = q.c * v.x - q.s * v.y;\n out.y = q.s * v.x + q.c * v.y;\n return out;\n}\n\nexport function derotVec2(out: Vec2Value, q: RotValue, v: Vec2Value): Vec2Value {\n const x = q.c * v.x + q.s * v.y;\n const y = -q.s * v.x + q.c * v.y;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function rerotVec2(out: Vec2Value, before: RotValue, after: RotValue, v: Vec2Value): Vec2Value {\n const x0 = before.c * v.x + before.s * v.y;\n const y0 = -before.s * v.x + before.c * v.y;\n const x = after.c * x0 - after.s * y0;\n const y = after.s * x0 + after.c * y0;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function transform(x: number, y: number, a: number): TransformValue {\n return { p: vec2(x, y), q: rotation(a) };\n}\n\nexport function copyTransform(out: TransformValue, transform: TransformValue): TransformValue {\n out.p.x = transform.p.x;\n out.p.y = transform.p.y;\n out.q.s = transform.q.s;\n out.q.c = transform.q.c;\n return out;\n}\n\nexport function transformVec2(out: Vec2Value, xf: TransformValue, v: Vec2Value): Vec2Value {\n const x = xf.q.c * v.x - xf.q.s * v.y + xf.p.x;\n const y = xf.q.s * v.x + xf.q.c * v.y + xf.p.y;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function detransformVec2(out: Vec2Value, xf: TransformValue, v: Vec2Value): Vec2Value {\n const px = v.x - xf.p.x;\n const py = v.y - xf.p.y;\n const x = (xf.q.c * px + xf.q.s * py);\n const y = (-xf.q.s * px + xf.q.c * py);\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function retransformVec2(out: Vec2Value, from: TransformValue, to: TransformValue, v: Vec2Value): Vec2Value {\n const x0 = from.q.c * v.x - from.q.s * v.y + from.p.x;\n const y0 = from.q.s * v.x + from.q.c * v.y + from.p.y;\n const px = x0 - to.p.x;\n const py = y0 - to.p.y;\n const x = to.q.c * px + to.q.s * py;\n const y = -to.q.s * px + to.q.c * py;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function detransformTransform(out: TransformValue, a: TransformValue, b: TransformValue): TransformValue {\n const c = a.q.c * b.q.c + a.q.s * b.q.s;\n const s = a.q.c * b.q.s - a.q.s * b.q.c;\n const x = a.q.c * (b.p.x - a.p.x) + a.q.s * (b.p.y - a.p.y);\n const y = -a.q.s * (b.p.x - a.p.x) + a.q.c * (b.p.y - a.p.y);\n out.q.c = c;\n out.q.s = s;\n out.p.x = x;\n out.p.y = y;\n return out;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n/** @internal */ const math_atan2 = Math.atan2;\n\nexport interface RotValue {\n /** sin(angle) */\n s: number;\n /** cos(angle) */\n c: number;\n}\n\ndeclare module \"./Rot\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(angle: number): Rot;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(obj: RotValue): Rot;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(): Rot;\n}\n\n/** Rotation */\n// @ts-expect-error\nexport class Rot {\n /** sin(angle) */\n s: number;\n /** cos(angle) */\n c: number;\n\n /** Initialize from an angle in radians. */\n constructor(angle?: number | RotValue) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Rot)) {\n return new Rot(angle);\n }\n if (typeof angle === \"number\") {\n this.setAngle(angle);\n } else if (typeof angle === \"object\") {\n this.setRot(angle);\n } else {\n this.setIdentity();\n }\n }\n\n /** @hidden */\n static neo(angle: number): Rot {\n const obj = Object.create(Rot.prototype);\n obj.setAngle(angle);\n return obj;\n }\n\n static clone(rot: RotValue): Rot {\n if (_ASSERT) Rot.assert(rot);\n const obj = Object.create(Rot.prototype);\n obj.s = rot.s;\n obj.c = rot.c;\n return obj;\n }\n\n static identity(): Rot {\n const obj = Object.create(Rot.prototype);\n obj.s = 0.0;\n obj.c = 1.0;\n return obj;\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.s) && Number.isFinite(obj.c);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Rot.isValid(o), \"Invalid Rot!\", o);\n }\n\n /** Set to the identity rotation. */\n setIdentity(): void {\n this.s = 0.0;\n this.c = 1.0;\n }\n\n set(angle: number | RotValue): void {\n if (typeof angle === \"object\") {\n if (_ASSERT) Rot.assert(angle);\n this.s = angle.s;\n this.c = angle.c;\n\n } else {\n if (_ASSERT) console.assert(Number.isFinite(angle));\n // TODO_ERIN optimize\n this.s = math_sin(angle);\n this.c = math_cos(angle);\n }\n }\n\n setRot(angle: RotValue): void {\n if (_ASSERT) Rot.assert(angle);\n this.s = angle.s;\n this.c = angle.c;\n }\n\n /** Set using an angle in radians. */\n setAngle(angle: number): void {\n if (_ASSERT) console.assert(Number.isFinite(angle));\n // TODO_ERIN optimize\n this.s = math_sin(angle);\n this.c = math_cos(angle);\n }\n\n /** Get the angle in radians. */\n getAngle(): number {\n return math_atan2(this.s, this.c);\n }\n\n /** Get the x-axis. */\n getXAxis(): Vec2 {\n return Vec2.neo(this.c, this.s);\n }\n\n /** Get the y-axis. */\n getYAxis(): Vec2 {\n return Vec2.neo(-this.s, this.c);\n }\n\n /** Multiply two rotations: q * r */\n static mul(rot: RotValue, m: RotValue): Rot;\n /** Rotate a vector */\n static mul(rot: RotValue, m: Vec2Value): Vec2;\n static mul(rot, m) {\n if (_ASSERT) Rot.assert(rot);\n if (\"c\" in m && \"s\" in m) {\n if (_ASSERT) Rot.assert(m);\n // [qc -qs] * [rc -rs] = [qc*rc-qs*rs -qc*rs-qs*rc]\n // [qs qc] [rs rc] [qs*rc+qc*rs -qs*rs+qc*rc]\n // s = qs * rc + qc * rs\n // c = qc * rc - qs * rs\n const qr = Rot.identity();\n qr.s = rot.s * m.c + rot.c * m.s;\n qr.c = rot.c * m.c - rot.s * m.s;\n return qr;\n\n } else if (\"x\" in m && \"y\" in m) {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x - rot.s * m.y, rot.s * m.x + rot.c * m.y);\n }\n }\n\n /** Multiply two rotations: q * r */\n static mulRot(rot: RotValue, m: RotValue): Rot {\n if (_ASSERT) Rot.assert(rot);\n if (_ASSERT) Rot.assert(m);\n // [qc -qs] * [rc -rs] = [qc*rc-qs*rs -qc*rs-qs*rc]\n // [qs qc] [rs rc] [qs*rc+qc*rs -qs*rs+qc*rc]\n // s = qs * rc + qc * rs\n // c = qc * rc - qs * rs\n const qr = Rot.identity();\n qr.s = rot.s * m.c + rot.c * m.s;\n qr.c = rot.c * m.c - rot.s * m.s;\n return qr;\n }\n\n /** Rotate a vector */\n static mulVec2(rot: RotValue, m: Vec2Value): Vec2 {\n if (_ASSERT) Rot.assert(rot);\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x - rot.s * m.y, rot.s * m.x + rot.c * m.y);\n }\n\n static mulSub(rot: RotValue, v: Vec2Value, w: Vec2Value): Vec2 {\n const x = rot.c * (v.x - w.x) - rot.s * (v.y - w.y);\n const y = rot.s * (v.x - w.x) + rot.c * (v.y - w.y);\n return Vec2.neo(x, y);\n }\n\n /** Transpose multiply two rotations: qT * r */\n static mulT(rot: RotValue, m: RotValue): Rot;\n /** Inverse rotate a vector */\n static mulT(rot: RotValue, m: Vec2Value): Vec2;\n static mulT(rot, m) {\n if (\"c\" in m && \"s\" in m) {\n if (_ASSERT) Rot.assert(m);\n // [ qc qs] * [rc -rs] = [qc*rc+qs*rs -qc*rs+qs*rc]\n // [-qs qc] [rs rc] [-qs*rc+qc*rs qs*rs+qc*rc]\n // s = qc * rs - qs * rc\n // c = qc * rc + qs * rs\n const qr = Rot.identity();\n qr.s = rot.c * m.s - rot.s * m.c;\n qr.c = rot.c * m.c + rot.s * m.s;\n return qr;\n\n } else if (\"x\" in m && \"y\" in m) {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x + rot.s * m.y, -rot.s * m.x + rot.c * m.y);\n }\n }\n\n /** Transpose multiply two rotations: qT * r */\n static mulTRot(rot: RotValue, m: RotValue): Rot {\n if (_ASSERT) Rot.assert(m);\n // [ qc qs] * [rc -rs] = [qc*rc+qs*rs -qc*rs+qs*rc]\n // [-qs qc] [rs rc] [-qs*rc+qc*rs qs*rs+qc*rc]\n // s = qc * rs - qs * rc\n // c = qc * rc + qs * rs\n const qr = Rot.identity();\n qr.s = rot.c * m.s - rot.s * m.c;\n qr.c = rot.c * m.c + rot.s * m.s;\n return qr;\n }\n\n /** Inverse rotate a vector */\n static mulTVec2(rot: RotValue, m: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x + rot.s * m.y, -rot.s * m.x + rot.c * m.y);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"./Matrix\";\nimport { mod } from \"./Math\";\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { TransformValue } from \"./Transform\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_atan2 = Math.atan2;\n/** @internal */ const math_PI = Math.PI;\n\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n\n/**\n * This describes the motion of a body/shape for TOI computation. Shapes are\n * defined with respect to the body origin, which may not coincide with the\n * center of mass. However, to support dynamics we must interpolate the center\n * of mass position.\n */\nexport class Sweep {\n /** Local center of mass position */\n localCenter = Vec2.zero();\n\n /** World center position */\n c = Vec2.zero();\n\n /** World angle */\n a = 0;\n\n /** Fraction of the current time step in the range [0,1], c0 and a0 are c and a at alpha0. */\n alpha0 = 0;\n\n c0 = Vec2.zero();\n a0 = 0;\n\n /** @internal */\n recycle() {\n matrix.zeroVec2(this.localCenter);\n matrix.zeroVec2(this.c);\n this.a = 0;\n this.alpha0 = 0;\n matrix.zeroVec2(this.c0);\n this.a0 = 0;\n }\n\n setTransform(xf: TransformValue): void {\n matrix.transformVec2(temp, xf, this.localCenter);\n matrix.copyVec2(this.c, temp);\n matrix.copyVec2(this.c0, temp);\n\n this.a = this.a0 = math_atan2(xf.q.s, xf.q.c);\n }\n\n setLocalCenter(localCenter: Vec2Value, xf: TransformValue): void {\n matrix.copyVec2(this.localCenter, localCenter);\n\n matrix.transformVec2(temp, xf, this.localCenter);\n matrix.copyVec2(this.c, temp);\n matrix.copyVec2(this.c0, temp);\n }\n\n /**\n * Get the interpolated transform at a specific time.\n *\n * @param xf\n * @param beta A factor in [0,1], where 0 indicates alpha0\n */\n getTransform(xf: TransformValue, beta: number = 0): void {\n matrix.setRotAngle(xf.q, (1.0 - beta) * this.a0 + beta * this.a);\n matrix.combine2Vec2(xf.p, (1.0 - beta), this.c0, beta, this.c);\n\n // shift to origin\n matrix.minusVec2(xf.p, matrix.rotVec2(temp, xf.q, this.localCenter));\n }\n\n /**\n * Advance the sweep forward, yielding a new initial state.\n *\n * @param alpha The new initial time\n */\n advance(alpha: number): void {\n if (_ASSERT) console.assert(this.alpha0 < 1.0);\n const beta = (alpha - this.alpha0) / (1.0 - this.alpha0);\n matrix.combine2Vec2(this.c0, beta, this.c, 1 - beta, this.c0);\n this.a0 = beta * this.a + (1 - beta) * this.a0;\n this.alpha0 = alpha;\n }\n\n forward(): void {\n this.a0 = this.a;\n matrix.copyVec2(this.c0, this.c);\n }\n\n /**\n * normalize the angles in radians to be between -pi and pi.\n */\n normalize(): void {\n const a0 = mod(this.a0, -math_PI, +math_PI);\n this.a -= this.a0 - a0;\n this.a0 = a0;\n }\n\n set(that: Sweep): void {\n matrix.copyVec2(this.localCenter, that.localCenter);\n matrix.copyVec2(this.c, that.c);\n this.a = that.a;\n this.alpha0 = that.alpha0;\n matrix.copyVec2(this.c0, that.c0);\n this.a0 = that.a0;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { Rot, RotValue } from \"./Rot\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\nexport type TransformValue = {\n p: Vec2Value;\n q: RotValue;\n};\n\ndeclare module \"./Transform\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Transform(position?: Vec2Value, rotation?: number): Transform;\n}\n\n/**\n * A transform contains translation and rotation. It is used to represent the\n * position and orientation of rigid frames. Initialize using a position vector\n * and a rotation.\n */\n// @ts-expect-error\nexport class Transform {\n /** position */\n p: Vec2;\n\n /** rotation */\n q: Rot;\n\n constructor(position?: Vec2Value, rotation?: number) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Transform)) {\n return new Transform(position, rotation);\n }\n this.p = Vec2.zero();\n this.q = Rot.identity();\n if (typeof position !== \"undefined\") {\n this.p.setVec2(position);\n }\n if (typeof rotation !== \"undefined\") {\n this.q.setAngle(rotation);\n }\n }\n\n static clone(xf: Transform): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.clone(xf.p);\n obj.q = Rot.clone(xf.q);\n return obj;\n }\n\n /** @hidden */\n static neo(position: Vec2Value, rotation: Rot): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.clone(position);\n obj.q = Rot.clone(rotation);\n return obj;\n }\n\n static identity(): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.zero();\n obj.q = Rot.identity();\n return obj;\n }\n\n /** Set this to the identity transform */\n setIdentity(): void {\n this.p.setZero();\n this.q.setIdentity();\n }\n\n /** Set position and angle */\n set(position: Vec2Value, rotation: number): void;\n /** Copy from another transform */\n set(xf: TransformValue): void;\n set(a: any, b?: any) {\n if (typeof b === \"undefined\") {\n this.p.set(a.p);\n this.q.set(a.q);\n } else {\n this.p.set(a);\n this.q.set(b);\n }\n }\n\n /** Set position and angle */\n setNum(position: Vec2Value, rotation: number) {\n this.p.setVec2(position);\n this.q.setAngle(rotation);\n }\n\n setTransform(xf: TransformValue): void {\n this.p.setVec2(xf.p);\n this.q.setRot(xf.q);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.p) && Rot.isValid(obj.q);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Transform.isValid(o), \"Invalid Transform!\", o);\n }\n\n static mul(a: TransformValue, b: Vec2Value): Vec2;\n static mul(a: TransformValue, b: TransformValue): Transform;\n // static mul(a: Transform, b: Vec2Value[]): Vec2[];\n // static mul(a: Transform, b: Transform[]): Transform[];\n static mul(a, b) {\n if (Array.isArray(b)) {\n // todo: this was used in examples, remove in the future\n if (_ASSERT) Transform.assert(a);\n const arr = [];\n for (let i = 0; i < b.length; i++) {\n arr[i] = Transform.mul(a, b[i]);\n }\n return arr;\n\n } else if (\"x\" in b && \"y\" in b) {\n return Transform.mulVec2(a, b);\n\n } else if (\"p\" in b && \"q\" in b) {\n return Transform.mulXf(a, b);\n }\n }\n\n static mulAll(a: Transform, b: Vec2Value[]): Vec2[];\n static mulAll(a: Transform, b: Transform[]): Transform[];\n static mulAll(a: TransformValue, b) {\n if (_ASSERT) Transform.assert(a);\n const arr = [];\n for (let i = 0; i < b.length; i++) {\n arr[i] = Transform.mul(a, b[i]);\n }\n return arr;\n }\n\n /** @hidden @deprecated */\n static mulFn(a: TransformValue) {\n // todo: this was used in examples, remove in the future\n if (_ASSERT) Transform.assert(a);\n return function(b: Vec2Value): Vec2 {\n return Transform.mul(a, b);\n };\n }\n\n static mulVec2(a: TransformValue, b: Vec2Value): Vec2 {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const x = (a.q.c * b.x - a.q.s * b.y) + a.p.x;\n const y = (a.q.s * b.x + a.q.c * b.y) + a.p.y;\n return Vec2.neo(x, y);\n }\n\n static mulXf(a: TransformValue, b: TransformValue): Transform {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Transform.assert(b);\n // v2 = A.q.Rot(B.q.Rot(v1) + B.p) + A.p\n // = (A.q * B.q).Rot(v1) + A.q.Rot(B.p) + A.p\n const xf = Transform.identity();\n xf.q = Rot.mulRot(a.q, b.q);\n xf.p = Vec2.add(Rot.mulVec2(a.q, b.p), a.p);\n return xf;\n }\n\n static mulT(a: TransformValue, b: Vec2Value): Vec2;\n static mulT(a: TransformValue, b: TransformValue): Transform;\n static mulT(a, b) {\n if (\"x\" in b && \"y\" in b) {\n return Transform.mulTVec2(a, b);\n\n } else if (\"p\" in b && \"q\" in b) {\n return Transform.mulTXf(a, b);\n }\n }\n\n static mulTVec2(a: TransformValue, b: Vec2Value): Vec2 {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const px = b.x - a.p.x;\n const py = b.y - a.p.y;\n const x = (a.q.c * px + a.q.s * py);\n const y = (-a.q.s * px + a.q.c * py);\n return Vec2.neo(x, y);\n }\n\n static mulTXf(a: TransformValue, b: TransformValue): Transform {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Transform.assert(b);\n // v2 = A.q' * (B.q * v1 + B.p - A.p)\n // = A.q' * B.q * v1 + A.q' * (B.p - A.p)\n const xf = Transform.identity();\n xf.q.setRot(Rot.mulTRot(a.q, b.q));\n xf.p.setVec2(Rot.mulTVec2(a.q, Vec2.sub(b.p, a.p)));\n return xf;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2 } from \"../common/Vec2\";\n\nexport class Velocity {\n /** linear */\n v = Vec2.zero();\n\n /** angular */\n w = 0;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { TransformValue } from \"../common/Transform\";\n\n\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n\n\nexport class Position {\n /** location */\n c = Vec2.zero();\n\n /** angle */\n a = 0;\n\n // todo: cache sin/cos\n getTransform(xf: TransformValue, p: Vec2Value): TransformValue {\n // xf.q = rotation(this.a);\n // xf.p = this.c - xf.q * p\n xf.q.c = math_cos(this.a);\n xf.q.s = math_sin(this.a);\n xf.p.x = this.c.x - (xf.q.c * p.x - xf.q.s * p.y);\n xf.p.y = this.c.y - (xf.q.s * p.x + xf.q.c * p.y);\n return xf;\n }\n}\n\nexport function getTransform(xf: TransformValue, p: Vec2Value, c: Vec2Value, a: number): TransformValue {\n // xf.q = rotation(a);\n // xf.p = this.c - xf.q * p\n xf.q.c = math_cos(a);\n xf.q.s = math_sin(a);\n xf.p.x = c.x - (xf.q.c * p.x - xf.q.s * p.y);\n xf.p.y = c.y - (xf.q.s * p.x + xf.q.c * p.y);\n return xf;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { MassData } from \"../dynamics/Body\";\nimport { RayCastOutput, RayCastInput, AABBValue } from \"./AABB\";\nimport { DistanceProxy } from \"./Distance\";\nimport type { Transform, TransformValue } from \"../common/Transform\";\nimport type { Vec2Value } from \"../common/Vec2\";\nimport { Style } from \"../util/Testbed\";\n\n// todo make shape an interface\n\n/**\n * A shape is used for collision detection. You can create a shape however you\n * like. Shapes used for simulation in World are created automatically when a\n * Fixture is created. Shapes may encapsulate one or more child shapes.\n */\nexport abstract class Shape {\n /** @hidden */ m_type: ShapeType;\n\n /**\n * @hidden\n * Radius of a shape. For polygonal shapes this must be b2_polygonRadius.\n * There is no support for making rounded polygons.\n */\n m_radius: number;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n /** @hidden */\n abstract _reset(): void;\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return typeof obj.m_type === \"string\" && typeof obj.m_radius === \"number\";\n }\n\n abstract getRadius(): number;\n\n /**\n * Get the type of this shape. You can use this to down cast to the concrete\n * shape.\n *\n * @return the shape type.\n */\n abstract getType(): ShapeType;\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n abstract _clone(): Shape;\n\n /**\n * Get the number of child primitives.\n */\n abstract getChildCount(): number;\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n abstract testPoint(xf: TransformValue, p: Vec2Value): boolean;\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n abstract rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean;\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n abstract computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void;\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n abstract computeMass(massData: MassData, density?: number): void;\n\n abstract computeDistanceProxy(proxy: DistanceProxy, childIndex: number): void;\n\n}\n\nexport type ShapeType = \"circle\" | \"edge\" | \"polygon\" | \"chain\";\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { options } from \"../util/options\";\nimport { Vec2Value } from \"../common/Vec2\";\nimport { AABB, RayCastInput, RayCastOutput } from \"../collision/AABB\";\nimport { Shape, ShapeType } from \"../collision/Shape\";\nimport { Body, MassData } from \"./Body\";\nimport { BroadPhase } from \"../collision/BroadPhase\";\nimport { TransformValue } from \"../common/Transform\";\nimport { Style } from \"../util/Testbed\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/** @internal */ const synchronize_aabb1 = new AABB();\n/** @internal */ const synchronize_aabb2 = new AABB();\n/** @internal */ const displacement = matrix.vec2(0, 0);\n\n/**\n * A fixture definition is used to create a fixture. This class defines an\n * abstract fixture definition. You can reuse fixture definitions safely.\n */\nexport interface FixtureOpt {\n userData?: unknown;\n /**\n * The friction coefficient, usually in the range [0,1]\n */\n friction?: number;\n /**\n * The restitution (elasticity) usually in the range [0,1]\n */\n restitution?: number;\n /**\n * The density, usually in kg/m^2\n */\n density?: number;\n /**\n * A sensor shape collects contact information but never generates a collision response.\n */\n isSensor?: boolean;\n /**\n * Zero, positive or negative collision group.\n * Fixtures with same positive groupIndex always collide and fixtures with same negative groupIndex never collide.\n */\n filterGroupIndex?: number;\n /**\n * Collision category bit or bits that this fixture belongs to.\n * If groupIndex is zero or not matching, then at least one bit in this fixture categoryBits should match other fixture maskBits and vice versa.\n */\n filterCategoryBits?: number;\n /**\n * Collision category bit or bits that this fixture accept for collision.\n */\n filterMaskBits?: number;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\nexport interface FixtureDef extends FixtureOpt {\n shape: Shape;\n}\n\n/** @internal */ const FixtureDefDefault: FixtureOpt = {\n userData : null,\n friction : 0.2,\n restitution : 0.0,\n density : 0.0,\n isSensor : false,\n\n filterGroupIndex : 0,\n filterCategoryBits : 0x0001,\n filterMaskBits : 0xFFFF\n};\n\n/**\n * This proxy is used internally to connect shape children to the broad-phase.\n */\nexport class FixtureProxy {\n aabb: AABB;\n fixture: Fixture;\n childIndex: number;\n proxyId: number;\n constructor(fixture: Fixture, childIndex: number) {\n this.aabb = new AABB();\n this.fixture = fixture;\n this.childIndex = childIndex;\n // this.proxyId;\n }\n}\n\n/**\n * A fixture is used to attach a shape to a body for collision detection. A\n * fixture inherits its transform from its parent. Fixtures hold additional\n * non-geometric data such as friction, collision filters, etc.\n *\n * To create a new Fixture use {@link Body.createFixture}.\n */\nexport class Fixture {\n /** @internal */ m_body: Body;\n /** @internal */ m_friction: number;\n /** @internal */ m_restitution: number;\n /** @internal */ m_density: number;\n /** @internal */ m_isSensor: boolean;\n /** @internal */ m_filterGroupIndex: number;\n /** @internal */ m_filterCategoryBits: number;\n /** @internal */ m_filterMaskBits: number;\n /** @internal */ m_shape: Shape;\n /** @internal */ m_next: Fixture | null;\n /** @internal */ m_proxies: FixtureProxy[];\n // 0 indicates inactive state, this is not the same as m_proxies.length\n /** @internal */ m_proxyCount: number;\n /** @internal */ m_userData: unknown;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n constructor(body: Body, def: FixtureDef);\n constructor(body: Body, shape: Shape, def?: FixtureOpt);\n constructor(body: Body, shape: Shape, density?: number);\n /** @internal */\n constructor(body: Body, shape?, def?) {\n if (shape.shape) {\n def = shape;\n shape = shape.shape;\n\n } else if (typeof def === \"number\") {\n def = {density : def};\n }\n\n def = options(def, FixtureDefDefault);\n\n this.m_body = body;\n\n this.m_friction = def.friction;\n this.m_restitution = def.restitution;\n this.m_density = def.density;\n this.m_isSensor = def.isSensor;\n\n this.m_filterGroupIndex = def.filterGroupIndex;\n this.m_filterCategoryBits = def.filterCategoryBits;\n this.m_filterMaskBits = def.filterMaskBits;\n\n // TODO validate shape\n this.m_shape = shape; // .clone();\n\n this.m_next = null;\n\n this.m_proxies = [];\n this.m_proxyCount = 0;\n\n // fixture proxies are created here,\n // but they are activate in when a fixture is added to body\n const childCount = this.m_shape.getChildCount();\n for (let i = 0; i < childCount; ++i) {\n this.m_proxies[i] = new FixtureProxy(this, i);\n }\n\n this.m_userData = def.userData;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /** @hidden Re-setup fixture. */\n _reset(): void {\n const body = this.getBody();\n const broadPhase = body.m_world.m_broadPhase;\n this.destroyProxies(broadPhase);\n if (this.m_shape._reset) {\n this.m_shape._reset();\n }\n const childCount = this.m_shape.getChildCount();\n for (let i = 0; i < childCount; ++i) {\n this.m_proxies[i] = new FixtureProxy(this, i);\n }\n this.createProxies(broadPhase, body.m_xf);\n body.resetMassData();\n }\n\n /** @internal */\n _serialize(): object {\n return {\n friction: this.m_friction,\n restitution: this.m_restitution,\n density: this.m_density,\n isSensor: this.m_isSensor,\n\n filterGroupIndex: this.m_filterGroupIndex,\n filterCategoryBits: this.m_filterCategoryBits,\n filterMaskBits: this.m_filterMaskBits,\n\n shape: this.m_shape,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, body: any, restore: any): Fixture {\n const shape = restore(Shape, data.shape);\n const fixture = shape && new Fixture(body, shape, data);\n return fixture;\n }\n\n /**\n * Get the type of the child shape. You can use this to down cast to the\n * concrete shape.\n */\n getType(): ShapeType {\n return this.m_shape.m_type;\n }\n\n /**\n * Get the child shape. You can modify the child shape, however you should not\n * change the number of vertices because this will crash some collision caching\n * mechanisms. Manipulating the shape may lead to non-physical behavior.\n */\n getShape(): Shape {\n return this.m_shape;\n }\n\n /**\n * A sensor shape collects contact information but never generates a collision\n * response.\n */\n isSensor(): boolean {\n return this.m_isSensor;\n }\n\n /**\n * Set if this fixture is a sensor.\n */\n setSensor(sensor: boolean): void {\n if (sensor != this.m_isSensor) {\n this.m_body.setAwake(true);\n this.m_isSensor = sensor;\n }\n }\n\n // /**\n // * Get the contact filtering data.\n // */\n // getFilterData() {\n // return this.m_filter;\n // }\n\n /**\n * Get the user data that was assigned in the fixture definition. Use this to\n * store your application specific data.\n */\n getUserData(): unknown {\n return this.m_userData;\n }\n\n /**\n * Set the user data. Use this to store your application specific data.\n */\n setUserData(data: unknown): void {\n this.m_userData = data;\n }\n\n /**\n * Get the parent body of this fixture. This is null if the fixture is not\n * attached.\n */\n getBody(): Body {\n return this.m_body;\n }\n\n /**\n * Get the next fixture in the parent body's fixture list.\n */\n getNext(): Fixture | null {\n return this.m_next;\n }\n\n /**\n * Get the density of this fixture.\n */\n getDensity(): number {\n return this.m_density;\n }\n\n /**\n * Set the density of this fixture. This will _not_ automatically adjust the\n * mass of the body. You must call Body.resetMassData to update the body's mass.\n */\n setDensity(density: number): void {\n if (_ASSERT) console.assert(Number.isFinite(density) && density >= 0.0);\n this.m_density = density;\n }\n\n /**\n * Get the coefficient of friction, usually in the range [0,1].\n */\n getFriction(): number {\n return this.m_friction;\n }\n\n /**\n * Set the coefficient of friction. This will not change the friction of\n * existing contacts.\n */\n setFriction(friction: number): void {\n this.m_friction = friction;\n }\n\n /**\n * Get the coefficient of restitution.\n */\n getRestitution(): number {\n return this.m_restitution;\n }\n\n /**\n * Set the coefficient of restitution. This will not change the restitution of\n * existing contacts.\n */\n setRestitution(restitution: number): void {\n this.m_restitution = restitution;\n }\n\n /**\n * Test a point in world coordinates for containment in this fixture.\n */\n testPoint(p: Vec2Value): boolean {\n return this.m_shape.testPoint(this.m_body.getTransform(), p);\n }\n\n /**\n * Cast a ray against this shape.\n */\n rayCast(output: RayCastOutput, input: RayCastInput, childIndex: number): boolean {\n return this.m_shape.rayCast(output, input, this.m_body.getTransform(), childIndex);\n }\n\n /**\n * Get the mass data for this fixture. The mass data is based on the density and\n * the shape. The rotational inertia is about the shape's origin. This operation\n * may be expensive.\n */\n getMassData(massData: MassData): void {\n this.m_shape.computeMass(massData, this.m_density);\n }\n\n /**\n * Get the fixture's AABB. This AABB may be enlarge and/or stale. If you need a\n * more accurate AABB, compute it using the shape and the body transform.\n */\n getAABB(childIndex: number): AABB {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_proxies.length);\n return this.m_proxies[childIndex].aabb;\n }\n\n /**\n * These support body activation/deactivation.\n */\n createProxies(broadPhase: BroadPhase, xf: TransformValue): void {\n if (_ASSERT) console.assert(this.m_proxyCount == 0);\n\n // Create proxies in the broad-phase.\n this.m_proxyCount = this.m_shape.getChildCount();\n\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n this.m_shape.computeAABB(proxy.aabb, xf, i);\n proxy.proxyId = broadPhase.createProxy(proxy.aabb, proxy);\n }\n }\n\n destroyProxies(broadPhase: BroadPhase): void {\n // Destroy proxies in the broad-phase.\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n broadPhase.destroyProxy(proxy.proxyId);\n proxy.proxyId = null;\n }\n\n this.m_proxyCount = 0;\n }\n\n /**\n * Updates this fixture proxy in broad-phase (with combined AABB of current and\n * next transformation).\n */\n synchronize(broadPhase: BroadPhase, xf1: TransformValue, xf2: TransformValue): void {\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n // Compute an AABB that covers the swept shape (may miss some rotation\n // effect).\n this.m_shape.computeAABB(synchronize_aabb1, xf1, proxy.childIndex);\n this.m_shape.computeAABB(synchronize_aabb2, xf2, proxy.childIndex);\n\n proxy.aabb.combine(synchronize_aabb1, synchronize_aabb2);\n\n matrix.subVec2(displacement, xf2.p, xf1.p);\n\n broadPhase.moveProxy(proxy.proxyId, proxy.aabb, displacement);\n }\n }\n\n /**\n * Set the contact filtering data. This will not update contacts until the next\n * time step when either parent body is active and awake. This automatically\n * calls refilter.\n */\n setFilterData(filter: { groupIndex: number, categoryBits: number, maskBits: number }): void {\n this.m_filterGroupIndex = filter.groupIndex;\n this.m_filterCategoryBits = filter.categoryBits;\n this.m_filterMaskBits = filter.maskBits;\n this.refilter();\n }\n\n getFilterGroupIndex(): number {\n return this.m_filterGroupIndex;\n }\n\n setFilterGroupIndex(groupIndex: number): void {\n this.m_filterGroupIndex = groupIndex;\n this.refilter();\n }\n\n getFilterCategoryBits(): number {\n return this.m_filterCategoryBits;\n }\n\n setFilterCategoryBits(categoryBits: number): void {\n this.m_filterCategoryBits = categoryBits;\n this.refilter();\n }\n\n getFilterMaskBits(): number {\n return this.m_filterMaskBits;\n }\n\n setFilterMaskBits(maskBits: number): void {\n this.m_filterMaskBits = maskBits;\n this.refilter();\n }\n\n /**\n * Call this if you want to establish collision that was previously disabled by\n * ContactFilter.\n */\n refilter(): void {\n if (this.m_body == null) {\n return;\n }\n\n // Flag associated contacts for filtering.\n let edge = this.m_body.getContactList();\n while (edge) {\n const contact = edge.contact;\n const fixtureA = contact.getFixtureA();\n const fixtureB = contact.getFixtureB();\n if (fixtureA == this || fixtureB == this) {\n contact.flagForFiltering();\n }\n\n edge = edge.next;\n }\n\n const world = this.m_body.getWorld();\n\n if (world == null) {\n return;\n }\n\n // Touch each proxy so that new pairs may be created\n const broadPhase = world.m_broadPhase;\n for (let i = 0; i < this.m_proxyCount; ++i) {\n broadPhase.touchProxy(this.m_proxies[i].proxyId);\n }\n }\n\n /**\n * Implement this method to provide collision filtering, if you want finer\n * control over contact creation.\n *\n * Return true if contact calculations should be performed between these two\n * fixtures.\n *\n * Warning: for performance reasons this is only called when the AABBs begin to\n * overlap.\n */\n shouldCollide(that: Fixture): boolean {\n\n if (that.m_filterGroupIndex === this.m_filterGroupIndex && that.m_filterGroupIndex !== 0) {\n return that.m_filterGroupIndex > 0;\n }\n\n const collideA = (that.m_filterMaskBits & this.m_filterCategoryBits) !== 0;\n const collideB = (that.m_filterCategoryBits & this.m_filterMaskBits) !== 0;\n const collide = collideA && collideB;\n return collide;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { options } from \"../util/options\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { Rot } from \"../common/Rot\";\nimport { Sweep } from \"../common/Sweep\";\nimport { Transform, TransformValue } from \"../common/Transform\";\nimport { Velocity } from \"./Velocity\";\nimport { Position } from \"./Position\";\nimport { Fixture, FixtureDef, FixtureOpt } from \"./Fixture\";\nimport { Shape } from \"../collision/Shape\";\nimport { JointEdge } from \"./Joint\";\nimport { World } from \"./World\";\nimport { ContactEdge } from \"./Contact\";\nimport { Style } from \"../util/Testbed\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A static body does not move under simulation and behaves as if it has infinite mass.\n * Internally, zero is stored for the mass and the inverse mass.\n * Static bodies can be moved manually by the user.\n * A static body has zero velocity.\n * Static bodies do not collide with other static or kinematic bodies.\n * \n * A kinematic body moves under simulation according to its velocity.\n * Kinematic bodies do not respond to forces.\n * They can be moved manually by the user, but normally a kinematic body is moved by setting its velocity.\n * A kinematic body behaves as if it has infinite mass, however, zero is stored for the mass and the inverse mass.\n * Kinematic bodies do not collide with other kinematic or static bodies.\n * \n * A dynamic body is fully simulated.\n * They can be moved manually by the user, but normally they move according to forces.\n * A dynamic body can collide with all body types.\n * A dynamic body always has finite, non-zero mass.\n * If you try to set the mass of a dynamic body to zero, it will automatically acquire a mass of one kilogram and it won't rotate.\n */\nexport type BodyType = \"static\" | \"kinematic\" | \"dynamic\";\n\n/** @internal */ const STATIC = \"static\";\n/** @internal */ const KINEMATIC = \"kinematic\";\n/** @internal */ const DYNAMIC = \"dynamic\";\n\n/** @internal */ const oldCenter = matrix.vec2(0, 0);\n/** @internal */ const localCenter = matrix.vec2(0, 0);\n/** @internal */ const shift = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n\nexport interface BodyDef {\n /**\n * Body types are static, kinematic, or dynamic. Note: if a dynamic\n * body would have zero mass, the mass is set to one.\n */\n type?: BodyType;\n /**\n * The world position of the body. Avoid creating bodies at the\n * origin since this can lead to many overlapping shapes.\n */\n position?: Vec2Value;\n /**\n * The world angle of the body in radians.\n */\n angle?: number;\n /**\n * The linear velocity of the body's origin in world co-ordinates.\n */\n linearVelocity?: Vec2Value;\n angularVelocity?: number;\n /**\n * Linear damping is use to reduce the linear velocity. The\n * damping parameter can be larger than 1.0 but the damping effect becomes\n * sensitive to the time step when the damping parameter is large.\n * Units are 1/time\n */\n linearDamping?: number;\n /**\n * Angular damping is use to reduce the angular velocity.\n * The damping parameter can be larger than 1.0 but the damping effect\n * becomes sensitive to the time step when the damping parameter is large.\n * Units are 1/time\n */\n angularDamping?: number;\n /**\n * Should this body be prevented from rotating? Useful for characters.\n */\n fixedRotation?: boolean;\n /**\n * Is this a fast moving body that should be prevented from\n * tunneling through other moving bodies? Note that all bodies are\n * prevented from tunneling through kinematic and static bodies. This\n * setting is only considered on dynamic bodies. Warning: You should use\n * this flag sparingly since it increases processing time.\n */\n bullet?: boolean;\n gravityScale?: number;\n /**\n * Set this flag to false if this body should never fall asleep. Note that this increases CPU usage.\n */\n allowSleep?: boolean;\n /**\n * Is this body initially awake or sleeping?\n */\n awake?: boolean;\n /**\n * Does this body start out active?\n */\n active?: boolean;\n userData?: any;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\n/** @internal */ const BodyDefDefault: BodyDef = {\n type : STATIC,\n position : Vec2.zero(),\n angle : 0.0,\n\n linearVelocity : Vec2.zero(),\n angularVelocity : 0.0,\n\n linearDamping : 0.0,\n angularDamping : 0.0,\n\n fixedRotation : false,\n bullet : false,\n gravityScale : 1.0,\n\n allowSleep : true,\n awake : true,\n active : true,\n\n userData : null\n};\n\n/**\n * MassData This holds the mass data computed for a shape.\n */\nexport interface MassData {\n /** The mass of the shape, usually in kilograms. */\n mass: number;\n /** The position of the shape's centroid relative to the shape's origin. */\n center: Vec2Value;\n /** The rotational inertia of the shape about the local origin. */\n I: number;\n}\n\n/**\n * A rigid body composed of one or more fixtures.\n *\n * To create a new Body use {@link World.createBody}.\n */\nexport class Body {\n /** @hidden */\n static readonly STATIC: BodyType = \"static\";\n /** @hidden */\n static readonly KINEMATIC: BodyType = \"kinematic\";\n /** @hidden */\n static readonly DYNAMIC: BodyType = \"dynamic\";\n\n /** @internal */ m_world: World;\n /** @internal */ m_awakeFlag: boolean;\n /** @internal */ m_autoSleepFlag: boolean;\n /** @internal */ m_bulletFlag: boolean;\n /** @internal */ m_fixedRotationFlag: boolean;\n /** @internal */ m_activeFlag: boolean;\n /** @internal */ m_islandFlag: boolean;\n /** @internal */ m_toiFlag: boolean;\n /** @internal */ m_userData: unknown;\n /** @internal */ m_type: BodyType;\n /** @internal */ m_mass: number;\n /** @internal */ m_invMass: number;\n /** @internal Rotational inertia about the center of mass. */\n m_I: number;\n /** @internal */ m_invI: number;\n /** @internal the body origin transform */\n m_xf: Transform;\n /** @internal the swept motion for CCD */\n m_sweep: Sweep;\n // position and velocity correction\n /** @internal */ c_velocity: Velocity;\n /** @internal */ c_position: Position;\n /** @internal */ m_force: Vec2;\n /** @internal */ m_torque: number;\n /** @internal */ m_linearVelocity: Vec2;\n /** @internal */ m_angularVelocity: number;\n /** @internal */ m_linearDamping: number;\n /** @internal */ m_angularDamping: number;\n /** @internal */ m_gravityScale: number;\n /** @internal */ m_sleepTime: number;\n /** @internal */ m_jointList: JointEdge | null;\n /** @internal */ m_contactList: ContactEdge | null;\n /** @internal */ m_fixtureList: Fixture | null;\n /** @internal */ m_prev: Body | null;\n /** @internal */ m_next: Body | null;\n /** @internal */ m_destroyed: boolean;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n /** @internal */\n constructor(world: World, def: BodyDef) {\n def = options(def, BodyDefDefault);\n\n if (_ASSERT) console.assert(Vec2.isValid(def.position));\n if (_ASSERT) console.assert(Vec2.isValid(def.linearVelocity));\n if (_ASSERT) console.assert(Number.isFinite(def.angle));\n if (_ASSERT) console.assert(Number.isFinite(def.angularVelocity));\n if (_ASSERT) console.assert(Number.isFinite(def.angularDamping) && def.angularDamping >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.linearDamping) && def.linearDamping >= 0.0);\n\n this.m_world = world;\n\n this.m_awakeFlag = def.awake;\n this.m_autoSleepFlag = def.allowSleep;\n this.m_bulletFlag = def.bullet;\n this.m_fixedRotationFlag = def.fixedRotation;\n this.m_activeFlag = def.active;\n\n this.m_islandFlag = false;\n this.m_toiFlag = false;\n\n this.m_userData = def.userData;\n this.m_type = def.type;\n\n if (this.m_type == DYNAMIC) {\n this.m_mass = 1.0;\n this.m_invMass = 1.0;\n } else {\n this.m_mass = 0.0;\n this.m_invMass = 0.0;\n }\n\n // Rotational inertia about the center of mass.\n this.m_I = 0.0;\n this.m_invI = 0.0;\n\n // the body origin transform\n this.m_xf = Transform.identity();\n this.m_xf.p.setVec2(def.position);\n this.m_xf.q.setAngle(def.angle);\n\n // the swept motion for CCD\n this.m_sweep = new Sweep();\n this.m_sweep.setTransform(this.m_xf);\n\n // position and velocity correction\n this.c_velocity = new Velocity();\n this.c_position = new Position();\n\n this.m_force = Vec2.zero();\n this.m_torque = 0.0;\n\n this.m_linearVelocity = Vec2.clone(def.linearVelocity);\n this.m_angularVelocity = def.angularVelocity;\n\n this.m_linearDamping = def.linearDamping;\n this.m_angularDamping = def.angularDamping;\n this.m_gravityScale = def.gravityScale;\n\n this.m_sleepTime = 0.0;\n\n this.m_jointList = null;\n this.m_contactList = null;\n this.m_fixtureList = null;\n\n this.m_prev = null;\n this.m_next = null;\n\n this.m_destroyed = false;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /** @internal */\n _serialize(): object {\n const fixtures = [];\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n fixtures.push(f);\n }\n return {\n type: this.m_type,\n bullet: this.m_bulletFlag,\n position: this.m_xf.p,\n angle: this.m_xf.q.getAngle(),\n linearVelocity: this.m_linearVelocity,\n angularVelocity: this.m_angularVelocity,\n fixtures,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): Body {\n const body = new Body(world, data);\n\n if (data.fixtures) {\n for (let i = data.fixtures.length - 1; i >= 0; i--) {\n const fixture = restore(Fixture, data.fixtures[i], body);\n body._addFixture(fixture);\n }\n }\n return body;\n }\n\n isWorldLocked(): boolean {\n return this.m_world && this.m_world.isLocked() ? true : false;\n }\n\n getWorld(): World {\n return this.m_world;\n }\n\n getNext(): Body | null {\n return this.m_next;\n }\n\n setUserData(data: any): void {\n this.m_userData = data;\n }\n\n getUserData(): unknown {\n return this.m_userData;\n }\n\n getFixtureList(): Fixture | null {\n return this.m_fixtureList;\n }\n\n getJointList(): JointEdge | null {\n return this.m_jointList;\n }\n\n /**\n * Warning: this list changes during the time step and you may miss some\n * collisions if you don't use ContactListener.\n */\n getContactList(): ContactEdge | null {\n return this.m_contactList;\n }\n\n isStatic(): boolean {\n return this.m_type == STATIC;\n }\n\n isDynamic(): boolean {\n return this.m_type == DYNAMIC;\n }\n\n isKinematic(): boolean {\n return this.m_type == KINEMATIC;\n }\n\n /**\n * This will alter the mass and velocity.\n */\n setStatic(): Body {\n this.setType(STATIC);\n return this;\n }\n\n setDynamic(): Body {\n this.setType(DYNAMIC);\n return this;\n }\n\n setKinematic(): Body {\n this.setType(KINEMATIC);\n return this;\n }\n\n /**\n * Get the type of the body.\n */\n getType(): BodyType {\n return this.m_type;\n }\n\n /**\n * Set the type of the body to \"static\", \"kinematic\" or \"dynamic\".\n * @param type The type of the body.\n */\n setType(type: BodyType): void {\n if (_ASSERT) console.assert(type === STATIC || type === KINEMATIC || type === DYNAMIC);\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (this.m_type == type) {\n return;\n }\n\n this.m_type = type;\n\n this.resetMassData();\n\n if (this.m_type == STATIC) {\n this.m_linearVelocity.setZero();\n this.m_angularVelocity = 0.0;\n this.m_sweep.forward();\n this.synchronizeFixtures();\n }\n\n this.setAwake(true);\n\n this.m_force.setZero();\n this.m_torque = 0.0;\n\n // Delete the attached contacts.\n let ce = this.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n this.m_world.destroyContact(ce0.contact);\n }\n this.m_contactList = null;\n\n // Touch the proxies so that new contacts will be created (when appropriate)\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n for (let i = 0; i < f.m_proxyCount; ++i) {\n broadPhase.touchProxy(f.m_proxies[i].proxyId);\n }\n }\n }\n\n isBullet(): boolean {\n return this.m_bulletFlag;\n }\n\n /**\n * Should this body be treated like a bullet for continuous collision detection?\n */\n setBullet(flag: boolean): void {\n this.m_bulletFlag = !!flag;\n }\n\n isSleepingAllowed(): boolean {\n return this.m_autoSleepFlag;\n }\n\n setSleepingAllowed(flag: boolean): void {\n this.m_autoSleepFlag = !!flag;\n if (this.m_autoSleepFlag == false) {\n this.setAwake(true);\n }\n }\n\n isAwake(): boolean {\n return this.m_awakeFlag;\n }\n\n /**\n * Set the sleep state of the body. A sleeping body has very low CPU cost.\n *\n * @param flag Set to true to wake the body, false to put it to sleep.\n */\n setAwake(flag: boolean): void {\n if (flag) {\n this.m_awakeFlag = true;\n this.m_sleepTime = 0.0;\n } else {\n this.m_awakeFlag = false;\n this.m_sleepTime = 0.0;\n this.m_linearVelocity.setZero();\n this.m_angularVelocity = 0.0;\n this.m_force.setZero();\n this.m_torque = 0.0;\n }\n }\n\n isActive(): boolean {\n return this.m_activeFlag;\n }\n\n /**\n * Set the active state of the body. An inactive body is not simulated and\n * cannot be collided with or woken up. If you pass a flag of true, all fixtures\n * will be added to the broad-phase. If you pass a flag of false, all fixtures\n * will be removed from the broad-phase and all contacts will be destroyed.\n * Fixtures and joints are otherwise unaffected.\n *\n * You may continue to create/destroy fixtures and joints on inactive bodies.\n * Fixtures on an inactive body are implicitly inactive and will not participate\n * in collisions, ray-casts, or queries. Joints connected to an inactive body\n * are implicitly inactive. An inactive body is still owned by a World object\n * and remains\n */\n setActive(flag: boolean): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (flag == this.m_activeFlag) {\n return;\n }\n\n this.m_activeFlag = !!flag;\n\n if (this.m_activeFlag) {\n // Create all proxies.\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.createProxies(broadPhase, this.m_xf);\n }\n\t\t // Contacts are created at the beginning of the next\n\t\t this.m_world.m_newFixture = true;\n } else {\n // Destroy all proxies.\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.destroyProxies(broadPhase);\n }\n\n // Destroy the attached contacts.\n let ce = this.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n this.m_world.destroyContact(ce0.contact);\n }\n this.m_contactList = null;\n }\n }\n\n isFixedRotation(): boolean {\n return this.m_fixedRotationFlag;\n }\n\n /**\n * Set this body to have fixed rotation. This causes the mass to be reset.\n */\n setFixedRotation(flag: boolean): void {\n if (this.m_fixedRotationFlag == flag) {\n return;\n }\n\n this.m_fixedRotationFlag = !!flag;\n\n this.m_angularVelocity = 0.0;\n\n this.resetMassData();\n }\n\n /**\n * Get the world transform for the body's origin.\n */\n getTransform(): Transform {\n return this.m_xf;\n }\n\n /**\n * Set the position of the body's origin and rotation. Manipulating a body's\n * transform may cause non-physical behavior. Note: contacts are updated on the\n * next call to World.step.\n *\n * @param position The world position of the body's local origin.\n * @param angle The world rotation in radians.\n */\n setTransform(position: Vec2Value, angle: number): void;\n /**\n * Set the position of the body's origin and rotation. Manipulating a body's\n * transform may cause non-physical behavior. Note: contacts are updated on the\n * next call to World.step.\n */\n setTransform(xf: Transform): void;\n setTransform(a: Vec2Value | Transform, b?: number): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return;\n }\n if (typeof b === \"number\") {\n this.m_xf.setNum(a as Vec2Value, b);\n } else {\n this.m_xf.setTransform(a as TransformValue);\n }\n\n this.m_sweep.setTransform(this.m_xf);\n\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.synchronize(broadPhase, this.m_xf, this.m_xf);\n }\n this.setAwake(true);\n }\n\n synchronizeTransform(): void {\n this.m_sweep.getTransform(this.m_xf, 1);\n }\n\n /**\n * Update fixtures in broad-phase.\n */\n synchronizeFixtures(): void {\n this.m_sweep.getTransform(xf, 0);\n\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.synchronize(broadPhase, xf, this.m_xf);\n }\n }\n\n /**\n * Used in TOI.\n */\n advance(alpha: number): void {\n // Advance to the new safe time. This doesn't sync the broad-phase.\n this.m_sweep.advance(alpha);\n matrix.copyVec2(this.m_sweep.c, this.m_sweep.c0);\n this.m_sweep.a = this.m_sweep.a0;\n this.m_sweep.getTransform(this.m_xf, 1);\n }\n\n /**\n * Get the world position for the body's origin.\n */\n getPosition(): Vec2 {\n return this.m_xf.p;\n }\n\n setPosition(p: Vec2Value): void {\n this.setTransform(p, this.m_sweep.a);\n }\n\n /**\n * Get the current world rotation angle in radians.\n */\n getAngle(): number {\n return this.m_sweep.a;\n }\n\n setAngle(angle: number): void {\n this.setTransform(this.m_xf.p, angle);\n }\n\n /**\n * Get the world position of the center of mass.\n */\n getWorldCenter(): Vec2 {\n return this.m_sweep.c;\n }\n\n /**\n * Get the local position of the center of mass.\n */\n getLocalCenter(): Vec2 {\n return this.m_sweep.localCenter;\n }\n\n /**\n * Get the linear velocity of the center of mass.\n *\n * @return the linear velocity of the center of mass.\n */\n getLinearVelocity(): Vec2 {\n return this.m_linearVelocity;\n }\n\n /**\n * Get the world linear velocity of a world point attached to this body.\n *\n * @param worldPoint A point in world coordinates.\n */\n getLinearVelocityFromWorldPoint(worldPoint: Vec2Value): Vec2 {\n const localCenter = Vec2.sub(worldPoint, this.m_sweep.c);\n return Vec2.add(this.m_linearVelocity, Vec2.crossNumVec2(this.m_angularVelocity,\n localCenter));\n }\n\n /**\n * Get the world velocity of a local point.\n *\n * @param localPoint A point in local coordinates.\n */\n getLinearVelocityFromLocalPoint(localPoint: Vec2Value): Vec2 {\n return this.getLinearVelocityFromWorldPoint(this.getWorldPoint(localPoint));\n }\n\n /**\n * Set the linear velocity of the center of mass.\n *\n * @param v The new linear velocity of the center of mass.\n */\n setLinearVelocity(v: Vec2Value): void {\n if (this.m_type == STATIC) {\n return;\n }\n if (Vec2.dot(v, v) > 0.0) {\n this.setAwake(true);\n }\n this.m_linearVelocity.setVec2(v);\n }\n\n /**\n * Get the angular velocity.\n *\n * @returns the angular velocity in radians/second.\n */\n getAngularVelocity(): number {\n return this.m_angularVelocity;\n }\n\n /**\n * Set the angular velocity.\n *\n * @param w The new angular velocity in radians/second.\n */\n setAngularVelocity(w: number): void {\n if (this.m_type == STATIC) {\n return;\n }\n if (w * w > 0.0) {\n this.setAwake(true);\n }\n this.m_angularVelocity = w;\n }\n\n getLinearDamping(): number {\n return this.m_linearDamping;\n }\n\n setLinearDamping(linearDamping: number): void {\n this.m_linearDamping = linearDamping;\n }\n\n getAngularDamping(): number {\n return this.m_angularDamping;\n }\n\n setAngularDamping(angularDamping: number): void {\n this.m_angularDamping = angularDamping;\n }\n\n getGravityScale(): number {\n return this.m_gravityScale;\n }\n\n /**\n * Scale the gravity applied to this body.\n */\n setGravityScale(scale: number): void {\n this.m_gravityScale = scale;\n }\n\n /**\n * Get the total mass of the body.\n *\n * @returns The mass, usually in kilograms (kg).\n */\n getMass(): number {\n return this.m_mass;\n }\n\n /**\n * Get the rotational inertia of the body about the local origin.\n *\n * @return the rotational inertia, usually in kg-m^2.\n */\n getInertia(): number {\n return this.m_I + this.m_mass\n * Vec2.dot(this.m_sweep.localCenter, this.m_sweep.localCenter);\n }\n\n /**\n * Copy the mass data of the body to data.\n */\n getMassData(data: MassData): void {\n data.mass = this.m_mass;\n data.I = this.getInertia();\n matrix.copyVec2(data.center, this.m_sweep.localCenter);\n }\n\n /**\n * This resets the mass properties to the sum of the mass properties of the\n * fixtures. This normally does not need to be called unless you called\n * SetMassData to override the mass and you later want to reset the mass.\n */\n resetMassData(): void {\n // Compute mass data from shapes. Each shape has its own density.\n this.m_mass = 0.0;\n this.m_invMass = 0.0;\n this.m_I = 0.0;\n this.m_invI = 0.0;\n matrix.zeroVec2(this.m_sweep.localCenter);\n\n // Static and kinematic bodies have zero mass.\n if (this.isStatic() || this.isKinematic()) {\n matrix.copyVec2(this.m_sweep.c0, this.m_xf.p);\n matrix.copyVec2(this.m_sweep.c, this.m_xf.p);\n this.m_sweep.a0 = this.m_sweep.a;\n return;\n }\n\n if (_ASSERT) console.assert(this.isDynamic());\n\n // Accumulate mass over all fixtures.\n matrix.zeroVec2(localCenter);\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n if (f.m_density == 0.0) {\n continue;\n }\n\n const massData: MassData = {\n mass: 0,\n center: matrix.vec2(0, 0),\n I: 0\n };\n f.getMassData(massData);\n this.m_mass += massData.mass;\n matrix.plusScaleVec2(localCenter, massData.mass, massData.center);\n this.m_I += massData.I;\n }\n\n // Compute center of mass.\n if (this.m_mass > 0.0) {\n this.m_invMass = 1.0 / this.m_mass;\n matrix.scaleVec2(localCenter, this.m_invMass, localCenter);\n\n } else {\n // Force all dynamic bodies to have a positive mass.\n this.m_mass = 1.0;\n this.m_invMass = 1.0;\n }\n\n if (this.m_I > 0.0 && this.m_fixedRotationFlag == false) {\n // Center the inertia about the center of mass.\n this.m_I -= this.m_mass * matrix.dotVec2(localCenter, localCenter);\n if (_ASSERT) console.assert(this.m_I > 0.0);\n this.m_invI = 1.0 / this.m_I;\n\n } else {\n this.m_I = 0.0;\n this.m_invI = 0.0;\n }\n\n // Move center of mass.\n matrix.copyVec2(oldCenter, this.m_sweep.c);\n this.m_sweep.setLocalCenter(localCenter, this.m_xf);\n\n // Update center of mass velocity.\n matrix.subVec2(shift, this.m_sweep.c, oldCenter);\n matrix.crossNumVec2(temp, this.m_angularVelocity, shift);\n matrix.plusVec2(this.m_linearVelocity, temp);\n }\n\n /**\n * Set the mass properties to override the mass properties of the fixtures. Note\n * that this changes the center of mass position. Note that creating or\n * destroying fixtures can also alter the mass. This function has no effect if\n * the body isn't dynamic.\n *\n * @param massData The mass properties.\n */\n setMassData(massData: MassData): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (this.m_type != DYNAMIC) {\n return;\n }\n\n this.m_invMass = 0.0;\n this.m_I = 0.0;\n this.m_invI = 0.0;\n\n this.m_mass = massData.mass;\n if (this.m_mass <= 0.0) {\n this.m_mass = 1.0;\n }\n\n this.m_invMass = 1.0 / this.m_mass;\n\n if (massData.I > 0.0 && this.m_fixedRotationFlag == false) {\n this.m_I = massData.I - this.m_mass * matrix.dotVec2(massData.center, massData.center);\n if (_ASSERT) console.assert(this.m_I > 0.0);\n this.m_invI = 1.0 / this.m_I;\n }\n\n // Move center of mass.\n matrix.copyVec2(oldCenter, this.m_sweep.c);\n this.m_sweep.setLocalCenter(massData.center, this.m_xf);\n\n // Update center of mass velocity.\n matrix.subVec2(shift, this.m_sweep.c, oldCenter);\n matrix.crossNumVec2(temp, this.m_angularVelocity, shift);\n matrix.plusVec2(this.m_linearVelocity, temp);\n }\n\n /**\n * Apply a force at a world point. If the force is not applied at the center of\n * mass, it will generate a torque and affect the angular velocity. This wakes\n * up the body.\n *\n * @param force The world force vector, usually in Newtons (N).\n * @param point The world position of the point of application.\n * @param wake Also wake up the body\n */\n applyForce(force: Vec2Value, point: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping.\n if (this.m_awakeFlag) {\n this.m_force.add(force);\n this.m_torque += Vec2.crossVec2Vec2(Vec2.sub(point, this.m_sweep.c), force);\n }\n }\n\n /**\n * Apply a force to the center of mass. This wakes up the body.\n *\n * @param force The world force vector, usually in Newtons (N).\n * @param wake Also wake up the body\n */\n applyForceToCenter(force: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_force.add(force);\n }\n }\n\n /**\n * Apply a torque. This affects the angular velocity without affecting the\n * linear velocity of the center of mass. This wakes up the body.\n *\n * @param torque About the z-axis (out of the screen), usually in N-m.\n * @param wake Also wake up the body\n */\n applyTorque(torque: number, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_torque += torque;\n }\n }\n\n /**\n * Apply an impulse at a point. This immediately modifies the velocity. It also\n * modifies the angular velocity if the point of application is not at the\n * center of mass. This wakes up the body.\n *\n * @param impulse The world impulse vector, usually in N-seconds or kg-m/s.\n * @param point The world position of the point of application.\n * @param wake Also wake up the body\n */\n applyLinearImpulse(impulse: Vec2Value, point: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n\n // Don't accumulate velocity if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_linearVelocity.addMul(this.m_invMass, impulse);\n this.m_angularVelocity += this.m_invI * Vec2.crossVec2Vec2(Vec2.sub(point, this.m_sweep.c), impulse);\n }\n }\n\n /**\n * Apply an angular impulse.\n *\n * @param impulse The angular impulse in units of kg*m*m/s\n * @param wake Also wake up the body\n */\n applyAngularImpulse(impulse: number, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate velocity if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_angularVelocity += this.m_invI * impulse;\n }\n }\n\n /**\n * This is used to test if two bodies should collide.\n * \n * Bodies do not collide when:\n * - Neither of them is dynamic\n * - They are connected by a joint with collideConnected == false\n */\n shouldCollide(that: Body): boolean {\n // At least one body should be dynamic.\n if (this.m_type != DYNAMIC && that.m_type != DYNAMIC) {\n return false;\n }\n // Does a joint prevent collision?\n for (let jn = this.m_jointList; jn; jn = jn.next) {\n if (jn.other == that) {\n if (jn.joint.m_collideConnected == false) {\n return false;\n }\n }\n }\n return true;\n }\n\n /** @internal Used for deserialize. */\n _addFixture(fixture: Fixture): Fixture {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return null;\n }\n\n if (this.m_activeFlag) {\n const broadPhase = this.m_world.m_broadPhase;\n fixture.createProxies(broadPhase, this.m_xf);\n }\n\n fixture.m_next = this.m_fixtureList;\n this.m_fixtureList = fixture;\n\n // Adjust mass properties if needed.\n if (fixture.m_density > 0.0) {\n this.resetMassData();\n }\n\n // Let the world know we have a new fixture. This will cause new contacts\n // to be created at the beginning of the next time step.\n this.m_world.m_newFixture = true;\n\n return fixture;\n }\n\n /**\n * Creates a fixture and attach it to this body.\n *\n * If the density is non-zero, this function automatically updates the mass of\n * the body.\n *\n * Contacts are not created until the next time step.\n *\n * Warning: This function is locked during callbacks.\n */\n createFixture(def: FixtureDef): Fixture;\n createFixture(shape: Shape, opt?: FixtureOpt): Fixture;\n createFixture(shape: Shape, density?: number): Fixture;\n // tslint:disable-next-line:typedef\n createFixture(shape, fixdef?) {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return null;\n }\n\n const fixture = new Fixture(this, shape, fixdef);\n this._addFixture(fixture);\n return fixture;\n }\n\n /**\n * Destroy a fixture. This removes the fixture from the broad-phase and destroys\n * all contacts associated with this fixture. This will automatically adjust the\n * mass of the body if the body is dynamic and the fixture has positive density.\n * All fixtures attached to a body are implicitly destroyed when the body is\n * destroyed.\n *\n * Warning: This function is locked during callbacks.\n *\n * @param fixture The fixture to be removed.\n */\n destroyFixture(fixture: Fixture): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (_ASSERT) console.assert(fixture.m_body == this);\n\n // Remove the fixture from this body's singly linked list.\n let found = false;\n if (this.m_fixtureList === fixture) {\n this.m_fixtureList = fixture.m_next;\n found = true;\n\n } else {\n let node = this.m_fixtureList;\n while (node != null) {\n if (node.m_next === fixture) {\n node.m_next = fixture.m_next;\n found = true;\n break;\n }\n node = node.m_next;\n }\n }\n\n // You tried to remove a shape that is not attached to this body.\n if (_ASSERT) console.assert(found);\n\n // Destroy any contacts associated with the fixture.\n let edge = this.m_contactList;\n while (edge) {\n const c = edge.contact;\n edge = edge.next;\n\n const fixtureA = c.getFixtureA();\n const fixtureB = c.getFixtureB();\n\n if (fixture == fixtureA || fixture == fixtureB) {\n // This destroys the contact and removes it from\n // this body's contact list.\n this.m_world.destroyContact(c);\n }\n }\n\n if (this.m_activeFlag) {\n const broadPhase = this.m_world.m_broadPhase;\n fixture.destroyProxies(broadPhase);\n }\n\n fixture.m_body = null;\n fixture.m_next = null;\n\n this.m_world.publish(\"remove-fixture\", fixture);\n\n // Reset the mass data.\n this.resetMassData();\n }\n\n /**\n * Get the corresponding world point of a local point.\n */\n getWorldPoint(localPoint: Vec2Value): Vec2 {\n return Transform.mulVec2(this.m_xf, localPoint);\n }\n\n /**\n * Get the corresponding world vector of a local vector.\n */\n getWorldVector(localVector: Vec2Value): Vec2 {\n return Rot.mulVec2(this.m_xf.q, localVector);\n }\n\n /**\n * Gets the corresponding local point of a world point.\n */\n getLocalPoint(worldPoint: Vec2Value): Vec2 {\n return Transform.mulTVec2(this.m_xf, worldPoint);\n }\n\n /**\n * Gets the corresponding local vector of a world vector.\n */\n getLocalVector(worldVector: Vec2Value): Vec2 {\n return Rot.mulTVec2(this.m_xf.q, worldVector);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { Vec2, Vec2Value } from \"../common/Vec2\";\nimport type { Body } from \"./Body\";\nimport { TimeStep } from \"./Solver\";\nimport { Style } from \"../util/Testbed\";\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/**\n * A joint edge is used to connect bodies and joints together in a joint graph\n * where each body is a node and each joint is an edge. A joint edge belongs to\n * a doubly linked list maintained in each attached body. Each joint has two\n * joint nodes, one for each attached body.\n */\nexport class JointEdge {\n /**\n * provides quick access to the other body attached.\n */\n other: Body | null = null;\n /**\n * the joint\n */\n joint: Joint | null = null;\n /**\n * prev the previous joint edge in the body's joint list\n */\n prev: JointEdge | null = null;\n /**\n * the next joint edge in the body's joint list\n */\n next: JointEdge | null = null;\n}\n\n/**\n * Joint definitions are used to construct joints.\n */\nexport interface JointOpt {\n /**\n * Use this to attach application specific data to your joints.\n */\n userData?: any;\n /**\n * Set this flag to true if the attached bodies\n * should collide.\n */\n collideConnected?: boolean;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\n/**\n * Joint definitions are used to construct joints.\n */\nexport interface JointDef extends JointOpt {\n /**\n * The first attached body.\n */\n bodyA: Body;\n /**\n * The second attached body.\n */\n bodyB: Body;\n}\n\n/** @internal */ const DEFAULTS = {\n userData : null,\n collideConnected : false\n};\n\n/**\n * The base joint class. Joints are used to constraint two bodies together in\n * various fashions. Some joints also feature limits and motors.\n */\nexport abstract class Joint {\n\n /** @internal */ m_type: string = \"unknown-joint\";\n\n /** @internal */ m_bodyA: Body;\n /** @internal */ m_bodyB: Body;\n\n /** @internal */ m_collideConnected: boolean;\n\n /** @internal */ m_prev: Joint | null = null;\n /** @internal */ m_next: Joint | null = null;\n\n /** @internal */ m_edgeA: JointEdge = new JointEdge();\n /** @internal */ m_edgeB: JointEdge = new JointEdge();\n\n /** @internal */ m_islandFlag: boolean = false;\n /** @internal */ m_userData: unknown;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n constructor(def: JointDef);\n constructor(def: JointOpt, bodyA: Body, bodyB: Body);\n constructor(def: JointDef | JointOpt, bodyA?: Body, bodyB?: Body) {\n bodyA = \"bodyA\" in def ? def.bodyA : bodyA;\n bodyB = \"bodyB\" in def ? def.bodyB : bodyB;\n\n if (_ASSERT) console.assert(!!bodyA);\n if (_ASSERT) console.assert(!!bodyB);\n if (_ASSERT) console.assert(bodyA != bodyB);\n\n this.m_bodyA = bodyA!;\n this.m_bodyB = bodyB!;\n\n this.m_collideConnected = !!def.collideConnected;\n this.m_userData = def.userData;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /**\n * Short-cut function to determine if either body is inactive.\n */\n isActive(): boolean {\n return this.m_bodyA.isActive() && this.m_bodyB.isActive();\n }\n\n /**\n * Get the type of the concrete joint.\n */\n getType(): string {\n return this.m_type;\n }\n\n /**\n * Get the first body attached to this joint.\n */\n getBodyA(): Body {\n return this.m_bodyA;\n }\n\n /**\n * Get the second body attached to this joint.\n */\n getBodyB(): Body {\n return this.m_bodyB;\n }\n\n /**\n * Get the next joint the world joint list.\n */\n getNext(): Joint {\n return this.m_next;\n }\n\n getUserData(): unknown {\n return this.m_userData;\n }\n\n setUserData(data: unknown): void {\n this.m_userData = data;\n }\n\n /**\n * Get collide connected. Note: modifying the collide connect flag won't work\n * correctly because the flag is only checked when fixture AABBs begin to\n * overlap.\n */\n getCollideConnected(): boolean {\n return this.m_collideConnected;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n abstract getAnchorA(): Vec2;\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n abstract getAnchorB(): Vec2;\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n abstract getReactionForce(inv_dt: number): Vec2;\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n abstract getReactionTorque(inv_dt: number): number;\n\n /**\n * Shift the origin for any points stored in world coordinates.\n */\n shiftOrigin(newOrigin: Vec2Value): void {}\n\n abstract initVelocityConstraints(step: TimeStep): void;\n\n abstract solveVelocityConstraints(step: TimeStep): void;\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n abstract solvePositionConstraints(step: TimeStep): boolean;\n\n /**\n * @hidden @experimental\n * Update joint with new props.\n */\n abstract _reset(def: Partial): void;\n\n /**\n * @internal @deprecated\n * Temporary for backward compatibility, will be removed.\n */\n _resetAnchors(def: any): void {\n return this._reset(def);\n }\n}\n","/** @hidden */\nexport const stats = {\n gjkCalls: 0,\n gjkIters: 0,\n gjkMaxIters: 0,\n\n toiTime: 0,\n toiMaxTime: 0,\n toiCalls: 0,\n toiIters: 0,\n toiMaxIters: 0,\n toiRootIters: 0,\n toiMaxRootIters: 0,\n\n toString(newline?: string): string {\n newline = typeof newline === \"string\" ? newline : \"\\n\";\n let string = \"\";\n // tslint:disable-next-line:no-for-in\n for (const name in this) {\n if (typeof this[name] !== \"function\" && typeof this[name] !== \"object\") {\n string += name + \": \" + this[name] + newline;\n }\n }\n return string;\n }\n};\n","/** @internal */\nexport const now = function(): number {\n return Date.now();\n};\n\n/** @internal */\nexport const diff = function(time: number): number {\n return Date.now() - time;\n};\n\n/** @internal */\nexport default {\n now,\n diff,\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { stats } from \"../util/stats\";\nimport { Shape } from \"./Shape\";\nimport { EPSILON } from \"../common/Math\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { Rot } from \"../common/Rot\";\nimport { Transform, TransformValue } from \"../common/Transform\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_max = Math.max;\n\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const e12 = matrix.vec2(0, 0);\n/** @internal */ const e13 = matrix.vec2(0, 0);\n/** @internal */ const e23 = matrix.vec2(0, 0);\n/** @internal */ const temp1 = matrix.vec2(0, 0);\n/** @internal */ const temp2 = matrix.vec2(0, 0);\n\n/**\n * GJK using Voronoi regions (Christer Ericson) and Barycentric coordinates.\n */\n\nstats.gjkCalls = 0;\nstats.gjkIters = 0;\nstats.gjkMaxIters = 0;\n\n/**\n * Input for Distance. You have to option to use the shape radii in the\n * computation. Even\n */\nexport class DistanceInput {\n readonly proxyA = new DistanceProxy();\n readonly proxyB = new DistanceProxy();\n readonly transformA = Transform.identity();\n readonly transformB = Transform.identity();\n useRadii = false;\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.transformA.setIdentity();\n this.transformB.setIdentity();\n this.useRadii = false;\n }\n}\n\n/**\n * Output for Distance.\n */\nexport class DistanceOutput {\n /** closest point on shapeA */\n pointA = matrix.vec2(0, 0);\n /** closest point on shapeB */\n pointB = matrix.vec2(0, 0);\n distance = 0;\n /** iterations number of GJK iterations used */\n iterations = 0;\n recycle() {\n matrix.zeroVec2(this.pointA);\n matrix.zeroVec2(this.pointB);\n this.distance = 0;\n this.iterations = 0;\n }\n}\n\n/**\n * Used to warm start Distance. Set count to zero on first call.\n */\nexport class SimplexCache {\n /** length or area */\n metric: number = 0;\n /** vertices on shape A */\n indexA: number[] = [];\n /** vertices on shape B */\n indexB: number[] = [];\n count: number = 0;\n recycle() {\n this.metric = 0;\n this.indexA.length = 0;\n this.indexB.length = 0;\n this.count = 0;\n }\n}\n\n/**\n * Compute the closest points between two shapes. Supports any combination of:\n * CircleShape, PolygonShape, EdgeShape. The simplex cache is input/output. On\n * the first call set SimplexCache.count to zero.\n */\nexport const Distance = function (output: DistanceOutput, cache: SimplexCache, input: DistanceInput): void {\n ++stats.gjkCalls;\n\n const proxyA = input.proxyA;\n const proxyB = input.proxyB;\n const xfA = input.transformA;\n const xfB = input.transformB;\n\n // Initialize the simplex.\n // const simplex = new Simplex();\n simplex.recycle();\n simplex.readCache(cache, proxyA, xfA, proxyB, xfB);\n\n // Get simplex vertices as an array.\n const vertices = simplex.m_v;\n const k_maxIters = Settings.maxDistanceIterations;\n\n // These store the vertices of the last simplex so that we\n // can check for duplicates and prevent cycling.\n const saveA = [];\n const saveB = []; // int[3]\n let saveCount = 0;\n\n // Main iteration loop.\n let iter = 0;\n while (iter < k_maxIters) {\n // Copy simplex so we can identify duplicates.\n saveCount = simplex.m_count;\n for (let i = 0; i < saveCount; ++i) {\n saveA[i] = vertices[i].indexA;\n saveB[i] = vertices[i].indexB;\n }\n\n simplex.solve();\n\n // If we have 3 points, then the origin is in the corresponding triangle.\n if (simplex.m_count === 3) {\n break;\n }\n\n // Get search direction.\n const d = simplex.getSearchDirection();\n\n // Ensure the search direction is numerically fit.\n if (matrix.lengthSqrVec2(d) < EPSILON * EPSILON) {\n // The origin is probably contained by a line segment\n // or triangle. Thus the shapes are overlapped.\n\n // We can't return zero here even though there may be overlap.\n // In case the simplex is a point, segment, or triangle it is difficult\n // to determine if the origin is contained in the CSO or very close to it.\n break;\n }\n\n // Compute a tentative new simplex vertex using support points.\n const vertex = vertices[simplex.m_count]; // SimplexVertex\n\n vertex.indexA = proxyA.getSupport(matrix.derotVec2(temp, xfA.q, matrix.scaleVec2(temp, -1, d)));\n matrix.transformVec2(vertex.wA, xfA, proxyA.getVertex(vertex.indexA));\n\n vertex.indexB = proxyB.getSupport(matrix.derotVec2(temp, xfB.q, d));\n matrix.transformVec2(vertex.wB, xfB, proxyB.getVertex(vertex.indexB));\n\n matrix.subVec2(vertex.w, vertex.wB, vertex.wA);\n\n // Iteration count is equated to the number of support point calls.\n ++iter;\n ++stats.gjkIters;\n\n // Check for duplicate support points. This is the main termination\n // criteria.\n let duplicate = false;\n for (let i = 0; i < saveCount; ++i) {\n if (vertex.indexA === saveA[i] && vertex.indexB === saveB[i]) {\n duplicate = true;\n break;\n }\n }\n\n // If we found a duplicate support point we must exit to avoid cycling.\n if (duplicate) {\n break;\n }\n\n // New vertex is ok and needed.\n ++simplex.m_count;\n }\n\n stats.gjkMaxIters = math_max(stats.gjkMaxIters, iter);\n\n // Prepare output.\n simplex.getWitnessPoints(output.pointA, output.pointB);\n output.distance = matrix.distVec2(output.pointA, output.pointB);\n output.iterations = iter;\n\n // Cache the simplex.\n simplex.writeCache(cache);\n\n // Apply radii if requested.\n if (input.useRadii) {\n const rA = proxyA.m_radius;\n const rB = proxyB.m_radius;\n\n if (output.distance > rA + rB && output.distance > EPSILON) {\n // Shapes are still no overlapped.\n // Move the witness points to the outer surface.\n output.distance -= rA + rB;\n matrix.subVec2(normal, output.pointB, output.pointA);\n matrix.normalizeVec2(normal);\n matrix.plusScaleVec2(output.pointA, rA, normal);\n matrix.minusScaleVec2(output.pointB, rB, normal);\n } else {\n // Shapes are overlapped when radii are considered.\n // Move the witness points to the middle.\n const p = matrix.subVec2(temp, output.pointA, output.pointB);\n matrix.copyVec2(output.pointA, p);\n matrix.copyVec2(output.pointB, p);\n output.distance = 0.0;\n }\n }\n};\n\n/**\n * A distance proxy is used by the GJK algorithm. It encapsulates any shape.\n */\nexport class DistanceProxy {\n /** @internal */ m_vertices: Vec2Value[] = [];\n // todo: remove this?\n /** @internal */ m_count = 0;\n /** @internal */ m_radius = 0;\n\n recycle() {\n this.m_vertices.length = 0;\n this.m_count = 0;\n this.m_radius = 0;\n }\n\n /**\n * Get the vertex count.\n */\n getVertexCount(): number {\n return this.m_count;\n }\n\n /**\n * Get a vertex by index. Used by Distance.\n */\n getVertex(index: number): Vec2Value {\n if (_ASSERT) console.assert(0 <= index && index < this.m_count);\n return this.m_vertices[index];\n }\n\n /**\n * Get the supporting vertex index in the given direction.\n */\n getSupport(d: Vec2Value): number {\n let bestIndex = -1;\n let bestValue = -Infinity;\n for (let i = 0; i < this.m_count; ++i) {\n const value = matrix.dotVec2(this.m_vertices[i], d);\n if (value > bestValue) {\n bestIndex = i;\n bestValue = value;\n }\n }\n return bestIndex;\n }\n\n /**\n * Get the supporting vertex in the given direction.\n */\n getSupportVertex(d: Vec2Value): Vec2Value {\n return this.m_vertices[this.getSupport(d)];\n }\n\n /**\n * Initialize the proxy using the given shape. The shape must remain in scope\n * while the proxy is in use.\n */\n set(shape: Shape, index: number): void {\n // TODO remove, use shape instead\n if (_ASSERT) console.assert(typeof shape.computeDistanceProxy === \"function\");\n shape.computeDistanceProxy(this, index);\n }\n\n /**\n * Initialize the proxy using a vertex cloud and radius. The vertices\n * must remain in scope while the proxy is in use.\n */\n setVertices(vertices: Vec2Value[], count: number, radius: number) {\n this.m_vertices = vertices;\n this.m_count = count;\n this.m_radius = radius;\n }\n}\n\nclass SimplexVertex {\n /** support point in proxyA */\n wA = matrix.vec2(0, 0);\n /** wA index */\n indexA = 0;\n\n /** support point in proxyB */\n wB = matrix.vec2(0, 0);\n /** wB index */\n indexB = 0;\n\n /** wB - wA; */\n w = matrix.vec2(0, 0);\n /** barycentric coordinate for closest point */\n a = 0;\n\n recycle() {\n this.indexA = 0;\n this.indexB = 0;\n matrix.zeroVec2(this.wA);\n matrix.zeroVec2(this.wB);\n matrix.zeroVec2(this.w);\n this.a = 0;\n }\n set(v: SimplexVertex): void {\n this.indexA = v.indexA;\n this.indexB = v.indexB;\n matrix.copyVec2(this.wA, v.wA);\n matrix.copyVec2(this.wB, v.wB);\n matrix.copyVec2(this.w, v.w);\n this.a = v.a;\n }\n}\n\n/** @internal */ const searchDirection_reuse = matrix.vec2(0, 0);\n/** @internal */ const closestPoint_reuse = matrix.vec2(0, 0); \n\nclass Simplex {\n m_v1 = new SimplexVertex();\n m_v2 = new SimplexVertex();\n m_v3 = new SimplexVertex();\n m_v = [this.m_v1, this.m_v2, this.m_v3];\n m_count: number;\n recycle() {\n this.m_v1.recycle();\n this.m_v2.recycle();\n this.m_v3.recycle();\n this.m_count = 0;\n }\n\n /** @internal */ toString(): string {\n if (this.m_count === 3) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y,\n this.m_v2.a, this.m_v2.wA.x, this.m_v2.wA.y, this.m_v2.wB.x, this.m_v2.wB.y,\n this.m_v3.a, this.m_v3.wA.x, this.m_v3.wA.y, this.m_v3.wB.x, this.m_v3.wB.y\n ].toString();\n\n } else if (this.m_count === 2) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y,\n this.m_v2.a, this.m_v2.wA.x, this.m_v2.wA.y, this.m_v2.wB.x, this.m_v2.wB.y\n ].toString();\n\n } else if (this.m_count === 1) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y\n ].toString();\n\n } else {\n return \"+\" + this.m_count;\n }\n }\n\n readCache(cache: SimplexCache, proxyA: DistanceProxy, transformA: TransformValue, proxyB: DistanceProxy, transformB: TransformValue): void {\n if (_ASSERT) console.assert(cache.count <= 3);\n\n // Copy data from cache.\n this.m_count = cache.count;\n for (let i = 0; i < this.m_count; ++i) {\n const v = this.m_v[i];\n v.indexA = cache.indexA[i];\n v.indexB = cache.indexB[i];\n const wALocal = proxyA.getVertex(v.indexA);\n const wBLocal = proxyB.getVertex(v.indexB);\n matrix.transformVec2(v.wA, transformA, wALocal);\n matrix.transformVec2(v.wB, transformB, wBLocal);\n matrix.subVec2(v.w,v.wB, v.wA);\n v.a = 0.0;\n }\n\n // Compute the new simplex metric, if it is substantially different than\n // old metric then flush the simplex.\n if (this.m_count > 1) {\n const metric1 = cache.metric;\n const metric2 = this.getMetric();\n if (metric2 < 0.5 * metric1 || 2.0 * metric1 < metric2 || metric2 < EPSILON) {\n // Reset the simplex.\n this.m_count = 0;\n }\n }\n\n // If the cache is empty or invalid...\n if (this.m_count === 0) {\n const v = this.m_v[0];\n v.indexA = 0;\n v.indexB = 0;\n const wALocal = proxyA.getVertex(0);\n const wBLocal = proxyB.getVertex(0);\n matrix.transformVec2(v.wA, transformA, wALocal);\n matrix.transformVec2(v.wB, transformB, wBLocal);\n matrix.subVec2(v.w,v.wB, v.wA);\n v.a = 1.0;\n this.m_count = 1;\n }\n }\n\n writeCache(cache: SimplexCache): void {\n cache.metric = this.getMetric();\n cache.count = this.m_count;\n for (let i = 0; i < this.m_count; ++i) {\n cache.indexA[i] = this.m_v[i].indexA;\n cache.indexB[i] = this.m_v[i].indexB;\n }\n }\n\n getSearchDirection(): Vec2Value {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 1:\n return matrix.setVec2(searchDirection_reuse, -v1.w.x, -v1.w.y);\n\n case 2: {\n matrix.subVec2(e12, v2.w, v1.w);\n const sgn = -matrix.crossVec2Vec2(e12, v1.w);\n if (sgn > 0.0) {\n // Origin is left of e12.\n return matrix.setVec2(searchDirection_reuse, -e12.y, e12.x);\n } else {\n // Origin is right of e12.\n return matrix.setVec2(searchDirection_reuse, e12.y, -e12.x);\n }\n }\n\n default:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(searchDirection_reuse);\n }\n }\n\n getClosestPoint(): Vec2Value {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(closestPoint_reuse);\n\n case 1:\n return matrix.copyVec2(closestPoint_reuse, v1.w);\n\n case 2:\n return matrix.combine2Vec2(closestPoint_reuse, v1.a, v1.w, v2.a, v2.w);\n\n case 3:\n return matrix.zeroVec2(closestPoint_reuse);\n\n default:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(closestPoint_reuse);\n }\n }\n\n getWitnessPoints(pA: Vec2Value, pB: Vec2Value): void {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n break;\n\n case 1:\n matrix.copyVec2(pA, v1.wA);\n matrix.copyVec2(pB, v1.wB);\n break;\n\n case 2:\n matrix.combine2Vec2(pA, v1.a, v1.wA, v2.a, v2.wA);\n matrix.combine2Vec2(pB, v1.a, v1.wB, v2.a, v2.wB);\n break;\n\n case 3:\n matrix.combine3Vec2(pA, v1.a, v1.wA, v2.a, v2.wA, v3.a, v3.wA);\n matrix.copyVec2(pB, pA);\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n break;\n }\n }\n\n getMetric(): number {\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n return 0.0;\n\n case 1:\n return 0.0;\n\n case 2:\n return matrix.distVec2(this.m_v1.w, this.m_v2.w);\n\n case 3:\n return matrix.crossVec2Vec2(\n matrix.subVec2(temp1, this.m_v2.w, this.m_v1.w),\n matrix.subVec2(temp2, this.m_v3.w, this.m_v1.w),\n );\n\n default:\n if (_ASSERT) console.assert(false);\n return 0.0;\n }\n }\n\n solve(): void {\n switch (this.m_count) {\n case 1:\n break;\n\n case 2:\n this.solve2();\n break;\n\n case 3:\n this.solve3();\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n }\n }\n\n// Solve a line segment using barycentric coordinates.\n//\n// p = a1 * w1 + a2 * w2\n// a1 + a2 = 1\n//\n// The vector from the origin to the closest point on the line is\n// perpendicular to the line.\n// e12 = w2 - w1\n// dot(p, e) = 0\n// a1 * dot(w1, e) + a2 * dot(w2, e) = 0\n//\n// 2-by-2 linear system\n// [1 1 ][a1] = [1]\n// [w1.e12 w2.e12][a2] = [0]\n//\n// Define\n// d12_1 = dot(w2, e12)\n// d12_2 = -dot(w1, e12)\n// d12 = d12_1 + d12_2\n//\n// Solution\n// a1 = d12_1 / d12\n// a2 = d12_2 / d12\n solve2(): void {\n const w1 = this.m_v1.w;\n const w2 = this.m_v2.w;\n matrix.subVec2(e12, w2, w1);\n\n // w1 region\n const d12_2 = -matrix.dotVec2(w1, e12);\n if (d12_2 <= 0.0) {\n // a2 <= 0, so we clamp it to 0\n this.m_v1.a = 1.0;\n this.m_count = 1;\n return;\n }\n\n // w2 region\n const d12_1 = matrix.dotVec2(w2, e12);\n if (d12_1 <= 0.0) {\n // a1 <= 0, so we clamp it to 0\n this.m_v2.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v2);\n return;\n }\n\n // Must be in e12 region.\n const inv_d12 = 1.0 / (d12_1 + d12_2);\n this.m_v1.a = d12_1 * inv_d12;\n this.m_v2.a = d12_2 * inv_d12;\n this.m_count = 2;\n }\n\n// Possible regions:\n// - points[2]\n// - edge points[0]-points[2]\n// - edge points[1]-points[2]\n// - inside the triangle\n solve3(): void {\n const w1 = this.m_v1.w;\n const w2 = this.m_v2.w;\n const w3 = this.m_v3.w;\n\n // Edge12\n // [1 1 ][a1] = [1]\n // [w1.e12 w2.e12][a2] = [0]\n // a3 = 0\n matrix.subVec2(e12, w2, w1);\n const w1e12 = matrix.dotVec2(w1, e12);\n const w2e12 = matrix.dotVec2(w2, e12);\n const d12_1 = w2e12;\n const d12_2 = -w1e12;\n\n // Edge13\n // [1 1 ][a1] = [1]\n // [w1.e13 w3.e13][a3] = [0]\n // a2 = 0\n matrix.subVec2(e13, w3, w1);\n const w1e13 = matrix.dotVec2(w1, e13);\n const w3e13 = matrix.dotVec2(w3, e13);\n const d13_1 = w3e13;\n const d13_2 = -w1e13;\n\n // Edge23\n // [1 1 ][a2] = [1]\n // [w2.e23 w3.e23][a3] = [0]\n // a1 = 0\n matrix.subVec2(e23, w3, w2);\n const w2e23 = matrix.dotVec2(w2, e23);\n const w3e23 = matrix.dotVec2(w3, e23);\n const d23_1 = w3e23;\n const d23_2 = -w2e23;\n\n // Triangle123\n const n123 = matrix.crossVec2Vec2(e12, e13);\n\n const d123_1 = n123 * matrix.crossVec2Vec2(w2, w3);\n const d123_2 = n123 * matrix.crossVec2Vec2(w3, w1);\n const d123_3 = n123 * matrix.crossVec2Vec2(w1, w2);\n\n // w1 region\n if (d12_2 <= 0.0 && d13_2 <= 0.0) {\n this.m_v1.a = 1.0;\n this.m_count = 1;\n return;\n }\n\n // e12\n if (d12_1 > 0.0 && d12_2 > 0.0 && d123_3 <= 0.0) {\n const inv_d12 = 1.0 / (d12_1 + d12_2);\n this.m_v1.a = d12_1 * inv_d12;\n this.m_v2.a = d12_2 * inv_d12;\n this.m_count = 2;\n return;\n }\n\n // e13\n if (d13_1 > 0.0 && d13_2 > 0.0 && d123_2 <= 0.0) {\n const inv_d13 = 1.0 / (d13_1 + d13_2);\n this.m_v1.a = d13_1 * inv_d13;\n this.m_v3.a = d13_2 * inv_d13;\n this.m_count = 2;\n this.m_v2.set(this.m_v3);\n return;\n }\n\n // w2 region\n if (d12_1 <= 0.0 && d23_2 <= 0.0) {\n this.m_v2.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v2);\n return;\n }\n\n // w3 region\n if (d13_1 <= 0.0 && d23_1 <= 0.0) {\n this.m_v3.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v3);\n return;\n }\n\n // e23\n if (d23_1 > 0.0 && d23_2 > 0.0 && d123_1 <= 0.0) {\n const inv_d23 = 1.0 / (d23_1 + d23_2);\n this.m_v2.a = d23_1 * inv_d23;\n this.m_v3.a = d23_2 * inv_d23;\n this.m_count = 2;\n this.m_v1.set(this.m_v3);\n return;\n }\n\n // Must be in triangle123\n const inv_d123 = 1.0 / (d123_1 + d123_2 + d123_3);\n this.m_v1.a = d123_1 * inv_d123;\n this.m_v2.a = d123_2 * inv_d123;\n this.m_v3.a = d123_3 * inv_d123;\n this.m_count = 3;\n }\n}\n\n/** @internal */ const simplex = new Simplex();\n\n/** @internal */ const input = new DistanceInput();\n/** @internal */ const cache = new SimplexCache();\n/** @internal */ const output = new DistanceOutput();\n\n/**\n * Determine if two generic shapes overlap.\n */\nexport const testOverlap = function (shapeA: Shape, indexA: number, shapeB: Shape, indexB: number, xfA: TransformValue, xfB: TransformValue): boolean {\n input.recycle();\n input.proxyA.set(shapeA, indexA);\n input.proxyB.set(shapeB, indexB);\n matrix.copyTransform(input.transformA, xfA);\n matrix.copyTransform(input.transformB, xfB);\n input.useRadii = true;\n\n output.recycle();\n cache.recycle();\n\n Distance(output, cache, input);\n\n return output.distance < 10.0 * EPSILON;\n};\n\n// legacy exports\nDistance.testOverlap = testOverlap;\nDistance.Input = DistanceInput;\nDistance.Output = DistanceOutput;\nDistance.Proxy = DistanceProxy;\nDistance.Cache = SimplexCache;\n\n/**\n * Input parameters for ShapeCast\n */\nexport class ShapeCastInput {\n readonly proxyA = new DistanceProxy();\n readonly proxyB = new DistanceProxy();\n readonly transformA = Transform.identity();\n readonly transformB = Transform.identity();\n readonly translationB = Vec2.zero();\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.transformA.setIdentity();\n this.transformB.setIdentity();\n matrix.zeroVec2(this.translationB);\n }\n}\n\n/**\n * Output results for b2ShapeCast\n */\nexport class ShapeCastOutput {\n point: Vec2 = Vec2.zero();\n normal: Vec2 = Vec2.zero();\n lambda = 1.0;\n iterations = 0;\n}\n\n/**\n * Perform a linear shape cast of shape B moving and shape A fixed. Determines\n * the hit point, normal, and translation fraction.\n * \n * @returns true if hit, false if there is no hit or an initial overlap\n */\n//\n// GJK-raycast\n// Algorithm by Gino van den Bergen.\n// \"Smooth Mesh Contacts with GJK\" in Game Physics Pearls. 2010\nexport const ShapeCast = function(output: ShapeCastOutput, input: ShapeCastInput): boolean {\n output.iterations = 0;\n output.lambda = 1.0;\n output.normal.setZero();\n output.point.setZero();\n\n const proxyA = input.proxyA;\n const proxyB = input.proxyB;\n\n const radiusA = math_max(proxyA.m_radius, Settings.polygonRadius);\n const radiusB = math_max(proxyB.m_radius, Settings.polygonRadius);\n const radius = radiusA + radiusB;\n\n const xfA = input.transformA;\n const xfB = input.transformB;\n\n const r = input.translationB;\n const n = Vec2.zero();\n let lambda = 0.0;\n\n // Initial simplex\n const simplex = new Simplex();\n simplex.m_count = 0;\n\n // Get simplex vertices as an array.\n const vertices = simplex.m_v;\n\n // Get support point in -r direction\n let indexA = proxyA.getSupport(Rot.mulTVec2(xfA.q, Vec2.neg(r)));\n let wA = Transform.mulVec2(xfA, proxyA.getVertex(indexA));\n let indexB = proxyB.getSupport(Rot.mulTVec2(xfB.q, r));\n let wB = Transform.mulVec2(xfB, proxyB.getVertex(indexB));\n const v = Vec2.sub(wA, wB);\n\n // Sigma is the target distance between polygons\n const sigma = math_max(Settings.polygonRadius, radius - Settings.polygonRadius);\n const tolerance = 0.5 * Settings.linearSlop;\n\n // Main iteration loop.\n const k_maxIters = 20;\n let iter = 0;\n while (iter < k_maxIters && v.length() - sigma > tolerance) {\n if (_ASSERT) console.assert(simplex.m_count < 3);\n\n output.iterations += 1;\n\n // Support in direction -v (A - B)\n indexA = proxyA.getSupport(Rot.mulTVec2(xfA.q, Vec2.neg(v)));\n wA = Transform.mulVec2(xfA, proxyA.getVertex(indexA));\n indexB = proxyB.getSupport(Rot.mulTVec2(xfB.q, v));\n wB = Transform.mulVec2(xfB, proxyB.getVertex(indexB));\n const p = Vec2.sub(wA, wB);\n\n // -v is a normal at p\n v.normalize();\n\n // Intersect ray with plane\n const vp = Vec2.dot(v, p);\n const vr = Vec2.dot(v, r);\n if (vp - sigma > lambda * vr) {\n if (vr <= 0.0) {\n return false;\n }\n\n lambda = (vp - sigma) / vr;\n if (lambda > 1.0) {\n return false;\n }\n\n n.setMul(-1, v);\n simplex.m_count = 0;\n }\n\n // Reverse simplex since it works with B - A.\n // Shift by lambda * r because we want the closest point to the current clip point.\n // Note that the support point p is not shifted because we want the plane equation\n // to be formed in unshifted space.\n const vertex = vertices[simplex.m_count];\n vertex.indexA = indexB;\n vertex.wA = Vec2.combine(1, wB, lambda, r);\n vertex.indexB = indexA;\n vertex.wB = wA;\n vertex.w = Vec2.sub(vertex.wB, vertex.wA);\n vertex.a = 1.0;\n simplex.m_count += 1;\n\n switch (simplex.m_count) {\n case 1:\n break;\n\n case 2:\n simplex.solve2();\n break;\n\n case 3:\n simplex.solve3();\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n }\n \n // If we have 3 points, then the origin is in the corresponding triangle.\n if (simplex.m_count == 3) {\n // Overlap\n return false;\n }\n\n // Get search direction.\n v.setVec2(simplex.getClosestPoint());\n\n // Iteration count is equated to the number of support point calls.\n ++iter;\n }\n\n if (iter == 0) {\n // Initial overlap\n return false;\n\t}\n\n // Prepare output.\n const pointA = Vec2.zero();\n const pointB = Vec2.zero();\n simplex.getWitnessPoints(pointB, pointA);\n\n if (v.lengthSquared() > 0.0) {\n n.setMul(-1, v);\n n.normalize();\n }\n\n output.point = Vec2.combine(1, pointA, radiusA, n);\n output.normal = n;\n output.lambda = lambda;\n output.iterations = iter;\n return true;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { stats } from \"../util/stats\";\nimport Timer from \"../util/Timer\";\nimport { Sweep } from \"../common/Sweep\";\nimport { Transform } from \"../common/Transform\";\nimport { Distance, DistanceInput, DistanceOutput, DistanceProxy, SimplexCache } from \"./Distance\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n\n\n/**\n * Input parameters for TimeOfImpact.\n */\nexport class TOIInput {\n proxyA = new DistanceProxy();\n proxyB = new DistanceProxy();\n sweepA = new Sweep();\n sweepB = new Sweep();\n /** defines sweep interval [0, tMax] */\n tMax: number;\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.sweepA.recycle();\n this.sweepB.recycle();\n this.tMax = -1;\n }\n}\n\nexport enum TOIOutputState {\n e_unset = -1,\n e_unknown = 0,\n e_failed = 1,\n e_overlapped = 2,\n e_touching = 3,\n e_separated = 4,\n}\n\n/**\n * Output parameters for TimeOfImpact.\n */\nexport class TOIOutput {\n state = TOIOutputState.e_unset;\n t = -1;\n recycle() {\n this.state = TOIOutputState.e_unset;\n this.t = -1;\n }\n}\n\nstats.toiTime = 0;\nstats.toiMaxTime = 0;\nstats.toiCalls = 0;\nstats.toiIters = 0;\nstats.toiMaxIters = 0;\nstats.toiRootIters = 0;\nstats.toiMaxRootIters = 0;\n\n/** @internal */ const distanceInput = new DistanceInput();\n/** @internal */ const distanceOutput = new DistanceOutput();\n// this is passed to Distance and SeparationFunction\n/** @internal */ const cache = new SimplexCache();\n\n/** @internal */ const xfA = matrix.transform(0, 0, 0);\n/** @internal */ const xfB = matrix.transform(0, 0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const axisA = matrix.vec2(0, 0);\n/** @internal */ const axisB = matrix.vec2(0, 0);\n/** @internal */ const localPointA = matrix.vec2(0, 0);\n/** @internal */ const localPointB = matrix.vec2(0, 0);\n\n\n/**\n * Compute the upper bound on time before two shapes penetrate. Time is\n * represented as a fraction between [0,tMax]. This uses a swept separating axis\n * and may miss some intermediate, non-tunneling collisions. If you change the\n * time interval, you should call this function again.\n *\n * Note: use Distance to compute the contact point and normal at the time of\n * impact.\n *\n * CCD via the local separating axis method. This seeks progression by computing\n * the largest time at which separation is maintained.\n */\nexport const TimeOfImpact = function (output: TOIOutput, input: TOIInput): void {\n const timer = Timer.now();\n\n ++stats.toiCalls;\n\n output.state = TOIOutputState.e_unknown;\n output.t = input.tMax;\n\n const proxyA = input.proxyA; // DistanceProxy\n const proxyB = input.proxyB; // DistanceProxy\n\n const sweepA = input.sweepA; // Sweep\n const sweepB = input.sweepB; // Sweep\n\n // Large rotations can make the root finder fail, so we normalize the\n // sweep angles.\n sweepA.normalize();\n sweepB.normalize();\n\n const tMax = input.tMax;\n\n const totalRadius = proxyA.m_radius + proxyB.m_radius;\n const target = math_max(Settings.linearSlop, totalRadius - 3.0 * Settings.linearSlop);\n const tolerance = 0.25 * Settings.linearSlop;\n if (_ASSERT) console.assert(target > tolerance);\n\n let t1 = 0.0;\n const k_maxIterations = Settings.maxTOIIterations;\n let iter = 0;\n\n // Prepare input for distance query.\n // const cache = new SimplexCache();\n cache.recycle();\n\n distanceInput.proxyA.setVertices(proxyA.m_vertices, proxyA.m_count, proxyA.m_radius);\n distanceInput.proxyB.setVertices(proxyB.m_vertices, proxyB.m_count, proxyB.m_radius);\n distanceInput.useRadii = false;\n\n // The outer loop progressively attempts to compute new separating axes.\n // This loop terminates when an axis is repeated (no progress is made).\n while (true) {\n sweepA.getTransform(xfA, t1);\n sweepB.getTransform(xfB, t1);\n\n // Get the distance between shapes. We can also use the results\n // to get a separating axis.\n matrix.copyTransform(distanceInput.transformA, xfA);\n matrix.copyTransform(distanceInput.transformB, xfB);\n Distance(distanceOutput, cache, distanceInput);\n\n // If the shapes are overlapped, we give up on continuous collision.\n if (distanceOutput.distance <= 0.0) {\n // Failure!\n output.state = TOIOutputState.e_overlapped;\n output.t = 0.0;\n break;\n }\n\n if (distanceOutput.distance < target + tolerance) {\n // Victory!\n output.state = TOIOutputState.e_touching;\n output.t = t1;\n break;\n }\n\n // Initialize the separating axis.\n separationFunction.initialize(cache, proxyA, sweepA, proxyB, sweepB, t1);\n\n // if (false) {\n // // Dump the curve seen by the root finder\n // const N = 100;\n // const dx = 1.0 / N;\n // const xs = []; // [ N + 1 ];\n // const fs = []; // [ N + 1 ];\n // const x = 0.0;\n // for (const i = 0; i <= N; ++i) {\n // sweepA.getTransform(xfA, x);\n // sweepB.getTransform(xfB, x);\n // const f = fcn.evaluate(xfA, xfB) - target;\n // printf(\"%g %g\\n\", x, f);\n // xs[i] = x;\n // fs[i] = f;\n // x += dx;\n // }\n // }\n\n // Compute the TOI on the separating axis. We do this by successively\n // resolving the deepest point. This loop is bounded by the number of\n // vertices.\n let done = false;\n let t2 = tMax;\n let pushBackIter = 0;\n while (true) {\n // Find the deepest point at t2. Store the witness point indices.\n let s2 = separationFunction.findMinSeparation(t2);\n\n // Is the final configuration separated?\n if (s2 > target + tolerance) {\n // Victory!\n output.state = TOIOutputState.e_separated;\n output.t = tMax;\n done = true;\n break;\n }\n\n // Has the separation reached tolerance?\n if (s2 > target - tolerance) {\n // Advance the sweeps\n t1 = t2;\n break;\n }\n\n // Compute the initial separation of the witness points.\n let s1 = separationFunction.evaluate(t1);\n\n // Check for initial overlap. This might happen if the root finder\n // runs out of iterations.\n if (s1 < target - tolerance) {\n output.state = TOIOutputState.e_failed;\n output.t = t1;\n done = true;\n break;\n }\n\n // Check for touching\n if (s1 <= target + tolerance) {\n // Victory! t1 should hold the TOI (could be 0.0).\n output.state = TOIOutputState.e_touching;\n output.t = t1;\n done = true;\n break;\n }\n\n // Compute 1D root of: f(x) - target = 0\n let rootIterCount = 0;\n let a1 = t1;\n let a2 = t2;\n while (true) {\n // Use a mix of the secant rule and bisection.\n let t;\n if (rootIterCount & 1) {\n // Secant rule to improve convergence.\n t = a1 + (target - s1) * (a2 - a1) / (s2 - s1);\n } else {\n // Bisection to guarantee progress.\n t = 0.5 * (a1 + a2);\n }\n\n ++rootIterCount;\n ++stats.toiRootIters;\n\n const s = separationFunction.evaluate(t);\n\n if (math_abs(s - target) < tolerance) {\n // t2 holds a tentative value for t1\n t2 = t;\n break;\n }\n\n // Ensure we continue to bracket the root.\n if (s > target) {\n a1 = t;\n s1 = s;\n } else {\n a2 = t;\n s2 = s;\n }\n\n if (rootIterCount === 50) {\n break;\n }\n }\n\n stats.toiMaxRootIters = math_max(stats.toiMaxRootIters, rootIterCount);\n\n ++pushBackIter;\n\n if (pushBackIter === Settings.maxPolygonVertices) {\n break;\n }\n }\n\n ++iter;\n ++stats.toiIters;\n\n if (done) {\n break;\n }\n\n if (iter === k_maxIterations) {\n // Root finder got stuck. Semi-victory.\n output.state = TOIOutputState.e_failed;\n output.t = t1;\n break;\n }\n }\n\n stats.toiMaxIters = math_max(stats.toiMaxIters, iter);\n\n const time = Timer.diff(timer);\n stats.toiMaxTime = math_max(stats.toiMaxTime, time);\n stats.toiTime += time;\n\n separationFunction.recycle();\n};\n\nenum SeparationFunctionType {\n e_unset = -1,\n e_points = 1,\n e_faceA = 2,\n e_faceB = 3,\n}\n\nclass SeparationFunction {\n // input cache\n // todo: maybe assign by copy instead of reference?\n m_proxyA: DistanceProxy = null;\n m_proxyB: DistanceProxy = null;\n m_sweepA: Sweep = null;\n m_sweepB: Sweep = null;\n\n // initialize cache\n m_type = SeparationFunctionType.e_unset;\n m_localPoint = matrix.vec2(0, 0);\n m_axis = matrix.vec2(0, 0);\n\n // compute output\n indexA = -1;\n indexB = -1;\n\n recycle() {\n this.m_proxyA = null;\n this.m_proxyB = null;\n this.m_sweepA = null;\n this.m_sweepB = null;\n\n this.m_type = SeparationFunctionType.e_unset;\n matrix.zeroVec2(this.m_localPoint);\n matrix.zeroVec2(this.m_axis);\n\n this.indexA = -1;\n this.indexB = -1;\n }\n\n // TODO_ERIN might not need to return the separation\n\n initialize(cache: SimplexCache, proxyA: DistanceProxy, sweepA: Sweep, proxyB: DistanceProxy, sweepB: Sweep, t1: number): number {\n const count = cache.count;\n if (_ASSERT) console.assert(0 < count && count < 3);\n\n this.m_proxyA = proxyA;\n this.m_proxyB = proxyB;\n this.m_sweepA = sweepA;\n this.m_sweepB = sweepB;\n\n this.m_sweepA.getTransform(xfA, t1);\n this.m_sweepB.getTransform(xfB, t1);\n\n if (count === 1) {\n this.m_type = SeparationFunctionType.e_points;\n const localPointA = this.m_proxyA.getVertex(cache.indexA[0]);\n const localPointB = this.m_proxyB.getVertex(cache.indexB[0]);\n matrix.transformVec2(pointA, xfA, localPointA);\n matrix.transformVec2(pointB, xfB, localPointB);\n matrix.subVec2(this.m_axis, pointB, pointA);\n const s = matrix.normalizeVec2Length(this.m_axis);\n return s;\n\n } else if (cache.indexA[0] === cache.indexA[1]) {\n // Two points on B and one on A.\n this.m_type = SeparationFunctionType.e_faceB;\n const localPointB1 = proxyB.getVertex(cache.indexB[0]);\n const localPointB2 = proxyB.getVertex(cache.indexB[1]);\n\n matrix.crossVec2Num(this.m_axis, matrix.subVec2(temp, localPointB2, localPointB1), 1.0);\n matrix.normalizeVec2(this.m_axis);\n matrix.rotVec2(normal, xfB.q, this.m_axis);\n\n matrix.combine2Vec2(this.m_localPoint, 0.5, localPointB1, 0.5, localPointB2);\n matrix.transformVec2(pointB, xfB, this.m_localPoint);\n\n const localPointA = proxyA.getVertex(cache.indexA[0]);\n const pointA = Transform.mulVec2(xfA, localPointA);\n\n let s = matrix.dotVec2(pointA, normal) - matrix.dotVec2(pointB, normal);\n if (s < 0.0) {\n matrix.negVec2(this.m_axis);\n s = -s;\n }\n return s;\n\n } else {\n // Two points on A and one or two points on B.\n this.m_type = SeparationFunctionType.e_faceA;\n const localPointA1 = this.m_proxyA.getVertex(cache.indexA[0]);\n const localPointA2 = this.m_proxyA.getVertex(cache.indexA[1]);\n\n matrix.crossVec2Num(this.m_axis, matrix.subVec2(temp, localPointA2, localPointA1), 1.0);\n matrix.normalizeVec2(this.m_axis);\n matrix.rotVec2(normal, xfA.q, this.m_axis);\n\n matrix.combine2Vec2(this.m_localPoint, 0.5, localPointA1, 0.5, localPointA2);\n matrix.transformVec2(pointA, xfA, this.m_localPoint);\n\n const localPointB = this.m_proxyB.getVertex(cache.indexB[0]);\n matrix.transformVec2(pointB, xfB, localPointB);\n\n let s = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal);\n if (s < 0.0) {\n matrix.negVec2(this.m_axis);\n s = -s;\n }\n return s;\n }\n }\n\n compute(find: boolean, t: number): number {\n // It was findMinSeparation and evaluate\n this.m_sweepA.getTransform(xfA, t);\n this.m_sweepB.getTransform(xfB, t);\n\n switch (this.m_type) {\n case SeparationFunctionType.e_points: {\n if (find) {\n matrix.derotVec2(axisA, xfA.q, this.m_axis);\n matrix.derotVec2(axisB, xfB.q, matrix.scaleVec2(temp, -1, this.m_axis));\n\n this.indexA = this.m_proxyA.getSupport(axisA);\n this.indexB = this.m_proxyB.getSupport(axisB);\n }\n\n matrix.copyVec2(localPointA, this.m_proxyA.getVertex(this.indexA));\n matrix.copyVec2(localPointB, this.m_proxyB.getVertex(this.indexB));\n\n matrix.transformVec2(pointA, xfA, localPointA);\n matrix.transformVec2(pointB, xfB, localPointB);\n\n const sep = matrix.dotVec2(pointB, this.m_axis) - matrix.dotVec2(pointA, this.m_axis);\n return sep;\n }\n\n case SeparationFunctionType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.m_axis);\n matrix.transformVec2(pointA, xfA, this.m_localPoint);\n\n if (find) {\n matrix.derotVec2(axisB, xfB.q, matrix.scaleVec2(temp, -1, normal));\n\n this.indexA = -1;\n this.indexB = this.m_proxyB.getSupport(axisB);\n }\n\n matrix.copyVec2(localPointB, this.m_proxyB.getVertex(this.indexB));\n matrix.transformVec2(pointB, xfB, localPointB);\n\n const sep = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal);\n return sep;\n }\n\n case SeparationFunctionType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.m_axis);\n matrix.transformVec2(pointB, xfB, this.m_localPoint);\n\n if (find) {\n matrix.derotVec2(axisA, xfA.q, matrix.scaleVec2(temp, -1, normal));\n\n this.indexB = -1;\n this.indexA = this.m_proxyA.getSupport(axisA);\n }\n\n matrix.copyVec2(localPointA, this.m_proxyA.getVertex(this.indexA));\n matrix.transformVec2(pointA, xfA, localPointA);\n\n const sep = matrix.dotVec2(pointA, normal) - matrix.dotVec2(pointB, normal);\n return sep;\n }\n\n default:\n if (_ASSERT) console.assert(false);\n if (find) {\n this.indexA = -1;\n this.indexB = -1;\n }\n return 0.0;\n }\n }\n\n findMinSeparation(t: number): number {\n return this.compute(true, t);\n }\n\n evaluate(t: number): number {\n return this.compute(false, t);\n }\n}\n\n/** @internal */ const separationFunction = new SeparationFunction();\n\n// legacy exports\nTimeOfImpact.Input = TOIInput;\nTimeOfImpact.Output = TOIOutput;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { EPSILON } from \"../common/Math\";\nimport { Body } from \"./Body\";\nimport type { Contact } from \"./Contact\";\nimport { Joint } from \"./Joint\";\nimport { TimeOfImpact, TOIInput, TOIOutput, TOIOutputState } from \"../collision/TimeOfImpact\";\nimport { Distance, DistanceInput, DistanceOutput, SimplexCache } from \"../collision/Distance\";\nimport { World } from \"./World\";\nimport { Sweep } from \"../common/Sweep\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_min = Math.min;\n\n\nexport class TimeStep {\n /** time step */\n dt: number = 0;\n /** inverse time step (0 if dt == 0) */\n inv_dt: number = 0;\n velocityIterations: number = 0;\n positionIterations: number = 0;\n warmStarting: boolean = false;\n blockSolve: boolean = true;\n\n /** timestep ratio for variable timestep */\n inv_dt0: number = 0.0;\n /** dt * inv_dt0 */\n dtRatio: number = 1;\n\n reset(dt: number): void {\n if (this.dt > 0.0) {\n this.inv_dt0 = this.inv_dt;\n }\n this.dt = dt;\n this.inv_dt = dt == 0 ? 0 : 1 / dt;\n this.dtRatio = dt * this.inv_dt0;\n }\n}\n\n// reuse\n/** @internal */ const s_subStep = new TimeStep();\n/** @internal */ const c = matrix.vec2(0, 0);\n/** @internal */ const v = matrix.vec2(0, 0);\n/** @internal */ const translation = matrix.vec2(0, 0);\n/** @internal */ const input = new TOIInput();\n/** @internal */ const output = new TOIOutput();\n/** @internal */ const backup = new Sweep();\n/** @internal */ const backup1 = new Sweep();\n/** @internal */ const backup2 = new Sweep();\n\n/**\n * Contact impulses for reporting. Impulses are used instead of forces because\n * sub-step forces may approach infinity for rigid body collisions. These match\n * up one-to-one with the contact points in Manifold.\n */\nexport class ContactImpulse {\n // TODO: merge with Contact class?\n\n private readonly contact: Contact;\n private readonly normals: number[];\n private readonly tangents: number[];\n\n constructor(contact: Contact) {\n this.contact = contact;\n this.normals = [];\n this.tangents = [];\n }\n\n recycle() {\n this.normals.length = 0;\n this.tangents.length = 0;\n }\n\n get normalImpulses(): number[] {\n const contact = this.contact;\n const normals = this.normals;\n normals.length = 0;\n for (let p = 0; p < contact.v_points.length; ++p) {\n normals.push(contact.v_points[p].normalImpulse);\n }\n return normals;\n }\n\n get tangentImpulses(): number[] {\n const contact = this.contact;\n const tangents = this.tangents;\n tangents.length = 0;\n for (let p = 0; p < contact.v_points.length; ++p) {\n tangents.push(contact.v_points[p].tangentImpulse);\n }\n return tangents;\n }\n}\n\n/**\n * Finds and solves islands. An island is a connected subset of the world.\n */\nexport class Solver {\n m_world: World;\n m_stack: Body[];\n m_bodies: Body[];\n m_contacts: Contact[];\n m_joints: Joint[];\n\n constructor(world: World) {\n this.m_world = world;\n this.m_stack = [];\n this.m_bodies = [];\n this.m_contacts = [];\n this.m_joints = [];\n }\n\n clear(): void {\n this.m_stack.length = 0;\n this.m_bodies.length = 0;\n this.m_contacts.length = 0;\n this.m_joints.length = 0;\n }\n\n addBody(body: Body): void {\n if (_ASSERT) console.assert(body instanceof Body, \"Not a Body!\", body);\n this.m_bodies.push(body);\n // why?\n // body.c_position.c.setZero();\n // body.c_position.a = 0;\n // body.c_velocity.v.setZero();\n // body.c_velocity.w = 0;\n }\n\n addContact(contact: Contact): void {\n // if (_ASSERT) console.assert(contact instanceof Contact, 'Not a Contact!', contact);\n this.m_contacts.push(contact);\n }\n\n addJoint(joint: Joint): void {\n if (_ASSERT) console.assert(joint instanceof Joint, \"Not a Joint!\", joint);\n this.m_joints.push(joint);\n }\n\n solveWorld(step: TimeStep): void {\n const world = this.m_world;\n\n // Clear all the island flags.\n for (let b = world.m_bodyList; b; b = b.m_next) {\n b.m_islandFlag = false;\n }\n for (let c = world.m_contactList; c; c = c.m_next) {\n c.m_islandFlag = false;\n }\n for (let j = world.m_jointList; j; j = j.m_next) {\n j.m_islandFlag = false;\n }\n\n // Build and simulate all awake islands.\n const stack = this.m_stack;\n let loop = -1;\n for (let seed = world.m_bodyList; seed; seed = seed.m_next) {\n loop++;\n if (seed.m_islandFlag) {\n continue;\n }\n\n if (seed.isAwake() == false || seed.isActive() == false) {\n continue;\n }\n\n // The seed can be dynamic or kinematic.\n if (seed.isStatic()) {\n continue;\n }\n\n // Reset island and stack.\n this.clear();\n\n stack.push(seed);\n\n seed.m_islandFlag = true;\n\n // Perform a depth first search (DFS) on the constraint graph.\n while (stack.length > 0) {\n // Grab the next body off the stack and add it to the island.\n const b = stack.pop();\n if (_ASSERT) console.assert(b.isActive() == true);\n this.addBody(b);\n\n // Make sure the body is awake (without resetting sleep timer).\n b.m_awakeFlag = true;\n\n // To keep islands as small as possible, we don't\n // propagate islands across static bodies.\n if (b.isStatic()) {\n continue;\n }\n\n // Search all contacts connected to this body.\n for (let ce = b.m_contactList; ce; ce = ce.next) {\n const contact = ce.contact;\n\n // Has this contact already been added to an island?\n if (contact.m_islandFlag) {\n continue;\n }\n\n // Is this contact solid and touching?\n if (contact.isEnabled() == false || contact.isTouching() == false) {\n continue;\n }\n\n // Skip sensors.\n const sensorA = contact.m_fixtureA.m_isSensor;\n const sensorB = contact.m_fixtureB.m_isSensor;\n if (sensorA || sensorB) {\n continue;\n }\n\n this.addContact(contact);\n contact.m_islandFlag = true;\n\n const other = ce.other;\n\n // Was the other body already added to this island?\n if (other.m_islandFlag) {\n continue;\n }\n\n // if (_ASSERT) console.assert(stack.length < world.m_bodyCount);\n stack.push(other);\n other.m_islandFlag = true;\n }\n\n // Search all joints connect to this body.\n for (let je = b.m_jointList; je; je = je.next) {\n if (je.joint.m_islandFlag == true) {\n continue;\n }\n\n const other = je.other;\n\n // Don't simulate joints connected to inactive bodies.\n if (other.isActive() == false) {\n continue;\n }\n\n this.addJoint(je.joint);\n je.joint.m_islandFlag = true;\n\n if (other.m_islandFlag) {\n continue;\n }\n\n // if (_ASSERT) console.assert(stack.length < world.m_bodyCount);\n stack.push(other);\n other.m_islandFlag = true;\n }\n }\n\n this.solveIsland(step);\n\n // Post solve cleanup.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n // Allow static bodies to participate in other islands.\n // TODO: are they added at all?\n const b = this.m_bodies[i];\n if (b.isStatic()) {\n b.m_islandFlag = false;\n }\n }\n }\n }\n\n solveIsland(step: TimeStep): void {\n // B2: Island Solve\n const world = this.m_world;\n const gravity = world.m_gravity;\n const allowSleep = world.m_allowSleep;\n\n const h = step.dt;\n\n // Integrate velocities and apply damping. Initialize the body state.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.m_sweep.c);\n const a = body.m_sweep.a;\n matrix.copyVec2(v, body.m_linearVelocity);\n let w = body.m_angularVelocity;\n\n // Store positions for continuous collision.\n matrix.copyVec2(body.m_sweep.c0, body.m_sweep.c);\n body.m_sweep.a0 = body.m_sweep.a;\n\n if (body.isDynamic()) {\n // Integrate velocities.\n matrix.plusScaleVec2(v, h * body.m_gravityScale, gravity);\n matrix.plusScaleVec2(v, h * body.m_invMass, body.m_force);\n w += h * body.m_invI * body.m_torque;\n /**\n *
\n         * Apply damping.\n         * ODE: dv/dt + c * v = 0\n         * Solution: v(t) = v0 * exp(-c * t)\n         * Time step: v(t + dt) = v0 * exp(-c * (t + dt)) = v0 * exp(-c * t) * exp(-c * dt) = v * exp(-c * dt)\n         * v2 = exp(-c * dt) * v1\n         * Pade approximation:\n         * v2 = v1 * 1 / (1 + c * dt)\n         * 
\n */\n matrix.scaleVec2(v, 1.0 / (1.0 + h * body.m_linearDamping), v);\n w *= 1.0 / (1.0 + h * body.m_angularDamping);\n }\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initConstraint(step);\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initVelocityConstraint(step);\n }\n\n if (step.warmStarting) {\n // Warm start.\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.warmStartConstraint(step);\n }\n }\n\n for (let i = 0; i < this.m_joints.length; ++i) {\n const joint = this.m_joints[i];\n joint.initVelocityConstraints(step);\n }\n\n // Solve velocity constraints\n for (let i = 0; i < step.velocityIterations; ++i) {\n for (let j = 0; j < this.m_joints.length; ++j) {\n const joint = this.m_joints[j];\n joint.solveVelocityConstraints(step);\n }\n\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n contact.solveVelocityConstraint(step);\n }\n }\n\n // Store impulses for warm starting\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.storeConstraintImpulses(step);\n }\n\n // Integrate positions\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.c_position.c);\n let a = body.c_position.a;\n matrix.copyVec2(v, body.c_velocity.v);\n let w = body.c_velocity.w;\n\n // Check for large velocities\n matrix.scaleVec2(translation, h, v);\n const translationLengthSqr = matrix.lengthSqrVec2(translation);\n if (translationLengthSqr > Settings.maxTranslationSquared) {\n const ratio = Settings.maxTranslation / math_sqrt(translationLengthSqr);\n matrix.mulVec2(v, ratio);\n }\n\n const rotation = h * w;\n if (rotation * rotation > Settings.maxRotationSquared) {\n const ratio = Settings.maxRotation / math_abs(rotation);\n w *= ratio;\n }\n\n // Integrate\n matrix.plusScaleVec2(c, h, v);\n a += h * w;\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n }\n\n // Solve position constraints\n let positionSolved = false;\n for (let i = 0; i < step.positionIterations; ++i) {\n let minSeparation = 0.0;\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n const separation = contact.solvePositionConstraint(step);\n minSeparation = math_min(minSeparation, separation);\n }\n // We can't expect minSpeparation >= -Settings.linearSlop because we don't\n // push the separation above -Settings.linearSlop.\n const contactsOkay = minSeparation >= -3.0 * Settings.linearSlop;\n\n let jointsOkay = true;\n for (let j = 0; j < this.m_joints.length; ++j) {\n const joint = this.m_joints[j];\n const jointOkay = joint.solvePositionConstraints(step);\n jointsOkay = jointsOkay && jointOkay;\n }\n\n if (contactsOkay && jointsOkay) {\n // Exit early if the position errors are small.\n positionSolved = true;\n break;\n }\n }\n\n // Copy state buffers back to the bodies\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(body.m_sweep.c, body.c_position.c);\n body.m_sweep.a = body.c_position.a;\n matrix.copyVec2(body.m_linearVelocity, body.c_velocity.v);\n body.m_angularVelocity = body.c_velocity.w;\n body.synchronizeTransform();\n }\n\n this.postSolveIsland();\n\n if (allowSleep) {\n let minSleepTime = Infinity;\n\n const linTolSqr = Settings.linearSleepToleranceSqr;\n const angTolSqr = Settings.angularSleepToleranceSqr;\n\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n if (body.isStatic()) {\n continue;\n }\n\n if ((body.m_autoSleepFlag == false)\n || (body.m_angularVelocity * body.m_angularVelocity > angTolSqr)\n || (matrix.lengthSqrVec2(body.m_linearVelocity) > linTolSqr)) {\n body.m_sleepTime = 0.0;\n minSleepTime = 0.0;\n } else {\n body.m_sleepTime += h;\n minSleepTime = math_min(minSleepTime, body.m_sleepTime);\n }\n }\n\n if (minSleepTime >= Settings.timeToSleep && positionSolved) {\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n body.setAwake(false);\n }\n }\n }\n }\n\n /**\n * Find TOI contacts and solve them.\n */\n solveWorldTOI(step: TimeStep): void {\n const world = this.m_world;\n\n if (world.m_stepComplete) {\n for (let b = world.m_bodyList; b; b = b.m_next) {\n b.m_islandFlag = false;\n b.m_sweep.alpha0 = 0.0;\n }\n\n for (let c = world.m_contactList; c; c = c.m_next) {\n // Invalidate TOI\n c.m_toiFlag = false;\n c.m_islandFlag = false;\n c.m_toiCount = 0;\n c.m_toi = 1.0;\n }\n }\n\n // Find TOI events and solve them.\n while (true) {\n // Find the first TOI.\n let minContact: Contact | null = null;\n let minAlpha = 1.0;\n\n for (let c = world.m_contactList; c; c = c.m_next) {\n // Is this contact disabled?\n if (c.isEnabled() == false) {\n continue;\n }\n\n // Prevent excessive sub-stepping.\n if (c.m_toiCount > Settings.maxSubSteps) {\n continue;\n }\n\n let alpha = 1.0;\n if (c.m_toiFlag) {\n // This contact has a valid cached TOI.\n alpha = c.m_toi;\n } else {\n const fA = c.getFixtureA();\n const fB = c.getFixtureB();\n\n // Is there a sensor?\n if (fA.isSensor() || fB.isSensor()) {\n continue;\n }\n\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n if (_ASSERT) console.assert(bA.isDynamic() || bB.isDynamic());\n\n const activeA = bA.isAwake() && !bA.isStatic();\n const activeB = bB.isAwake() && !bB.isStatic();\n\n // Is at least one body active (awake and dynamic or kinematic)?\n if (activeA == false && activeB == false) {\n continue;\n }\n\n const collideA = bA.isBullet() || !bA.isDynamic();\n const collideB = bB.isBullet() || !bB.isDynamic();\n\n // Are these two non-bullet dynamic bodies?\n if (collideA == false && collideB == false) {\n continue;\n }\n\n // Compute the TOI for this contact.\n // Put the sweeps onto the same time interval.\n let alpha0 = bA.m_sweep.alpha0;\n\n if (bA.m_sweep.alpha0 < bB.m_sweep.alpha0) {\n alpha0 = bB.m_sweep.alpha0;\n bA.m_sweep.advance(alpha0);\n } else if (bB.m_sweep.alpha0 < bA.m_sweep.alpha0) {\n alpha0 = bA.m_sweep.alpha0;\n bB.m_sweep.advance(alpha0);\n }\n\n if (_ASSERT) console.assert(alpha0 < 1.0);\n\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n\n const sweepA = bA.m_sweep;\n const sweepB = bB.m_sweep;\n\n // Compute the time of impact in interval [0, minTOI]\n input.proxyA.set(fA.getShape(), indexA);\n input.proxyB.set(fB.getShape(), indexB);\n input.sweepA.set(bA.m_sweep);\n input.sweepB.set(bB.m_sweep);\n input.tMax = 1.0;\n\n TimeOfImpact(output, input);\n\n // Beta is the fraction of the remaining portion of the [time?].\n const beta = output.t;\n if (output.state == TOIOutputState.e_touching) {\n alpha = math_min(alpha0 + (1.0 - alpha0) * beta, 1.0);\n } else {\n alpha = 1.0;\n }\n\n c.m_toi = alpha;\n c.m_toiFlag = true;\n }\n\n if (alpha < minAlpha) {\n // This is the minimum TOI found so far.\n minContact = c;\n minAlpha = alpha;\n }\n }\n\n if (minContact == null || 1.0 - 10.0 * EPSILON < minAlpha) {\n // No more TOI events. Done!\n world.m_stepComplete = true;\n break;\n }\n\n // Advance the bodies to the TOI.\n const fA = minContact.getFixtureA();\n const fB = minContact.getFixtureB();\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n backup1.set(bA.m_sweep);\n backup2.set(bB.m_sweep);\n\n bA.advance(minAlpha);\n bB.advance(minAlpha);\n\n // The TOI contact likely has some new contact points.\n minContact.update(world);\n minContact.m_toiFlag = false;\n ++minContact.m_toiCount;\n\n // Is the contact solid?\n if (minContact.isEnabled() == false || minContact.isTouching() == false) {\n // Restore the sweeps.\n minContact.setEnabled(false);\n bA.m_sweep.set(backup1);\n bB.m_sweep.set(backup2);\n bA.synchronizeTransform();\n bB.synchronizeTransform();\n continue;\n }\n\n bA.setAwake(true);\n bB.setAwake(true);\n\n // Build the island\n this.clear();\n this.addBody(bA);\n this.addBody(bB);\n this.addContact(minContact);\n\n bA.m_islandFlag = true;\n bB.m_islandFlag = true;\n minContact.m_islandFlag = true;\n\n // Get contacts on bodyA and bodyB.\n const bodies = [ bA, bB ];\n for (let i = 0; i < bodies.length; ++i) {\n const body = bodies[i];\n if (body.isDynamic()) {\n for (let ce = body.m_contactList; ce; ce = ce.next) {\n // if (this.m_bodyCount == this.m_bodyCapacity) { break; }\n // if (this.m_contactCount == this.m_contactCapacity) { break; }\n\n const contact = ce.contact;\n\n // Has this contact already been added to the island?\n if (contact.m_islandFlag) {\n continue;\n }\n\n // Only add if either is static, kinematic or bullet.\n const other = ce.other;\n if (other.isDynamic() && !body.isBullet() && !other.isBullet()) {\n continue;\n }\n\n // Skip sensors.\n const sensorA = contact.m_fixtureA.m_isSensor;\n const sensorB = contact.m_fixtureB.m_isSensor;\n if (sensorA || sensorB) {\n continue;\n }\n\n // Tentatively advance the body to the TOI.\n backup.set(other.m_sweep);\n if (other.m_islandFlag == false) {\n other.advance(minAlpha);\n }\n\n // Update the contact points\n contact.update(world);\n\n // Was the contact disabled by the user?\n // Are there contact points?\n if (contact.isEnabled() == false || contact.isTouching() == false) {\n other.m_sweep.set(backup);\n other.synchronizeTransform();\n continue;\n }\n\n // Add the contact to the island\n contact.m_islandFlag = true;\n this.addContact(contact);\n\n // Has the other body already been added to the island?\n if (other.m_islandFlag) {\n continue;\n }\n\n // Add the other body to the island.\n other.m_islandFlag = true;\n\n if (!other.isStatic()) {\n other.setAwake(true);\n }\n\n this.addBody(other);\n }\n }\n }\n\n s_subStep.reset((1.0 - minAlpha) * step.dt);\n s_subStep.dtRatio = 1.0;\n s_subStep.positionIterations = 20;\n s_subStep.velocityIterations = step.velocityIterations;\n s_subStep.warmStarting = false;\n\n this.solveIslandTOI(s_subStep, bA, bB);\n\n // Reset island flags and synchronize broad-phase proxies.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n body.m_islandFlag = false;\n\n if (!body.isDynamic()) {\n continue;\n }\n\n body.synchronizeFixtures();\n\n // Invalidate all contact TOIs on this displaced body.\n for (let ce = body.m_contactList; ce; ce = ce.next) {\n ce.contact.m_toiFlag = false;\n ce.contact.m_islandFlag = false;\n }\n }\n\n // Commit fixture proxy movements to the broad-phase so that new contacts\n // are created.\n // Also, some contacts can be destroyed.\n world.findNewContacts();\n\n if (world.m_subStepping) {\n world.m_stepComplete = false;\n break;\n }\n }\n }\n\n solveIslandTOI(subStep: TimeStep, toiA: Body, toiB: Body): void {\n\n // Initialize the body state.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n matrix.copyVec2(body.c_position.c, body.m_sweep.c);\n body.c_position.a = body.m_sweep.a;\n matrix.copyVec2(body.c_velocity.v, body.m_linearVelocity);\n body.c_velocity.w = body.m_angularVelocity;\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initConstraint(subStep);\n }\n\n // Solve position constraints.\n for (let i = 0; i < subStep.positionIterations; ++i) {\n let minSeparation = 0.0;\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n const separation = contact.solvePositionConstraintTOI(subStep, toiA, toiB);\n minSeparation = math_min(minSeparation, separation);\n }\n // We can't expect minSpeparation >= -Settings.linearSlop because we don't\n // push the separation above -Settings.linearSlop.\n const contactsOkay = minSeparation >= -1.5 * Settings.linearSlop;\n if (contactsOkay) {\n break;\n }\n }\n\n if (false) {\n // Is the new position really safe?\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const c = this.m_contacts[i];\n const fA = c.getFixtureA();\n const fB = c.getFixtureB();\n\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n\n const input = new DistanceInput();\n input.proxyA.set(fA.getShape(), indexA);\n input.proxyB.set(fB.getShape(), indexB);\n input.transformA.set(bA.getTransform());\n input.transformB.set(bB.getTransform());\n input.useRadii = false;\n\n const output = new DistanceOutput();\n const cache = new SimplexCache();\n Distance(output, cache, input);\n\n if (output.distance == 0 || cache.count == 3) {\n cache.count += 0;\n }\n }\n }\n\n // Leap of faith to new safe state.\n matrix.copyVec2(toiA.m_sweep.c0, toiA.c_position.c);\n toiA.m_sweep.a0 = toiA.c_position.a;\n matrix.copyVec2(toiB.m_sweep.c0, toiB.c_position.c);\n toiB.m_sweep.a0 = toiB.c_position.a;\n\n // No warm starting is needed for TOI events because warm\n // starting impulses were applied in the discrete solver.\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initVelocityConstraint(subStep);\n }\n\n // Solve velocity constraints.\n for (let i = 0; i < subStep.velocityIterations; ++i) {\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n contact.solveVelocityConstraint(subStep);\n }\n }\n\n // Don't store the TOI contact forces for warm starting\n // because they can be quite large.\n\n const h = subStep.dt;\n\n // Integrate positions\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.c_position.c);\n let a = body.c_position.a;\n matrix.copyVec2(v, body.c_velocity.v);\n let w = body.c_velocity.w;\n\n // Check for large velocities\n matrix.scaleVec2(translation, h, v);\n const translationLengthSqr = matrix.lengthSqrVec2(translation);\n if (translationLengthSqr > Settings.maxTranslationSquared) {\n const ratio = Settings.maxTranslation / math_sqrt(translationLengthSqr);\n matrix.mulVec2(v, ratio);\n }\n\n const rotation = h * w;\n if (rotation * rotation > Settings.maxRotationSquared) {\n const ratio = Settings.maxRotation / math_abs(rotation);\n w *= ratio;\n }\n\n // Integrate\n matrix.plusScaleVec2(c, h, v);\n a += h * w;\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n\n // Sync bodies\n matrix.copyVec2(body.m_sweep.c, c);\n body.m_sweep.a = a;\n matrix.copyVec2(body.m_linearVelocity, v);\n body.m_angularVelocity = w;\n body.synchronizeTransform();\n }\n\n this.postSolveIsland();\n }\n\n /** @internal */\n postSolveIsland(): void {\n for (let c = 0; c < this.m_contacts.length; ++c) {\n const contact = this.m_contacts[c];\n this.m_world.postSolve(contact, contact.m_impulse);\n }\n }\n}\n\n// @ts-ignore\nSolver.TimeStep = TimeStep;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A 2-by-2 matrix. Stored in column-major order.\n */\nexport class Mat22 {\n ex: Vec2;\n ey: Vec2;\n\n constructor(a: number, b: number, c: number, d: number);\n constructor(a: { x: number; y: number }, b: { x: number; y: number });\n constructor();\n constructor(a?, b?, c?, d?) {\n if (typeof a === \"object\" && a !== null) {\n this.ex = Vec2.clone(a);\n this.ey = Vec2.clone(b);\n } else if (typeof a === \"number\") {\n this.ex = Vec2.neo(a, c);\n this.ey = Vec2.neo(b, d);\n } else {\n this.ex = Vec2.zero();\n this.ey = Vec2.zero();\n }\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.ex) && Vec2.isValid(obj.ey);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Mat22.isValid(o), \"Invalid Mat22!\", o);\n }\n\n set(a: Mat22): void;\n set(a: Vec2Value, b: Vec2Value): void;\n set(a: number, b: number, c: number, d: number): void;\n set(a, b?, c?, d?): void {\n if (typeof a === \"number\" && typeof b === \"number\" && typeof c === \"number\"\n && typeof d === \"number\") {\n this.ex.setNum(a, c);\n this.ey.setNum(b, d);\n\n } else if (typeof a === \"object\" && typeof b === \"object\") {\n this.ex.setVec2(a);\n this.ey.setVec2(b);\n\n } else if (typeof a === \"object\") {\n if (_ASSERT) Mat22.assert(a);\n this.ex.setVec2(a.ex);\n this.ey.setVec2(a.ey);\n\n } else {\n if (_ASSERT) console.assert(false);\n }\n }\n\n setIdentity(): void {\n this.ex.x = 1.0;\n this.ey.x = 0.0;\n this.ex.y = 0.0;\n this.ey.y = 1.0;\n }\n\n setZero(): void {\n this.ex.x = 0.0;\n this.ey.x = 0.0;\n this.ex.y = 0.0;\n this.ey.y = 0.0;\n }\n\n getInverse(): Mat22 {\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const imx = new Mat22();\n imx.ex.x = det * d;\n imx.ey.x = -det * b;\n imx.ex.y = -det * c;\n imx.ey.y = det * a;\n return imx;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases.\n */\n solve(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const w = Vec2.zero();\n w.x = det * (d * v.x - b * v.y);\n w.y = det * (a * v.y - c * v.x);\n return w;\n }\n\n /**\n * Multiply a matrix times a vector. If a rotation matrix is provided, then this\n * transforms the vector from one frame to another.\n */\n static mul(mx: Mat22, my: Mat22): Mat22;\n static mul(mx: Mat22, v: Vec2Value): Vec2;\n static mul(mx, v) {\n if (v && \"x\" in v && \"y\" in v) {\n if (_ASSERT) Vec2.assert(v);\n const x = mx.ex.x * v.x + mx.ey.x * v.y;\n const y = mx.ex.y * v.x + mx.ey.y * v.y;\n return Vec2.neo(x, y);\n\n } else if (v && \"ex\" in v && \"ey\" in v) { // Mat22\n if (_ASSERT) Mat22.assert(v);\n // return new Mat22(Vec2.mul(mx, v.ex), Vec2.mul(mx, v.ey));\n const a = mx.ex.x * v.ex.x + mx.ey.x * v.ex.y;\n const b = mx.ex.x * v.ey.x + mx.ey.x * v.ey.y;\n const c = mx.ex.y * v.ex.x + mx.ey.y * v.ex.y;\n const d = mx.ex.y * v.ey.x + mx.ey.y * v.ey.y;\n return new Mat22(a, b, c, d);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulVec2(mx: Mat22, v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n const x = mx.ex.x * v.x + mx.ey.x * v.y;\n const y = mx.ex.y * v.x + mx.ey.y * v.y;\n return Vec2.neo(x, y);\n }\n\n static mulMat22(mx: Mat22, v: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(v);\n // return new Mat22(Vec2.mul(mx, v.ex), Vec2.mul(mx, v.ey));\n const a = mx.ex.x * v.ex.x + mx.ey.x * v.ex.y;\n const b = mx.ex.x * v.ey.x + mx.ey.x * v.ey.y;\n const c = mx.ex.y * v.ex.x + mx.ey.y * v.ex.y;\n const d = mx.ex.y * v.ey.x + mx.ey.y * v.ey.y;\n return new Mat22(a, b, c, d);\n }\n\n /**\n * Multiply a matrix transpose times a vector. If a rotation matrix is provided,\n * then this transforms the vector from one frame to another (inverse\n * transform).\n */\n static mulT(mx: Mat22, my: Mat22): Mat22;\n static mulT(mx: Mat22, v: Vec2Value): Vec2;\n static mulT(mx, v) {\n if (v && \"x\" in v && \"y\" in v) { // Vec2\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(Vec2.dot(v, mx.ex), Vec2.dot(v, mx.ey));\n\n } else if (v && \"ex\" in v && \"ey\" in v) { // Mat22\n if (_ASSERT) Mat22.assert(v);\n const c1 = Vec2.neo(Vec2.dot(mx.ex, v.ex), Vec2.dot(mx.ey, v.ex));\n const c2 = Vec2.neo(Vec2.dot(mx.ex, v.ey), Vec2.dot(mx.ey, v.ey));\n return new Mat22(c1, c2);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulTVec2(mx: Mat22, v: Vec2Value): Vec2 {\n if (_ASSERT) Mat22.assert(mx);\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(Vec2.dot(v, mx.ex), Vec2.dot(v, mx.ey));\n }\n\n static mulTMat22(mx: Mat22, v: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx);\n if (_ASSERT) Mat22.assert(v);\n const c1 = Vec2.neo(Vec2.dot(mx.ex, v.ex), Vec2.dot(mx.ey, v.ex));\n const c2 = Vec2.neo(Vec2.dot(mx.ex, v.ey), Vec2.dot(mx.ey, v.ey));\n return new Mat22(c1, c2);\n }\n\n static abs(mx: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx);\n return new Mat22(Vec2.abs(mx.ex), Vec2.abs(mx.ey));\n }\n\n static add(mx1: Mat22, mx2: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx1);\n if (_ASSERT) Mat22.assert(mx2);\n return new Mat22(Vec2.add(mx1.ex, mx2.ex), Vec2.add(mx1.ey, mx2.ey));\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { Vec2Value } from \"../common/Vec2\";\nimport { TransformValue } from \"../common/Transform\";\nimport { EPSILON } from \"../common/Math\";\n\n\n/** @internal */ const math_sqrt = Math.sqrt;\n\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const cA = matrix.vec2(0, 0);\n/** @internal */ const cB = matrix.vec2(0, 0);\n/** @internal */ const dist = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const clipPoint = matrix.vec2(0, 0);\n\nexport enum ManifoldType {\n e_unset = -1,\n e_circles = 0,\n e_faceA = 1,\n e_faceB = 2\n}\n\nexport enum ContactFeatureType {\n e_unset = -1,\n e_vertex = 0,\n e_face = 1\n}\n\n/**\n * This is used for determining the state of contact points.\n */\n export enum PointState {\n /** Point does not exist */\n nullState = 0,\n /** Point was added in the update */\n addState = 1,\n /** Point persisted across the update */\n persistState = 2,\n /** Point was removed in the update */\n removeState = 3\n}\n\n/**\n * Used for computing contact manifolds.\n */\n export class ClipVertex {\n v = matrix.vec2(0, 0);\n id: ContactID = new ContactID();\n\n set(o: ClipVertex): void {\n matrix.copyVec2(this.v, o.v);\n this.id.set(o.id);\n }\n recycle() {\n matrix.zeroVec2(this.v);\n this.id.recycle();\n }\n}\n\n/**\n * A manifold for two touching convex shapes. Manifolds are created in `evaluate`\n * method of Contact subclasses.\n *\n * Supported manifold types are e_faceA or e_faceB for clip point versus plane\n * with radius and e_circles point versus point with radius.\n *\n * We store contacts in this way so that position correction can account for\n * movement, which is critical for continuous physics. All contact scenarios\n * must be expressed in one of these types. This structure is stored across time\n * steps, so we keep it small.\n */\nexport class Manifold {\n type: ManifoldType;\n\n /**\n * Usage depends on manifold type:\n * - circles: not used\n * - faceA: the normal on polygonA\n * - faceB: the normal on polygonB\n */\n localNormal = matrix.vec2(0, 0);\n\n /**\n * Usage depends on manifold type:\n * - circles: the local center of circleA\n * - faceA: the center of faceA\n * - faceB: the center of faceB\n */\n localPoint = matrix.vec2(0, 0);\n\n /** The points of contact */\n points: ManifoldPoint[] = [ new ManifoldPoint(), new ManifoldPoint() ];\n\n /** The number of manifold points */\n pointCount: number = 0;\n\n set(that: Manifold): void {\n this.type = that.type;\n matrix.copyVec2(this.localNormal, that.localNormal);\n matrix.copyVec2(this.localPoint, that.localPoint);\n this.pointCount = that.pointCount;\n this.points[0].set(that.points[0]);\n this.points[1].set(that.points[1]);\n }\n\n recycle(): void {\n this.type = ManifoldType.e_unset;\n matrix.zeroVec2(this.localNormal);\n matrix.zeroVec2(this.localPoint);\n this.pointCount = 0;\n this.points[0].recycle();\n this.points[1].recycle();\n }\n\n /**\n * Evaluate the manifold with supplied transforms. This assumes modest motion\n * from the original state. This does not change the point count, impulses, etc.\n * The radii must come from the shapes that generated the manifold.\n */\n getWorldManifold(wm: WorldManifold | null, xfA: TransformValue, radiusA: number, xfB: TransformValue, radiusB: number): WorldManifold {\n if (this.pointCount == 0) {\n return wm;\n }\n\n wm = wm || new WorldManifold();\n\n wm.pointCount = this.pointCount;\n\n const normal = wm.normal;\n const points = wm.points;\n const separations = wm.separations;\n\n switch (this.type) {\n case ManifoldType.e_circles: {\n matrix.setVec2(normal, 1.0, 0.0);\n const manifoldPoint = this.points[0];\n matrix.transformVec2(pointA, xfA, this.localPoint);\n matrix.transformVec2(pointB, xfB, manifoldPoint.localPoint);\n matrix.subVec2(dist, pointB, pointA);\n const lengthSqr = matrix.lengthSqrVec2(dist);\n if (lengthSqr > EPSILON * EPSILON) {\n const length = math_sqrt(lengthSqr);\n matrix.scaleVec2(normal, 1 / length, dist);\n }\n matrix.combine2Vec2(cA, 1, pointA, radiusA, normal);\n matrix.combine2Vec2(cB, 1, pointB, -radiusB, normal);\n matrix.combine2Vec2(points[0], 0.5, cA, 0.5, cB);\n separations[0] = matrix.dotVec2(matrix.subVec2(temp, cB, cA), normal);\n break;\n }\n\n case ManifoldType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.localNormal);\n matrix.transformVec2(planePoint, xfA, this.localPoint);\n\n for (let i = 0; i < this.pointCount; ++i) {\n const manifoldPoint = this.points[i];\n matrix.transformVec2(clipPoint, xfB, manifoldPoint.localPoint);\n matrix.combine2Vec2(cA, 1, clipPoint, radiusA - matrix.dotVec2(matrix.subVec2(temp, clipPoint, planePoint), normal), normal);\n matrix.combine2Vec2(cB, 1, clipPoint, -radiusB, normal);\n matrix.combine2Vec2(points[i], 0.5, cA, 0.5, cB);\n separations[i] = matrix.dotVec2(matrix.subVec2(temp, cB, cA), normal);\n }\n break;\n }\n\n case ManifoldType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.localNormal);\n matrix.transformVec2(planePoint, xfB, this.localPoint);\n\n for (let i = 0; i < this.pointCount; ++i) {\n const manifoldPoint = this.points[i];\n matrix.transformVec2(clipPoint, xfA, manifoldPoint.localPoint);\n matrix.combine2Vec2(cB, 1, clipPoint, radiusB - matrix.dotVec2(matrix.subVec2(temp, clipPoint, planePoint), normal), normal);\n matrix.combine2Vec2(cA, 1, clipPoint, -radiusA, normal);\n matrix.combine2Vec2(points[i], 0.5, cA, 0.5, cB);\n separations[i] = matrix.dotVec2(matrix.subVec2(temp, cA, cB), normal);\n }\n // Ensure normal points from A to B.\n matrix.negVec2(normal);\n break;\n }\n }\n\n return wm;\n }\n\n static clipSegmentToLine = clipSegmentToLine;\n static ClipVertex = ClipVertex;\n static getPointStates = getPointStates;\n static PointState = PointState;\n}\n\n/**\n * A manifold point is a contact point belonging to a contact manifold. It holds\n * details related to the geometry and dynamics of the contact points.\n *\n * This structure is stored across time steps, so we keep it small.\n *\n * Note: impulses are used for internal caching and may not provide reliable\n * contact forces, especially for high speed collisions.\n */\nexport class ManifoldPoint {\n /**\n * Usage depends on manifold type:\n * - circles: the local center of circleB\n * - faceA: the local center of circleB or the clip point of polygonB\n * - faceB: the clip point of polygonA\n */\n localPoint = matrix.vec2(0, 0);\n /**\n * The non-penetration impulse\n */\n normalImpulse = 0;\n /**\n * The friction impulse\n */\n tangentImpulse = 0;\n /**\n * Uniquely identifies a contact point between two shapes to facilitate warm starting\n */\n readonly id = new ContactID();\n\n set(that: ManifoldPoint): void {\n matrix.copyVec2(this.localPoint, that.localPoint);\n this.normalImpulse = that.normalImpulse;\n this.tangentImpulse = that.tangentImpulse;\n this.id.set(that.id);\n }\n\n recycle(): void {\n matrix.zeroVec2(this.localPoint);\n this.normalImpulse = 0;\n this.tangentImpulse = 0;\n this.id.recycle();\n }\n}\n\n/**\n * Contact ids to facilitate warm starting.\n * \n * ContactFeature: The features that intersect to form the contact point.\n */\nexport class ContactID {\n\n /**\n * Used to quickly compare contact ids.\n */\n key = -1;\n\n /** ContactFeature index on shapeA */\n indexA = -1;\n\n /** ContactFeature index on shapeB */\n indexB = -1;\n\n /** ContactFeature type on shapeA */\n typeA = ContactFeatureType.e_unset;\n\n /** ContactFeature type on shapeB */\n typeB = ContactFeatureType.e_unset;\n\n setFeatures(indexA: number, typeA: ContactFeatureType, indexB: number, typeB: ContactFeatureType): void {\n this.indexA = indexA;\n this.indexB = indexB;\n this.typeA = typeA;\n this.typeB = typeB;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n set(that: ContactID): void {\n this.indexA = that.indexA;\n this.indexB = that.indexB;\n this.typeA = that.typeA;\n this.typeB = that.typeB;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n swapFeatures(): void {\n const indexA = this.indexA;\n const indexB = this.indexB;\n const typeA = this.typeA;\n const typeB = this.typeB;\n this.indexA = indexB;\n this.indexB = indexA;\n this.typeA = typeB;\n this.typeB = typeA;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n recycle(): void {\n this.indexA = 0;\n this.indexB = 0;\n this.typeA = ContactFeatureType.e_unset;\n this.typeB = ContactFeatureType.e_unset;\n this.key = -1;\n }\n}\n\n/**\n * This is used to compute the current state of a contact manifold.\n */\nexport class WorldManifold {\n /** World vector pointing from A to B */\n normal = matrix.vec2(0, 0);\n\n /** World contact point (point of intersection) */\n points = [matrix.vec2(0, 0), matrix.vec2(0, 0)]; // [maxManifoldPoints]\n\n /** A negative value indicates overlap, in meters */\n separations = [0, 0]; // [maxManifoldPoints]\n\n /** The number of manifold points */\n pointCount = 0;\n\n recycle() {\n matrix.zeroVec2(this.normal);\n matrix.zeroVec2(this.points[0]);\n matrix.zeroVec2(this.points[1]);\n this.separations[0] = 0;\n this.separations[1] = 0;\n this.pointCount = 0;\n }\n}\n\n/**\n * Compute the point states given two manifolds. The states pertain to the\n * transition from manifold1 to manifold2. So state1 is either persist or remove\n * while state2 is either add or persist.\n */\nexport function getPointStates(\n state1: PointState[],\n state2: PointState[],\n manifold1: Manifold,\n manifold2: Manifold\n): void {\n // state1, state2: PointState[Settings.maxManifoldPoints]\n\n // for (var i = 0; i < Settings.maxManifoldPoints; ++i) {\n // state1[i] = PointState.nullState;\n // state2[i] = PointState.nullState;\n // }\n\n // Detect persists and removes.\n for (let i = 0; i < manifold1.pointCount; ++i) {\n const id = manifold1.points[i].id;\n\n state1[i] = PointState.removeState;\n\n for (let j = 0; j < manifold2.pointCount; ++j) {\n if (manifold2.points[j].id.key === id.key) {\n state1[i] = PointState.persistState;\n break;\n }\n }\n }\n\n // Detect persists and adds.\n for (let i = 0; i < manifold2.pointCount; ++i) {\n const id = manifold2.points[i].id;\n\n state2[i] = PointState.addState;\n\n for (let j = 0; j < manifold1.pointCount; ++j) {\n if (manifold1.points[j].id.key === id.key) {\n state2[i] = PointState.persistState;\n break;\n }\n }\n }\n}\n\n/**\n * Clipping for contact manifolds. Sutherland-Hodgman clipping.\n */\nexport function clipSegmentToLine(\n vOut: ClipVertex[],\n vIn: ClipVertex[],\n normal: Vec2Value,\n offset: number,\n vertexIndexA: number\n): number {\n // Start with no output points\n let numOut = 0;\n\n // Calculate the distance of end points to the line\n const distance0 = matrix.dotVec2(normal, vIn[0].v) - offset;\n const distance1 = matrix.dotVec2(normal, vIn[1].v) - offset;\n\n // If the points are behind the plane\n if (distance0 <= 0.0)\n vOut[numOut++].set(vIn[0]);\n if (distance1 <= 0.0)\n vOut[numOut++].set(vIn[1]);\n\n // If the points are on different sides of the plane\n if (distance0 * distance1 < 0.0) {\n // Find intersection point of edge and plane\n const interp = distance0 / (distance0 - distance1);\n matrix.combine2Vec2(vOut[numOut].v, 1 - interp, vIn[0].v, interp, vIn[1].v);\n\n // VertexA is hitting edgeB.\n vOut[numOut].id.setFeatures(vertexIndexA, ContactFeatureType.e_vertex, vIn[0].id.indexB, ContactFeatureType.e_face);\n ++numOut;\n }\n\n return numOut;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { ShapeType } from \"../collision/Shape\";\nimport { clamp } from \"../common/Math\";\nimport { TransformValue } from \"../common/Transform\";\nimport { Mat22 } from \"../common/Mat22\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { Manifold, ManifoldType, WorldManifold } from \"../collision/Manifold\";\nimport { testOverlap } from \"../collision/Distance\";\nimport { Fixture } from \"./Fixture\";\nimport { Body } from \"./Body\";\nimport { ContactImpulse, TimeStep } from \"./Solver\";\nimport { Pool } from \"../util/Pool\";\nimport { getTransform } from \"./Position\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n// Solver debugging is normally disabled because the block solver sometimes has to deal with a poorly conditioned effective mass matrix.\n/** @internal */ const DEBUG_SOLVER = false;\n\n/** @internal */ const contactPool = new Pool({\n create() {\n return new Contact();\n },\n release(contact: Contact) {\n contact.recycle();\n }\n});\n\n/** @internal */ const oldManifold = new Manifold();\n\n/** @internal */ const worldManifold = new WorldManifold();\n\n/**\n * A contact edge is used to connect bodies and contacts together in a contact\n * graph where each body is a node and each contact is an edge. A contact edge\n * belongs to a doubly linked list maintained in each attached body. Each\n * contact has two contact nodes, one for each attached body.\n */\nexport class ContactEdge {\n contact: Contact;\n prev: ContactEdge | null = null;\n next: ContactEdge | null = null;\n other: Body | null = null;\n constructor(contact: Contact) {\n this.contact = contact;\n }\n\n /** @internal */\n recycle() {\n this.prev = null;\n this.next = null;\n this.other = null;\n }\n}\n\nexport type EvaluateFunction = (\n manifold: Manifold,\n xfA: TransformValue,\n fixtureA: Fixture,\n indexA: number,\n xfB: TransformValue,\n fixtureB: Fixture,\n indexB: number\n) => void;\n\n/**\n * Friction mixing law. The idea is to allow either fixture to drive the\n * friction to zero. For example, anything slides on ice.\n */\nexport function mixFriction(friction1: number, friction2: number): number {\n return math_sqrt(friction1 * friction2);\n}\n\n/**\n * Restitution mixing law. The idea is allow for anything to bounce off an\n * inelastic surface. For example, a superball bounces on anything.\n */\nexport function mixRestitution(restitution1: number, restitution2: number): number {\n return restitution1 > restitution2 ? restitution1 : restitution2;\n}\n\n// TODO: move this to Settings?\n/** @internal */ const s_registers = [];\n\n// TODO: merge with ManifoldPoint?\nexport class VelocityConstraintPoint {\n rA = matrix.vec2(0, 0);\n rB = matrix.vec2(0, 0);\n normalImpulse = 0;\n tangentImpulse = 0;\n normalMass = 0;\n tangentMass = 0;\n velocityBias = 0;\n\n recycle() {\n matrix.zeroVec2(this.rA);\n matrix.zeroVec2(this.rB);\n this.normalImpulse = 0;\n this.tangentImpulse = 0;\n this.normalMass = 0;\n this.tangentMass = 0;\n this.velocityBias = 0;\n }\n}\n\n/** @internal */ const cA = matrix.vec2(0, 0);\n/** @internal */ const vA = matrix.vec2(0, 0);\n/** @internal */ const cB = matrix.vec2(0, 0);\n/** @internal */ const vB = matrix.vec2(0, 0);\n/** @internal */ const tangent = matrix.vec2(0, 0);\n/** @internal */ const xfA = matrix.transform(0, 0, 0);\n/** @internal */ const xfB = matrix.transform(0, 0, 0);\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const clipPoint = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const rA = matrix.vec2(0, 0);\n/** @internal */ const rB = matrix.vec2(0, 0);\n/** @internal */ const P = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const point = matrix.vec2(0, 0);\n/** @internal */ const dv = matrix.vec2(0, 0);\n/** @internal */ const dv1 = matrix.vec2(0, 0);\n/** @internal */ const dv2 = matrix.vec2(0, 0);\n/** @internal */ const b = matrix.vec2(0, 0);\n/** @internal */ const a = matrix.vec2(0, 0);\n/** @internal */ const x = matrix.vec2(0, 0);\n/** @internal */ const d = matrix.vec2(0, 0);\n/** @internal */ const P1 = matrix.vec2(0, 0);\n/** @internal */ const P2 = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n\n/**\n * The class manages contact between two shapes. A contact exists for each\n * overlapping AABB in the broad-phase (except if filtered). Therefore a contact\n * object may exist that has no contact points.\n */\nexport class Contact {\n // Nodes for connecting bodies.\n /** @internal */ m_nodeA = new ContactEdge(this);\n /** @internal */ m_nodeB = new ContactEdge(this);\n /** @internal */ m_fixtureA: Fixture | null = null;\n /** @internal */ m_fixtureB: Fixture | null = null;\n /** @internal */ m_indexA = -1;\n /** @internal */ m_indexB = -1;\n /** @internal */ m_evaluateFcn: EvaluateFunction | null = null;\n /** @internal */ m_manifold: Manifold = new Manifold();\n /** @internal */ m_prev: Contact | null = null;\n /** @internal */ m_next: Contact | null = null;\n /** @internal */ m_toi = 1.0;\n /** @internal */ m_toiCount = 0;\n // This contact has a valid TOI in m_toi\n /** @internal */ m_toiFlag = false;\n /** @internal */ m_friction = 0.0;\n /** @internal */ m_restitution = 0.0;\n /** @internal */ m_tangentSpeed = 0.0;\n /** @internal This contact can be disabled (by user) */\n m_enabledFlag = true;\n /** @internal Used when crawling contact graph when forming islands. */\n m_islandFlag = false;\n /** @internal Set when the shapes are touching. */\n m_touchingFlag = false;\n /** @internal This contact needs filtering because a fixture filter was changed. */\n m_filterFlag = false;\n /** @internal This bullet contact had a TOI event */\n m_bulletHitFlag = false;\n\n /** @internal Contact reporting impulse object cache */\n m_impulse: ContactImpulse = new ContactImpulse(this);\n\n // VelocityConstraint\n /** @internal */ v_points = [new VelocityConstraintPoint(), new VelocityConstraintPoint()]; // [maxManifoldPoints];\n /** @internal */ v_normal = matrix.vec2(0, 0);\n /** @internal */ v_normalMass: Mat22 = new Mat22();\n /** @internal */ v_K: Mat22 = new Mat22();\n /** @internal */ v_pointCount = 0;\n /** @internal */ v_tangentSpeed = 0;\n /** @internal */ v_friction = 0;\n /** @internal */ v_restitution = 0;\n /** @internal */ v_invMassA = 0;\n /** @internal */ v_invMassB = 0;\n /** @internal */ v_invIA = 0;\n /** @internal */ v_invIB = 0;\n\n // PositionConstraint\n /** @internal */ p_localPoints = [matrix.vec2(0, 0), matrix.vec2(0, 0)]; // [maxManifoldPoints];\n /** @internal */ p_localNormal = matrix.vec2(0, 0);\n /** @internal */ p_localPoint = matrix.vec2(0, 0);\n /** @internal */ p_localCenterA = matrix.vec2(0, 0);\n /** @internal */ p_localCenterB = matrix.vec2(0, 0);\n /** @internal */ p_type = ManifoldType.e_unset;\n /** @internal */ p_radiusA = 0;\n /** @internal */ p_radiusB = 0;\n /** @internal */ p_pointCount = 0;\n /** @internal */ p_invMassA = 0;\n /** @internal */ p_invMassB = 0;\n /** @internal */ p_invIA = 0;\n /** @internal */ p_invIB = 0;\n\n /** @internal */ \n initialize(fA: Fixture, indexA: number, fB: Fixture, indexB: number, evaluateFcn: EvaluateFunction) {\n this.m_fixtureA = fA;\n this.m_fixtureB = fB;\n\n this.m_indexA = indexA;\n this.m_indexB = indexB;\n\n this.m_evaluateFcn = evaluateFcn;\n\n this.m_friction = mixFriction(this.m_fixtureA.m_friction, this.m_fixtureB.m_friction);\n this.m_restitution = mixRestitution(this.m_fixtureA.m_restitution, this.m_fixtureB.m_restitution);\n }\n\n /** @internal */ \n recycle() {\n this.m_nodeA.recycle();\n this.m_nodeB.recycle();\n this.m_fixtureA = null;\n this.m_fixtureB = null;\n this.m_indexA = -1;\n this.m_indexB = -1;\n this.m_evaluateFcn = null;\n this.m_manifold.recycle();\n this.m_prev = null;\n this.m_next = null;\n this.m_toi = 1;\n this.m_toiCount = 0;\n this.m_toiFlag = false;\n this.m_friction = 0;\n this.m_restitution = 0;\n this.m_tangentSpeed = 0;\n this.m_enabledFlag = true;\n this.m_islandFlag = false;\n this.m_touchingFlag = false;\n this.m_filterFlag = false;\n this.m_bulletHitFlag = false;\n\n this.m_impulse.recycle();\n\n // VelocityConstraint\n for(const point of this.v_points) {\n point.recycle();\n }\n matrix.zeroVec2(this.v_normal);\n this.v_normalMass.setZero();\n this.v_K.setZero();\n this.v_pointCount = 0;\n this.v_tangentSpeed = 0;\n this.v_friction = 0;\n this.v_restitution = 0;\n this.v_invMassA = 0;\n this.v_invMassB = 0;\n this.v_invIA = 0;\n this.v_invIB = 0;\n\n // PositionConstraint\n for(const point of this.p_localPoints) {\n matrix.zeroVec2(point);\n }\n matrix.zeroVec2(this.p_localNormal);\n matrix.zeroVec2(this.p_localPoint);\n matrix.zeroVec2(this.p_localCenterA);\n matrix.zeroVec2(this.p_localCenterB);\n this.p_type = ManifoldType.e_unset;\n this.p_radiusA = 0;\n this.p_radiusB = 0;\n this.p_pointCount = 0;\n this.p_invMassA = 0;\n this.p_invMassB = 0;\n this.p_invIA = 0;\n this.p_invIB = 0;\n }\n\n initConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n const manifold = this.m_manifold;\n\n const pointCount = manifold.pointCount;\n if (_ASSERT) console.assert(pointCount > 0);\n\n this.v_invMassA = bodyA.m_invMass;\n this.v_invMassB = bodyB.m_invMass;\n this.v_invIA = bodyA.m_invI;\n this.v_invIB = bodyB.m_invI;\n\n this.v_friction = this.m_friction;\n this.v_restitution = this.m_restitution;\n this.v_tangentSpeed = this.m_tangentSpeed;\n\n this.v_pointCount = pointCount;\n\n this.v_K.setZero();\n this.v_normalMass.setZero();\n\n this.p_invMassA = bodyA.m_invMass;\n this.p_invMassB = bodyB.m_invMass;\n this.p_invIA = bodyA.m_invI;\n this.p_invIB = bodyB.m_invI;\n matrix.copyVec2(this.p_localCenterA, bodyA.m_sweep.localCenter);\n matrix.copyVec2(this.p_localCenterB, bodyB.m_sweep.localCenter);\n\n this.p_radiusA = shapeA.m_radius;\n this.p_radiusB = shapeB.m_radius;\n\n this.p_type = manifold.type;\n matrix.copyVec2(this.p_localNormal, manifold.localNormal);\n matrix.copyVec2(this.p_localPoint, manifold.localPoint);\n this.p_pointCount = pointCount;\n\n for (let j = 0; j < Settings.maxManifoldPoints; ++j) {\n this.v_points[j].recycle();\n matrix.zeroVec2(this.p_localPoints[j]);\n }\n\n for (let j = 0; j < pointCount; ++j) {\n const cp = manifold.points[j];\n const vcp = this.v_points[j];\n if (step.warmStarting) {\n vcp.normalImpulse = step.dtRatio * cp.normalImpulse;\n vcp.tangentImpulse = step.dtRatio * cp.tangentImpulse;\n }\n matrix.copyVec2(this.p_localPoints[j], cp.localPoint);\n }\n }\n\n /**\n * Get the contact manifold. Do not modify the manifold unless you understand\n * the internals of the library.\n */\n getManifold(): Manifold {\n return this.m_manifold;\n }\n\n /**\n * Get the world manifold.\n */\n getWorldManifold(worldManifold: WorldManifold | null): WorldManifold | undefined {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n return this.m_manifold.getWorldManifold(\n worldManifold,\n bodyA.getTransform(), shapeA.m_radius,\n bodyB.getTransform(), shapeB.m_radius\n );\n }\n\n /**\n * Enable/disable this contact. This can be used inside the pre-solve contact\n * listener. The contact is only disabled for the current time step (or sub-step\n * in continuous collisions).\n */\n setEnabled(flag: boolean): void {\n this.m_enabledFlag = !!flag;\n }\n\n /**\n * Has this contact been disabled?\n */\n isEnabled(): boolean {\n return this.m_enabledFlag;\n }\n\n /**\n * Is this contact touching?\n */\n isTouching(): boolean {\n return this.m_touchingFlag;\n }\n\n /**\n * Get the next contact in the world's contact list.\n */\n getNext(): Contact | null {\n return this.m_next;\n }\n\n /**\n * Get fixture A in this contact.\n */\n getFixtureA(): Fixture {\n return this.m_fixtureA;\n }\n\n /**\n * Get fixture B in this contact.\n */\n getFixtureB(): Fixture {\n return this.m_fixtureB;\n }\n\n /**\n * Get the child primitive index for fixture A.\n */\n getChildIndexA(): number {\n return this.m_indexA;\n }\n\n /**\n * Get the child primitive index for fixture B.\n */\n getChildIndexB(): number {\n return this.m_indexB;\n }\n\n /**\n * Flag this contact for filtering. Filtering will occur the next time step.\n */\n flagForFiltering(): void {\n this.m_filterFlag = true;\n }\n\n /**\n * Override the default friction mixture. You can call this in\n * \"pre-solve\" callback. This value persists until set or reset.\n */\n setFriction(friction: number): void {\n this.m_friction = friction;\n }\n\n /**\n * Get the friction.\n */\n getFriction(): number {\n return this.m_friction;\n }\n\n /**\n * Reset the friction mixture to the default value.\n */\n resetFriction(): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_friction = mixFriction(fixtureA.m_friction, fixtureB.m_friction);\n }\n\n /**\n * Override the default restitution mixture. You can call this in\n * \"pre-solve\" callback. The value persists until you set or reset.\n */\n setRestitution(restitution: number): void {\n this.m_restitution = restitution;\n }\n\n /**\n * Get the restitution.\n */\n getRestitution(): number {\n return this.m_restitution;\n }\n\n /**\n * Reset the restitution to the default value.\n */\n resetRestitution(): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_restitution = mixRestitution(fixtureA.m_restitution, fixtureB.m_restitution);\n }\n\n /**\n * Set the desired tangent speed for a conveyor belt behavior. In meters per\n * second.\n */\n setTangentSpeed(speed: number): void {\n this.m_tangentSpeed = speed;\n }\n\n /**\n * Get the desired tangent speed. In meters per second.\n */\n getTangentSpeed(): number {\n return this.m_tangentSpeed;\n }\n\n /**\n * Called by Update method, and implemented by subclasses.\n */\n evaluate(manifold: Manifold, xfA: TransformValue, xfB: TransformValue): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_evaluateFcn(manifold, xfA, fixtureA, this.m_indexA, xfB, fixtureB, this.m_indexB);\n }\n\n /**\n * Updates the contact manifold and touching status.\n *\n * Note: do not assume the fixture AABBs are overlapping or are valid.\n *\n * @param listener.beginContact\n * @param listener.endContact\n * @param listener.preSolve\n */\n update(listener?: {\n beginContact(contact: Contact): void,\n endContact(contact: Contact): void,\n preSolve(contact: Contact, oldManifold: Manifold): void\n }): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n // Re-enable this contact.\n this.m_enabledFlag = true;\n\n let touching = false;\n const wasTouching = this.m_touchingFlag;\n\n const sensorA = fixtureA.m_isSensor;\n const sensorB = fixtureB.m_isSensor;\n const sensor = sensorA || sensorB;\n\n const xfA = bodyA.m_xf;\n const xfB = bodyB.m_xf;\n\n // Is this contact a sensor?\n if (sensor) {\n touching = testOverlap(shapeA, this.m_indexA, shapeB, this.m_indexB, xfA, xfB);\n\n // Sensors don't generate manifolds.\n this.m_manifold.pointCount = 0;\n } else {\n\n oldManifold.recycle();\n oldManifold.set(this.m_manifold);\n this.m_manifold.recycle();\n\n this.evaluate(this.m_manifold, xfA, xfB);\n touching = this.m_manifold.pointCount > 0;\n\n // Match old contact ids to new contact ids and copy the\n // stored impulses to warm start the solver.\n for (let i = 0; i < this.m_manifold.pointCount; ++i) {\n const nmp = this.m_manifold.points[i];\n nmp.normalImpulse = 0.0;\n nmp.tangentImpulse = 0.0;\n\n for (let j = 0; j < oldManifold.pointCount; ++j) {\n const omp = oldManifold.points[j];\n if (omp.id.key === nmp.id.key) {\n nmp.normalImpulse = omp.normalImpulse;\n nmp.tangentImpulse = omp.tangentImpulse;\n break;\n }\n }\n }\n\n if (touching !== wasTouching) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n }\n\n this.m_touchingFlag = touching;\n\n const hasListener = typeof listener === \"object\" && listener !== null;\n\n if (!wasTouching && touching && hasListener) {\n listener.beginContact(this);\n }\n\n if (wasTouching && !touching && hasListener) {\n listener.endContact(this);\n }\n\n if (!sensor && touching && hasListener && oldManifold) {\n listener.preSolve(this, oldManifold);\n }\n }\n\n solvePositionConstraint(step: TimeStep): number {\n return this._solvePositionConstraint(step, null, null);\n }\n\n solvePositionConstraintTOI(step: TimeStep, toiA: Body, toiB: Body): number {\n return this._solvePositionConstraint(step, toiA, toiB);\n }\n\n private _solvePositionConstraint(step: TimeStep, toiA: Body | null, toiB: Body | null): number {\n const toi = toiA !== null && toiB !== null ? true : false;\n let minSeparation = 0.0;\n\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return minSeparation;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return minSeparation;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const localCenterA = this.p_localCenterA;\n const localCenterB = this.p_localCenterB;\n\n let mA = 0.0;\n let iA = 0.0;\n if (!toi || (bodyA === toiA || bodyA === toiB)) {\n mA = this.p_invMassA;\n iA = this.p_invIA;\n }\n\n let mB = 0.0;\n let iB = 0.0;\n if (!toi || (bodyB === toiA || bodyB === toiB)) {\n mB = this.p_invMassB;\n iB = this.p_invIB;\n }\n\n matrix.copyVec2(cA, positionA.c);\n let aA = positionA.a;\n\n matrix.copyVec2(cB, positionB.c);\n let aB = positionB.a;\n\n // Solve normal constraints\n for (let j = 0; j < this.p_pointCount; ++j) {\n getTransform(xfA, localCenterA, cA, aA);\n getTransform(xfB, localCenterB, cB, aB);\n\n // PositionSolverManifold\n let separation: number;\n switch (this.p_type) {\n case ManifoldType.e_circles: {\n matrix.transformVec2(pointA, xfA, this.p_localPoint);\n matrix.transformVec2(pointB, xfB, this.p_localPoints[0]);\n matrix.subVec2(normal, pointB, pointA);\n matrix.normalizeVec2(normal);\n\n matrix.combine2Vec2(point, 0.5, pointA, 0.5, pointB);\n separation = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal) - this.p_radiusA - this.p_radiusB;\n break;\n }\n\n case ManifoldType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.p_localNormal);\n matrix.transformVec2(planePoint, xfA, this.p_localPoint);\n matrix.transformVec2(clipPoint, xfB, this.p_localPoints[j]);\n separation = matrix.dotVec2(clipPoint, normal) - matrix.dotVec2(planePoint, normal) - this.p_radiusA - this.p_radiusB;\n matrix.copyVec2(point, clipPoint);\n break;\n }\n\n case ManifoldType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.p_localNormal);\n matrix.transformVec2(planePoint, xfB, this.p_localPoint);\n matrix.transformVec2(clipPoint, xfA, this.p_localPoints[j]);\n separation = matrix.dotVec2(clipPoint, normal) - matrix.dotVec2(planePoint, normal) - this.p_radiusA - this.p_radiusB;\n matrix.copyVec2(point, clipPoint);\n\n // Ensure normal points from A to B\n matrix.negVec2(normal);\n break;\n }\n // todo: what should we do here?\n default: {\n return minSeparation;\n }\n }\n\n matrix.subVec2(rA, point, cA);\n matrix.subVec2(rB, point, cB);\n\n // Track max constraint error.\n minSeparation = math_min(minSeparation, separation);\n\n const baumgarte = toi ? Settings.toiBaugarte : Settings.baumgarte;\n const linearSlop = Settings.linearSlop;\n const maxLinearCorrection = Settings.maxLinearCorrection;\n\n // Prevent large corrections and allow slop.\n const C = clamp(baumgarte * (separation + linearSlop), -maxLinearCorrection, 0.0);\n\n // Compute the effective mass.\n const rnA = matrix.crossVec2Vec2(rA, normal);\n const rnB = matrix.crossVec2Vec2(rB, normal);\n const K = mA + mB + iA * rnA * rnA + iB * rnB * rnB;\n\n // Compute normal impulse\n const impulse = K > 0.0 ? -C / K : 0.0;\n\n matrix.scaleVec2(P, impulse, normal);\n\n matrix.minusScaleVec2(cA, mA, P);\n aA -= iA * matrix.crossVec2Vec2(rA, P);\n\n matrix.plusScaleVec2(cB, mB, P);\n aB += iB * matrix.crossVec2Vec2(rB, P);\n }\n\n matrix.copyVec2(positionA.c, cA);\n positionA.a = aA;\n\n matrix.copyVec2(positionB.c, cB);\n positionB.a = aB;\n\n return minSeparation;\n }\n\n initVelocityConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const radiusA = this.p_radiusA;\n const radiusB = this.p_radiusB;\n const manifold = this.m_manifold;\n\n const mA = this.v_invMassA;\n const mB = this.v_invMassB;\n const iA = this.v_invIA;\n const iB = this.v_invIB;\n const localCenterA = this.p_localCenterA;\n const localCenterB = this.p_localCenterB;\n\n matrix.copyVec2(cA, positionA.c);\n const aA = positionA.a;\n matrix.copyVec2(vA, velocityA.v);\n const wA = velocityA.w;\n\n matrix.copyVec2(cB, positionB.c);\n const aB = positionB.a;\n matrix.copyVec2(vB, velocityB.v);\n const wB = velocityB.w;\n\n if (_ASSERT) console.assert(manifold.pointCount > 0);\n\n getTransform(xfA, localCenterA, cA, aA);\n getTransform(xfB, localCenterB, cB, aB);\n\n worldManifold.recycle();\n manifold.getWorldManifold(worldManifold, xfA, radiusA, xfB, radiusB);\n\n matrix.copyVec2(this.v_normal, worldManifold.normal);\n\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n const wmp = worldManifold.points[j];\n\n matrix.subVec2(vcp.rA, wmp, cA);\n matrix.subVec2(vcp.rB, wmp, cB);\n\n const rnA = matrix.crossVec2Vec2(vcp.rA, this.v_normal);\n const rnB = matrix.crossVec2Vec2(vcp.rB, this.v_normal);\n\n const kNormal = mA + mB + iA * rnA * rnA + iB * rnB * rnB;\n\n vcp.normalMass = kNormal > 0.0 ? 1.0 / kNormal : 0.0;\n\n matrix.crossVec2Num(tangent, this.v_normal, 1.0);\n\n const rtA = matrix.crossVec2Vec2(vcp.rA, tangent);\n const rtB = matrix.crossVec2Vec2(vcp.rB, tangent);\n\n const kTangent = mA + mB + iA * rtA * rtA + iB * rtB * rtB;\n\n vcp.tangentMass = kTangent > 0.0 ? 1.0 / kTangent : 0.0;\n\n // Setup a velocity bias for restitution.\n vcp.velocityBias = 0.0;\n let vRel = 0;\n vRel += matrix.dotVec2(this.v_normal, vB);\n vRel += matrix.dotVec2(this.v_normal, matrix.crossNumVec2(temp, wB, vcp.rB));\n vRel -= matrix.dotVec2(this.v_normal, vA);\n vRel -= matrix.dotVec2(this.v_normal, matrix.crossNumVec2(temp, wA, vcp.rA));\n if (vRel < -Settings.velocityThreshold) {\n vcp.velocityBias = -this.v_restitution * vRel;\n }\n }\n\n // If we have two points, then prepare the block solver.\n if (this.v_pointCount == 2 && step.blockSolve) {\n const vcp1 = this.v_points[0]; // VelocityConstraintPoint\n const vcp2 = this.v_points[1]; // VelocityConstraintPoint\n\n const rn1A = matrix.crossVec2Vec2(vcp1.rA, this.v_normal);\n const rn1B = matrix.crossVec2Vec2(vcp1.rB, this.v_normal);\n const rn2A = matrix.crossVec2Vec2(vcp2.rA, this.v_normal);\n const rn2B = matrix.crossVec2Vec2(vcp2.rB, this.v_normal);\n\n const k11 = mA + mB + iA * rn1A * rn1A + iB * rn1B * rn1B;\n const k22 = mA + mB + iA * rn2A * rn2A + iB * rn2B * rn2B;\n const k12 = mA + mB + iA * rn1A * rn2A + iB * rn1B * rn2B;\n\n // Ensure a reasonable condition number.\n const k_maxConditionNumber = 1000.0;\n if (k11 * k11 < k_maxConditionNumber * (k11 * k22 - k12 * k12)) {\n // K is safe to invert.\n this.v_K.ex.setNum(k11, k12);\n this.v_K.ey.setNum(k12, k22);\n // this.v_normalMass.set(this.v_K.getInverse());\n const a = this.v_K.ex.x;\n const b = this.v_K.ey.x;\n const c = this.v_K.ex.y;\n const d = this.v_K.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n this.v_normalMass.ex.x = det * d;\n this.v_normalMass.ey.x = -det * b;\n this.v_normalMass.ex.y = -det * c;\n this.v_normalMass.ey.y = det * a;\n\n } else {\n // The constraints are redundant, just use one.\n // TODO_ERIN use deepest?\n this.v_pointCount = 1;\n }\n }\n\n matrix.copyVec2(positionA.c, cA);\n positionA.a = aA;\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n\n matrix.copyVec2(positionB.c, cB);\n positionB.a = aB;\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n warmStartConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const mA = this.v_invMassA;\n const iA = this.v_invIA;\n const mB = this.v_invMassB;\n const iB = this.v_invIB;\n\n matrix.copyVec2(vA, velocityA.v);\n let wA = velocityA.w;\n matrix.copyVec2(vB, velocityB.v);\n let wB = velocityB.w;\n\n matrix.copyVec2(normal, this.v_normal);\n matrix.crossVec2Num(tangent, normal, 1.0);\n\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n\n matrix.combine2Vec2(P, vcp.normalImpulse, normal, vcp.tangentImpulse, tangent);\n\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n matrix.minusScaleVec2(vA, mA, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n matrix.plusScaleVec2(vB, mB, P);\n }\n\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n storeConstraintImpulses(step: TimeStep): void {\n const manifold = this.m_manifold;\n for (let j = 0; j < this.v_pointCount; ++j) {\n manifold.points[j].normalImpulse = this.v_points[j].normalImpulse;\n manifold.points[j].tangentImpulse = this.v_points[j].tangentImpulse;\n }\n }\n\n solveVelocityConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const positionA = bodyA.c_position;\n\n const velocityB = bodyB.c_velocity;\n const positionB = bodyB.c_position;\n\n const mA = this.v_invMassA;\n const iA = this.v_invIA;\n const mB = this.v_invMassB;\n const iB = this.v_invIB;\n\n matrix.copyVec2(vA, velocityA.v);\n let wA = velocityA.w;\n matrix.copyVec2(vB, velocityB.v);\n let wB = velocityB.w;\n\n matrix.copyVec2(normal, this.v_normal);\n matrix.crossVec2Num(tangent, normal, 1.0);\n const friction = this.v_friction;\n\n if (_ASSERT) console.assert(this.v_pointCount == 1 || this.v_pointCount == 2);\n\n // Solve tangent constraints first because non-penetration is more important\n // than friction.\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n\n // Relative velocity at contact\n matrix.zeroVec2(dv);\n matrix.plusVec2(dv, vB);\n matrix.plusVec2(dv, matrix.crossNumVec2(temp, wB, vcp.rB));\n matrix.minusVec2(dv, vA);\n matrix.minusVec2(dv, matrix.crossNumVec2(temp, wA, vcp.rA));\n\n // Compute tangent force\n const vt = matrix.dotVec2(dv, tangent) - this.v_tangentSpeed;\n let lambda = vcp.tangentMass * (-vt);\n\n // Clamp the accumulated force\n const maxFriction = friction * vcp.normalImpulse;\n const newImpulse = clamp(vcp.tangentImpulse + lambda, -maxFriction, maxFriction);\n lambda = newImpulse - vcp.tangentImpulse;\n vcp.tangentImpulse = newImpulse;\n\n // Apply contact impulse\n matrix.scaleVec2(P, lambda, tangent);\n\n matrix.minusScaleVec2(vA, mA, P);\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n\n matrix.plusScaleVec2(vB, mB, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n }\n\n // Solve normal constraints\n if (this.v_pointCount == 1 || step.blockSolve == false) {\n for (let i = 0; i < this.v_pointCount; ++i) {\n const vcp = this.v_points[i]; // VelocityConstraintPoint\n\n // Relative velocity at contact\n matrix.zeroVec2(dv);\n matrix.plusVec2(dv, vB);\n matrix.plusVec2(dv, matrix.crossNumVec2(temp, wB, vcp.rB));\n matrix.minusVec2(dv, vA);\n matrix.minusVec2(dv, matrix.crossNumVec2(temp, wA, vcp.rA));\n\n // Compute normal impulse\n const vn = matrix.dotVec2(dv, normal);\n let lambda = -vcp.normalMass * (vn - vcp.velocityBias);\n\n // Clamp the accumulated impulse\n const newImpulse = math_max(vcp.normalImpulse + lambda, 0.0);\n lambda = newImpulse - vcp.normalImpulse;\n vcp.normalImpulse = newImpulse;\n\n // Apply contact impulse\n matrix.scaleVec2(P, lambda, normal);\n\n matrix.minusScaleVec2(vA, mA, P);\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n\n matrix.plusScaleVec2(vB, mB, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n }\n } else {\n // Block solver developed in collaboration with Dirk Gregorius (back in\n // 01/07 on Box2D_Lite).\n // Build the mini LCP for this contact patch\n //\n // vn = A * x + b, vn >= 0, x >= 0 and vn_i * x_i = 0 with i = 1..2\n //\n // A = J * W * JT and J = ( -n, -r1 x n, n, r2 x n )\n // b = vn0 - velocityBias\n //\n // The system is solved using the \"Total enumeration method\" (s. Murty).\n // The complementary constraint vn_i * x_i\n // implies that we must have in any solution either vn_i = 0 or x_i = 0.\n // So for the 2D contact problem the cases\n // vn1 = 0 and vn2 = 0, x1 = 0 and x2 = 0, x1 = 0 and vn2 = 0, x2 = 0 and\n // vn1 = 0 need to be tested. The first valid\n // solution that satisfies the problem is chosen.\n //\n // In order to account of the accumulated impulse 'a' (because of the\n // iterative nature of the solver which only requires\n // that the accumulated impulse is clamped and not the incremental\n // impulse) we change the impulse variable (x_i).\n //\n // Substitute:\n //\n // x = a + d\n //\n // a := old total impulse\n // x := new total impulse\n // d := incremental impulse\n //\n // For the current iteration we extend the formula for the incremental\n // impulse\n // to compute the new total impulse:\n //\n // vn = A * d + b\n // = A * (x - a) + b\n // = A * x + b - A * a\n // = A * x + b'\n // b' = b - A * a;\n\n const vcp1 = this.v_points[0]; // VelocityConstraintPoint\n const vcp2 = this.v_points[1]; // VelocityConstraintPoint\n\n matrix.setVec2(a, vcp1.normalImpulse, vcp2.normalImpulse);\n if (_ASSERT) console.assert(a.x >= 0.0 && a.y >= 0.0);\n\n // Relative velocity at contact\n // let dv1 = Vec2.zero().add(vB).add(Vec2.crossNumVec2(wB, vcp1.rB)).sub(vA).sub(Vec2.crossNumVec2(wA, vcp1.rA));\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n // let dv2 = Vec2.zero().add(vB).add(Vec2.crossNumVec2(wB, vcp2.rB)).sub(vA).sub(Vec2.crossNumVec2(wA, vcp2.rA));\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n let vn1 = matrix.dotVec2(dv1, normal);\n let vn2 = matrix.dotVec2(dv2, normal);\n\n matrix.setVec2(b, vn1 - vcp1.velocityBias, vn2 - vcp2.velocityBias);\n\n // Compute b'\n // b.sub(Mat22.mulVec2(this.v_K, a));\n b.x -= this.v_K.ex.x * a.x + this.v_K.ey.x * a.y;\n b.y -= this.v_K.ex.y * a.x + this.v_K.ey.y * a.y;\n\n const k_errorTol = 1e-3;\n // NOT_USED(k_errorTol);\n\n while (true) {\n //\n // Case 1: vn = 0\n //\n // 0 = A * x + b'\n //\n // Solve for x:\n //\n // x = - inv(A) * b'\n //\n // const x = Mat22.mulVec2(this.v_normalMass, b).neg();\n matrix.zeroVec2(x);\n x.x = -(this.v_normalMass.ex.x * b.x + this.v_normalMass.ey.x * b.y);\n x.y = -(this.v_normalMass.ex.y * b.x + this.v_normalMass.ey.y * b.y);\n\n if (x.x >= 0.0 && x.y >= 0.0) {\n // Get the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n vn1 = matrix.dotVec2(dv1, normal);\n vn2 = matrix.dotVec2(dv2, normal);\n\n if (_ASSERT) console.assert(math_abs(vn1 - vcp1.velocityBias) < k_errorTol);\n if (_ASSERT) console.assert(math_abs(vn2 - vcp2.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 2: vn1 = 0 and x2 = 0\n //\n // 0 = a11 * x1 + a12 * 0 + b1'\n // vn2 = a21 * x1 + a22 * 0 + b2'\n //\n x.x = -vcp1.normalMass * b.x;\n x.y = 0.0;\n vn1 = 0.0;\n vn2 = this.v_K.ex.y * x.x + b.y;\n\n if (x.x >= 0.0 && vn2 >= 0.0) {\n // Get the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n // Compute normal velocity\n vn1 = matrix.dotVec2(dv1, normal);\n\n if (_ASSERT) console.assert(math_abs(vn1 - vcp1.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 3: vn2 = 0 and x1 = 0\n //\n // vn1 = a11 * 0 + a12 * x2 + b1'\n // 0 = a21 * 0 + a22 * x2 + b2'\n //\n x.x = 0.0;\n x.y = -vcp2.normalMass * b.y;\n vn1 = this.v_K.ey.x * x.y + b.x;\n vn2 = 0.0;\n\n if (x.y >= 0.0 && vn1 >= 0.0) {\n // Resubstitute for the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n vn2 = matrix.dotVec2(dv2, normal);\n\n if (_ASSERT) console.assert(math_abs(vn2 - vcp2.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 4: x1 = 0 and x2 = 0\n //\n // vn1 = b1\n // vn2 = b2;\n //\n x.x = 0.0;\n x.y = 0.0;\n vn1 = b.x;\n vn2 = b.y;\n\n if (vn1 >= 0.0 && vn2 >= 0.0) {\n // Resubstitute for the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n break;\n }\n\n // No solution, give up. This is hit sometimes, but it doesn't seem to\n // matter.\n break;\n }\n }\n\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n /** @internal */\n static addType(type1: ShapeType, type2: ShapeType, callback: EvaluateFunction): void {\n s_registers[type1] = s_registers[type1] || {};\n s_registers[type1][type2] = callback;\n }\n\n /** @internal */\n static create(fixtureA: Fixture, indexA: number, fixtureB: Fixture, indexB: number): Contact | null {\n const typeA = fixtureA.m_shape.m_type;\n const typeB = fixtureB.m_shape.m_type;\n\n const contact = contactPool.allocate();\n let evaluateFcn;\n if (evaluateFcn = s_registers[typeA] && s_registers[typeA][typeB]) {\n contact.initialize(fixtureA, indexA, fixtureB, indexB, evaluateFcn);\n } else if (evaluateFcn = s_registers[typeB] && s_registers[typeB][typeA]) {\n contact.initialize(fixtureB, indexB, fixtureA, indexA, evaluateFcn);\n } else {\n return null;\n }\n\n // Contact creation may swap fixtures.\n fixtureA = contact.m_fixtureA;\n fixtureB = contact.m_fixtureB;\n indexA = contact.getChildIndexA();\n indexB = contact.getChildIndexB();\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n\n // Connect to body A\n contact.m_nodeA.contact = contact;\n contact.m_nodeA.other = bodyB;\n\n contact.m_nodeA.prev = null;\n contact.m_nodeA.next = bodyA.m_contactList;\n if (bodyA.m_contactList != null) {\n bodyA.m_contactList.prev = contact.m_nodeA;\n }\n bodyA.m_contactList = contact.m_nodeA;\n\n // Connect to body B\n contact.m_nodeB.contact = contact;\n contact.m_nodeB.other = bodyA;\n\n contact.m_nodeB.prev = null;\n contact.m_nodeB.next = bodyB.m_contactList;\n if (bodyB.m_contactList != null) {\n bodyB.m_contactList.prev = contact.m_nodeB;\n }\n bodyB.m_contactList = contact.m_nodeB;\n\n // Wake up the bodies\n if (fixtureA.isSensor() == false && fixtureB.isSensor() == false) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n\n return contact;\n }\n\n /** @internal */\n static destroy(contact: Contact, listener: { endContact: (contact: Contact) => void }): void {\n const fixtureA = contact.m_fixtureA;\n const fixtureB = contact.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n if (contact.isTouching()) {\n listener.endContact(contact);\n }\n\n // Remove from body 1\n if (contact.m_nodeA.prev) {\n contact.m_nodeA.prev.next = contact.m_nodeA.next;\n }\n\n if (contact.m_nodeA.next) {\n contact.m_nodeA.next.prev = contact.m_nodeA.prev;\n }\n\n if (contact.m_nodeA == bodyA.m_contactList) {\n bodyA.m_contactList = contact.m_nodeA.next;\n }\n\n // Remove from body 2\n if (contact.m_nodeB.prev) {\n contact.m_nodeB.prev.next = contact.m_nodeB.next;\n }\n\n if (contact.m_nodeB.next) {\n contact.m_nodeB.next.prev = contact.m_nodeB.prev;\n }\n\n if (contact.m_nodeB == bodyB.m_contactList) {\n bodyB.m_contactList = contact.m_nodeB.next;\n }\n\n if (contact.m_manifold.pointCount > 0 && !fixtureA.m_isSensor && !fixtureB.m_isSensor) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n\n // const typeA = fixtureA.getType();\n // const typeB = fixtureB.getType();\n\n // const destroyFcn = s_registers[typeA][typeB].destroyFcn;\n // if (typeof destroyFcn === 'function') {\n // destroyFcn(contact);\n // }\n\n contactPool.release(contact);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../util/options\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { BroadPhase } from \"../collision/BroadPhase\";\nimport { Solver, ContactImpulse, TimeStep } from \"./Solver\";\nimport { Body, BodyDef } from \"./Body\";\nimport { Joint } from \"./Joint\";\nimport { Contact } from \"./Contact\";\nimport { AABBValue, RayCastInput, RayCastOutput } from \"../collision/AABB\";\nimport { Fixture, FixtureProxy } from \"./Fixture\";\nimport { Manifold } from \"../collision/Manifold\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\nexport interface WorldDef {\n /** [default: { x : 0, y : 0}] */\n gravity?: Vec2Value;\n\n /** [default: true] */\n allowSleep?: boolean;\n\n /** [default: true] */\n warmStarting?: boolean;\n\n /** [default: true] */\n continuousPhysics?: boolean;\n\n /** [default: false] */\n subStepping?: boolean;\n\n /** [default: true] */\n blockSolve?: boolean;\n\n /** @internal [8] For the velocity constraint solver. */\n velocityIterations?: number;\n\n /** @internal [3] For the position constraint solver. */\n positionIterations?: number;\n}\n\n/** @internal */ const DEFAULTS: WorldDef = {\n gravity : Vec2.zero(),\n allowSleep : true,\n warmStarting : true,\n continuousPhysics : true,\n subStepping : false,\n blockSolve : true,\n velocityIterations : 8,\n positionIterations : 3\n};\n\n/**\n * Callback function for ray casts, see {@link World.rayCast}.\n *\n * Called for each fixture found in the query.\n * The returned value replaces the ray-cast input maxFraction.\n * You control how the ray cast proceeds by returning a numeric/float value.\n * \n * - `0` to terminate the ray cast\n * - `fraction` to clip the ray cast at current point\n * - `1` don't clip the ray and continue\n * - `-1` (or anything else) to continue\n *\n * @param fixture The fixture hit by the ray\n * @param point The point of initial intersection\n * @param normal The normal vector at the point of intersection\n * @param fraction The fraction along the ray at the point of intersection\n *\n * @returns A number to update the maxFraction\n */\nexport type WorldRayCastCallback = (fixture: Fixture, point: Vec2, normal: Vec2, fraction: number) => number;\n\n/**\n * Called for each fixture found in the query AABB. It may return `false` to terminate the query.\n */\nexport type WorldAABBQueryCallback = (fixture: Fixture) => boolean;\n\ndeclare module \"./World\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(deg: WorldDef): World;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(gravity: Vec2): World;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(): World;\n}\n\n/**\n * The `World` class contains the bodies and joints. It manages all aspects\n * of the simulation and allows for asynchronous queries (like AABB queries\n * and ray-casts). Much of your interactions with Planck.js will be with a\n * World object.\n */\n// @ts-expect-error\nexport class World {\n /** @internal */ m_solver: Solver;\n /** @internal */ m_broadPhase: BroadPhase;\n /** @internal */ m_contactList: Contact | null;\n /** @internal */ m_contactCount: number;\n /** @internal */ m_bodyList: Body | null;\n /** @internal */ m_bodyCount: number;\n /** @internal */ m_jointList: Joint | null;\n /** @internal */ m_jointCount: number;\n /** @internal */ m_stepComplete: boolean;\n /** @internal */ m_allowSleep: boolean;\n /** @internal */ m_gravity: Vec2;\n /** @internal */ m_clearForces: boolean;\n /** @internal */ m_newFixture: boolean;\n /** @internal */ m_locked: boolean;\n /** @internal */ m_warmStarting: boolean;\n /** @internal */ m_continuousPhysics: boolean;\n /** @internal */ m_subStepping: boolean;\n /** @internal */ m_blockSolve: boolean;\n /** @internal */ m_velocityIterations: number;\n /** @internal */ m_positionIterations: number;\n /** @internal */ m_t: number;\n\n // TODO\n /** @internal */ _listeners: {\n [key: string]: any[]\n };\n\n /**\n * @param def World definition or gravity vector.\n */\n constructor(def?: WorldDef | Vec2Value) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof World)) {\n return new World(def);\n }\n\n this.s_step = new TimeStep();\n\n\n if (!def) {\n def = {};\n } else if (Vec2.isValid(def)) {\n def = { gravity: def as Vec2 };\n }\n\n def = options(def, DEFAULTS) as WorldDef;\n\n this.m_solver = new Solver(this);\n\n this.m_broadPhase = new BroadPhase();\n\n this.m_contactList = null;\n this.m_contactCount = 0;\n\n this.m_bodyList = null;\n this.m_bodyCount = 0;\n\n this.m_jointList = null;\n this.m_jointCount = 0;\n\n this.m_stepComplete = true;\n\n this.m_allowSleep = def.allowSleep;\n this.m_gravity = Vec2.clone(def.gravity);\n\n this.m_clearForces = true;\n this.m_newFixture = false;\n this.m_locked = false;\n\n // These are for debugging the solver.\n this.m_warmStarting = def.warmStarting;\n this.m_continuousPhysics = def.continuousPhysics;\n this.m_subStepping = def.subStepping;\n\n this.m_blockSolve = def.blockSolve;\n this.m_velocityIterations = def.velocityIterations;\n this.m_positionIterations = def.positionIterations;\n\n this.m_t = 0;\n }\n\n /** @internal */\n _serialize(): object {\n const bodies = [];\n const joints = [];\n\n for (let b = this.getBodyList(); b; b = b.getNext()) {\n bodies.push(b);\n }\n\n for (let j = this.getJointList(); j; j = j.getNext()) {\n // @ts-ignore\n if (typeof j._serialize === \"function\") {\n joints.push(j);\n }\n }\n\n return {\n gravity: this.m_gravity,\n bodies,\n joints,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, context: any, restore: any): World {\n if (!data) {\n return new World();\n }\n\n const world = new World(data.gravity);\n\n if (data.bodies) {\n for (let i = data.bodies.length - 1; i >= 0; i -= 1) {\n world._addBody(restore(Body, data.bodies[i], world));\n }\n }\n\n if (data.joints) {\n for (let i = data.joints.length - 1; i >= 0; i--) {\n world.createJoint(restore(Joint, data.joints[i], world));\n }\n }\n\n return world;\n }\n\n /**\n * Get the world body list. With the returned body, use Body.getNext to get the\n * next body in the world list. A null body indicates the end of the list.\n *\n * @return the head of the world body list.\n */\n getBodyList(): Body | null {\n return this.m_bodyList;\n }\n\n /**\n * Get the world joint list. With the returned joint, use Joint.getNext to get\n * the next joint in the world list. A null joint indicates the end of the list.\n *\n * @return the head of the world joint list.\n */\n getJointList(): Joint | null {\n return this.m_jointList;\n }\n\n /**\n * Get the world contact list. With the returned contact, use Contact.getNext to\n * get the next contact in the world list. A null contact indicates the end of\n * the list.\n *\n * Warning: contacts are created and destroyed in the middle of a time step.\n * Use ContactListener to avoid missing contacts.\n *\n * @return the head of the world contact list.\n */\n getContactList(): Contact | null {\n return this.m_contactList;\n }\n\n getBodyCount(): number {\n return this.m_bodyCount;\n }\n\n getJointCount(): number {\n return this.m_jointCount;\n }\n\n /**\n * Get the number of contacts (each may have 0 or more contact points).\n */\n getContactCount(): number {\n return this.m_contactCount;\n }\n\n /**\n * Change the global gravity vector.\n */\n setGravity(gravity: Vec2Value): void {\n this.m_gravity.set(gravity);\n }\n\n /**\n * Get the global gravity vector.\n */\n getGravity(): Vec2 {\n return this.m_gravity;\n }\n\n /**\n * Is the world locked (in the middle of a time step).\n */\n isLocked(): boolean {\n return this.m_locked;\n }\n\n /**\n * Enable/disable sleep.\n */\n setAllowSleeping(flag: boolean): void {\n if (flag == this.m_allowSleep) {\n return;\n }\n\n this.m_allowSleep = flag;\n if (this.m_allowSleep == false) {\n for (let b = this.m_bodyList; b; b = b.m_next) {\n b.setAwake(true);\n }\n }\n }\n\n getAllowSleeping(): boolean {\n return this.m_allowSleep;\n }\n\n /**\n * Enable/disable warm starting. For testing.\n */\n setWarmStarting(flag: boolean): void {\n this.m_warmStarting = flag;\n }\n\n getWarmStarting(): boolean {\n return this.m_warmStarting;\n }\n\n /**\n * Enable/disable continuous physics. For testing.\n */\n setContinuousPhysics(flag: boolean): void {\n this.m_continuousPhysics = flag;\n }\n\n getContinuousPhysics(): boolean {\n return this.m_continuousPhysics;\n }\n\n /**\n * Enable/disable single stepped continuous physics. For testing.\n */\n setSubStepping(flag: boolean): void {\n this.m_subStepping = flag;\n }\n\n getSubStepping(): boolean {\n return this.m_subStepping;\n }\n\n /**\n * Set flag to control automatic clearing of forces after each time step.\n */\n setAutoClearForces(flag: boolean): void {\n this.m_clearForces = flag;\n }\n\n /**\n * Get the flag that controls automatic clearing of forces after each time step.\n */\n getAutoClearForces(): boolean {\n return this.m_clearForces;\n }\n\n /**\n * Manually clear the force buffer on all bodies. By default, forces are cleared\n * automatically after each call to step. The default behavior is modified by\n * calling setAutoClearForces. The purpose of this function is to support\n * sub-stepping. Sub-stepping is often used to maintain a fixed sized time step\n * under a variable frame-rate. When you perform sub-stepping you will disable\n * auto clearing of forces and instead call clearForces after all sub-steps are\n * complete in one pass of your game loop.\n *\n * See {@link World.setAutoClearForces}\n */\n clearForces(): void {\n for (let body = this.m_bodyList; body; body = body.getNext()) {\n body.m_force.setZero();\n body.m_torque = 0.0;\n }\n }\n\n /**\n * Query the world for all fixtures that potentially overlap the provided AABB.\n *\n * @param aabb The query box.\n * @param callback Called for each fixture found in the query AABB. It may return `false` to terminate the query.\n */\n queryAABB(aabb: AABBValue, callback: WorldAABBQueryCallback): void {\n if (_ASSERT) console.assert(typeof callback === \"function\");\n const broadPhase = this.m_broadPhase;\n this.m_broadPhase.query(aabb, function(proxyId: number): boolean { // TODO GC\n const proxy = broadPhase.getUserData(proxyId);\n return callback(proxy.fixture);\n });\n }\n\n /**\n * Ray-cast the world for all fixtures in the path of the ray. Your callback\n * controls whether you get the closest point, any point, or n-points. The\n * ray-cast ignores shapes that contain the starting point.\n *\n * @param point1 The ray starting point\n * @param point2 The ray ending point\n * @param callback A function that is called for each fixture that is hit by the ray. You control how the ray cast proceeds by returning a numeric/float value.\n */\n rayCast(point1: Vec2Value, point2: Vec2Value, callback: WorldRayCastCallback): void {\n if (_ASSERT) console.assert(typeof callback === \"function\");\n const broadPhase = this.m_broadPhase;\n\n this.m_broadPhase.rayCast({\n maxFraction : 1.0,\n p1 : point1,\n p2 : point2\n }, function(input: RayCastInput, proxyId: number): number { // TODO GC\n const proxy = broadPhase.getUserData(proxyId);\n const fixture = proxy.fixture;\n const index = proxy.childIndex;\n // @ts-ignore\n const output: RayCastOutput = {}; // TODO GC\n const hit = fixture.rayCast(output, input, index);\n if (hit) {\n const fraction = output.fraction;\n const point = Vec2.add(Vec2.mulNumVec2((1.0 - fraction), input.p1), Vec2.mulNumVec2(fraction, input.p2));\n return callback(fixture, point, output.normal, fraction);\n }\n return input.maxFraction;\n });\n }\n\n /**\n * Get the number of broad-phase proxies.\n */\n getProxyCount(): number {\n return this.m_broadPhase.getProxyCount();\n }\n\n /**\n * Get the height of broad-phase dynamic tree.\n */\n getTreeHeight(): number {\n return this.m_broadPhase.getTreeHeight();\n }\n\n /**\n * Get the balance of broad-phase dynamic tree.\n */\n getTreeBalance(): number {\n return this.m_broadPhase.getTreeBalance();\n }\n\n /**\n * Get the quality metric of broad-phase dynamic tree. The smaller the better.\n * The minimum is 1.\n */\n getTreeQuality(): number {\n return this.m_broadPhase.getTreeQuality();\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The body shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n if (_ASSERT) console.assert(this.m_locked == false);\n if (this.m_locked) {\n return;\n }\n\n for (let b = this.m_bodyList; b; b = b.m_next) {\n b.m_xf.p.sub(newOrigin);\n b.m_sweep.c0.sub(newOrigin);\n b.m_sweep.c.sub(newOrigin);\n }\n\n for (let j = this.m_jointList; j; j = j.m_next) {\n j.shiftOrigin(newOrigin);\n }\n\n this.m_broadPhase.shiftOrigin(newOrigin);\n }\n\n /** @internal Used for deserialize. */\n _addBody(body: Body): void {\n if (_ASSERT) console.assert(this.isLocked() === false);\n if (this.isLocked()) {\n return;\n }\n\n // Add to world doubly linked list.\n body.m_prev = null;\n body.m_next = this.m_bodyList;\n if (this.m_bodyList) {\n this.m_bodyList.m_prev = body;\n }\n this.m_bodyList = body;\n ++this.m_bodyCount;\n }\n\n /**\n * Create a rigid body given a definition. No reference to the definition is\n * retained.\n *\n * Warning: This function is locked during callbacks.\n */\n createBody(def?: BodyDef): Body;\n createBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createBody(arg1?, arg2?) {\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return null;\n }\n\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n\n const body = new Body(this, def);\n this._addBody(body);\n return body;\n }\n\n createDynamicBody(def?: BodyDef): Body;\n createDynamicBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createDynamicBody(arg1?, arg2?) {\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n def.type = \"dynamic\";\n return this.createBody(def);\n }\n\n createKinematicBody(def?: BodyDef): Body;\n createKinematicBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createKinematicBody(arg1?, arg2?) {\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n def.type = \"kinematic\";\n return this.createBody(def);\n }\n\n /**\n * Destroy a rigid body given a definition. No reference to the definition is\n * retained.\n *\n * Warning: This automatically deletes all associated shapes and joints.\n *\n * Warning: This function is locked during callbacks.\n */\n destroyBody(b: Body): boolean {\n if (_ASSERT) console.assert(this.m_bodyCount > 0);\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return;\n }\n\n if (b.m_destroyed) {\n return false;\n }\n\n // Delete the attached joints.\n let je = b.m_jointList;\n while (je) {\n const je0 = je;\n je = je.next;\n\n this.publish(\"remove-joint\", je0.joint);\n this.destroyJoint(je0.joint);\n\n b.m_jointList = je;\n }\n b.m_jointList = null;\n\n // Delete the attached contacts.\n let ce = b.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n\n this.destroyContact(ce0.contact);\n\n b.m_contactList = ce;\n }\n b.m_contactList = null;\n\n // Delete the attached fixtures. This destroys broad-phase proxies.\n let f = b.m_fixtureList;\n while (f) {\n const f0 = f;\n f = f.m_next;\n\n this.publish(\"remove-fixture\", f0);\n f0.destroyProxies(this.m_broadPhase);\n\n b.m_fixtureList = f;\n }\n b.m_fixtureList = null;\n\n // Remove world body list.\n if (b.m_prev) {\n b.m_prev.m_next = b.m_next;\n }\n\n if (b.m_next) {\n b.m_next.m_prev = b.m_prev;\n }\n\n if (b == this.m_bodyList) {\n this.m_bodyList = b.m_next;\n }\n\n b.m_destroyed = true;\n\n --this.m_bodyCount;\n\n this.publish(\"remove-body\", b);\n\n return true;\n }\n\n /**\n * Create a joint to constrain bodies together. No reference to the definition\n * is retained. This may cause the connected bodies to cease colliding.\n *\n * Warning: This function is locked during callbacks.\n */\n createJoint(joint: T): T | null {\n if (_ASSERT) console.assert(!!joint.m_bodyA);\n if (_ASSERT) console.assert(!!joint.m_bodyB);\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return null;\n }\n\n // Connect to the world list.\n joint.m_prev = null;\n joint.m_next = this.m_jointList;\n if (this.m_jointList) {\n this.m_jointList.m_prev = joint;\n }\n this.m_jointList = joint;\n ++this.m_jointCount;\n\n // Connect to the bodies' doubly linked lists.\n joint.m_edgeA.joint = joint;\n joint.m_edgeA.other = joint.m_bodyB;\n joint.m_edgeA.prev = null;\n joint.m_edgeA.next = joint.m_bodyA.m_jointList;\n if (joint.m_bodyA.m_jointList)\n joint.m_bodyA.m_jointList.prev = joint.m_edgeA;\n joint.m_bodyA.m_jointList = joint.m_edgeA;\n\n joint.m_edgeB.joint = joint;\n joint.m_edgeB.other = joint.m_bodyA;\n joint.m_edgeB.prev = null;\n joint.m_edgeB.next = joint.m_bodyB.m_jointList;\n if (joint.m_bodyB.m_jointList)\n joint.m_bodyB.m_jointList.prev = joint.m_edgeB;\n joint.m_bodyB.m_jointList = joint.m_edgeB;\n\n // If the joint prevents collisions, then flag any contacts for filtering.\n if (joint.m_collideConnected == false) {\n for (let edge = joint.m_bodyB.getContactList(); edge; edge = edge.next) {\n if (edge.other == joint.m_bodyA) {\n // Flag the contact for filtering at the next time step (where either\n // body is awake).\n edge.contact.flagForFiltering();\n }\n }\n }\n\n // Note: creating a joint doesn't wake the bodies.\n\n return joint;\n }\n\n /**\n * Destroy a joint. This may cause the connected bodies to begin colliding.\n * Warning: This function is locked during callbacks.\n */\n destroyJoint(joint: Joint): void {\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return;\n }\n\n // Remove from the doubly linked list.\n if (joint.m_prev) {\n joint.m_prev.m_next = joint.m_next;\n }\n\n if (joint.m_next) {\n joint.m_next.m_prev = joint.m_prev;\n }\n\n if (joint == this.m_jointList) {\n this.m_jointList = joint.m_next;\n }\n\n // Disconnect from bodies.\n const bodyA = joint.m_bodyA;\n const bodyB = joint.m_bodyB;\n\n // Wake up connected bodies.\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n\n // Remove from body 1.\n if (joint.m_edgeA.prev) {\n joint.m_edgeA.prev.next = joint.m_edgeA.next;\n }\n\n if (joint.m_edgeA.next) {\n joint.m_edgeA.next.prev = joint.m_edgeA.prev;\n }\n\n if (joint.m_edgeA == bodyA.m_jointList) {\n bodyA.m_jointList = joint.m_edgeA.next;\n }\n\n joint.m_edgeA.prev = null;\n joint.m_edgeA.next = null;\n\n // Remove from body 2\n if (joint.m_edgeB.prev) {\n joint.m_edgeB.prev.next = joint.m_edgeB.next;\n }\n\n if (joint.m_edgeB.next) {\n joint.m_edgeB.next.prev = joint.m_edgeB.prev;\n }\n\n if (joint.m_edgeB == bodyB.m_jointList) {\n bodyB.m_jointList = joint.m_edgeB.next;\n }\n\n joint.m_edgeB.prev = null;\n joint.m_edgeB.next = null;\n\n if (_ASSERT) console.assert(this.m_jointCount > 0);\n --this.m_jointCount;\n\n // If the joint prevents collisions, then flag any contacts for filtering.\n if (joint.m_collideConnected == false) {\n let edge = bodyB.getContactList();\n while (edge) {\n if (edge.other == bodyA) {\n // Flag the contact for filtering at the next time step (where either\n // body is awake).\n edge.contact.flagForFiltering();\n }\n\n edge = edge.next;\n }\n }\n\n this.publish(\"remove-joint\", joint);\n }\n\n /** @internal */\n s_step: TimeStep; // reuse\n\n /**\n * Take a time step. This performs collision detection, integration, and\n * constraint solution.\n *\n * Broad-phase, narrow-phase, solve and solve time of impacts.\n *\n * @param timeStep Time step, this should not vary.\n */\n step(timeStep: number, velocityIterations?: number, positionIterations?: number): void {\n this.publish(\"pre-step\", timeStep);\n\n if ((velocityIterations | 0) !== velocityIterations) {\n // TODO: remove this in future\n velocityIterations = 0;\n }\n\n velocityIterations = velocityIterations || this.m_velocityIterations;\n positionIterations = positionIterations || this.m_positionIterations;\n\n // If new fixtures were added, we need to find the new contacts.\n if (this.m_newFixture) {\n this.findNewContacts();\n this.m_newFixture = false;\n }\n\n this.m_locked = true;\n\n this.s_step.reset(timeStep);\n this.s_step.velocityIterations = velocityIterations;\n this.s_step.positionIterations = positionIterations;\n this.s_step.warmStarting = this.m_warmStarting;\n this.s_step.blockSolve = this.m_blockSolve;\n\n // Update contacts. This is where some contacts are destroyed.\n this.updateContacts();\n\n // Integrate velocities, solve velocity constraints, and integrate positions.\n if (this.m_stepComplete && timeStep > 0.0) {\n this.m_solver.solveWorld(this.s_step);\n\n // Synchronize fixtures, check for out of range bodies.\n for (let b = this.m_bodyList; b; b = b.getNext()) {\n // If a body was not in an island then it did not move.\n if (b.m_islandFlag == false) {\n continue;\n }\n\n if (b.isStatic()) {\n continue;\n }\n\n // Update fixtures (for broad-phase).\n b.synchronizeFixtures();\n }\n // Look for new contacts.\n this.findNewContacts();\n }\n\n // Handle TOI events.\n if (this.m_continuousPhysics && timeStep > 0.0) {\n this.m_solver.solveWorldTOI(this.s_step);\n }\n\n if (this.m_clearForces) {\n this.clearForces();\n }\n\n this.m_locked = false;\n\n this.publish(\"post-step\", timeStep);\n }\n\n /**\n * @internal\n * Call this method to find new contacts.\n */\n findNewContacts(): void {\n this.m_broadPhase.updatePairs(\n (proxyA: FixtureProxy, proxyB: FixtureProxy) => this.createContact(proxyA, proxyB)\n );\n }\n\n /**\n * @internal\n * Callback for broad-phase.\n */\n createContact(proxyA: FixtureProxy, proxyB: FixtureProxy): void {\n const fixtureA = proxyA.fixture;\n const fixtureB = proxyB.fixture;\n\n const indexA = proxyA.childIndex;\n const indexB = proxyB.childIndex;\n\n const bodyA = fixtureA.getBody();\n const bodyB = fixtureB.getBody();\n\n // Are the fixtures on the same body?\n if (bodyA == bodyB) {\n return;\n }\n\n // TODO_ERIN use a hash table to remove a potential bottleneck when both\n // bodies have a lot of contacts.\n // Does a contact already exist?\n let edge = bodyB.getContactList(); // ContactEdge\n while (edge) {\n if (edge.other == bodyA) {\n const fA = edge.contact.getFixtureA();\n const fB = edge.contact.getFixtureB();\n const iA = edge.contact.getChildIndexA();\n const iB = edge.contact.getChildIndexB();\n\n if (fA == fixtureA && fB == fixtureB && iA == indexA && iB == indexB) {\n // A contact already exists.\n return;\n }\n\n if (fA == fixtureB && fB == fixtureA && iA == indexB && iB == indexA) {\n // A contact already exists.\n return;\n }\n }\n\n edge = edge.next;\n }\n\n if (bodyB.shouldCollide(bodyA) == false) {\n return;\n }\n if (fixtureB.shouldCollide(fixtureA) == false) {\n return;\n }\n\n // Call the factory.\n const contact = Contact.create(fixtureA, indexA, fixtureB, indexB);\n if (contact == null) {\n return;\n }\n\n // Insert into the world.\n contact.m_prev = null;\n if (this.m_contactList != null) {\n contact.m_next = this.m_contactList;\n this.m_contactList.m_prev = contact;\n }\n this.m_contactList = contact;\n\n ++this.m_contactCount;\n }\n\n /**\n * @internal\n * Removes old non-overlapping contacts, applies filters and updates contacts.\n */\n updateContacts(): void {\n // Update awake contacts.\n let c: Contact;\n let next_c = this.m_contactList;\n while (c = next_c) {\n next_c = c.getNext();\n const fixtureA = c.getFixtureA();\n const fixtureB = c.getFixtureB();\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n const bodyA = fixtureA.getBody();\n const bodyB = fixtureB.getBody();\n\n // Is this contact flagged for filtering?\n if (c.m_filterFlag) {\n if (bodyB.shouldCollide(bodyA) == false) {\n this.destroyContact(c);\n continue;\n }\n\n if (fixtureB.shouldCollide(fixtureA) == false) {\n this.destroyContact(c);\n continue;\n }\n\n // Clear the filtering flag.\n c.m_filterFlag = false;\n }\n\n const activeA = bodyA.isAwake() && !bodyA.isStatic();\n const activeB = bodyB.isAwake() && !bodyB.isStatic();\n\n // At least one body must be awake and it must be dynamic or kinematic.\n if (activeA == false && activeB == false) {\n continue;\n }\n\n const proxyIdA = fixtureA.m_proxies[indexA].proxyId;\n const proxyIdB = fixtureB.m_proxies[indexB].proxyId;\n const overlap = this.m_broadPhase.testOverlap(proxyIdA, proxyIdB);\n\n // Here we destroy contacts that cease to overlap in the broad-phase.\n if (overlap == false) {\n this.destroyContact(c);\n continue;\n }\n\n // The contact persists.\n c.update(this);\n }\n }\n\n /** @internal */\n destroyContact(contact: Contact): void {\n // Remove from the world.\n if (contact.m_prev) {\n contact.m_prev.m_next = contact.m_next;\n }\n if (contact.m_next) {\n contact.m_next.m_prev = contact.m_prev;\n }\n if (contact == this.m_contactList) {\n this.m_contactList = contact.m_next;\n }\n\n Contact.destroy(contact, this);\n\n --this.m_contactCount;\n }\n\n\n /**\n * Called when two fixtures begin to touch.\n *\n * Implement contact callbacks to get contact information. You can use these\n * results for things like sounds and game logic. You can also get contact\n * results by traversing the contact lists after the time step. However, you\n * might miss some contacts because continuous physics leads to sub-stepping.\n * Additionally you may receive multiple callbacks for the same contact in a\n * single time step. You should strive to make your callbacks efficient because\n * there may be many callbacks per time step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"begin-contact\", listener: (contact: Contact) => void): World;\n /**\n * Called when two fixtures cease to touch.\n *\n * Implement contact callbacks to get contact information. You can use these\n * results for things like sounds and game logic. You can also get contact\n * results by traversing the contact lists after the time step. However, you\n * might miss some contacts because continuous physics leads to sub-stepping.\n * Additionally you may receive multiple callbacks for the same contact in a\n * single time step. You should strive to make your callbacks efficient because\n * there may be many callbacks per time step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"end-contact\", listener: (contact: Contact) => void): World;\n /**\n * This is called after a contact is updated. This allows you to inspect a\n * contact before it goes to the solver. If you are careful, you can modify the\n * contact manifold (e.g. disable contact). A copy of the old manifold is\n * provided so that you can detect changes. Note: this is called only for awake\n * bodies. Note: this is called even when the number of contact points is zero.\n * Note: this is not called for sensors. Note: if you set the number of contact\n * points to zero, you will not get an end-contact callback. However, you may get\n * a begin-contact callback the next step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"pre-solve\", listener: (contact: Contact, oldManifold: Manifold) => void): World;\n /**\n * This lets you inspect a contact after the solver is finished. This is useful\n * for inspecting impulses. Note: the contact manifold does not include time of\n * impact impulses, which can be arbitrarily large if the sub-step is small.\n * Hence the impulse is provided explicitly in a separate data structure. Note:\n * this is only called for contacts that are touching, solid, and awake.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"post-solve\", listener: (contact: Contact, impulse: ContactImpulse) => void): World;\n /** Listener is called whenever a body is removed. */\n on(name: \"remove-body\", listener: (body: Body) => void): World;\n /** Listener is called whenever a joint is removed implicitly or explicitly. */\n on(name: \"remove-joint\", listener: (joint: Joint) => void): World;\n /** Listener is called whenever a fixture is removed implicitly or explicitly. */\n on(name: \"remove-fixture\", listener: (fixture: Fixture) => void): World;\n /**\n * Register an event listener.\n */\n // tslint:disable-next-line:typedef\n on(name, listener) {\n if (typeof name !== \"string\" || typeof listener !== \"function\") {\n return this;\n }\n if (!this._listeners) {\n this._listeners = {};\n }\n if (!this._listeners[name]) {\n this._listeners[name] = [];\n }\n this._listeners[name].push(listener);\n return this;\n }\n\n off(name: \"begin-contact\", listener: (contact: Contact) => void): World;\n off(name: \"end-contact\", listener: (contact: Contact) => void): World;\n off(name: \"pre-solve\", listener: (contact: Contact, oldManifold: Manifold) => void): World;\n off(name: \"post-solve\", listener: (contact: Contact, impulse: ContactImpulse) => void): World;\n off(name: \"remove-body\", listener: (body: Body) => void): World;\n off(name: \"remove-joint\", listener: (joint: Joint) => void): World;\n off(name: \"remove-fixture\", listener: (fixture: Fixture) => void): World;\n /**\n * Remove an event listener.\n */\n // tslint:disable-next-line:typedef\n off(name, listener) {\n if (typeof name !== \"string\" || typeof listener !== \"function\") {\n return this;\n }\n const listeners = this._listeners && this._listeners[name];\n if (!listeners || !listeners.length) {\n return this;\n }\n const index = listeners.indexOf(listener);\n if (index >= 0) {\n listeners.splice(index, 1);\n }\n return this;\n }\n\n publish(name: string, arg1?: any, arg2?: any, arg3?: any): number {\n const listeners = this._listeners && this._listeners[name];\n if (!listeners || !listeners.length) {\n return 0;\n }\n for (let l = 0; l < listeners.length; l++) {\n listeners[l].call(this, arg1, arg2, arg3);\n }\n return listeners.length;\n }\n\n /** @internal */\n beginContact(contact: Contact): void {\n this.publish(\"begin-contact\", contact);\n }\n\n /** @internal */\n endContact(contact: Contact): void {\n this.publish(\"end-contact\", contact);\n }\n\n /** @internal */\n preSolve(contact: Contact, oldManifold: Manifold): void {\n this.publish(\"pre-solve\", contact, oldManifold);\n }\n\n /** @internal */\n postSolve(contact: Contact, impulse: ContactImpulse): void {\n this.publish(\"post-solve\", contact, impulse);\n }\n\n /**\n * Joints and fixtures are destroyed when their associated body is destroyed.\n * Register a destruction listener so that you may nullify references to these\n * joints and shapes.\n *\n * `function(object)` is called when any joint or fixture is about to\n * be destroyed due to the destruction of one of its attached or parent bodies.\n */\n\n /**\n * Register a contact filter to provide specific control over collision.\n * Otherwise the default filter is used (defaultFilter). The listener is owned\n * by you and must remain in scope.\n *\n * Moved to Fixture.\n */\n}","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/** 3D vector */\nexport interface Vec3Value {\n x: number;\n y: number;\n z: number;\n}\n\ndeclare module \"./Vec3\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(x: number, y: number, z: number): Vec3;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(obj: Vec3Value): Vec3;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(): Vec3;\n}\n\n/** 3D vector */\n// @ts-expect-error\nexport class Vec3 {\n x: number;\n y: number;\n z: number;\n\n constructor(x: number, y: number, z: number);\n constructor(obj: Vec3Value);\n constructor();\n constructor(x?, y?, z?) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Vec3)) {\n return new Vec3(x, y, z);\n }\n if (typeof x === \"undefined\") {\n this.x = 0;\n this.y = 0;\n this.z = 0;\n } else if (typeof x === \"object\") {\n this.x = x.x;\n this.y = x.y;\n this.z = x.z;\n } else {\n this.x = x;\n this.y = y;\n this.z = z;\n }\n if (_ASSERT) Vec3.assert(this);\n }\n\n /** @internal */\n _serialize(): object {\n return {\n x: this.x,\n y: this.y,\n z: this.z\n };\n }\n\n /** @internal */\n static _deserialize(data: any): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = data.x;\n obj.y = data.y;\n obj.z = data.z;\n return obj;\n }\n\n /** @hidden */\n static neo(x: number, y: number, z: number): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = x;\n obj.y = y;\n obj.z = z;\n return obj;\n }\n\n static zero(): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = 0;\n obj.y = 0;\n obj.z = 0;\n return obj;\n }\n\n static clone(v: Vec3Value): Vec3 {\n if (_ASSERT) Vec3.assert(v);\n return Vec3.neo(v.x, v.y, v.z);\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n /** Does this vector contain finite coordinates? */\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.x) && Number.isFinite(obj.y) && Number.isFinite(obj.z);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Vec3.isValid(o), \"Invalid Vec3!\", o);\n }\n\n setZero(): Vec3 {\n this.x = 0.0;\n this.y = 0.0;\n this.z = 0.0;\n return this;\n }\n\n set(x: number, y: number, z: number): Vec3 {\n this.x = x;\n this.y = y;\n this.z = z;\n return this;\n }\n\n add(w: Vec3Value): Vec3 {\n this.x += w.x;\n this.y += w.y;\n this.z += w.z;\n return this;\n }\n\n sub(w: Vec3Value): Vec3 {\n this.x -= w.x;\n this.y -= w.y;\n this.z -= w.z;\n return this;\n }\n\n mul(m: number): Vec3 {\n this.x *= m;\n this.y *= m;\n this.z *= m;\n return this;\n }\n\n static areEqual(v: Vec3Value, w: Vec3Value): boolean {\n if (_ASSERT) Vec3.assert(v);\n if (_ASSERT) Vec3.assert(w);\n return v === w ||\n typeof v === \"object\" && v !== null &&\n typeof w === \"object\" && w !== null &&\n v.x === w.x && v.y === w.y && v.z === w.z;\n }\n\n /** Dot product on two vectors */\n static dot(v: Vec3Value, w: Vec3Value): number {\n return v.x * w.x + v.y * w.y + v.z * w.z;\n }\n\n /** Cross product on two vectors */\n static cross(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(\n v.y * w.z - v.z * w.y,\n v.z * w.x - v.x * w.z,\n v.x * w.y - v.y * w.x\n );\n }\n\n static add(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(v.x + w.x, v.y + w.y, v.z + w.z);\n }\n\n static sub(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(v.x - w.x, v.y - w.y, v.z - w.z);\n }\n\n static mul(v: Vec3Value, m: number): Vec3 {\n return new Vec3(m * v.x, m * v.y, m * v.z);\n }\n\n neg(): Vec3 {\n this.x = -this.x;\n this.y = -this.y;\n this.z = -this.z;\n return this;\n }\n\n static neg(v: Vec3Value): Vec3 {\n return new Vec3(-v.x, -v.y, -v.z);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport * as matrix from \"../../common/Matrix\";\nimport { Shape } from \"../Shape\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { AABB, AABBValue, RayCastInput, RayCastOutput } from \"../AABB\";\nimport { MassData } from \"../../dynamics/Body\";\nimport { DistanceProxy } from \"../Distance\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const v2 = matrix.vec2(0, 0);\n\ndeclare module \"./EdgeShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function EdgeShape(v1?: Vec2Value, v2?: Vec2Value): EdgeShape;\n}\n\n/**\n * A line segment (edge) shape. These can be connected in chains or loops to\n * other edge shapes. The connectivity information is used to ensure correct\n * contact normals.\n */\n// @ts-expect-error\nexport class EdgeShape extends Shape {\n static TYPE = \"edge\" as const;\n /** @hidden */ m_type: \"edge\";\n\n /** @hidden */ m_radius: number;\n\n // These are the edge vertices\n /** @hidden */ m_vertex1: Vec2;\n /** @hidden */ m_vertex2: Vec2;\n\n // Optional adjacent vertices. These are used for smooth collision.\n // Used by chain shape.\n /** @hidden */ m_vertex0: Vec2;\n /** @hidden */ m_vertex3: Vec2;\n /** @hidden */ m_hasVertex0: boolean;\n /** @hidden */ m_hasVertex3: boolean;\n\n constructor(v1?: Vec2Value, v2?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof EdgeShape)) {\n return new EdgeShape(v1, v2);\n }\n\n super();\n\n this.m_type = EdgeShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n\n this.m_vertex1 = v1 ? Vec2.clone(v1) : Vec2.zero();\n this.m_vertex2 = v2 ? Vec2.clone(v2) : Vec2.zero();\n\n this.m_vertex0 = Vec2.zero();\n this.m_vertex3 = Vec2.zero();\n this.m_hasVertex0 = false;\n this.m_hasVertex3 = false;\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n vertex1: this.m_vertex1,\n vertex2: this.m_vertex2,\n\n vertex0: this.m_vertex0,\n vertex3: this.m_vertex3,\n hasVertex0: this.m_hasVertex0,\n hasVertex3: this.m_hasVertex3,\n };\n }\n\n /** @internal */\n static _deserialize(data: any): EdgeShape {\n const shape = new EdgeShape(data.vertex1, data.vertex2);\n if (shape.m_hasVertex0) {\n shape.setPrevVertex(data.vertex0);\n }\n if (shape.m_hasVertex3) {\n shape.setNextVertex(data.vertex3);\n }\n return shape;\n }\n\n /** @hidden */\n _reset(): void {\n // noop\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n getType(): \"edge\" {\n return this.m_type;\n }\n\n /** @internal @deprecated */\n setNext(v?: Vec2Value): EdgeShape {\n return this.setNextVertex(v);\n }\n\n /**\n * Optional next vertex, used for smooth collision.\n */\n setNextVertex(v?: Vec2Value): EdgeShape {\n if (v) {\n this.m_vertex3.setVec2(v);\n this.m_hasVertex3 = true;\n } else {\n this.m_vertex3.setZero();\n this.m_hasVertex3 = false;\n }\n return this;\n }\n\n /**\n * Optional next vertex, used for smooth collision.\n */\n getNextVertex(): Vec2 {\n return this.m_vertex3;\n }\n\n /** @internal @deprecated */\n setPrev(v?: Vec2Value): EdgeShape {\n return this.setPrevVertex(v);\n }\n\n /**\n * Optional prev vertex, used for smooth collision.\n */\n setPrevVertex(v?: Vec2Value): EdgeShape {\n if (v) {\n this.m_vertex0.setVec2(v);\n this.m_hasVertex0 = true;\n } else {\n this.m_vertex0.setZero();\n this.m_hasVertex0 = false;\n }\n return this;\n }\n\n /**\n * Optional prev vertex, used for smooth collision.\n */\n getPrevVertex(): Vec2 {\n return this.m_vertex0;\n }\n\n /**\n * Set this as an isolated edge.\n */\n _set(v1: Vec2Value, v2: Vec2Value): EdgeShape {\n this.m_vertex1.setVec2(v1);\n this.m_vertex2.setVec2(v2);\n this.m_hasVertex0 = false;\n this.m_hasVertex3 = false;\n return this;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): EdgeShape {\n const clone = new EdgeShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_vertex1.setVec2(this.m_vertex1);\n clone.m_vertex2.setVec2(this.m_vertex2);\n clone.m_vertex0.setVec2(this.m_vertex0);\n clone.m_vertex3.setVec2(this.m_vertex3);\n clone.m_hasVertex0 = this.m_hasVertex0;\n clone.m_hasVertex3 = this.m_hasVertex3;\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): false {\n return false;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n // p = p1 + t * d\n // v = v1 + s * e\n // p1 + t * d = v1 + s * e\n // s * e - t * d = p1 - v1\n\n // NOT_USED(childIndex);\n\n // Put the ray into the edge's frame of reference.\n const p1 = Rot.mulTVec2(xf.q, Vec2.sub(input.p1, xf.p));\n const p2 = Rot.mulTVec2(xf.q, Vec2.sub(input.p2, xf.p));\n const d = Vec2.sub(p2, p1);\n\n const v1 = this.m_vertex1;\n const v2 = this.m_vertex2;\n const e = Vec2.sub(v2, v1);\n const normal = Vec2.neo(e.y, -e.x);\n normal.normalize();\n\n // q = p1 + t * d\n // dot(normal, q - v1) = 0\n // dot(normal, p1 - v1) + t * dot(normal, d) = 0\n const numerator = Vec2.dot(normal, Vec2.sub(v1, p1));\n const denominator = Vec2.dot(normal, d);\n\n if (denominator == 0.0) {\n return false;\n }\n\n const t = numerator / denominator;\n if (t < 0.0 || input.maxFraction < t) {\n return false;\n }\n\n const q = Vec2.add(p1, Vec2.mulNumVec2(t, d));\n\n // q = v1 + s * r\n // s = dot(q - v1, r) / dot(r, r)\n const r = Vec2.sub(v2, v1);\n const rr = Vec2.dot(r, r);\n if (rr == 0.0) {\n return false;\n }\n\n const s = Vec2.dot(Vec2.sub(q, v1), r) / rr;\n if (s < 0.0 || 1.0 < s) {\n return false;\n }\n\n output.fraction = t;\n if (numerator > 0.0) {\n output.normal = Rot.mulVec2(xf.q, normal).neg();\n } else {\n output.normal = Rot.mulVec2(xf.q, normal);\n }\n return true;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n matrix.transformVec2(v1, xf, this.m_vertex1);\n matrix.transformVec2(v2, xf, this.m_vertex2);\n\n AABB.combinePoints(aabb, v1, v2);\n AABB.extend(aabb, this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density?: number): void {\n massData.mass = 0.0;\n matrix.combine2Vec2(massData.center, 0.5, this.m_vertex1, 0.5, this.m_vertex2);\n massData.I = 0.0;\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n proxy.m_vertices[0] = this.m_vertex1;\n proxy.m_vertices[1] = this.m_vertex2;\n proxy.m_vertices.length = 2;\n proxy.m_count = 2;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Edge = EdgeShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport type { MassData } from \"../../dynamics/Body\";\nimport { AABBValue, RayCastOutput, RayCastInput, AABB } from \"../AABB\";\nimport { DistanceProxy } from \"../Distance\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Shape } from \"../Shape\";\nimport { EdgeShape } from \"./EdgeShape\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const v2 = matrix.vec2(0, 0);\n\ndeclare module \"./ChainShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function ChainShape(vertices?: Vec2Value[], loop?: boolean): ChainShape;\n}\n\n/**\n * A chain shape is a free form sequence of line segments. The chain has\n * two-sided collision, so you can use inside and outside collision. Therefore,\n * you may use any winding order. Connectivity information is used to create\n * smooth collisions.\n *\n * WARNING: The chain will not collide properly if there are self-intersections.\n */\n// @ts-expect-error\nexport class ChainShape extends Shape {\n static TYPE = \"chain\" as const;\n /** @hidden */ m_type: \"chain\";\n\n /** @hidden */ m_radius: number;\n\n /** @hidden */ m_vertices: Vec2[];\n /** @hidden */ m_count: number;\n /** @hidden */ m_prevVertex: Vec2 | null;\n /** @hidden */ m_nextVertex: Vec2 | null;\n /** @hidden */ m_hasPrevVertex: boolean;\n /** @hidden */ m_hasNextVertex: boolean;\n\n /** @hidden */ m_isLoop: boolean;\n\n constructor(vertices?: Vec2Value[], loop?: boolean) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof ChainShape)) {\n return new ChainShape(vertices, loop);\n }\n\n super();\n\n this.m_type = ChainShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n this.m_vertices = [];\n this.m_count = 0;\n this.m_prevVertex = null;\n this.m_nextVertex = null;\n this.m_hasPrevVertex = false;\n this.m_hasNextVertex = false;\n\n this.m_isLoop = !!loop;\n\n if (vertices && vertices.length) {\n if (loop) {\n this._createLoop(vertices);\n } else {\n this._createChain(vertices);\n }\n }\n }\n\n /** @internal */\n _serialize(): object {\n const data = {\n type: this.m_type,\n vertices: this.m_isLoop ? this.m_vertices.slice(0, this.m_vertices.length - 1) : this.m_vertices,\n isLoop: this.m_isLoop,\n hasPrevVertex: this.m_hasPrevVertex,\n hasNextVertex: this.m_hasNextVertex,\n prevVertex: null as Vec2 | null,\n nextVertex: null as Vec2 | null,\n };\n if (this.m_prevVertex) {\n data.prevVertex = this.m_prevVertex;\n }\n if (this.m_nextVertex) {\n data.nextVertex = this.m_nextVertex;\n }\n return data;\n }\n\n /** @internal */\n static _deserialize(data: any, fixture: any, restore: any): ChainShape {\n const vertices: Vec2[] = [];\n if (data.vertices) {\n for (let i = 0; i < data.vertices.length; i++) {\n vertices.push(restore(Vec2, data.vertices[i]));\n }\n }\n const shape = new ChainShape(vertices, data.isLoop);\n if (data.prevVertex) {\n shape.setPrevVertex(data.prevVertex);\n }\n if (data.nextVertex) {\n shape.setNextVertex(data.nextVertex);\n }\n return shape;\n }\n\n // clear() {\n // this.m_vertices.length = 0;\n // this.m_count = 0;\n // }\n\n getType(): \"chain\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n /**\n * @internal\n * Create a loop. This automatically adjusts connectivity.\n *\n * @param vertices an array of vertices, these are copied\n */\n _createLoop(vertices: Vec2Value[]): ChainShape {\n if (_ASSERT) console.assert(this.m_vertices.length == 0 && this.m_count == 0);\n if (_ASSERT) console.assert(vertices.length >= 3);\n if (vertices.length < 3) {\n return;\n }\n\n for (let i = 1; i < vertices.length; ++i) {\n const v1 = vertices[i - 1];\n const v2 = vertices[i];\n // If the code crashes here, it means your vertices are too close together.\n if (_ASSERT) console.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);\n }\n\n this.m_vertices = [];\n this.m_count = vertices.length + 1;\n for (let i = 0; i < vertices.length; ++i) {\n this.m_vertices[i] = Vec2.clone(vertices[i]);\n }\n this.m_vertices[vertices.length] = Vec2.clone(vertices[0]);\n\n this.m_prevVertex = this.m_vertices[this.m_count - 2];\n this.m_nextVertex = this.m_vertices[1];\n this.m_hasPrevVertex = true;\n this.m_hasNextVertex = true;\n return this;\n }\n\n /**\n * @internal\n * Create a chain with isolated end vertices.\n *\n * @param vertices an array of vertices, these are copied\n */\n _createChain(vertices: Vec2Value[]): ChainShape {\n if (_ASSERT) console.assert(this.m_vertices.length == 0 && this.m_count == 0);\n if (_ASSERT) console.assert(vertices.length >= 2);\n for (let i = 1; i < vertices.length; ++i) {\n const v1 = vertices[i - 1];\n const v2 = vertices[i];\n // If the code crashes here, it means your vertices are too close together.\n if (_ASSERT) console.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);\n }\n\n this.m_vertices = [];\n this.m_count = vertices.length;\n for (let i = 0; i < vertices.length; ++i) {\n this.m_vertices[i] = Vec2.clone(vertices[i]);\n }\n\n this.m_prevVertex = null;\n this.m_nextVertex = null;\n this.m_hasPrevVertex = false;\n this.m_hasNextVertex = false;\n return this;\n }\n\n /** @hidden */\n _reset(): void {\n if (this.m_isLoop) {\n this._createLoop(this.m_vertices.slice(0, this.m_vertices.length - 1));\n } else {\n this._createChain(this.m_vertices);\n }\n }\n\n /**\n * Establish connectivity to a vertex that precedes the first vertex. Don't call\n * this for loops.\n */\n setPrevVertex(prevVertex: Vec2): void {\n // todo: copy or reference\n this.m_prevVertex = prevVertex;\n this.m_hasPrevVertex = true;\n }\n\n getPrevVertex(): Vec2 {\n return this.m_prevVertex;\n }\n\n /**\n * Establish connectivity to a vertex that follows the last vertex. Don't call\n * this for loops.\n */\n setNextVertex(nextVertex: Vec2): void {\n // todo: copy or reference\n this.m_nextVertex = nextVertex;\n this.m_hasNextVertex = true;\n }\n\n getNextVertex(): Vec2 {\n return this.m_nextVertex;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): ChainShape {\n const clone = new ChainShape();\n clone._createChain(this.m_vertices);\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_prevVertex = this.m_prevVertex;\n clone.m_nextVertex = this.m_nextVertex;\n clone.m_hasPrevVertex = this.m_hasPrevVertex;\n clone.m_hasNextVertex = this.m_hasNextVertex;\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): number {\n // edge count = vertex count - 1\n return this.m_count - 1;\n }\n\n // Get a child edge.\n getChildEdge(edge: EdgeShape, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count - 1);\n edge.m_type = EdgeShape.TYPE;\n edge.m_radius = this.m_radius;\n\n edge.m_vertex1 = this.m_vertices[childIndex];\n edge.m_vertex2 = this.m_vertices[childIndex + 1];\n\n if (childIndex > 0) {\n edge.m_vertex0 = this.m_vertices[childIndex - 1];\n edge.m_hasVertex0 = true;\n } else {\n edge.m_vertex0 = this.m_prevVertex;\n edge.m_hasVertex0 = this.m_hasPrevVertex;\n }\n\n if (childIndex < this.m_count - 2) {\n edge.m_vertex3 = this.m_vertices[childIndex + 2];\n edge.m_hasVertex3 = true;\n } else {\n edge.m_vertex3 = this.m_nextVertex;\n edge.m_hasVertex3 = this.m_hasNextVertex;\n }\n }\n\n getVertex(index: number): Vec2 {\n if (_ASSERT) console.assert(0 <= index && index <= this.m_count);\n if (index < this.m_count) {\n return this.m_vertices[index];\n } else {\n return this.m_vertices[0];\n }\n }\n\n isLoop(): boolean {\n return this.m_isLoop;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * This always return false.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): false {\n return false;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n\n const edgeShape = new EdgeShape(this.getVertex(childIndex), this.getVertex(childIndex + 1));\n return edgeShape.rayCast(output, input, xf, 0);\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n\n matrix.transformVec2(v1, xf, this.getVertex(childIndex));\n matrix.transformVec2(v2, xf, this.getVertex(childIndex + 1));\n\n AABB.combinePoints(aabb, v1, v2);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * Chains have zero mass.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density?: number): void {\n massData.mass = 0.0;\n matrix.zeroVec2(massData.center);\n massData.I = 0.0;\n }\n\n computeDistanceProxy(proxy: DistanceProxy, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n proxy.m_vertices[0] = this.getVertex(childIndex);\n proxy.m_vertices[1] = this.getVertex(childIndex + 1);\n proxy.m_count = 2;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Chain = ChainShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport type { MassData } from \"../../dynamics/Body\";\nimport { RayCastOutput, RayCastInput, AABBValue } from \"../AABB\";\nimport { DistanceProxy } from \"../Distance\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Shape } from \"../Shape\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const e = matrix.vec2(0, 0);\n/** @internal */ const e1 = matrix.vec2(0, 0);\n/** @internal */ const e2 = matrix.vec2(0, 0);\n/** @internal */ const center = matrix.vec2(0, 0);\n/** @internal */ const s = matrix.vec2(0, 0);\n\ndeclare module \"./PolygonShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PolygonShape(vertices?: Vec2Value[]): PolygonShape;\n}\n\n/**\n * A convex polygon. It is assumed that the interior of the polygon is to the\n * left of each edge. Polygons have a maximum number of vertices equal to\n * Settings.maxPolygonVertices. In most cases you should not need many vertices\n * for a convex polygon. extends Shape\n */\n// @ts-expect-error\nexport class PolygonShape extends Shape {\n static TYPE = \"polygon\" as const;\n /** @hidden */ m_type: \"polygon\";\n\n /** @hidden */ m_centroid: Vec2;\n /** @hidden */ m_vertices: Vec2[]; // [Settings.maxPolygonVertices]\n /** @hidden */ m_normals: Vec2[]; // [Settings.maxPolygonVertices]\n /** @hidden */ m_count: number;\n /** @hidden */ m_radius: number;\n\n constructor(vertices?: Vec2Value[]) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PolygonShape)) {\n return new PolygonShape(vertices);\n }\n\n super();\n\n this.m_type = PolygonShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n this.m_centroid = Vec2.zero();\n this.m_vertices = [];\n this.m_normals = [];\n this.m_count = 0;\n\n if (vertices && vertices.length) {\n this._set(vertices);\n }\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n vertices: this.m_vertices,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, fixture: any, restore: any): PolygonShape {\n const vertices: Vec2[] = [];\n if (data.vertices) {\n for (let i = 0; i < data.vertices.length; i++) {\n vertices.push(restore(Vec2, data.vertices[i]));\n }\n }\n\n const shape = new PolygonShape(vertices);\n return shape;\n }\n\n getType(): \"polygon\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): PolygonShape {\n const clone = new PolygonShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_count = this.m_count;\n clone.m_centroid.setVec2(this.m_centroid);\n for (let i = 0; i < this.m_count; i++) {\n clone.m_vertices.push(this.m_vertices[i].clone());\n }\n for (let i = 0; i < this.m_normals.length; i++) {\n clone.m_normals.push(this.m_normals[i].clone());\n }\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /** @hidden */\n _reset(): void {\n this._set(this.m_vertices);\n }\n\n /**\n * @internal\n *\n * Create a convex hull from the given array of local points. The count must be\n * in the range [3, Settings.maxPolygonVertices].\n *\n * Warning: the points may be re-ordered, even if they form a convex polygon\n * Warning: collinear points are handled but not removed. Collinear points may\n * lead to poor stacking behavior.\n */\n _set(vertices: Vec2Value[]): void {\n if (_ASSERT) console.assert(3 <= vertices.length && vertices.length <= Settings.maxPolygonVertices);\n if (vertices.length < 3) {\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n let n = math_min(vertices.length, Settings.maxPolygonVertices);\n\n // Perform welding and copy vertices into local buffer.\n const ps: Vec2[] = []; // [Settings.maxPolygonVertices];\n for (let i = 0; i < n; ++i) {\n const v = vertices[i];\n\n let unique = true;\n for (let j = 0; j < ps.length; ++j) {\n if (Vec2.distanceSquared(v, ps[j]) < 0.25 * Settings.linearSlopSquared) {\n unique = false;\n break;\n }\n }\n\n if (unique) {\n ps.push(Vec2.clone(v));\n }\n }\n\n n = ps.length;\n if (n < 3) {\n // Polygon is degenerate.\n if (_ASSERT) console.assert(false);\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n // Create the convex hull using the Gift wrapping algorithm\n // http://en.wikipedia.org/wiki/Gift_wrapping_algorithm\n\n // Find the right most point on the hull (in case of multiple points bottom most is used)\n let i0 = 0;\n let x0 = ps[0].x;\n for (let i = 1; i < n; ++i) {\n const x = ps[i].x;\n if (x > x0 || (x === x0 && ps[i].y < ps[i0].y)) {\n i0 = i;\n x0 = x;\n }\n }\n\n const hull = [] as number[]; // [Settings.maxPolygonVertices];\n let m = 0;\n let ih = i0;\n\n while (true) {\n if (_ASSERT) console.assert(m < Settings.maxPolygonVertices);\n hull[m] = ih;\n\n let ie = 0;\n for (let j = 1; j < n; ++j) {\n if (ie === ih) {\n ie = j;\n continue;\n }\n\n const r = Vec2.sub(ps[ie], ps[hull[m]]);\n const v = Vec2.sub(ps[j], ps[hull[m]]);\n const c = Vec2.crossVec2Vec2(r, v);\n // c < 0 means counter-clockwise wrapping, c > 0 means clockwise wrapping\n if (c < 0.0) {\n ie = j;\n }\n\n // Collinearity check\n if (c === 0.0 && v.lengthSquared() > r.lengthSquared()) {\n ie = j;\n }\n }\n\n ++m;\n ih = ie;\n\n if (ie === i0) {\n break;\n }\n }\n\n if (m < 3) {\n // Polygon is degenerate.\n if (_ASSERT) console.assert(false);\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n this.m_count = m;\n\n // Copy vertices.\n this.m_vertices = [];\n for (let i = 0; i < m; ++i) {\n this.m_vertices[i] = ps[hull[i]];\n }\n\n // Compute normals. Ensure the edges have non-zero length.\n for (let i = 0; i < m; ++i) {\n const i1 = i;\n const i2 = i + 1 < m ? i + 1 : 0;\n const edge = Vec2.sub(this.m_vertices[i2], this.m_vertices[i1]);\n if (_ASSERT) console.assert(edge.lengthSquared() > EPSILON * EPSILON);\n this.m_normals[i] = Vec2.crossVec2Num(edge, 1.0);\n this.m_normals[i].normalize();\n }\n\n // Compute the polygon centroid.\n this.m_centroid = computeCentroid(this.m_vertices, m);\n }\n\n /** @internal */ _setAsBox(hx: number, hy: number, center?: Vec2Value, angle?: number): void {\n // start with right-bottom, counter-clockwise, as in Gift wrapping algorithm in PolygonShape._set()\n this.m_vertices[0] = Vec2.neo(hx, -hy);\n this.m_vertices[1] = Vec2.neo(hx, hy);\n this.m_vertices[2] = Vec2.neo(-hx, hy);\n this.m_vertices[3] = Vec2.neo(-hx, -hy);\n\n this.m_normals[0] = Vec2.neo(1.0, 0.0);\n this.m_normals[1] = Vec2.neo(0.0, 1.0);\n this.m_normals[2] = Vec2.neo(-1.0, 0.0);\n this.m_normals[3] = Vec2.neo(0.0, -1.0);\n\n this.m_count = 4;\n\n if (center && Vec2.isValid(center)) {\n angle = angle || 0;\n\n matrix.copyVec2(this.m_centroid, center);\n\n const xf = Transform.identity();\n xf.p.setVec2(center);\n xf.q.setAngle(angle);\n\n // Transform vertices and normals.\n for (let i = 0; i < this.m_count; ++i) {\n this.m_vertices[i] = Transform.mulVec2(xf, this.m_vertices[i]);\n this.m_normals[i] = Rot.mulVec2(xf.q, this.m_normals[i]);\n }\n }\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): boolean {\n const pLocal = matrix.detransformVec2(temp, xf, p);\n\n for (let i = 0; i < this.m_count; ++i) {\n const dot = matrix.dotVec2(this.m_normals[i], pLocal) - matrix.dotVec2(this.m_normals[i], this.m_vertices[i]);\n if (dot > 0.0) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n\n // Put the ray into the polygon's frame of reference.\n const p1 = Rot.mulTVec2(xf.q, Vec2.sub(input.p1, xf.p));\n const p2 = Rot.mulTVec2(xf.q, Vec2.sub(input.p2, xf.p));\n const d = Vec2.sub(p2, p1);\n\n let lower = 0.0;\n let upper = input.maxFraction;\n\n let index = -1;\n\n for (let i = 0; i < this.m_count; ++i) {\n // p = p1 + a * d\n // dot(normal, p - v) = 0\n // dot(normal, p1 - v) + a * dot(normal, d) = 0\n const numerator = Vec2.dot(this.m_normals[i], Vec2.sub(this.m_vertices[i], p1));\n const denominator = Vec2.dot(this.m_normals[i], d);\n\n if (denominator == 0.0) {\n if (numerator < 0.0) {\n return false;\n }\n } else {\n // Note: we want this predicate without division:\n // lower < numerator / denominator, where denominator < 0\n // Since denominator < 0, we have to flip the inequality:\n // lower < numerator / denominator <==> denominator * lower > numerator.\n if (denominator < 0.0 && numerator < lower * denominator) {\n // Increase lower.\n // The segment enters this half-space.\n lower = numerator / denominator;\n index = i;\n } else if (denominator > 0.0 && numerator < upper * denominator) {\n // Decrease upper.\n // The segment exits this half-space.\n upper = numerator / denominator;\n }\n }\n\n // The use of epsilon here causes the assert on lower to trip\n // in some cases. Apparently the use of epsilon was to make edge\n // shapes work, but now those are handled separately.\n // if (upper < lower - matrix.EPSILON)\n if (upper < lower) {\n return false;\n }\n }\n\n if (_ASSERT) console.assert(0.0 <= lower && lower <= input.maxFraction);\n\n if (index >= 0) {\n output.fraction = lower;\n output.normal = Rot.mulVec2(xf.q, this.m_normals[index]);\n return true;\n }\n\n return false;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (let i = 0; i < this.m_count; ++i) {\n const v = matrix.transformVec2(temp, xf, this.m_vertices[i]);\n minX = math_min(minX, v.x);\n maxX = math_max(maxX, v.x);\n minY = math_min(minY, v.y);\n maxY = math_max(maxY, v.y);\n }\n\n matrix.setVec2(aabb.lowerBound, minX - this.m_radius, minY - this.m_radius);\n matrix.setVec2(aabb.upperBound, maxX + this.m_radius, maxY + this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density: number): void {\n // Polygon mass, centroid, and inertia.\n // Let rho be the polygon density in mass per unit area.\n // Then:\n // mass = rho * int(dA)\n // centroid.x = (1/mass) * rho * int(x * dA)\n // centroid.y = (1/mass) * rho * int(y * dA)\n // I = rho * int((x*x + y*y) * dA)\n //\n // We can compute these integrals by summing all the integrals\n // for each triangle of the polygon. To evaluate the integral\n // for a single triangle, we make a change of variables to\n // the (u,v) coordinates of the triangle:\n // x = x0 + e1x * u + e2x * v\n // y = y0 + e1y * u + e2y * v\n // where 0 <= u && 0 <= v && u + v <= 1.\n //\n // We integrate u from [0,1-v] and then v from [0,1].\n // We also need to use the Jacobian of the transformation:\n // D = cross(e1, e2)\n //\n // Simplification: triangle centroid = (1/3) * (p1 + p2 + p3)\n //\n // The rest of the derivation is handled by computer algebra.\n\n if (_ASSERT) console.assert(this.m_count >= 3);\n\n matrix.zeroVec2(center);\n let area = 0.0;\n let I = 0.0;\n\n // s is the reference point for forming triangles.\n // It's location doesn't change the result (except for rounding error).\n matrix.zeroVec2(s);\n\n // This code would put the reference point inside the polygon.\n for (let i = 0; i < this.m_count; ++i) {\n matrix.plusVec2(s, this.m_vertices[i]);\n }\n matrix.scaleVec2(s, 1.0 / this.m_count, s);\n\n const k_inv3 = 1.0 / 3.0;\n\n for (let i = 0; i < this.m_count; ++i) {\n // Triangle vertices.\n matrix.subVec2(e1, this.m_vertices[i], s);\n if ( i + 1 < this.m_count) {\n matrix.subVec2(e2, this.m_vertices[i + 1], s);\n } else {\n matrix.subVec2(e2, this.m_vertices[0], s);\n }\n\n const D = matrix.crossVec2Vec2(e1, e2);\n\n const triangleArea = 0.5 * D;\n area += triangleArea;\n\n // Area weighted centroid\n matrix.combine2Vec2(temp, triangleArea * k_inv3, e1, triangleArea * k_inv3, e2);\n matrix.plusVec2(center, temp);\n\n const ex1 = e1.x;\n const ey1 = e1.y;\n const ex2 = e2.x;\n const ey2 = e2.y;\n\n const intx2 = ex1 * ex1 + ex2 * ex1 + ex2 * ex2;\n const inty2 = ey1 * ey1 + ey2 * ey1 + ey2 * ey2;\n\n I += (0.25 * k_inv3 * D) * (intx2 + inty2);\n }\n\n // Total mass\n massData.mass = density * area;\n\n // Center of mass\n if (_ASSERT) console.assert(area > EPSILON);\n matrix.scaleVec2(center, 1.0 / area, center);\n matrix.addVec2(massData.center, center, s);\n\n // Inertia tensor relative to the local origin (point s).\n massData.I = density * I;\n\n // Shift to center of mass then to original body origin.\n massData.I += massData.mass * (matrix.dotVec2(massData.center, massData.center) - matrix.dotVec2(center, center));\n }\n\n /**\n * Validate convexity. This is a very time consuming operation.\n * @returns true if valid\n */\n validate(): boolean {\n for (let i = 0; i < this.m_count; ++i) {\n const i1 = i;\n const i2 = i < this.m_count - 1 ? i1 + 1 : 0;\n const p = this.m_vertices[i1];\n matrix.subVec2(e, this.m_vertices[i2], p);\n\n for (let j = 0; j < this.m_count; ++j) {\n if (j == i1 || j == i2) {\n continue;\n }\n\n const c = matrix.crossVec2Vec2(e, matrix.subVec2(temp, this.m_vertices[j], p));\n if (c < 0.0) {\n return false;\n }\n }\n }\n\n return true;\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n for (let i = 0; i < this.m_count; ++i) {\n proxy.m_vertices[i] = this.m_vertices[i];\n }\n proxy.m_vertices.length = this.m_count;\n proxy.m_count = this.m_count;\n proxy.m_radius = this.m_radius;\n }\n}\n\n/** @internal */ function computeCentroid(vs: Vec2[], count: number): Vec2 {\n if (_ASSERT) console.assert(count >= 3);\n\n const c = Vec2.zero();\n let area = 0.0;\n\n // pRef is the reference point for forming triangles.\n // It's location doesn't change the result (except for rounding error).\n const pRef = Vec2.zero();\n if (false) {\n // This code would put the reference point inside the polygon.\n for (let i = 0; i < count; ++i) {\n pRef.add(vs[i]);\n }\n pRef.mul(1.0 / count);\n }\n\n const inv3 = 1.0 / 3.0;\n\n for (let i = 0; i < count; ++i) {\n // Triangle vertices.\n const p1 = pRef;\n const p2 = vs[i];\n const p3 = i + 1 < count ? vs[i + 1] : vs[0];\n\n const e1 = Vec2.sub(p2, p1);\n const e2 = Vec2.sub(p3, p1);\n\n const D = Vec2.crossVec2Vec2(e1, e2);\n\n const triangleArea = 0.5 * D;\n area += triangleArea;\n\n // Area weighted centroid\n matrix.combine3Vec2(temp, 1, p1, 1, p2, 1, p3);\n matrix.plusScaleVec2(c, triangleArea * inv3, temp);\n }\n\n // Centroid\n if (_ASSERT) console.assert(area > EPSILON);\n c.mul(1.0 / area);\n return c;\n}\n\nexport const Polygon = PolygonShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Shape } from \"../Shape\";\nimport { AABBValue, RayCastInput, RayCastOutput } from \"../AABB\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { MassData } from \"../../dynamics/Body\";\nimport { DistanceProxy } from \"../Distance\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_PI = Math.PI;\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n\ndeclare module \"./CircleShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function CircleShape(position: Vec2Value, radius?: number): CircleShape;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function CircleShape(radius?: number): CircleShape;\n}\n\n/** Circle shape. */\n// @ts-expect-error\nexport class CircleShape extends Shape {\n static TYPE = \"circle\" as const;\n /** @hidden */ m_type: \"circle\";\n\n /** @hidden */ m_p: Vec2;\n /** @hidden */ m_radius: number;\n\n constructor(position: Vec2Value, radius?: number);\n constructor(radius?: number);\n constructor(a: any, b?: any) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof CircleShape)) {\n return new CircleShape(a, b);\n }\n\n super();\n\n this.m_type = CircleShape.TYPE;\n this.m_p = Vec2.zero();\n this.m_radius = 1;\n\n if (typeof a === \"object\" && Vec2.isValid(a)) {\n this.m_p.setVec2(a);\n\n if (typeof b === \"number\") {\n this.m_radius = b;\n }\n\n } else if (typeof a === \"number\") {\n this.m_radius = a;\n }\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n p: this.m_p,\n radius: this.m_radius,\n };\n }\n\n /** @internal */\n static _deserialize(data: any): CircleShape {\n return new CircleShape(data.p, data.radius);\n }\n\n /** @hidden */\n _reset(): void {\n // noop\n }\n\n getType(): \"circle\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n getCenter(): Vec2 {\n return this.m_p;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): CircleShape {\n const clone = new CircleShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_p = this.m_p.clone();\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): boolean {\n const center = matrix.transformVec2(temp, xf, this.m_p);\n return matrix.distSqrVec2(p, center) <= this.m_radius * this.m_radius;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n // Collision Detection in Interactive 3D Environments by Gino van den Bergen\n // From Section 3.1.2\n // x = s + a * r\n // norm(x) = radius\n\n const position = Vec2.add(xf.p, Rot.mulVec2(xf.q, this.m_p));\n const s = Vec2.sub(input.p1, position);\n const b = Vec2.dot(s, s) - this.m_radius * this.m_radius;\n\n // Solve quadratic equation.\n const r = Vec2.sub(input.p2, input.p1);\n const c = Vec2.dot(s, r);\n const rr = Vec2.dot(r, r);\n const sigma = c * c - rr * b;\n\n // Check for negative discriminant and short segment.\n if (sigma < 0.0 || rr < EPSILON) {\n return false;\n }\n\n // Find the point of intersection of the line with the circle.\n let a = -(c + math_sqrt(sigma));\n\n // Is the intersection point on the segment?\n if (0.0 <= a && a <= input.maxFraction * rr) {\n a /= rr;\n output.fraction = a;\n output.normal = Vec2.add(s, Vec2.mulNumVec2(a, r));\n output.normal.normalize();\n return true;\n }\n\n return false;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n const p = matrix.transformVec2(temp, xf, this.m_p);\n\n matrix.setVec2(aabb.lowerBound, p.x - this.m_radius, p.y - this.m_radius);\n matrix.setVec2(aabb.upperBound, p.x + this.m_radius, p.y + this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density: number): void {\n massData.mass = density * math_PI * this.m_radius * this.m_radius;\n matrix.copyVec2(massData.center, this.m_p);\n // inertia about the local origin\n massData.I = massData.mass * (0.5 * this.m_radius * this.m_radius + matrix.lengthSqrVec2(this.m_p));\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n proxy.m_vertices[0] = this.m_p;\n proxy.m_vertices.length = 1;\n proxy.m_count = 1;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Circle = CircleShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Distance joint definition. This requires defining an anchor point on both\n * bodies and the non-zero length of the distance joint. The definition uses\n * local anchor points so that the initial configuration can violate the\n * constraint slightly. This helps when saving and loading a game. Warning: Do\n * not use a zero or short length.\n */\nexport interface DistanceJointOpt extends JointOpt {\n /**\n * The mass-spring-damper frequency in Hertz. A value of 0 disables softness.\n */\n frequencyHz?: number;\n /**\n * The damping ratio. 0 = no damping, 1 = critical damping.\n */\n dampingRatio?: number;\n /**\n * Distance length.\n */\n length?: number;\n}\n/**\n * Distance joint definition. This requires defining an anchor point on both\n * bodies and the non-zero length of the distance joint. The definition uses\n * local anchor points so that the initial configuration can violate the\n * constraint slightly. This helps when saving and loading a game. Warning: Do\n * not use a zero or short length.\n */\nexport interface DistanceJointDef extends JointDef, DistanceJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n frequencyHz : 0.0,\n dampingRatio : 0.0\n};\n\ndeclare module \"./DistanceJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function DistanceJoint(def: DistanceJointDef): DistanceJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function DistanceJoint(def: DistanceJointOpt, bodyA: Body, bodyB: Body, anchorA: Vec2Value, anchorB: Vec2Value): DistanceJoint;\n}\n\n/**\n * A distance joint constrains two points on two bodies to remain at a fixed\n * distance from each other. You can view this as a massless, rigid rod.\n */\n// @ts-expect-error\nexport class DistanceJoint extends Joint {\n static TYPE = \"distance-joint\" as const;\n\n // Solver shared\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_length: number;\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_gamma: number;\n /** @internal */ m_bias: number;\n\n // Solver temp\n /** @internal */ m_u: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: number;\n\n /**\n * @param def DistanceJoint definition.\n */\n constructor(def: DistanceJointDef);\n /**\n * @param anchorA Anchor A in global coordination.\n * @param anchorB Anchor B in global coordination.\n */\n constructor(def: DistanceJointOpt, bodyA: Body, bodyB: Body, anchorA?: Vec2Value, anchorB?: Vec2Value);\n constructor(def: DistanceJointDef, bodyA?: Body, bodyB?: Body, anchorA?: Vec2Value, anchorB?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof DistanceJoint)) {\n return new DistanceJoint(def, bodyA, bodyB, anchorA, anchorB);\n }\n\n // order of constructor arguments is changed in v0.2\n if (bodyB && anchorA && (\"m_type\" in anchorA) && (\"x\" in bodyB) && (\"y\" in bodyB)) {\n const temp = bodyB;\n bodyB = anchorA as any as Body;\n anchorA = temp as any as Vec2;\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = DistanceJoint.TYPE;\n\n // Solver shared\n this.m_localAnchorA = Vec2.clone(anchorA ? bodyA.getLocalPoint(anchorA) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchorB ? bodyB.getLocalPoint(anchorB) : def.localAnchorB || Vec2.zero());\n this.m_length = Number.isFinite(def.length) ? def.length :\n Vec2.distance(bodyA.getWorldPoint(this.m_localAnchorA), bodyB.getWorldPoint(this.m_localAnchorB));\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n this.m_impulse = 0.0;\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n\n // 1-D constrained system\n // m (v2 - v1) = lambda\n // v2 + (beta/h) * x1 + gamma * lambda = 0, gamma has units of inverse mass.\n // x2 = x1 + h * v2\n\n // 1-D mass-damper-spring system\n // m (v2 - v1) + h * d * v2 + h * k *\n\n // C = norm(p2 - p1) - L\n // u = (p2 - p1) / norm(p2 - p1)\n // Cdot = dot(u, v2 + cross(w2, r2) - v1 - cross(w1, r1))\n // J = [-u -cross(r1, u) u cross(r2, u)]\n // K = J * invM * JT\n // = invMass1 + invI1 * cross(r1, u)^2 + invMass2 + invI2 * cross(r2, u)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n length: this.m_length,\n\n impulse: this.m_impulse,\n gamma: this.m_gamma,\n bias: this.m_bias,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): DistanceJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new DistanceJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n\n if (def.length > 0) {\n this.m_length = +def.length;\n } else if (def.length < 0) { // don't change length\n } else if (def.anchorA || def.anchorA || def.anchorA || def.anchorA) {\n this.m_length = Vec2.distance(\n this.m_bodyA.getWorldPoint(this.m_localAnchorA),\n this.m_bodyB.getWorldPoint(this.m_localAnchorB)\n );\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the natural length. Manipulating the length can lead to non-physical\n * behavior when the frequency is zero.\n */\n setLength(length: number): void {\n this.m_length = length;\n }\n\n /**\n * Get the natural length.\n */\n getLength(): number {\n return this.m_length;\n }\n\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_u).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n this.m_u = Vec2.sub(Vec2.add(cB, this.m_rB), Vec2.add(cA, this.m_rA));\n\n // Handle singularity.\n const length = this.m_u.length();\n if (length > Settings.linearSlop) {\n this.m_u.mul(1.0 / length);\n } else {\n this.m_u.setNum(0.0, 0.0);\n }\n\n const crAu = Vec2.crossVec2Vec2(this.m_rA, this.m_u);\n const crBu = Vec2.crossVec2Vec2(this.m_rB, this.m_u);\n let invMass = this.m_invMassA + this.m_invIA * crAu * crAu + this.m_invMassB + this.m_invIB * crBu * crBu;\n\n // Compute the effective mass matrix.\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n\n if (this.m_frequencyHz > 0.0) {\n const C = length - this.m_length;\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * this.m_mass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = this.m_mass * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (d + h * k);\n this.m_gamma = this.m_gamma != 0.0 ? 1.0 / this.m_gamma : 0.0;\n this.m_bias = C * h * k * this.m_gamma;\n\n invMass += this.m_gamma;\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n } else {\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n }\n\n if (step.warmStarting) {\n // Scale the impulse to support a variable time step.\n this.m_impulse *= step.dtRatio;\n\n const P = Vec2.mulNumVec2(this.m_impulse, this.m_u);\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Cdot = dot(u, v + cross(w, r))\n const vpA = Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA));\n const vpB = Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB));\n const Cdot = Vec2.dot(this.m_u, vpB) - Vec2.dot(this.m_u, vpA);\n\n const impulse = -this.m_mass * (Cdot + this.m_bias + this.m_gamma * this.m_impulse);\n this.m_impulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_u);\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n if (this.m_frequencyHz > 0.0) {\n // There is no position correction for soft distance constraints.\n return true;\n }\n\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n const u = Vec2.sub(Vec2.add(cB, rB), Vec2.add(cA, rA));\n\n const length = u.normalize();\n const C = clamp(length - this.m_length, -Settings.maxLinearCorrection, Settings.maxLinearCorrection);\n\n const impulse = -this.m_mass * C;\n const P = Vec2.mulNumVec2(impulse, u);\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * Vec2.crossVec2Vec2(rA, P);\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, P);\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return math_abs(C) < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Friction joint definition.\n */\nexport interface FrictionJointOpt extends JointOpt {\n /**\n * The maximum friction force in N.\n */\n maxForce?: number;\n /**\n * The maximum friction torque in N-m.\n */\n maxTorque?: number;\n}\n\n/**\n * Friction joint definition.\n */\nexport interface FrictionJointDef extends JointDef, FrictionJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 0.0,\n maxTorque : 0.0,\n};\n\ndeclare module \"./FrictionJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function FrictionJoint(def: FrictionJointDef): FrictionJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function FrictionJoint(def: FrictionJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): FrictionJoint;\n}\n\n/**\n * Friction joint. This is used for top-down friction. It provides 2D\n * translational friction and angular friction.\n */\n// @ts-expect-error\nexport class FrictionJoint extends Joint {\n static TYPE = \"friction-joint\" as const;\n\n /** @internal */ m_type: \"friction-joint\";\n\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n\n // Solver shared\n /** @internal */ m_linearImpulse: Vec2;\n /** @internal */ m_angularImpulse: number;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_maxTorque: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_linearMass: Mat22;\n /** @internal */ m_angularMass: number;\n\n constructor(def: FrictionJointDef);\n /**\n * @param anchor Anchor in global coordination.\n */\n constructor(def: FrictionJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: FrictionJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof FrictionJoint)) {\n return new FrictionJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = FrictionJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n\n // Solver shared\n this.m_linearImpulse = Vec2.zero();\n this.m_angularImpulse = 0.0;\n this.m_maxForce = def.maxForce;\n this.m_maxTorque = def.maxTorque;\n\n // Point-to-point constraint\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Angle constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n maxForce: this.m_maxForce,\n maxTorque: this.m_maxTorque,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): FrictionJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new FrictionJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.maxTorque)) {\n this.m_maxTorque = def.maxTorque;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the maximum friction force in N.\n */\n setMaxForce(force: number): void {\n if (_ASSERT) console.assert(Number.isFinite(force) && force >= 0.0);\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum friction force in N.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the maximum friction torque in N*m.\n */\n setMaxTorque(torque: number): void {\n if (_ASSERT) console.assert(Number.isFinite(torque) && torque >= 0.0);\n this.m_maxTorque = torque;\n }\n\n /**\n * Get the maximum friction torque in N*m.\n */\n getMaxTorque(): number {\n return this.m_maxTorque;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_linearImpulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_angularImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective mass matrix.\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat22();\n K.ex.x = mA + mB + iA * this.m_rA.y * this.m_rA.y + iB * this.m_rB.y\n * this.m_rB.y;\n K.ex.y = -iA * this.m_rA.x * this.m_rA.y - iB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * this.m_rA.x * this.m_rA.x + iB * this.m_rB.x\n * this.m_rB.x;\n\n this.m_linearMass = K.getInverse();\n\n this.m_angularMass = iA + iB;\n if (this.m_angularMass > 0.0) {\n this.m_angularMass = 1.0 / this.m_angularMass;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_linearImpulse.mul(step.dtRatio);\n this.m_angularImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_linearImpulse.x, this.m_linearImpulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_angularImpulse);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_angularImpulse);\n\n } else {\n this.m_linearImpulse.setZero();\n this.m_angularImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const h = step.dt;\n\n // Solve angular friction\n {\n const Cdot = wB - wA;\n let impulse = -this.m_angularMass * Cdot;\n\n const oldImpulse = this.m_angularImpulse;\n const maxImpulse = h * this.m_maxTorque;\n this.m_angularImpulse = clamp(this.m_angularImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_angularImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve linear friction\n {\n const Cdot = Vec2.sub(\n Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB)),\n Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA))\n );\n\n let impulse = Vec2.neg(Mat22.mulVec2(this.m_linearMass, Cdot));\n const oldImpulse = this.m_linearImpulse;\n this.m_linearImpulse.add(impulse);\n\n const maxImpulse = h * this.m_maxForce;\n\n if (this.m_linearImpulse.lengthSquared() > maxImpulse * maxImpulse) {\n this.m_linearImpulse.normalize();\n this.m_linearImpulse.mul(maxImpulse);\n }\n\n impulse = Vec2.sub(this.m_linearImpulse, oldImpulse);\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { Vec3, Vec3Value } from \"./Vec3\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A 3-by-3 matrix. Stored in column-major order.\n */\nexport class Mat33 {\n ex: Vec3;\n ey: Vec3;\n ez: Vec3;\n\n constructor(a: Vec3Value, b: Vec3Value, c: Vec3Value);\n constructor();\n constructor(a?: Vec3Value, b?: Vec3Value, c?: Vec3Value) {\n if (typeof a === \"object\" && a !== null) {\n this.ex = Vec3.clone(a);\n this.ey = Vec3.clone(b);\n this.ez = Vec3.clone(c);\n } else {\n this.ex = Vec3.zero();\n this.ey = Vec3.zero();\n this.ez = Vec3.zero();\n }\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec3.isValid(obj.ex) && Vec3.isValid(obj.ey) && Vec3.isValid(obj.ez);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Mat33.isValid(o), \"Invalid Mat33!\", o);\n }\n\n /**\n * Set this matrix to all zeros.\n */\n setZero(): Mat33 {\n this.ex.setZero();\n this.ey.setZero();\n this.ez.setZero();\n return this;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases.\n */\n solve33(v: Vec3Value): Vec3 {\n // let det = matrix.dotVec3(this.ex, matrix.newCrossVec3(this.ey, this.ez));\n let cross_x = this.ey.y * this.ez.z - this.ey.z * this.ez.y;\n let cross_y = this.ey.z * this.ez.x - this.ey.x * this.ez.z;\n let cross_z = this.ey.x * this.ez.y - this.ey.y * this.ez.x;\n let det = this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const r = new Vec3();\n // r.x = det * matrix.dotVec3(v, matrix.newCrossVec3(this.ey, this.ez));\n cross_x = this.ey.y * this.ez.z - this.ey.z * this.ez.y;\n cross_y = this.ey.z * this.ez.x - this.ey.x * this.ez.z;\n cross_z = this.ey.x * this.ez.y - this.ey.y * this.ez.x;\n r.x = det * (v.x * cross_x + v.y * cross_y + v.z * cross_z);\n\n // r.y = det * matrix.dotVec3(this.ex, matrix.newCrossVec3(v, this.ez));\n cross_x = v.y * this.ez.z - v.z * this.ez.y;\n cross_y = v.z * this.ez.x - v.x * this.ez.z;\n cross_z = v.x * this.ez.y - v.y * this.ez.x;\n r.y = det * (this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z);\n\n // r.z = det * matrix.dotVec3(this.ex, matrix.newCrossVec3(this.ey, v));\n cross_x = this.ey.y * v.z - this.ey.z * v.y;\n cross_y = this.ey.z * v.x - this.ey.x * v.z;\n cross_z = this.ey.x * v.y - this.ey.y * v.x;\n r.z = det * (this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z);\n return r;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases. Solve only the upper 2-by-2 matrix\n * equation.\n */\n solve22(v: Vec2Value): Vec2 {\n const a11 = this.ex.x;\n const a12 = this.ey.x;\n const a21 = this.ex.y;\n const a22 = this.ey.y;\n let det = a11 * a22 - a12 * a21;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const r = Vec2.zero();\n r.x = det * (a22 * v.x - a12 * v.y);\n r.y = det * (a11 * v.y - a21 * v.x);\n return r;\n }\n\n /**\n * Get the inverse of this matrix as a 2-by-2. Returns the zero matrix if\n * singular.\n */\n getInverse22(M: Mat33): void {\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n M.ex.x = det * d;\n M.ey.x = -det * b;\n M.ex.z = 0.0;\n M.ex.y = -det * c;\n M.ey.y = det * a;\n M.ey.z = 0.0;\n M.ez.x = 0.0;\n M.ez.y = 0.0;\n M.ez.z = 0.0;\n }\n\n /**\n * Get the symmetric inverse of this matrix as a 3-by-3. Returns the zero matrix\n * if singular.\n */\n getSymInverse33(M: Mat33): void {\n let det = Vec3.dot(this.ex, Vec3.cross(this.ey, this.ez));\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const a11 = this.ex.x;\n const a12 = this.ey.x;\n const a13 = this.ez.x;\n const a22 = this.ey.y;\n const a23 = this.ez.y;\n const a33 = this.ez.z;\n\n M.ex.x = det * (a22 * a33 - a23 * a23);\n M.ex.y = det * (a13 * a23 - a12 * a33);\n M.ex.z = det * (a12 * a23 - a13 * a22);\n\n M.ey.x = M.ex.y;\n M.ey.y = det * (a11 * a33 - a13 * a13);\n M.ey.z = det * (a13 * a12 - a11 * a23);\n\n M.ez.x = M.ex.z;\n M.ez.y = M.ey.z;\n M.ez.z = det * (a11 * a22 - a12 * a12);\n }\n\n /**\n * Multiply a matrix times a vector.\n */\n static mul(a: Mat33, b: Vec2Value): Vec2;\n static mul(a: Mat33, b: Vec3Value): Vec3;\n static mul(a, b) {\n if (_ASSERT) Mat33.assert(a);\n if (b && \"z\" in b && \"y\" in b && \"x\" in b) {\n if (_ASSERT) Vec3.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y + a.ez.x * b.z;\n const y = a.ex.y * b.x + a.ey.y * b.y + a.ez.y * b.z;\n const z = a.ex.z * b.x + a.ey.z * b.y + a.ez.z * b.z;\n return new Vec3(x, y, z);\n\n } else if (b && \"y\" in b && \"x\" in b) {\n if (_ASSERT) Vec2.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y;\n const y = a.ex.y * b.x + a.ey.y * b.y;\n return Vec2.neo(x, y);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulVec3(a: Mat33, b: Vec3Value): Vec3 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Vec3.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y + a.ez.x * b.z;\n const y = a.ex.y * b.x + a.ey.y * b.y + a.ez.y * b.z;\n const z = a.ex.z * b.x + a.ey.z * b.y + a.ez.z * b.z;\n return new Vec3(x, y, z);\n }\n\n static mulVec2(a: Mat33, b: Vec2Value): Vec2 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y;\n const y = a.ex.y * b.x + a.ey.y * b.y;\n return Vec2.neo(x, y);\n }\n\n static add(a: Mat33, b: Mat33): Mat33 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Mat33.assert(b);\n return new Mat33(\n Vec3.add(a.ex, b.ex),\n Vec3.add(a.ey, b.ey),\n Vec3.add(a.ez, b.ez)\n );\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n\n\n// todo: use string?\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3,\n} \n\n/**\n * Revolute joint definition. This requires defining an anchor point where the\n * bodies are joined. The definition uses local anchor points so that the\n * initial configuration can violate the constraint slightly. You also need to\n * specify the initial relative angle for joint limits. This helps when saving\n * and loading a game.\n *\n * The local anchor points are measured from the body's origin rather than the\n * center of mass because: 1. you might not know where the center of mass will\n * be. 2. if you add/remove shapes from a body and recompute the mass, the\n * joints will be broken.\n */\nexport interface RevoluteJointOpt extends JointOpt {\n /**\n * The lower angle for the joint limit (radians).\n */\n lowerAngle?: number;\n /**\n * The upper angle for the joint limit (radians).\n */\n upperAngle?: number;\n /**\n * The maximum motor torque used to achieve the desired motor speed. Usually\n * in N-m.\n */\n maxMotorTorque?: number;\n /**\n * The desired motor speed. Usually in radians per second.\n */\n motorSpeed?: number;\n /**\n * A flag to enable joint limits.\n */\n enableLimit?: boolean;\n /**\n * A flag to enable the joint motor.\n */\n enableMotor?: boolean;\n}\n\n/**\n * Revolute joint definition. This requires defining an anchor point where the\n * bodies are joined. The definition uses local anchor points so that the\n * initial configuration can violate the constraint slightly. You also need to\n * specify the initial relative angle for joint limits. This helps when saving\n * and loading a game.\n *\n * The local anchor points are measured from the body's origin rather than the\n * center of mass because: 1. you might not know where the center of mass will\n * be. 2. if you add/remove shapes from a body and recompute the mass, the\n * joints will be broken.\n */\nexport interface RevoluteJointDef extends JointDef, RevoluteJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The bodyB angle minus bodyA angle in the reference state (radians).\n */\n referenceAngle?: number;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n lowerAngle : 0.0,\n upperAngle : 0.0,\n maxMotorTorque : 0.0,\n motorSpeed : 0.0,\n enableLimit : false,\n enableMotor : false\n};\n\ndeclare module \"./RevoluteJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RevoluteJoint(def: RevoluteJointDef): RevoluteJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RevoluteJoint(def: RevoluteJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): RevoluteJoint;\n}\n\n/**\n * A revolute joint constrains two bodies to share a common point while they are\n * free to rotate about the point. The relative rotation about the shared point\n * is the joint angle. You can limit the relative rotation with a joint limit\n * that specifies a lower and upper angle. You can use a motor to drive the\n * relative rotation about the shared point. A maximum motor torque is provided\n * so that infinite forces are not generated.\n */\n// @ts-expect-error\nexport class RevoluteJoint extends Joint {\n static TYPE = \"revolute-joint\" as const;\n\n /** @internal */ m_type: \"revolute-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngle: number;\n /** @internal */ m_impulse: Vec3;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_lowerAngle: number;\n /** @internal */ m_upperAngle: number;\n /** @internal */ m_maxMotorTorque: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableLimit: boolean;\n /** @internal */ m_enableMotor: boolean;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n // effective mass for point-to-point constraint.\n /** @internal */ m_mass: Mat33;\n // effective mass for motor/limit angular constraint.\n /** @internal */ m_motorMass: number;\n /** @internal */ m_limitState: number;\n\n constructor(def: RevoluteJointDef);\n constructor(def: RevoluteJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: RevoluteJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof RevoluteJoint)) {\n return new RevoluteJoint(def, bodyA, bodyB, anchor);\n }\n\n def = def ?? {} as RevoluteJointDef;\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_mass = new Mat33();\n this.m_limitState = LimitState.inactiveLimit;\n\n this.m_type = RevoluteJoint.TYPE;\n\n if (Vec2.isValid(anchor)) {\n this.m_localAnchorA = bodyA.getLocalPoint(anchor);\n } else if (Vec2.isValid(def.localAnchorA)) {\n this.m_localAnchorA = Vec2.clone(def.localAnchorA);\n } else {\n this.m_localAnchorA = Vec2.zero();\n }\n\n if (Vec2.isValid(anchor)) {\n this.m_localAnchorB = bodyB.getLocalPoint(anchor);\n } else if (Vec2.isValid(def.localAnchorB)) {\n this.m_localAnchorB = Vec2.clone(def.localAnchorB);\n } else {\n this.m_localAnchorB = Vec2.zero();\n }\n\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n } else {\n this.m_referenceAngle = bodyB.getAngle() - bodyA.getAngle();\n }\n\n this.m_impulse = new Vec3();\n this.m_motorImpulse = 0.0;\n\n this.m_lowerAngle = def.lowerAngle ?? DEFAULTS.lowerAngle;\n this.m_upperAngle = def.upperAngle ?? DEFAULTS.upperAngle;\n this.m_maxMotorTorque = def.maxMotorTorque ?? DEFAULTS.maxMotorTorque;\n this.m_motorSpeed = def.motorSpeed ?? DEFAULTS.motorSpeed;\n this.m_enableLimit = def.enableLimit ?? DEFAULTS.enableLimit;\n this.m_enableMotor = def.enableMotor ?? DEFAULTS.enableMotor;\n\n // Point-to-point constraint\n // C = p2 - p1\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Motor constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n lowerAngle: this.m_lowerAngle,\n upperAngle: this.m_upperAngle,\n maxMotorTorque: this.m_maxMotorTorque,\n motorSpeed: this.m_motorSpeed,\n enableLimit: this.m_enableLimit,\n enableMotor: this.m_enableMotor,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any):RevoluteJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new RevoluteJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n }\n if (def.enableLimit !== undefined) {\n this.m_enableLimit = def.enableLimit;\n }\n if (Number.isFinite(def.lowerAngle)) {\n this.m_lowerAngle = def.lowerAngle;\n }\n if (Number.isFinite(def.upperAngle)) {\n this.m_upperAngle = def.upperAngle;\n }\n if (Number.isFinite(def.maxMotorTorque)) {\n this.m_maxMotorTorque = def.maxMotorTorque;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n if (def.enableMotor !== undefined) {\n this.m_enableMotor = def.enableMotor;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Get the current joint angle in radians.\n */\n getJointAngle(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n return bB.m_sweep.a - bA.m_sweep.a - this.m_referenceAngle;\n }\n\n /**\n * Get the current joint angle speed in radians per second.\n */\n getJointSpeed(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n return bB.m_angularVelocity - bA.m_angularVelocity;\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Get the current motor torque given the inverse time step. Unit is N*m.\n */\n getMotorTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Set the motor speed in radians per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Get the motor speed in radians per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Set the maximum motor torque, usually in N-m.\n */\n setMaxMotorTorque(torque: number): void {\n if (torque == this.m_maxMotorTorque) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorTorque = torque;\n }\n\n getMaxMotorTorque(): number {\n return this.m_maxMotorTorque;\n }\n\n /**\n * Is the joint limit enabled?\n */\n isLimitEnabled(): boolean {\n return this.m_enableLimit;\n }\n\n /**\n * Enable/disable the joint limit.\n */\n enableLimit(flag: boolean): void {\n if (flag != this.m_enableLimit) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableLimit = flag;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Get the lower joint limit in radians.\n */\n getLowerLimit(): number {\n return this.m_lowerAngle;\n }\n\n /**\n * Get the upper joint limit in radians.\n */\n getUpperLimit(): number {\n return this.m_upperAngle;\n }\n\n /**\n * Set the joint limits in radians.\n */\n setLimits(lower: number, upper: number): void {\n if (_ASSERT) console.assert(lower <= upper);\n\n if (lower != this.m_lowerAngle || upper != this.m_upperAngle) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_impulse.z = 0.0;\n this.m_lowerAngle = lower;\n this.m_upperAngle = upper;\n }\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force given the inverse time step. Unit is N.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.neo(this.m_impulse.x, this.m_impulse.y).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque due to the joint limit given the inverse time step.\n * Unit is N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.z;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const fixedRotation = (iA + iB === 0.0);\n\n this.m_mass.ex.x = mA + mB + this.m_rA.y * this.m_rA.y * iA + this.m_rB.y * this.m_rB.y * iB;\n this.m_mass.ey.x = -this.m_rA.y * this.m_rA.x * iA - this.m_rB.y * this.m_rB.x * iB;\n this.m_mass.ez.x = -this.m_rA.y * iA - this.m_rB.y * iB;\n this.m_mass.ex.y = this.m_mass.ey.x;\n this.m_mass.ey.y = mA + mB + this.m_rA.x * this.m_rA.x * iA + this.m_rB.x * this.m_rB.x * iB;\n this.m_mass.ez.y = this.m_rA.x * iA + this.m_rB.x * iB;\n this.m_mass.ex.z = this.m_mass.ez.x;\n this.m_mass.ey.z = this.m_mass.ez.y;\n this.m_mass.ez.z = iA + iB;\n\n this.m_motorMass = iA + iB;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n\n if (this.m_enableMotor == false || fixedRotation) {\n this.m_motorImpulse = 0.0;\n }\n\n if (this.m_enableLimit && fixedRotation == false) {\n const jointAngle = aB - aA - this.m_referenceAngle;\n\n if (math_abs(this.m_upperAngle - this.m_lowerAngle) < 2.0 * Settings.angularSlop) {\n this.m_limitState = LimitState.equalLimits;\n\n } else if (jointAngle <= this.m_lowerAngle) {\n if (this.m_limitState != LimitState.atLowerLimit) {\n this.m_impulse.z = 0.0;\n }\n this.m_limitState = LimitState.atLowerLimit;\n\n } else if (jointAngle >= this.m_upperAngle) {\n if (this.m_limitState != LimitState.atUpperLimit) {\n this.m_impulse.z = 0.0;\n }\n this.m_limitState = LimitState.atUpperLimit;\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_impulse.mul(step.dtRatio);\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_impulse.x, this.m_impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_motorImpulse + this.m_impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_motorImpulse + this.m_impulse.z);\n\n } else {\n this.m_impulse.setZero();\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const fixedRotation = (iA + iB === 0.0);\n\n // Solve motor constraint.\n if (this.m_enableMotor && this.m_limitState != LimitState.equalLimits && fixedRotation == false) {\n const Cdot = wB - wA - this.m_motorSpeed;\n let impulse = -this.m_motorMass * Cdot;\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorTorque;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve limit constraint.\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit && fixedRotation == false) {\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const Cdot2 = wB - wA;\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const impulse = Vec3.neg(this.m_mass.solve33(Cdot));\n\n if (this.m_limitState == LimitState.equalLimits) {\n this.m_impulse.add(impulse);\n\n } else if (this.m_limitState == LimitState.atLowerLimit) {\n const newImpulse = this.m_impulse.z + impulse.z;\n\n if (newImpulse < 0.0) {\n const rhs = Vec2.combine(-1, Cdot1, this.m_impulse.z, Vec2.neo(this.m_mass.ez.x, this.m_mass.ez.y));\n const reduced = this.m_mass.solve22(rhs);\n impulse.x = reduced.x;\n impulse.y = reduced.y;\n impulse.z = -this.m_impulse.z;\n this.m_impulse.x += reduced.x;\n this.m_impulse.y += reduced.y;\n this.m_impulse.z = 0.0;\n\n } else {\n this.m_impulse.add(impulse);\n }\n\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n const newImpulse = this.m_impulse.z + impulse.z;\n\n if (newImpulse > 0.0) {\n const rhs = Vec2.combine(-1, Cdot1, this.m_impulse.z, Vec2.neo(this.m_mass.ez.x, this.m_mass.ez.y));\n const reduced = this.m_mass.solve22(rhs);\n impulse.x = reduced.x;\n impulse.y = reduced.y;\n impulse.z = -this.m_impulse.z;\n this.m_impulse.x += reduced.x;\n this.m_impulse.y += reduced.y;\n this.m_impulse.z = 0.0;\n\n } else {\n this.m_impulse.add(impulse);\n }\n }\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + impulse.z);\n\n } else {\n // Solve point-to-point constraint\n const Cdot = Vec2.zero();\n Cdot.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const impulse = this.m_mass.solve22(Vec2.neg(Cdot));\n\n this.m_impulse.x += impulse.x;\n this.m_impulse.y += impulse.y;\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n let angularError = 0.0;\n let positionError = 0.0;\n\n const fixedRotation = (this.m_invIA + this.m_invIB == 0.0);\n\n // Solve angular limit constraint.\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit && fixedRotation == false) {\n const angle = aB - aA - this.m_referenceAngle;\n let limitImpulse = 0.0;\n\n if (this.m_limitState == LimitState.equalLimits) {\n // Prevent large angular corrections\n const C = clamp(angle - this.m_lowerAngle, -Settings.maxAngularCorrection, Settings.maxAngularCorrection);\n limitImpulse = -this.m_motorMass * C;\n angularError = math_abs(C);\n\n } else if (this.m_limitState == LimitState.atLowerLimit) {\n let C = angle - this.m_lowerAngle;\n angularError = -C;\n\n // Prevent large angular corrections and allow some slop.\n C = clamp(C + Settings.angularSlop, -Settings.maxAngularCorrection, 0.0);\n limitImpulse = -this.m_motorMass * C;\n\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n let C = angle - this.m_upperAngle;\n angularError = C;\n\n // Prevent large angular corrections and allow some slop.\n C = clamp(C - Settings.angularSlop, 0.0, Settings.maxAngularCorrection);\n limitImpulse = -this.m_motorMass * C;\n }\n\n aA -= this.m_invIA * limitImpulse;\n aB += this.m_invIB * limitImpulse;\n }\n\n // Solve point-to-point constraint.\n {\n qA.setAngle(aA);\n qB.setAngle(aB);\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n const C = Vec2.zero();\n C.addCombine(1, cB, 1, rB);\n C.subCombine(1, cA, 1, rA);\n positionError = C.length();\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat22();\n K.ex.x = mA + mB + iA * rA.y * rA.y + iB * rB.y * rB.y;\n K.ex.y = -iA * rA.x * rA.y - iB * rB.x * rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * rA.x * rA.x + iB * rB.x * rB.x;\n\n const impulse = Vec2.neg(K.solve(C));\n\n cA.subMul(mA, impulse);\n aA -= iA * Vec2.crossVec2Vec2(rA, impulse);\n\n cB.addMul(mB, impulse);\n aB += iB * Vec2.crossVec2Vec2(rB, impulse);\n }\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return positionError <= Settings.linearSlop && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3, \n}\n\n/**\n * Prismatic joint definition. This requires defining a line of motion using an\n * axis and an anchor point. The definition uses local anchor points and a local\n * axis so that the initial configuration can violate the constraint slightly.\n * The joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface PrismaticJointOpt extends JointOpt {\n /**\n * Enable/disable the joint limit.\n */\n enableLimit?: boolean;\n /**\n * The lower translation limit, usually in meters.\n */\n lowerTranslation?: number;\n /**\n * The upper translation limit, usually in meters.\n */\n upperTranslation?: number;\n /**\n * Enable/disable the joint motor.\n */\n enableMotor?: boolean;\n /**\n * The maximum motor torque, usually in N-m.\n */\n maxMotorForce?: number;\n /**\n * The desired motor speed in radians per second.\n */\n motorSpeed?: number;\n}\n\n/**\n * Prismatic joint definition. This requires defining a line of motion using an\n * axis and an anchor point. The definition uses local anchor points and a local\n * axis so that the initial configuration can violate the constraint slightly.\n * The joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface PrismaticJointDef extends JointDef, PrismaticJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The local translation unit axis in bodyA.\n */\n localAxisA: Vec2Value;\n /**\n * referenceAngle The constrained angle between the bodies:\n * bodyB_angle - bodyA_angle.\n */\n referenceAngle?: number;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n enableLimit : false,\n lowerTranslation : 0.0,\n upperTranslation : 0.0,\n enableMotor : false,\n maxMotorForce : 0.0,\n motorSpeed : 0.0\n};\n\ndeclare module \"./PrismaticJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PrismaticJoint(def: PrismaticJointDef): PrismaticJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PrismaticJoint(def: PrismaticJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value, axis: Vec2Value): PrismaticJoint;\n}\n\n/**\n * A prismatic joint. This joint provides one degree of freedom: translation\n * along an axis fixed in bodyA. Relative rotation is prevented. You can use a\n * joint limit to restrict the range of motion and a joint motor to drive the\n * motion or to model joint friction.\n */\n// @ts-expect-error\nexport class PrismaticJoint extends Joint {\n static TYPE = \"prismatic-joint\" as const;\n\n /** @internal */ m_type: \"prismatic-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_localXAxisA: Vec2;\n /** @internal */ m_localYAxisA: Vec2;\n /** @internal */ m_referenceAngle: number;\n /** @internal */ m_impulse: Vec3;\n /** @internal */ m_motorMass: number;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_lowerTranslation: number;\n /** @internal */ m_upperTranslation: number;\n /** @internal */ m_maxMotorForce: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableLimit: boolean;\n /** @internal */ m_enableMotor: boolean;\n /** @internal */ m_limitState: number; // TODO enum\n /** @internal */ m_axis: Vec2;\n /** @internal */ m_perp: Vec2;\n // Solver temp\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_s1: number;\n /** @internal */ m_s2: number;\n /** @internal */ m_a1: number;\n /** @internal */ m_a2: number;\n /** @internal */ m_K: Mat33;\n\n constructor(def: PrismaticJointDef);\n constructor(def: PrismaticJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value, axis?: Vec2Value);\n constructor(def: PrismaticJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value, axis?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PrismaticJoint)) {\n return new PrismaticJoint(def, bodyA, bodyB, anchor, axis);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = PrismaticJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n this.m_localXAxisA = Vec2.clone(axis ? bodyA.getLocalVector(axis) : def.localAxisA || Vec2.neo(1.0, 0.0));\n this.m_localXAxisA.normalize();\n this.m_localYAxisA = Vec2.crossNumVec2(1.0, this.m_localXAxisA);\n this.m_referenceAngle = Number.isFinite(def.referenceAngle) ? def.referenceAngle : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_impulse = new Vec3();\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n\n this.m_lowerTranslation = def.lowerTranslation;\n this.m_upperTranslation = def.upperTranslation;\n this.m_maxMotorForce = def.maxMotorForce;\n this.m_motorSpeed = def.motorSpeed;\n this.m_enableLimit = def.enableLimit;\n this.m_enableMotor = def.enableMotor;\n this.m_limitState = LimitState.inactiveLimit;\n\n this.m_axis = Vec2.zero();\n this.m_perp = Vec2.zero();\n\n this.m_K = new Mat33();\n\n // Linear constraint (point-to-line)\n // d = p2 - p1 = x2 + r2 - x1 - r1\n // C = dot(perp, d)\n // Cdot = dot(d, cross(w1, perp)) + dot(perp, v2 + cross(w2, r2) - v1 -\n // cross(w1, r1))\n // = -dot(perp, v1) - dot(cross(d + r1, perp), w1) + dot(perp, v2) +\n // dot(cross(r2, perp), v2)\n // J = [-perp, -cross(d + r1, perp), perp, cross(r2,perp)]\n //\n // Angular constraint\n // C = a2 - a1 + a_initial\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n //\n // K = J * invM * JT\n //\n // J = [-a -s1 a s2]\n // [0 -1 0 1]\n // a = perp\n // s1 = cross(d + r1, a) = cross(p2 - x1, a)\n // s2 = cross(r2, a) = cross(p2 - x2, a)\n\n // Motor/Limit linear constraint\n // C = dot(ax1, d)\n // Cdot = = -dot(ax1, v1) - dot(cross(d + r1, ax1), w1) + dot(ax1, v2) +\n // dot(cross(r2, ax1), v2)\n // J = [-ax1 -cross(d+r1,ax1) ax1 cross(r2,ax1)]\n\n // Block Solver\n // We develop a block solver that includes the joint limit. This makes the\n // limit stiff (inelastic) even\n // when the mass has poor distribution (leading to large torques about the\n // joint anchor points).\n //\n // The Jacobian has 3 rows:\n // J = [-uT -s1 uT s2] // linear\n // [0 -1 0 1] // angular\n // [-vT -a1 vT a2] // limit\n //\n // u = perp\n // v = axis\n // s1 = cross(d + r1, u), s2 = cross(r2, u)\n // a1 = cross(d + r1, v), a2 = cross(r2, v)\n\n // M * (v2 - v1) = JT * df\n // J * v2 = bias\n //\n // v2 = v1 + invM * JT * df\n // J * (v1 + invM * JT * df) = bias\n // K * df = bias - J * v1 = -Cdot\n // K = J * invM * JT\n // Cdot = J * v1 - bias\n //\n // Now solve for f2.\n // df = f2 - f1\n // K * (f2 - f1) = -Cdot\n // f2 = invK * (-Cdot) + f1\n //\n // Clamp accumulated limit impulse.\n // lower: f2(3) = max(f2(3), 0)\n // upper: f2(3) = min(f2(3), 0)\n //\n // Solve for correct f2(1:2)\n // K(1:2, 1:2) * f2(1:2) = -Cdot(1:2) - K(1:2,3) * f2(3) + K(1:2,1:3) * f1\n // = -Cdot(1:2) - K(1:2,3) * f2(3) + K(1:2,1:2) * f1(1:2) + K(1:2,3) * f1(3)\n // K(1:2, 1:2) * f2(1:2) = -Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3)) +\n // K(1:2,1:2) * f1(1:2)\n // f2(1:2) = invK(1:2,1:2) * (-Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3))) +\n // f1(1:2)\n //\n // Now compute impulse to be applied:\n // df = f2 - f1\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n lowerTranslation: this.m_lowerTranslation,\n upperTranslation: this.m_upperTranslation,\n maxMotorForce: this.m_maxMotorForce,\n motorSpeed: this.m_motorSpeed,\n enableLimit: this.m_enableLimit,\n enableMotor: this.m_enableMotor,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n localAxisA: this.m_localXAxisA,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): PrismaticJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.localAxisA = Vec2.clone(data.localAxisA);\n const joint = new PrismaticJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (def.localAxisA) {\n this.m_localXAxisA.setVec2(def.localAxisA);\n this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1.0, def.localAxisA));\n }\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n }\n if (typeof def.enableLimit !== \"undefined\") {\n this.m_enableLimit = !!def.enableLimit;\n }\n if (Number.isFinite(def.lowerTranslation)) {\n this.m_lowerTranslation = def.lowerTranslation;\n }\n if (Number.isFinite(def.upperTranslation)) {\n this.m_upperTranslation = def.upperTranslation;\n }\n if (typeof def.enableMotor !== \"undefined\") {\n this.m_enableMotor = !!def.enableMotor;\n }\n if (Number.isFinite(def.maxMotorForce)) {\n this.m_maxMotorForce = def.maxMotorForce;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * The local joint axis relative to bodyA.\n */\n getLocalAxisA(): Vec2 {\n return this.m_localXAxisA;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Get the current joint translation, usually in meters.\n */\n getJointTranslation(): number {\n const pA = this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n const pB = this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n const d = Vec2.sub(pB, pA);\n const axis = this.m_bodyA.getWorldVector(this.m_localXAxisA);\n\n const translation = Vec2.dot(d, axis);\n return translation;\n }\n\n /**\n * Get the current joint translation speed, usually in meters per second.\n */\n getJointSpeed(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n\n const rA = Rot.mulVec2(bA.m_xf.q, Vec2.sub(this.m_localAnchorA, bA.m_sweep.localCenter));\n const rB = Rot.mulVec2(bB.m_xf.q, Vec2.sub(this.m_localAnchorB, bB.m_sweep.localCenter));\n const p1 = Vec2.add(bA.m_sweep.c, rA);\n const p2 = Vec2.add(bB.m_sweep.c, rB);\n const d = Vec2.sub(p2, p1);\n const axis = Rot.mulVec2(bA.m_xf.q, this.m_localXAxisA);\n\n const vA = bA.m_linearVelocity;\n const vB = bB.m_linearVelocity;\n const wA = bA.m_angularVelocity;\n const wB = bB.m_angularVelocity;\n\n const speed = Vec2.dot(d, Vec2.crossNumVec2(wA, axis)) + Vec2.dot(axis, Vec2.sub(Vec2.addCrossNumVec2(vB, wB, rB), Vec2.addCrossNumVec2(vA, wA, rA)));\n return speed;\n }\n\n /**\n * Is the joint limit enabled?\n */\n isLimitEnabled(): boolean {\n return this.m_enableLimit;\n }\n\n /**\n * Enable/disable the joint limit.\n */\n enableLimit(flag: boolean): void {\n if (flag != this.m_enableLimit) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableLimit = flag;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Get the lower joint limit, usually in meters.\n */\n getLowerLimit(): number {\n return this.m_lowerTranslation;\n }\n\n /**\n * Get the upper joint limit, usually in meters.\n */\n getUpperLimit(): number {\n return this.m_upperTranslation;\n }\n\n /**\n * Set the joint limits, usually in meters.\n */\n setLimits(lower: number, upper: number): void {\n if (_ASSERT) console.assert(lower <= upper);\n if (lower != this.m_lowerTranslation || upper != this.m_upperTranslation) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_lowerTranslation = lower;\n this.m_upperTranslation = upper;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Set the motor speed, usually in meters per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Set the maximum motor force, usually in N.\n */\n setMaxMotorForce(force: number): void {\n if (force == this.m_maxMotorForce) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorForce = force;\n }\n\n getMaxMotorForce(): number {\n return this.m_maxMotorForce;\n }\n\n /**\n * Get the motor speed, usually in meters per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Get the current motor force given the inverse time step, usually in N.\n */\n getMotorForce(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.combine(this.m_impulse.x, this.m_perp, this.m_motorImpulse + this.m_impulse.z, this.m_axis).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.y;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective masses.\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Compute motor Jacobian and effective mass.\n {\n this.m_axis = Rot.mulVec2(qA, this.m_localXAxisA);\n this.m_a1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_axis);\n this.m_a2 = Vec2.crossVec2Vec2(rB, this.m_axis);\n\n this.m_motorMass = mA + mB + iA * this.m_a1 * this.m_a1 + iB * this.m_a2\n * this.m_a2;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n }\n\n // Prismatic constraint.\n {\n this.m_perp = Rot.mulVec2(qA, this.m_localYAxisA);\n\n this.m_s1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_perp);\n this.m_s2 = Vec2.crossVec2Vec2(rB, this.m_perp);\n\n const s1test = Vec2.crossVec2Vec2(rA, this.m_perp);\n\n const k11 = mA + mB + iA * this.m_s1 * this.m_s1 + iB * this.m_s2 * this.m_s2;\n const k12 = iA * this.m_s1 + iB * this.m_s2;\n const k13 = iA * this.m_s1 * this.m_a1 + iB * this.m_s2 * this.m_a2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n // For bodies with fixed rotation.\n k22 = 1.0;\n }\n const k23 = iA * this.m_a1 + iB * this.m_a2;\n const k33 = mA + mB + iA * this.m_a1 * this.m_a1 + iB * this.m_a2 * this.m_a2;\n\n this.m_K.ex.set(k11, k12, k13);\n this.m_K.ey.set(k12, k22, k23);\n this.m_K.ez.set(k13, k23, k33);\n }\n\n // Compute motor and limit terms.\n if (this.m_enableLimit) {\n\n const jointTranslation = Vec2.dot(this.m_axis, d);\n if (math_abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * Settings.linearSlop) {\n this.m_limitState = LimitState.equalLimits;\n\n } else if (jointTranslation <= this.m_lowerTranslation) {\n if (this.m_limitState != LimitState.atLowerLimit) {\n this.m_limitState = LimitState.atLowerLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else if (jointTranslation >= this.m_upperTranslation) {\n if (this.m_limitState != LimitState.atUpperLimit) {\n this.m_limitState = LimitState.atUpperLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n if (this.m_enableMotor == false) {\n this.m_motorImpulse = 0.0;\n }\n\n if (step.warmStarting) {\n // Account for variable time step.\n this.m_impulse.mul(step.dtRatio);\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.combine(this.m_impulse.x, this.m_perp, this.m_motorImpulse\n + this.m_impulse.z, this.m_axis);\n const LA = this.m_impulse.x * this.m_s1 + this.m_impulse.y\n + (this.m_motorImpulse + this.m_impulse.z) * this.m_a1;\n const LB = this.m_impulse.x * this.m_s2 + this.m_impulse.y\n + (this.m_motorImpulse + this.m_impulse.z) * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n } else {\n this.m_impulse.setZero();\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Solve linear motor constraint.\n if (this.m_enableMotor && this.m_limitState != LimitState.equalLimits) {\n const Cdot = Vec2.dot(this.m_axis, Vec2.sub(vB, vA)) + this.m_a2 * wB\n - this.m_a1 * wA;\n let impulse = this.m_motorMass * (this.m_motorSpeed - Cdot);\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorForce;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse,\n -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_axis);\n const LA = impulse * this.m_a1;\n const LB = impulse * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n const Cdot1 = Vec2.zero();\n Cdot1.x += Vec2.dot(this.m_perp, vB) + this.m_s2 * wB;\n Cdot1.x -= Vec2.dot(this.m_perp, vA) + this.m_s1 * wA;\n Cdot1.y = wB - wA;\n\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit) {\n // Solve prismatic and limit constraint in block form.\n let Cdot2 = 0;\n Cdot2 += Vec2.dot(this.m_axis, vB) + this.m_a2 * wB;\n Cdot2 -= Vec2.dot(this.m_axis, vA) + this.m_a1 * wA;\n\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const f1 = Vec3.clone(this.m_impulse);\n let df = this.m_K.solve33(Vec3.neg(Cdot));\n this.m_impulse.add(df);\n\n if (this.m_limitState == LimitState.atLowerLimit) {\n this.m_impulse.z = math_max(this.m_impulse.z, 0.0);\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n this.m_impulse.z = math_min(this.m_impulse.z, 0.0);\n }\n\n // f2(1:2) = invK(1:2,1:2) * (-Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3))) +\n // f1(1:2)\n const b = Vec2.combine(-1, Cdot1, -(this.m_impulse.z - f1.z), Vec2.neo(this.m_K.ez.x, this.m_K.ez.y));\n const f2r = Vec2.add(this.m_K.solve22(b), Vec2.neo(f1.x, f1.y));\n this.m_impulse.x = f2r.x;\n this.m_impulse.y = f2r.y;\n\n df = Vec3.sub(this.m_impulse, f1);\n\n const P = Vec2.combine(df.x, this.m_perp, df.z, this.m_axis);\n const LA = df.x * this.m_s1 + df.y + df.z * this.m_a1;\n const LB = df.x * this.m_s2 + df.y + df.z * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n } else {\n // Limit is inactive, just solve the prismatic constraint in block form.\n const df = this.m_K.solve22(Vec2.neg(Cdot1));\n this.m_impulse.x += df.x;\n this.m_impulse.y += df.y;\n\n const P = Vec2.mulNumVec2(df.x, this.m_perp);\n const LA = df.x * this.m_s1 + df.y;\n const LB = df.x * this.m_s2 + df.y;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Compute fresh Jacobians\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.sub(Vec2.add(cB, rB), Vec2.add(cA, rA));\n\n const axis = Rot.mulVec2(qA, this.m_localXAxisA);\n const a1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), axis);\n const a2 = Vec2.crossVec2Vec2(rB, axis);\n const perp = Rot.mulVec2(qA, this.m_localYAxisA);\n\n const s1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), perp);\n const s2 = Vec2.crossVec2Vec2(rB, perp);\n\n let impulse = new Vec3();\n const C1 = Vec2.zero();\n C1.x = Vec2.dot(perp, d);\n C1.y = aB - aA - this.m_referenceAngle;\n\n let linearError = math_abs(C1.x);\n const angularError = math_abs(C1.y);\n\n const linearSlop = Settings.linearSlop;\n const maxLinearCorrection = Settings.maxLinearCorrection;\n\n let active = false; // bool\n let C2 = 0.0;\n if (this.m_enableLimit) {\n\n const translation = Vec2.dot(axis, d);\n if (math_abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * linearSlop) {\n // Prevent large angular corrections\n C2 = clamp(translation, -maxLinearCorrection, maxLinearCorrection);\n linearError = math_max(linearError, math_abs(translation));\n active = true;\n\n } else if (translation <= this.m_lowerTranslation) {\n // Prevent large linear corrections and allow some slop.\n C2 = clamp(translation - this.m_lowerTranslation + linearSlop,\n -maxLinearCorrection, 0.0);\n linearError = Math\n .max(linearError, this.m_lowerTranslation - translation);\n active = true;\n\n } else if (translation >= this.m_upperTranslation) {\n // Prevent large linear corrections and allow some slop.\n C2 = clamp(translation - this.m_upperTranslation - linearSlop, 0.0,\n maxLinearCorrection);\n linearError = Math\n .max(linearError, translation - this.m_upperTranslation);\n active = true;\n }\n }\n\n if (active) {\n const k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2;\n const k12 = iA * s1 + iB * s2;\n const k13 = iA * s1 * a1 + iB * s2 * a2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n // For fixed rotation\n k22 = 1.0;\n }\n const k23 = iA * a1 + iB * a2;\n const k33 = mA + mB + iA * a1 * a1 + iB * a2 * a2;\n\n const K = new Mat33();\n K.ex.set(k11, k12, k13);\n K.ey.set(k12, k22, k23);\n K.ez.set(k13, k23, k33);\n\n const C = new Vec3();\n C.x = C1.x;\n C.y = C1.y;\n C.z = C2;\n\n impulse = K.solve33(Vec3.neg(C));\n } else {\n const k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2;\n const k12 = iA * s1 + iB * s2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n k22 = 1.0;\n }\n\n const K = new Mat22();\n K.ex.setNum(k11, k12);\n K.ey.setNum(k12, k22);\n\n const impulse1 = K.solve(Vec2.neg(C1));\n impulse.x = impulse1.x;\n impulse.y = impulse1.y;\n impulse.z = 0.0;\n }\n\n const P = Vec2.combine(impulse.x, perp, impulse.z, axis);\n const LA = impulse.x * s1 + impulse.y + impulse.z * a1;\n const LB = impulse.x * s2 + impulse.y + impulse.z * a2;\n\n cA.subMul(mA, P);\n aA -= iA * LA;\n cB.addMul(mB, P);\n aB += iB * LB;\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return linearError <= Settings.linearSlop\n && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { } from \"../../common/Math\";\nimport { Vec2 } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { RevoluteJoint } from \"./RevoluteJoint\";\nimport { PrismaticJoint } from \"./PrismaticJoint\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Gear joint definition.\n */\nexport interface GearJointOpt extends JointOpt {\n /**\n * The gear ratio. See {@link GearJoint} for explanation.\n */\n ratio?: number;\n}\n\n/**\n * Gear joint definition.\n */\nexport interface GearJointDef extends JointDef, GearJointOpt {\n /**\n * The first revolute/prismatic joint attached to the gear joint.\n */\n joint1: RevoluteJoint | PrismaticJoint;\n /**\n * The second prismatic/revolute joint attached to the gear joint.\n */\n joint2: RevoluteJoint | PrismaticJoint;\n}\n\n/** @internal */ const DEFAULTS = {\n ratio : 1.0\n};\n\ndeclare module \"./GearJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function GearJoint(def: GearJointDef): GearJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function GearJoint(def: GearJointOpt, bodyA: Body, bodyB: Body, joint1: RevoluteJoint | PrismaticJoint, joint2: RevoluteJoint | PrismaticJoint, ratio?: number): GearJoint;\n}\n\n/**\n * A gear joint is used to connect two joints together. Either joint can be a\n * revolute or prismatic joint. You specify a gear ratio to bind the motions\n * together: coordinate1 + ratio * coordinate2 = constant\n *\n * The ratio can be negative or positive. If one joint is a revolute joint and\n * the other joint is a prismatic joint, then the ratio will have units of\n * length or units of 1/length. Warning: You have to manually destroy the gear\n * joint if joint1 or joint2 is destroyed.\n *\n * This definition requires two existing revolute or prismatic joints (any\n * combination will work).\n */\n// @ts-expect-error\nexport class GearJoint extends Joint {\n static TYPE = \"gear-joint\" as const;\n\n /** @internal */ m_type: \"gear-joint\";\n /** @internal */ m_joint1: RevoluteJoint | PrismaticJoint;\n /** @internal */ m_joint2: RevoluteJoint | PrismaticJoint;\n /** @internal */ m_type1: \"revolute-joint\" | \"prismatic-joint\";\n /** @internal */ m_type2: \"revolute-joint\" | \"prismatic-joint\";\n /** @internal */ m_bodyC: Body;\n /** @internal */ m_localAnchorC: Vec2;\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_referenceAngleA: number;\n /** @internal */ m_localAxisC: Vec2;\n /** @internal */ m_bodyD: Body;\n /** @internal */ m_localAnchorD: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngleB: number;\n /** @internal */ m_localAxisD: Vec2;\n /** @internal */ m_ratio: number;\n /** @internal */ m_constant: number;\n /** @internal */ m_impulse: number;\n\n // Solver temp\n /** @internal */ m_lcA: Vec2;\n /** @internal */ m_lcB: Vec2;\n /** @internal */ m_lcC: Vec2;\n /** @internal */ m_lcD: Vec2;\n /** @internal */ m_mA: number;\n /** @internal */ m_mB: number;\n /** @internal */ m_mC: number;\n /** @internal */ m_mD: number;\n /** @internal */ m_iA: number;\n /** @internal */ m_iB: number;\n /** @internal */ m_iC: number;\n /** @internal */ m_iD: number;\n /** @internal */ m_JvAC: Vec2;\n /** @internal */ m_JvBD: Vec2;\n /** @internal */ m_JwA: number;\n /** @internal */ m_JwB: number;\n /** @internal */ m_JwC: number;\n /** @internal */ m_JwD: number;\n /** @internal */ m_mass: number;\n\n constructor(def: GearJointDef);\n constructor(def: GearJointOpt, bodyA: Body, bodyB: Body, joint1: RevoluteJoint | PrismaticJoint, joint2: RevoluteJoint | PrismaticJoint, ratio?: number);\n constructor(def: GearJointDef, bodyA?: Body, bodyB?: Body, joint1?: RevoluteJoint | PrismaticJoint, joint2?: RevoluteJoint | PrismaticJoint, ratio?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof GearJoint)) {\n return new GearJoint(def, bodyA, bodyB, joint1, joint2, ratio);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = GearJoint.TYPE;\n\n if (_ASSERT) console.assert(joint1.m_type === RevoluteJoint.TYPE || joint1.m_type === PrismaticJoint.TYPE);\n if (_ASSERT) console.assert(joint2.m_type === RevoluteJoint.TYPE || joint2.m_type === PrismaticJoint.TYPE);\n\n this.m_joint1 = joint1 ? joint1 : def.joint1;\n this.m_joint2 = joint2 ? joint2 : def.joint2;\n this.m_ratio = Number.isFinite(ratio) ? ratio : def.ratio;\n\n this.m_type1 = this.m_joint1.getType() as \"revolute-joint\" | \"prismatic-joint\";\n this.m_type2 = this.m_joint2.getType() as \"revolute-joint\" | \"prismatic-joint\";\n\n // joint1 connects body A to body C\n // joint2 connects body B to body D\n\n let coordinateA: number;\n let coordinateB: number;\n\n // TODO_ERIN there might be some problem with the joint edges in Joint.\n\n this.m_bodyC = this.m_joint1.getBodyA();\n this.m_bodyA = this.m_joint1.getBodyB();\n\n // Get geometry of joint1\n const xfA = this.m_bodyA.m_xf;\n const aA = this.m_bodyA.m_sweep.a;\n const xfC = this.m_bodyC.m_xf;\n const aC = this.m_bodyC.m_sweep.a;\n\n if (this.m_type1 === RevoluteJoint.TYPE) {\n const revolute = this.m_joint1 as RevoluteJoint;\n this.m_localAnchorC = revolute.m_localAnchorA;\n this.m_localAnchorA = revolute.m_localAnchorB;\n this.m_referenceAngleA = revolute.m_referenceAngle;\n this.m_localAxisC = Vec2.zero();\n\n coordinateA = aA - aC - this.m_referenceAngleA;\n } else {\n const prismatic = this.m_joint1 as PrismaticJoint;\n this.m_localAnchorC = prismatic.m_localAnchorA;\n this.m_localAnchorA = prismatic.m_localAnchorB;\n this.m_referenceAngleA = prismatic.m_referenceAngle;\n this.m_localAxisC = prismatic.m_localXAxisA;\n\n const pC = this.m_localAnchorC;\n const pA = Rot.mulTVec2(xfC.q, Vec2.add(Rot.mulVec2(xfA.q, this.m_localAnchorA), Vec2.sub(xfA.p, xfC.p)));\n coordinateA = Vec2.dot(pA, this.m_localAxisC) - Vec2.dot(pC, this.m_localAxisC);\n }\n\n this.m_bodyD = this.m_joint2.getBodyA();\n this.m_bodyB = this.m_joint2.getBodyB();\n\n // Get geometry of joint2\n const xfB = this.m_bodyB.m_xf;\n const aB = this.m_bodyB.m_sweep.a;\n const xfD = this.m_bodyD.m_xf;\n const aD = this.m_bodyD.m_sweep.a;\n\n if (this.m_type2 === RevoluteJoint.TYPE) {\n const revolute = this.m_joint2 as RevoluteJoint;\n this.m_localAnchorD = revolute.m_localAnchorA;\n this.m_localAnchorB = revolute.m_localAnchorB;\n this.m_referenceAngleB = revolute.m_referenceAngle;\n this.m_localAxisD = Vec2.zero();\n\n coordinateB = aB - aD - this.m_referenceAngleB;\n } else {\n const prismatic = this.m_joint2 as PrismaticJoint;\n this.m_localAnchorD = prismatic.m_localAnchorA;\n this.m_localAnchorB = prismatic.m_localAnchorB;\n this.m_referenceAngleB = prismatic.m_referenceAngle;\n this.m_localAxisD = prismatic.m_localXAxisA;\n\n const pD = this.m_localAnchorD;\n const pB = Rot.mulTVec2(xfD.q, Vec2.add(Rot.mulVec2(xfB.q, this.m_localAnchorB), Vec2.sub(xfB.p, xfD.p)));\n coordinateB = Vec2.dot(pB, this.m_localAxisD) - Vec2.dot(pD, this.m_localAxisD);\n }\n\n this.m_constant = coordinateA + this.m_ratio * coordinateB;\n\n this.m_impulse = 0.0;\n\n // Gear Joint:\n // C0 = (coordinate1 + ratio * coordinate2)_initial\n // C = (coordinate1 + ratio * coordinate2) - C0 = 0\n // J = [J1 ratio * J2]\n // K = J * invM * JT\n // = J1 * invM1 * J1T + ratio * ratio * J2 * invM2 * J2T\n //\n // Revolute:\n // coordinate = rotation\n // Cdot = angularVelocity\n // J = [0 0 1]\n // K = J * invM * JT = invI\n //\n // Prismatic:\n // coordinate = dot(p - pg, ug)\n // Cdot = dot(v + cross(w, r), ug)\n // J = [ug cross(r, ug)]\n // K = J * invM * JT = invMass + invI * cross(r, ug)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n joint1: this.m_joint1,\n joint2: this.m_joint2,\n ratio: this.m_ratio,\n\n // _constant: this.m_constant,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): GearJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.joint1 = restore(Joint, data.joint1, world);\n data.joint2 = restore(Joint, data.joint2, world);\n const joint = new GearJoint(data);\n // if (data._constant) joint.m_constant = data._constant;\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n // todo: implement other fields\n if (Number.isFinite(def.ratio)) {\n this.m_ratio = def.ratio;\n }\n }\n\n /**\n * Get the first joint.\n */\n getJoint1(): Joint {\n return this.m_joint1;\n }\n\n /**\n * Get the second joint.\n */\n getJoint2(): Joint {\n return this.m_joint2;\n }\n\n /**\n * Set the gear ratio.\n */\n setRatio(ratio: number): void {\n if (_ASSERT) console.assert(Number.isFinite(ratio));\n this.m_ratio = ratio;\n }\n\n /**\n * Get the gear ratio.\n */\n getRatio(): number {\n return this.m_ratio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_JvAC).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n const L = this.m_impulse * this.m_JwA;\n return inv_dt * L;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_lcA = this.m_bodyA.m_sweep.localCenter;\n this.m_lcB = this.m_bodyB.m_sweep.localCenter;\n this.m_lcC = this.m_bodyC.m_sweep.localCenter;\n this.m_lcD = this.m_bodyD.m_sweep.localCenter;\n this.m_mA = this.m_bodyA.m_invMass;\n this.m_mB = this.m_bodyB.m_invMass;\n this.m_mC = this.m_bodyC.m_invMass;\n this.m_mD = this.m_bodyD.m_invMass;\n this.m_iA = this.m_bodyA.m_invI;\n this.m_iB = this.m_bodyB.m_invI;\n this.m_iC = this.m_bodyC.m_invI;\n this.m_iD = this.m_bodyD.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const aC = this.m_bodyC.c_position.a;\n const vC = this.m_bodyC.c_velocity.v;\n let wC = this.m_bodyC.c_velocity.w;\n\n const aD = this.m_bodyD.c_position.a;\n const vD = this.m_bodyD.c_velocity.v;\n let wD = this.m_bodyD.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n const qC = Rot.neo(aC);\n const qD = Rot.neo(aD);\n\n this.m_mass = 0.0;\n\n if (this.m_type1 == RevoluteJoint.TYPE) {\n this.m_JvAC = Vec2.zero();\n this.m_JwA = 1.0;\n this.m_JwC = 1.0;\n this.m_mass += this.m_iA + this.m_iC;\n } else {\n const u = Rot.mulVec2(qC, this.m_localAxisC);\n const rC = Rot.mulSub(qC, this.m_localAnchorC, this.m_lcC);\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_lcA);\n this.m_JvAC = u;\n this.m_JwC = Vec2.crossVec2Vec2(rC, u);\n this.m_JwA = Vec2.crossVec2Vec2(rA, u);\n this.m_mass += this.m_mC + this.m_mA + this.m_iC * this.m_JwC * this.m_JwC + this.m_iA * this.m_JwA * this.m_JwA;\n }\n\n if (this.m_type2 == RevoluteJoint.TYPE) {\n this.m_JvBD = Vec2.zero();\n this.m_JwB = this.m_ratio;\n this.m_JwD = this.m_ratio;\n this.m_mass += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD);\n } else {\n const u = Rot.mulVec2(qD, this.m_localAxisD);\n const rD = Rot.mulSub(qD, this.m_localAnchorD, this.m_lcD);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_lcB);\n this.m_JvBD = Vec2.mulNumVec2(this.m_ratio, u);\n this.m_JwD = this.m_ratio * Vec2.crossVec2Vec2(rD, u);\n this.m_JwB = this.m_ratio * Vec2.crossVec2Vec2(rB, u);\n this.m_mass += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * this.m_JwD * this.m_JwD + this.m_iB * this.m_JwB * this.m_JwB;\n }\n\n // Compute effective mass.\n this.m_mass = this.m_mass > 0.0 ? 1.0 / this.m_mass : 0.0;\n\n if (step.warmStarting) {\n vA.addMul(this.m_mA * this.m_impulse, this.m_JvAC);\n wA += this.m_iA * this.m_impulse * this.m_JwA;\n\n vB.addMul(this.m_mB * this.m_impulse, this.m_JvBD);\n wB += this.m_iB * this.m_impulse * this.m_JwB;\n\n vC.subMul(this.m_mC * this.m_impulse, this.m_JvAC);\n wC -= this.m_iC * this.m_impulse * this.m_JwC;\n\n vD.subMul(this.m_mD * this.m_impulse, this.m_JvBD);\n wD -= this.m_iD * this.m_impulse * this.m_JwD;\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n this.m_bodyC.c_velocity.v.setVec2(vC);\n this.m_bodyC.c_velocity.w = wC;\n this.m_bodyD.c_velocity.v.setVec2(vD);\n this.m_bodyD.c_velocity.w = wD;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n const vC = this.m_bodyC.c_velocity.v;\n let wC = this.m_bodyC.c_velocity.w;\n const vD = this.m_bodyD.c_velocity.v;\n let wD = this.m_bodyD.c_velocity.w;\n\n let Cdot = Vec2.dot(this.m_JvAC, vA) - Vec2.dot(this.m_JvAC, vC) + Vec2.dot(this.m_JvBD, vB) - Vec2.dot(this.m_JvBD, vD);\n Cdot += (this.m_JwA * wA - this.m_JwC * wC) + (this.m_JwB * wB - this.m_JwD * wD);\n\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n vA.addMul(this.m_mA * impulse, this.m_JvAC);\n wA += this.m_iA * impulse * this.m_JwA;\n vB.addMul(this.m_mB * impulse, this.m_JvBD);\n wB += this.m_iB * impulse * this.m_JwB;\n vC.subMul(this.m_mC * impulse, this.m_JvAC);\n wC -= this.m_iC * impulse * this.m_JwC;\n vD.subMul(this.m_mD * impulse, this.m_JvBD);\n wD -= this.m_iD * impulse * this.m_JwD;\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n this.m_bodyC.c_velocity.v.setVec2(vC);\n this.m_bodyC.c_velocity.w = wC;\n this.m_bodyD.c_velocity.v.setVec2(vD);\n this.m_bodyD.c_velocity.w = wD;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n const cC = this.m_bodyC.c_position.c;\n let aC = this.m_bodyC.c_position.a;\n const cD = this.m_bodyD.c_position.c;\n let aD = this.m_bodyD.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n const qC = Rot.neo(aC);\n const qD = Rot.neo(aD);\n\n const linearError = 0.0;\n\n let coordinateA: number;\n let coordinateB: number;\n\n let JvAC: Vec2;\n let JvBD: Vec2;\n let JwA: number;\n let JwB: number;\n let JwC: number;\n let JwD: number;\n let mass = 0.0;\n\n if (this.m_type1 == RevoluteJoint.TYPE) {\n JvAC = Vec2.zero();\n JwA = 1.0;\n JwC = 1.0;\n mass += this.m_iA + this.m_iC;\n\n coordinateA = aA - aC - this.m_referenceAngleA;\n } else {\n const u = Rot.mulVec2(qC, this.m_localAxisC);\n const rC = Rot.mulSub(qC, this.m_localAnchorC, this.m_lcC);\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_lcA);\n JvAC = u;\n JwC = Vec2.crossVec2Vec2(rC, u);\n JwA = Vec2.crossVec2Vec2(rA, u);\n mass += this.m_mC + this.m_mA + this.m_iC * JwC * JwC + this.m_iA * JwA * JwA;\n\n const pC = Vec2.sub(this.m_localAnchorC, this.m_lcC);\n const pA = Rot.mulTVec2(qC, Vec2.add(rA, Vec2.sub(cA, cC)));\n coordinateA = Vec2.dot(Vec2.sub(pA, pC), this.m_localAxisC);\n }\n\n if (this.m_type2 == RevoluteJoint.TYPE) {\n JvBD = Vec2.zero();\n JwB = this.m_ratio;\n JwD = this.m_ratio;\n mass += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD);\n\n coordinateB = aB - aD - this.m_referenceAngleB;\n } else {\n const u = Rot.mulVec2(qD, this.m_localAxisD);\n const rD = Rot.mulSub(qD, this.m_localAnchorD, this.m_lcD);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_lcB);\n JvBD = Vec2.mulNumVec2(this.m_ratio, u);\n JwD = this.m_ratio * Vec2.crossVec2Vec2(rD, u);\n JwB = this.m_ratio * Vec2.crossVec2Vec2(rB, u);\n mass += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * JwD * JwD + this.m_iB * JwB * JwB;\n\n const pD = Vec2.sub(this.m_localAnchorD, this.m_lcD);\n const pB = Rot.mulTVec2(qD, Vec2.add(rB, Vec2.sub(cB, cD)));\n coordinateB = Vec2.dot(pB, this.m_localAxisD) - Vec2.dot(pD, this.m_localAxisD);\n }\n\n const C = (coordinateA + this.m_ratio * coordinateB) - this.m_constant;\n\n let impulse = 0.0;\n if (mass > 0.0) {\n impulse = -C / mass;\n }\n\n cA.addMul(this.m_mA * impulse, JvAC);\n aA += this.m_iA * impulse * JwA;\n cB.addMul(this.m_mB * impulse, JvBD);\n aB += this.m_iB * impulse * JwB;\n cC.subMul(this.m_mC * impulse, JvAC);\n aC -= this.m_iC * impulse * JwC;\n cD.subMul(this.m_mD * impulse, JvBD);\n aD -= this.m_iD * impulse * JwD;\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n this.m_bodyC.c_position.c.setVec2(cC);\n this.m_bodyC.c_position.a = aC;\n this.m_bodyD.c_position.c.setVec2(cD);\n this.m_bodyD.c_position.a = aD;\n\n // TODO_ERIN not implemented\n return linearError < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Motor joint definition.\n */\nexport interface MotorJointOpt extends JointOpt {\n /**\n * The bodyB angle minus bodyA angle in radians.\n */\n angularOffset?: number;\n /**\n * The maximum motor force in N.\n */\n maxForce?: number;\n /**\n * The maximum motor torque in N-m.\n */\n maxTorque?: number;\n /**\n * Position correction factor in the range [0,1].\n */\n correctionFactor?: number;\n /**\n * Position of bodyB minus the position of bodyA, in bodyA's frame, in meters.\n */\n linearOffset?: Vec2Value;\n}\n\n/**\n * Motor joint definition.\n */\nexport interface MotorJointDef extends JointDef, MotorJointOpt {\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 1.0,\n maxTorque : 1.0,\n correctionFactor : 0.3\n};\n\ndeclare module \"./MotorJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MotorJoint(def: MotorJointDef): MotorJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MotorJoint(def: MotorJointOpt, bodyA: Body, bodyB: Body): MotorJoint;\n}\n\n/**\n * A motor joint is used to control the relative motion between two bodies. A\n * typical usage is to control the movement of a dynamic body with respect to\n * the ground.\n */\n// @ts-expect-error\nexport class MotorJoint extends Joint {\n static TYPE = \"motor-joint\" as const;\n\n /** @internal */ m_type: \"motor-joint\";\n /** @internal */ m_linearOffset: Vec2;\n /** @internal */ m_angularOffset: number;\n /** @internal */ m_linearImpulse: Vec2;\n /** @internal */ m_angularImpulse: number;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_maxTorque: number;\n /** @internal */ m_correctionFactor: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_linearError: Vec2;\n /** @internal */ m_angularError: number;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_linearMass: Mat22;\n /** @internal */ m_angularMass: number;\n\n constructor(def: MotorJointDef);\n constructor(def: MotorJointOpt, bodyA: Body, bodyB: Body);\n constructor(def: MotorJointDef | MotorJointOpt, bodyA?: Body, bodyB?: Body) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof MotorJoint)) {\n return new MotorJoint(def, bodyA, bodyB);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = MotorJoint.TYPE;\n\n this.m_linearOffset = Vec2.isValid(def.linearOffset) ? Vec2.clone(def.linearOffset) : bodyA.getLocalPoint(bodyB.getPosition());\n this.m_angularOffset = Number.isFinite(def.angularOffset) ? def.angularOffset : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_linearImpulse = Vec2.zero();\n this.m_angularImpulse = 0.0;\n\n this.m_maxForce = def.maxForce;\n this.m_maxTorque = def.maxTorque;\n this.m_correctionFactor = def.correctionFactor;\n\n // Point-to-point constraint\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n //\n // r1 = offset - c1\n // r2 = -c2\n\n // Angle constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n maxForce: this.m_maxForce,\n maxTorque: this.m_maxTorque,\n correctionFactor: this.m_correctionFactor,\n\n linearOffset: this.m_linearOffset,\n angularOffset: this.m_angularOffset,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): MotorJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new MotorJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.angularOffset)) {\n this.m_angularOffset = def.angularOffset;\n }\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.maxTorque)) {\n this.m_maxTorque = def.maxTorque;\n }\n if (Number.isFinite(def.correctionFactor)) {\n this.m_correctionFactor = def.correctionFactor;\n }\n if (Vec2.isValid(def.linearOffset)) {\n this.m_linearOffset.set(def.linearOffset); \n }\n }\n\n /**\n * Set the maximum friction force in N.\n */\n setMaxForce(force: number): void {\n if (_ASSERT) console.assert(Number.isFinite(force) && force >= 0.0);\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum friction force in N.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the maximum friction torque in N*m.\n */\n setMaxTorque(torque: number): void {\n if (_ASSERT) console.assert(Number.isFinite(torque) && torque >= 0.0);\n this.m_maxTorque = torque;\n }\n\n /**\n * Get the maximum friction torque in N*m.\n */\n getMaxTorque(): number {\n return this.m_maxTorque;\n }\n\n /**\n * Set the position correction factor in the range [0,1].\n */\n setCorrectionFactor(factor: number): void {\n if (_ASSERT) console.assert(Number.isFinite(factor) && 0.0 <= factor && factor <= 1.0);\n this.m_correctionFactor = factor;\n }\n\n /**\n * Get the position correction factor in the range [0,1].\n */\n getCorrectionFactor(): number {\n return this.m_correctionFactor;\n }\n\n /**\n * Set/get the target linear offset, in frame A, in meters.\n */\n setLinearOffset(linearOffset: Vec2Value): void {\n if (linearOffset.x != this.m_linearOffset.x || linearOffset.y != this.m_linearOffset.y) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_linearOffset.set(linearOffset);\n }\n }\n\n getLinearOffset(): Vec2 {\n return this.m_linearOffset;\n }\n\n /**\n * Set/get the target angular offset, in radians.\n */\n setAngularOffset(angularOffset: number): void {\n if (angularOffset != this.m_angularOffset) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_angularOffset = angularOffset;\n }\n }\n\n getAngularOffset(): number {\n return this.m_angularOffset;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getPosition();\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getPosition();\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_linearImpulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_angularImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective mass matrix.\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_linearOffset, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.neg(this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Upper 2 by 2 of K for point to point\n const K = new Mat22();\n K.ex.x = mA + mB + iA * this.m_rA.y * this.m_rA.y + iB * this.m_rB.y * this.m_rB.y;\n K.ex.y = -iA * this.m_rA.x * this.m_rA.y - iB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * this.m_rA.x * this.m_rA.x + iB * this.m_rB.x * this.m_rB.x;\n\n this.m_linearMass = K.getInverse();\n\n this.m_angularMass = iA + iB;\n if (this.m_angularMass > 0.0) {\n this.m_angularMass = 1.0 / this.m_angularMass;\n }\n\n this.m_linearError = Vec2.zero();\n this.m_linearError.addCombine(1, cB, 1, this.m_rB);\n this.m_linearError.subCombine(1, cA, 1, this.m_rA);\n\n this.m_angularError = aB - aA - this.m_angularOffset;\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_linearImpulse.mul(step.dtRatio);\n this.m_angularImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_linearImpulse.x, this.m_linearImpulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_angularImpulse);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_angularImpulse);\n\n } else {\n this.m_linearImpulse.setZero();\n this.m_angularImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const h = step.dt;\n const inv_h = step.inv_dt;\n\n // Solve angular friction\n {\n const Cdot = wB - wA + inv_h * this.m_correctionFactor * this.m_angularError;\n let impulse = -this.m_angularMass * Cdot;\n\n const oldImpulse = this.m_angularImpulse;\n const maxImpulse = h * this.m_maxTorque;\n this.m_angularImpulse = clamp(this.m_angularImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_angularImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve linear friction\n {\n const Cdot = Vec2.zero();\n Cdot.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n Cdot.addMul(inv_h * this.m_correctionFactor, this.m_linearError);\n\n let impulse = Vec2.neg(Mat22.mulVec2(this.m_linearMass, Cdot));\n const oldImpulse = Vec2.clone(this.m_linearImpulse);\n this.m_linearImpulse.add(impulse);\n\n const maxImpulse = h * this.m_maxForce;\n\n this.m_linearImpulse.clamp(maxImpulse);\n\n impulse = Vec2.sub(this.m_linearImpulse, oldImpulse);\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Transform } from \"../../common/Transform\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Mouse joint definition. This requires a world target point, tuning\n * parameters, and the time step.\n */\nexport interface MouseJointOpt extends JointOpt {\n /**\n * [maxForce = 0.0] The maximum constraint force that can be exerted to move\n * the candidate body. Usually you will express as some multiple of the\n * weight (multiplier * mass * gravity).\n */\n maxForce?: number;\n /**\n * [frequencyHz = 5.0] The response speed.\n */\n frequencyHz?: number;\n /**\n * [dampingRatio = 0.7] The damping ratio. 0 = no damping, 1 = critical\n * damping.\n */\n dampingRatio?: number;\n}\n\n/**\n * Mouse joint definition. This requires a world target point, tuning\n * parameters, and the time step.\n */\nexport interface MouseJointDef extends JointDef, MouseJointOpt {\n /**\n * The initial world target point. This is assumed to coincide with the body\n * anchor initially.\n */\n target: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 0.0,\n frequencyHz : 5.0,\n dampingRatio : 0.7\n};\n\ndeclare module \"./MouseJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MouseJoint(def: MouseJointDef): MouseJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MouseJoint(def: MouseJointOpt, bodyA: Body, bodyB: Body, target: Vec2Value): MouseJoint;\n}\n\n/**\n * A mouse joint is used to make a point on a body track a specified world\n * point. This a soft constraint with a maximum force. This allows the\n * constraint to stretch and without applying huge forces.\n *\n * You need to call setTarget(target) every time that mouse is \n * moved, to track the new location of the mouse.\n *\n * NOTE: this joint is not documented in the manual because it was developed to\n * be used in the testbed. If you want to learn how to use the mouse joint, look\n * at the testbed.\n */\n// @ts-expect-error\nexport class MouseJoint extends Joint {\n static TYPE = \"mouse-joint\" as const;\n\n /** @internal */ m_type: \"mouse-joint\";\n /** @internal */ m_targetA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_impulse: Vec2;\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n /** @internal */ m_beta: number;\n /** @internal */ m_gamma: number;\n // Solver temp\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: Mat22;\n /** @internal */ m_C: Vec2;\n\n constructor(def: MouseJointDef);\n constructor(def: MouseJointOpt, bodyA: Body, bodyB: Body, target?: Vec2Value);\n constructor(def: MouseJointDef, bodyA?: Body, bodyB?: Body, target?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof MouseJoint)) {\n return new MouseJoint(def, bodyA, bodyB, target);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = MouseJoint.TYPE;\n\n if (_ASSERT) console.assert(Number.isFinite(def.maxForce) && def.maxForce >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.frequencyHz) && def.frequencyHz >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.dampingRatio) && def.dampingRatio >= 0.0);\n\n if (Vec2.isValid(target)) {\n this.m_targetA = Vec2.clone(target);\n } else if (Vec2.isValid(def.target)) {\n this.m_targetA = Vec2.clone(def.target);\n } else {\n this.m_targetA = Vec2.zero();\n }\n\n this.m_localAnchorB = Transform.mulTVec2(bodyB.getTransform(), this.m_targetA);\n\n this.m_maxForce = def.maxForce;\n this.m_impulse = Vec2.zero();\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_beta = 0.0;\n this.m_gamma = 0.0;\n\n // Solver temp\n this.m_rB = Vec2.zero();\n this.m_localCenterB = Vec2.zero();\n this.m_invMassB = 0.0;\n this.m_invIB = 0.0;\n this.m_mass = new Mat22();\n this.m_C = Vec2.zero();\n\n // p = attached point, m = mouse point\n // C = p - m\n // Cdot = v\n // = v + cross(w, r)\n // J = [I r_skew]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n target: this.m_targetA,\n maxForce: this.m_maxForce,\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n _localAnchorB: this.m_localAnchorB,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): MouseJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.target = Vec2.clone(data.target);\n const joint = new MouseJoint(data);\n if (data._localAnchorB) {\n joint.m_localAnchorB = data._localAnchorB;\n }\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * Use this to update the target point.\n */\n setTarget(target: Vec2Value): void {\n if (Vec2.areEqual(target, this.m_targetA)) return;\n this.m_bodyB.setAwake(true);\n this.m_targetA.set(target);\n }\n\n getTarget(): Vec2 {\n return this.m_targetA;\n }\n\n /**\n * Set the maximum force in Newtons.\n */\n setMaxForce(force: number): void {\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum force in Newtons.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the frequency in Hertz.\n */\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n /**\n * Get the frequency in Hertz.\n */\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set the damping ratio (dimensionless).\n */\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n /**\n * Get the damping ratio (dimensionless).\n */\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return Vec2.clone(this.m_targetA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_impulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * 0.0;\n }\n\n /**\n * Shift the origin for any points stored in world coordinates.\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_targetA.sub(newOrigin);\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const position = this.m_bodyB.c_position;\n const velocity = this.m_bodyB.c_velocity;\n\n const cB = position.c;\n const aB = position.a;\n const vB = velocity.v;\n let wB = velocity.w;\n\n const qB = Rot.neo(aB);\n\n const mass = this.m_bodyB.getMass();\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * mass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = mass * (omega * omega);\n\n // magic formulas\n // gamma has units of inverse mass.\n // beta has units of inverse time.\n const h = step.dt;\n if (_ASSERT) console.assert(d + h * k > EPSILON);\n this.m_gamma = h * (d + h * k);\n if (this.m_gamma != 0.0) {\n this.m_gamma = 1.0 / this.m_gamma;\n }\n this.m_beta = h * k * this.m_gamma;\n\n // Compute the effective mass matrix.\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // K = [(1/m1 + 1/m2) * eye(2) - skew(r1) * invI1 * skew(r1) - skew(r2) *\n // invI2 * skew(r2)]\n // = [1/m1+1/m2 0 ] + invI1 * [r1.y*r1.y -r1.x*r1.y] + invI2 * [r1.y*r1.y\n // -r1.x*r1.y]\n // [ 0 1/m1+1/m2] [-r1.x*r1.y r1.x*r1.x] [-r1.x*r1.y r1.x*r1.x]\n const K = new Mat22();\n K.ex.x = this.m_invMassB + this.m_invIB * this.m_rB.y * this.m_rB.y\n + this.m_gamma;\n K.ex.y = -this.m_invIB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = this.m_invMassB + this.m_invIB * this.m_rB.x * this.m_rB.x\n + this.m_gamma;\n\n this.m_mass = K.getInverse();\n\n this.m_C.setVec2(cB);\n this.m_C.addCombine(1, this.m_rB, -1, this.m_targetA);\n this.m_C.mul(this.m_beta);\n\n // Cheat with some damping\n wB *= 0.98;\n\n if (step.warmStarting) {\n this.m_impulse.mul(step.dtRatio);\n vB.addMul(this.m_invMassB, this.m_impulse);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, this.m_impulse);\n\n } else {\n this.m_impulse.setZero();\n }\n\n velocity.v.setVec2(vB);\n velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const velocity = this.m_bodyB.c_velocity;\n const vB = Vec2.clone(velocity.v);\n let wB = velocity.w;\n\n // Cdot = v + cross(w, r)\n\n const Cdot = Vec2.crossNumVec2(wB, this.m_rB);\n Cdot.add(vB);\n\n Cdot.addCombine(1, this.m_C, this.m_gamma, this.m_impulse);\n Cdot.neg();\n\n let impulse = Mat22.mulVec2(this.m_mass, Cdot);\n\n const oldImpulse = Vec2.clone(this.m_impulse);\n this.m_impulse.add(impulse);\n const maxImpulse = step.dt * this.m_maxForce;\n this.m_impulse.clamp(maxImpulse);\n impulse = Vec2.sub(this.m_impulse, oldImpulse);\n\n vB.addMul(this.m_invMassB, impulse);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n\n velocity.v.setVec2(vB);\n velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n\n\n/**\n * Pulley joint definition. This requires two ground anchors, two dynamic body\n * anchor points, and a pulley ratio.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface PulleyJointOpt extends JointOpt {\n}\n\n/**\n * Pulley joint definition. This requires two ground anchors, two dynamic body\n * anchor points, and a pulley ratio.\n */\nexport interface PulleyJointDef extends JointDef, PulleyJointOpt {\n /**\n * The first ground anchor in world coordinates. This point never moves.\n */\n groundAnchorA: Vec2Value;\n /**\n * The second ground anchor in world coordinates. This point never moves.\n */\n groundAnchorB: Vec2Value;\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The reference length for the segment attached to bodyA.\n */\n lengthA: number;\n /**\n * The reference length for the segment attached to bodyB.\n */\n lengthB: number;\n /**\n * The pulley ratio, used to simulate a block-and-tackle.\n */\n ratio: number;\n\n /** @hidden */ anchorA?: Vec2Value;\n /** @hidden */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n collideConnected : true\n};\n\ndeclare module \"./PulleyJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PulleyJoint(def: PulleyJointDef): PulleyJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PulleyJoint(def: PulleyJointOpt, bodyA: Body, bodyB: Body, groundA: Vec2Value, groundB: Vec2Value, anchorA: Vec2Value, anchorB: Vec2Value, ratio: number): PulleyJoint;\n}\n\n/**\n * The pulley joint is connected to two bodies and two fixed ground points. The\n * pulley supports a ratio such that: length1 + ratio * length2 <= constant\n *\n * Yes, the force transmitted is scaled by the ratio.\n *\n * Warning: the pulley joint can get a bit squirrelly by itself. They often work\n * better when combined with prismatic joints. You should also cover the the\n * anchor points with static shapes to prevent one side from going to zero\n * length.\n */\n// @ts-expect-error\nexport class PulleyJoint extends Joint {\n static TYPE = \"pulley-joint\" as const;\n // static MIN_PULLEY_LENGTH: number = 2.0; // TODO where this is used?\n\n /** @internal */ m_type: \"pulley-joint\";\n /** @internal */ m_groundAnchorA: Vec2;\n /** @internal */ m_groundAnchorB: Vec2;\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_lengthA: number;\n /** @internal */ m_lengthB: number;\n /** @internal */ m_ratio: number;\n /** @internal */ m_constant: number;\n /** @internal */ m_impulse: number;\n\n // Solver temp\n /** @internal */ m_uA: Vec2;\n /** @internal */ m_uB: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: number;\n\n constructor(def: PulleyJointDef);\n constructor(def: PulleyJointOpt, bodyA: Body, bodyB: Body, groundA?: Vec2Value, groundB?: Vec2Value, anchorA?: Vec2Value, anchorB?: Vec2Value, ratio?: number);\n constructor(def: PulleyJointDef, bodyA?: Body, bodyB?: Body, groundA?: Vec2Value, groundB?: Vec2Value, anchorA?: Vec2Value, anchorB?: Vec2Value, ratio?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PulleyJoint)) {\n return new PulleyJoint(def, bodyA, bodyB, groundA, groundB, anchorA, anchorB, ratio);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = PulleyJoint.TYPE;\n this.m_groundAnchorA = Vec2.clone(groundA ? groundA : def.groundAnchorA || Vec2.neo(-1.0, 1.0));\n this.m_groundAnchorB = Vec2.clone(groundB ? groundB : def.groundAnchorB || Vec2.neo(1.0, 1.0));\n this.m_localAnchorA = Vec2.clone(anchorA ? bodyA.getLocalPoint(anchorA) : def.localAnchorA || Vec2.neo(-1.0, 0.0));\n this.m_localAnchorB = Vec2.clone(anchorB ? bodyB.getLocalPoint(anchorB) : def.localAnchorB || Vec2.neo(1.0, 0.0));\n this.m_lengthA = Number.isFinite(def.lengthA) ? def.lengthA : Vec2.distance(anchorA, groundA);\n this.m_lengthB = Number.isFinite(def.lengthB) ? def.lengthB : Vec2.distance(anchorB, groundB);\n this.m_ratio = Number.isFinite(ratio) ? ratio : def.ratio;\n\n if (_ASSERT) console.assert(ratio > EPSILON);\n\n this.m_constant = this.m_lengthA + this.m_ratio * this.m_lengthB;\n\n this.m_impulse = 0.0;\n\n // Pulley:\n // length1 = norm(p1 - s1)\n // length2 = norm(p2 - s2)\n // C0 = (length1 + ratio * length2)_initial\n // C = C0 - (length1 + ratio * length2)\n // u1 = (p1 - s1) / norm(p1 - s1)\n // u2 = (p2 - s2) / norm(p2 - s2)\n // Cdot = -dot(u1, v1 + cross(w1, r1)) - ratio * dot(u2, v2 + cross(w2, r2))\n // J = -[u1 cross(r1, u1) ratio * u2 ratio * cross(r2, u2)]\n // K = J * invM * JT\n // = invMass1 + invI1 * cross(r1, u1)^2 + ratio^2 * (invMass2 + invI2 *\n // cross(r2, u2)^2)\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n groundAnchorA: this.m_groundAnchorA,\n groundAnchorB: this.m_groundAnchorB,\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n lengthA: this.m_lengthA,\n lengthB: this.m_lengthB,\n ratio: this.m_ratio,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): PulleyJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new PulleyJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Vec2.isValid(def.groundAnchorA)) {\n this.m_groundAnchorA.set(def.groundAnchorA);\n }\n if (Vec2.isValid(def.groundAnchorB)) {\n this.m_groundAnchorB.set(def.groundAnchorB);\n }\n if (Vec2.isValid(def.localAnchorA)) {\n this.m_localAnchorA.set(def.localAnchorA);\n } else if (Vec2.isValid(def.anchorA)) {\n this.m_localAnchorA.set(this.m_bodyA.getLocalPoint(def.anchorA));\n }\n if (Vec2.isValid(def.localAnchorB)) {\n this.m_localAnchorB.set(def.localAnchorB);\n } else if (Vec2.isValid(def.anchorB)) {\n this.m_localAnchorB.set(this.m_bodyB.getLocalPoint(def.anchorB));\n }\n if (Number.isFinite(def.lengthA)) {\n this.m_lengthA = def.lengthA;\n }\n if (Number.isFinite(def.lengthB)) {\n this.m_lengthB = def.lengthB;\n }\n if (Number.isFinite(def.ratio)) {\n this.m_ratio = def.ratio;\n }\n }\n\n /**\n * Get the first ground anchor.\n */\n getGroundAnchorA(): Vec2 {\n return this.m_groundAnchorA;\n }\n\n /**\n * Get the second ground anchor.\n */\n getGroundAnchorB(): Vec2 {\n return this.m_groundAnchorB;\n }\n\n /**\n * Get the current length of the segment attached to bodyA.\n */\n getLengthA(): number {\n return this.m_lengthA;\n }\n\n /**\n * Get the current length of the segment attached to bodyB.\n */\n getLengthB(): number {\n return this.m_lengthB;\n }\n\n /**\n * Get the pulley ratio.\n */\n getRatio(): number {\n return this.m_ratio;\n }\n\n /**\n * Get the current length of the segment attached to bodyA.\n */\n getCurrentLengthA(): number {\n const p = this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n const s = this.m_groundAnchorA;\n return Vec2.distance(p, s);\n }\n\n /**\n * Get the current length of the segment attached to bodyB.\n */\n getCurrentLengthB(): number {\n const p = this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n const s = this.m_groundAnchorB;\n return Vec2.distance(p, s);\n }\n\n /**\n * Shift the origin for any points stored in world coordinates.\n *\n * @param newOrigin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_groundAnchorA.sub(newOrigin);\n this.m_groundAnchorB.sub(newOrigin);\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_uB).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // Get the pulley axes.\n this.m_uA = Vec2.sub(Vec2.add(cA, this.m_rA), this.m_groundAnchorA);\n this.m_uB = Vec2.sub(Vec2.add(cB, this.m_rB), this.m_groundAnchorB);\n\n const lengthA = this.m_uA.length();\n const lengthB = this.m_uB.length();\n\n if (lengthA > 10.0 * Settings.linearSlop) {\n this.m_uA.mul(1.0 / lengthA);\n } else {\n this.m_uA.setZero();\n }\n\n if (lengthB > 10.0 * Settings.linearSlop) {\n this.m_uB.mul(1.0 / lengthB);\n } else {\n this.m_uB.setZero();\n }\n\n // Compute effective mass.\n const ruA = Vec2.crossVec2Vec2(this.m_rA, this.m_uA);\n const ruB = Vec2.crossVec2Vec2(this.m_rB, this.m_uB);\n\n const mA = this.m_invMassA + this.m_invIA * ruA * ruA;\n const mB = this.m_invMassB + this.m_invIB * ruB * ruB;\n\n this.m_mass = mA + this.m_ratio * this.m_ratio * mB;\n\n if (this.m_mass > 0.0) {\n this.m_mass = 1.0 / this.m_mass;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support variable time steps.\n this.m_impulse *= step.dtRatio;\n\n // Warm starting.\n const PA = Vec2.mulNumVec2(-this.m_impulse, this.m_uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * this.m_impulse, this.m_uB);\n\n vA.addMul(this.m_invMassA, PA);\n wA += this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, PA);\n\n vB.addMul(this.m_invMassB, PB);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, PB);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const vpA = Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA));\n const vpB = Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB));\n\n const Cdot = -Vec2.dot(this.m_uA, vpA) - this.m_ratio * Vec2.dot(this.m_uB, vpB);\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n const PA = Vec2.mulNumVec2(-impulse, this.m_uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * impulse, this.m_uB);\n vA.addMul(this.m_invMassA, PA);\n wA += this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, PA);\n vB.addMul(this.m_invMassB, PB);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, PB);\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // Get the pulley axes.\n const uA = Vec2.sub(Vec2.add(cA, this.m_rA), this.m_groundAnchorA);\n const uB = Vec2.sub(Vec2.add(cB, this.m_rB), this.m_groundAnchorB);\n\n const lengthA = uA.length();\n const lengthB = uB.length();\n\n if (lengthA > 10.0 * Settings.linearSlop) {\n uA.mul(1.0 / lengthA);\n } else {\n uA.setZero();\n }\n\n if (lengthB > 10.0 * Settings.linearSlop) {\n uB.mul(1.0 / lengthB);\n } else {\n uB.setZero();\n }\n\n // Compute effective mass.\n const ruA = Vec2.crossVec2Vec2(rA, uA);\n const ruB = Vec2.crossVec2Vec2(rB, uB);\n\n const mA = this.m_invMassA + this.m_invIA * ruA * ruA;\n const mB = this.m_invMassB + this.m_invIB * ruB * ruB;\n\n let mass = mA + this.m_ratio * this.m_ratio * mB;\n\n if (mass > 0.0) {\n mass = 1.0 / mass;\n }\n\n const C = this.m_constant - lengthA - this.m_ratio * lengthB;\n const linearError = math_abs(C);\n\n const impulse = -mass * C;\n\n const PA = Vec2.mulNumVec2(-impulse, uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * impulse, uB);\n\n cA.addMul(this.m_invMassA, PA);\n aA += this.m_invIA * Vec2.crossVec2Vec2(rA, PA);\n cB.addMul(this.m_invMassB, PB);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, PB);\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return linearError < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_min = Math.min;\n\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3,\n}\n\n/**\n * Rope joint definition. This requires two body anchor points and a maximum\n * lengths. Note: by default the connected objects will not collide. see\n * collideConnected in JointDef.\n */\nexport interface RopeJointOpt extends JointOpt {\n /**\n * The maximum length of the rope.\n * Warning: this must be larger than linearSlop or the joint will have no effect.\n */\n maxLength?: number;\n}\n\n/**\n * Rope joint definition. This requires two body anchor points and a maximum\n * lengths. Note: by default the connected objects will not collide. see\n * collideConnected in JointDef.\n */\nexport interface RopeJointDef extends JointDef, RopeJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxLength : 0.0,\n};\n\ndeclare module \"./RopeJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RopeJoint(def: RopeJointDef): RopeJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RopeJoint(def: RopeJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): RopeJoint;\n}\n\n/**\n * A rope joint enforces a maximum distance between two points on two bodies. It\n * has no other effect.\n *\n * Warning: if you attempt to change the maximum length during the simulation\n * you will get some non-physical behavior.\n *\n * A model that would allow you to dynamically modify the length would have some\n * sponginess, so I chose not to implement it that way. See {@link DistanceJoint} if you\n * want to dynamically control length.\n */\n// @ts-expect-error\nexport class RopeJoint extends Joint {\n static TYPE = \"rope-joint\" as const;\n\n /** @internal */ m_type: \"rope-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n\n /** @internal */ m_maxLength: number;\n\n /** @internal */ m_mass: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_length: number;\n /** @internal */ m_state: number; // TODO enum\n\n // Solver temp\n /** @internal */ m_u: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n\n constructor(def: RopeJointDef);\n constructor(def: RopeJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: RopeJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof RopeJoint)) {\n return new RopeJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = RopeJoint.TYPE;\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.neo(-1.0, 0.0));\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.neo(1.0, 0.0));\n\n this.m_maxLength = def.maxLength;\n\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n this.m_length = 0.0;\n this.m_state = LimitState.inactiveLimit;\n\n // Limit:\n // C = norm(pB - pA) - L\n // u = (pB - pA) / norm(pB - pA)\n // Cdot = dot(u, vB + cross(wB, rB) - vA - cross(wA, rA))\n // J = [-u -cross(rA, u) u cross(rB, u)]\n // K = J * invM * JT\n // = invMassA + invIA * cross(rA, u)^2 + invMassB + invIB * cross(rB, u)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n maxLength: this.m_maxLength,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): RopeJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new RopeJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.maxLength)) {\n this.m_maxLength = def.maxLength;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the maximum length of the rope.\n */\n setMaxLength(length: number): void {\n this.m_maxLength = length;\n }\n\n /**\n * Get the maximum length of the rope.\n */\n getMaxLength(): number {\n return this.m_maxLength;\n }\n\n getLimitState(): number {\n // TODO LimitState\n return this.m_state;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_u).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n this.m_rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n this.m_u = Vec2.zero();\n this.m_u.addCombine(1, cB, 1, this.m_rB);\n this.m_u.subCombine(1, cA, 1, this.m_rA);\n\n this.m_length = this.m_u.length();\n\n const C = this.m_length - this.m_maxLength;\n if (C > 0.0) {\n this.m_state = LimitState.atUpperLimit;\n } else {\n this.m_state = LimitState.inactiveLimit;\n }\n\n if (this.m_length > Settings.linearSlop) {\n this.m_u.mul(1.0 / this.m_length);\n } else {\n this.m_u.setZero();\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n return;\n }\n\n // Compute effective mass.\n const crA = Vec2.crossVec2Vec2(this.m_rA, this.m_u);\n const crB = Vec2.crossVec2Vec2(this.m_rB, this.m_u);\n const invMass = this.m_invMassA + this.m_invIA * crA * crA + this.m_invMassB + this.m_invIB * crB * crB;\n\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n\n if (step.warmStarting) {\n // Scale the impulse to support a variable time step.\n this.m_impulse *= step.dtRatio;\n\n const P = Vec2.mulNumVec2(this.m_impulse, this.m_u);\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Cdot = dot(u, v + cross(w, r))\n const vpA = Vec2.addCrossNumVec2(vA, wA, this.m_rA);\n const vpB = Vec2.addCrossNumVec2(vB, wB, this.m_rB);\n const C = this.m_length - this.m_maxLength;\n let Cdot = Vec2.dot(this.m_u, Vec2.sub(vpB, vpA));\n\n // Predictive constraint.\n if (C < 0.0) {\n Cdot += step.inv_dt * C;\n }\n\n let impulse = -this.m_mass * Cdot;\n const oldImpulse = this.m_impulse;\n this.m_impulse = math_min(0.0, this.m_impulse + impulse);\n impulse = this.m_impulse - oldImpulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_u);\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n const u = Vec2.zero();\n u.addCombine(1, cB, 1, rB);\n u.subCombine(1, cA, 1, rA);\n\n const length = u.normalize();\n let C = length - this.m_maxLength;\n\n C = clamp(C, 0.0, Settings.maxLinearCorrection);\n\n const impulse = -this.m_mass * C;\n const P = Vec2.mulNumVec2(impulse, u);\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * Vec2.crossVec2Vec2(rA, P);\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, P);\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return length - this.m_maxLength < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Weld joint definition. You need to specify local anchor points where they are\n * attached and the relative body angle. The position of the anchor points is\n * important for computing the reaction torque.\n */\nexport interface WeldJointOpt extends JointOpt {\n /**\n * The mass-spring-damper frequency in Hertz. Rotation only. Disable softness\n * with a value of 0.\n */\n frequencyHz?: number;\n /**\n * The damping ratio. 0 = no damping, 1 = critical damping.\n */\n dampingRatio?: number;\n /**\n * The bodyB angle minus bodyA angle in the reference state (radians).\n */\n referenceAngle?: number;\n}\n\n/**\n * Weld joint definition. You need to specify local anchor points where they are\n * attached and the relative body angle. The position of the anchor points is\n * important for computing the reaction torque.\n */\nexport interface WeldJointDef extends JointDef, WeldJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n frequencyHz : 0.0,\n dampingRatio : 0.0,\n};\n\ndeclare module \"./WeldJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WeldJoint(def: WeldJointDef): WeldJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WeldJoint(def: WeldJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): WeldJoint;\n}\n\n/**\n * A weld joint essentially glues two bodies together. A weld joint may distort\n * somewhat because the island constraint solver is approximate.\n */\n// @ts-expect-error\nexport class WeldJoint extends Joint {\n static TYPE = \"weld-joint\" as const;\n\n /** @internal */ m_type: \"weld-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngle: number;\n\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n\n /** @internal */ m_impulse: Vec3;\n\n /** @internal */ m_bias: number;\n /** @internal */ m_gamma: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: Mat33;\n\n constructor(def: WeldJointDef);\n constructor(def: WeldJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: WeldJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof WeldJoint)) {\n return new WeldJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = WeldJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n this.m_referenceAngle = Number.isFinite(def.referenceAngle) ? def.referenceAngle : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_impulse = new Vec3();\n\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n\n // Solver temp\n // todo: do we need to initialize?\n // this.m_rA;\n // this.m_rB;\n // this.m_localCenterA;\n // this.m_localCenterB;\n // this.m_invMassA;\n // this.m_invMassB;\n // this.m_invIA;\n // this.m_invIB;\n this.m_mass = new Mat33();\n\n // Point-to-point constraint\n // C = p2 - p1\n // Cdot = v2 - v1\n // / = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Angle constraint\n // C = angle2 - angle1 - referenceAngle\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): WeldJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new WeldJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Set frequency in Hz.\n */\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n /**\n * Get frequency in Hz.\n */\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set damping ratio.\n */\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n /**\n * Get damping ratio.\n */\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.neo(this.m_impulse.x, this.m_impulse.y).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.z;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat33();\n K.ex.x = mA + mB + this.m_rA.y * this.m_rA.y * iA + this.m_rB.y * this.m_rB.y\n * iB;\n K.ey.x = -this.m_rA.y * this.m_rA.x * iA - this.m_rB.y * this.m_rB.x * iB;\n K.ez.x = -this.m_rA.y * iA - this.m_rB.y * iB;\n K.ex.y = K.ey.x;\n K.ey.y = mA + mB + this.m_rA.x * this.m_rA.x * iA + this.m_rB.x * this.m_rB.x\n * iB;\n K.ez.y = this.m_rA.x * iA + this.m_rB.x * iB;\n K.ex.z = K.ez.x;\n K.ey.z = K.ez.y;\n K.ez.z = iA + iB;\n\n if (this.m_frequencyHz > 0.0) {\n K.getInverse22(this.m_mass);\n\n let invM = iA + iB;\n const m = invM > 0.0 ? 1.0 / invM : 0.0;\n\n const C = aB - aA - this.m_referenceAngle;\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * m * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = m * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (d + h * k);\n this.m_gamma = this.m_gamma != 0.0 ? 1.0 / this.m_gamma : 0.0;\n this.m_bias = C * h * k * this.m_gamma;\n\n invM += this.m_gamma;\n this.m_mass.ez.z = invM != 0.0 ? 1.0 / invM : 0.0;\n } else if (K.ez.z == 0.0) {\n K.getInverse22(this.m_mass);\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n } else {\n K.getSymInverse33(this.m_mass);\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_impulse.mul(step.dtRatio);\n\n const P = Vec2.neo(this.m_impulse.x, this.m_impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_impulse.z);\n\n } else {\n this.m_impulse.setZero();\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n if (this.m_frequencyHz > 0.0) {\n const Cdot2 = wB - wA;\n\n const impulse2 = -this.m_mass.ez.z * (Cdot2 + this.m_bias + this.m_gamma * this.m_impulse.z);\n this.m_impulse.z += impulse2;\n\n wA -= iA * impulse2;\n wB += iB * impulse2;\n\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n\n const impulse1 = Vec2.neg(Mat33.mulVec2(this.m_mass, Cdot1));\n this.m_impulse.x += impulse1.x;\n this.m_impulse.y += impulse1.y;\n\n const P = Vec2.clone(impulse1);\n\n vA.subMul(mA, P);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(mB, P);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, P);\n } else {\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const Cdot2 = wB - wA;\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const impulse = Vec3.neg(Mat33.mulVec3(this.m_mass, Cdot));\n this.m_impulse.add(impulse);\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + impulse.z);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n let positionError: number;\n let angularError: number;\n\n const K = new Mat33();\n K.ex.x = mA + mB + rA.y * rA.y * iA + rB.y * rB.y * iB;\n K.ey.x = -rA.y * rA.x * iA - rB.y * rB.x * iB;\n K.ez.x = -rA.y * iA - rB.y * iB;\n K.ex.y = K.ey.x;\n K.ey.y = mA + mB + rA.x * rA.x * iA + rB.x * rB.x * iB;\n K.ez.y = rA.x * iA + rB.x * iB;\n K.ex.z = K.ez.x;\n K.ey.z = K.ez.y;\n K.ez.z = iA + iB;\n\n if (this.m_frequencyHz > 0.0) {\n const C1 = Vec2.zero();\n C1.addCombine(1, cB, 1, rB);\n C1.subCombine(1, cA, 1, rA);\n\n positionError = C1.length();\n angularError = 0.0;\n\n const P = Vec2.neg(K.solve22(C1));\n\n cA.subMul(mA, P);\n aA -= iA * Vec2.crossVec2Vec2(rA, P);\n\n cB.addMul(mB, P);\n aB += iB * Vec2.crossVec2Vec2(rB, P);\n } else {\n const C1 = Vec2.zero();\n C1.addCombine(1, cB, 1, rB);\n C1.subCombine(1, cA, 1, rA);\n\n const C2 = aB - aA - this.m_referenceAngle;\n\n positionError = C1.length();\n angularError = math_abs(C2);\n\n const C = new Vec3(C1.x, C1.y, C2);\n\n let impulse = new Vec3();\n if (K.ez.z > 0.0) {\n impulse = Vec3.neg(K.solve33(C));\n } else {\n const impulse2 = Vec2.neg(K.solve22(C1));\n impulse.set(impulse2.x, impulse2.y, 0.0);\n }\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n cA.subMul(mA, P);\n aA -= iA * (Vec2.crossVec2Vec2(rA, P) + impulse.z);\n\n cB.addMul(mB, P);\n aB += iB * (Vec2.crossVec2Vec2(rB, P) + impulse.z);\n }\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return positionError <= Settings.linearSlop && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Wheel joint definition. This requires defining a line of motion using an axis\n * and an anchor point. The definition uses local anchor points and a local axis\n * so that the initial configuration can violate the constraint slightly. The\n * joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface WheelJointOpt extends JointOpt {\n /**\n * Enable/disable the joint motor.\n */\n enableMotor?: boolean;\n /**\n * The maximum motor torque, usually in N-m.\n */\n maxMotorTorque?: number;\n /**\n * The desired motor speed in radians per second.\n */\n motorSpeed?: number;\n /**\n * Suspension frequency, zero indicates no suspension.\n */\n frequencyHz?: number;\n /**\n * Suspension damping ratio, one indicates critical damping.\n */\n dampingRatio?: number;\n}\n\n/**\n * Wheel joint definition. This requires defining a line of motion using an axis\n * and an anchor point. The definition uses local anchor points and a local axis\n * so that the initial configuration can violate the constraint slightly. The\n * joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface WheelJointDef extends JointDef, WheelJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The local translation axis in bodyA.\n */\n localAxisA: Vec2Value;\n\n /** @internal renamed to localAxisA */\n localAxis?: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n enableMotor : false,\n maxMotorTorque : 0.0,\n motorSpeed : 0.0,\n frequencyHz : 2.0,\n dampingRatio : 0.7,\n};\n\ndeclare module \"./WheelJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WheelJoint(def: WheelJointDef): WheelJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WheelJoint(def: WheelJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value, axis: Vec2Value): WheelJoint;\n}\n\n/**\n * A wheel joint. This joint provides two degrees of freedom: translation along\n * an axis fixed in bodyA and rotation in the plane. In other words, it is a\n * point to line constraint with a rotational motor and a linear spring/damper.\n * This joint is designed for vehicle suspensions.\n */\n// @ts-expect-error\nexport class WheelJoint extends Joint {\n static TYPE = \"wheel-joint\" as const;\n\n /** @internal */ m_type: \"wheel-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_localXAxisA: Vec2;\n /** @internal */ m_localYAxisA: Vec2;\n\n /** @internal */ m_mass: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_motorMass: number;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_springMass: number;\n /** @internal */ m_springImpulse: number;\n\n /** @internal */ m_maxMotorTorque: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableMotor: boolean;\n\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n\n /** @internal */ m_bias: number;\n /** @internal */ m_gamma: number;\n\n // Solver temp\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n\n /** @internal */ m_ax: Vec2;\n /** @internal */ m_ay: Vec2;\n /** @internal */ m_sAx: number;\n /** @internal */ m_sBx: number;\n /** @internal */ m_sAy: number;\n /** @internal */ m_sBy: number;\n\n constructor(def: WheelJointDef);\n constructor(def: WheelJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value, axis?: Vec2Value);\n constructor(def: WheelJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value, axis?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof WheelJoint)) {\n return new WheelJoint(def, bodyA, bodyB, anchor, axis);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_ax = Vec2.zero();\n this.m_ay = Vec2.zero();\n\n this.m_type = WheelJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n\n if (Vec2.isValid(axis)) {\n this.m_localXAxisA = bodyA.getLocalVector(axis);\n } else if (Vec2.isValid(def.localAxisA)) {\n this.m_localXAxisA = Vec2.clone(def.localAxisA);\n } else if (Vec2.isValid(def.localAxis)) {\n // localAxis is renamed to localAxisA, this is for backward compatibility\n this.m_localXAxisA = Vec2.clone(def.localAxis);\n } else {\n this.m_localXAxisA = Vec2.neo(1.0, 0.0);\n }\n\n this.m_localYAxisA = Vec2.crossNumVec2(1.0, this.m_localXAxisA);\n\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n this.m_springMass = 0.0;\n this.m_springImpulse = 0.0;\n\n this.m_maxMotorTorque = def.maxMotorTorque;\n this.m_motorSpeed = def.motorSpeed;\n this.m_enableMotor = def.enableMotor;\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n\n // Linear constraint (point-to-line)\n // d = pB - pA = xB + rB - xA - rA\n // C = dot(ay, d)\n // Cdot = dot(d, cross(wA, ay)) + dot(ay, vB + cross(wB, rB) - vA - cross(wA,\n // rA))\n // = -dot(ay, vA) - dot(cross(d + rA, ay), wA) + dot(ay, vB) + dot(cross(rB,\n // ay), vB)\n // J = [-ay, -cross(d + rA, ay), ay, cross(rB, ay)]\n\n // Spring linear constraint\n // C = dot(ax, d)\n // Cdot = = -dot(ax, vA) - dot(cross(d + rA, ax), wA) + dot(ax, vB) +\n // dot(cross(rB, ax), vB)\n // J = [-ax -cross(d+rA, ax) ax cross(rB, ax)]\n\n // Motor rotational constraint\n // Cdot = wB - wA\n // J = [0 0 -1 0 0 1]\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n enableMotor: this.m_enableMotor,\n maxMotorTorque: this.m_maxMotorTorque,\n motorSpeed: this.m_motorSpeed,\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n localAxisA: this.m_localXAxisA,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): WheelJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new WheelJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (def.localAxisA) {\n this.m_localXAxisA.setVec2(def.localAxisA);\n this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1.0, def.localAxisA));\n }\n if (def.enableMotor !== undefined) {\n this.m_enableMotor = def.enableMotor;\n }\n if (Number.isFinite(def.maxMotorTorque)) {\n this.m_maxMotorTorque = def.maxMotorTorque;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * The local joint axis relative to bodyA.\n */\n getLocalAxisA(): Vec2 {\n return this.m_localXAxisA;\n }\n\n /**\n * Get the current joint translation, usually in meters.\n */\n getJointTranslation(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n\n const pA = bA.getWorldPoint(this.m_localAnchorA);\n const pB = bB.getWorldPoint(this.m_localAnchorB);\n const d = Vec2.sub(pB, pA);\n const axis = bA.getWorldVector(this.m_localXAxisA);\n\n const translation = Vec2.dot(d, axis);\n return translation;\n }\n\n /**\n * Get the current joint translation speed, usually in meters per second.\n */\n getJointSpeed(): number {\n const wA = this.m_bodyA.m_angularVelocity;\n const wB = this.m_bodyB.m_angularVelocity;\n return wB - wA;\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Set the motor speed, usually in radians per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Get the motor speed, usually in radians per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Set/Get the maximum motor force, usually in N-m.\n */\n setMaxMotorTorque(torque: number): void {\n if (torque == this.m_maxMotorTorque) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorTorque = torque;\n }\n\n getMaxMotorTorque(): number {\n return this.m_maxMotorTorque;\n }\n\n /**\n * Get the current motor torque given the inverse time step, usually in N-m.\n */\n getMotorTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Set/Get the spring frequency in hertz. Setting the frequency to zero disables\n * the spring.\n */\n setSpringFrequencyHz(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n getSpringFrequencyHz(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set/Get the spring damping ratio\n */\n setSpringDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n getSpringDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.combine(this.m_impulse, this.m_ay, this.m_springImpulse, this.m_ax).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective masses.\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n // Point to line constraint\n {\n this.m_ay = Rot.mulVec2(qA, this.m_localYAxisA);\n this.m_sAy = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_ay);\n this.m_sBy = Vec2.crossVec2Vec2(rB, this.m_ay);\n\n this.m_mass = mA + mB + iA * this.m_sAy * this.m_sAy + iB * this.m_sBy\n * this.m_sBy;\n\n if (this.m_mass > 0.0) {\n this.m_mass = 1.0 / this.m_mass;\n }\n }\n\n // Spring constraint\n this.m_springMass = 0.0;\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n if (this.m_frequencyHz > 0.0) {\n this.m_ax = Rot.mulVec2(qA, this.m_localXAxisA);\n this.m_sAx = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_ax);\n this.m_sBx = Vec2.crossVec2Vec2(rB, this.m_ax);\n\n const invMass = mA + mB + iA * this.m_sAx * this.m_sAx + iB * this.m_sBx\n * this.m_sBx;\n\n if (invMass > 0.0) {\n this.m_springMass = 1.0 / invMass;\n\n const C = Vec2.dot(d, this.m_ax);\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const damp = 2.0 * this.m_springMass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = this.m_springMass * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (damp + h * k);\n if (this.m_gamma > 0.0) {\n this.m_gamma = 1.0 / this.m_gamma;\n }\n\n this.m_bias = C * h * k * this.m_gamma;\n\n this.m_springMass = invMass + this.m_gamma;\n if (this.m_springMass > 0.0) {\n this.m_springMass = 1.0 / this.m_springMass;\n }\n }\n } else {\n this.m_springImpulse = 0.0;\n }\n\n // Rotational motor\n if (this.m_enableMotor) {\n this.m_motorMass = iA + iB;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n } else {\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n }\n\n if (step.warmStarting) {\n // Account for variable time step.\n this.m_impulse *= step.dtRatio;\n this.m_springImpulse *= step.dtRatio;\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.combine(this.m_impulse, this.m_ay, this.m_springImpulse, this.m_ax);\n const LA = this.m_impulse * this.m_sAy + this.m_springImpulse * this.m_sAx + this.m_motorImpulse;\n const LB = this.m_impulse * this.m_sBy + this.m_springImpulse * this.m_sBx + this.m_motorImpulse;\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * LA;\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * LB;\n\n } else {\n this.m_impulse = 0.0;\n this.m_springImpulse = 0.0;\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Solve spring constraint\n {\n const Cdot = Vec2.dot(this.m_ax, vB) - Vec2.dot(this.m_ax, vA) + this.m_sBx * wB - this.m_sAx * wA;\n const impulse = -this.m_springMass * (Cdot + this.m_bias + this.m_gamma * this.m_springImpulse);\n this.m_springImpulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_ax);\n const LA = impulse * this.m_sAx;\n const LB = impulse * this.m_sBx;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n // Solve rotational motor constraint\n {\n const Cdot = wB - wA - this.m_motorSpeed;\n let impulse = -this.m_motorMass * Cdot;\n\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorTorque;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve point to line constraint\n {\n const Cdot = Vec2.dot(this.m_ay, vB) - Vec2.dot(this.m_ay, vA) + this.m_sBy * wB - this.m_sAy * wA;\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_ay);\n const LA = impulse * this.m_sAy;\n const LB = impulse * this.m_sBy;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n const ay = Rot.mulVec2(qA, this.m_localYAxisA);\n\n const sAy = Vec2.crossVec2Vec2(Vec2.add(d, rA), ay);\n const sBy = Vec2.crossVec2Vec2(rB, ay);\n\n const C = Vec2.dot(d, ay);\n\n const k = this.m_invMassA + this.m_invMassB + this.m_invIA * this.m_sAy * this.m_sAy + this.m_invIB * this.m_sBy * this.m_sBy;\n\n const impulse = k != 0.0 ? -C / k : 0.0;\n\n const P = Vec2.mulNumVec2(impulse, ay);\n const LA = impulse * sAy;\n const LB = impulse * sBy;\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * LA;\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * LB;\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return math_abs(C) <= Settings.linearSlop;\n }\n\n}\n","import { World } from \"../dynamics/World\";\nimport { Body } from \"../dynamics/Body\";\nimport { Joint } from \"../dynamics/Joint\";\nimport { Fixture } from \"../dynamics/Fixture\";\nimport { Shape } from \"../collision/Shape\";\nimport { Vec2 } from \"../common/Vec2\";\nimport { Vec3 } from \"../common/Vec3\";\nimport { ChainShape } from \"../collision/shape/ChainShape\";\n// import { BoxShape } from \"../collision/shape/BoxShape\";\nimport { EdgeShape } from \"../collision/shape/EdgeShape\";\nimport { PolygonShape } from \"../collision/shape/PolygonShape\";\nimport { CircleShape } from \"../collision/shape/CircleShape\";\nimport { DistanceJoint } from \"../dynamics/joint/DistanceJoint\";\nimport { FrictionJoint } from \"../dynamics/joint/FrictionJoint\";\nimport { GearJoint } from \"../dynamics/joint/GearJoint\";\nimport { MotorJoint } from \"../dynamics/joint/MotorJoint\";\nimport { MouseJoint } from \"../dynamics/joint/MouseJoint\";\nimport { PrismaticJoint } from \"../dynamics/joint/PrismaticJoint\";\nimport { PulleyJoint } from \"../dynamics/joint/PulleyJoint\";\nimport { RevoluteJoint } from \"../dynamics/joint/RevoluteJoint\";\nimport { RopeJoint } from \"../dynamics/joint/RopeJoint\";\nimport { WeldJoint } from \"../dynamics/joint/WeldJoint\";\nimport { WheelJoint } from \"../dynamics/joint/WheelJoint\";\n\nlet SID = 0;\n\n// Classes to be serialized as reference objects\nconst SERIALIZE_REF_TYPES = {\n \"World\": World,\n \"Body\": Body,\n \"Joint\": Joint,\n \"Fixture\": Fixture,\n \"Shape\": Shape,\n};\n\n// For deserializing reference objects by reference type\nconst DESERIALIZE_BY_REF_TYPE = {\n \"Vec2\": Vec2,\n \"Vec3\": Vec3,\n \"World\": World,\n \"Body\": Body,\n \"Joint\": Joint,\n \"Fixture\": Fixture,\n \"Shape\": Shape,\n};\n\n// For deserializing data objects by type field\nconst DESERIALIZE_BY_TYPE_FIELD = {\n [Body.STATIC]: Body,\n [Body.DYNAMIC]: Body,\n [Body.KINEMATIC]: Body,\n [ChainShape.TYPE]: ChainShape,\n // [BoxShape.TYPE]: BoxShape,\n [PolygonShape.TYPE]: PolygonShape,\n [EdgeShape.TYPE]: EdgeShape,\n [CircleShape.TYPE]: CircleShape,\n [DistanceJoint.TYPE]: DistanceJoint,\n [FrictionJoint.TYPE]: FrictionJoint,\n [GearJoint.TYPE]: GearJoint,\n [MotorJoint.TYPE]: MotorJoint,\n [MouseJoint.TYPE]: MouseJoint,\n [PrismaticJoint.TYPE]: PrismaticJoint,\n [PulleyJoint.TYPE]: PulleyJoint,\n [RevoluteJoint.TYPE]: RevoluteJoint,\n [RopeJoint.TYPE]: RopeJoint,\n [WeldJoint.TYPE]: WeldJoint,\n [WheelJoint.TYPE]: WheelJoint,\n};\n\n// dummy types\ntype DataType = any;\ntype ObjectType = any;\ntype ClassName = any;\n\ntype SerializedType = object[];\n\ntype RefType = {\n refIndex: number,\n refType: string,\n};\n\ntype SerializerOptions = {\n rootClass: ClassName,\n preSerialize?: (obj: ObjectType) => DataType,\n postSerialize?: (data: DataType, obj: any) => DataType,\n preDeserialize?: (data: DataType) => DataType,\n postDeserialize?: (obj: ObjectType, data: DataType) => ObjectType,\n};\n\nconst DEFAULT_OPTIONS: SerializerOptions = {\n rootClass: World,\n preSerialize: function(obj) { return obj; },\n postSerialize: function(data, obj) { return data; },\n preDeserialize: function(data: DataType) { return data; },\n postDeserialize: function(obj, data) { return obj; },\n};\n\ntype DeserializeChildCallback = (classHint: any, obj: any, context: any) => any;\ntype ClassDeserializerMethod = (data: any, context: any, deserialize: DeserializeChildCallback) => any;\n\nexport class Serializer {\n private options: SerializerOptions;\n constructor(options: SerializerOptions) {\n this.options = {\n ...DEFAULT_OPTIONS,\n ...options,\n };\n }\n\n toJson = (root: T): SerializedType => {\n const preSerialize = this.options.preSerialize;\n const postSerialize = this.options.postSerialize;\n const json = [];\n\n // Breadth-first ref serialization queue\n const refQueue = [root];\n\n const refMemoById: Record = {};\n\n function addToRefQueue(value: any, typeName: string) {\n value.__sid = value.__sid || ++SID;\n if (!refMemoById[value.__sid]) {\n refQueue.push(value);\n const index = json.length + refQueue.length;\n const ref = {\n refIndex: index,\n refType: typeName\n };\n refMemoById[value.__sid] = ref;\n }\n return refMemoById[value.__sid];\n }\n\n function serializeWithHooks(obj: ObjectType) {\n obj = preSerialize(obj);\n let data = obj._serialize();\n data = postSerialize(data, obj);\n return data;\n }\n\n // traverse the object graph\n // ref objects are pushed into the queue\n // other objects are serialize in-place \n function traverse(value: any, noRefType = false) {\n if (typeof value !== \"object\" || value === null) {\n return value;\n }\n // object with _serialize function\n if (typeof value._serialize === \"function\") {\n if (!noRefType) {\n for (const typeName in SERIALIZE_REF_TYPES) {\n if (value instanceof SERIALIZE_REF_TYPES[typeName]) {\n return addToRefQueue(value, typeName);\n }\n }\n }\n // object with _serialize function\n value = serializeWithHooks(value);\n }\n // recursive for arrays any objects\n if (Array.isArray(value)) {\n const newValue = [];\n for (let key = 0; key < value.length; key++) {\n newValue[key] = traverse(value[key]);\n }\n value = newValue;\n\n } else {\n const newValue = {};\n for (const key in value) {\n if (value.hasOwnProperty(key)) {\n newValue[key] = traverse(value[key]);\n }\n }\n value = newValue;\n }\n return value;\n }\n\n while (refQueue.length) {\n const obj = refQueue.shift();\n const str = traverse(obj, true);\n json.push(str);\n }\n\n return json;\n };\n\n fromJson = (json: SerializedType): T => {\n const preDeserialize = this.options.preDeserialize;\n const postDeserialize = this.options.postDeserialize;\n const rootClass = this.options.rootClass;\n\n const deserializedRefMemoByIndex: Record = {};\n\n function deserializeWithHooks(classHint: ClassName, data: DataType, context: any): ObjectType {\n if (!classHint || !classHint._deserialize) {\n classHint = DESERIALIZE_BY_TYPE_FIELD[data.type];\n }\n const deserializer = classHint && classHint._deserialize;\n if (!deserializer) {\n return;\n }\n data = preDeserialize(data);\n const classDeserializeFn = classHint._deserialize as ClassDeserializerMethod;\n let obj = classDeserializeFn(data, context, deserializeChild);\n obj = postDeserialize(obj, data);\n return obj;\n }\n\n /**\n * Recursive callback function to deserialize a child data object or reference object.\n * \n * @param classHint suggested class to deserialize obj to\n * @param dataOrRef data or reference object\n * @param context for example world when deserializing bodies and joints\n */\n function deserializeChild(classHint: ClassName, dataOrRef: DataType | RefType, context: any) {\n const isRefObject = dataOrRef.refIndex && dataOrRef.refType;\n if (!isRefObject) {\n return deserializeWithHooks(classHint, dataOrRef, context); \n }\n const ref = dataOrRef as RefType;\n if (DESERIALIZE_BY_REF_TYPE[ref.refType]) {\n classHint = DESERIALIZE_BY_REF_TYPE[ref.refType];\n }\n const refIndex = ref.refIndex;\n if (!deserializedRefMemoByIndex[refIndex]) {\n const data = json[refIndex];\n const obj = deserializeWithHooks(classHint, data, context);\n deserializedRefMemoByIndex[refIndex] = obj;\n }\n return deserializedRefMemoByIndex[refIndex];\n }\n\n const root = deserializeWithHooks(rootClass, json[0], null);\n\n return root;\n };\n\n static toJson: (root: World) => SerializedType;\n static fromJson: (json: SerializedType) => World;\n}\n\nconst worldSerializer = new Serializer({\n rootClass: World,\n});\n\nSerializer.fromJson = worldSerializer.fromJson;\nSerializer.toJson = worldSerializer.toJson;\n","import type { AABBValue } from \"../collision/AABB\";\nimport type { World } from \"../dynamics/World\";\nimport type { Joint } from \"../dynamics/Joint\";\nimport type { Fixture } from \"../dynamics/Fixture\";\nimport type { Body } from \"../dynamics/Body\";\n\nexport interface Style {\n stroke?: string;\n fill?: string;\n lineWidth?: number;\n}\n\ntype KEY = \"0\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" |\n \"8\" | \"9\" | \"A\" | \"B\" | \"C\" | \"D\" | \"E\" | \"F\" | \"G\" |\n \"H\" | \"I\" | \"J\" | \"K\" | \"L\" | \"M\" | \"N\" | \"O\" | \"P\" |\n \"Q\" | \"R\" | \"S\" | \"T\" | \"U\" | \"V\" | \"W\" | \"X\" | \"Y\" |\n \"Z\" | \"right\" | \"left\" | \"up\" | \"down\" | \"fire\";\n\nexport type ActiveKeys = { [key in KEY]?: boolean };\n\ntype TestbedMountOptions = { [key: string]: any };\n\nexport abstract class Testbed {\n /**\n * Mounts testbed. Call start with a world to start simulation and rendering.\n */\n static mount(options?: TestbedMountOptions): Testbed {\n throw new Error(\"Not implemented\");\n }\n\n /**\n * Mounts testbed if needed, then starts simulation and rendering.\n * \n * If you need to customize testbed before starting, first run `const testbed = Testbed.mount()` and then `testbed.start()`.\n */\n static start(world: World): Testbed {\n const testbed = Testbed.mount();\n testbed.start(world);\n return testbed;\n }\n\n /** World viewbox width. */\n width: number = 80;\n\n /** World viewbox height. */\n height: number = 60;\n\n /** World viewbox center vertical offset. */\n x: number = 0;\n\n /** World viewbox center horizontal offset. */\n y: number = -10;\n\n /** @hidden */\n scaleY: number = -1;\n\n /** World simulation step frequency */\n hz: number = 60;\n\n /** World simulation speed, default is 1 */\n speed: number = 1;\n\n background: string = \"#222222\";\n\n mouseForce?: number;\n activeKeys: ActiveKeys = {};\n\n /** callback, to be implemented by user */\n step = (dt: number, t: number): void => {\n return;\n };\n\n /** callback, to be implemented by user */\n keydown = (keyCode: number, label: string): void => {\n return;\n };\n\n /** callback, to be implemented by user */\n keyup = (keyCode: number, label: string): void => {\n return;\n };\n\n abstract status(name: string, value: any): void;\n abstract status(value: object | string): void;\n\n abstract info(text: string): void;\n\n color(r: number, g: number, b: number): string {\n r = r * 256 | 0;\n g = g * 256 | 0;\n b = b * 256 | 0;\n return \"rgb(\" + r + \", \" + g + \", \" + b + \")\";\n }\n\n abstract drawPoint(p: {x: number, y: number}, r: any, color: string): void;\n abstract drawCircle(p: {x: number, y: number}, r: number, color: string): void;\n abstract drawEdge(a: {x: number, y: number}, b: {x: number, y: number}, color: string): void;\n abstract drawSegment(a: {x: number, y: number}, b: {x: number, y: number}, color: string): void;\n abstract drawPolygon(points: Array<{x: number, y: number}>, color: string): void;\n abstract drawAABB(aabb: AABBValue, color: string): void;\n\n abstract start(world: World): void;\n\n abstract findOne(query: string): (Body | Joint | Fixture | null);\n abstract findAll(query: string): (Body | Joint | Fixture)[];\n}\n\ntype TestbedFactoryOptions = string | TestbedMountOptions;\n\n/** @deprecated */\ntype TestbedCallback = (testbed: Testbed) => (World | undefined);\n\n/** @deprecated */\nexport function testbed(callback: TestbedCallback): void;\n/** @deprecated */\nexport function testbed(options: TestbedFactoryOptions, callback: TestbedCallback): void;\n/** @internal */\nexport function testbed(a?: any, b?: any) {\n let callback: TestbedCallback | undefined;\n let options;\n if (typeof a === \"function\") {\n callback = a;\n options = b;\n } else if (typeof b === \"function\") {\n callback = b;\n options = a;\n } else {\n options = a ?? b;\n }\n const testbed = Testbed.mount(options);\n if (callback) {\n // this is for backwards compatibility\n const world = callback(testbed) || (testbed as any).world;\n testbed.start(world);\n } else {\n return testbed;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { Vec2Value } from \"../../common/Vec2\";\nimport { PolygonShape } from \"./PolygonShape\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\ndeclare module \"./BoxShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function BoxShape(halfWidth: number, halfHeight: number, center?: Vec2Value, angle?: number): BoxShape;\n}\n\n/**\n * A rectangle polygon which extend PolygonShape.\n */\n// @ts-expect-error\nexport class BoxShape extends PolygonShape {\n // note that box is serialized/deserialized as polygon\n static TYPE = \"polygon\" as const;\n\n /**\n * \n * @param halfWidth \n * @param halfHeight \n * @param center coordinate of the center of the box relative to the body\n * @param angle angle of the box relative to the body\n */\n constructor(halfWidth: number, halfHeight: number, center?: Vec2Value, angle?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof BoxShape)) {\n return new BoxShape(halfWidth, halfHeight, center, angle);\n }\n\n super();\n\n this._setAsBox(halfWidth, halfHeight, center, angle);\n }\n}\n\nexport const Box = BoxShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { CircleShape } from \"./CircleShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(CircleShape.TYPE, CircleShape.TYPE, CircleCircleContact);\n\n/** @internal */ function CircleCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == CircleShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n CollideCircles(manifold, fixtureA.getShape() as CircleShape, xfA, fixtureB.getShape() as CircleShape, xfB);\n}\n\n/** @internal */ const pA = matrix.vec2(0, 0);\n/** @internal */ const pB = matrix.vec2(0, 0);\n\nexport const CollideCircles = function (manifold: Manifold, circleA: CircleShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n matrix.transformVec2(pA, xfA, circleA.m_p);\n matrix.transformVec2(pB, xfB, circleB.m_p);\n\n const distSqr = matrix.distSqrVec2(pB, pA);\n const rA = circleA.m_radius;\n const rB = circleB.m_radius;\n const radius = rA + rB;\n if (distSqr > radius * radius) {\n return;\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.copyVec2(manifold.localPoint, circleA.m_p);\n matrix.zeroVec2(manifold.localNormal);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { TransformValue } from \"../../common/Transform\";\nimport * as matrix from \"../../common/Matrix\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { EdgeShape } from \"./EdgeShape\";\nimport { ChainShape } from \"./ChainShape\";\nimport { CircleShape } from \"./CircleShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(EdgeShape.TYPE, CircleShape.TYPE, EdgeCircleContact);\nContact.addType(ChainShape.TYPE, CircleShape.TYPE, ChainCircleContact);\n\n/** @internal */ function EdgeCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == EdgeShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n\n const shapeA = fixtureA.getShape() as EdgeShape;\n const shapeB = fixtureB.getShape() as CircleShape;\n\n CollideEdgeCircle(manifold, shapeA, xfA, shapeB, xfB);\n}\n\nfunction ChainCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == ChainShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n\n const chain = fixtureA.getShape() as ChainShape;\n const edge = new EdgeShape();\n chain.getChildEdge(edge, indexA);\n\n const shapeA = edge;\n const shapeB = fixtureB.getShape() as CircleShape;\n\n CollideEdgeCircle(manifold, shapeA, xfA, shapeB, xfB);\n}\n\n/** @internal */ const e = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const e1 = matrix.vec2(0, 0);\n/** @internal */ const e2 = matrix.vec2(0, 0);\n/** @internal */ const Q = matrix.vec2(0, 0);\n/** @internal */ const P = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n\n// Compute contact points for edge versus circle.\n// This accounts for edge connectivity.\nexport const CollideEdgeCircle = function (manifold: Manifold, edgeA: EdgeShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n // Compute circle in frame of edge\n matrix.retransformVec2(Q, xfB, xfA, circleB.m_p);\n\n const A = edgeA.m_vertex1;\n const B = edgeA.m_vertex2;\n matrix.subVec2(e, B, A);\n\n // Barycentric coordinates\n const u = matrix.dotVec2(e, B) - matrix.dotVec2(e, Q);\n const v = matrix.dotVec2(e, Q) - matrix.dotVec2(e, A);\n\n const radius = edgeA.m_radius + circleB.m_radius;\n\n // Region A\n if (v <= 0.0) {\n matrix.copyVec2(P, A);\n const dd = matrix.distSqrVec2(Q, A);\n if (dd > radius * radius) {\n return;\n }\n\n // Is there an edge connected to A?\n if (edgeA.m_hasVertex0) {\n const A1 = edgeA.m_vertex0;\n const B1 = A;\n matrix.subVec2(e1, B1, A1);\n const u1 = matrix.dotVec2(e1, B1) - matrix.dotVec2(e1, Q);\n\n // Is the circle in Region AB of the previous edge?\n if (u1 > 0.0) {\n return;\n }\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.zeroVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, P);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n return;\n }\n\n // Region B\n if (u <= 0.0) {\n matrix.copyVec2(P, B);\n const dd = matrix.distSqrVec2(Q, P);\n if (dd > radius * radius) {\n return;\n }\n\n // Is there an edge connected to B?\n if (edgeA.m_hasVertex3) {\n const B2 = edgeA.m_vertex3;\n const A2 = B;\n matrix.subVec2(e2, B2, A2);\n const v2 = matrix.dotVec2(e2, Q) - matrix.dotVec2(e2, A2);\n\n // Is the circle in Region AB of the next edge?\n if (v2 > 0.0) {\n return;\n }\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.zeroVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, P);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(1, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n\n return;\n }\n\n // Region AB\n const den = matrix.lengthSqrVec2(e);\n if (_ASSERT) console.assert(den > 0.0);\n matrix.combine2Vec2(P, u / den, A, v / den, B);\n const dd = matrix.distSqrVec2(Q, P);\n if (dd > radius * radius) {\n return;\n }\n\n matrix.crossNumVec2(n, 1, e);\n if (matrix.dotVec2(n, Q) - matrix.dotVec2(n, A) < 0.0) {\n matrix.negVec2(n);\n }\n matrix.normalizeVec2(n);\n\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, n);\n matrix.copyVec2(manifold.localPoint, A);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_face, 0, ContactFeatureType.e_vertex);\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { TransformValue } from \"../../common/Transform\";\nimport * as matrix from \"../../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Manifold, clipSegmentToLine, ClipVertex, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/** @internal */ const incidentEdge = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints1 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints2 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipSegmentToLineNormal = matrix.vec2(0, 0);\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const v11 = matrix.vec2(0, 0);\n/** @internal */ const v12 = matrix.vec2(0, 0);\n/** @internal */ const localTangent = matrix.vec2(0, 0);\n/** @internal */ const localNormal = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const tangent = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const normal1 = matrix.vec2(0, 0);\n\n\nContact.addType(PolygonShape.TYPE, PolygonShape.TYPE, PolygonContact);\n\n/** @internal */ function PolygonContact(\n manifold: Manifold,\n xfA: TransformValue,\n fixtureA: Fixture,\n indexA: number,\n xfB: TransformValue,\n fixtureB: Fixture,\n indexB: number,\n): void {\n if (_ASSERT) console.assert(fixtureA.getType() == PolygonShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == PolygonShape.TYPE);\n CollidePolygons(manifold, fixtureA.getShape() as PolygonShape, xfA, fixtureB.getShape() as PolygonShape, xfB);\n}\n\n/** @internal */ interface MaxSeparation {\n maxSeparation: number;\n bestIndex: number;\n}\n\n/**\n * Find the max separation between poly1 and poly2 using edge normals from\n * poly1.\n */\n/** @internal */ function findMaxSeparation(\n poly1: PolygonShape,\n xf1: TransformValue,\n poly2: PolygonShape,\n xf2: TransformValue,\n output: MaxSeparation,\n): void {\n const count1 = poly1.m_count;\n const count2 = poly2.m_count;\n const n1s = poly1.m_normals;\n const v1s = poly1.m_vertices;\n const v2s = poly2.m_vertices;\n\n matrix.detransformTransform(xf, xf2, xf1);\n\n let bestIndex = 0;\n let maxSeparation = -Infinity;\n for (let i = 0; i < count1; ++i) {\n // Get poly1 normal in frame2.\n matrix.rotVec2(n, xf.q, n1s[i]);\n matrix.transformVec2(v1, xf, v1s[i]);\n\n // Find deepest point for normal i.\n let si = Infinity;\n for (let j = 0; j < count2; ++j) {\n const sij = matrix.dotVec2(n, v2s[j]) - matrix.dotVec2(n, v1);\n if (sij < si) {\n si = sij;\n }\n }\n\n if (si > maxSeparation) {\n maxSeparation = si;\n bestIndex = i;\n }\n }\n\n // used to keep last FindMaxSeparation call values\n output.maxSeparation = maxSeparation;\n output.bestIndex = bestIndex;\n}\n\n/** @internal */ function findIncidentEdge(\n clipVertex: ClipVertex[],\n poly1: PolygonShape,\n xf1: TransformValue,\n edge1: number,\n poly2: PolygonShape,\n xf2: TransformValue,\n): void {\n const normals1 = poly1.m_normals;\n\n const count2 = poly2.m_count;\n const vertices2 = poly2.m_vertices;\n const normals2 = poly2.m_normals;\n\n if (_ASSERT) console.assert(0 <= edge1 && edge1 < poly1.m_count);\n\n // Get the normal of the reference edge in poly2's frame.\n matrix.rerotVec2(normal1, xf2.q, xf1.q, normals1[edge1]);\n\n // Find the incident edge on poly2.\n let index = 0;\n let minDot = Infinity;\n for (let i = 0; i < count2; ++i) {\n const dot = matrix.dotVec2(normal1, normals2[i]);\n if (dot < minDot) {\n minDot = dot;\n index = i;\n }\n }\n\n // Build the clip vertices for the incident edge.\n const i1 = index;\n const i2 = i1 + 1 < count2 ? i1 + 1 : 0;\n\n matrix.transformVec2(clipVertex[0].v, xf2, vertices2[i1]);\n clipVertex[0].id.setFeatures(edge1, ContactFeatureType.e_face, i1, ContactFeatureType.e_vertex);\n\n matrix.transformVec2(clipVertex[1].v, xf2, vertices2[i2]);\n clipVertex[1].id.setFeatures(edge1, ContactFeatureType.e_face, i2, ContactFeatureType.e_vertex);\n}\n\n/** @internal */ const maxSeparation = {\n maxSeparation: 0,\n bestIndex: 0,\n};\n\n/**\n *\n * Find edge normal of max separation on A - return if separating axis is found
\n * Find edge normal of max separation on B - return if separation axis is found
\n * Choose reference edge as min(minA, minB)
\n * Find incident edge
\n * Clip\n *\n * The normal points from 1 to 2\n */\nexport const CollidePolygons = function (\n manifold: Manifold,\n polyA: PolygonShape,\n xfA: TransformValue,\n polyB: PolygonShape,\n xfB: TransformValue,\n): void {\n manifold.pointCount = 0;\n const totalRadius = polyA.m_radius + polyB.m_radius;\n\n findMaxSeparation(polyA, xfA, polyB, xfB, maxSeparation);\n const edgeA = maxSeparation.bestIndex;\n const separationA = maxSeparation.maxSeparation;\n if (separationA > totalRadius)\n return;\n\n findMaxSeparation(polyB, xfB, polyA, xfA, maxSeparation);\n const edgeB = maxSeparation.bestIndex;\n const separationB = maxSeparation.maxSeparation;\n if (separationB > totalRadius)\n return;\n\n let poly1: PolygonShape; // reference polygon\n let poly2: PolygonShape; // incident polygon\n let xf1: TransformValue;\n let xf2: TransformValue;\n let edge1: number; // reference edge\n let flip: boolean;\n const k_tol = 0.1 * Settings.linearSlop;\n\n if (separationB > separationA + k_tol) {\n poly1 = polyB;\n poly2 = polyA;\n xf1 = xfB;\n xf2 = xfA;\n edge1 = edgeB;\n manifold.type = ManifoldType.e_faceB;\n flip = true;\n } else {\n poly1 = polyA;\n poly2 = polyB;\n xf1 = xfA;\n xf2 = xfB;\n edge1 = edgeA;\n manifold.type = ManifoldType.e_faceA;\n flip = false;\n }\n\n incidentEdge[0].recycle();\n incidentEdge[1].recycle();\n findIncidentEdge(incidentEdge, poly1, xf1, edge1, poly2, xf2);\n\n const count1 = poly1.m_count;\n const vertices1 = poly1.m_vertices;\n\n const iv1 = edge1;\n const iv2 = edge1 + 1 < count1 ? edge1 + 1 : 0;\n\n matrix.copyVec2(v11, vertices1[iv1]);\n matrix.copyVec2(v12, vertices1[iv2]);\n\n matrix.subVec2(localTangent, v12, v11);\n matrix.normalizeVec2(localTangent);\n\n matrix.crossVec2Num(localNormal, localTangent, 1.0);\n matrix.combine2Vec2(planePoint, 0.5, v11, 0.5, v12);\n\n matrix.rotVec2(tangent, xf1.q, localTangent);\n matrix.crossVec2Num(normal, tangent, 1.0);\n\n matrix.transformVec2(v11, xf1, v11);\n matrix.transformVec2(v12, xf1, v12);\n\n // Face offset.\n const frontOffset = matrix.dotVec2(normal, v11);\n\n // Side offsets, extended by polytope skin thickness.\n const sideOffset1 = -matrix.dotVec2(tangent, v11) + totalRadius;\n const sideOffset2 = matrix.dotVec2(tangent, v12) + totalRadius;\n\n // Clip incident edge against extruded edge1 side edges.\n clipPoints1[0].recycle();\n clipPoints1[1].recycle();\n clipPoints2[0].recycle();\n clipPoints2[1].recycle();\n\n // Clip to box side 1\n matrix.setVec2(clipSegmentToLineNormal, -tangent.x, -tangent.y);\n const np1 = clipSegmentToLine(clipPoints1, incidentEdge, clipSegmentToLineNormal, sideOffset1, iv1);\n\n if (np1 < 2) {\n return;\n }\n\n // Clip to negative box side 1\n matrix.setVec2(clipSegmentToLineNormal, tangent.x, tangent.y);\n const np2 = clipSegmentToLine(clipPoints2, clipPoints1, clipSegmentToLineNormal, sideOffset2, iv2);\n\n if (np2 < 2) {\n return;\n }\n\n // Now clipPoints2 contains the clipped points.\n matrix.copyVec2(manifold.localNormal, localNormal);\n matrix.copyVec2(manifold.localPoint, planePoint);\n\n let pointCount = 0;\n for (let i = 0; i < clipPoints2.length/* maxManifoldPoints */; ++i) {\n const separation = matrix.dotVec2(normal, clipPoints2[i].v) - frontOffset;\n\n if (separation <= totalRadius) {\n const cp = manifold.points[pointCount];\n matrix.detransformVec2(cp.localPoint, xf2, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n if (flip) {\n // Swap features\n cp.id.swapFeatures();\n }\n ++pointCount;\n }\n }\n\n manifold.pointCount = pointCount;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { EPSILON } from \"../../common/Math\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { CircleShape } from \"./CircleShape\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(PolygonShape.TYPE, CircleShape.TYPE, PolygonCircleContact);\n\n/** @internal */ function PolygonCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == PolygonShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n CollidePolygonCircle(manifold, fixtureA.getShape() as PolygonShape, xfA, fixtureB.getShape() as CircleShape, xfB);\n}\n\n/** @internal */ const cLocal = matrix.vec2(0, 0);\n/** @internal */ const faceCenter = matrix.vec2(0, 0);\n\nexport const CollidePolygonCircle = function (manifold: Manifold, polygonA: PolygonShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n // Compute circle position in the frame of the polygon.\n matrix.retransformVec2(cLocal, xfB, xfA, circleB.m_p);\n\n // Find the min separating edge.\n let normalIndex = 0;\n let separation = -Infinity;\n const radius = polygonA.m_radius + circleB.m_radius;\n const vertexCount = polygonA.m_count;\n const vertices = polygonA.m_vertices;\n const normals = polygonA.m_normals;\n\n for (let i = 0; i < vertexCount; ++i) {\n const s = matrix.dotVec2(normals[i], cLocal) - matrix.dotVec2(normals[i], vertices[i]);\n\n if (s > radius) {\n // Early out.\n return;\n }\n\n if (s > separation) {\n separation = s;\n normalIndex = i;\n }\n }\n\n // Vertices that subtend the incident face.\n const vertIndex1 = normalIndex;\n const vertIndex2 = vertIndex1 + 1 < vertexCount ? vertIndex1 + 1 : 0;\n const v1 = vertices[vertIndex1];\n const v2 = vertices[vertIndex2];\n\n // If the center is inside the polygon ...\n if (separation < EPSILON) {\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, normals[normalIndex]);\n matrix.combine2Vec2(manifold.localPoint, 0.5, v1, 0.5, v2);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n return;\n }\n\n // Compute barycentric coordinates\n // u1 = (cLocal - v1) dot (v2 - v1))\n const u1 = matrix.dotVec2(cLocal, v2) - matrix.dotVec2(cLocal, v1) - matrix.dotVec2(v1, v2) + matrix.dotVec2(v1, v1);\n // u2 = (cLocal - v2) dot (v1 - v2)\n const u2 = matrix.dotVec2(cLocal, v1) - matrix.dotVec2(cLocal, v2) - matrix.dotVec2(v2, v1) + matrix.dotVec2(v2, v2);\n if (u1 <= 0.0) {\n if (matrix.distSqrVec2(cLocal, v1) > radius * radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.subVec2(manifold.localNormal, cLocal, v1);\n matrix.normalizeVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, v1);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n } else if (u2 <= 0.0) {\n if (matrix.distSqrVec2(cLocal, v2) > radius * radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.subVec2(manifold.localNormal, cLocal, v2);\n matrix.normalizeVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, v2);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n } else {\n matrix.combine2Vec2(faceCenter, 0.5, v1, 0.5, v2);\n const separation = matrix.dotVec2(cLocal, normals[vertIndex1]) - matrix.dotVec2(faceCenter, normals[vertIndex1]);\n if (separation > radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, normals[vertIndex1]);\n matrix.copyVec2(manifold.localPoint, faceCenter);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n }\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { Manifold, clipSegmentToLine, ClipVertex, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { EdgeShape } from \"./EdgeShape\";\nimport { ChainShape } from \"./ChainShape\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_min = Math.min;\n\nContact.addType(EdgeShape.TYPE, PolygonShape.TYPE, EdgePolygonContact);\nContact.addType(ChainShape.TYPE, PolygonShape.TYPE, ChainPolygonContact);\n\n/** @internal */ function EdgePolygonContact(manifold: Manifold, xfA: TransformValue, fA: Fixture, indexA: number, xfB: TransformValue, fB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fA.getType() == EdgeShape.TYPE);\n if (_ASSERT) console.assert(fB.getType() == PolygonShape.TYPE);\n\n CollideEdgePolygon(manifold, fA.getShape() as EdgeShape, xfA, fB.getShape() as PolygonShape, xfB);\n}\n\n// reused\n/** @internal */ const edge_reuse = new EdgeShape();\n\n/** @internal */ function ChainPolygonContact(manifold: Manifold, xfA: TransformValue, fA: Fixture, indexA: number, xfB: TransformValue, fB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fA.getType() == ChainShape.TYPE);\n if (_ASSERT) console.assert(fB.getType() == PolygonShape.TYPE);\n\n const chain = fA.getShape() as ChainShape;\n chain.getChildEdge(edge_reuse, indexA);\n\n CollideEdgePolygon(manifold, edge_reuse, xfA, fB.getShape() as PolygonShape, xfB);\n}\n\n/** @internal */ enum EPAxisType {\n e_unknown = -1,\n e_edgeA = 1,\n e_edgeB = 2,\n}\n\n// unused?\n/** @internal */ enum VertexType {\n e_isolated = 0,\n e_concave = 1,\n e_convex = 2,\n}\n\n/**\n * This structure is used to keep track of the best separating axis.\n */\n/** @internal */ class EPAxis {\n type: EPAxisType;\n index: number;\n separation: number;\n}\n\n/**\n * This holds polygon B expressed in frame A.\n */\n/** @internal */ class TempPolygon {\n vertices: Vec2Value[] = []; // [Settings.maxPolygonVertices]\n normals: Vec2Value[] = []; // [Settings.maxPolygonVertices];\n count: number = 0;\n constructor() {\n for (let i = 0; i < Settings.maxPolygonVertices; i++) {\n this.vertices.push(matrix.vec2(0, 0));\n this.normals.push(matrix.vec2(0, 0));\n }\n }\n}\n\n/**\n * Reference face used for clipping\n */\n/** @internal */ class ReferenceFace {\n i1: number;\n i2: number;\n readonly v1 = matrix.vec2(0 ,0);\n readonly v2 = matrix.vec2(0 ,0);\n readonly normal = matrix.vec2(0 ,0);\n readonly sideNormal1 = matrix.vec2(0 ,0);\n sideOffset1: number;\n readonly sideNormal2 = matrix.vec2(0 ,0);\n sideOffset2: number;\n recycle() {\n matrix.zeroVec2(this.v1);\n matrix.zeroVec2(this.v2);\n matrix.zeroVec2(this.normal);\n matrix.zeroVec2(this.sideNormal1);\n matrix.zeroVec2(this.sideNormal2);\n }\n}\n\n// reused\n/** @internal */ const clipPoints1 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints2 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const ie = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const edgeAxis = new EPAxis();\n/** @internal */ const polygonAxis = new EPAxis();\n/** @internal */ const polygonBA = new TempPolygon();\n/** @internal */ const rf = new ReferenceFace();\n/** @internal */ const centroidB = matrix.vec2(0, 0);\n/** @internal */ const edge0 = matrix.vec2(0, 0);\n/** @internal */ const edge1 = matrix.vec2(0, 0);\n/** @internal */ const edge2 = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const normal0 = matrix.vec2(0, 0);\n/** @internal */ const normal1 = matrix.vec2(0, 0);\n/** @internal */ const normal2 = matrix.vec2(0, 0);\n/** @internal */ const lowerLimit = matrix.vec2(0, 0);\n/** @internal */ const upperLimit = matrix.vec2(0, 0);\n/** @internal */ const perp = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n\n/**\n * This function collides and edge and a polygon, taking into account edge\n * adjacency.\n */\nexport const CollideEdgePolygon = function (manifold: Manifold, edgeA: EdgeShape, xfA: TransformValue, polygonB: PolygonShape, xfB: TransformValue): void {\n // Algorithm:\n // 1. Classify v1 and v2\n // 2. Classify polygon centroid as front or back\n // 3. Flip normal if necessary\n // 4. Initialize normal range to [-pi, pi] about face normal\n // 5. Adjust normal range according to adjacent edges\n // 6. Visit each separating axes, only accept axes within the range\n // 7. Return if _any_ axis indicates separation\n // 8. Clip\n\n // let m_type1: VertexType;\n // let m_type2: VertexType;\n\n matrix.detransformTransform(xf, xfA, xfB);\n matrix.transformVec2(centroidB, xf, polygonB.m_centroid);\n\n const v0 = edgeA.m_vertex0;\n const v1 = edgeA.m_vertex1;\n const v2 = edgeA.m_vertex2;\n const v3 = edgeA.m_vertex3;\n\n const hasVertex0 = edgeA.m_hasVertex0;\n const hasVertex3 = edgeA.m_hasVertex3;\n\n matrix.subVec2(edge1, v2, v1);\n matrix.normalizeVec2(edge1);\n matrix.setVec2(normal1, edge1.y, -edge1.x);\n const offset1 = matrix.dotVec2(normal1, centroidB) - matrix.dotVec2(normal1, v1);\n let offset0 = 0.0;\n let offset2 = 0.0;\n let convex1 = false;\n let convex2 = false;\n\n matrix.zeroVec2(normal0);\n matrix.zeroVec2(normal2);\n\n // Is there a preceding edge?\n if (hasVertex0) {\n matrix.subVec2(edge0, v1, v0);\n matrix.normalizeVec2(edge0);\n matrix.setVec2(normal0, edge0.y, -edge0.x);\n convex1 = matrix.crossVec2Vec2(edge0, edge1) >= 0.0;\n offset0 = Vec2.dot(normal0, centroidB) - Vec2.dot(normal0, v0);\n }\n\n // Is there a following edge?\n if (hasVertex3) {\n matrix.subVec2(edge2, v3, v2);\n matrix.normalizeVec2(edge2);\n matrix.setVec2(normal2, edge2.y, -edge2.x);\n convex2 = Vec2.crossVec2Vec2(edge1, edge2) > 0.0;\n offset2 = Vec2.dot(normal2, centroidB) - Vec2.dot(normal2, v2);\n }\n\n let front: boolean;\n matrix.zeroVec2(normal);\n matrix.zeroVec2(lowerLimit);\n matrix.zeroVec2(upperLimit);\n\n // Determine front or back collision. Determine collision normal limits.\n if (hasVertex0 && hasVertex3) {\n if (convex1 && convex2) {\n front = offset0 >= 0.0 || offset1 >= 0.0 || offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else if (convex1) {\n front = offset0 >= 0.0 || (offset1 >= 0.0 && offset2 >= 0.0);\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else if (convex2) {\n front = offset2 >= 0.0 || (offset0 >= 0.0 && offset1 >= 0.0);\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n } else {\n front = offset0 >= 0.0 && offset1 >= 0.0 && offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n }\n } else if (hasVertex0) {\n if (convex1) {\n front = offset0 >= 0.0 || offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else {\n front = offset0 >= 0.0 && offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n }\n } else if (hasVertex3) {\n if (convex2) {\n front = offset1 >= 0.0 || offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal1);\n }\n } else {\n front = offset1 >= 0.0 && offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.copyVec2(upperLimit, normal1);\n }\n }\n } else {\n front = offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal1);\n }\n }\n\n // Get polygonB in frameA\n polygonBA.count = polygonB.m_count;\n for (let i = 0; i < polygonB.m_count; ++i) {\n matrix.transformVec2(polygonBA.vertices[i], xf, polygonB.m_vertices[i]);\n matrix.rotVec2(polygonBA.normals[i], xf.q, polygonB.m_normals[i]);\n }\n\n const radius = polygonB.m_radius + edgeA.m_radius;\n\n manifold.pointCount = 0;\n\n { // ComputeEdgeSeparation\n edgeAxis.type = EPAxisType.e_edgeA;\n edgeAxis.index = front ? 0 : 1;\n edgeAxis.separation = Infinity;\n\n for (let i = 0; i < polygonBA.count; ++i) {\n const v = polygonBA.vertices[i];\n const s = matrix.dotVec2(normal, v) - matrix.dotVec2(normal, v1);\n if (s < edgeAxis.separation) {\n edgeAxis.separation = s;\n }\n }\n }\n\n // If no valid normal can be found than this edge should not collide.\n // @ts-ignore todo: why we need this if here?\n if (edgeAxis.type == EPAxisType.e_unknown) {\n return;\n }\n\n if (edgeAxis.separation > radius) {\n return;\n }\n\n { // ComputePolygonSeparation\n polygonAxis.type = EPAxisType.e_unknown;\n polygonAxis.index = -1;\n polygonAxis.separation = -Infinity;\n\n matrix.setVec2(perp, -normal.y, normal.x);\n\n for (let i = 0; i < polygonBA.count; ++i) {\n matrix.scaleVec2(n, -1, polygonBA.normals[i]);\n\n const s1 = matrix.dotVec2(n, polygonBA.vertices[i]) - matrix.dotVec2(n, v1);\n const s2 = matrix.dotVec2(n, polygonBA.vertices[i]) - matrix.dotVec2(n, v2);\n const s = math_min(s1, s2);\n\n if (s > radius) {\n // No collision\n polygonAxis.type = EPAxisType.e_edgeB;\n polygonAxis.index = i;\n polygonAxis.separation = s;\n break;\n }\n\n // Adjacency\n if (matrix.dotVec2(n, perp) >= 0.0) {\n if (matrix.dotVec2(n, normal) - matrix.dotVec2(upperLimit, normal) < -Settings.angularSlop) {\n continue;\n }\n } else {\n if (matrix.dotVec2(n, normal) - matrix.dotVec2(lowerLimit, normal) < -Settings.angularSlop) {\n continue;\n }\n }\n\n if (s > polygonAxis.separation) {\n polygonAxis.type = EPAxisType.e_edgeB;\n polygonAxis.index = i;\n polygonAxis.separation = s;\n }\n }\n }\n\n if (polygonAxis.type != EPAxisType.e_unknown && polygonAxis.separation > radius) {\n return;\n }\n\n // Use hysteresis for jitter reduction.\n const k_relativeTol = 0.98;\n const k_absoluteTol = 0.001;\n\n let primaryAxis: EPAxis;\n if (polygonAxis.type == EPAxisType.e_unknown) {\n primaryAxis = edgeAxis;\n } else if (polygonAxis.separation > k_relativeTol * edgeAxis.separation + k_absoluteTol) {\n primaryAxis = polygonAxis;\n } else {\n primaryAxis = edgeAxis;\n }\n\n ie[0].recycle();\n ie[1].recycle();\n\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n manifold.type = ManifoldType.e_faceA;\n\n // Search for the polygon normal that is most anti-parallel to the edge\n // normal.\n let bestIndex = 0;\n let bestValue = matrix.dotVec2(normal, polygonBA.normals[0]);\n for (let i = 1; i < polygonBA.count; ++i) {\n const value = matrix.dotVec2(normal, polygonBA.normals[i]);\n if (value < bestValue) {\n bestValue = value;\n bestIndex = i;\n }\n }\n\n const i1 = bestIndex;\n const i2 = i1 + 1 < polygonBA.count ? i1 + 1 : 0;\n\n matrix.copyVec2(ie[0].v, polygonBA.vertices[i1]);\n ie[0].id.setFeatures(0, ContactFeatureType.e_face, i1, ContactFeatureType.e_vertex);\n\n matrix.copyVec2(ie[1].v, polygonBA.vertices[i2]);\n ie[1].id.setFeatures(0, ContactFeatureType.e_face, i2, ContactFeatureType.e_vertex);\n\n if (front) {\n rf.i1 = 0;\n rf.i2 = 1;\n matrix.copyVec2(rf.v1, v1);\n matrix.copyVec2(rf.v2, v2);\n matrix.copyVec2(rf.normal, normal1);\n } else {\n rf.i1 = 1;\n rf.i2 = 0;\n matrix.copyVec2(rf.v1, v2);\n matrix.copyVec2(rf.v2, v1);\n matrix.scaleVec2(rf.normal, -1, normal1);\n }\n } else {\n manifold.type = ManifoldType.e_faceB;\n\n matrix.copyVec2(ie[0].v, v1);\n ie[0].id.setFeatures(0, ContactFeatureType.e_vertex, primaryAxis.index, ContactFeatureType.e_face);\n\n matrix.copyVec2(ie[1].v, v2);\n ie[1].id.setFeatures(0, ContactFeatureType.e_vertex, primaryAxis.index, ContactFeatureType.e_face);\n\n rf.i1 = primaryAxis.index;\n rf.i2 = rf.i1 + 1 < polygonBA.count ? rf.i1 + 1 : 0;\n matrix.copyVec2(rf.v1, polygonBA.vertices[rf.i1]);\n matrix.copyVec2(rf.v2, polygonBA.vertices[rf.i2]);\n matrix.copyVec2(rf.normal, polygonBA.normals[rf.i1]);\n }\n\n matrix.setVec2(rf.sideNormal1, rf.normal.y, -rf.normal.x);\n matrix.setVec2(rf.sideNormal2, -rf.sideNormal1.x, -rf.sideNormal1.y);\n rf.sideOffset1 = matrix.dotVec2(rf.sideNormal1, rf.v1);\n rf.sideOffset2 = matrix.dotVec2(rf.sideNormal2, rf.v2);\n\n // Clip incident edge against extruded edge1 side edges.\n clipPoints1[0].recycle();\n clipPoints1[1].recycle();\n clipPoints2[0].recycle();\n clipPoints2[1].recycle();\n\n // Clip to box side 1\n const np1 = clipSegmentToLine(clipPoints1, ie, rf.sideNormal1, rf.sideOffset1, rf.i1);\n\n if (np1 < Settings.maxManifoldPoints) {\n return;\n }\n\n // Clip to negative box side 1\n const np2 = clipSegmentToLine(clipPoints2, clipPoints1, rf.sideNormal2, rf.sideOffset2, rf.i2);\n\n if (np2 < Settings.maxManifoldPoints) {\n return;\n }\n\n // Now clipPoints2 contains the clipped points.\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n matrix.copyVec2(manifold.localNormal, rf.normal);\n matrix.copyVec2(manifold.localPoint, rf.v1);\n } else {\n matrix.copyVec2(manifold.localNormal, polygonB.m_normals[rf.i1]);\n matrix.copyVec2(manifold.localPoint, polygonB.m_vertices[rf.i1]);\n }\n\n let pointCount = 0;\n for (let i = 0; i < Settings.maxManifoldPoints; ++i) {\n const separation = matrix.dotVec2(rf.normal, clipPoints2[i].v) - matrix.dotVec2(rf.normal, rf.v1);\n\n if (separation <= radius) {\n const cp = manifold.points[pointCount]; // ManifoldPoint\n\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n matrix.detransformVec2(cp.localPoint, xf, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n } else {\n matrix.copyVec2(cp.localPoint, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n cp.id.swapFeatures();\n }\n\n ++pointCount;\n }\n }\n\n manifold.pointCount = pointCount;\n};\n","import { CollidePolygons } from \"./collision/shape/CollidePolygon\";\nimport { Settings } from \"./Settings\";\nimport { Sweep } from \"./common/Sweep\";\nimport { DynamicTree } from \"./collision/DynamicTree\";\nimport { Manifold } from \"./collision/Manifold\";\nimport { Distance } from \"./collision/Distance\";\nimport { TimeOfImpact } from \"./collision/TimeOfImpact\";\nimport { stats } from \"./util/stats\";\n\n/** @hidden @deprecated Merged with main namespace */\nexport const internal = {\n CollidePolygons,\n Settings,\n Sweep,\n Manifold,\n Distance,\n TimeOfImpact,\n DynamicTree,\n stats\n};\n"],"names":["d","b","__assign","s","n","input","output","x","math_abs","math_sqrt","math_max","math_min","Vec2","v","a","AABB","normal","temp","math_PI","Settings","SettingsInternal","Pool","TreeNode","DynamicTree","c","Iterator","BroadPhase","displacement","math_sin","math_cos","transform","xf","math_atan2","Rot","matrix.vec2","Sweep","matrix.zeroVec2","matrix.transformVec2","matrix.copyVec2","localCenter","matrix.setRotAngle","matrix.combine2Vec2","matrix.minusVec2","matrix.rotVec2","Transform","rotation","Velocity","Position","Shape","FixtureProxy","Fixture","matrix.subVec2","matrix.transform","Body","matrix.plusScaleVec2","matrix.scaleVec2","matrix.dotVec2","matrix.crossNumVec2","matrix.plusVec2","point","JointEdge","Joint","DistanceInput","DistanceOutput","SimplexCache","cache","xfA","xfB","matrix.lengthSqrVec2","matrix.derotVec2","matrix.distVec2","rA","rB","matrix.normalizeVec2","matrix.minusScaleVec2","DistanceProxy","SimplexVertex","Simplex","v1","v2","matrix.setVec2","matrix.crossVec2Vec2","pA","pB","matrix.combine3Vec2","matrix.copyTransform","ShapeCastInput","ShapeCastOutput","simplex","pointA","pointB","TOIInput","TOIOutputState","TOIOutput","SeparationFunctionType","SeparationFunction","matrix.normalizeVec2Length","matrix.crossVec2Num","matrix.negVec2","TimeStep","ContactImpulse","Solver","matrix.mulVec2","Mat22","cA","cB","planePoint","clipPoint","ManifoldType","ContactFeatureType","PointState","ClipVertex","Manifold","ManifoldPoint","ContactID","WorldManifold","ContactEdge","VelocityConstraintPoint","tangent","P","Contact","_a","worldManifold","DEFAULTS","World","oldManifold","Vec3","EdgeShape","e","ChainShape","e1","e2","PolygonShape","ie","center","matrix.detransformVec2","matrix.addVec2","CircleShape","matrix.distSqrVec2","DistanceJoint","vA","vB","FrictionJoint","Mat33","LimitState","RevoluteJoint","PrismaticJoint","translation","perp","GearJoint","MotorJoint","MouseJoint","PulleyJoint","RopeJoint","WeldJoint","WheelJoint","Serializer","options","obj","Testbed","testbed","BoxShape","matrix.retransformVec2","clipPoints1","clipPoints2","normal1","matrix.detransformTransform","maxSeparation","edge1","matrix.rerotVec2","EPAxisType","VertexType","EPAxis","TempPolygon","ReferenceFace","s2"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,IAAI,gBAAgB,SAASA,IAAGC,IAAG;AAC/B,kBAAgB,OAAO,kBAClB,EAAE,WAAW,CAAA,eAAgB,SAAS,SAAUD,IAAGC,IAAG;AAAE,IAAAD,GAAE,YAAYC;AAAA,EAAE,KACzE,SAAUD,IAAGC,IAAG;AAAE,aAAS,KAAKA,GAAG,KAAI,OAAO,UAAU,eAAe,KAAKA,IAAG,CAAC,EAAG,CAAAD,GAAE,CAAC,IAAIC,GAAE,CAAC;AAAA;AACjG,SAAO,cAAcD,IAAGC,EAAC;AAC7B;AAEO,SAAS,UAAUD,IAAGC,IAAG;AAC5B,MAAI,OAAOA,OAAM,cAAcA,OAAM;AACjC,UAAM,IAAI,UAAU,yBAAyB,OAAOA,EAAC,IAAI,+BAA+B;AAC5F,gBAAcD,IAAGC,EAAC;AAClB,WAAS,KAAK;AAAE,SAAK,cAAcD;AAAA,EAAI;AACvC,EAAAA,GAAE,YAAYC,OAAM,OAAO,OAAO,OAAOA,EAAC,KAAK,GAAG,YAAYA,GAAE,WAAW,IAAI,GAAI;AACvF;AAEO,IAAI,WAAW,WAAW;AAC7B,aAAW,OAAO,UAAU,SAASC,UAAS,GAAG;AAC7C,aAASC,IAAG,IAAI,GAAGC,KAAI,UAAU,QAAQ,IAAIA,IAAG,KAAK;AACjD,MAAAD,KAAI,UAAU,CAAC;AACf,eAAS,KAAKA,GAAG,KAAI,OAAO,UAAU,eAAe,KAAKA,IAAG,CAAC,EAAG,GAAE,CAAC,IAAIA,GAAE,CAAC;AAAA,IAC9E;AACD,WAAO;AAAA,EACV;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wBAAuB,GAAG,YAAY,IAAI,YAAY,CAAC,EAAE,CAAC;AAC1D,WAAG,GAAG,IAAI,YAAY,CAAC,EAAE,EAAE;AAAA,MAAA,OACtB;AACLjG,iBAAgB,GAAG,YAAY,YAAY,CAAC,EAAE,CAAC;AAC/C,WAAG,GAAG,IAAI,YAAY,CAAC,EAAE,EAAE;AAC3B,WAAG,GAAG;;AAGN,QAAA;AAAA,IAAA;AAAA,EACJ;AAGF,WAAS,aAAa;AACxB;AC9eO,IAAM,WAAW;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","x_google_ignoreList":[0]} \ No newline at end of file +{"version":3,"file":"planck.mjs","sources":["../node_modules/tslib/tslib.es6.js","../src/util/options.ts","../src/common/Math.ts","../src/common/Vec2.ts","../src/collision/AABB.ts","../src/Settings.ts","../src/util/Pool.ts","../src/collision/DynamicTree.ts","../src/collision/BroadPhase.ts","../src/common/Matrix.ts","../src/common/Rot.ts","../src/common/Sweep.ts","../src/common/Transform.ts","../src/dynamics/Velocity.ts","../src/dynamics/Position.ts","../src/collision/Shape.ts","../src/dynamics/Fixture.ts","../src/dynamics/Body.ts","../src/dynamics/Joint.ts","../src/util/stats.ts","../src/util/Timer.ts","../src/collision/Distance.ts","../src/collision/TimeOfImpact.ts","../src/dynamics/Solver.ts","../src/common/Mat22.ts","../src/collision/Manifold.ts","../src/dynamics/Contact.ts","../src/dynamics/World.ts","../src/common/Vec3.ts","../src/collision/shape/EdgeShape.ts","../src/collision/shape/ChainShape.ts","../src/collision/shape/PolygonShape.ts","../src/collision/shape/CircleShape.ts","../src/dynamics/joint/DistanceJoint.ts","../src/dynamics/joint/FrictionJoint.ts","../src/common/Mat33.ts","../src/dynamics/joint/RevoluteJoint.ts","../src/dynamics/joint/PrismaticJoint.ts","../src/dynamics/joint/GearJoint.ts","../src/dynamics/joint/MotorJoint.ts","../src/dynamics/joint/MouseJoint.ts","../src/dynamics/joint/PulleyJoint.ts","../src/dynamics/joint/RopeJoint.ts","../src/dynamics/joint/WeldJoint.ts","../src/dynamics/joint/WheelJoint.ts","../src/serializer/index.ts","../src/util/Testbed.ts","../src/collision/shape/BoxShape.ts","../src/collision/shape/CollideCircle.ts","../src/collision/shape/CollideEdgeCircle.ts","../src/collision/shape/CollidePolygon.ts","../src/collision/shape/CollideCirclePolygon.ts","../src/collision/shape/CollideEdgePolygon.ts","../src/internal.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from) {\r\n for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)\r\n to[j] = from[i];\r\n return to;\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","/** @internal */\nexport const options = function(input: T, defaults: object): T {\n if (input === null || typeof input === \"undefined\") {\n // tslint:disable-next-line:no-object-literal-type-assertion\n input = {} as T;\n }\n\n const output = {...input};\n\n // tslint:disable-next-line:no-for-in\n for (const key in defaults) {\n if (defaults.hasOwnProperty(key) && typeof input[key] === \"undefined\") {\n output[key] = defaults[key];\n }\n }\n\n if (typeof Object.getOwnPropertySymbols === \"function\") {\n const symbols = Object.getOwnPropertySymbols(defaults);\n for (let i = 0; i < symbols.length; i++) {\n const symbol = symbols[i];\n if (defaults.propertyIsEnumerable(symbol) && typeof input[symbol] === \"undefined\") {\n output[symbol] = defaults[symbol];\n }\n }\n }\n\n return output;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_random = Math.random;\n\n\nexport const EPSILON = 1e-9;\n\n/** @internal @deprecated */\nexport const isFinite = Number.isFinite;\n\n/**\n * @deprecated\n * Next Largest Power of 2 Given a binary integer value x, the next largest\n * power of 2 can be computed by a SWAR algorithm that recursively \"folds\" the\n * upper bits into the lower bits. This process yields a bit vector with the\n * same most significant 1 as x, but all 1's below it. Adding 1 to that value\n * yields the next largest power of 2. For a 32-bit value:\n */\nexport function nextPowerOfTwo(x: number): number {\n x |= (x >> 1);\n x |= (x >> 2);\n x |= (x >> 4);\n x |= (x >> 8);\n x |= (x >> 16);\n return x + 1;\n}\n\n/** @deprecated */\nexport function isPowerOfTwo(x: number): boolean {\n return x > 0 && (x & (x - 1)) === 0;\n}\n\n/** @deprecated */\nexport function mod(num: number, min?: number, max?: number): number {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n if (max > min) {\n num = (num - min) % (max - min);\n return num + (num < 0 ? max : min);\n } else {\n num = (num - max) % (min - max);\n return num + (num <= 0 ? min : max);\n }\n}\n\n/**\n * @deprecated\n * Returns a min if num is less than min, and max if more than max, otherwise returns num.\n */\nexport function clamp(num: number, min: number, max: number): number {\n if (num < min) {\n return min;\n } else if (num > max) {\n return max;\n } else {\n return num;\n }\n}\n\n/**\n * @deprecated\n * Returns a random number between min and max when two arguments are provided.\n * If one arg is provided between 0 to max.\n * If one arg is passed between 0 to 1.\n */\nexport function random(min?: number, max?: number): number {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n return min === max ? min : math_random() * (max - min) + min;\n}\n\n/** @ignore */\nexport const math = Object.create(Math);\nmath.EPSILON = EPSILON;\nmath.isFinite = isFinite;\nmath.nextPowerOfTwo = nextPowerOfTwo;\nmath.isPowerOfTwo = isPowerOfTwo;\nmath.mod = mod;\nmath.clamp = clamp;\nmath.random = random;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { clamp, EPSILON } from \"./Math\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/** 2D vector */\nexport interface Vec2Value {\n x: number;\n y: number;\n}\n\ndeclare module \"./Vec2\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(x: number, y: number): Vec2;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(obj: Vec2Value): Vec2;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec2(): Vec2;\n}\n\n/** 2D vector */\n// @ts-expect-error\nexport class Vec2 {\n x: number;\n y: number;\n\n constructor(x: number, y: number);\n constructor(obj: Vec2Value);\n constructor();\n // tslint:disable-next-line:typedef\n constructor(x?, y?) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Vec2)) {\n return new Vec2(x, y);\n }\n if (typeof x === \"undefined\") {\n this.x = 0;\n this.y = 0;\n } else if (typeof x === \"object\") {\n this.x = x.x;\n this.y = x.y;\n } else {\n this.x = x;\n this.y = y;\n }\n if (_ASSERT) Vec2.assert(this);\n }\n\n /** @internal */\n _serialize(): object {\n return {\n x: this.x,\n y: this.y\n };\n }\n\n /** @internal */\n static _deserialize(data: any): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = data.x;\n obj.y = data.y;\n return obj;\n }\n\n static zero(): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = 0;\n obj.y = 0;\n return obj;\n }\n\n /** @hidden */\n static neo(x: number, y: number): Vec2 {\n const obj = Object.create(Vec2.prototype);\n obj.x = x;\n obj.y = y;\n return obj;\n }\n\n static clone(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(v.x, v.y);\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n /**\n * Does this vector contain finite coordinates?\n */\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.x) && Number.isFinite(obj.y);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Vec2.isValid(o), \"Invalid Vec2!\", o);\n }\n\n clone(): Vec2 {\n return Vec2.clone(this);\n }\n\n /**\n * Set this vector to all zeros.\n *\n * @returns this\n */\n setZero(): Vec2 {\n this.x = 0.0;\n this.y = 0.0;\n return this;\n }\n\n set(x: number, y: number): Vec2;\n set(value: Vec2Value): Vec2;\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n // tslint:disable-next-line:typedef\n set(x, y?) {\n if (typeof x === \"object\") {\n if (_ASSERT) Vec2.assert(x);\n this.x = x.x;\n this.y = x.y;\n } else {\n if (_ASSERT) console.assert(Number.isFinite(x));\n if (_ASSERT) console.assert(Number.isFinite(y));\n this.x = x;\n this.y = y;\n }\n return this;\n }\n\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n setNum(x: number, y: number) {\n if (_ASSERT) console.assert(Number.isFinite(x));\n if (_ASSERT) console.assert(Number.isFinite(y));\n this.x = x;\n this.y = y;\n\n return this;\n }\n\n /**\n * Set this vector to some specified coordinates.\n *\n * @returns this\n */\n setVec2(value: Vec2Value) {\n if (_ASSERT) Vec2.assert(value);\n this.x = value.x;\n this.y = value.y;\n\n return this;\n }\n\n /** @internal @deprecated Use setCombine or setMul */\n wSet(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.setCombine(a, v, b, w);\n } else {\n return this.setMul(a, v);\n }\n }\n\n /**\n * Set linear combination of v and w: `a * v + b * w`\n */\n setCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x = x;\n this.y = y;\n return this;\n }\n\n setMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x = x;\n this.y = y;\n return this;\n }\n\n /**\n * Add a vector to this vector.\n *\n * @returns this\n */\n add(w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(w);\n this.x += w.x;\n this.y += w.y;\n return this;\n }\n\n /** @internal @deprecated Use addCombine or addMul */\n wAdd(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.addCombine(a, v, b, w);\n } else {\n return this.addMul(a, v);\n }\n }\n\n /**\n * Add linear combination of v and w: `a * v + b * w`\n */\n addCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x += x;\n this.y += y;\n return this;\n }\n\n addMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x += x;\n this.y += y;\n return this;\n }\n\n /**\n * @deprecated Use subCombine or subMul\n */\n wSub(a: number, v: Vec2Value, b?: number, w?: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return this.subCombine(a, v, b, w);\n } else {\n return this.subMul(a, v);\n }}\n\n /**\n * Subtract linear combination of v and w: `a * v + b * w`\n */\n subCombine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(b));\n if (_ASSERT) Vec2.assert(w);\n const x = a * v.x + b * w.x;\n const y = a * v.y + b * w.y;\n\n // `this` may be `w`\n this.x -= x;\n this.y -= y;\n return this;\n }\n\n subMul(a: number, v: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(v);\n const x = a * v.x;\n const y = a * v.y;\n\n this.x -= x;\n this.y -= y;\n return this;\n }\n\n /**\n * Subtract a vector from this vector\n *\n * @returns this\n */\n sub(w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(w);\n this.x -= w.x;\n this.y -= w.y;\n return this;\n }\n\n /**\n * Multiply this vector by a scalar.\n *\n * @returns this\n */\n mul(m: number): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(m));\n this.x *= m;\n this.y *= m;\n return this;\n }\n\n /**\n * Get the length of this vector (the norm).\n *\n * For performance, use this instead of lengthSquared (if possible).\n */\n length(): number {\n return Vec2.lengthOf(this);\n }\n\n /**\n * Get the length squared.\n */\n lengthSquared(): number {\n return Vec2.lengthSquared(this);\n }\n\n /**\n * Convert this vector into a unit vector.\n *\n * @returns old length\n */\n normalize(): number {\n const length = this.length();\n if (length < EPSILON) {\n return 0.0;\n }\n const invLength = 1.0 / length;\n this.x *= invLength;\n this.y *= invLength;\n return length;\n }\n\n /**\n * Returns a new unit vector from the provided vector.\n *\n * @returns new unit vector\n */\n static normalize(v: Vec2Value): Vec2 {\n const length = Vec2.lengthOf(v);\n if (length < EPSILON) {\n return Vec2.zero();\n }\n const invLength = 1.0 / length;\n return Vec2.neo(v.x * invLength, v.y * invLength);\n }\n\n /**\n * Get the length of this vector (the norm).\n *\n * For performance, use this instead of lengthSquared (if possible).\n */\n static lengthOf(v: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n return math_sqrt(v.x * v.x + v.y * v.y);\n }\n\n /**\n * Get the length squared.\n */\n static lengthSquared(v: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n return v.x * v.x + v.y * v.y;\n }\n\n static distance(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n const dx = v.x - w.x;\n const dy = v.y - w.y;\n return math_sqrt(dx * dx + dy * dy);\n }\n\n static distanceSquared(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n const dx = v.x - w.x;\n const dy = v.y - w.y;\n return dx * dx + dy * dy;\n }\n\n static areEqual(v: Vec2Value, w: Vec2Value): boolean {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v === w || typeof w === \"object\" && w !== null && v.x === w.x && v.y === w.y;\n }\n\n /**\n * Get the skew vector such that dot(skew_vec, other) == cross(vec, other)\n */\n static skew(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(-v.y, v.x);\n }\n\n /** Dot product on two vectors */\n static dot(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.x + v.y * w.y;\n }\n\n /** Cross product between two vectors */\n static cross(v: Vec2Value, w: Vec2Value): number;\n /** Cross product between a vector and a scalar */\n static cross(v: Vec2Value, w: number): Vec2;\n /** Cross product between a scalar and a vector */\n static cross(v: number, w: Vec2Value): Vec2;\n static cross(v: any, w: any): any {\n if (typeof w === \"number\") {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y, -w * v.x);\n\n } else if (typeof v === \"number\") {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y, v * w.x);\n\n } else {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.y - v.y * w.x;\n }\n }\n\n /** Cross product on two vectors */\n static crossVec2Vec2(v: Vec2Value, w: Vec2Value): number {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return v.x * w.y - v.y * w.x;\n }\n\n /** Cross product on a vector and a scalar */\n static crossVec2Num(v: Vec2Value, w: number): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y, -w * v.x);\n }\n\n /** Cross product on a vector and a scalar */\n static crossNumVec2(v: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y, v * w.x);\n }\n\n /** Returns `a + (v x w)` */\n static addCross(a: Vec2Value, v: Vec2Value, w: number): Vec2;\n /** Returns `a + (v x w)` */\n static addCross(a: Vec2Value, v: number, w: Vec2Value): Vec2;\n static addCross(a: Vec2Value, v: any, w: any): Vec2 {\n if (typeof w === \"number\") {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y + a.x, -w * v.x + a.y);\n\n } else if (typeof v === \"number\") {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y + a.x, v * w.x + a.y);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n /**\n * Returns `a + (v x w)`\n */\n static addCrossVec2Num(a: Vec2Value, v: Vec2Value, w: number): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) console.assert(Number.isFinite(w));\n return Vec2.neo(w * v.y + a.x, -w * v.x + a.y);\n }\n\n /**\n * Returns `a + (v x w)`\n */\n static addCrossNumVec2(a: Vec2Value, v: number, w: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(v));\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(-v * w.y + a.x, v * w.x + a.y);\n }\n\n static add(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(v.x + w.x, v.y + w.y);\n }\n\n /** @hidden @deprecated */\n static wAdd(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n return Vec2.combine(a, v, b, w);\n } else {\n return Vec2.mulNumVec2(a, v);\n }\n }\n\n static combine(a: number, v: Vec2Value, b: number, w: Vec2Value): Vec2 {\n return Vec2.zero().setCombine(a, v, b, w);\n }\n\n static sub(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(v.x - w.x, v.y - w.y);\n }\n\n static mul(a: Vec2Value, b: number): Vec2;\n static mul(a: number, b: Vec2Value): Vec2;\n static mul(a: any, b: any): Vec2 {\n if (typeof a === \"object\") {\n if (_ASSERT) Vec2.assert(a);\n if (_ASSERT) console.assert(Number.isFinite(b));\n return Vec2.neo(a.x * b, a.y * b);\n\n } else if (typeof b === \"object\") {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(b);\n return Vec2.neo(a * b.x, a * b.y);\n }\n }\n\n static mulVec2Num(a: Vec2Value, b: number): Vec2 {\n if (_ASSERT) Vec2.assert(a);\n if (_ASSERT) console.assert(Number.isFinite(b));\n return Vec2.neo(a.x * b, a.y * b);\n }\n\n static mulNumVec2(a: number, b: Vec2Value): Vec2 {\n if (_ASSERT) console.assert(Number.isFinite(a));\n if (_ASSERT) Vec2.assert(b);\n return Vec2.neo(a * b.x, a * b.y);\n }\n\n neg(): Vec2 {\n this.x = -this.x;\n this.y = -this.y;\n return this;\n }\n\n static neg(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(-v.x, -v.y);\n }\n\n static abs(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(math_abs(v.x), math_abs(v.y));\n }\n\n static mid(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo((v.x + w.x) * 0.5, (v.y + w.y) * 0.5);\n }\n\n static upper(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(math_max(v.x, w.x), math_max(v.y, w.y));\n }\n\n static lower(v: Vec2Value, w: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n if (_ASSERT) Vec2.assert(w);\n return Vec2.neo(math_min(v.x, w.x), math_min(v.y, w.y));\n }\n\n clamp(max: number): Vec2 {\n const lengthSqr = this.x * this.x + this.y * this.y;\n if (lengthSqr > max * max) {\n const scale = max / math_sqrt(lengthSqr);\n this.x *= scale;\n this.y *= scale;\n }\n return this;\n }\n\n static clamp(v: Vec2Value, max: number): Vec2 {\n const r = Vec2.neo(v.x, v.y);\n r.clamp(max);\n return r;\n }\n\n /** @hidden */\n static clampVec2(v: Vec2Value, min?: Vec2Value, max?: Vec2Value): Vec2Value {\n return {\n x: clamp(v.x, min?.x, max?.x),\n y: clamp(v.y, min?.y, max?.y)\n };\n }\n\n /** @hidden @deprecated */\n static scaleFn(x: number, y: number) {\n // todo: this was used in examples, remove in the future\n return function(v: Vec2Value): Vec2 {\n return Vec2.neo(v.x * x, v.y * y);\n };\n }\n\n /** @hidden @deprecated */\n static translateFn(x: number, y: number) {\n // todo: this was used in examples, remove in the future\n return function(v: Vec2Value): Vec2 {\n return Vec2.neo(v.x + x, v.y + y);\n };\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { EPSILON } from \"../common/Math\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n/**\n * Ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n */\nexport interface RayCastInput {\n p1: Vec2Value;\n p2: Vec2Value;\n maxFraction: number;\n}\n\nexport type RayCastCallback = (subInput: RayCastInput, id: number) => number;\n\n/**\n * Ray-cast output data. The ray hits at `p1 + fraction * (p2 - p1)`,\n * where `p1` and `p2` come from RayCastInput.\n */\nexport interface RayCastOutput {\n normal: Vec2;\n fraction: number;\n}\n\n/** Axis-aligned bounding box */\nexport interface AABBValue {\n lowerBound: Vec2Value;\n upperBound: Vec2Value;\n}\n\ndeclare module \"./AABB\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function AABB(lower?: Vec2Value, upper?: Vec2Value): AABB;\n}\n\n/** Axis-aligned bounding box */\n// @ts-expect-error\nexport class AABB {\n lowerBound: Vec2;\n upperBound: Vec2;\n\n constructor(lower?: Vec2Value, upper?: Vec2Value) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof AABB)) {\n return new AABB(lower, upper);\n }\n\n this.lowerBound = Vec2.zero();\n this.upperBound = Vec2.zero();\n\n if (typeof lower === \"object\") {\n this.lowerBound.setVec2(lower);\n }\n if (typeof upper === \"object\") {\n this.upperBound.setVec2(upper);\n } else if (typeof lower === \"object\") {\n this.upperBound.setVec2(lower);\n }\n }\n\n /**\n * Verify that the bounds are sorted.\n */\n isValid(): boolean {\n return AABB.isValid(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.lowerBound) && Vec2.isValid(obj.upperBound) && Vec2.sub(obj.upperBound, obj.lowerBound).lengthSquared() >= 0;\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!AABB.isValid(o), \"Invalid AABB!\", o);\n }\n\n /**\n * Get the center of the AABB.\n */\n getCenter(): Vec2 {\n return Vec2.neo((this.lowerBound.x + this.upperBound.x) * 0.5, (this.lowerBound.y + this.upperBound.y) * 0.5);\n }\n\n /**\n * Get the extents of the AABB (half-widths).\n */\n getExtents(): Vec2 {\n return Vec2.neo((this.upperBound.x - this.lowerBound.x) * 0.5, (this.upperBound.y - this.lowerBound.y) * 0.5);\n }\n\n /**\n * Get the perimeter length.\n */\n getPerimeter(): number {\n return 2.0 * (this.upperBound.x - this.lowerBound.x + this.upperBound.y - this.lowerBound.y);\n }\n\n /**\n * Combine one or two AABB into this one.\n */\n combine(a: AABBValue, b?: AABBValue): void {\n b = b || this;\n\n const lowerA = a.lowerBound;\n const upperA = a.upperBound;\n const lowerB = b.lowerBound;\n const upperB = b.upperBound;\n\n const lowerX = math_min(lowerA.x, lowerB.x);\n const lowerY = math_min(lowerA.y, lowerB.y);\n const upperX = math_max(upperB.x, upperA.x);\n const upperY = math_max(upperB.y, upperA.y);\n\n this.lowerBound.setNum(lowerX, lowerY);\n this.upperBound.setNum(upperX, upperY);\n }\n\n combinePoints(a: Vec2Value, b: Vec2Value): void {\n this.lowerBound.setNum(math_min(a.x, b.x), math_min(a.y, b.y));\n this.upperBound.setNum(math_max(a.x, b.x), math_max(a.y, b.y));\n }\n\n set(aabb: AABBValue): void {\n this.lowerBound.setNum(aabb.lowerBound.x, aabb.lowerBound.y);\n this.upperBound.setNum(aabb.upperBound.x, aabb.upperBound.y);\n }\n\n contains(aabb: AABBValue): boolean {\n let result = true;\n result = result && this.lowerBound.x <= aabb.lowerBound.x;\n result = result && this.lowerBound.y <= aabb.lowerBound.y;\n result = result && aabb.upperBound.x <= this.upperBound.x;\n result = result && aabb.upperBound.y <= this.upperBound.y;\n return result;\n }\n\n extend(value: number): AABB {\n AABB.extend(this, value);\n return this;\n }\n\n static extend(out: AABBValue, value: number): AABBValue {\n out.lowerBound.x -= value;\n out.lowerBound.y -= value;\n out.upperBound.x += value;\n out.upperBound.y += value;\n return out;\n }\n\n static testOverlap(a: AABBValue, b: AABBValue): boolean {\n const d1x = b.lowerBound.x - a.upperBound.x;\n const d2x = a.lowerBound.x - b.upperBound.x;\n\n const d1y = b.lowerBound.y - a.upperBound.y;\n const d2y = a.lowerBound.y - b.upperBound.y;\n\n if (d1x > 0 || d1y > 0 || d2x > 0 || d2y > 0) {\n return false;\n }\n return true;\n }\n\n static areEqual(a: AABBValue, b: AABBValue): boolean {\n return Vec2.areEqual(a.lowerBound, b.lowerBound) && Vec2.areEqual(a.upperBound, b.upperBound);\n }\n\n static diff(a: AABBValue, b: AABBValue): number {\n const wD = math_max(0, math_min(a.upperBound.x, b.upperBound.x) - math_max(b.lowerBound.x, a.lowerBound.x));\n const hD = math_max(0, math_min(a.upperBound.y, b.upperBound.y) - math_max(b.lowerBound.y, a.lowerBound.y));\n\n const wA = a.upperBound.x - a.lowerBound.x;\n const hA = a.upperBound.y - a.lowerBound.y;\n\n const wB = b.upperBound.x - b.lowerBound.x;\n const hB = b.upperBound.y - b.lowerBound.y;\n\n return wA * hA + wB * hB - wD * hD;\n }\n\n rayCast(output: RayCastOutput, input: RayCastInput): boolean {\n // From Real-time Collision Detection, p179.\n\n let tmin = -Infinity;\n let tmax = Infinity;\n\n const p = input.p1;\n const d = Vec2.sub(input.p2, input.p1);\n const absD = Vec2.abs(d);\n\n const normal = Vec2.zero();\n\n for (let f: \"x\" | \"y\" = \"x\"; f !== null; f = (f === \"x\" ? \"y\" : null)) {\n if (absD.x < EPSILON) {\n // Parallel.\n if (p[f] < this.lowerBound[f] || this.upperBound[f] < p[f]) {\n return false;\n }\n } else {\n const inv_d = 1.0 / d[f];\n let t1 = (this.lowerBound[f] - p[f]) * inv_d;\n let t2 = (this.upperBound[f] - p[f]) * inv_d;\n\n // Sign of the normal vector.\n let s = -1.0;\n\n if (t1 > t2) {\n const temp = t1;\n t1 = t2;\n t2 = temp;\n s = 1.0;\n }\n\n // Push the min up\n if (t1 > tmin) {\n normal.setZero();\n normal[f] = s;\n tmin = t1;\n }\n\n // Pull the max down\n tmax = math_min(tmax, t2);\n\n if (tmin > tmax) {\n return false;\n }\n }\n }\n\n // Does the ray start inside the box?\n // Does the ray intersect beyond the max fraction?\n if (tmin < 0.0 || input.maxFraction < tmin) {\n return false;\n }\n\n // Intersection.\n output.fraction = tmin;\n output.normal = normal;\n return true;\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static combinePoints(out: AABBValue, a: Vec2Value, b: Vec2Value): AABBValue {\n out.lowerBound.x = math_min(a.x, b.x);\n out.lowerBound.y = math_min(a.y, b.y);\n out.upperBound.x = math_max(a.x, b.x);\n out.upperBound.y = math_max(a.y, b.y);\n return out;\n }\n\n static combinedPerimeter(a: AABBValue, b: AABBValue) {\n const lx = math_min(a.lowerBound.x, b.lowerBound.x);\n const ly = math_min(a.lowerBound.y, b.lowerBound.y);\n const ux = math_max(a.upperBound.x, b.upperBound.x);\n const uy = math_max(a.upperBound.y, b.upperBound.y);\n return 2.0 * (ux - lx + uy - ly); \n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Tuning constants based on meters-kilograms-seconds (MKS) units.\n * \n * Some tolerances are absolute and some are relative. Absolute tolerances use MKS units.\n */\nexport class Settings {\n /**\n * You can use this to change the length scale used by your game.\n * \n * For example for inches you could use 39.4.\n */\n static lengthUnitsPerMeter = 1.0;\n \n // Collision\n /**\n * The maximum number of contact points between two convex shapes. Do not change\n * this value.\n */\n static maxManifoldPoints: number = 2;\n\n /**\n * The maximum number of vertices on a convex polygon. You cannot increase this\n * too much because BlockAllocator has a maximum object size.\n */\n static maxPolygonVertices: number = 12;\n\n /**\n * This is used to fatten AABBs in the dynamic tree. This allows proxies to move\n * by a small amount without triggering a tree adjustment. This is in meters.\n */\n static aabbExtension: number = 0.1;\n\n /**\n * This is used to fatten AABBs in the dynamic tree. This is used to predict the\n * future position based on the current displacement. This is a dimensionless\n * multiplier.\n */\n static aabbMultiplier: number = 2.0;\n\n /**\n * A small length used as a collision and constraint tolerance. Usually it is\n * chosen to be numerically significant, but visually insignificant.\n */\n static linearSlop: number = 0.005;\n\n /**\n * A small angle used as a collision and constraint tolerance. Usually it is\n * chosen to be numerically significant, but visually insignificant.\n */\n static angularSlop: number = (2.0 / 180.0 * math_PI);\n\n /**\n * The radius of the polygon/edge shape skin. This should not be modified.\n * Making this smaller means polygons will have an insufficient buffer for\n * continuous collision. Making it larger may create artifacts for vertex\n * collision.\n */\n static get polygonRadius(): number { return 2.0 * Settings.linearSlop; }\n\n /**\n * Maximum number of sub-steps per contact in continuous physics simulation.\n */\n static maxSubSteps: number = 8;\n\n // Dynamics\n\n /**\n * Maximum number of contacts to be handled to solve a TOI impact.\n */\n static maxTOIContacts: number = 32;\n\n /**\n * Maximum iterations to solve a TOI.\n */\n static maxTOIIterations: number = 20;\n\n /**\n * Maximum iterations to find Distance.\n */\n static maxDistanceIterations: number = 20;\n\n /**\n * A velocity threshold for elastic collisions. Any collision with a relative\n * linear velocity below this threshold will be treated as inelastic.\n */\n static velocityThreshold: number = 1.0;\n\n /**\n * The maximum linear position correction used when solving constraints. This\n * helps to prevent overshoot.\n */\n static maxLinearCorrection: number = 0.2;\n\n /**\n * The maximum angular position correction used when solving constraints. This\n * helps to prevent overshoot.\n */\n static maxAngularCorrection: number = (8.0 / 180.0 * math_PI);\n\n /**\n * The maximum linear velocity of a body. This limit is very large and is used\n * to prevent numerical problems. You shouldn't need to adjust Settings.\n */\n static maxTranslation: number = 2.0;\n\n /**\n * The maximum angular velocity of a body. This limit is very large and is used\n * to prevent numerical problems. You shouldn't need to adjust Settings.\n */\n static maxRotation: number = (0.5 * math_PI);\n\n /**\n * This scale factor controls how fast overlap is resolved. Ideally this would\n * be 1 so that overlap is removed in one time step. However using values close\n * to 1 often lead to overshoot.\n */\n static baumgarte: number = 0.2;\n static toiBaugarte: number = 0.75;\n\n // Sleep\n\n /**\n * The time that a body must be still before it will go to sleep.\n */\n static timeToSleep: number = 0.5;\n\n /**\n * A body cannot sleep if its linear velocity is above this tolerance.\n */\n static linearSleepTolerance: number = 0.01;\n\n /**\n * A body cannot sleep if its angular velocity is above this tolerance.\n */\n static angularSleepTolerance: number = (2.0 / 180.0 * math_PI);\n}\n\n/** @internal */\nexport class SettingsInternal {\n static get maxManifoldPoints() {\n return Settings.maxManifoldPoints;\n }\n static get maxPolygonVertices() {\n return Settings.maxPolygonVertices;\n }\n static get aabbExtension() {\n return Settings.aabbExtension * Settings.lengthUnitsPerMeter;\n }\n static get aabbMultiplier() {\n return Settings.aabbMultiplier;\n }\n static get linearSlop() {\n return Settings.linearSlop * Settings.lengthUnitsPerMeter;\n }\n static get linearSlopSquared() {\n return Settings.linearSlop * Settings.lengthUnitsPerMeter * Settings.linearSlop * Settings.lengthUnitsPerMeter;\n }\n static get angularSlop() {\n return Settings.angularSlop;\n }\n static get polygonRadius() {\n return 2.0 * Settings.linearSlop;\n }\n static get maxSubSteps() {\n return Settings.maxSubSteps;\n }\n static get maxTOIContacts() {\n return Settings.maxTOIContacts;\n }\n static get maxTOIIterations() {\n return Settings.maxTOIIterations;\n }\n static get maxDistanceIterations() {\n return Settings.maxDistanceIterations;\n }\n static get velocityThreshold() {\n return Settings.velocityThreshold * Settings.lengthUnitsPerMeter;\n }\n static get maxLinearCorrection() {\n return Settings.maxLinearCorrection * Settings.lengthUnitsPerMeter;\n }\n static get maxAngularCorrection() {\n return Settings.maxAngularCorrection;\n }\n static get maxTranslation() {\n return Settings.maxTranslation * Settings.lengthUnitsPerMeter;\n }\n static get maxTranslationSquared() {\n return Settings.maxTranslation * Settings.lengthUnitsPerMeter * Settings.maxTranslation * Settings.lengthUnitsPerMeter;\n }\n static get maxRotation() {\n return Settings.maxRotation;\n }\n static get maxRotationSquared() {\n return Settings.maxRotation * Settings.maxRotation;\n }\n static get baumgarte() {\n return Settings.baumgarte;\n }\n static get toiBaugarte() {\n return Settings.toiBaugarte;\n }\n static get timeToSleep() {\n return Settings.timeToSleep;\n }\n static get linearSleepTolerance() {\n return Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter;\n }\n static get linearSleepToleranceSqr() {\n return Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter * Settings.linearSleepTolerance * Settings.lengthUnitsPerMeter;\n }\n static get angularSleepTolerance() {\n return Settings.angularSleepTolerance;\n }\n static get angularSleepToleranceSqr() {\n return Settings.angularSleepTolerance * Settings.angularSleepTolerance;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */\nexport interface PoolOptions {\n max?: number,\n create?: () => T,\n /** Called when an object is being re-allocated. */\n allocate?: (item: T) => void,\n /** Called when an object is returned to pool. */\n release?: (item: T) => void,\n /** Called when an object is returned to the pool but will be disposed from pool. */\n dispose?: (item: T) => T,\n}\n\n/** @internal */\nexport class Pool {\n _list: T[] = [];\n _max: number = Infinity;\n\n _createFn: () => T;\n _hasCreateFn: boolean = false;\n _createCount: number = 0;\n\n _allocateFn: (item: T) => void;\n _hasAllocateFn: boolean = false;\n _allocateCount: number = 0;\n\n _releaseFn: (item: T) => void;\n _hasReleaseFn: boolean = false;\n _releaseCount: number = 0;\n\n _disposeFn: (item: T) => T;\n _hasDisposeFn: boolean = false;\n _disposeCount: number = 0;\n\n constructor(opts: PoolOptions) {\n this._list = [];\n this._max = opts.max || this._max;\n\n this._createFn = opts.create;\n this._hasCreateFn = typeof this._createFn === \"function\";\n this._allocateFn = opts.allocate;\n this._hasAllocateFn = typeof this._allocateFn === \"function\";\n this._releaseFn = opts.release;\n this._hasReleaseFn = typeof this._releaseFn === \"function\";\n this._disposeFn = opts.dispose;\n this._hasDisposeFn = typeof this._disposeFn === \"function\";\n }\n\n max(n?: number): number | Pool {\n if (typeof n === \"number\") {\n this._max = n;\n return this;\n }\n return this._max;\n }\n\n size(): number {\n return this._list.length;\n }\n\n allocate(): T {\n let item: T;\n if (this._list.length > 0) {\n item = this._list.shift();\n } else {\n this._createCount++;\n if (this._hasCreateFn) {\n item = this._createFn();\n } else {\n // tslint:disable-next-line:no-object-literal-type-assertion\n item = {} as T;\n }\n }\n this._allocateCount++;\n if (this._hasAllocateFn) {\n this._allocateFn(item);\n }\n return item;\n }\n\n release(item: T): void {\n if (this._list.length < this._max) {\n this._releaseCount++;\n if (this._hasReleaseFn) {\n this._releaseFn(item);\n }\n this._list.push(item);\n } else {\n this._disposeCount++;\n if (this._hasDisposeFn) {\n item = this._disposeFn(item);\n }\n }\n }\n\n toString(): string {\n return \" +\" + this._createCount + \" >\" + this._allocateCount + \" <\" + this._releaseCount + \" -\"\n + this._disposeCount + \" =\" + this._list.length + \"/\" + this._max;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { Pool } from \"../util/Pool\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { AABB, AABBValue, RayCastCallback, RayCastInput } from \"./AABB\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n\n\nexport type DynamicTreeQueryCallback = (nodeId: number) => boolean;\n\n/**\n * A node in the dynamic tree. The client does not interact with this directly.\n */\nexport class TreeNode {\n id: number;\n /** Enlarged AABB */\n aabb: AABB = new AABB();\n userData: T = null;\n parent: TreeNode = null;\n child1: TreeNode = null;\n child2: TreeNode = null;\n /** 0: leaf, -1: free node */\n height: number = -1;\n\n constructor(id?: number) {\n this.id = id;\n }\n\n /** @internal */\n toString(): string {\n return this.id + \": \" + this.userData;\n }\n\n isLeaf(): boolean {\n return this.child1 == null;\n }\n}\n\n/** @internal */ const poolTreeNode = new Pool>({\n create(): TreeNode {\n return new TreeNode();\n },\n release(node: TreeNode) {\n node.userData = null;\n node.parent = null;\n node.child1 = null;\n node.child2 = null;\n node.height = -1;\n node.id = undefined;\n }\n});\n\n/**\n * A dynamic AABB tree broad-phase, inspired by Nathanael Presson's btDbvt. A\n * dynamic tree arranges data in a binary tree to accelerate queries such as\n * volume queries and ray casts. Leafs are proxies with an AABB. In the tree we\n * expand the proxy AABB by `aabbExtension` so that the proxy AABB is bigger\n * than the client object. This allows the client object to move by small\n * amounts without triggering a tree update.\n *\n * Nodes are pooled and relocatable, so we use node indices rather than\n * pointers.\n */\nexport class DynamicTree {\n m_root: TreeNode;\n m_lastProxyId: number;\n m_nodes: {\n [id: number]: TreeNode\n };\n\n constructor() {\n this.m_root = null;\n this.m_nodes = {};\n this.m_lastProxyId = 0;\n }\n\n /**\n * Get proxy user data.\n *\n * @return the proxy user data or 0 if the id is invalid.\n */\n getUserData(id: number): T {\n const node = this.m_nodes[id];\n if (_ASSERT) console.assert(!!node);\n return node.userData;\n }\n\n /**\n * Get the fat AABB for a node id.\n *\n * @return the proxy user data or 0 if the id is invalid.\n */\n getFatAABB(id: number): AABB {\n const node = this.m_nodes[id];\n if (_ASSERT) console.assert(!!node);\n return node.aabb;\n }\n\n allocateNode(): TreeNode {\n const node = poolTreeNode.allocate();\n node.id = ++this.m_lastProxyId;\n this.m_nodes[node.id] = node;\n return node;\n }\n\n freeNode(node: TreeNode): void {\n // tslint:disable-next-line:no-dynamic-delete\n delete this.m_nodes[node.id];\n poolTreeNode.release(node);\n }\n\n /**\n * Create a proxy in the tree as a leaf node. We return the index of the node\n * instead of a pointer so that we can grow the node pool.\n *\n * Create a proxy. Provide a tight fitting AABB and a userData pointer.\n */\n createProxy(aabb: AABBValue, userData: T): number {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n\n const node = this.allocateNode();\n\n node.aabb.set(aabb);\n\n // Fatten the aabb.\n AABB.extend(node.aabb, Settings.aabbExtension);\n\n node.userData = userData;\n node.height = 0;\n\n this.insertLeaf(node);\n\n return node.id;\n }\n\n /**\n * Destroy a proxy. This asserts if the id is invalid.\n */\n destroyProxy(id: number): void {\n const node = this.m_nodes[id];\n\n if (_ASSERT) console.assert(!!node);\n if (_ASSERT) console.assert(node.isLeaf());\n\n this.removeLeaf(node);\n this.freeNode(node);\n }\n\n /**\n * Move a proxy with a swepted AABB. If the proxy has moved outside of its\n * fattened AABB, then the proxy is removed from the tree and re-inserted.\n * Otherwise the function returns immediately.\n *\n * @param d Displacement\n *\n * @return true if the proxy was re-inserted.\n */\n moveProxy(id: number, aabb: AABBValue, d: Vec2Value): boolean {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n if (_ASSERT) console.assert(!d || Vec2.isValid(d));\n\n const node = this.m_nodes[id];\n\n if (_ASSERT) console.assert(!!node);\n if (_ASSERT) console.assert(node.isLeaf());\n\n if (node.aabb.contains(aabb)) {\n return false;\n }\n\n this.removeLeaf(node);\n\n node.aabb.set(aabb);\n\n // Extend AABB.\n aabb = node.aabb;\n AABB.extend(aabb, Settings.aabbExtension);\n\n // Predict AABB displacement.\n // const d = Vec2.mul(Settings.aabbMultiplier, displacement);\n\n if (d.x < 0.0) {\n aabb.lowerBound.x += d.x * Settings.aabbMultiplier;\n } else {\n aabb.upperBound.x += d.x * Settings.aabbMultiplier;\n }\n\n if (d.y < 0.0) {\n aabb.lowerBound.y += d.y * Settings.aabbMultiplier;\n } else {\n aabb.upperBound.y += d.y * Settings.aabbMultiplier;\n }\n\n this.insertLeaf(node);\n\n return true;\n }\n\n insertLeaf(leaf: TreeNode): void {\n if (_ASSERT) console.assert(AABB.isValid(leaf.aabb));\n\n if (this.m_root == null) {\n this.m_root = leaf;\n this.m_root.parent = null;\n return;\n }\n\n // Find the best sibling for this node\n const leafAABB = leaf.aabb;\n let index = this.m_root;\n while (!index.isLeaf()) {\n const child1 = index.child1;\n const child2 = index.child2;\n\n const area = index.aabb.getPerimeter();\n\n const combinedArea = AABB.combinedPerimeter(index.aabb, leafAABB);\n\n // Cost of creating a new parent for this node and the new leaf\n const cost = 2.0 * combinedArea;\n\n // Minimum cost of pushing the leaf further down the tree\n const inheritanceCost = 2.0 * (combinedArea - area);\n\n // Cost of descending into child1\n const newArea1 = AABB.combinedPerimeter(leafAABB, child1.aabb);\n let cost1 = newArea1 + inheritanceCost;\n if (!child1.isLeaf()) {\n const oldArea = child1.aabb.getPerimeter();\n cost1 -= oldArea;\n }\n\n // Cost of descending into child2\n const newArea2 = AABB.combinedPerimeter(leafAABB, child2.aabb);\n let cost2 = newArea2 + inheritanceCost;\n if (!child2.isLeaf()) {\n const oldArea = child2.aabb.getPerimeter();\n cost2 -= oldArea;\n }\n\n // Descend according to the minimum cost.\n if (cost < cost1 && cost < cost2) {\n break;\n }\n\n // Descend\n if (cost1 < cost2) {\n index = child1;\n } else {\n index = child2;\n }\n }\n\n const sibling = index;\n\n // Create a new parent.\n const oldParent = sibling.parent;\n const newParent = this.allocateNode();\n newParent.parent = oldParent;\n newParent.userData = null;\n newParent.aabb.combine(leafAABB, sibling.aabb);\n newParent.height = sibling.height + 1;\n\n if (oldParent != null) {\n // The sibling was not the root.\n if (oldParent.child1 === sibling) {\n oldParent.child1 = newParent;\n } else {\n oldParent.child2 = newParent;\n }\n\n newParent.child1 = sibling;\n newParent.child2 = leaf;\n sibling.parent = newParent;\n leaf.parent = newParent;\n } else {\n // The sibling was the root.\n newParent.child1 = sibling;\n newParent.child2 = leaf;\n sibling.parent = newParent;\n leaf.parent = newParent;\n this.m_root = newParent;\n }\n\n // Walk back up the tree fixing heights and AABBs\n index = leaf.parent;\n while (index != null) {\n index = this.balance(index);\n\n const child1 = index.child1;\n const child2 = index.child2;\n\n if (_ASSERT) console.assert(child1 != null);\n if (_ASSERT) console.assert(child2 != null);\n\n index.height = 1 + math_max(child1.height, child2.height);\n index.aabb.combine(child1.aabb, child2.aabb);\n\n index = index.parent;\n }\n\n // validate();\n }\n\n removeLeaf(leaf: TreeNode): void {\n if (leaf === this.m_root) {\n this.m_root = null;\n return;\n }\n\n const parent = leaf.parent;\n const grandParent = parent.parent;\n let sibling;\n if (parent.child1 === leaf) {\n sibling = parent.child2;\n } else {\n sibling = parent.child1;\n }\n\n if (grandParent != null) {\n // Destroy parent and connect sibling to grandParent.\n if (grandParent.child1 === parent) {\n grandParent.child1 = sibling;\n } else {\n grandParent.child2 = sibling;\n }\n sibling.parent = grandParent;\n this.freeNode(parent);\n\n // Adjust ancestor bounds.\n let index = grandParent;\n while (index != null) {\n index = this.balance(index);\n\n const child1 = index.child1;\n const child2 = index.child2;\n\n index.aabb.combine(child1.aabb, child2.aabb);\n index.height = 1 + math_max(child1.height, child2.height);\n\n index = index.parent;\n }\n } else {\n this.m_root = sibling;\n sibling.parent = null;\n this.freeNode(parent);\n }\n\n // validate();\n }\n\n /**\n * Perform a left or right rotation if node A is imbalanced. Returns the new\n * root index.\n */\n balance(iA: TreeNode): TreeNode {\n if (_ASSERT) console.assert(iA != null);\n\n const A = iA;\n if (A.isLeaf() || A.height < 2) {\n return iA;\n }\n\n const B = A.child1;\n const C = A.child2;\n\n const balance = C.height - B.height;\n\n // Rotate C up\n if (balance > 1) {\n const F = C.child1;\n const G = C.child2;\n\n // Swap A and C\n C.child1 = A;\n C.parent = A.parent;\n A.parent = C;\n\n // A's old parent should point to C\n if (C.parent != null) {\n if (C.parent.child1 === iA) {\n C.parent.child1 = C;\n } else {\n C.parent.child2 = C;\n }\n } else {\n this.m_root = C;\n }\n\n // Rotate\n if (F.height > G.height) {\n C.child2 = F;\n A.child2 = G;\n G.parent = A;\n A.aabb.combine(B.aabb, G.aabb);\n C.aabb.combine(A.aabb, F.aabb);\n\n A.height = 1 + math_max(B.height, G.height);\n C.height = 1 + math_max(A.height, F.height);\n } else {\n C.child2 = G;\n A.child2 = F;\n F.parent = A;\n A.aabb.combine(B.aabb, F.aabb);\n C.aabb.combine(A.aabb, G.aabb);\n\n A.height = 1 + math_max(B.height, F.height);\n C.height = 1 + math_max(A.height, G.height);\n }\n\n return C;\n }\n\n // Rotate B up\n if (balance < -1) {\n const D = B.child1;\n const E = B.child2;\n\n // Swap A and B\n B.child1 = A;\n B.parent = A.parent;\n A.parent = B;\n\n // A's old parent should point to B\n if (B.parent != null) {\n if (B.parent.child1 === A) {\n B.parent.child1 = B;\n } else {\n B.parent.child2 = B;\n }\n } else {\n this.m_root = B;\n }\n\n // Rotate\n if (D.height > E.height) {\n B.child2 = D;\n A.child1 = E;\n E.parent = A;\n A.aabb.combine(C.aabb, E.aabb);\n B.aabb.combine(A.aabb, D.aabb);\n\n A.height = 1 + math_max(C.height, E.height);\n B.height = 1 + math_max(A.height, D.height);\n } else {\n B.child2 = E;\n A.child1 = D;\n D.parent = A;\n A.aabb.combine(C.aabb, D.aabb);\n B.aabb.combine(A.aabb, E.aabb);\n\n A.height = 1 + math_max(C.height, D.height);\n B.height = 1 + math_max(A.height, E.height);\n }\n\n return B;\n }\n\n return A;\n }\n\n /**\n * Compute the height of the binary tree in O(N) time. Should not be called\n * often.\n */\n getHeight(): number {\n if (this.m_root == null) {\n return 0;\n }\n\n return this.m_root.height;\n }\n\n /**\n * Get the ratio of the sum of the node areas to the root area.\n */\n getAreaRatio(): number {\n if (this.m_root == null) {\n return 0.0;\n }\n\n const root = this.m_root;\n const rootArea = root.aabb.getPerimeter();\n\n let totalArea = 0.0;\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height < 0) {\n // Free node in pool\n continue;\n }\n\n totalArea += node.aabb.getPerimeter();\n }\n\n this.iteratorPool.release(it);\n\n return totalArea / rootArea;\n }\n\n /**\n * Compute the height of a sub-tree.\n */\n computeHeight(id?: number): number {\n let node;\n if (typeof id !== \"undefined\") {\n node = this.m_nodes[id];\n } else {\n node = this.m_root;\n }\n\n // if (_ASSERT) console.assert(0 <= id && id < this.m_nodeCapacity);\n\n if (node.isLeaf()) {\n return 0;\n }\n\n const height1 = this.computeHeight(node.child1.id);\n const height2 = this.computeHeight(node.child2.id);\n return 1 + math_max(height1, height2);\n }\n\n validateStructure(node: TreeNode): void {\n if (node == null) {\n return;\n }\n\n if (node === this.m_root) {\n if (_ASSERT) console.assert(node.parent == null);\n }\n\n const child1 = node.child1;\n const child2 = node.child2;\n\n if (node.isLeaf()) {\n if (_ASSERT) console.assert(child1 == null);\n if (_ASSERT) console.assert(child2 == null);\n if (_ASSERT) console.assert(node.height === 0);\n return;\n }\n\n // if (_ASSERT) console.assert(0 <= child1 && child1 < this.m_nodeCapacity);\n // if (_ASSERT) console.assert(0 <= child2 && child2 < this.m_nodeCapacity);\n\n if (_ASSERT) console.assert(child1.parent === node);\n if (_ASSERT) console.assert(child2.parent === node);\n\n this.validateStructure(child1);\n this.validateStructure(child2);\n }\n\n validateMetrics(node: TreeNode): void {\n if (node == null) {\n return;\n }\n\n const child1 = node.child1;\n const child2 = node.child2;\n\n if (node.isLeaf()) {\n if (_ASSERT) console.assert(child1 == null);\n if (_ASSERT) console.assert(child2 == null);\n if (_ASSERT) console.assert(node.height === 0);\n return;\n }\n\n // if (_ASSERT) console.assert(0 <= child1 && child1 < this.m_nodeCapacity);\n // if (_ASSERT) console.assert(0 <= child2 && child2 < this.m_nodeCapacity);\n\n const height1 = child1.height;\n const height2 = child2.height;\n const height = 1 + math_max(height1, height2);\n if (_ASSERT) console.assert(node.height === height);\n\n const aabb = new AABB();\n aabb.combine(child1.aabb, child2.aabb);\n\n if (_ASSERT) console.assert(AABB.areEqual(aabb, node.aabb));\n\n this.validateMetrics(child1);\n this.validateMetrics(child2);\n }\n\n /**\n * Validate this tree. For testing.\n */\n validate(): void {\n if (!_ASSERT) return;\n this.validateStructure(this.m_root);\n this.validateMetrics(this.m_root);\n\n console.assert(this.getHeight() === this.computeHeight());\n }\n\n /**\n * Get the maximum balance of an node in the tree. The balance is the difference\n * in height of the two children of a node.\n */\n getMaxBalance(): number {\n let maxBalance = 0;\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height <= 1) {\n continue;\n }\n\n if (_ASSERT) console.assert(!node.isLeaf());\n\n const balance = math_abs(node.child2.height - node.child1.height);\n maxBalance = math_max(maxBalance, balance);\n }\n this.iteratorPool.release(it);\n\n return maxBalance;\n }\n\n /**\n * Build an optimal tree. Very expensive. For testing.\n */\n rebuildBottomUp(): void {\n const nodes = [];\n let count = 0;\n\n // Build array of leaves. Free the rest.\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height < 0) {\n // free node in pool\n continue;\n }\n\n if (node.isLeaf()) {\n node.parent = null;\n nodes[count] = node;\n ++count;\n } else {\n this.freeNode(node);\n }\n }\n this.iteratorPool.release(it);\n\n while (count > 1) {\n let minCost = Infinity;\n let iMin = -1;\n let jMin = -1;\n for (let i = 0; i < count; ++i) {\n const aabbi = nodes[i].aabb;\n for (let j = i + 1; j < count; ++j) {\n const aabbj = nodes[j].aabb;\n const cost = AABB.combinedPerimeter(aabbi, aabbj);\n if (cost < minCost) {\n iMin = i;\n jMin = j;\n minCost = cost;\n }\n }\n }\n\n const child1 = nodes[iMin];\n const child2 = nodes[jMin];\n\n const parent = this.allocateNode();\n parent.child1 = child1;\n parent.child2 = child2;\n parent.height = 1 + math_max(child1.height, child2.height);\n parent.aabb.combine(child1.aabb, child2.aabb);\n parent.parent = null;\n\n child1.parent = parent;\n child2.parent = parent;\n\n nodes[jMin] = nodes[count - 1];\n nodes[iMin] = parent;\n --count;\n }\n\n this.m_root = nodes[0];\n\n if (_ASSERT) this.validate();\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n // Build array of leaves. Free the rest.\n let node;\n const it = this.iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n const aabb = node.aabb;\n aabb.lowerBound.x -= newOrigin.x;\n aabb.lowerBound.y -= newOrigin.y;\n aabb.upperBound.x -= newOrigin.x;\n aabb.upperBound.y -= newOrigin.y;\n }\n this.iteratorPool.release(it);\n }\n\n /**\n * Query an AABB for overlapping proxies. The callback class is called for each\n * proxy that overlaps the supplied AABB.\n */\n query(aabb: AABBValue, queryCallback: DynamicTreeQueryCallback): void {\n if (_ASSERT) console.assert(typeof queryCallback === \"function\");\n const stack = this.stackPool.allocate();\n\n stack.push(this.m_root);\n while (stack.length > 0) {\n const node = stack.pop();\n if (node == null) {\n continue;\n }\n\n if (AABB.testOverlap(node.aabb, aabb)) {\n if (node.isLeaf()) {\n const proceed = queryCallback(node.id);\n if (proceed === false) {\n return;\n }\n } else {\n stack.push(node.child1);\n stack.push(node.child2);\n }\n }\n }\n\n this.stackPool.release(stack);\n }\n\n /**\n * Ray-cast against the proxies in the tree. This relies on the callback to\n * perform a exact ray-cast in the case were the proxy contains a shape. The\n * callback also performs the any collision filtering. This has performance\n * roughly equal to k * log(n), where k is the number of collisions and n is the\n * number of proxies in the tree.\n *\n * @param input The ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n * @param rayCastCallback A function that is called for each proxy that is hit by the ray. If the return value is a positive number it will update the maxFraction of the ray cast input, and if it is zero it will terminate they ray cast.\n */\n rayCast(input: RayCastInput, rayCastCallback: RayCastCallback): void {\n // TODO: GC\n if (_ASSERT) console.assert(typeof rayCastCallback === \"function\");\n const p1 = input.p1;\n const p2 = input.p2;\n const r = Vec2.sub(p2, p1);\n if (_ASSERT) console.assert(r.lengthSquared() > 0.0);\n r.normalize();\n\n // v is perpendicular to the segment.\n const v = Vec2.crossNumVec2(1.0, r);\n const abs_v = Vec2.abs(v);\n\n // Separating axis for segment (Gino, p80).\n // |dot(v, p1 - c)| > dot(|v|, h)\n\n let maxFraction = input.maxFraction;\n\n // Build a bounding box for the segment.\n const segmentAABB = new AABB();\n let t = Vec2.combine((1 - maxFraction), p1, maxFraction, p2);\n segmentAABB.combinePoints(p1, t);\n\n const stack = this.stackPool.allocate();\n const subInput = this.inputPool.allocate();\n\n stack.push(this.m_root);\n while (stack.length > 0) {\n const node = stack.pop();\n if (node == null) {\n continue;\n }\n\n if (AABB.testOverlap(node.aabb, segmentAABB) === false) {\n continue;\n }\n\n // Separating axis for segment (Gino, p80).\n // |dot(v, p1 - c)| > dot(|v|, h)\n const c = node.aabb.getCenter();\n const h = node.aabb.getExtents();\n const separation = math_abs(Vec2.dot(v, Vec2.sub(p1, c))) - Vec2.dot(abs_v, h);\n if (separation > 0.0) {\n continue;\n }\n\n if (node.isLeaf()) {\n subInput.p1 = Vec2.clone(input.p1);\n subInput.p2 = Vec2.clone(input.p2);\n subInput.maxFraction = maxFraction;\n\n const value = rayCastCallback(subInput, node.id);\n\n if (value === 0.0) {\n // The client has terminated the ray cast.\n break;\n } else if (value > 0.0) {\n // update segment bounding box.\n maxFraction = value;\n t = Vec2.combine((1 - maxFraction), p1, maxFraction, p2);\n segmentAABB.combinePoints(p1, t);\n }\n } else {\n stack.push(node.child1);\n stack.push(node.child2);\n }\n }\n this.stackPool.release(stack);\n this.inputPool.release(subInput);\n }\n\n private inputPool: Pool = new Pool({\n create(): RayCastInput {\n // tslint:disable-next-line:no-object-literal-type-assertion\n return {} as RayCastInput;\n },\n release(stack: RayCastInput): void {\n }\n });\n\n private stackPool: Pool>> = new Pool>>({\n create(): Array> {\n return [];\n },\n release(stack: Array>): void {\n stack.length = 0;\n }\n });\n\n private iteratorPool: Pool> = new Pool>({\n create(): Iterator {\n return new Iterator();\n },\n release(iterator: Iterator): void {\n iterator.close();\n }\n });\n\n}\n\n/** @internal */\nclass Iterator {\n parents: Array> = [];\n states: number[] = [];\n preorder(root: TreeNode): Iterator {\n this.parents.length = 0;\n this.parents.push(root);\n this.states.length = 0;\n this.states.push(0);\n return this;\n }\n next(): TreeNode {\n while (this.parents.length > 0) {\n const i = this.parents.length - 1;\n const node = this.parents[i];\n if (this.states[i] === 0) {\n this.states[i] = 1;\n return node;\n }\n if (this.states[i] === 1) {\n this.states[i] = 2;\n if (node.child1) {\n this.parents.push(node.child1);\n this.states.push(1);\n return node.child1;\n }\n }\n if (this.states[i] === 2) {\n this.states[i] = 3;\n if (node.child2) {\n this.parents.push(node.child2);\n this.states.push(1);\n return node.child2;\n }\n }\n this.parents.pop();\n this.states.pop();\n }\n }\n close(): void {\n this.parents.length = 0;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2Value } from \"../common/Vec2\";\nimport { AABB, AABBValue, RayCastCallback, RayCastInput } from \"./AABB\";\nimport { DynamicTree, DynamicTreeQueryCallback } from \"./DynamicTree\";\nimport { FixtureProxy } from \"../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/**\n * The broad-phase wraps and extends a dynamic-tree to keep track of moved\n * objects and query them on update.\n */\nexport class BroadPhase {\n m_tree: DynamicTree = new DynamicTree();\n m_moveBuffer: number[] = [];\n\n m_callback: (userDataA: any, userDataB: any) => void;\n m_queryProxyId: number;\n\n /**\n * Get user data from a proxy. Returns null if the id is invalid.\n */\n getUserData(proxyId: number): FixtureProxy {\n return this.m_tree.getUserData(proxyId);\n }\n\n /**\n * Test overlap of fat AABBs.\n */\n testOverlap(proxyIdA: number, proxyIdB: number): boolean {\n const aabbA = this.m_tree.getFatAABB(proxyIdA);\n const aabbB = this.m_tree.getFatAABB(proxyIdB);\n return AABB.testOverlap(aabbA, aabbB);\n }\n\n /**\n * Get the fat AABB for a proxy.\n */\n getFatAABB(proxyId: number): AABB {\n return this.m_tree.getFatAABB(proxyId);\n }\n\n /**\n * Get the number of proxies.\n */\n getProxyCount(): number {\n return this.m_moveBuffer.length;\n }\n\n /**\n * Get the height of the embedded tree.\n */\n getTreeHeight(): number {\n return this.m_tree.getHeight();\n }\n\n /**\n * Get the balance (integer) of the embedded tree.\n */\n getTreeBalance(): number {\n return this.m_tree.getMaxBalance();\n }\n\n /**\n * Get the quality metric of the embedded tree.\n */\n getTreeQuality(): number {\n return this.m_tree.getAreaRatio();\n }\n\n /**\n * Query an AABB for overlapping proxies. The callback class is called for each\n * proxy that overlaps the supplied AABB.\n */\n query = (aabb: AABBValue, queryCallback: DynamicTreeQueryCallback): void => {\n this.m_tree.query(aabb, queryCallback);\n };\n\n /**\n * Ray-cast against the proxies in the tree. This relies on the callback to\n * perform a exact ray-cast in the case were the proxy contains a shape. The\n * callback also performs the any collision filtering. This has performance\n * roughly equal to k * log(n), where k is the number of collisions and n is the\n * number of proxies in the tree.\n *\n * @param input The ray-cast input data. The ray extends from `p1` to `p1 + maxFraction * (p2 - p1)`.\n * @param rayCastCallback A function that is called for each proxy that is hit by the ray. If the return value is a positive number it will update the maxFraction of the ray cast input, and if it is zero it will terminate they ray cast.\n */\n rayCast(input: RayCastInput, rayCastCallback: RayCastCallback): void {\n this.m_tree.rayCast(input, rayCastCallback);\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_tree.shiftOrigin(newOrigin);\n }\n\n /**\n * Create a proxy with an initial AABB. Pairs are not reported until UpdatePairs\n * is called.\n */\n createProxy(aabb: AABBValue, userData: FixtureProxy): number {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n const proxyId = this.m_tree.createProxy(aabb, userData);\n this.bufferMove(proxyId);\n return proxyId;\n }\n\n /**\n * Destroy a proxy. It is up to the client to remove any pairs.\n */\n destroyProxy(proxyId: number): void {\n this.unbufferMove(proxyId);\n this.m_tree.destroyProxy(proxyId);\n }\n\n /**\n * Call moveProxy as many times as you like, then when you are done call\n * UpdatePairs to finalized the proxy pairs (for your time step).\n */\n moveProxy(proxyId: number, aabb: AABB, displacement: Vec2Value): void {\n if (_ASSERT) console.assert(AABB.isValid(aabb));\n const changed = this.m_tree.moveProxy(proxyId, aabb, displacement);\n if (changed) {\n this.bufferMove(proxyId);\n }\n }\n\n /**\n * Call to trigger a re-processing of it's pairs on the next call to\n * UpdatePairs.\n */\n touchProxy(proxyId: number): void {\n this.bufferMove(proxyId);\n }\n\n bufferMove(proxyId: number): void {\n this.m_moveBuffer.push(proxyId);\n }\n\n unbufferMove(proxyId: number): void {\n for (let i = 0; i < this.m_moveBuffer.length; ++i) {\n if (this.m_moveBuffer[i] === proxyId) {\n this.m_moveBuffer[i] = null;\n }\n }\n }\n\n /**\n * Update the pairs. This results in pair callbacks. This can only add pairs.\n */\n updatePairs(addPairCallback: (userDataA: FixtureProxy, userDataB: FixtureProxy) => void): void {\n if (_ASSERT) console.assert(typeof addPairCallback === \"function\");\n this.m_callback = addPairCallback;\n\n // Perform tree queries for all moving proxies.\n while (this.m_moveBuffer.length > 0) {\n this.m_queryProxyId = this.m_moveBuffer.pop();\n if (this.m_queryProxyId === null) {\n continue;\n }\n\n // We have to query the tree with the fat AABB so that\n // we don't fail to create a pair that may touch later.\n const fatAABB = this.m_tree.getFatAABB(this.m_queryProxyId);\n\n // Query tree, create pairs and add them pair buffer.\n this.m_tree.query(fatAABB, this.queryCallback);\n }\n\n // Try to keep the tree balanced.\n // this.m_tree.rebalance(4);\n }\n\n queryCallback = (proxyId: number): boolean => {\n // A proxy cannot form a pair with itself.\n if (proxyId === this.m_queryProxyId) {\n return true;\n }\n\n const proxyIdA = math_min(proxyId, this.m_queryProxyId);\n const proxyIdB = math_max(proxyId, this.m_queryProxyId);\n\n // TODO: Skip any duplicate pairs.\n\n const userDataA = this.m_tree.getUserData(proxyIdA);\n const userDataB = this.m_tree.getUserData(proxyIdB);\n\n // Send the pairs back to the client.\n this.m_callback(userDataA, userDataB);\n\n return true;\n };\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n/** @internal */ const math_sqrt = Math.sqrt;\n\n\nimport { RotValue } from \"./Rot\";\nimport { TransformValue } from \"./Transform\";\nimport { Vec2Value } from \"./Vec2\";\nimport { Vec3Value } from \"./Vec3\";\n\nexport function vec2(x: number, y: number): Vec2Value {\n return { x, y };\n}\n\nexport function vec3(x: number, y: number, z: number): Vec3Value {\n return { x, y, z };\n}\n\nexport function rotation(angle: number): RotValue {\n return { s: math_sin(angle), c: math_cos(angle) };\n}\n\nexport function setVec2(out: Vec2Value, x: number, y: number): Vec2Value {\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function copyVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = w.x;\n out.y = w.y;\n return out;\n}\n\nexport function zeroVec2(out: Vec2Value): Vec2Value {\n out.x = 0;\n out.y = 0;\n return out;\n}\n\nexport function negVec2(out: Vec2Value): Vec2Value {\n out.x = -out.x;\n out.y = -out.y;\n return out;\n}\n\nexport function plusVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x += w.x;\n out.y += w.y;\n return out;\n}\n\nexport function addVec2(out: Vec2Value, v: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = v.x + w.x;\n out.y = v.x + w.y;\n return out;\n}\n\nexport function minusVec2(out: Vec2Value, w: Vec2Value): Vec2Value {\n out.x -= w.x;\n out.y -= w.y;\n return out;\n}\n\nexport function subVec2(out: Vec2Value, v: Vec2Value, w: Vec2Value): Vec2Value {\n out.x = v.x - w.x;\n out.y = v.y - w.y;\n return out;\n}\n\nexport function mulVec2(out: Vec2Value, m: number): Vec2Value {\n out.x *= m;\n out.y *= m;\n return out;\n}\n\nexport function scaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x = m * w.x;\n out.y = m * w.y;\n return out;\n}\n\nexport function plusScaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x += m * w.x;\n out.y += m * w.y;\n return out;\n}\n\nexport function minusScaleVec2(out: Vec2Value, m: number, w: Vec2Value): Vec2Value {\n out.x -= m * w.x;\n out.y -= m * w.y;\n return out;\n}\n\nexport function combine2Vec2(out: Vec2Value, am: number, a: Vec2Value, bm: number, b: Vec2Value): Vec2Value {\n out.x = am * a.x + bm * b.x;\n out.y = am * a.y + bm * b.y;\n return out;\n}\n\nexport function combine3Vec2(out: Vec2Value, am: number, a: Vec2Value, bm: number, b: Vec2Value, cm: number, c: Vec2Value): Vec2Value {\n out.x = am * a.x + bm * b.x + cm * c.x;\n out.y = am * a.y + bm * b.y + cm * c.y;\n return out;\n}\n\nexport function normalizeVec2Length(out: Vec2Value): number {\n const length = math_sqrt(out.x * out.x + out.y * out.y);\n if (length !== 0) {\n const invLength = 1 / length;\n out.x *= invLength;\n out.y *= invLength;\n }\n return length;\n}\n\nexport function normalizeVec2(out: Vec2Value): Vec2Value {\n const length = math_sqrt(out.x * out.x + out.y * out.y);\n if (length > 0) {\n const invLength = 1 / length;\n out.x *= invLength;\n out.y *= invLength;\n }\n return out;\n}\n\nexport function crossVec2Num(out: Vec2Value, v: Vec2Value, w: number): Vec2Value {\n const x = w * v.y;\n const y = -w * v.x;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function crossNumVec2(out: Vec2Value, w: number, v: Vec2Value): Vec2Value {\n const x = -w * v.y;\n const y = w * v.x;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function crossVec2Vec2(a: Vec2Value, b: Vec2Value): number {\n return a.x * b.y - a.y * b.x;\n}\n\nexport function dotVec2(a: Vec2Value, b: Vec2Value): number {\n return a.x * b.x + a.y * b.y;\n}\n\nexport function lengthVec2(a: Vec2Value): number {\n return math_sqrt(a.x * a.x + a.y * a.y);\n}\n\nexport function lengthSqrVec2(a: Vec2Value): number {\n return a.x * a.x + a.y * a.y;\n}\n\nexport function distVec2(a: Vec2Value, b: Vec2Value): number {\n const dx = a.x - b.x;\n const dy = a.y - b.y;\n return math_sqrt(dx * dx + dy * dy);\n}\n\nexport function distSqrVec2(a: Vec2Value, b: Vec2Value): number {\n const dx = a.x - b.x;\n const dy = a.y - b.y;\n return dx * dx + dy * dy;\n}\n\nexport function dotVec3(v: Vec3Value, w: Vec3Value): number {\n return v.x * w.x + v.y * w.y + v.z * w.z;\n}\n\nexport function setRotAngle(out: RotValue, a: number): RotValue {\n out.c = math_cos(a);\n out.s = math_sin(a);\n return out;\n}\n\nexport function rotVec2(out: Vec2Value, q: RotValue, v: Vec2Value): Vec2Value {\n out.x = q.c * v.x - q.s * v.y;\n out.y = q.s * v.x + q.c * v.y;\n return out;\n}\n\nexport function derotVec2(out: Vec2Value, q: RotValue, v: Vec2Value): Vec2Value {\n const x = q.c * v.x + q.s * v.y;\n const y = -q.s * v.x + q.c * v.y;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function rerotVec2(out: Vec2Value, before: RotValue, after: RotValue, v: Vec2Value): Vec2Value {\n const x0 = before.c * v.x + before.s * v.y;\n const y0 = -before.s * v.x + before.c * v.y;\n const x = after.c * x0 - after.s * y0;\n const y = after.s * x0 + after.c * y0;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function transform(x: number, y: number, a: number): TransformValue {\n return { p: vec2(x, y), q: rotation(a) };\n}\n\nexport function copyTransform(out: TransformValue, transform: TransformValue): TransformValue {\n out.p.x = transform.p.x;\n out.p.y = transform.p.y;\n out.q.s = transform.q.s;\n out.q.c = transform.q.c;\n return out;\n}\n\nexport function transformVec2(out: Vec2Value, xf: TransformValue, v: Vec2Value): Vec2Value {\n const x = xf.q.c * v.x - xf.q.s * v.y + xf.p.x;\n const y = xf.q.s * v.x + xf.q.c * v.y + xf.p.y;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function detransformVec2(out: Vec2Value, xf: TransformValue, v: Vec2Value): Vec2Value {\n const px = v.x - xf.p.x;\n const py = v.y - xf.p.y;\n const x = (xf.q.c * px + xf.q.s * py);\n const y = (-xf.q.s * px + xf.q.c * py);\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function retransformVec2(out: Vec2Value, from: TransformValue, to: TransformValue, v: Vec2Value): Vec2Value {\n const x0 = from.q.c * v.x - from.q.s * v.y + from.p.x;\n const y0 = from.q.s * v.x + from.q.c * v.y + from.p.y;\n const px = x0 - to.p.x;\n const py = y0 - to.p.y;\n const x = to.q.c * px + to.q.s * py;\n const y = -to.q.s * px + to.q.c * py;\n out.x = x;\n out.y = y;\n return out;\n}\n\nexport function detransformTransform(out: TransformValue, a: TransformValue, b: TransformValue): TransformValue {\n const c = a.q.c * b.q.c + a.q.s * b.q.s;\n const s = a.q.c * b.q.s - a.q.s * b.q.c;\n const x = a.q.c * (b.p.x - a.p.x) + a.q.s * (b.p.y - a.p.y);\n const y = -a.q.s * (b.p.x - a.p.x) + a.q.c * (b.p.y - a.p.y);\n out.q.c = c;\n out.q.s = s;\n out.p.x = x;\n out.p.y = y;\n return out;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n/** @internal */ const math_atan2 = Math.atan2;\n\nexport interface RotValue {\n /** sin(angle) */\n s: number;\n /** cos(angle) */\n c: number;\n}\n\ndeclare module \"./Rot\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(angle: number): Rot;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(obj: RotValue): Rot;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Rot(): Rot;\n}\n\n/** Rotation */\n// @ts-expect-error\nexport class Rot {\n /** sin(angle) */\n s: number;\n /** cos(angle) */\n c: number;\n\n /** Initialize from an angle in radians. */\n constructor(angle?: number | RotValue) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Rot)) {\n return new Rot(angle);\n }\n if (typeof angle === \"number\") {\n this.setAngle(angle);\n } else if (typeof angle === \"object\") {\n this.setRot(angle);\n } else {\n this.setIdentity();\n }\n }\n\n /** @hidden */\n static neo(angle: number): Rot {\n const obj = Object.create(Rot.prototype);\n obj.setAngle(angle);\n return obj;\n }\n\n static clone(rot: RotValue): Rot {\n if (_ASSERT) Rot.assert(rot);\n const obj = Object.create(Rot.prototype);\n obj.s = rot.s;\n obj.c = rot.c;\n return obj;\n }\n\n static identity(): Rot {\n const obj = Object.create(Rot.prototype);\n obj.s = 0.0;\n obj.c = 1.0;\n return obj;\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.s) && Number.isFinite(obj.c);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Rot.isValid(o), \"Invalid Rot!\", o);\n }\n\n /** Set to the identity rotation. */\n setIdentity(): void {\n this.s = 0.0;\n this.c = 1.0;\n }\n\n set(angle: number | RotValue): void {\n if (typeof angle === \"object\") {\n if (_ASSERT) Rot.assert(angle);\n this.s = angle.s;\n this.c = angle.c;\n\n } else {\n if (_ASSERT) console.assert(Number.isFinite(angle));\n // TODO_ERIN optimize\n this.s = math_sin(angle);\n this.c = math_cos(angle);\n }\n }\n\n setRot(angle: RotValue): void {\n if (_ASSERT) Rot.assert(angle);\n this.s = angle.s;\n this.c = angle.c;\n }\n\n /** Set using an angle in radians. */\n setAngle(angle: number): void {\n if (_ASSERT) console.assert(Number.isFinite(angle));\n // TODO_ERIN optimize\n this.s = math_sin(angle);\n this.c = math_cos(angle);\n }\n\n /** Get the angle in radians. */\n getAngle(): number {\n return math_atan2(this.s, this.c);\n }\n\n /** Get the x-axis. */\n getXAxis(): Vec2 {\n return Vec2.neo(this.c, this.s);\n }\n\n /** Get the y-axis. */\n getYAxis(): Vec2 {\n return Vec2.neo(-this.s, this.c);\n }\n\n /** Multiply two rotations: q * r */\n static mul(rot: RotValue, m: RotValue): Rot;\n /** Rotate a vector */\n static mul(rot: RotValue, m: Vec2Value): Vec2;\n static mul(rot, m) {\n if (_ASSERT) Rot.assert(rot);\n if (\"c\" in m && \"s\" in m) {\n if (_ASSERT) Rot.assert(m);\n // [qc -qs] * [rc -rs] = [qc*rc-qs*rs -qc*rs-qs*rc]\n // [qs qc] [rs rc] [qs*rc+qc*rs -qs*rs+qc*rc]\n // s = qs * rc + qc * rs\n // c = qc * rc - qs * rs\n const qr = Rot.identity();\n qr.s = rot.s * m.c + rot.c * m.s;\n qr.c = rot.c * m.c - rot.s * m.s;\n return qr;\n\n } else if (\"x\" in m && \"y\" in m) {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x - rot.s * m.y, rot.s * m.x + rot.c * m.y);\n }\n }\n\n /** Multiply two rotations: q * r */\n static mulRot(rot: RotValue, m: RotValue): Rot {\n if (_ASSERT) Rot.assert(rot);\n if (_ASSERT) Rot.assert(m);\n // [qc -qs] * [rc -rs] = [qc*rc-qs*rs -qc*rs-qs*rc]\n // [qs qc] [rs rc] [qs*rc+qc*rs -qs*rs+qc*rc]\n // s = qs * rc + qc * rs\n // c = qc * rc - qs * rs\n const qr = Rot.identity();\n qr.s = rot.s * m.c + rot.c * m.s;\n qr.c = rot.c * m.c - rot.s * m.s;\n return qr;\n }\n\n /** Rotate a vector */\n static mulVec2(rot: RotValue, m: Vec2Value): Vec2 {\n if (_ASSERT) Rot.assert(rot);\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x - rot.s * m.y, rot.s * m.x + rot.c * m.y);\n }\n\n static mulSub(rot: RotValue, v: Vec2Value, w: Vec2Value): Vec2 {\n const x = rot.c * (v.x - w.x) - rot.s * (v.y - w.y);\n const y = rot.s * (v.x - w.x) + rot.c * (v.y - w.y);\n return Vec2.neo(x, y);\n }\n\n /** Transpose multiply two rotations: qT * r */\n static mulT(rot: RotValue, m: RotValue): Rot;\n /** Inverse rotate a vector */\n static mulT(rot: RotValue, m: Vec2Value): Vec2;\n static mulT(rot, m) {\n if (\"c\" in m && \"s\" in m) {\n if (_ASSERT) Rot.assert(m);\n // [ qc qs] * [rc -rs] = [qc*rc+qs*rs -qc*rs+qs*rc]\n // [-qs qc] [rs rc] [-qs*rc+qc*rs qs*rs+qc*rc]\n // s = qc * rs - qs * rc\n // c = qc * rc + qs * rs\n const qr = Rot.identity();\n qr.s = rot.c * m.s - rot.s * m.c;\n qr.c = rot.c * m.c + rot.s * m.s;\n return qr;\n\n } else if (\"x\" in m && \"y\" in m) {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x + rot.s * m.y, -rot.s * m.x + rot.c * m.y);\n }\n }\n\n /** Transpose multiply two rotations: qT * r */\n static mulTRot(rot: RotValue, m: RotValue): Rot {\n if (_ASSERT) Rot.assert(m);\n // [ qc qs] * [rc -rs] = [qc*rc+qs*rs -qc*rs+qs*rc]\n // [-qs qc] [rs rc] [-qs*rc+qc*rs qs*rs+qc*rc]\n // s = qc * rs - qs * rc\n // c = qc * rc + qs * rs\n const qr = Rot.identity();\n qr.s = rot.c * m.s - rot.s * m.c;\n qr.c = rot.c * m.c + rot.s * m.s;\n return qr;\n }\n\n /** Inverse rotate a vector */\n static mulTVec2(rot: RotValue, m: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(m);\n return Vec2.neo(rot.c * m.x + rot.s * m.y, -rot.s * m.x + rot.c * m.y);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"./Matrix\";\nimport { mod } from \"./Math\";\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { TransformValue } from \"./Transform\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_atan2 = Math.atan2;\n/** @internal */ const math_PI = Math.PI;\n\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n\n/**\n * This describes the motion of a body/shape for TOI computation. Shapes are\n * defined with respect to the body origin, which may not coincide with the\n * center of mass. However, to support dynamics we must interpolate the center\n * of mass position.\n */\nexport class Sweep {\n /** Local center of mass position */\n localCenter = Vec2.zero();\n\n /** World center position */\n c = Vec2.zero();\n\n /** World angle */\n a = 0;\n\n /** Fraction of the current time step in the range [0,1], c0 and a0 are c and a at alpha0. */\n alpha0 = 0;\n\n c0 = Vec2.zero();\n a0 = 0;\n\n /** @internal */\n recycle() {\n matrix.zeroVec2(this.localCenter);\n matrix.zeroVec2(this.c);\n this.a = 0;\n this.alpha0 = 0;\n matrix.zeroVec2(this.c0);\n this.a0 = 0;\n }\n\n setTransform(xf: TransformValue): void {\n matrix.transformVec2(temp, xf, this.localCenter);\n matrix.copyVec2(this.c, temp);\n matrix.copyVec2(this.c0, temp);\n\n this.a = this.a0 = math_atan2(xf.q.s, xf.q.c);\n }\n\n setLocalCenter(localCenter: Vec2Value, xf: TransformValue): void {\n matrix.copyVec2(this.localCenter, localCenter);\n\n matrix.transformVec2(temp, xf, this.localCenter);\n matrix.copyVec2(this.c, temp);\n matrix.copyVec2(this.c0, temp);\n }\n\n /**\n * Get the interpolated transform at a specific time.\n *\n * @param xf\n * @param beta A factor in [0,1], where 0 indicates alpha0\n */\n getTransform(xf: TransformValue, beta: number = 0): void {\n matrix.setRotAngle(xf.q, (1.0 - beta) * this.a0 + beta * this.a);\n matrix.combine2Vec2(xf.p, (1.0 - beta), this.c0, beta, this.c);\n\n // shift to origin\n matrix.minusVec2(xf.p, matrix.rotVec2(temp, xf.q, this.localCenter));\n }\n\n /**\n * Advance the sweep forward, yielding a new initial state.\n *\n * @param alpha The new initial time\n */\n advance(alpha: number): void {\n if (_ASSERT) console.assert(this.alpha0 < 1.0);\n const beta = (alpha - this.alpha0) / (1.0 - this.alpha0);\n matrix.combine2Vec2(this.c0, beta, this.c, 1 - beta, this.c0);\n this.a0 = beta * this.a + (1 - beta) * this.a0;\n this.alpha0 = alpha;\n }\n\n forward(): void {\n this.a0 = this.a;\n matrix.copyVec2(this.c0, this.c);\n }\n\n /**\n * normalize the angles in radians to be between -pi and pi.\n */\n normalize(): void {\n const a0 = mod(this.a0, -math_PI, +math_PI);\n this.a -= this.a0 - a0;\n this.a0 = a0;\n }\n\n set(that: Sweep): void {\n matrix.copyVec2(this.localCenter, that.localCenter);\n matrix.copyVec2(this.c, that.c);\n this.a = that.a;\n this.alpha0 = that.alpha0;\n matrix.copyVec2(this.c0, that.c0);\n this.a0 = that.a0;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { Rot, RotValue } from \"./Rot\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\nexport type TransformValue = {\n p: Vec2Value;\n q: RotValue;\n};\n\ndeclare module \"./Transform\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Transform(position?: Vec2Value, rotation?: number): Transform;\n}\n\n/**\n * A transform contains translation and rotation. It is used to represent the\n * position and orientation of rigid frames. Initialize using a position vector\n * and a rotation.\n */\n// @ts-expect-error\nexport class Transform {\n /** position */\n p: Vec2;\n\n /** rotation */\n q: Rot;\n\n constructor(position?: Vec2Value, rotation?: number) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Transform)) {\n return new Transform(position, rotation);\n }\n this.p = Vec2.zero();\n this.q = Rot.identity();\n if (typeof position !== \"undefined\") {\n this.p.setVec2(position);\n }\n if (typeof rotation !== \"undefined\") {\n this.q.setAngle(rotation);\n }\n }\n\n static clone(xf: Transform): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.clone(xf.p);\n obj.q = Rot.clone(xf.q);\n return obj;\n }\n\n /** @hidden */\n static neo(position: Vec2Value, rotation: Rot): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.clone(position);\n obj.q = Rot.clone(rotation);\n return obj;\n }\n\n static identity(): Transform {\n const obj = Object.create(Transform.prototype);\n obj.p = Vec2.zero();\n obj.q = Rot.identity();\n return obj;\n }\n\n /** Set this to the identity transform */\n setIdentity(): void {\n this.p.setZero();\n this.q.setIdentity();\n }\n\n /** Set position and angle */\n set(position: Vec2Value, rotation: number): void;\n /** Copy from another transform */\n set(xf: TransformValue): void;\n set(a: any, b?: any) {\n if (typeof b === \"undefined\") {\n this.p.set(a.p);\n this.q.set(a.q);\n } else {\n this.p.set(a);\n this.q.set(b);\n }\n }\n\n /** Set position and angle */\n setNum(position: Vec2Value, rotation: number) {\n this.p.setVec2(position);\n this.q.setAngle(rotation);\n }\n\n setTransform(xf: TransformValue): void {\n this.p.setVec2(xf.p);\n this.q.setRot(xf.q);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.p) && Rot.isValid(obj.q);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Transform.isValid(o), \"Invalid Transform!\", o);\n }\n\n static mul(a: TransformValue, b: Vec2Value): Vec2;\n static mul(a: TransformValue, b: TransformValue): Transform;\n // static mul(a: Transform, b: Vec2Value[]): Vec2[];\n // static mul(a: Transform, b: Transform[]): Transform[];\n static mul(a, b) {\n if (Array.isArray(b)) {\n // todo: this was used in examples, remove in the future\n if (_ASSERT) Transform.assert(a);\n const arr = [];\n for (let i = 0; i < b.length; i++) {\n arr[i] = Transform.mul(a, b[i]);\n }\n return arr;\n\n } else if (\"x\" in b && \"y\" in b) {\n return Transform.mulVec2(a, b);\n\n } else if (\"p\" in b && \"q\" in b) {\n return Transform.mulXf(a, b);\n }\n }\n\n static mulAll(a: Transform, b: Vec2Value[]): Vec2[];\n static mulAll(a: Transform, b: Transform[]): Transform[];\n static mulAll(a: TransformValue, b) {\n if (_ASSERT) Transform.assert(a);\n const arr = [];\n for (let i = 0; i < b.length; i++) {\n arr[i] = Transform.mul(a, b[i]);\n }\n return arr;\n }\n\n /** @hidden @deprecated */\n static mulFn(a: TransformValue) {\n // todo: this was used in examples, remove in the future\n if (_ASSERT) Transform.assert(a);\n return function(b: Vec2Value): Vec2 {\n return Transform.mul(a, b);\n };\n }\n\n static mulVec2(a: TransformValue, b: Vec2Value): Vec2 {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const x = (a.q.c * b.x - a.q.s * b.y) + a.p.x;\n const y = (a.q.s * b.x + a.q.c * b.y) + a.p.y;\n return Vec2.neo(x, y);\n }\n\n static mulXf(a: TransformValue, b: TransformValue): Transform {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Transform.assert(b);\n // v2 = A.q.Rot(B.q.Rot(v1) + B.p) + A.p\n // = (A.q * B.q).Rot(v1) + A.q.Rot(B.p) + A.p\n const xf = Transform.identity();\n xf.q = Rot.mulRot(a.q, b.q);\n xf.p = Vec2.add(Rot.mulVec2(a.q, b.p), a.p);\n return xf;\n }\n\n static mulT(a: TransformValue, b: Vec2Value): Vec2;\n static mulT(a: TransformValue, b: TransformValue): Transform;\n static mulT(a, b) {\n if (\"x\" in b && \"y\" in b) {\n return Transform.mulTVec2(a, b);\n\n } else if (\"p\" in b && \"q\" in b) {\n return Transform.mulTXf(a, b);\n }\n }\n\n static mulTVec2(a: TransformValue, b: Vec2Value): Vec2 {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const px = b.x - a.p.x;\n const py = b.y - a.p.y;\n const x = (a.q.c * px + a.q.s * py);\n const y = (-a.q.s * px + a.q.c * py);\n return Vec2.neo(x, y);\n }\n\n static mulTXf(a: TransformValue, b: TransformValue): Transform {\n if (_ASSERT) Transform.assert(a);\n if (_ASSERT) Transform.assert(b);\n // v2 = A.q' * (B.q * v1 + B.p - A.p)\n // = A.q' * B.q * v1 + A.q' * (B.p - A.p)\n const xf = Transform.identity();\n xf.q.setRot(Rot.mulTRot(a.q, b.q));\n xf.p.setVec2(Rot.mulTVec2(a.q, Vec2.sub(b.p, a.p)));\n return xf;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2 } from \"../common/Vec2\";\n\nexport class Velocity {\n /** linear */\n v = Vec2.zero();\n\n /** angular */\n w = 0;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { TransformValue } from \"../common/Transform\";\n\n\n/** @internal */ const math_sin = Math.sin;\n/** @internal */ const math_cos = Math.cos;\n\n\nexport class Position {\n /** location */\n c = Vec2.zero();\n\n /** angle */\n a = 0;\n\n // todo: cache sin/cos\n getTransform(xf: TransformValue, p: Vec2Value): TransformValue {\n // xf.q = rotation(this.a);\n // xf.p = this.c - xf.q * p\n xf.q.c = math_cos(this.a);\n xf.q.s = math_sin(this.a);\n xf.p.x = this.c.x - (xf.q.c * p.x - xf.q.s * p.y);\n xf.p.y = this.c.y - (xf.q.s * p.x + xf.q.c * p.y);\n return xf;\n }\n}\n\nexport function getTransform(xf: TransformValue, p: Vec2Value, c: Vec2Value, a: number): TransformValue {\n // xf.q = rotation(a);\n // xf.p = this.c - xf.q * p\n xf.q.c = math_cos(a);\n xf.q.s = math_sin(a);\n xf.p.x = c.x - (xf.q.c * p.x - xf.q.s * p.y);\n xf.p.y = c.y - (xf.q.s * p.x + xf.q.c * p.y);\n return xf;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { MassData } from \"../dynamics/Body\";\nimport { RayCastOutput, RayCastInput, AABBValue } from \"./AABB\";\nimport { DistanceProxy } from \"./Distance\";\nimport type { Transform, TransformValue } from \"../common/Transform\";\nimport type { Vec2Value } from \"../common/Vec2\";\nimport { Style } from \"../util/Testbed\";\n\n// todo make shape an interface\n\n/**\n * A shape is used for collision detection. You can create a shape however you\n * like. Shapes used for simulation in World are created automatically when a\n * Fixture is created. Shapes may encapsulate one or more child shapes.\n */\nexport abstract class Shape {\n /** @hidden */ m_type: ShapeType;\n\n /**\n * @hidden\n * Radius of a shape. For polygonal shapes this must be b2_polygonRadius.\n * There is no support for making rounded polygons.\n */\n m_radius: number;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n /** @hidden */\n abstract _reset(): void;\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return typeof obj.m_type === \"string\" && typeof obj.m_radius === \"number\";\n }\n\n abstract getRadius(): number;\n\n /**\n * Get the type of this shape. You can use this to down cast to the concrete\n * shape.\n *\n * @return the shape type.\n */\n abstract getType(): ShapeType;\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n abstract _clone(): Shape;\n\n /**\n * Get the number of child primitives.\n */\n abstract getChildCount(): number;\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n abstract testPoint(xf: TransformValue, p: Vec2Value): boolean;\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n abstract rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean;\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n abstract computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void;\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n abstract computeMass(massData: MassData, density?: number): void;\n\n abstract computeDistanceProxy(proxy: DistanceProxy, childIndex: number): void;\n\n}\n\nexport type ShapeType = \"circle\" | \"edge\" | \"polygon\" | \"chain\";\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { options } from \"../util/options\";\nimport { Vec2Value } from \"../common/Vec2\";\nimport { AABB, RayCastInput, RayCastOutput } from \"../collision/AABB\";\nimport { Shape, ShapeType } from \"../collision/Shape\";\nimport { Body, MassData } from \"./Body\";\nimport { BroadPhase } from \"../collision/BroadPhase\";\nimport { TransformValue } from \"../common/Transform\";\nimport { Style } from \"../util/Testbed\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/** @internal */ const synchronize_aabb1 = new AABB();\n/** @internal */ const synchronize_aabb2 = new AABB();\n/** @internal */ const displacement = matrix.vec2(0, 0);\n\n/**\n * A fixture definition is used to create a fixture. This class defines an\n * abstract fixture definition. You can reuse fixture definitions safely.\n */\nexport interface FixtureOpt {\n userData?: unknown;\n /**\n * The friction coefficient, usually in the range [0,1]\n */\n friction?: number;\n /**\n * The restitution (elasticity) usually in the range [0,1]\n */\n restitution?: number;\n /**\n * The density, usually in kg/m^2\n */\n density?: number;\n /**\n * A sensor shape collects contact information but never generates a collision response.\n */\n isSensor?: boolean;\n /**\n * Zero, positive or negative collision group.\n * Fixtures with same positive groupIndex always collide and fixtures with same negative groupIndex never collide.\n */\n filterGroupIndex?: number;\n /**\n * Collision category bit or bits that this fixture belongs to.\n * If groupIndex is zero or not matching, then at least one bit in this fixture categoryBits should match other fixture maskBits and vice versa.\n */\n filterCategoryBits?: number;\n /**\n * Collision category bit or bits that this fixture accept for collision.\n */\n filterMaskBits?: number;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\nexport interface FixtureDef extends FixtureOpt {\n shape: Shape;\n}\n\n/** @internal */ const FixtureDefDefault: FixtureOpt = {\n userData : null,\n friction : 0.2,\n restitution : 0.0,\n density : 0.0,\n isSensor : false,\n\n filterGroupIndex : 0,\n filterCategoryBits : 0x0001,\n filterMaskBits : 0xFFFF\n};\n\n/**\n * This proxy is used internally to connect shape children to the broad-phase.\n */\nexport class FixtureProxy {\n aabb: AABB;\n fixture: Fixture;\n childIndex: number;\n proxyId: number;\n constructor(fixture: Fixture, childIndex: number) {\n this.aabb = new AABB();\n this.fixture = fixture;\n this.childIndex = childIndex;\n // this.proxyId;\n }\n}\n\n/**\n * A fixture is used to attach a shape to a body for collision detection. A\n * fixture inherits its transform from its parent. Fixtures hold additional\n * non-geometric data such as friction, collision filters, etc.\n *\n * To create a new Fixture use {@link Body.createFixture}.\n */\nexport class Fixture {\n /** @internal */ m_body: Body;\n /** @internal */ m_friction: number;\n /** @internal */ m_restitution: number;\n /** @internal */ m_density: number;\n /** @internal */ m_isSensor: boolean;\n /** @internal */ m_filterGroupIndex: number;\n /** @internal */ m_filterCategoryBits: number;\n /** @internal */ m_filterMaskBits: number;\n /** @internal */ m_shape: Shape;\n /** @internal */ m_next: Fixture | null;\n /** @internal */ m_proxies: FixtureProxy[];\n // 0 indicates inactive state, this is not the same as m_proxies.length\n /** @internal */ m_proxyCount: number;\n /** @internal */ m_userData: unknown;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n constructor(body: Body, def: FixtureDef);\n constructor(body: Body, shape: Shape, def?: FixtureOpt);\n constructor(body: Body, shape: Shape, density?: number);\n /** @internal */\n constructor(body: Body, shape?, def?) {\n if (shape.shape) {\n def = shape;\n shape = shape.shape;\n\n } else if (typeof def === \"number\") {\n def = {density : def};\n }\n\n def = options(def, FixtureDefDefault);\n\n this.m_body = body;\n\n this.m_friction = def.friction;\n this.m_restitution = def.restitution;\n this.m_density = def.density;\n this.m_isSensor = def.isSensor;\n\n this.m_filterGroupIndex = def.filterGroupIndex;\n this.m_filterCategoryBits = def.filterCategoryBits;\n this.m_filterMaskBits = def.filterMaskBits;\n\n // TODO validate shape\n this.m_shape = shape; // .clone();\n\n this.m_next = null;\n\n this.m_proxies = [];\n this.m_proxyCount = 0;\n\n // fixture proxies are created here,\n // but they are activate in when a fixture is added to body\n const childCount = this.m_shape.getChildCount();\n for (let i = 0; i < childCount; ++i) {\n this.m_proxies[i] = new FixtureProxy(this, i);\n }\n\n this.m_userData = def.userData;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /** @hidden Re-setup fixture. */\n _reset(): void {\n const body = this.getBody();\n const broadPhase = body.m_world.m_broadPhase;\n this.destroyProxies(broadPhase);\n if (this.m_shape._reset) {\n this.m_shape._reset();\n }\n const childCount = this.m_shape.getChildCount();\n for (let i = 0; i < childCount; ++i) {\n this.m_proxies[i] = new FixtureProxy(this, i);\n }\n this.createProxies(broadPhase, body.m_xf);\n body.resetMassData();\n }\n\n /** @internal */\n _serialize(): object {\n return {\n friction: this.m_friction,\n restitution: this.m_restitution,\n density: this.m_density,\n isSensor: this.m_isSensor,\n\n filterGroupIndex: this.m_filterGroupIndex,\n filterCategoryBits: this.m_filterCategoryBits,\n filterMaskBits: this.m_filterMaskBits,\n\n shape: this.m_shape,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, body: any, restore: any): Fixture {\n const shape = restore(Shape, data.shape);\n const fixture = shape && new Fixture(body, shape, data);\n return fixture;\n }\n\n /**\n * Get the type of the child shape. You can use this to down cast to the\n * concrete shape.\n */\n getType(): ShapeType {\n return this.m_shape.m_type;\n }\n\n /**\n * Get the child shape. You can modify the child shape, however you should not\n * change the number of vertices because this will crash some collision caching\n * mechanisms. Manipulating the shape may lead to non-physical behavior.\n */\n getShape(): Shape {\n return this.m_shape;\n }\n\n /**\n * A sensor shape collects contact information but never generates a collision\n * response.\n */\n isSensor(): boolean {\n return this.m_isSensor;\n }\n\n /**\n * Set if this fixture is a sensor.\n */\n setSensor(sensor: boolean): void {\n if (sensor != this.m_isSensor) {\n this.m_body.setAwake(true);\n this.m_isSensor = sensor;\n }\n }\n\n // /**\n // * Get the contact filtering data.\n // */\n // getFilterData() {\n // return this.m_filter;\n // }\n\n /**\n * Get the user data that was assigned in the fixture definition. Use this to\n * store your application specific data.\n */\n getUserData(): unknown {\n return this.m_userData;\n }\n\n /**\n * Set the user data. Use this to store your application specific data.\n */\n setUserData(data: unknown): void {\n this.m_userData = data;\n }\n\n /**\n * Get the parent body of this fixture. This is null if the fixture is not\n * attached.\n */\n getBody(): Body {\n return this.m_body;\n }\n\n /**\n * Get the next fixture in the parent body's fixture list.\n */\n getNext(): Fixture | null {\n return this.m_next;\n }\n\n /**\n * Get the density of this fixture.\n */\n getDensity(): number {\n return this.m_density;\n }\n\n /**\n * Set the density of this fixture. This will _not_ automatically adjust the\n * mass of the body. You must call Body.resetMassData to update the body's mass.\n */\n setDensity(density: number): void {\n if (_ASSERT) console.assert(Number.isFinite(density) && density >= 0.0);\n this.m_density = density;\n }\n\n /**\n * Get the coefficient of friction, usually in the range [0,1].\n */\n getFriction(): number {\n return this.m_friction;\n }\n\n /**\n * Set the coefficient of friction. This will not change the friction of\n * existing contacts.\n */\n setFriction(friction: number): void {\n this.m_friction = friction;\n }\n\n /**\n * Get the coefficient of restitution.\n */\n getRestitution(): number {\n return this.m_restitution;\n }\n\n /**\n * Set the coefficient of restitution. This will not change the restitution of\n * existing contacts.\n */\n setRestitution(restitution: number): void {\n this.m_restitution = restitution;\n }\n\n /**\n * Test a point in world coordinates for containment in this fixture.\n */\n testPoint(p: Vec2Value): boolean {\n return this.m_shape.testPoint(this.m_body.getTransform(), p);\n }\n\n /**\n * Cast a ray against this shape.\n */\n rayCast(output: RayCastOutput, input: RayCastInput, childIndex: number): boolean {\n return this.m_shape.rayCast(output, input, this.m_body.getTransform(), childIndex);\n }\n\n /**\n * Get the mass data for this fixture. The mass data is based on the density and\n * the shape. The rotational inertia is about the shape's origin. This operation\n * may be expensive.\n */\n getMassData(massData: MassData): void {\n this.m_shape.computeMass(massData, this.m_density);\n }\n\n /**\n * Get the fixture's AABB. This AABB may be enlarge and/or stale. If you need a\n * more accurate AABB, compute it using the shape and the body transform.\n */\n getAABB(childIndex: number): AABB {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_proxies.length);\n return this.m_proxies[childIndex].aabb;\n }\n\n /**\n * These support body activation/deactivation.\n */\n createProxies(broadPhase: BroadPhase, xf: TransformValue): void {\n if (_ASSERT) console.assert(this.m_proxyCount == 0);\n\n // Create proxies in the broad-phase.\n this.m_proxyCount = this.m_shape.getChildCount();\n\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n this.m_shape.computeAABB(proxy.aabb, xf, i);\n proxy.proxyId = broadPhase.createProxy(proxy.aabb, proxy);\n }\n }\n\n destroyProxies(broadPhase: BroadPhase): void {\n // Destroy proxies in the broad-phase.\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n broadPhase.destroyProxy(proxy.proxyId);\n proxy.proxyId = null;\n }\n\n this.m_proxyCount = 0;\n }\n\n /**\n * Updates this fixture proxy in broad-phase (with combined AABB of current and\n * next transformation).\n */\n synchronize(broadPhase: BroadPhase, xf1: TransformValue, xf2: TransformValue): void {\n for (let i = 0; i < this.m_proxyCount; ++i) {\n const proxy = this.m_proxies[i];\n // Compute an AABB that covers the swept shape (may miss some rotation\n // effect).\n this.m_shape.computeAABB(synchronize_aabb1, xf1, proxy.childIndex);\n this.m_shape.computeAABB(synchronize_aabb2, xf2, proxy.childIndex);\n\n proxy.aabb.combine(synchronize_aabb1, synchronize_aabb2);\n\n matrix.subVec2(displacement, xf2.p, xf1.p);\n\n broadPhase.moveProxy(proxy.proxyId, proxy.aabb, displacement);\n }\n }\n\n /**\n * Set the contact filtering data. This will not update contacts until the next\n * time step when either parent body is active and awake. This automatically\n * calls refilter.\n */\n setFilterData(filter: { groupIndex: number, categoryBits: number, maskBits: number }): void {\n this.m_filterGroupIndex = filter.groupIndex;\n this.m_filterCategoryBits = filter.categoryBits;\n this.m_filterMaskBits = filter.maskBits;\n this.refilter();\n }\n\n getFilterGroupIndex(): number {\n return this.m_filterGroupIndex;\n }\n\n setFilterGroupIndex(groupIndex: number): void {\n this.m_filterGroupIndex = groupIndex;\n this.refilter();\n }\n\n getFilterCategoryBits(): number {\n return this.m_filterCategoryBits;\n }\n\n setFilterCategoryBits(categoryBits: number): void {\n this.m_filterCategoryBits = categoryBits;\n this.refilter();\n }\n\n getFilterMaskBits(): number {\n return this.m_filterMaskBits;\n }\n\n setFilterMaskBits(maskBits: number): void {\n this.m_filterMaskBits = maskBits;\n this.refilter();\n }\n\n /**\n * Call this if you want to establish collision that was previously disabled by\n * ContactFilter.\n */\n refilter(): void {\n if (this.m_body == null) {\n return;\n }\n\n // Flag associated contacts for filtering.\n let edge = this.m_body.getContactList();\n while (edge) {\n const contact = edge.contact;\n const fixtureA = contact.getFixtureA();\n const fixtureB = contact.getFixtureB();\n if (fixtureA == this || fixtureB == this) {\n contact.flagForFiltering();\n }\n\n edge = edge.next;\n }\n\n const world = this.m_body.getWorld();\n\n if (world == null) {\n return;\n }\n\n // Touch each proxy so that new pairs may be created\n const broadPhase = world.m_broadPhase;\n for (let i = 0; i < this.m_proxyCount; ++i) {\n broadPhase.touchProxy(this.m_proxies[i].proxyId);\n }\n }\n\n /**\n * Implement this method to provide collision filtering, if you want finer\n * control over contact creation.\n *\n * Return true if contact calculations should be performed between these two\n * fixtures.\n *\n * Warning: for performance reasons this is only called when the AABBs begin to\n * overlap.\n */\n shouldCollide(that: Fixture): boolean {\n\n if (that.m_filterGroupIndex === this.m_filterGroupIndex && that.m_filterGroupIndex !== 0) {\n return that.m_filterGroupIndex > 0;\n }\n\n const collideA = (that.m_filterMaskBits & this.m_filterCategoryBits) !== 0;\n const collideB = (that.m_filterCategoryBits & this.m_filterMaskBits) !== 0;\n const collide = collideA && collideB;\n return collide;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { options } from \"../util/options\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { Rot } from \"../common/Rot\";\nimport { Sweep } from \"../common/Sweep\";\nimport { Transform, TransformValue } from \"../common/Transform\";\nimport { Velocity } from \"./Velocity\";\nimport { Position } from \"./Position\";\nimport { Fixture, FixtureDef, FixtureOpt } from \"./Fixture\";\nimport { Shape } from \"../collision/Shape\";\nimport { JointEdge } from \"./Joint\";\nimport { World } from \"./World\";\nimport { ContactEdge } from \"./Contact\";\nimport { Style } from \"../util/Testbed\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A static body does not move under simulation and behaves as if it has infinite mass.\n * Internally, zero is stored for the mass and the inverse mass.\n * Static bodies can be moved manually by the user.\n * A static body has zero velocity.\n * Static bodies do not collide with other static or kinematic bodies.\n * \n * A kinematic body moves under simulation according to its velocity.\n * Kinematic bodies do not respond to forces.\n * They can be moved manually by the user, but normally a kinematic body is moved by setting its velocity.\n * A kinematic body behaves as if it has infinite mass, however, zero is stored for the mass and the inverse mass.\n * Kinematic bodies do not collide with other kinematic or static bodies.\n * \n * A dynamic body is fully simulated.\n * They can be moved manually by the user, but normally they move according to forces.\n * A dynamic body can collide with all body types.\n * A dynamic body always has finite, non-zero mass.\n * If you try to set the mass of a dynamic body to zero, it will automatically acquire a mass of one kilogram and it won't rotate.\n */\nexport type BodyType = \"static\" | \"kinematic\" | \"dynamic\";\n\n/** @internal */ const STATIC = \"static\";\n/** @internal */ const KINEMATIC = \"kinematic\";\n/** @internal */ const DYNAMIC = \"dynamic\";\n\n/** @internal */ const oldCenter = matrix.vec2(0, 0);\n/** @internal */ const localCenter = matrix.vec2(0, 0);\n/** @internal */ const shift = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n\nexport interface BodyDef {\n /**\n * Body types are static, kinematic, or dynamic. Note: if a dynamic\n * body would have zero mass, the mass is set to one.\n */\n type?: BodyType;\n /**\n * The world position of the body. Avoid creating bodies at the\n * origin since this can lead to many overlapping shapes.\n */\n position?: Vec2Value;\n /**\n * The world angle of the body in radians.\n */\n angle?: number;\n /**\n * The linear velocity of the body's origin in world co-ordinates.\n */\n linearVelocity?: Vec2Value;\n angularVelocity?: number;\n /**\n * Linear damping is use to reduce the linear velocity. The\n * damping parameter can be larger than 1.0 but the damping effect becomes\n * sensitive to the time step when the damping parameter is large.\n * Units are 1/time\n */\n linearDamping?: number;\n /**\n * Angular damping is use to reduce the angular velocity.\n * The damping parameter can be larger than 1.0 but the damping effect\n * becomes sensitive to the time step when the damping parameter is large.\n * Units are 1/time\n */\n angularDamping?: number;\n /**\n * Should this body be prevented from rotating? Useful for characters.\n */\n fixedRotation?: boolean;\n /**\n * Is this a fast moving body that should be prevented from\n * tunneling through other moving bodies? Note that all bodies are\n * prevented from tunneling through kinematic and static bodies. This\n * setting is only considered on dynamic bodies. Warning: You should use\n * this flag sparingly since it increases processing time.\n */\n bullet?: boolean;\n gravityScale?: number;\n /**\n * Set this flag to false if this body should never fall asleep. Note that this increases CPU usage.\n */\n allowSleep?: boolean;\n /**\n * Is this body initially awake or sleeping?\n */\n awake?: boolean;\n /**\n * Does this body start out active?\n */\n active?: boolean;\n userData?: any;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\n/** @internal */ const BodyDefDefault: BodyDef = {\n type : STATIC,\n position : Vec2.zero(),\n angle : 0.0,\n\n linearVelocity : Vec2.zero(),\n angularVelocity : 0.0,\n\n linearDamping : 0.0,\n angularDamping : 0.0,\n\n fixedRotation : false,\n bullet : false,\n gravityScale : 1.0,\n\n allowSleep : true,\n awake : true,\n active : true,\n\n userData : null\n};\n\n/**\n * MassData This holds the mass data computed for a shape.\n */\nexport interface MassData {\n /** The mass of the shape, usually in kilograms. */\n mass: number;\n /** The position of the shape's centroid relative to the shape's origin. */\n center: Vec2Value;\n /** The rotational inertia of the shape about the local origin. */\n I: number;\n}\n\n/**\n * A rigid body composed of one or more fixtures.\n *\n * To create a new Body use {@link World.createBody}.\n */\nexport class Body {\n /** @hidden */\n static readonly STATIC: BodyType = \"static\";\n /** @hidden */\n static readonly KINEMATIC: BodyType = \"kinematic\";\n /** @hidden */\n static readonly DYNAMIC: BodyType = \"dynamic\";\n\n /** @internal */ m_world: World;\n /** @internal */ m_awakeFlag: boolean;\n /** @internal */ m_autoSleepFlag: boolean;\n /** @internal */ m_bulletFlag: boolean;\n /** @internal */ m_fixedRotationFlag: boolean;\n /** @internal */ m_activeFlag: boolean;\n /** @internal */ m_islandFlag: boolean;\n /** @internal */ m_toiFlag: boolean;\n /** @internal */ m_userData: unknown;\n /** @internal */ m_type: BodyType;\n /** @internal */ m_mass: number;\n /** @internal */ m_invMass: number;\n /** @internal Rotational inertia about the center of mass. */\n m_I: number;\n /** @internal */ m_invI: number;\n /** @internal the body origin transform */\n m_xf: Transform;\n /** @internal the swept motion for CCD */\n m_sweep: Sweep;\n // position and velocity correction\n /** @internal */ c_velocity: Velocity;\n /** @internal */ c_position: Position;\n /** @internal */ m_force: Vec2;\n /** @internal */ m_torque: number;\n /** @internal */ m_linearVelocity: Vec2;\n /** @internal */ m_angularVelocity: number;\n /** @internal */ m_linearDamping: number;\n /** @internal */ m_angularDamping: number;\n /** @internal */ m_gravityScale: number;\n /** @internal */ m_sleepTime: number;\n /** @internal */ m_jointList: JointEdge | null;\n /** @internal */ m_contactList: ContactEdge | null;\n /** @internal */ m_fixtureList: Fixture | null;\n /** @internal */ m_prev: Body | null;\n /** @internal */ m_next: Body | null;\n /** @internal */ m_destroyed: boolean;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n /** @internal */\n constructor(world: World, def: BodyDef) {\n def = options(def, BodyDefDefault);\n\n if (_ASSERT) console.assert(Vec2.isValid(def.position));\n if (_ASSERT) console.assert(Vec2.isValid(def.linearVelocity));\n if (_ASSERT) console.assert(Number.isFinite(def.angle));\n if (_ASSERT) console.assert(Number.isFinite(def.angularVelocity));\n if (_ASSERT) console.assert(Number.isFinite(def.angularDamping) && def.angularDamping >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.linearDamping) && def.linearDamping >= 0.0);\n\n this.m_world = world;\n\n this.m_awakeFlag = def.awake;\n this.m_autoSleepFlag = def.allowSleep;\n this.m_bulletFlag = def.bullet;\n this.m_fixedRotationFlag = def.fixedRotation;\n this.m_activeFlag = def.active;\n\n this.m_islandFlag = false;\n this.m_toiFlag = false;\n\n this.m_userData = def.userData;\n this.m_type = def.type;\n\n if (this.m_type == DYNAMIC) {\n this.m_mass = 1.0;\n this.m_invMass = 1.0;\n } else {\n this.m_mass = 0.0;\n this.m_invMass = 0.0;\n }\n\n // Rotational inertia about the center of mass.\n this.m_I = 0.0;\n this.m_invI = 0.0;\n\n // the body origin transform\n this.m_xf = Transform.identity();\n this.m_xf.p.setVec2(def.position);\n this.m_xf.q.setAngle(def.angle);\n\n // the swept motion for CCD\n this.m_sweep = new Sweep();\n this.m_sweep.setTransform(this.m_xf);\n\n // position and velocity correction\n this.c_velocity = new Velocity();\n this.c_position = new Position();\n\n this.m_force = Vec2.zero();\n this.m_torque = 0.0;\n\n this.m_linearVelocity = Vec2.clone(def.linearVelocity);\n this.m_angularVelocity = def.angularVelocity;\n\n this.m_linearDamping = def.linearDamping;\n this.m_angularDamping = def.angularDamping;\n this.m_gravityScale = def.gravityScale;\n\n this.m_sleepTime = 0.0;\n\n this.m_jointList = null;\n this.m_contactList = null;\n this.m_fixtureList = null;\n\n this.m_prev = null;\n this.m_next = null;\n\n this.m_destroyed = false;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /** @internal */\n _serialize(): object {\n const fixtures = [];\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n fixtures.push(f);\n }\n return {\n type: this.m_type,\n bullet: this.m_bulletFlag,\n position: this.m_xf.p,\n angle: this.m_xf.q.getAngle(),\n linearVelocity: this.m_linearVelocity,\n angularVelocity: this.m_angularVelocity,\n fixtures,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): Body {\n const body = new Body(world, data);\n\n if (data.fixtures) {\n for (let i = data.fixtures.length - 1; i >= 0; i--) {\n const fixture = restore(Fixture, data.fixtures[i], body);\n body._addFixture(fixture);\n }\n }\n return body;\n }\n\n isWorldLocked(): boolean {\n return this.m_world && this.m_world.isLocked() ? true : false;\n }\n\n getWorld(): World {\n return this.m_world;\n }\n\n getNext(): Body | null {\n return this.m_next;\n }\n\n setUserData(data: any): void {\n this.m_userData = data;\n }\n\n getUserData(): unknown {\n return this.m_userData;\n }\n\n getFixtureList(): Fixture | null {\n return this.m_fixtureList;\n }\n\n getJointList(): JointEdge | null {\n return this.m_jointList;\n }\n\n /**\n * Warning: this list changes during the time step and you may miss some\n * collisions if you don't use ContactListener.\n */\n getContactList(): ContactEdge | null {\n return this.m_contactList;\n }\n\n isStatic(): boolean {\n return this.m_type == STATIC;\n }\n\n isDynamic(): boolean {\n return this.m_type == DYNAMIC;\n }\n\n isKinematic(): boolean {\n return this.m_type == KINEMATIC;\n }\n\n /**\n * This will alter the mass and velocity.\n */\n setStatic(): Body {\n this.setType(STATIC);\n return this;\n }\n\n setDynamic(): Body {\n this.setType(DYNAMIC);\n return this;\n }\n\n setKinematic(): Body {\n this.setType(KINEMATIC);\n return this;\n }\n\n /**\n * Get the type of the body.\n */\n getType(): BodyType {\n return this.m_type;\n }\n\n /**\n * Set the type of the body to \"static\", \"kinematic\" or \"dynamic\".\n * @param type The type of the body.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n setType(type: BodyType): void {\n if (_ASSERT) console.assert(type === STATIC || type === KINEMATIC || type === DYNAMIC);\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (this.m_type == type) {\n return;\n }\n\n this.m_type = type;\n\n this.resetMassData();\n\n if (this.m_type == STATIC) {\n this.m_linearVelocity.setZero();\n this.m_angularVelocity = 0.0;\n this.m_sweep.forward();\n this.synchronizeFixtures();\n }\n\n this.setAwake(true);\n\n this.m_force.setZero();\n this.m_torque = 0.0;\n\n // Delete the attached contacts.\n let ce = this.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n this.m_world.destroyContact(ce0.contact);\n }\n this.m_contactList = null;\n\n // Touch the proxies so that new contacts will be created (when appropriate)\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n for (let i = 0; i < f.m_proxyCount; ++i) {\n broadPhase.touchProxy(f.m_proxies[i].proxyId);\n }\n }\n }\n\n isBullet(): boolean {\n return this.m_bulletFlag;\n }\n\n /**\n * Should this body be treated like a bullet for continuous collision detection?\n */\n setBullet(flag: boolean): void {\n this.m_bulletFlag = !!flag;\n }\n\n isSleepingAllowed(): boolean {\n return this.m_autoSleepFlag;\n }\n\n setSleepingAllowed(flag: boolean): void {\n this.m_autoSleepFlag = !!flag;\n if (this.m_autoSleepFlag == false) {\n this.setAwake(true);\n }\n }\n\n isAwake(): boolean {\n return this.m_awakeFlag;\n }\n\n /**\n * Set the sleep state of the body. A sleeping body has very low CPU cost.\n *\n * @param flag Set to true to wake the body, false to put it to sleep.\n */\n setAwake(flag: boolean): void {\n if (flag) {\n this.m_awakeFlag = true;\n this.m_sleepTime = 0.0;\n } else {\n this.m_awakeFlag = false;\n this.m_sleepTime = 0.0;\n this.m_linearVelocity.setZero();\n this.m_angularVelocity = 0.0;\n this.m_force.setZero();\n this.m_torque = 0.0;\n }\n }\n\n isActive(): boolean {\n return this.m_activeFlag;\n }\n\n /**\n * Set the active state of the body. An inactive body is not simulated and\n * cannot be collided with or woken up. If you pass a flag of true, all fixtures\n * will be added to the broad-phase. If you pass a flag of false, all fixtures\n * will be removed from the broad-phase and all contacts will be destroyed.\n * Fixtures and joints are otherwise unaffected.\n *\n * You may continue to create/destroy fixtures and joints on inactive bodies.\n * Fixtures on an inactive body are implicitly inactive and will not participate\n * in collisions, ray-casts, or queries. Joints connected to an inactive body\n * are implicitly inactive. An inactive body is still owned by a World object\n * and remains\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n setActive(flag: boolean): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (flag == this.m_activeFlag) {\n return;\n }\n\n this.m_activeFlag = !!flag;\n\n if (this.m_activeFlag) {\n // Create all proxies.\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.createProxies(broadPhase, this.m_xf);\n }\n\t\t // Contacts are created at the beginning of the next\n\t\t this.m_world.m_newFixture = true;\n } else {\n // Destroy all proxies.\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.destroyProxies(broadPhase);\n }\n\n // Destroy the attached contacts.\n let ce = this.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n this.m_world.destroyContact(ce0.contact);\n }\n this.m_contactList = null;\n }\n }\n\n isFixedRotation(): boolean {\n return this.m_fixedRotationFlag;\n }\n\n /**\n * Set this body to have fixed rotation. This causes the mass to be reset.\n */\n setFixedRotation(flag: boolean): void {\n if (this.m_fixedRotationFlag == flag) {\n return;\n }\n\n this.m_fixedRotationFlag = !!flag;\n\n this.m_angularVelocity = 0.0;\n\n this.resetMassData();\n }\n\n /**\n * Get the world transform for the body's origin.\n */\n getTransform(): Transform {\n return this.m_xf;\n }\n\n /**\n * Set the position of the body's origin and rotation. Manipulating a body's\n * transform may cause non-physical behavior. Note: contacts are updated on the\n * next call to World.step.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n *\n * @param position The world position of the body's local origin.\n * @param angle The world rotation in radians.\n */\n setTransform(position: Vec2Value, angle: number): void;\n /**\n * Set the position of the body's origin and rotation. Manipulating a body's\n * transform may cause non-physical behavior. Note: contacts are updated on the\n * next call to World.step.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n setTransform(xf: Transform): void;\n setTransform(a: Vec2Value | Transform, b?: number): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return;\n }\n if (typeof b === \"number\") {\n this.m_xf.setNum(a as Vec2Value, b);\n } else {\n this.m_xf.setTransform(a as TransformValue);\n }\n\n this.m_sweep.setTransform(this.m_xf);\n\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.synchronize(broadPhase, this.m_xf, this.m_xf);\n }\n this.setAwake(true);\n }\n\n synchronizeTransform(): void {\n this.m_sweep.getTransform(this.m_xf, 1);\n }\n\n /**\n * Update fixtures in broad-phase.\n */\n synchronizeFixtures(): void {\n this.m_sweep.getTransform(xf, 0);\n\n const broadPhase = this.m_world.m_broadPhase;\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n f.synchronize(broadPhase, xf, this.m_xf);\n }\n }\n\n /**\n * Used in TOI.\n */\n advance(alpha: number): void {\n // Advance to the new safe time. This doesn't sync the broad-phase.\n this.m_sweep.advance(alpha);\n matrix.copyVec2(this.m_sweep.c, this.m_sweep.c0);\n this.m_sweep.a = this.m_sweep.a0;\n this.m_sweep.getTransform(this.m_xf, 1);\n }\n\n /**\n * Get the world position for the body's origin.\n */\n getPosition(): Vec2 {\n return this.m_xf.p;\n }\n\n setPosition(p: Vec2Value): void {\n this.setTransform(p, this.m_sweep.a);\n }\n\n /**\n * Get the current world rotation angle in radians.\n */\n getAngle(): number {\n return this.m_sweep.a;\n }\n\n setAngle(angle: number): void {\n this.setTransform(this.m_xf.p, angle);\n }\n\n /**\n * Get the world position of the center of mass.\n */\n getWorldCenter(): Vec2 {\n return this.m_sweep.c;\n }\n\n /**\n * Get the local position of the center of mass.\n */\n getLocalCenter(): Vec2 {\n return this.m_sweep.localCenter;\n }\n\n /**\n * Get the linear velocity of the center of mass.\n *\n * @return the linear velocity of the center of mass.\n */\n getLinearVelocity(): Vec2 {\n return this.m_linearVelocity;\n }\n\n /**\n * Get the world linear velocity of a world point attached to this body.\n *\n * @param worldPoint A point in world coordinates.\n */\n getLinearVelocityFromWorldPoint(worldPoint: Vec2Value): Vec2 {\n const localCenter = Vec2.sub(worldPoint, this.m_sweep.c);\n return Vec2.add(this.m_linearVelocity, Vec2.crossNumVec2(this.m_angularVelocity,\n localCenter));\n }\n\n /**\n * Get the world velocity of a local point.\n *\n * @param localPoint A point in local coordinates.\n */\n getLinearVelocityFromLocalPoint(localPoint: Vec2Value): Vec2 {\n return this.getLinearVelocityFromWorldPoint(this.getWorldPoint(localPoint));\n }\n\n /**\n * Set the linear velocity of the center of mass.\n *\n * @param v The new linear velocity of the center of mass.\n */\n setLinearVelocity(v: Vec2Value): void {\n if (this.m_type == STATIC) {\n return;\n }\n if (Vec2.dot(v, v) > 0.0) {\n this.setAwake(true);\n }\n this.m_linearVelocity.setVec2(v);\n }\n\n /**\n * Get the angular velocity.\n *\n * @returns the angular velocity in radians/second.\n */\n getAngularVelocity(): number {\n return this.m_angularVelocity;\n }\n\n /**\n * Set the angular velocity.\n *\n * @param w The new angular velocity in radians/second.\n */\n setAngularVelocity(w: number): void {\n if (this.m_type == STATIC) {\n return;\n }\n if (w * w > 0.0) {\n this.setAwake(true);\n }\n this.m_angularVelocity = w;\n }\n\n getLinearDamping(): number {\n return this.m_linearDamping;\n }\n\n setLinearDamping(linearDamping: number): void {\n this.m_linearDamping = linearDamping;\n }\n\n getAngularDamping(): number {\n return this.m_angularDamping;\n }\n\n setAngularDamping(angularDamping: number): void {\n this.m_angularDamping = angularDamping;\n }\n\n getGravityScale(): number {\n return this.m_gravityScale;\n }\n\n /**\n * Scale the gravity applied to this body.\n */\n setGravityScale(scale: number): void {\n this.m_gravityScale = scale;\n }\n\n /**\n * Get the total mass of the body.\n *\n * @returns The mass, usually in kilograms (kg).\n */\n getMass(): number {\n return this.m_mass;\n }\n\n /**\n * Get the rotational inertia of the body about the local origin.\n *\n * @return the rotational inertia, usually in kg-m^2.\n */\n getInertia(): number {\n return this.m_I + this.m_mass\n * Vec2.dot(this.m_sweep.localCenter, this.m_sweep.localCenter);\n }\n\n /**\n * Copy the mass data of the body to data.\n */\n getMassData(data: MassData): void {\n data.mass = this.m_mass;\n data.I = this.getInertia();\n matrix.copyVec2(data.center, this.m_sweep.localCenter);\n }\n\n /**\n * This resets the mass properties to the sum of the mass properties of the\n * fixtures. This normally does not need to be called unless you called\n * SetMassData to override the mass and you later want to reset the mass.\n */\n resetMassData(): void {\n // Compute mass data from shapes. Each shape has its own density.\n this.m_mass = 0.0;\n this.m_invMass = 0.0;\n this.m_I = 0.0;\n this.m_invI = 0.0;\n matrix.zeroVec2(this.m_sweep.localCenter);\n\n // Static and kinematic bodies have zero mass.\n if (this.isStatic() || this.isKinematic()) {\n matrix.copyVec2(this.m_sweep.c0, this.m_xf.p);\n matrix.copyVec2(this.m_sweep.c, this.m_xf.p);\n this.m_sweep.a0 = this.m_sweep.a;\n return;\n }\n\n if (_ASSERT) console.assert(this.isDynamic());\n\n // Accumulate mass over all fixtures.\n matrix.zeroVec2(localCenter);\n for (let f = this.m_fixtureList; f; f = f.m_next) {\n if (f.m_density == 0.0) {\n continue;\n }\n\n const massData: MassData = {\n mass: 0,\n center: matrix.vec2(0, 0),\n I: 0\n };\n f.getMassData(massData);\n this.m_mass += massData.mass;\n matrix.plusScaleVec2(localCenter, massData.mass, massData.center);\n this.m_I += massData.I;\n }\n\n // Compute center of mass.\n if (this.m_mass > 0.0) {\n this.m_invMass = 1.0 / this.m_mass;\n matrix.scaleVec2(localCenter, this.m_invMass, localCenter);\n\n } else {\n // Force all dynamic bodies to have a positive mass.\n this.m_mass = 1.0;\n this.m_invMass = 1.0;\n }\n\n if (this.m_I > 0.0 && this.m_fixedRotationFlag == false) {\n // Center the inertia about the center of mass.\n this.m_I -= this.m_mass * matrix.dotVec2(localCenter, localCenter);\n if (_ASSERT) console.assert(this.m_I > 0.0);\n this.m_invI = 1.0 / this.m_I;\n\n } else {\n this.m_I = 0.0;\n this.m_invI = 0.0;\n }\n\n // Move center of mass.\n matrix.copyVec2(oldCenter, this.m_sweep.c);\n this.m_sweep.setLocalCenter(localCenter, this.m_xf);\n\n // Update center of mass velocity.\n matrix.subVec2(shift, this.m_sweep.c, oldCenter);\n matrix.crossNumVec2(temp, this.m_angularVelocity, shift);\n matrix.plusVec2(this.m_linearVelocity, temp);\n }\n\n /**\n * Set the mass properties to override the mass properties of the fixtures. Note\n * that this changes the center of mass position. Note that creating or\n * destroying fixtures can also alter the mass. This function has no effect if\n * the body isn't dynamic.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n *\n * @param massData The mass properties.\n */\n setMassData(massData: MassData): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (this.m_type != DYNAMIC) {\n return;\n }\n\n this.m_invMass = 0.0;\n this.m_I = 0.0;\n this.m_invI = 0.0;\n\n this.m_mass = massData.mass;\n if (this.m_mass <= 0.0) {\n this.m_mass = 1.0;\n }\n\n this.m_invMass = 1.0 / this.m_mass;\n\n if (massData.I > 0.0 && this.m_fixedRotationFlag == false) {\n this.m_I = massData.I - this.m_mass * matrix.dotVec2(massData.center, massData.center);\n if (_ASSERT) console.assert(this.m_I > 0.0);\n this.m_invI = 1.0 / this.m_I;\n }\n\n // Move center of mass.\n matrix.copyVec2(oldCenter, this.m_sweep.c);\n this.m_sweep.setLocalCenter(massData.center, this.m_xf);\n\n // Update center of mass velocity.\n matrix.subVec2(shift, this.m_sweep.c, oldCenter);\n matrix.crossNumVec2(temp, this.m_angularVelocity, shift);\n matrix.plusVec2(this.m_linearVelocity, temp);\n }\n\n /**\n * Apply a force at a world point. If the force is not applied at the center of\n * mass, it will generate a torque and affect the angular velocity. This wakes\n * up the body.\n *\n * @param force The world force vector, usually in Newtons (N).\n * @param point The world position of the point of application.\n * @param wake Also wake up the body\n */\n applyForce(force: Vec2Value, point: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping.\n if (this.m_awakeFlag) {\n this.m_force.add(force);\n this.m_torque += Vec2.crossVec2Vec2(Vec2.sub(point, this.m_sweep.c), force);\n }\n }\n\n /**\n * Apply a force to the center of mass. This wakes up the body.\n *\n * @param force The world force vector, usually in Newtons (N).\n * @param wake Also wake up the body\n */\n applyForceToCenter(force: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_force.add(force);\n }\n }\n\n /**\n * Apply a torque. This affects the angular velocity without affecting the\n * linear velocity of the center of mass. This wakes up the body.\n *\n * @param torque About the z-axis (out of the screen), usually in N-m.\n * @param wake Also wake up the body\n */\n applyTorque(torque: number, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate a force if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_torque += torque;\n }\n }\n\n /**\n * Apply an impulse at a point. This immediately modifies the velocity. It also\n * modifies the angular velocity if the point of application is not at the\n * center of mass. This wakes up the body.\n *\n * @param impulse The world impulse vector, usually in N-seconds or kg-m/s.\n * @param point The world position of the point of application.\n * @param wake Also wake up the body\n */\n applyLinearImpulse(impulse: Vec2Value, point: Vec2Value, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n\n // Don't accumulate velocity if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_linearVelocity.addMul(this.m_invMass, impulse);\n this.m_angularVelocity += this.m_invI * Vec2.crossVec2Vec2(Vec2.sub(point, this.m_sweep.c), impulse);\n }\n }\n\n /**\n * Apply an angular impulse.\n *\n * @param impulse The angular impulse in units of kg*m*m/s\n * @param wake Also wake up the body\n */\n applyAngularImpulse(impulse: number, wake: boolean = true): void {\n if (this.m_type != DYNAMIC) {\n return;\n }\n\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n // Don't accumulate velocity if the body is sleeping\n if (this.m_awakeFlag) {\n this.m_angularVelocity += this.m_invI * impulse;\n }\n }\n\n /**\n * This is used to test if two bodies should collide.\n * \n * Bodies do not collide when:\n * - Neither of them is dynamic\n * - They are connected by a joint with collideConnected == false\n */\n shouldCollide(that: Body): boolean {\n // At least one body should be dynamic.\n if (this.m_type != DYNAMIC && that.m_type != DYNAMIC) {\n return false;\n }\n // Does a joint prevent collision?\n for (let jn = this.m_jointList; jn; jn = jn.next) {\n if (jn.other == that) {\n if (jn.joint.m_collideConnected == false) {\n return false;\n }\n }\n }\n return true;\n }\n\n /** @internal Used for deserialize. */\n _addFixture(fixture: Fixture): Fixture {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return null;\n }\n\n if (this.m_activeFlag) {\n const broadPhase = this.m_world.m_broadPhase;\n fixture.createProxies(broadPhase, this.m_xf);\n }\n\n fixture.m_next = this.m_fixtureList;\n this.m_fixtureList = fixture;\n\n // Adjust mass properties if needed.\n if (fixture.m_density > 0.0) {\n this.resetMassData();\n }\n\n // Let the world know we have a new fixture. This will cause new contacts\n // to be created at the beginning of the next time step.\n this.m_world.m_newFixture = true;\n\n return fixture;\n }\n\n /**\n * Creates a fixture and attach it to this body.\n *\n * If the density is non-zero, this function automatically updates the mass of\n * the body.\n *\n * Contacts are not created until the next time step.\n *\n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n createFixture(def: FixtureDef): Fixture;\n createFixture(shape: Shape, opt?: FixtureOpt): Fixture;\n createFixture(shape: Shape, density?: number): Fixture;\n // tslint:disable-next-line:typedef\n createFixture(shape, fixdef?) {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return null;\n }\n\n const fixture = new Fixture(this, shape, fixdef);\n this._addFixture(fixture);\n return fixture;\n }\n\n /**\n * Destroy a fixture. This removes the fixture from the broad-phase and destroys\n * all contacts associated with this fixture. This will automatically adjust the\n * mass of the body if the body is dynamic and the fixture has positive density.\n * All fixtures attached to a body are implicitly destroyed when the body is\n * destroyed.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n *\n * @param fixture The fixture to be removed.\n */\n destroyFixture(fixture: Fixture): void {\n if (_ASSERT) console.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (_ASSERT) console.assert(fixture.m_body == this);\n\n // Remove the fixture from this body's singly linked list.\n let found = false;\n if (this.m_fixtureList === fixture) {\n this.m_fixtureList = fixture.m_next;\n found = true;\n\n } else {\n let node = this.m_fixtureList;\n while (node != null) {\n if (node.m_next === fixture) {\n node.m_next = fixture.m_next;\n found = true;\n break;\n }\n node = node.m_next;\n }\n }\n\n // You tried to remove a shape that is not attached to this body.\n if (_ASSERT) console.assert(found);\n\n // Destroy any contacts associated with the fixture.\n let edge = this.m_contactList;\n while (edge) {\n const c = edge.contact;\n edge = edge.next;\n\n const fixtureA = c.getFixtureA();\n const fixtureB = c.getFixtureB();\n\n if (fixture == fixtureA || fixture == fixtureB) {\n // This destroys the contact and removes it from\n // this body's contact list.\n this.m_world.destroyContact(c);\n }\n }\n\n if (this.m_activeFlag) {\n const broadPhase = this.m_world.m_broadPhase;\n fixture.destroyProxies(broadPhase);\n }\n\n fixture.m_body = null;\n fixture.m_next = null;\n\n this.m_world.publish(\"remove-fixture\", fixture);\n\n // Reset the mass data.\n this.resetMassData();\n }\n\n /**\n * Get the corresponding world point of a local point.\n */\n getWorldPoint(localPoint: Vec2Value): Vec2 {\n return Transform.mulVec2(this.m_xf, localPoint);\n }\n\n /**\n * Get the corresponding world vector of a local vector.\n */\n getWorldVector(localVector: Vec2Value): Vec2 {\n return Rot.mulVec2(this.m_xf.q, localVector);\n }\n\n /**\n * Gets the corresponding local point of a world point.\n */\n getLocalPoint(worldPoint: Vec2Value): Vec2 {\n return Transform.mulTVec2(this.m_xf, worldPoint);\n }\n\n /**\n * Gets the corresponding local vector of a world vector.\n */\n getLocalVector(worldVector: Vec2Value): Vec2 {\n return Rot.mulTVec2(this.m_xf.q, worldVector);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { Vec2, Vec2Value } from \"../common/Vec2\";\nimport type { Body } from \"./Body\";\nimport { TimeStep } from \"./Solver\";\nimport { Style } from \"../util/Testbed\";\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/**\n * A joint edge is used to connect bodies and joints together in a joint graph\n * where each body is a node and each joint is an edge. A joint edge belongs to\n * a doubly linked list maintained in each attached body. Each joint has two\n * joint nodes, one for each attached body.\n */\nexport class JointEdge {\n /**\n * provides quick access to the other body attached.\n */\n other: Body | null = null;\n /**\n * the joint\n */\n joint: Joint | null = null;\n /**\n * prev the previous joint edge in the body's joint list\n */\n prev: JointEdge | null = null;\n /**\n * the next joint edge in the body's joint list\n */\n next: JointEdge | null = null;\n}\n\n/**\n * Joint definitions are used to construct joints.\n */\nexport interface JointOpt {\n /**\n * Use this to attach application specific data to your joints.\n */\n userData?: any;\n /**\n * Set this flag to true if the attached bodies\n * should collide.\n */\n collideConnected?: boolean;\n\n /** Styling for dev-tools. */\n style?: Style;\n}\n\n/**\n * Joint definitions are used to construct joints.\n */\nexport interface JointDef extends JointOpt {\n /**\n * The first attached body.\n */\n bodyA: Body;\n /**\n * The second attached body.\n */\n bodyB: Body;\n}\n\n/** @internal */ const DEFAULTS = {\n userData : null,\n collideConnected : false\n};\n\n/**\n * The base joint class. Joints are used to constraint two bodies together in\n * various fashions. Some joints also feature limits and motors.\n */\nexport abstract class Joint {\n\n /** @internal */ m_type: string = \"unknown-joint\";\n\n /** @internal */ m_bodyA: Body;\n /** @internal */ m_bodyB: Body;\n\n /** @internal */ m_collideConnected: boolean;\n\n /** @internal */ m_prev: Joint | null = null;\n /** @internal */ m_next: Joint | null = null;\n\n /** @internal */ m_edgeA: JointEdge = new JointEdge();\n /** @internal */ m_edgeB: JointEdge = new JointEdge();\n\n /** @internal */ m_islandFlag: boolean = false;\n /** @internal */ m_userData: unknown;\n\n /** Styling for dev-tools. */\n style: Style = {};\n\n /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */\n appData: Record = {};\n\n constructor(def: JointDef);\n constructor(def: JointOpt, bodyA: Body, bodyB: Body);\n constructor(def: JointDef | JointOpt, bodyA?: Body, bodyB?: Body) {\n bodyA = \"bodyA\" in def ? def.bodyA : bodyA;\n bodyB = \"bodyB\" in def ? def.bodyB : bodyB;\n\n if (_ASSERT) console.assert(!!bodyA);\n if (_ASSERT) console.assert(!!bodyB);\n if (_ASSERT) console.assert(bodyA != bodyB);\n\n this.m_bodyA = bodyA!;\n this.m_bodyB = bodyB!;\n\n this.m_collideConnected = !!def.collideConnected;\n this.m_userData = def.userData;\n\n if (typeof def.style === \"object\" && def.style !== null) {\n this.style = def.style;\n }\n }\n\n /**\n * Short-cut function to determine if either body is inactive.\n */\n isActive(): boolean {\n return this.m_bodyA.isActive() && this.m_bodyB.isActive();\n }\n\n /**\n * Get the type of the concrete joint.\n */\n getType(): string {\n return this.m_type;\n }\n\n /**\n * Get the first body attached to this joint.\n */\n getBodyA(): Body {\n return this.m_bodyA;\n }\n\n /**\n * Get the second body attached to this joint.\n */\n getBodyB(): Body {\n return this.m_bodyB;\n }\n\n /**\n * Get the next joint the world joint list.\n */\n getNext(): Joint {\n return this.m_next;\n }\n\n getUserData(): unknown {\n return this.m_userData;\n }\n\n setUserData(data: unknown): void {\n this.m_userData = data;\n }\n\n /**\n * Get collide connected. Note: modifying the collide connect flag won't work\n * correctly because the flag is only checked when fixture AABBs begin to\n * overlap.\n */\n getCollideConnected(): boolean {\n return this.m_collideConnected;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n abstract getAnchorA(): Vec2;\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n abstract getAnchorB(): Vec2;\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n abstract getReactionForce(inv_dt: number): Vec2;\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n abstract getReactionTorque(inv_dt: number): number;\n\n /**\n * Shift the origin for any points stored in world coordinates.\n */\n shiftOrigin(newOrigin: Vec2Value): void {}\n\n abstract initVelocityConstraints(step: TimeStep): void;\n\n abstract solveVelocityConstraints(step: TimeStep): void;\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n abstract solvePositionConstraints(step: TimeStep): boolean;\n\n /**\n * @hidden @experimental\n * Update joint with new props.\n */\n abstract _reset(def: Partial): void;\n\n /**\n * @internal @deprecated\n * Temporary for backward compatibility, will be removed.\n */\n _resetAnchors(def: any): void {\n return this._reset(def);\n }\n}\n","/** @hidden */\nexport const stats = {\n gjkCalls: 0,\n gjkIters: 0,\n gjkMaxIters: 0,\n\n toiTime: 0,\n toiMaxTime: 0,\n toiCalls: 0,\n toiIters: 0,\n toiMaxIters: 0,\n toiRootIters: 0,\n toiMaxRootIters: 0,\n\n toString(newline?: string): string {\n newline = typeof newline === \"string\" ? newline : \"\\n\";\n let string = \"\";\n // tslint:disable-next-line:no-for-in\n for (const name in this) {\n if (typeof this[name] !== \"function\" && typeof this[name] !== \"object\") {\n string += name + \": \" + this[name] + newline;\n }\n }\n return string;\n }\n};\n","/** @internal */\nexport const now = function(): number {\n return Date.now();\n};\n\n/** @internal */\nexport const diff = function(time: number): number {\n return Date.now() - time;\n};\n\n/** @internal */\nexport default {\n now,\n diff,\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { stats } from \"../util/stats\";\nimport { Shape } from \"./Shape\";\nimport { EPSILON } from \"../common/Math\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { Rot } from \"../common/Rot\";\nimport { Transform, TransformValue } from \"../common/Transform\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_max = Math.max;\n\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const e12 = matrix.vec2(0, 0);\n/** @internal */ const e13 = matrix.vec2(0, 0);\n/** @internal */ const e23 = matrix.vec2(0, 0);\n/** @internal */ const temp1 = matrix.vec2(0, 0);\n/** @internal */ const temp2 = matrix.vec2(0, 0);\n\n/**\n * GJK using Voronoi regions (Christer Ericson) and Barycentric coordinates.\n */\n\nstats.gjkCalls = 0;\nstats.gjkIters = 0;\nstats.gjkMaxIters = 0;\n\n/**\n * Input for Distance. You have to option to use the shape radii in the\n * computation. Even\n */\nexport class DistanceInput {\n readonly proxyA = new DistanceProxy();\n readonly proxyB = new DistanceProxy();\n readonly transformA = Transform.identity();\n readonly transformB = Transform.identity();\n useRadii = false;\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.transformA.setIdentity();\n this.transformB.setIdentity();\n this.useRadii = false;\n }\n}\n\n/**\n * Output for Distance.\n */\nexport class DistanceOutput {\n /** closest point on shapeA */\n pointA = matrix.vec2(0, 0);\n /** closest point on shapeB */\n pointB = matrix.vec2(0, 0);\n distance = 0;\n /** iterations number of GJK iterations used */\n iterations = 0;\n recycle() {\n matrix.zeroVec2(this.pointA);\n matrix.zeroVec2(this.pointB);\n this.distance = 0;\n this.iterations = 0;\n }\n}\n\n/**\n * Used to warm start Distance. Set count to zero on first call.\n */\nexport class SimplexCache {\n /** length or area */\n metric: number = 0;\n /** vertices on shape A */\n indexA: number[] = [];\n /** vertices on shape B */\n indexB: number[] = [];\n count: number = 0;\n recycle() {\n this.metric = 0;\n this.indexA.length = 0;\n this.indexB.length = 0;\n this.count = 0;\n }\n}\n\n/**\n * Compute the closest points between two shapes. Supports any combination of:\n * CircleShape, PolygonShape, EdgeShape. The simplex cache is input/output. On\n * the first call set SimplexCache.count to zero.\n */\nexport const Distance = function (output: DistanceOutput, cache: SimplexCache, input: DistanceInput): void {\n ++stats.gjkCalls;\n\n const proxyA = input.proxyA;\n const proxyB = input.proxyB;\n const xfA = input.transformA;\n const xfB = input.transformB;\n\n // Initialize the simplex.\n // const simplex = new Simplex();\n simplex.recycle();\n simplex.readCache(cache, proxyA, xfA, proxyB, xfB);\n\n // Get simplex vertices as an array.\n const vertices = simplex.m_v;\n const k_maxIters = Settings.maxDistanceIterations;\n\n // These store the vertices of the last simplex so that we\n // can check for duplicates and prevent cycling.\n const saveA = [];\n const saveB = []; // int[3]\n let saveCount = 0;\n\n // Main iteration loop.\n let iter = 0;\n while (iter < k_maxIters) {\n // Copy simplex so we can identify duplicates.\n saveCount = simplex.m_count;\n for (let i = 0; i < saveCount; ++i) {\n saveA[i] = vertices[i].indexA;\n saveB[i] = vertices[i].indexB;\n }\n\n simplex.solve();\n\n // If we have 3 points, then the origin is in the corresponding triangle.\n if (simplex.m_count === 3) {\n break;\n }\n\n // Get search direction.\n const d = simplex.getSearchDirection();\n\n // Ensure the search direction is numerically fit.\n if (matrix.lengthSqrVec2(d) < EPSILON * EPSILON) {\n // The origin is probably contained by a line segment\n // or triangle. Thus the shapes are overlapped.\n\n // We can't return zero here even though there may be overlap.\n // In case the simplex is a point, segment, or triangle it is difficult\n // to determine if the origin is contained in the CSO or very close to it.\n break;\n }\n\n // Compute a tentative new simplex vertex using support points.\n const vertex = vertices[simplex.m_count]; // SimplexVertex\n\n vertex.indexA = proxyA.getSupport(matrix.derotVec2(temp, xfA.q, matrix.scaleVec2(temp, -1, d)));\n matrix.transformVec2(vertex.wA, xfA, proxyA.getVertex(vertex.indexA));\n\n vertex.indexB = proxyB.getSupport(matrix.derotVec2(temp, xfB.q, d));\n matrix.transformVec2(vertex.wB, xfB, proxyB.getVertex(vertex.indexB));\n\n matrix.subVec2(vertex.w, vertex.wB, vertex.wA);\n\n // Iteration count is equated to the number of support point calls.\n ++iter;\n ++stats.gjkIters;\n\n // Check for duplicate support points. This is the main termination\n // criteria.\n let duplicate = false;\n for (let i = 0; i < saveCount; ++i) {\n if (vertex.indexA === saveA[i] && vertex.indexB === saveB[i]) {\n duplicate = true;\n break;\n }\n }\n\n // If we found a duplicate support point we must exit to avoid cycling.\n if (duplicate) {\n break;\n }\n\n // New vertex is ok and needed.\n ++simplex.m_count;\n }\n\n stats.gjkMaxIters = math_max(stats.gjkMaxIters, iter);\n\n // Prepare output.\n simplex.getWitnessPoints(output.pointA, output.pointB);\n output.distance = matrix.distVec2(output.pointA, output.pointB);\n output.iterations = iter;\n\n // Cache the simplex.\n simplex.writeCache(cache);\n\n // Apply radii if requested.\n if (input.useRadii) {\n const rA = proxyA.m_radius;\n const rB = proxyB.m_radius;\n\n if (output.distance > rA + rB && output.distance > EPSILON) {\n // Shapes are still no overlapped.\n // Move the witness points to the outer surface.\n output.distance -= rA + rB;\n matrix.subVec2(normal, output.pointB, output.pointA);\n matrix.normalizeVec2(normal);\n matrix.plusScaleVec2(output.pointA, rA, normal);\n matrix.minusScaleVec2(output.pointB, rB, normal);\n } else {\n // Shapes are overlapped when radii are considered.\n // Move the witness points to the middle.\n const p = matrix.subVec2(temp, output.pointA, output.pointB);\n matrix.copyVec2(output.pointA, p);\n matrix.copyVec2(output.pointB, p);\n output.distance = 0.0;\n }\n }\n};\n\n/**\n * A distance proxy is used by the GJK algorithm. It encapsulates any shape.\n */\nexport class DistanceProxy {\n /** @internal */ m_vertices: Vec2Value[] = [];\n // todo: remove this?\n /** @internal */ m_count = 0;\n /** @internal */ m_radius = 0;\n\n recycle() {\n this.m_vertices.length = 0;\n this.m_count = 0;\n this.m_radius = 0;\n }\n\n /**\n * Get the vertex count.\n */\n getVertexCount(): number {\n return this.m_count;\n }\n\n /**\n * Get a vertex by index. Used by Distance.\n */\n getVertex(index: number): Vec2Value {\n if (_ASSERT) console.assert(0 <= index && index < this.m_count);\n return this.m_vertices[index];\n }\n\n /**\n * Get the supporting vertex index in the given direction.\n */\n getSupport(d: Vec2Value): number {\n let bestIndex = -1;\n let bestValue = -Infinity;\n for (let i = 0; i < this.m_count; ++i) {\n const value = matrix.dotVec2(this.m_vertices[i], d);\n if (value > bestValue) {\n bestIndex = i;\n bestValue = value;\n }\n }\n return bestIndex;\n }\n\n /**\n * Get the supporting vertex in the given direction.\n */\n getSupportVertex(d: Vec2Value): Vec2Value {\n return this.m_vertices[this.getSupport(d)];\n }\n\n /**\n * Initialize the proxy using the given shape. The shape must remain in scope\n * while the proxy is in use.\n */\n set(shape: Shape, index: number): void {\n // TODO remove, use shape instead\n if (_ASSERT) console.assert(typeof shape.computeDistanceProxy === \"function\");\n shape.computeDistanceProxy(this, index);\n }\n\n /**\n * Initialize the proxy using a vertex cloud and radius. The vertices\n * must remain in scope while the proxy is in use.\n */\n setVertices(vertices: Vec2Value[], count: number, radius: number) {\n this.m_vertices = vertices;\n this.m_count = count;\n this.m_radius = radius;\n }\n}\n\nclass SimplexVertex {\n /** support point in proxyA */\n wA = matrix.vec2(0, 0);\n /** wA index */\n indexA = 0;\n\n /** support point in proxyB */\n wB = matrix.vec2(0, 0);\n /** wB index */\n indexB = 0;\n\n /** wB - wA; */\n w = matrix.vec2(0, 0);\n /** barycentric coordinate for closest point */\n a = 0;\n\n recycle() {\n this.indexA = 0;\n this.indexB = 0;\n matrix.zeroVec2(this.wA);\n matrix.zeroVec2(this.wB);\n matrix.zeroVec2(this.w);\n this.a = 0;\n }\n set(v: SimplexVertex): void {\n this.indexA = v.indexA;\n this.indexB = v.indexB;\n matrix.copyVec2(this.wA, v.wA);\n matrix.copyVec2(this.wB, v.wB);\n matrix.copyVec2(this.w, v.w);\n this.a = v.a;\n }\n}\n\n/** @internal */ const searchDirection_reuse = matrix.vec2(0, 0);\n/** @internal */ const closestPoint_reuse = matrix.vec2(0, 0); \n\nclass Simplex {\n m_v1 = new SimplexVertex();\n m_v2 = new SimplexVertex();\n m_v3 = new SimplexVertex();\n m_v = [this.m_v1, this.m_v2, this.m_v3];\n m_count: number;\n recycle() {\n this.m_v1.recycle();\n this.m_v2.recycle();\n this.m_v3.recycle();\n this.m_count = 0;\n }\n\n /** @internal */ toString(): string {\n if (this.m_count === 3) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y,\n this.m_v2.a, this.m_v2.wA.x, this.m_v2.wA.y, this.m_v2.wB.x, this.m_v2.wB.y,\n this.m_v3.a, this.m_v3.wA.x, this.m_v3.wA.y, this.m_v3.wB.x, this.m_v3.wB.y\n ].toString();\n\n } else if (this.m_count === 2) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y,\n this.m_v2.a, this.m_v2.wA.x, this.m_v2.wA.y, this.m_v2.wB.x, this.m_v2.wB.y\n ].toString();\n\n } else if (this.m_count === 1) {\n return [\"+\" + this.m_count,\n this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y\n ].toString();\n\n } else {\n return \"+\" + this.m_count;\n }\n }\n\n readCache(cache: SimplexCache, proxyA: DistanceProxy, transformA: TransformValue, proxyB: DistanceProxy, transformB: TransformValue): void {\n if (_ASSERT) console.assert(cache.count <= 3);\n\n // Copy data from cache.\n this.m_count = cache.count;\n for (let i = 0; i < this.m_count; ++i) {\n const v = this.m_v[i];\n v.indexA = cache.indexA[i];\n v.indexB = cache.indexB[i];\n const wALocal = proxyA.getVertex(v.indexA);\n const wBLocal = proxyB.getVertex(v.indexB);\n matrix.transformVec2(v.wA, transformA, wALocal);\n matrix.transformVec2(v.wB, transformB, wBLocal);\n matrix.subVec2(v.w,v.wB, v.wA);\n v.a = 0.0;\n }\n\n // Compute the new simplex metric, if it is substantially different than\n // old metric then flush the simplex.\n if (this.m_count > 1) {\n const metric1 = cache.metric;\n const metric2 = this.getMetric();\n if (metric2 < 0.5 * metric1 || 2.0 * metric1 < metric2 || metric2 < EPSILON) {\n // Reset the simplex.\n this.m_count = 0;\n }\n }\n\n // If the cache is empty or invalid...\n if (this.m_count === 0) {\n const v = this.m_v[0];\n v.indexA = 0;\n v.indexB = 0;\n const wALocal = proxyA.getVertex(0);\n const wBLocal = proxyB.getVertex(0);\n matrix.transformVec2(v.wA, transformA, wALocal);\n matrix.transformVec2(v.wB, transformB, wBLocal);\n matrix.subVec2(v.w,v.wB, v.wA);\n v.a = 1.0;\n this.m_count = 1;\n }\n }\n\n writeCache(cache: SimplexCache): void {\n cache.metric = this.getMetric();\n cache.count = this.m_count;\n for (let i = 0; i < this.m_count; ++i) {\n cache.indexA[i] = this.m_v[i].indexA;\n cache.indexB[i] = this.m_v[i].indexB;\n }\n }\n\n getSearchDirection(): Vec2Value {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 1:\n return matrix.setVec2(searchDirection_reuse, -v1.w.x, -v1.w.y);\n\n case 2: {\n matrix.subVec2(e12, v2.w, v1.w);\n const sgn = -matrix.crossVec2Vec2(e12, v1.w);\n if (sgn > 0.0) {\n // Origin is left of e12.\n return matrix.setVec2(searchDirection_reuse, -e12.y, e12.x);\n } else {\n // Origin is right of e12.\n return matrix.setVec2(searchDirection_reuse, e12.y, -e12.x);\n }\n }\n\n default:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(searchDirection_reuse);\n }\n }\n\n getClosestPoint(): Vec2Value {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(closestPoint_reuse);\n\n case 1:\n return matrix.copyVec2(closestPoint_reuse, v1.w);\n\n case 2:\n return matrix.combine2Vec2(closestPoint_reuse, v1.a, v1.w, v2.a, v2.w);\n\n case 3:\n return matrix.zeroVec2(closestPoint_reuse);\n\n default:\n if (_ASSERT) console.assert(false);\n return matrix.zeroVec2(closestPoint_reuse);\n }\n }\n\n getWitnessPoints(pA: Vec2Value, pB: Vec2Value): void {\n const v1 = this.m_v1;\n const v2 = this.m_v2;\n const v3 = this.m_v3;\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n break;\n\n case 1:\n matrix.copyVec2(pA, v1.wA);\n matrix.copyVec2(pB, v1.wB);\n break;\n\n case 2:\n matrix.combine2Vec2(pA, v1.a, v1.wA, v2.a, v2.wA);\n matrix.combine2Vec2(pB, v1.a, v1.wB, v2.a, v2.wB);\n break;\n\n case 3:\n matrix.combine3Vec2(pA, v1.a, v1.wA, v2.a, v2.wA, v3.a, v3.wA);\n matrix.copyVec2(pB, pA);\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n break;\n }\n }\n\n getMetric(): number {\n switch (this.m_count) {\n case 0:\n if (_ASSERT) console.assert(false);\n return 0.0;\n\n case 1:\n return 0.0;\n\n case 2:\n return matrix.distVec2(this.m_v1.w, this.m_v2.w);\n\n case 3:\n return matrix.crossVec2Vec2(\n matrix.subVec2(temp1, this.m_v2.w, this.m_v1.w),\n matrix.subVec2(temp2, this.m_v3.w, this.m_v1.w),\n );\n\n default:\n if (_ASSERT) console.assert(false);\n return 0.0;\n }\n }\n\n solve(): void {\n switch (this.m_count) {\n case 1:\n break;\n\n case 2:\n this.solve2();\n break;\n\n case 3:\n this.solve3();\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n }\n }\n\n// Solve a line segment using barycentric coordinates.\n//\n// p = a1 * w1 + a2 * w2\n// a1 + a2 = 1\n//\n// The vector from the origin to the closest point on the line is\n// perpendicular to the line.\n// e12 = w2 - w1\n// dot(p, e) = 0\n// a1 * dot(w1, e) + a2 * dot(w2, e) = 0\n//\n// 2-by-2 linear system\n// [1 1 ][a1] = [1]\n// [w1.e12 w2.e12][a2] = [0]\n//\n// Define\n// d12_1 = dot(w2, e12)\n// d12_2 = -dot(w1, e12)\n// d12 = d12_1 + d12_2\n//\n// Solution\n// a1 = d12_1 / d12\n// a2 = d12_2 / d12\n solve2(): void {\n const w1 = this.m_v1.w;\n const w2 = this.m_v2.w;\n matrix.subVec2(e12, w2, w1);\n\n // w1 region\n const d12_2 = -matrix.dotVec2(w1, e12);\n if (d12_2 <= 0.0) {\n // a2 <= 0, so we clamp it to 0\n this.m_v1.a = 1.0;\n this.m_count = 1;\n return;\n }\n\n // w2 region\n const d12_1 = matrix.dotVec2(w2, e12);\n if (d12_1 <= 0.0) {\n // a1 <= 0, so we clamp it to 0\n this.m_v2.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v2);\n return;\n }\n\n // Must be in e12 region.\n const inv_d12 = 1.0 / (d12_1 + d12_2);\n this.m_v1.a = d12_1 * inv_d12;\n this.m_v2.a = d12_2 * inv_d12;\n this.m_count = 2;\n }\n\n// Possible regions:\n// - points[2]\n// - edge points[0]-points[2]\n// - edge points[1]-points[2]\n// - inside the triangle\n solve3(): void {\n const w1 = this.m_v1.w;\n const w2 = this.m_v2.w;\n const w3 = this.m_v3.w;\n\n // Edge12\n // [1 1 ][a1] = [1]\n // [w1.e12 w2.e12][a2] = [0]\n // a3 = 0\n matrix.subVec2(e12, w2, w1);\n const w1e12 = matrix.dotVec2(w1, e12);\n const w2e12 = matrix.dotVec2(w2, e12);\n const d12_1 = w2e12;\n const d12_2 = -w1e12;\n\n // Edge13\n // [1 1 ][a1] = [1]\n // [w1.e13 w3.e13][a3] = [0]\n // a2 = 0\n matrix.subVec2(e13, w3, w1);\n const w1e13 = matrix.dotVec2(w1, e13);\n const w3e13 = matrix.dotVec2(w3, e13);\n const d13_1 = w3e13;\n const d13_2 = -w1e13;\n\n // Edge23\n // [1 1 ][a2] = [1]\n // [w2.e23 w3.e23][a3] = [0]\n // a1 = 0\n matrix.subVec2(e23, w3, w2);\n const w2e23 = matrix.dotVec2(w2, e23);\n const w3e23 = matrix.dotVec2(w3, e23);\n const d23_1 = w3e23;\n const d23_2 = -w2e23;\n\n // Triangle123\n const n123 = matrix.crossVec2Vec2(e12, e13);\n\n const d123_1 = n123 * matrix.crossVec2Vec2(w2, w3);\n const d123_2 = n123 * matrix.crossVec2Vec2(w3, w1);\n const d123_3 = n123 * matrix.crossVec2Vec2(w1, w2);\n\n // w1 region\n if (d12_2 <= 0.0 && d13_2 <= 0.0) {\n this.m_v1.a = 1.0;\n this.m_count = 1;\n return;\n }\n\n // e12\n if (d12_1 > 0.0 && d12_2 > 0.0 && d123_3 <= 0.0) {\n const inv_d12 = 1.0 / (d12_1 + d12_2);\n this.m_v1.a = d12_1 * inv_d12;\n this.m_v2.a = d12_2 * inv_d12;\n this.m_count = 2;\n return;\n }\n\n // e13\n if (d13_1 > 0.0 && d13_2 > 0.0 && d123_2 <= 0.0) {\n const inv_d13 = 1.0 / (d13_1 + d13_2);\n this.m_v1.a = d13_1 * inv_d13;\n this.m_v3.a = d13_2 * inv_d13;\n this.m_count = 2;\n this.m_v2.set(this.m_v3);\n return;\n }\n\n // w2 region\n if (d12_1 <= 0.0 && d23_2 <= 0.0) {\n this.m_v2.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v2);\n return;\n }\n\n // w3 region\n if (d13_1 <= 0.0 && d23_1 <= 0.0) {\n this.m_v3.a = 1.0;\n this.m_count = 1;\n this.m_v1.set(this.m_v3);\n return;\n }\n\n // e23\n if (d23_1 > 0.0 && d23_2 > 0.0 && d123_1 <= 0.0) {\n const inv_d23 = 1.0 / (d23_1 + d23_2);\n this.m_v2.a = d23_1 * inv_d23;\n this.m_v3.a = d23_2 * inv_d23;\n this.m_count = 2;\n this.m_v1.set(this.m_v3);\n return;\n }\n\n // Must be in triangle123\n const inv_d123 = 1.0 / (d123_1 + d123_2 + d123_3);\n this.m_v1.a = d123_1 * inv_d123;\n this.m_v2.a = d123_2 * inv_d123;\n this.m_v3.a = d123_3 * inv_d123;\n this.m_count = 3;\n }\n}\n\n/** @internal */ const simplex = new Simplex();\n\n/** @internal */ const input = new DistanceInput();\n/** @internal */ const cache = new SimplexCache();\n/** @internal */ const output = new DistanceOutput();\n\n/**\n * Determine if two generic shapes overlap.\n */\nexport const testOverlap = function (shapeA: Shape, indexA: number, shapeB: Shape, indexB: number, xfA: TransformValue, xfB: TransformValue): boolean {\n input.recycle();\n input.proxyA.set(shapeA, indexA);\n input.proxyB.set(shapeB, indexB);\n matrix.copyTransform(input.transformA, xfA);\n matrix.copyTransform(input.transformB, xfB);\n input.useRadii = true;\n\n output.recycle();\n cache.recycle();\n\n Distance(output, cache, input);\n\n return output.distance < 10.0 * EPSILON;\n};\n\n// legacy exports\nDistance.testOverlap = testOverlap;\nDistance.Input = DistanceInput;\nDistance.Output = DistanceOutput;\nDistance.Proxy = DistanceProxy;\nDistance.Cache = SimplexCache;\n\n/**\n * Input parameters for ShapeCast\n */\nexport class ShapeCastInput {\n readonly proxyA = new DistanceProxy();\n readonly proxyB = new DistanceProxy();\n readonly transformA = Transform.identity();\n readonly transformB = Transform.identity();\n readonly translationB = Vec2.zero();\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.transformA.setIdentity();\n this.transformB.setIdentity();\n matrix.zeroVec2(this.translationB);\n }\n}\n\n/**\n * Output results for b2ShapeCast\n */\nexport class ShapeCastOutput {\n point: Vec2 = Vec2.zero();\n normal: Vec2 = Vec2.zero();\n lambda = 1.0;\n iterations = 0;\n}\n\n/**\n * Perform a linear shape cast of shape B moving and shape A fixed. Determines\n * the hit point, normal, and translation fraction.\n * \n * @returns true if hit, false if there is no hit or an initial overlap\n */\n//\n// GJK-raycast\n// Algorithm by Gino van den Bergen.\n// \"Smooth Mesh Contacts with GJK\" in Game Physics Pearls. 2010\nexport const ShapeCast = function(output: ShapeCastOutput, input: ShapeCastInput): boolean {\n output.iterations = 0;\n output.lambda = 1.0;\n output.normal.setZero();\n output.point.setZero();\n\n const proxyA = input.proxyA;\n const proxyB = input.proxyB;\n\n const radiusA = math_max(proxyA.m_radius, Settings.polygonRadius);\n const radiusB = math_max(proxyB.m_radius, Settings.polygonRadius);\n const radius = radiusA + radiusB;\n\n const xfA = input.transformA;\n const xfB = input.transformB;\n\n const r = input.translationB;\n const n = Vec2.zero();\n let lambda = 0.0;\n\n // Initial simplex\n const simplex = new Simplex();\n simplex.m_count = 0;\n\n // Get simplex vertices as an array.\n const vertices = simplex.m_v;\n\n // Get support point in -r direction\n let indexA = proxyA.getSupport(Rot.mulTVec2(xfA.q, Vec2.neg(r)));\n let wA = Transform.mulVec2(xfA, proxyA.getVertex(indexA));\n let indexB = proxyB.getSupport(Rot.mulTVec2(xfB.q, r));\n let wB = Transform.mulVec2(xfB, proxyB.getVertex(indexB));\n const v = Vec2.sub(wA, wB);\n\n // Sigma is the target distance between polygons\n const sigma = math_max(Settings.polygonRadius, radius - Settings.polygonRadius);\n const tolerance = 0.5 * Settings.linearSlop;\n\n // Main iteration loop.\n const k_maxIters = 20;\n let iter = 0;\n while (iter < k_maxIters && v.length() - sigma > tolerance) {\n if (_ASSERT) console.assert(simplex.m_count < 3);\n\n output.iterations += 1;\n\n // Support in direction -v (A - B)\n indexA = proxyA.getSupport(Rot.mulTVec2(xfA.q, Vec2.neg(v)));\n wA = Transform.mulVec2(xfA, proxyA.getVertex(indexA));\n indexB = proxyB.getSupport(Rot.mulTVec2(xfB.q, v));\n wB = Transform.mulVec2(xfB, proxyB.getVertex(indexB));\n const p = Vec2.sub(wA, wB);\n\n // -v is a normal at p\n v.normalize();\n\n // Intersect ray with plane\n const vp = Vec2.dot(v, p);\n const vr = Vec2.dot(v, r);\n if (vp - sigma > lambda * vr) {\n if (vr <= 0.0) {\n return false;\n }\n\n lambda = (vp - sigma) / vr;\n if (lambda > 1.0) {\n return false;\n }\n\n n.setMul(-1, v);\n simplex.m_count = 0;\n }\n\n // Reverse simplex since it works with B - A.\n // Shift by lambda * r because we want the closest point to the current clip point.\n // Note that the support point p is not shifted because we want the plane equation\n // to be formed in unshifted space.\n const vertex = vertices[simplex.m_count];\n vertex.indexA = indexB;\n vertex.wA = Vec2.combine(1, wB, lambda, r);\n vertex.indexB = indexA;\n vertex.wB = wA;\n vertex.w = Vec2.sub(vertex.wB, vertex.wA);\n vertex.a = 1.0;\n simplex.m_count += 1;\n\n switch (simplex.m_count) {\n case 1:\n break;\n\n case 2:\n simplex.solve2();\n break;\n\n case 3:\n simplex.solve3();\n break;\n\n default:\n if (_ASSERT) console.assert(false);\n }\n \n // If we have 3 points, then the origin is in the corresponding triangle.\n if (simplex.m_count == 3) {\n // Overlap\n return false;\n }\n\n // Get search direction.\n v.setVec2(simplex.getClosestPoint());\n\n // Iteration count is equated to the number of support point calls.\n ++iter;\n }\n\n if (iter == 0) {\n // Initial overlap\n return false;\n\t}\n\n // Prepare output.\n const pointA = Vec2.zero();\n const pointB = Vec2.zero();\n simplex.getWitnessPoints(pointB, pointA);\n\n if (v.lengthSquared() > 0.0) {\n n.setMul(-1, v);\n n.normalize();\n }\n\n output.point = Vec2.combine(1, pointA, radiusA, n);\n output.normal = n;\n output.lambda = lambda;\n output.iterations = iter;\n return true;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { stats } from \"../util/stats\";\nimport Timer from \"../util/Timer\";\nimport { Sweep } from \"../common/Sweep\";\nimport { Transform } from \"../common/Transform\";\nimport { Distance, DistanceInput, DistanceOutput, DistanceProxy, SimplexCache } from \"./Distance\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n\n\n/**\n * Input parameters for TimeOfImpact.\n */\nexport class TOIInput {\n proxyA = new DistanceProxy();\n proxyB = new DistanceProxy();\n sweepA = new Sweep();\n sweepB = new Sweep();\n /** defines sweep interval [0, tMax] */\n tMax: number;\n recycle() {\n this.proxyA.recycle();\n this.proxyB.recycle();\n this.sweepA.recycle();\n this.sweepB.recycle();\n this.tMax = -1;\n }\n}\n\nexport enum TOIOutputState {\n e_unset = -1,\n e_unknown = 0,\n e_failed = 1,\n e_overlapped = 2,\n e_touching = 3,\n e_separated = 4,\n}\n\n/**\n * Output parameters for TimeOfImpact.\n */\nexport class TOIOutput {\n state = TOIOutputState.e_unset;\n t = -1;\n recycle() {\n this.state = TOIOutputState.e_unset;\n this.t = -1;\n }\n}\n\nstats.toiTime = 0;\nstats.toiMaxTime = 0;\nstats.toiCalls = 0;\nstats.toiIters = 0;\nstats.toiMaxIters = 0;\nstats.toiRootIters = 0;\nstats.toiMaxRootIters = 0;\n\n/** @internal */ const distanceInput = new DistanceInput();\n/** @internal */ const distanceOutput = new DistanceOutput();\n// this is passed to Distance and SeparationFunction\n/** @internal */ const cache = new SimplexCache();\n\n/** @internal */ const xfA = matrix.transform(0, 0, 0);\n/** @internal */ const xfB = matrix.transform(0, 0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const axisA = matrix.vec2(0, 0);\n/** @internal */ const axisB = matrix.vec2(0, 0);\n/** @internal */ const localPointA = matrix.vec2(0, 0);\n/** @internal */ const localPointB = matrix.vec2(0, 0);\n\n\n/**\n * Compute the upper bound on time before two shapes penetrate. Time is\n * represented as a fraction between [0,tMax]. This uses a swept separating axis\n * and may miss some intermediate, non-tunneling collisions. If you change the\n * time interval, you should call this function again.\n *\n * Note: use Distance to compute the contact point and normal at the time of\n * impact.\n *\n * CCD via the local separating axis method. This seeks progression by computing\n * the largest time at which separation is maintained.\n */\nexport const TimeOfImpact = function (output: TOIOutput, input: TOIInput): void {\n const timer = Timer.now();\n\n ++stats.toiCalls;\n\n output.state = TOIOutputState.e_unknown;\n output.t = input.tMax;\n\n const proxyA = input.proxyA; // DistanceProxy\n const proxyB = input.proxyB; // DistanceProxy\n\n const sweepA = input.sweepA; // Sweep\n const sweepB = input.sweepB; // Sweep\n\n // Large rotations can make the root finder fail, so we normalize the\n // sweep angles.\n sweepA.normalize();\n sweepB.normalize();\n\n const tMax = input.tMax;\n\n const totalRadius = proxyA.m_radius + proxyB.m_radius;\n const target = math_max(Settings.linearSlop, totalRadius - 3.0 * Settings.linearSlop);\n const tolerance = 0.25 * Settings.linearSlop;\n if (_ASSERT) console.assert(target > tolerance);\n\n let t1 = 0.0;\n const k_maxIterations = Settings.maxTOIIterations;\n let iter = 0;\n\n // Prepare input for distance query.\n // const cache = new SimplexCache();\n cache.recycle();\n\n distanceInput.proxyA.setVertices(proxyA.m_vertices, proxyA.m_count, proxyA.m_radius);\n distanceInput.proxyB.setVertices(proxyB.m_vertices, proxyB.m_count, proxyB.m_radius);\n distanceInput.useRadii = false;\n\n // The outer loop progressively attempts to compute new separating axes.\n // This loop terminates when an axis is repeated (no progress is made).\n while (true) {\n sweepA.getTransform(xfA, t1);\n sweepB.getTransform(xfB, t1);\n\n // Get the distance between shapes. We can also use the results\n // to get a separating axis.\n matrix.copyTransform(distanceInput.transformA, xfA);\n matrix.copyTransform(distanceInput.transformB, xfB);\n Distance(distanceOutput, cache, distanceInput);\n\n // If the shapes are overlapped, we give up on continuous collision.\n if (distanceOutput.distance <= 0.0) {\n // Failure!\n output.state = TOIOutputState.e_overlapped;\n output.t = 0.0;\n break;\n }\n\n if (distanceOutput.distance < target + tolerance) {\n // Victory!\n output.state = TOIOutputState.e_touching;\n output.t = t1;\n break;\n }\n\n // Initialize the separating axis.\n separationFunction.initialize(cache, proxyA, sweepA, proxyB, sweepB, t1);\n\n // if (false) {\n // // Dump the curve seen by the root finder\n // const N = 100;\n // const dx = 1.0 / N;\n // const xs = []; // [ N + 1 ];\n // const fs = []; // [ N + 1 ];\n // const x = 0.0;\n // for (const i = 0; i <= N; ++i) {\n // sweepA.getTransform(xfA, x);\n // sweepB.getTransform(xfB, x);\n // const f = fcn.evaluate(xfA, xfB) - target;\n // printf(\"%g %g\\n\", x, f);\n // xs[i] = x;\n // fs[i] = f;\n // x += dx;\n // }\n // }\n\n // Compute the TOI on the separating axis. We do this by successively\n // resolving the deepest point. This loop is bounded by the number of\n // vertices.\n let done = false;\n let t2 = tMax;\n let pushBackIter = 0;\n while (true) {\n // Find the deepest point at t2. Store the witness point indices.\n let s2 = separationFunction.findMinSeparation(t2);\n\n // Is the final configuration separated?\n if (s2 > target + tolerance) {\n // Victory!\n output.state = TOIOutputState.e_separated;\n output.t = tMax;\n done = true;\n break;\n }\n\n // Has the separation reached tolerance?\n if (s2 > target - tolerance) {\n // Advance the sweeps\n t1 = t2;\n break;\n }\n\n // Compute the initial separation of the witness points.\n let s1 = separationFunction.evaluate(t1);\n\n // Check for initial overlap. This might happen if the root finder\n // runs out of iterations.\n if (s1 < target - tolerance) {\n output.state = TOIOutputState.e_failed;\n output.t = t1;\n done = true;\n break;\n }\n\n // Check for touching\n if (s1 <= target + tolerance) {\n // Victory! t1 should hold the TOI (could be 0.0).\n output.state = TOIOutputState.e_touching;\n output.t = t1;\n done = true;\n break;\n }\n\n // Compute 1D root of: f(x) - target = 0\n let rootIterCount = 0;\n let a1 = t1;\n let a2 = t2;\n while (true) {\n // Use a mix of the secant rule and bisection.\n let t;\n if (rootIterCount & 1) {\n // Secant rule to improve convergence.\n t = a1 + (target - s1) * (a2 - a1) / (s2 - s1);\n } else {\n // Bisection to guarantee progress.\n t = 0.5 * (a1 + a2);\n }\n\n ++rootIterCount;\n ++stats.toiRootIters;\n\n const s = separationFunction.evaluate(t);\n\n if (math_abs(s - target) < tolerance) {\n // t2 holds a tentative value for t1\n t2 = t;\n break;\n }\n\n // Ensure we continue to bracket the root.\n if (s > target) {\n a1 = t;\n s1 = s;\n } else {\n a2 = t;\n s2 = s;\n }\n\n if (rootIterCount === 50) {\n break;\n }\n }\n\n stats.toiMaxRootIters = math_max(stats.toiMaxRootIters, rootIterCount);\n\n ++pushBackIter;\n\n if (pushBackIter === Settings.maxPolygonVertices) {\n break;\n }\n }\n\n ++iter;\n ++stats.toiIters;\n\n if (done) {\n break;\n }\n\n if (iter === k_maxIterations) {\n // Root finder got stuck. Semi-victory.\n output.state = TOIOutputState.e_failed;\n output.t = t1;\n break;\n }\n }\n\n stats.toiMaxIters = math_max(stats.toiMaxIters, iter);\n\n const time = Timer.diff(timer);\n stats.toiMaxTime = math_max(stats.toiMaxTime, time);\n stats.toiTime += time;\n\n separationFunction.recycle();\n};\n\nenum SeparationFunctionType {\n e_unset = -1,\n e_points = 1,\n e_faceA = 2,\n e_faceB = 3,\n}\n\nclass SeparationFunction {\n // input cache\n // todo: maybe assign by copy instead of reference?\n m_proxyA: DistanceProxy = null;\n m_proxyB: DistanceProxy = null;\n m_sweepA: Sweep = null;\n m_sweepB: Sweep = null;\n\n // initialize cache\n m_type = SeparationFunctionType.e_unset;\n m_localPoint = matrix.vec2(0, 0);\n m_axis = matrix.vec2(0, 0);\n\n // compute output\n indexA = -1;\n indexB = -1;\n\n recycle() {\n this.m_proxyA = null;\n this.m_proxyB = null;\n this.m_sweepA = null;\n this.m_sweepB = null;\n\n this.m_type = SeparationFunctionType.e_unset;\n matrix.zeroVec2(this.m_localPoint);\n matrix.zeroVec2(this.m_axis);\n\n this.indexA = -1;\n this.indexB = -1;\n }\n\n // TODO_ERIN might not need to return the separation\n\n initialize(cache: SimplexCache, proxyA: DistanceProxy, sweepA: Sweep, proxyB: DistanceProxy, sweepB: Sweep, t1: number): number {\n const count = cache.count;\n if (_ASSERT) console.assert(0 < count && count < 3);\n\n this.m_proxyA = proxyA;\n this.m_proxyB = proxyB;\n this.m_sweepA = sweepA;\n this.m_sweepB = sweepB;\n\n this.m_sweepA.getTransform(xfA, t1);\n this.m_sweepB.getTransform(xfB, t1);\n\n if (count === 1) {\n this.m_type = SeparationFunctionType.e_points;\n const localPointA = this.m_proxyA.getVertex(cache.indexA[0]);\n const localPointB = this.m_proxyB.getVertex(cache.indexB[0]);\n matrix.transformVec2(pointA, xfA, localPointA);\n matrix.transformVec2(pointB, xfB, localPointB);\n matrix.subVec2(this.m_axis, pointB, pointA);\n const s = matrix.normalizeVec2Length(this.m_axis);\n return s;\n\n } else if (cache.indexA[0] === cache.indexA[1]) {\n // Two points on B and one on A.\n this.m_type = SeparationFunctionType.e_faceB;\n const localPointB1 = proxyB.getVertex(cache.indexB[0]);\n const localPointB2 = proxyB.getVertex(cache.indexB[1]);\n\n matrix.crossVec2Num(this.m_axis, matrix.subVec2(temp, localPointB2, localPointB1), 1.0);\n matrix.normalizeVec2(this.m_axis);\n matrix.rotVec2(normal, xfB.q, this.m_axis);\n\n matrix.combine2Vec2(this.m_localPoint, 0.5, localPointB1, 0.5, localPointB2);\n matrix.transformVec2(pointB, xfB, this.m_localPoint);\n\n const localPointA = proxyA.getVertex(cache.indexA[0]);\n const pointA = Transform.mulVec2(xfA, localPointA);\n\n let s = matrix.dotVec2(pointA, normal) - matrix.dotVec2(pointB, normal);\n if (s < 0.0) {\n matrix.negVec2(this.m_axis);\n s = -s;\n }\n return s;\n\n } else {\n // Two points on A and one or two points on B.\n this.m_type = SeparationFunctionType.e_faceA;\n const localPointA1 = this.m_proxyA.getVertex(cache.indexA[0]);\n const localPointA2 = this.m_proxyA.getVertex(cache.indexA[1]);\n\n matrix.crossVec2Num(this.m_axis, matrix.subVec2(temp, localPointA2, localPointA1), 1.0);\n matrix.normalizeVec2(this.m_axis);\n matrix.rotVec2(normal, xfA.q, this.m_axis);\n\n matrix.combine2Vec2(this.m_localPoint, 0.5, localPointA1, 0.5, localPointA2);\n matrix.transformVec2(pointA, xfA, this.m_localPoint);\n\n const localPointB = this.m_proxyB.getVertex(cache.indexB[0]);\n matrix.transformVec2(pointB, xfB, localPointB);\n\n let s = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal);\n if (s < 0.0) {\n matrix.negVec2(this.m_axis);\n s = -s;\n }\n return s;\n }\n }\n\n compute(find: boolean, t: number): number {\n // It was findMinSeparation and evaluate\n this.m_sweepA.getTransform(xfA, t);\n this.m_sweepB.getTransform(xfB, t);\n\n switch (this.m_type) {\n case SeparationFunctionType.e_points: {\n if (find) {\n matrix.derotVec2(axisA, xfA.q, this.m_axis);\n matrix.derotVec2(axisB, xfB.q, matrix.scaleVec2(temp, -1, this.m_axis));\n\n this.indexA = this.m_proxyA.getSupport(axisA);\n this.indexB = this.m_proxyB.getSupport(axisB);\n }\n\n matrix.copyVec2(localPointA, this.m_proxyA.getVertex(this.indexA));\n matrix.copyVec2(localPointB, this.m_proxyB.getVertex(this.indexB));\n\n matrix.transformVec2(pointA, xfA, localPointA);\n matrix.transformVec2(pointB, xfB, localPointB);\n\n const sep = matrix.dotVec2(pointB, this.m_axis) - matrix.dotVec2(pointA, this.m_axis);\n return sep;\n }\n\n case SeparationFunctionType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.m_axis);\n matrix.transformVec2(pointA, xfA, this.m_localPoint);\n\n if (find) {\n matrix.derotVec2(axisB, xfB.q, matrix.scaleVec2(temp, -1, normal));\n\n this.indexA = -1;\n this.indexB = this.m_proxyB.getSupport(axisB);\n }\n\n matrix.copyVec2(localPointB, this.m_proxyB.getVertex(this.indexB));\n matrix.transformVec2(pointB, xfB, localPointB);\n\n const sep = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal);\n return sep;\n }\n\n case SeparationFunctionType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.m_axis);\n matrix.transformVec2(pointB, xfB, this.m_localPoint);\n\n if (find) {\n matrix.derotVec2(axisA, xfA.q, matrix.scaleVec2(temp, -1, normal));\n\n this.indexB = -1;\n this.indexA = this.m_proxyA.getSupport(axisA);\n }\n\n matrix.copyVec2(localPointA, this.m_proxyA.getVertex(this.indexA));\n matrix.transformVec2(pointA, xfA, localPointA);\n\n const sep = matrix.dotVec2(pointA, normal) - matrix.dotVec2(pointB, normal);\n return sep;\n }\n\n default:\n if (_ASSERT) console.assert(false);\n if (find) {\n this.indexA = -1;\n this.indexB = -1;\n }\n return 0.0;\n }\n }\n\n findMinSeparation(t: number): number {\n return this.compute(true, t);\n }\n\n evaluate(t: number): number {\n return this.compute(false, t);\n }\n}\n\n/** @internal */ const separationFunction = new SeparationFunction();\n\n// legacy exports\nTimeOfImpact.Input = TOIInput;\nTimeOfImpact.Output = TOIOutput;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { EPSILON } from \"../common/Math\";\nimport { Body } from \"./Body\";\nimport type { Contact } from \"./Contact\";\nimport { Joint } from \"./Joint\";\nimport { TimeOfImpact, TOIInput, TOIOutput, TOIOutputState } from \"../collision/TimeOfImpact\";\nimport { Distance, DistanceInput, DistanceOutput, SimplexCache } from \"../collision/Distance\";\nimport { World } from \"./World\";\nimport { Sweep } from \"../common/Sweep\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_min = Math.min;\n\n\nexport class TimeStep {\n /** time step */\n dt: number = 0;\n /** inverse time step (0 if dt == 0) */\n inv_dt: number = 0;\n velocityIterations: number = 0;\n positionIterations: number = 0;\n warmStarting: boolean = false;\n blockSolve: boolean = true;\n\n /** timestep ratio for variable timestep */\n inv_dt0: number = 0.0;\n /** dt * inv_dt0 */\n dtRatio: number = 1;\n\n reset(dt: number): void {\n if (this.dt > 0.0) {\n this.inv_dt0 = this.inv_dt;\n }\n this.dt = dt;\n this.inv_dt = dt == 0 ? 0 : 1 / dt;\n this.dtRatio = dt * this.inv_dt0;\n }\n}\n\n// reuse\n/** @internal */ const s_subStep = new TimeStep();\n/** @internal */ const c = matrix.vec2(0, 0);\n/** @internal */ const v = matrix.vec2(0, 0);\n/** @internal */ const translation = matrix.vec2(0, 0);\n/** @internal */ const input = new TOIInput();\n/** @internal */ const output = new TOIOutput();\n/** @internal */ const backup = new Sweep();\n/** @internal */ const backup1 = new Sweep();\n/** @internal */ const backup2 = new Sweep();\n\n/**\n * Contact impulses for reporting. Impulses are used instead of forces because\n * sub-step forces may approach infinity for rigid body collisions. These match\n * up one-to-one with the contact points in Manifold.\n */\nexport class ContactImpulse {\n // TODO: merge with Contact class?\n\n private readonly contact: Contact;\n private readonly normals: number[];\n private readonly tangents: number[];\n\n constructor(contact: Contact) {\n this.contact = contact;\n this.normals = [];\n this.tangents = [];\n }\n\n recycle() {\n this.normals.length = 0;\n this.tangents.length = 0;\n }\n\n get normalImpulses(): number[] {\n const contact = this.contact;\n const normals = this.normals;\n normals.length = 0;\n for (let p = 0; p < contact.v_points.length; ++p) {\n normals.push(contact.v_points[p].normalImpulse);\n }\n return normals;\n }\n\n get tangentImpulses(): number[] {\n const contact = this.contact;\n const tangents = this.tangents;\n tangents.length = 0;\n for (let p = 0; p < contact.v_points.length; ++p) {\n tangents.push(contact.v_points[p].tangentImpulse);\n }\n return tangents;\n }\n}\n\n/**\n * Finds and solves islands. An island is a connected subset of the world.\n */\nexport class Solver {\n m_world: World;\n m_stack: Body[];\n m_bodies: Body[];\n m_contacts: Contact[];\n m_joints: Joint[];\n\n constructor(world: World) {\n this.m_world = world;\n this.m_stack = [];\n this.m_bodies = [];\n this.m_contacts = [];\n this.m_joints = [];\n }\n\n clear(): void {\n this.m_stack.length = 0;\n this.m_bodies.length = 0;\n this.m_contacts.length = 0;\n this.m_joints.length = 0;\n }\n\n addBody(body: Body): void {\n if (_ASSERT) console.assert(body instanceof Body, \"Not a Body!\", body);\n this.m_bodies.push(body);\n // why?\n // body.c_position.c.setZero();\n // body.c_position.a = 0;\n // body.c_velocity.v.setZero();\n // body.c_velocity.w = 0;\n }\n\n addContact(contact: Contact): void {\n // if (_ASSERT) console.assert(contact instanceof Contact, 'Not a Contact!', contact);\n this.m_contacts.push(contact);\n }\n\n addJoint(joint: Joint): void {\n if (_ASSERT) console.assert(joint instanceof Joint, \"Not a Joint!\", joint);\n this.m_joints.push(joint);\n }\n\n solveWorld(step: TimeStep): void {\n const world = this.m_world;\n\n // Clear all the island flags.\n for (let b = world.m_bodyList; b; b = b.m_next) {\n b.m_islandFlag = false;\n }\n for (let c = world.m_contactList; c; c = c.m_next) {\n c.m_islandFlag = false;\n }\n for (let j = world.m_jointList; j; j = j.m_next) {\n j.m_islandFlag = false;\n }\n\n // Build and simulate all awake islands.\n const stack = this.m_stack;\n let loop = -1;\n for (let seed = world.m_bodyList; seed; seed = seed.m_next) {\n loop++;\n if (seed.m_islandFlag) {\n continue;\n }\n\n if (seed.isAwake() == false || seed.isActive() == false) {\n continue;\n }\n\n // The seed can be dynamic or kinematic.\n if (seed.isStatic()) {\n continue;\n }\n\n // Reset island and stack.\n this.clear();\n\n stack.push(seed);\n\n seed.m_islandFlag = true;\n\n // Perform a depth first search (DFS) on the constraint graph.\n while (stack.length > 0) {\n // Grab the next body off the stack and add it to the island.\n const b = stack.pop();\n if (_ASSERT) console.assert(b.isActive() == true);\n this.addBody(b);\n\n // Make sure the body is awake (without resetting sleep timer).\n b.m_awakeFlag = true;\n\n // To keep islands as small as possible, we don't\n // propagate islands across static bodies.\n if (b.isStatic()) {\n continue;\n }\n\n // Search all contacts connected to this body.\n for (let ce = b.m_contactList; ce; ce = ce.next) {\n const contact = ce.contact;\n\n // Has this contact already been added to an island?\n if (contact.m_islandFlag) {\n continue;\n }\n\n // Is this contact solid and touching?\n if (contact.isEnabled() == false || contact.isTouching() == false) {\n continue;\n }\n\n // Skip sensors.\n const sensorA = contact.m_fixtureA.m_isSensor;\n const sensorB = contact.m_fixtureB.m_isSensor;\n if (sensorA || sensorB) {\n continue;\n }\n\n this.addContact(contact);\n contact.m_islandFlag = true;\n\n const other = ce.other;\n\n // Was the other body already added to this island?\n if (other.m_islandFlag) {\n continue;\n }\n\n // if (_ASSERT) console.assert(stack.length < world.m_bodyCount);\n stack.push(other);\n other.m_islandFlag = true;\n }\n\n // Search all joints connect to this body.\n for (let je = b.m_jointList; je; je = je.next) {\n if (je.joint.m_islandFlag == true) {\n continue;\n }\n\n const other = je.other;\n\n // Don't simulate joints connected to inactive bodies.\n if (other.isActive() == false) {\n continue;\n }\n\n this.addJoint(je.joint);\n je.joint.m_islandFlag = true;\n\n if (other.m_islandFlag) {\n continue;\n }\n\n // if (_ASSERT) console.assert(stack.length < world.m_bodyCount);\n stack.push(other);\n other.m_islandFlag = true;\n }\n }\n\n this.solveIsland(step);\n\n // Post solve cleanup.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n // Allow static bodies to participate in other islands.\n // TODO: are they added at all?\n const b = this.m_bodies[i];\n if (b.isStatic()) {\n b.m_islandFlag = false;\n }\n }\n }\n }\n\n solveIsland(step: TimeStep): void {\n // B2: Island Solve\n const world = this.m_world;\n const gravity = world.m_gravity;\n const allowSleep = world.m_allowSleep;\n\n const h = step.dt;\n\n // Integrate velocities and apply damping. Initialize the body state.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.m_sweep.c);\n const a = body.m_sweep.a;\n matrix.copyVec2(v, body.m_linearVelocity);\n let w = body.m_angularVelocity;\n\n // Store positions for continuous collision.\n matrix.copyVec2(body.m_sweep.c0, body.m_sweep.c);\n body.m_sweep.a0 = body.m_sweep.a;\n\n if (body.isDynamic()) {\n // Integrate velocities.\n matrix.plusScaleVec2(v, h * body.m_gravityScale, gravity);\n matrix.plusScaleVec2(v, h * body.m_invMass, body.m_force);\n w += h * body.m_invI * body.m_torque;\n /**\n *
\n         * Apply damping.\n         * ODE: dv/dt + c * v = 0\n         * Solution: v(t) = v0 * exp(-c * t)\n         * Time step: v(t + dt) = v0 * exp(-c * (t + dt)) = v0 * exp(-c * t) * exp(-c * dt) = v * exp(-c * dt)\n         * v2 = exp(-c * dt) * v1\n         * Pade approximation:\n         * v2 = v1 * 1 / (1 + c * dt)\n         * 
\n */\n matrix.scaleVec2(v, 1.0 / (1.0 + h * body.m_linearDamping), v);\n w *= 1.0 / (1.0 + h * body.m_angularDamping);\n }\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initConstraint(step);\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initVelocityConstraint(step);\n }\n\n if (step.warmStarting) {\n // Warm start.\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.warmStartConstraint(step);\n }\n }\n\n for (let i = 0; i < this.m_joints.length; ++i) {\n const joint = this.m_joints[i];\n joint.initVelocityConstraints(step);\n }\n\n // Solve velocity constraints\n for (let i = 0; i < step.velocityIterations; ++i) {\n for (let j = 0; j < this.m_joints.length; ++j) {\n const joint = this.m_joints[j];\n joint.solveVelocityConstraints(step);\n }\n\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n contact.solveVelocityConstraint(step);\n }\n }\n\n // Store impulses for warm starting\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.storeConstraintImpulses(step);\n }\n\n // Integrate positions\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.c_position.c);\n let a = body.c_position.a;\n matrix.copyVec2(v, body.c_velocity.v);\n let w = body.c_velocity.w;\n\n // Check for large velocities\n matrix.scaleVec2(translation, h, v);\n const translationLengthSqr = matrix.lengthSqrVec2(translation);\n if (translationLengthSqr > Settings.maxTranslationSquared) {\n const ratio = Settings.maxTranslation / math_sqrt(translationLengthSqr);\n matrix.mulVec2(v, ratio);\n }\n\n const rotation = h * w;\n if (rotation * rotation > Settings.maxRotationSquared) {\n const ratio = Settings.maxRotation / math_abs(rotation);\n w *= ratio;\n }\n\n // Integrate\n matrix.plusScaleVec2(c, h, v);\n a += h * w;\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n }\n\n // Solve position constraints\n let positionSolved = false;\n for (let i = 0; i < step.positionIterations; ++i) {\n let minSeparation = 0.0;\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n const separation = contact.solvePositionConstraint(step);\n minSeparation = math_min(minSeparation, separation);\n }\n // We can't expect minSpeparation >= -Settings.linearSlop because we don't\n // push the separation above -Settings.linearSlop.\n const contactsOkay = minSeparation >= -3.0 * Settings.linearSlop;\n\n let jointsOkay = true;\n for (let j = 0; j < this.m_joints.length; ++j) {\n const joint = this.m_joints[j];\n const jointOkay = joint.solvePositionConstraints(step);\n jointsOkay = jointsOkay && jointOkay;\n }\n\n if (contactsOkay && jointsOkay) {\n // Exit early if the position errors are small.\n positionSolved = true;\n break;\n }\n }\n\n // Copy state buffers back to the bodies\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(body.m_sweep.c, body.c_position.c);\n body.m_sweep.a = body.c_position.a;\n matrix.copyVec2(body.m_linearVelocity, body.c_velocity.v);\n body.m_angularVelocity = body.c_velocity.w;\n body.synchronizeTransform();\n }\n\n this.postSolveIsland();\n\n if (allowSleep) {\n let minSleepTime = Infinity;\n\n const linTolSqr = Settings.linearSleepToleranceSqr;\n const angTolSqr = Settings.angularSleepToleranceSqr;\n\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n if (body.isStatic()) {\n continue;\n }\n\n if ((body.m_autoSleepFlag == false)\n || (body.m_angularVelocity * body.m_angularVelocity > angTolSqr)\n || (matrix.lengthSqrVec2(body.m_linearVelocity) > linTolSqr)) {\n body.m_sleepTime = 0.0;\n minSleepTime = 0.0;\n } else {\n body.m_sleepTime += h;\n minSleepTime = math_min(minSleepTime, body.m_sleepTime);\n }\n }\n\n if (minSleepTime >= Settings.timeToSleep && positionSolved) {\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n body.setAwake(false);\n }\n }\n }\n }\n\n /**\n * Find TOI contacts and solve them.\n */\n solveWorldTOI(step: TimeStep): void {\n const world = this.m_world;\n\n if (world.m_stepComplete) {\n for (let b = world.m_bodyList; b; b = b.m_next) {\n b.m_islandFlag = false;\n b.m_sweep.alpha0 = 0.0;\n }\n\n for (let c = world.m_contactList; c; c = c.m_next) {\n // Invalidate TOI\n c.m_toiFlag = false;\n c.m_islandFlag = false;\n c.m_toiCount = 0;\n c.m_toi = 1.0;\n }\n }\n\n // Find TOI events and solve them.\n while (true) {\n // Find the first TOI.\n let minContact: Contact | null = null;\n let minAlpha = 1.0;\n\n for (let c = world.m_contactList; c; c = c.m_next) {\n // Is this contact disabled?\n if (c.isEnabled() == false) {\n continue;\n }\n\n // Prevent excessive sub-stepping.\n if (c.m_toiCount > Settings.maxSubSteps) {\n continue;\n }\n\n let alpha = 1.0;\n if (c.m_toiFlag) {\n // This contact has a valid cached TOI.\n alpha = c.m_toi;\n } else {\n const fA = c.getFixtureA();\n const fB = c.getFixtureB();\n\n // Is there a sensor?\n if (fA.isSensor() || fB.isSensor()) {\n continue;\n }\n\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n if (_ASSERT) console.assert(bA.isDynamic() || bB.isDynamic());\n\n const activeA = bA.isAwake() && !bA.isStatic();\n const activeB = bB.isAwake() && !bB.isStatic();\n\n // Is at least one body active (awake and dynamic or kinematic)?\n if (activeA == false && activeB == false) {\n continue;\n }\n\n const collideA = bA.isBullet() || !bA.isDynamic();\n const collideB = bB.isBullet() || !bB.isDynamic();\n\n // Are these two non-bullet dynamic bodies?\n if (collideA == false && collideB == false) {\n continue;\n }\n\n // Compute the TOI for this contact.\n // Put the sweeps onto the same time interval.\n let alpha0 = bA.m_sweep.alpha0;\n\n if (bA.m_sweep.alpha0 < bB.m_sweep.alpha0) {\n alpha0 = bB.m_sweep.alpha0;\n bA.m_sweep.advance(alpha0);\n } else if (bB.m_sweep.alpha0 < bA.m_sweep.alpha0) {\n alpha0 = bA.m_sweep.alpha0;\n bB.m_sweep.advance(alpha0);\n }\n\n if (_ASSERT) console.assert(alpha0 < 1.0);\n\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n\n const sweepA = bA.m_sweep;\n const sweepB = bB.m_sweep;\n\n // Compute the time of impact in interval [0, minTOI]\n input.proxyA.set(fA.getShape(), indexA);\n input.proxyB.set(fB.getShape(), indexB);\n input.sweepA.set(bA.m_sweep);\n input.sweepB.set(bB.m_sweep);\n input.tMax = 1.0;\n\n TimeOfImpact(output, input);\n\n // Beta is the fraction of the remaining portion of the [time?].\n const beta = output.t;\n if (output.state == TOIOutputState.e_touching) {\n alpha = math_min(alpha0 + (1.0 - alpha0) * beta, 1.0);\n } else {\n alpha = 1.0;\n }\n\n c.m_toi = alpha;\n c.m_toiFlag = true;\n }\n\n if (alpha < minAlpha) {\n // This is the minimum TOI found so far.\n minContact = c;\n minAlpha = alpha;\n }\n }\n\n if (minContact == null || 1.0 - 10.0 * EPSILON < minAlpha) {\n // No more TOI events. Done!\n world.m_stepComplete = true;\n break;\n }\n\n // Advance the bodies to the TOI.\n const fA = minContact.getFixtureA();\n const fB = minContact.getFixtureB();\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n backup1.set(bA.m_sweep);\n backup2.set(bB.m_sweep);\n\n bA.advance(minAlpha);\n bB.advance(minAlpha);\n\n // The TOI contact likely has some new contact points.\n minContact.update(world);\n minContact.m_toiFlag = false;\n ++minContact.m_toiCount;\n\n // Is the contact solid?\n if (minContact.isEnabled() == false || minContact.isTouching() == false) {\n // Restore the sweeps.\n minContact.setEnabled(false);\n bA.m_sweep.set(backup1);\n bB.m_sweep.set(backup2);\n bA.synchronizeTransform();\n bB.synchronizeTransform();\n continue;\n }\n\n bA.setAwake(true);\n bB.setAwake(true);\n\n // Build the island\n this.clear();\n this.addBody(bA);\n this.addBody(bB);\n this.addContact(minContact);\n\n bA.m_islandFlag = true;\n bB.m_islandFlag = true;\n minContact.m_islandFlag = true;\n\n // Get contacts on bodyA and bodyB.\n const bodies = [ bA, bB ];\n for (let i = 0; i < bodies.length; ++i) {\n const body = bodies[i];\n if (body.isDynamic()) {\n for (let ce = body.m_contactList; ce; ce = ce.next) {\n // if (this.m_bodyCount == this.m_bodyCapacity) { break; }\n // if (this.m_contactCount == this.m_contactCapacity) { break; }\n\n const contact = ce.contact;\n\n // Has this contact already been added to the island?\n if (contact.m_islandFlag) {\n continue;\n }\n\n // Only add if either is static, kinematic or bullet.\n const other = ce.other;\n if (other.isDynamic() && !body.isBullet() && !other.isBullet()) {\n continue;\n }\n\n // Skip sensors.\n const sensorA = contact.m_fixtureA.m_isSensor;\n const sensorB = contact.m_fixtureB.m_isSensor;\n if (sensorA || sensorB) {\n continue;\n }\n\n // Tentatively advance the body to the TOI.\n backup.set(other.m_sweep);\n if (other.m_islandFlag == false) {\n other.advance(minAlpha);\n }\n\n // Update the contact points\n contact.update(world);\n\n // Was the contact disabled by the user?\n // Are there contact points?\n if (contact.isEnabled() == false || contact.isTouching() == false) {\n other.m_sweep.set(backup);\n other.synchronizeTransform();\n continue;\n }\n\n // Add the contact to the island\n contact.m_islandFlag = true;\n this.addContact(contact);\n\n // Has the other body already been added to the island?\n if (other.m_islandFlag) {\n continue;\n }\n\n // Add the other body to the island.\n other.m_islandFlag = true;\n\n if (!other.isStatic()) {\n other.setAwake(true);\n }\n\n this.addBody(other);\n }\n }\n }\n\n s_subStep.reset((1.0 - minAlpha) * step.dt);\n s_subStep.dtRatio = 1.0;\n s_subStep.positionIterations = 20;\n s_subStep.velocityIterations = step.velocityIterations;\n s_subStep.warmStarting = false;\n\n this.solveIslandTOI(s_subStep, bA, bB);\n\n // Reset island flags and synchronize broad-phase proxies.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n body.m_islandFlag = false;\n\n if (!body.isDynamic()) {\n continue;\n }\n\n body.synchronizeFixtures();\n\n // Invalidate all contact TOIs on this displaced body.\n for (let ce = body.m_contactList; ce; ce = ce.next) {\n ce.contact.m_toiFlag = false;\n ce.contact.m_islandFlag = false;\n }\n }\n\n // Commit fixture proxy movements to the broad-phase so that new contacts\n // are created.\n // Also, some contacts can be destroyed.\n world.findNewContacts();\n\n if (world.m_subStepping) {\n world.m_stepComplete = false;\n break;\n }\n }\n }\n\n solveIslandTOI(subStep: TimeStep, toiA: Body, toiB: Body): void {\n\n // Initialize the body state.\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n matrix.copyVec2(body.c_position.c, body.m_sweep.c);\n body.c_position.a = body.m_sweep.a;\n matrix.copyVec2(body.c_velocity.v, body.m_linearVelocity);\n body.c_velocity.w = body.m_angularVelocity;\n }\n\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initConstraint(subStep);\n }\n\n // Solve position constraints.\n for (let i = 0; i < subStep.positionIterations; ++i) {\n let minSeparation = 0.0;\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n const separation = contact.solvePositionConstraintTOI(subStep, toiA, toiB);\n minSeparation = math_min(minSeparation, separation);\n }\n // We can't expect minSpeparation >= -Settings.linearSlop because we don't\n // push the separation above -Settings.linearSlop.\n const contactsOkay = minSeparation >= -1.5 * Settings.linearSlop;\n if (contactsOkay) {\n break;\n }\n }\n\n if (false) {\n // Is the new position really safe?\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const c = this.m_contacts[i];\n const fA = c.getFixtureA();\n const fB = c.getFixtureB();\n\n const bA = fA.getBody();\n const bB = fB.getBody();\n\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n\n const input = new DistanceInput();\n input.proxyA.set(fA.getShape(), indexA);\n input.proxyB.set(fB.getShape(), indexB);\n input.transformA.set(bA.getTransform());\n input.transformB.set(bB.getTransform());\n input.useRadii = false;\n\n const output = new DistanceOutput();\n const cache = new SimplexCache();\n Distance(output, cache, input);\n\n if (output.distance == 0 || cache.count == 3) {\n cache.count += 0;\n }\n }\n }\n\n // Leap of faith to new safe state.\n matrix.copyVec2(toiA.m_sweep.c0, toiA.c_position.c);\n toiA.m_sweep.a0 = toiA.c_position.a;\n matrix.copyVec2(toiB.m_sweep.c0, toiB.c_position.c);\n toiB.m_sweep.a0 = toiB.c_position.a;\n\n // No warm starting is needed for TOI events because warm\n // starting impulses were applied in the discrete solver.\n for (let i = 0; i < this.m_contacts.length; ++i) {\n const contact = this.m_contacts[i];\n contact.initVelocityConstraint(subStep);\n }\n\n // Solve velocity constraints.\n for (let i = 0; i < subStep.velocityIterations; ++i) {\n for (let j = 0; j < this.m_contacts.length; ++j) {\n const contact = this.m_contacts[j];\n contact.solveVelocityConstraint(subStep);\n }\n }\n\n // Don't store the TOI contact forces for warm starting\n // because they can be quite large.\n\n const h = subStep.dt;\n\n // Integrate positions\n for (let i = 0; i < this.m_bodies.length; ++i) {\n const body = this.m_bodies[i];\n\n matrix.copyVec2(c, body.c_position.c);\n let a = body.c_position.a;\n matrix.copyVec2(v, body.c_velocity.v);\n let w = body.c_velocity.w;\n\n // Check for large velocities\n matrix.scaleVec2(translation, h, v);\n const translationLengthSqr = matrix.lengthSqrVec2(translation);\n if (translationLengthSqr > Settings.maxTranslationSquared) {\n const ratio = Settings.maxTranslation / math_sqrt(translationLengthSqr);\n matrix.mulVec2(v, ratio);\n }\n\n const rotation = h * w;\n if (rotation * rotation > Settings.maxRotationSquared) {\n const ratio = Settings.maxRotation / math_abs(rotation);\n w *= ratio;\n }\n\n // Integrate\n matrix.plusScaleVec2(c, h, v);\n a += h * w;\n\n matrix.copyVec2(body.c_position.c, c);\n body.c_position.a = a;\n matrix.copyVec2(body.c_velocity.v, v);\n body.c_velocity.w = w;\n\n // Sync bodies\n matrix.copyVec2(body.m_sweep.c, c);\n body.m_sweep.a = a;\n matrix.copyVec2(body.m_linearVelocity, v);\n body.m_angularVelocity = w;\n body.synchronizeTransform();\n }\n\n this.postSolveIsland();\n }\n\n /** @internal */\n postSolveIsland(): void {\n for (let c = 0; c < this.m_contacts.length; ++c) {\n const contact = this.m_contacts[c];\n this.m_world.postSolve(contact, contact.m_impulse);\n }\n }\n}\n\n// @ts-ignore\nSolver.TimeStep = TimeStep;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A 2-by-2 matrix. Stored in column-major order.\n */\nexport class Mat22 {\n ex: Vec2;\n ey: Vec2;\n\n constructor(a: number, b: number, c: number, d: number);\n constructor(a: { x: number; y: number }, b: { x: number; y: number });\n constructor();\n constructor(a?, b?, c?, d?) {\n if (typeof a === \"object\" && a !== null) {\n this.ex = Vec2.clone(a);\n this.ey = Vec2.clone(b);\n } else if (typeof a === \"number\") {\n this.ex = Vec2.neo(a, c);\n this.ey = Vec2.neo(b, d);\n } else {\n this.ex = Vec2.zero();\n this.ey = Vec2.zero();\n }\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec2.isValid(obj.ex) && Vec2.isValid(obj.ey);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Mat22.isValid(o), \"Invalid Mat22!\", o);\n }\n\n set(a: Mat22): void;\n set(a: Vec2Value, b: Vec2Value): void;\n set(a: number, b: number, c: number, d: number): void;\n set(a, b?, c?, d?): void {\n if (typeof a === \"number\" && typeof b === \"number\" && typeof c === \"number\"\n && typeof d === \"number\") {\n this.ex.setNum(a, c);\n this.ey.setNum(b, d);\n\n } else if (typeof a === \"object\" && typeof b === \"object\") {\n this.ex.setVec2(a);\n this.ey.setVec2(b);\n\n } else if (typeof a === \"object\") {\n if (_ASSERT) Mat22.assert(a);\n this.ex.setVec2(a.ex);\n this.ey.setVec2(a.ey);\n\n } else {\n if (_ASSERT) console.assert(false);\n }\n }\n\n setIdentity(): void {\n this.ex.x = 1.0;\n this.ey.x = 0.0;\n this.ex.y = 0.0;\n this.ey.y = 1.0;\n }\n\n setZero(): void {\n this.ex.x = 0.0;\n this.ey.x = 0.0;\n this.ex.y = 0.0;\n this.ey.y = 0.0;\n }\n\n getInverse(): Mat22 {\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const imx = new Mat22();\n imx.ex.x = det * d;\n imx.ey.x = -det * b;\n imx.ex.y = -det * c;\n imx.ey.y = det * a;\n return imx;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases.\n */\n solve(v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const w = Vec2.zero();\n w.x = det * (d * v.x - b * v.y);\n w.y = det * (a * v.y - c * v.x);\n return w;\n }\n\n /**\n * Multiply a matrix times a vector. If a rotation matrix is provided, then this\n * transforms the vector from one frame to another.\n */\n static mul(mx: Mat22, my: Mat22): Mat22;\n static mul(mx: Mat22, v: Vec2Value): Vec2;\n static mul(mx, v) {\n if (v && \"x\" in v && \"y\" in v) {\n if (_ASSERT) Vec2.assert(v);\n const x = mx.ex.x * v.x + mx.ey.x * v.y;\n const y = mx.ex.y * v.x + mx.ey.y * v.y;\n return Vec2.neo(x, y);\n\n } else if (v && \"ex\" in v && \"ey\" in v) { // Mat22\n if (_ASSERT) Mat22.assert(v);\n // return new Mat22(Vec2.mul(mx, v.ex), Vec2.mul(mx, v.ey));\n const a = mx.ex.x * v.ex.x + mx.ey.x * v.ex.y;\n const b = mx.ex.x * v.ey.x + mx.ey.x * v.ey.y;\n const c = mx.ex.y * v.ex.x + mx.ey.y * v.ex.y;\n const d = mx.ex.y * v.ey.x + mx.ey.y * v.ey.y;\n return new Mat22(a, b, c, d);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulVec2(mx: Mat22, v: Vec2Value): Vec2 {\n if (_ASSERT) Vec2.assert(v);\n const x = mx.ex.x * v.x + mx.ey.x * v.y;\n const y = mx.ex.y * v.x + mx.ey.y * v.y;\n return Vec2.neo(x, y);\n }\n\n static mulMat22(mx: Mat22, v: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(v);\n // return new Mat22(Vec2.mul(mx, v.ex), Vec2.mul(mx, v.ey));\n const a = mx.ex.x * v.ex.x + mx.ey.x * v.ex.y;\n const b = mx.ex.x * v.ey.x + mx.ey.x * v.ey.y;\n const c = mx.ex.y * v.ex.x + mx.ey.y * v.ex.y;\n const d = mx.ex.y * v.ey.x + mx.ey.y * v.ey.y;\n return new Mat22(a, b, c, d);\n }\n\n /**\n * Multiply a matrix transpose times a vector. If a rotation matrix is provided,\n * then this transforms the vector from one frame to another (inverse\n * transform).\n */\n static mulT(mx: Mat22, my: Mat22): Mat22;\n static mulT(mx: Mat22, v: Vec2Value): Vec2;\n static mulT(mx, v) {\n if (v && \"x\" in v && \"y\" in v) { // Vec2\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(Vec2.dot(v, mx.ex), Vec2.dot(v, mx.ey));\n\n } else if (v && \"ex\" in v && \"ey\" in v) { // Mat22\n if (_ASSERT) Mat22.assert(v);\n const c1 = Vec2.neo(Vec2.dot(mx.ex, v.ex), Vec2.dot(mx.ey, v.ex));\n const c2 = Vec2.neo(Vec2.dot(mx.ex, v.ey), Vec2.dot(mx.ey, v.ey));\n return new Mat22(c1, c2);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulTVec2(mx: Mat22, v: Vec2Value): Vec2 {\n if (_ASSERT) Mat22.assert(mx);\n if (_ASSERT) Vec2.assert(v);\n return Vec2.neo(Vec2.dot(v, mx.ex), Vec2.dot(v, mx.ey));\n }\n\n static mulTMat22(mx: Mat22, v: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx);\n if (_ASSERT) Mat22.assert(v);\n const c1 = Vec2.neo(Vec2.dot(mx.ex, v.ex), Vec2.dot(mx.ey, v.ex));\n const c2 = Vec2.neo(Vec2.dot(mx.ex, v.ey), Vec2.dot(mx.ey, v.ey));\n return new Mat22(c1, c2);\n }\n\n static abs(mx: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx);\n return new Mat22(Vec2.abs(mx.ex), Vec2.abs(mx.ey));\n }\n\n static add(mx1: Mat22, mx2: Mat22): Mat22 {\n if (_ASSERT) Mat22.assert(mx1);\n if (_ASSERT) Mat22.assert(mx2);\n return new Mat22(Vec2.add(mx1.ex, mx2.ex), Vec2.add(mx1.ey, mx2.ey));\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { Vec2Value } from \"../common/Vec2\";\nimport { TransformValue } from \"../common/Transform\";\nimport { EPSILON } from \"../common/Math\";\n\n\n/** @internal */ const math_sqrt = Math.sqrt;\n\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const cA = matrix.vec2(0, 0);\n/** @internal */ const cB = matrix.vec2(0, 0);\n/** @internal */ const dist = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const clipPoint = matrix.vec2(0, 0);\n\nexport enum ManifoldType {\n e_unset = -1,\n e_circles = 0,\n e_faceA = 1,\n e_faceB = 2\n}\n\nexport enum ContactFeatureType {\n e_unset = -1,\n e_vertex = 0,\n e_face = 1\n}\n\n/**\n * This is used for determining the state of contact points.\n */\n export enum PointState {\n /** Point does not exist */\n nullState = 0,\n /** Point was added in the update */\n addState = 1,\n /** Point persisted across the update */\n persistState = 2,\n /** Point was removed in the update */\n removeState = 3\n}\n\n/**\n * Used for computing contact manifolds.\n */\n export class ClipVertex {\n v = matrix.vec2(0, 0);\n id: ContactID = new ContactID();\n\n set(o: ClipVertex): void {\n matrix.copyVec2(this.v, o.v);\n this.id.set(o.id);\n }\n recycle() {\n matrix.zeroVec2(this.v);\n this.id.recycle();\n }\n}\n\n/**\n * A manifold for two touching convex shapes. Manifolds are created in `evaluate`\n * method of Contact subclasses.\n *\n * Supported manifold types are e_faceA or e_faceB for clip point versus plane\n * with radius and e_circles point versus point with radius.\n *\n * We store contacts in this way so that position correction can account for\n * movement, which is critical for continuous physics. All contact scenarios\n * must be expressed in one of these types. This structure is stored across time\n * steps, so we keep it small.\n */\nexport class Manifold {\n type: ManifoldType;\n\n /**\n * Usage depends on manifold type:\n * - circles: not used\n * - faceA: the normal on polygonA\n * - faceB: the normal on polygonB\n */\n localNormal = matrix.vec2(0, 0);\n\n /**\n * Usage depends on manifold type:\n * - circles: the local center of circleA\n * - faceA: the center of faceA\n * - faceB: the center of faceB\n */\n localPoint = matrix.vec2(0, 0);\n\n /** The points of contact */\n points: ManifoldPoint[] = [ new ManifoldPoint(), new ManifoldPoint() ];\n\n /** The number of manifold points */\n pointCount: number = 0;\n\n set(that: Manifold): void {\n this.type = that.type;\n matrix.copyVec2(this.localNormal, that.localNormal);\n matrix.copyVec2(this.localPoint, that.localPoint);\n this.pointCount = that.pointCount;\n this.points[0].set(that.points[0]);\n this.points[1].set(that.points[1]);\n }\n\n recycle(): void {\n this.type = ManifoldType.e_unset;\n matrix.zeroVec2(this.localNormal);\n matrix.zeroVec2(this.localPoint);\n this.pointCount = 0;\n this.points[0].recycle();\n this.points[1].recycle();\n }\n\n /**\n * Evaluate the manifold with supplied transforms. This assumes modest motion\n * from the original state. This does not change the point count, impulses, etc.\n * The radii must come from the shapes that generated the manifold.\n */\n getWorldManifold(wm: WorldManifold | null, xfA: TransformValue, radiusA: number, xfB: TransformValue, radiusB: number): WorldManifold {\n if (this.pointCount == 0) {\n return wm;\n }\n\n wm = wm || new WorldManifold();\n\n wm.pointCount = this.pointCount;\n\n const normal = wm.normal;\n const points = wm.points;\n const separations = wm.separations;\n\n switch (this.type) {\n case ManifoldType.e_circles: {\n matrix.setVec2(normal, 1.0, 0.0);\n const manifoldPoint = this.points[0];\n matrix.transformVec2(pointA, xfA, this.localPoint);\n matrix.transformVec2(pointB, xfB, manifoldPoint.localPoint);\n matrix.subVec2(dist, pointB, pointA);\n const lengthSqr = matrix.lengthSqrVec2(dist);\n if (lengthSqr > EPSILON * EPSILON) {\n const length = math_sqrt(lengthSqr);\n matrix.scaleVec2(normal, 1 / length, dist);\n }\n matrix.combine2Vec2(cA, 1, pointA, radiusA, normal);\n matrix.combine2Vec2(cB, 1, pointB, -radiusB, normal);\n matrix.combine2Vec2(points[0], 0.5, cA, 0.5, cB);\n separations[0] = matrix.dotVec2(matrix.subVec2(temp, cB, cA), normal);\n break;\n }\n\n case ManifoldType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.localNormal);\n matrix.transformVec2(planePoint, xfA, this.localPoint);\n\n for (let i = 0; i < this.pointCount; ++i) {\n const manifoldPoint = this.points[i];\n matrix.transformVec2(clipPoint, xfB, manifoldPoint.localPoint);\n matrix.combine2Vec2(cA, 1, clipPoint, radiusA - matrix.dotVec2(matrix.subVec2(temp, clipPoint, planePoint), normal), normal);\n matrix.combine2Vec2(cB, 1, clipPoint, -radiusB, normal);\n matrix.combine2Vec2(points[i], 0.5, cA, 0.5, cB);\n separations[i] = matrix.dotVec2(matrix.subVec2(temp, cB, cA), normal);\n }\n break;\n }\n\n case ManifoldType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.localNormal);\n matrix.transformVec2(planePoint, xfB, this.localPoint);\n\n for (let i = 0; i < this.pointCount; ++i) {\n const manifoldPoint = this.points[i];\n matrix.transformVec2(clipPoint, xfA, manifoldPoint.localPoint);\n matrix.combine2Vec2(cB, 1, clipPoint, radiusB - matrix.dotVec2(matrix.subVec2(temp, clipPoint, planePoint), normal), normal);\n matrix.combine2Vec2(cA, 1, clipPoint, -radiusA, normal);\n matrix.combine2Vec2(points[i], 0.5, cA, 0.5, cB);\n separations[i] = matrix.dotVec2(matrix.subVec2(temp, cA, cB), normal);\n }\n // Ensure normal points from A to B.\n matrix.negVec2(normal);\n break;\n }\n }\n\n return wm;\n }\n\n static clipSegmentToLine = clipSegmentToLine;\n static ClipVertex = ClipVertex;\n static getPointStates = getPointStates;\n static PointState = PointState;\n}\n\n/**\n * A manifold point is a contact point belonging to a contact manifold. It holds\n * details related to the geometry and dynamics of the contact points.\n *\n * This structure is stored across time steps, so we keep it small.\n *\n * Note: impulses are used for internal caching and may not provide reliable\n * contact forces, especially for high speed collisions.\n */\nexport class ManifoldPoint {\n /**\n * Usage depends on manifold type:\n * - circles: the local center of circleB\n * - faceA: the local center of circleB or the clip point of polygonB\n * - faceB: the clip point of polygonA\n */\n localPoint = matrix.vec2(0, 0);\n /**\n * The non-penetration impulse\n */\n normalImpulse = 0;\n /**\n * The friction impulse\n */\n tangentImpulse = 0;\n /**\n * Uniquely identifies a contact point between two shapes to facilitate warm starting\n */\n readonly id = new ContactID();\n\n set(that: ManifoldPoint): void {\n matrix.copyVec2(this.localPoint, that.localPoint);\n this.normalImpulse = that.normalImpulse;\n this.tangentImpulse = that.tangentImpulse;\n this.id.set(that.id);\n }\n\n recycle(): void {\n matrix.zeroVec2(this.localPoint);\n this.normalImpulse = 0;\n this.tangentImpulse = 0;\n this.id.recycle();\n }\n}\n\n/**\n * Contact ids to facilitate warm starting.\n * \n * ContactFeature: The features that intersect to form the contact point.\n */\nexport class ContactID {\n\n /**\n * Used to quickly compare contact ids.\n */\n key = -1;\n\n /** ContactFeature index on shapeA */\n indexA = -1;\n\n /** ContactFeature index on shapeB */\n indexB = -1;\n\n /** ContactFeature type on shapeA */\n typeA = ContactFeatureType.e_unset;\n\n /** ContactFeature type on shapeB */\n typeB = ContactFeatureType.e_unset;\n\n setFeatures(indexA: number, typeA: ContactFeatureType, indexB: number, typeB: ContactFeatureType): void {\n this.indexA = indexA;\n this.indexB = indexB;\n this.typeA = typeA;\n this.typeB = typeB;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n set(that: ContactID): void {\n this.indexA = that.indexA;\n this.indexB = that.indexB;\n this.typeA = that.typeA;\n this.typeB = that.typeB;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n swapFeatures(): void {\n const indexA = this.indexA;\n const indexB = this.indexB;\n const typeA = this.typeA;\n const typeB = this.typeB;\n this.indexA = indexB;\n this.indexB = indexA;\n this.typeA = typeB;\n this.typeB = typeA;\n this.key = this.indexA + this.indexB * 4 + this.typeA * 16 + this.typeB * 64;\n }\n\n recycle(): void {\n this.indexA = 0;\n this.indexB = 0;\n this.typeA = ContactFeatureType.e_unset;\n this.typeB = ContactFeatureType.e_unset;\n this.key = -1;\n }\n}\n\n/**\n * This is used to compute the current state of a contact manifold.\n */\nexport class WorldManifold {\n /** World vector pointing from A to B */\n normal = matrix.vec2(0, 0);\n\n /** World contact point (point of intersection) */\n points = [matrix.vec2(0, 0), matrix.vec2(0, 0)]; // [maxManifoldPoints]\n\n /** A negative value indicates overlap, in meters */\n separations = [0, 0]; // [maxManifoldPoints]\n\n /** The number of manifold points */\n pointCount = 0;\n\n recycle() {\n matrix.zeroVec2(this.normal);\n matrix.zeroVec2(this.points[0]);\n matrix.zeroVec2(this.points[1]);\n this.separations[0] = 0;\n this.separations[1] = 0;\n this.pointCount = 0;\n }\n}\n\n/**\n * Compute the point states given two manifolds. The states pertain to the\n * transition from manifold1 to manifold2. So state1 is either persist or remove\n * while state2 is either add or persist.\n */\nexport function getPointStates(\n state1: PointState[],\n state2: PointState[],\n manifold1: Manifold,\n manifold2: Manifold\n): void {\n // state1, state2: PointState[Settings.maxManifoldPoints]\n\n // for (var i = 0; i < Settings.maxManifoldPoints; ++i) {\n // state1[i] = PointState.nullState;\n // state2[i] = PointState.nullState;\n // }\n\n // Detect persists and removes.\n for (let i = 0; i < manifold1.pointCount; ++i) {\n const id = manifold1.points[i].id;\n\n state1[i] = PointState.removeState;\n\n for (let j = 0; j < manifold2.pointCount; ++j) {\n if (manifold2.points[j].id.key === id.key) {\n state1[i] = PointState.persistState;\n break;\n }\n }\n }\n\n // Detect persists and adds.\n for (let i = 0; i < manifold2.pointCount; ++i) {\n const id = manifold2.points[i].id;\n\n state2[i] = PointState.addState;\n\n for (let j = 0; j < manifold1.pointCount; ++j) {\n if (manifold1.points[j].id.key === id.key) {\n state2[i] = PointState.persistState;\n break;\n }\n }\n }\n}\n\n/**\n * Clipping for contact manifolds. Sutherland-Hodgman clipping.\n */\nexport function clipSegmentToLine(\n vOut: ClipVertex[],\n vIn: ClipVertex[],\n normal: Vec2Value,\n offset: number,\n vertexIndexA: number\n): number {\n // Start with no output points\n let numOut = 0;\n\n // Calculate the distance of end points to the line\n const distance0 = matrix.dotVec2(normal, vIn[0].v) - offset;\n const distance1 = matrix.dotVec2(normal, vIn[1].v) - offset;\n\n // If the points are behind the plane\n if (distance0 <= 0.0)\n vOut[numOut++].set(vIn[0]);\n if (distance1 <= 0.0)\n vOut[numOut++].set(vIn[1]);\n\n // If the points are on different sides of the plane\n if (distance0 * distance1 < 0.0) {\n // Find intersection point of edge and plane\n const interp = distance0 / (distance0 - distance1);\n matrix.combine2Vec2(vOut[numOut].v, 1 - interp, vIn[0].v, interp, vIn[1].v);\n\n // VertexA is hitting edgeB.\n vOut[numOut].id.setFeatures(vertexIndexA, ContactFeatureType.e_vertex, vIn[0].id.indexB, ContactFeatureType.e_face);\n ++numOut;\n }\n\n return numOut;\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../common/Matrix\";\nimport { ShapeType } from \"../collision/Shape\";\nimport { clamp } from \"../common/Math\";\nimport { TransformValue } from \"../common/Transform\";\nimport { Mat22 } from \"../common/Mat22\";\nimport { SettingsInternal as Settings } from \"../Settings\";\nimport { Manifold, ManifoldType, WorldManifold } from \"../collision/Manifold\";\nimport { testOverlap } from \"../collision/Distance\";\nimport { Fixture } from \"./Fixture\";\nimport { Body } from \"./Body\";\nimport { ContactImpulse, TimeStep } from \"./Solver\";\nimport { Pool } from \"../util/Pool\";\nimport { getTransform } from \"./Position\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n// Solver debugging is normally disabled because the block solver sometimes has to deal with a poorly conditioned effective mass matrix.\n/** @internal */ const DEBUG_SOLVER = false;\n\n/** @internal */ const contactPool = new Pool({\n create() {\n return new Contact();\n },\n release(contact: Contact) {\n contact.recycle();\n }\n});\n\n/** @internal */ const oldManifold = new Manifold();\n\n/** @internal */ const worldManifold = new WorldManifold();\n\n/**\n * A contact edge is used to connect bodies and contacts together in a contact\n * graph where each body is a node and each contact is an edge. A contact edge\n * belongs to a doubly linked list maintained in each attached body. Each\n * contact has two contact nodes, one for each attached body.\n */\nexport class ContactEdge {\n contact: Contact;\n prev: ContactEdge | null = null;\n next: ContactEdge | null = null;\n other: Body | null = null;\n constructor(contact: Contact) {\n this.contact = contact;\n }\n\n /** @internal */\n recycle() {\n this.prev = null;\n this.next = null;\n this.other = null;\n }\n}\n\nexport type EvaluateFunction = (\n manifold: Manifold,\n xfA: TransformValue,\n fixtureA: Fixture,\n indexA: number,\n xfB: TransformValue,\n fixtureB: Fixture,\n indexB: number\n) => void;\n\n/**\n * Friction mixing law. The idea is to allow either fixture to drive the\n * friction to zero. For example, anything slides on ice.\n */\nexport function mixFriction(friction1: number, friction2: number): number {\n return math_sqrt(friction1 * friction2);\n}\n\n/**\n * Restitution mixing law. The idea is allow for anything to bounce off an\n * inelastic surface. For example, a superball bounces on anything.\n */\nexport function mixRestitution(restitution1: number, restitution2: number): number {\n return restitution1 > restitution2 ? restitution1 : restitution2;\n}\n\n// TODO: move this to Settings?\n/** @internal */ const s_registers = [];\n\n// TODO: merge with ManifoldPoint?\nexport class VelocityConstraintPoint {\n rA = matrix.vec2(0, 0);\n rB = matrix.vec2(0, 0);\n normalImpulse = 0;\n tangentImpulse = 0;\n normalMass = 0;\n tangentMass = 0;\n velocityBias = 0;\n\n recycle() {\n matrix.zeroVec2(this.rA);\n matrix.zeroVec2(this.rB);\n this.normalImpulse = 0;\n this.tangentImpulse = 0;\n this.normalMass = 0;\n this.tangentMass = 0;\n this.velocityBias = 0;\n }\n}\n\n/** @internal */ const cA = matrix.vec2(0, 0);\n/** @internal */ const vA = matrix.vec2(0, 0);\n/** @internal */ const cB = matrix.vec2(0, 0);\n/** @internal */ const vB = matrix.vec2(0, 0);\n/** @internal */ const tangent = matrix.vec2(0, 0);\n/** @internal */ const xfA = matrix.transform(0, 0, 0);\n/** @internal */ const xfB = matrix.transform(0, 0, 0);\n/** @internal */ const pointA = matrix.vec2(0, 0);\n/** @internal */ const pointB = matrix.vec2(0, 0);\n/** @internal */ const clipPoint = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const rA = matrix.vec2(0, 0);\n/** @internal */ const rB = matrix.vec2(0, 0);\n/** @internal */ const P = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const point = matrix.vec2(0, 0);\n/** @internal */ const dv = matrix.vec2(0, 0);\n/** @internal */ const dv1 = matrix.vec2(0, 0);\n/** @internal */ const dv2 = matrix.vec2(0, 0);\n/** @internal */ const b = matrix.vec2(0, 0);\n/** @internal */ const a = matrix.vec2(0, 0);\n/** @internal */ const x = matrix.vec2(0, 0);\n/** @internal */ const d = matrix.vec2(0, 0);\n/** @internal */ const P1 = matrix.vec2(0, 0);\n/** @internal */ const P2 = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n\n/**\n * The class manages contact between two shapes. A contact exists for each\n * overlapping AABB in the broad-phase (except if filtered). Therefore a contact\n * object may exist that has no contact points.\n */\nexport class Contact {\n // Nodes for connecting bodies.\n /** @internal */ m_nodeA = new ContactEdge(this);\n /** @internal */ m_nodeB = new ContactEdge(this);\n /** @internal */ m_fixtureA: Fixture | null = null;\n /** @internal */ m_fixtureB: Fixture | null = null;\n /** @internal */ m_indexA = -1;\n /** @internal */ m_indexB = -1;\n /** @internal */ m_evaluateFcn: EvaluateFunction | null = null;\n /** @internal */ m_manifold: Manifold = new Manifold();\n /** @internal */ m_prev: Contact | null = null;\n /** @internal */ m_next: Contact | null = null;\n /** @internal */ m_toi = 1.0;\n /** @internal */ m_toiCount = 0;\n // This contact has a valid TOI in m_toi\n /** @internal */ m_toiFlag = false;\n /** @internal */ m_friction = 0.0;\n /** @internal */ m_restitution = 0.0;\n /** @internal */ m_tangentSpeed = 0.0;\n /** @internal This contact can be disabled (by user) */\n m_enabledFlag = true;\n /** @internal Used when crawling contact graph when forming islands. */\n m_islandFlag = false;\n /** @internal Set when the shapes are touching. */\n m_touchingFlag = false;\n /** @internal This contact needs filtering because a fixture filter was changed. */\n m_filterFlag = false;\n /** @internal This bullet contact had a TOI event */\n m_bulletHitFlag = false;\n\n /** @internal Contact reporting impulse object cache */\n m_impulse: ContactImpulse = new ContactImpulse(this);\n\n // VelocityConstraint\n /** @internal */ v_points = [new VelocityConstraintPoint(), new VelocityConstraintPoint()]; // [maxManifoldPoints];\n /** @internal */ v_normal = matrix.vec2(0, 0);\n /** @internal */ v_normalMass: Mat22 = new Mat22();\n /** @internal */ v_K: Mat22 = new Mat22();\n /** @internal */ v_pointCount = 0;\n /** @internal */ v_tangentSpeed = 0;\n /** @internal */ v_friction = 0;\n /** @internal */ v_restitution = 0;\n /** @internal */ v_invMassA = 0;\n /** @internal */ v_invMassB = 0;\n /** @internal */ v_invIA = 0;\n /** @internal */ v_invIB = 0;\n\n // PositionConstraint\n /** @internal */ p_localPoints = [matrix.vec2(0, 0), matrix.vec2(0, 0)]; // [maxManifoldPoints];\n /** @internal */ p_localNormal = matrix.vec2(0, 0);\n /** @internal */ p_localPoint = matrix.vec2(0, 0);\n /** @internal */ p_localCenterA = matrix.vec2(0, 0);\n /** @internal */ p_localCenterB = matrix.vec2(0, 0);\n /** @internal */ p_type = ManifoldType.e_unset;\n /** @internal */ p_radiusA = 0;\n /** @internal */ p_radiusB = 0;\n /** @internal */ p_pointCount = 0;\n /** @internal */ p_invMassA = 0;\n /** @internal */ p_invMassB = 0;\n /** @internal */ p_invIA = 0;\n /** @internal */ p_invIB = 0;\n\n /** @internal */ \n initialize(fA: Fixture, indexA: number, fB: Fixture, indexB: number, evaluateFcn: EvaluateFunction) {\n this.m_fixtureA = fA;\n this.m_fixtureB = fB;\n\n this.m_indexA = indexA;\n this.m_indexB = indexB;\n\n this.m_evaluateFcn = evaluateFcn;\n\n this.m_friction = mixFriction(this.m_fixtureA.m_friction, this.m_fixtureB.m_friction);\n this.m_restitution = mixRestitution(this.m_fixtureA.m_restitution, this.m_fixtureB.m_restitution);\n }\n\n /** @internal */ \n recycle() {\n this.m_nodeA.recycle();\n this.m_nodeB.recycle();\n this.m_fixtureA = null;\n this.m_fixtureB = null;\n this.m_indexA = -1;\n this.m_indexB = -1;\n this.m_evaluateFcn = null;\n this.m_manifold.recycle();\n this.m_prev = null;\n this.m_next = null;\n this.m_toi = 1;\n this.m_toiCount = 0;\n this.m_toiFlag = false;\n this.m_friction = 0;\n this.m_restitution = 0;\n this.m_tangentSpeed = 0;\n this.m_enabledFlag = true;\n this.m_islandFlag = false;\n this.m_touchingFlag = false;\n this.m_filterFlag = false;\n this.m_bulletHitFlag = false;\n\n this.m_impulse.recycle();\n\n // VelocityConstraint\n for(const point of this.v_points) {\n point.recycle();\n }\n matrix.zeroVec2(this.v_normal);\n this.v_normalMass.setZero();\n this.v_K.setZero();\n this.v_pointCount = 0;\n this.v_tangentSpeed = 0;\n this.v_friction = 0;\n this.v_restitution = 0;\n this.v_invMassA = 0;\n this.v_invMassB = 0;\n this.v_invIA = 0;\n this.v_invIB = 0;\n\n // PositionConstraint\n for(const point of this.p_localPoints) {\n matrix.zeroVec2(point);\n }\n matrix.zeroVec2(this.p_localNormal);\n matrix.zeroVec2(this.p_localPoint);\n matrix.zeroVec2(this.p_localCenterA);\n matrix.zeroVec2(this.p_localCenterB);\n this.p_type = ManifoldType.e_unset;\n this.p_radiusA = 0;\n this.p_radiusB = 0;\n this.p_pointCount = 0;\n this.p_invMassA = 0;\n this.p_invMassB = 0;\n this.p_invIA = 0;\n this.p_invIB = 0;\n }\n\n initConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n const manifold = this.m_manifold;\n\n const pointCount = manifold.pointCount;\n if (_ASSERT) console.assert(pointCount > 0);\n\n this.v_invMassA = bodyA.m_invMass;\n this.v_invMassB = bodyB.m_invMass;\n this.v_invIA = bodyA.m_invI;\n this.v_invIB = bodyB.m_invI;\n\n this.v_friction = this.m_friction;\n this.v_restitution = this.m_restitution;\n this.v_tangentSpeed = this.m_tangentSpeed;\n\n this.v_pointCount = pointCount;\n\n this.v_K.setZero();\n this.v_normalMass.setZero();\n\n this.p_invMassA = bodyA.m_invMass;\n this.p_invMassB = bodyB.m_invMass;\n this.p_invIA = bodyA.m_invI;\n this.p_invIB = bodyB.m_invI;\n matrix.copyVec2(this.p_localCenterA, bodyA.m_sweep.localCenter);\n matrix.copyVec2(this.p_localCenterB, bodyB.m_sweep.localCenter);\n\n this.p_radiusA = shapeA.m_radius;\n this.p_radiusB = shapeB.m_radius;\n\n this.p_type = manifold.type;\n matrix.copyVec2(this.p_localNormal, manifold.localNormal);\n matrix.copyVec2(this.p_localPoint, manifold.localPoint);\n this.p_pointCount = pointCount;\n\n for (let j = 0; j < Settings.maxManifoldPoints; ++j) {\n this.v_points[j].recycle();\n matrix.zeroVec2(this.p_localPoints[j]);\n }\n\n for (let j = 0; j < pointCount; ++j) {\n const cp = manifold.points[j];\n const vcp = this.v_points[j];\n if (step.warmStarting) {\n vcp.normalImpulse = step.dtRatio * cp.normalImpulse;\n vcp.tangentImpulse = step.dtRatio * cp.tangentImpulse;\n }\n matrix.copyVec2(this.p_localPoints[j], cp.localPoint);\n }\n }\n\n /**\n * Get the contact manifold. Do not modify the manifold unless you understand\n * the internals of the library.\n */\n getManifold(): Manifold {\n return this.m_manifold;\n }\n\n /**\n * Get the world manifold.\n */\n getWorldManifold(worldManifold: WorldManifold | null): WorldManifold | undefined {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n return this.m_manifold.getWorldManifold(\n worldManifold,\n bodyA.getTransform(), shapeA.m_radius,\n bodyB.getTransform(), shapeB.m_radius\n );\n }\n\n /**\n * Enable/disable this contact. This can be used inside the pre-solve contact\n * listener. The contact is only disabled for the current time step (or sub-step\n * in continuous collisions).\n */\n setEnabled(flag: boolean): void {\n this.m_enabledFlag = !!flag;\n }\n\n /**\n * Has this contact been disabled?\n */\n isEnabled(): boolean {\n return this.m_enabledFlag;\n }\n\n /**\n * Is this contact touching?\n */\n isTouching(): boolean {\n return this.m_touchingFlag;\n }\n\n /**\n * Get the next contact in the world's contact list.\n */\n getNext(): Contact | null {\n return this.m_next;\n }\n\n /**\n * Get fixture A in this contact.\n */\n getFixtureA(): Fixture {\n return this.m_fixtureA;\n }\n\n /**\n * Get fixture B in this contact.\n */\n getFixtureB(): Fixture {\n return this.m_fixtureB;\n }\n\n /**\n * Get the child primitive index for fixture A.\n */\n getChildIndexA(): number {\n return this.m_indexA;\n }\n\n /**\n * Get the child primitive index for fixture B.\n */\n getChildIndexB(): number {\n return this.m_indexB;\n }\n\n /**\n * Flag this contact for filtering. Filtering will occur the next time step.\n */\n flagForFiltering(): void {\n this.m_filterFlag = true;\n }\n\n /**\n * Override the default friction mixture. You can call this in\n * \"pre-solve\" callback. This value persists until set or reset.\n */\n setFriction(friction: number): void {\n this.m_friction = friction;\n }\n\n /**\n * Get the friction.\n */\n getFriction(): number {\n return this.m_friction;\n }\n\n /**\n * Reset the friction mixture to the default value.\n */\n resetFriction(): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_friction = mixFriction(fixtureA.m_friction, fixtureB.m_friction);\n }\n\n /**\n * Override the default restitution mixture. You can call this in\n * \"pre-solve\" callback. The value persists until you set or reset.\n */\n setRestitution(restitution: number): void {\n this.m_restitution = restitution;\n }\n\n /**\n * Get the restitution.\n */\n getRestitution(): number {\n return this.m_restitution;\n }\n\n /**\n * Reset the restitution to the default value.\n */\n resetRestitution(): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_restitution = mixRestitution(fixtureA.m_restitution, fixtureB.m_restitution);\n }\n\n /**\n * Set the desired tangent speed for a conveyor belt behavior. In meters per\n * second.\n */\n setTangentSpeed(speed: number): void {\n this.m_tangentSpeed = speed;\n }\n\n /**\n * Get the desired tangent speed. In meters per second.\n */\n getTangentSpeed(): number {\n return this.m_tangentSpeed;\n }\n\n /**\n * Called by Update method, and implemented by subclasses.\n */\n evaluate(manifold: Manifold, xfA: TransformValue, xfB: TransformValue): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n this.m_evaluateFcn(manifold, xfA, fixtureA, this.m_indexA, xfB, fixtureB, this.m_indexB);\n }\n\n /**\n * Updates the contact manifold and touching status.\n *\n * Note: do not assume the fixture AABBs are overlapping or are valid.\n *\n * @param listener.beginContact\n * @param listener.endContact\n * @param listener.preSolve\n */\n update(listener?: {\n beginContact(contact: Contact): void,\n endContact(contact: Contact): void,\n preSolve(contact: Contact, oldManifold: Manifold): void\n }): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n const shapeA = fixtureA.m_shape;\n const shapeB = fixtureB.m_shape;\n if (shapeA === null || shapeB === null) return;\n\n // Re-enable this contact.\n this.m_enabledFlag = true;\n\n let touching = false;\n const wasTouching = this.m_touchingFlag;\n\n const sensorA = fixtureA.m_isSensor;\n const sensorB = fixtureB.m_isSensor;\n const sensor = sensorA || sensorB;\n\n const xfA = bodyA.m_xf;\n const xfB = bodyB.m_xf;\n\n // Is this contact a sensor?\n if (sensor) {\n touching = testOverlap(shapeA, this.m_indexA, shapeB, this.m_indexB, xfA, xfB);\n\n // Sensors don't generate manifolds.\n this.m_manifold.pointCount = 0;\n } else {\n\n oldManifold.recycle();\n oldManifold.set(this.m_manifold);\n this.m_manifold.recycle();\n\n this.evaluate(this.m_manifold, xfA, xfB);\n touching = this.m_manifold.pointCount > 0;\n\n // Match old contact ids to new contact ids and copy the\n // stored impulses to warm start the solver.\n for (let i = 0; i < this.m_manifold.pointCount; ++i) {\n const nmp = this.m_manifold.points[i];\n nmp.normalImpulse = 0.0;\n nmp.tangentImpulse = 0.0;\n\n for (let j = 0; j < oldManifold.pointCount; ++j) {\n const omp = oldManifold.points[j];\n if (omp.id.key === nmp.id.key) {\n nmp.normalImpulse = omp.normalImpulse;\n nmp.tangentImpulse = omp.tangentImpulse;\n break;\n }\n }\n }\n\n if (touching !== wasTouching) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n }\n\n this.m_touchingFlag = touching;\n\n const hasListener = typeof listener === \"object\" && listener !== null;\n\n if (!wasTouching && touching && hasListener) {\n listener.beginContact(this);\n }\n\n if (wasTouching && !touching && hasListener) {\n listener.endContact(this);\n }\n\n if (!sensor && touching && hasListener && oldManifold) {\n listener.preSolve(this, oldManifold);\n }\n }\n\n solvePositionConstraint(step: TimeStep): number {\n return this._solvePositionConstraint(step, null, null);\n }\n\n solvePositionConstraintTOI(step: TimeStep, toiA: Body, toiB: Body): number {\n return this._solvePositionConstraint(step, toiA, toiB);\n }\n\n private _solvePositionConstraint(step: TimeStep, toiA: Body | null, toiB: Body | null): number {\n const toi = toiA !== null && toiB !== null ? true : false;\n let minSeparation = 0.0;\n\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return minSeparation;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return minSeparation;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const localCenterA = this.p_localCenterA;\n const localCenterB = this.p_localCenterB;\n\n let mA = 0.0;\n let iA = 0.0;\n if (!toi || (bodyA === toiA || bodyA === toiB)) {\n mA = this.p_invMassA;\n iA = this.p_invIA;\n }\n\n let mB = 0.0;\n let iB = 0.0;\n if (!toi || (bodyB === toiA || bodyB === toiB)) {\n mB = this.p_invMassB;\n iB = this.p_invIB;\n }\n\n matrix.copyVec2(cA, positionA.c);\n let aA = positionA.a;\n\n matrix.copyVec2(cB, positionB.c);\n let aB = positionB.a;\n\n // Solve normal constraints\n for (let j = 0; j < this.p_pointCount; ++j) {\n getTransform(xfA, localCenterA, cA, aA);\n getTransform(xfB, localCenterB, cB, aB);\n\n // PositionSolverManifold\n let separation: number;\n switch (this.p_type) {\n case ManifoldType.e_circles: {\n matrix.transformVec2(pointA, xfA, this.p_localPoint);\n matrix.transformVec2(pointB, xfB, this.p_localPoints[0]);\n matrix.subVec2(normal, pointB, pointA);\n matrix.normalizeVec2(normal);\n\n matrix.combine2Vec2(point, 0.5, pointA, 0.5, pointB);\n separation = matrix.dotVec2(pointB, normal) - matrix.dotVec2(pointA, normal) - this.p_radiusA - this.p_radiusB;\n break;\n }\n\n case ManifoldType.e_faceA: {\n matrix.rotVec2(normal, xfA.q, this.p_localNormal);\n matrix.transformVec2(planePoint, xfA, this.p_localPoint);\n matrix.transformVec2(clipPoint, xfB, this.p_localPoints[j]);\n separation = matrix.dotVec2(clipPoint, normal) - matrix.dotVec2(planePoint, normal) - this.p_radiusA - this.p_radiusB;\n matrix.copyVec2(point, clipPoint);\n break;\n }\n\n case ManifoldType.e_faceB: {\n matrix.rotVec2(normal, xfB.q, this.p_localNormal);\n matrix.transformVec2(planePoint, xfB, this.p_localPoint);\n matrix.transformVec2(clipPoint, xfA, this.p_localPoints[j]);\n separation = matrix.dotVec2(clipPoint, normal) - matrix.dotVec2(planePoint, normal) - this.p_radiusA - this.p_radiusB;\n matrix.copyVec2(point, clipPoint);\n\n // Ensure normal points from A to B\n matrix.negVec2(normal);\n break;\n }\n // todo: what should we do here?\n default: {\n return minSeparation;\n }\n }\n\n matrix.subVec2(rA, point, cA);\n matrix.subVec2(rB, point, cB);\n\n // Track max constraint error.\n minSeparation = math_min(minSeparation, separation);\n\n const baumgarte = toi ? Settings.toiBaugarte : Settings.baumgarte;\n const linearSlop = Settings.linearSlop;\n const maxLinearCorrection = Settings.maxLinearCorrection;\n\n // Prevent large corrections and allow slop.\n const C = clamp(baumgarte * (separation + linearSlop), -maxLinearCorrection, 0.0);\n\n // Compute the effective mass.\n const rnA = matrix.crossVec2Vec2(rA, normal);\n const rnB = matrix.crossVec2Vec2(rB, normal);\n const K = mA + mB + iA * rnA * rnA + iB * rnB * rnB;\n\n // Compute normal impulse\n const impulse = K > 0.0 ? -C / K : 0.0;\n\n matrix.scaleVec2(P, impulse, normal);\n\n matrix.minusScaleVec2(cA, mA, P);\n aA -= iA * matrix.crossVec2Vec2(rA, P);\n\n matrix.plusScaleVec2(cB, mB, P);\n aB += iB * matrix.crossVec2Vec2(rB, P);\n }\n\n matrix.copyVec2(positionA.c, cA);\n positionA.a = aA;\n\n matrix.copyVec2(positionB.c, cB);\n positionB.a = aB;\n\n return minSeparation;\n }\n\n initVelocityConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const radiusA = this.p_radiusA;\n const radiusB = this.p_radiusB;\n const manifold = this.m_manifold;\n\n const mA = this.v_invMassA;\n const mB = this.v_invMassB;\n const iA = this.v_invIA;\n const iB = this.v_invIB;\n const localCenterA = this.p_localCenterA;\n const localCenterB = this.p_localCenterB;\n\n matrix.copyVec2(cA, positionA.c);\n const aA = positionA.a;\n matrix.copyVec2(vA, velocityA.v);\n const wA = velocityA.w;\n\n matrix.copyVec2(cB, positionB.c);\n const aB = positionB.a;\n matrix.copyVec2(vB, velocityB.v);\n const wB = velocityB.w;\n\n if (_ASSERT) console.assert(manifold.pointCount > 0);\n\n getTransform(xfA, localCenterA, cA, aA);\n getTransform(xfB, localCenterB, cB, aB);\n\n worldManifold.recycle();\n manifold.getWorldManifold(worldManifold, xfA, radiusA, xfB, radiusB);\n\n matrix.copyVec2(this.v_normal, worldManifold.normal);\n\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n const wmp = worldManifold.points[j];\n\n matrix.subVec2(vcp.rA, wmp, cA);\n matrix.subVec2(vcp.rB, wmp, cB);\n\n const rnA = matrix.crossVec2Vec2(vcp.rA, this.v_normal);\n const rnB = matrix.crossVec2Vec2(vcp.rB, this.v_normal);\n\n const kNormal = mA + mB + iA * rnA * rnA + iB * rnB * rnB;\n\n vcp.normalMass = kNormal > 0.0 ? 1.0 / kNormal : 0.0;\n\n matrix.crossVec2Num(tangent, this.v_normal, 1.0);\n\n const rtA = matrix.crossVec2Vec2(vcp.rA, tangent);\n const rtB = matrix.crossVec2Vec2(vcp.rB, tangent);\n\n const kTangent = mA + mB + iA * rtA * rtA + iB * rtB * rtB;\n\n vcp.tangentMass = kTangent > 0.0 ? 1.0 / kTangent : 0.0;\n\n // Setup a velocity bias for restitution.\n vcp.velocityBias = 0.0;\n let vRel = 0;\n vRel += matrix.dotVec2(this.v_normal, vB);\n vRel += matrix.dotVec2(this.v_normal, matrix.crossNumVec2(temp, wB, vcp.rB));\n vRel -= matrix.dotVec2(this.v_normal, vA);\n vRel -= matrix.dotVec2(this.v_normal, matrix.crossNumVec2(temp, wA, vcp.rA));\n if (vRel < -Settings.velocityThreshold) {\n vcp.velocityBias = -this.v_restitution * vRel;\n }\n }\n\n // If we have two points, then prepare the block solver.\n if (this.v_pointCount == 2 && step.blockSolve) {\n const vcp1 = this.v_points[0]; // VelocityConstraintPoint\n const vcp2 = this.v_points[1]; // VelocityConstraintPoint\n\n const rn1A = matrix.crossVec2Vec2(vcp1.rA, this.v_normal);\n const rn1B = matrix.crossVec2Vec2(vcp1.rB, this.v_normal);\n const rn2A = matrix.crossVec2Vec2(vcp2.rA, this.v_normal);\n const rn2B = matrix.crossVec2Vec2(vcp2.rB, this.v_normal);\n\n const k11 = mA + mB + iA * rn1A * rn1A + iB * rn1B * rn1B;\n const k22 = mA + mB + iA * rn2A * rn2A + iB * rn2B * rn2B;\n const k12 = mA + mB + iA * rn1A * rn2A + iB * rn1B * rn2B;\n\n // Ensure a reasonable condition number.\n const k_maxConditionNumber = 1000.0;\n if (k11 * k11 < k_maxConditionNumber * (k11 * k22 - k12 * k12)) {\n // K is safe to invert.\n this.v_K.ex.setNum(k11, k12);\n this.v_K.ey.setNum(k12, k22);\n // this.v_normalMass.set(this.v_K.getInverse());\n const a = this.v_K.ex.x;\n const b = this.v_K.ey.x;\n const c = this.v_K.ex.y;\n const d = this.v_K.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n this.v_normalMass.ex.x = det * d;\n this.v_normalMass.ey.x = -det * b;\n this.v_normalMass.ex.y = -det * c;\n this.v_normalMass.ey.y = det * a;\n\n } else {\n // The constraints are redundant, just use one.\n // TODO_ERIN use deepest?\n this.v_pointCount = 1;\n }\n }\n\n matrix.copyVec2(positionA.c, cA);\n positionA.a = aA;\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n\n matrix.copyVec2(positionB.c, cB);\n positionB.a = aB;\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n warmStartConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const velocityB = bodyB.c_velocity;\n const positionA = bodyA.c_position;\n const positionB = bodyB.c_position;\n\n const mA = this.v_invMassA;\n const iA = this.v_invIA;\n const mB = this.v_invMassB;\n const iB = this.v_invIB;\n\n matrix.copyVec2(vA, velocityA.v);\n let wA = velocityA.w;\n matrix.copyVec2(vB, velocityB.v);\n let wB = velocityB.w;\n\n matrix.copyVec2(normal, this.v_normal);\n matrix.crossVec2Num(tangent, normal, 1.0);\n\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n\n matrix.combine2Vec2(P, vcp.normalImpulse, normal, vcp.tangentImpulse, tangent);\n\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n matrix.minusScaleVec2(vA, mA, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n matrix.plusScaleVec2(vB, mB, P);\n }\n\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n storeConstraintImpulses(step: TimeStep): void {\n const manifold = this.m_manifold;\n for (let j = 0; j < this.v_pointCount; ++j) {\n manifold.points[j].normalImpulse = this.v_points[j].normalImpulse;\n manifold.points[j].tangentImpulse = this.v_points[j].tangentImpulse;\n }\n }\n\n solveVelocityConstraint(step: TimeStep): void {\n const fixtureA = this.m_fixtureA;\n const fixtureB = this.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n const velocityA = bodyA.c_velocity;\n const positionA = bodyA.c_position;\n\n const velocityB = bodyB.c_velocity;\n const positionB = bodyB.c_position;\n\n const mA = this.v_invMassA;\n const iA = this.v_invIA;\n const mB = this.v_invMassB;\n const iB = this.v_invIB;\n\n matrix.copyVec2(vA, velocityA.v);\n let wA = velocityA.w;\n matrix.copyVec2(vB, velocityB.v);\n let wB = velocityB.w;\n\n matrix.copyVec2(normal, this.v_normal);\n matrix.crossVec2Num(tangent, normal, 1.0);\n const friction = this.v_friction;\n\n if (_ASSERT) console.assert(this.v_pointCount == 1 || this.v_pointCount == 2);\n\n // Solve tangent constraints first because non-penetration is more important\n // than friction.\n for (let j = 0; j < this.v_pointCount; ++j) {\n const vcp = this.v_points[j]; // VelocityConstraintPoint\n\n // Relative velocity at contact\n matrix.zeroVec2(dv);\n matrix.plusVec2(dv, vB);\n matrix.plusVec2(dv, matrix.crossNumVec2(temp, wB, vcp.rB));\n matrix.minusVec2(dv, vA);\n matrix.minusVec2(dv, matrix.crossNumVec2(temp, wA, vcp.rA));\n\n // Compute tangent force\n const vt = matrix.dotVec2(dv, tangent) - this.v_tangentSpeed;\n let lambda = vcp.tangentMass * (-vt);\n\n // Clamp the accumulated force\n const maxFriction = friction * vcp.normalImpulse;\n const newImpulse = clamp(vcp.tangentImpulse + lambda, -maxFriction, maxFriction);\n lambda = newImpulse - vcp.tangentImpulse;\n vcp.tangentImpulse = newImpulse;\n\n // Apply contact impulse\n matrix.scaleVec2(P, lambda, tangent);\n\n matrix.minusScaleVec2(vA, mA, P);\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n\n matrix.plusScaleVec2(vB, mB, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n }\n\n // Solve normal constraints\n if (this.v_pointCount == 1 || step.blockSolve == false) {\n for (let i = 0; i < this.v_pointCount; ++i) {\n const vcp = this.v_points[i]; // VelocityConstraintPoint\n\n // Relative velocity at contact\n matrix.zeroVec2(dv);\n matrix.plusVec2(dv, vB);\n matrix.plusVec2(dv, matrix.crossNumVec2(temp, wB, vcp.rB));\n matrix.minusVec2(dv, vA);\n matrix.minusVec2(dv, matrix.crossNumVec2(temp, wA, vcp.rA));\n\n // Compute normal impulse\n const vn = matrix.dotVec2(dv, normal);\n let lambda = -vcp.normalMass * (vn - vcp.velocityBias);\n\n // Clamp the accumulated impulse\n const newImpulse = math_max(vcp.normalImpulse + lambda, 0.0);\n lambda = newImpulse - vcp.normalImpulse;\n vcp.normalImpulse = newImpulse;\n\n // Apply contact impulse\n matrix.scaleVec2(P, lambda, normal);\n\n matrix.minusScaleVec2(vA, mA, P);\n wA -= iA * matrix.crossVec2Vec2(vcp.rA, P);\n\n matrix.plusScaleVec2(vB, mB, P);\n wB += iB * matrix.crossVec2Vec2(vcp.rB, P);\n }\n } else {\n // Block solver developed in collaboration with Dirk Gregorius (back in\n // 01/07 on Box2D_Lite).\n // Build the mini LCP for this contact patch\n //\n // vn = A * x + b, vn >= 0, x >= 0 and vn_i * x_i = 0 with i = 1..2\n //\n // A = J * W * JT and J = ( -n, -r1 x n, n, r2 x n )\n // b = vn0 - velocityBias\n //\n // The system is solved using the \"Total enumeration method\" (s. Murty).\n // The complementary constraint vn_i * x_i\n // implies that we must have in any solution either vn_i = 0 or x_i = 0.\n // So for the 2D contact problem the cases\n // vn1 = 0 and vn2 = 0, x1 = 0 and x2 = 0, x1 = 0 and vn2 = 0, x2 = 0 and\n // vn1 = 0 need to be tested. The first valid\n // solution that satisfies the problem is chosen.\n //\n // In order to account of the accumulated impulse 'a' (because of the\n // iterative nature of the solver which only requires\n // that the accumulated impulse is clamped and not the incremental\n // impulse) we change the impulse variable (x_i).\n //\n // Substitute:\n //\n // x = a + d\n //\n // a := old total impulse\n // x := new total impulse\n // d := incremental impulse\n //\n // For the current iteration we extend the formula for the incremental\n // impulse\n // to compute the new total impulse:\n //\n // vn = A * d + b\n // = A * (x - a) + b\n // = A * x + b - A * a\n // = A * x + b'\n // b' = b - A * a;\n\n const vcp1 = this.v_points[0]; // VelocityConstraintPoint\n const vcp2 = this.v_points[1]; // VelocityConstraintPoint\n\n matrix.setVec2(a, vcp1.normalImpulse, vcp2.normalImpulse);\n if (_ASSERT) console.assert(a.x >= 0.0 && a.y >= 0.0);\n\n // Relative velocity at contact\n // let dv1 = Vec2.zero().add(vB).add(Vec2.crossNumVec2(wB, vcp1.rB)).sub(vA).sub(Vec2.crossNumVec2(wA, vcp1.rA));\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n // let dv2 = Vec2.zero().add(vB).add(Vec2.crossNumVec2(wB, vcp2.rB)).sub(vA).sub(Vec2.crossNumVec2(wA, vcp2.rA));\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n let vn1 = matrix.dotVec2(dv1, normal);\n let vn2 = matrix.dotVec2(dv2, normal);\n\n matrix.setVec2(b, vn1 - vcp1.velocityBias, vn2 - vcp2.velocityBias);\n\n // Compute b'\n // b.sub(Mat22.mulVec2(this.v_K, a));\n b.x -= this.v_K.ex.x * a.x + this.v_K.ey.x * a.y;\n b.y -= this.v_K.ex.y * a.x + this.v_K.ey.y * a.y;\n\n const k_errorTol = 1e-3;\n // NOT_USED(k_errorTol);\n\n while (true) {\n //\n // Case 1: vn = 0\n //\n // 0 = A * x + b'\n //\n // Solve for x:\n //\n // x = - inv(A) * b'\n //\n // const x = Mat22.mulVec2(this.v_normalMass, b).neg();\n matrix.zeroVec2(x);\n x.x = -(this.v_normalMass.ex.x * b.x + this.v_normalMass.ey.x * b.y);\n x.y = -(this.v_normalMass.ex.y * b.x + this.v_normalMass.ey.y * b.y);\n\n if (x.x >= 0.0 && x.y >= 0.0) {\n // Get the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n vn1 = matrix.dotVec2(dv1, normal);\n vn2 = matrix.dotVec2(dv2, normal);\n\n if (_ASSERT) console.assert(math_abs(vn1 - vcp1.velocityBias) < k_errorTol);\n if (_ASSERT) console.assert(math_abs(vn2 - vcp2.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 2: vn1 = 0 and x2 = 0\n //\n // 0 = a11 * x1 + a12 * 0 + b1'\n // vn2 = a21 * x1 + a22 * 0 + b2'\n //\n x.x = -vcp1.normalMass * b.x;\n x.y = 0.0;\n vn1 = 0.0;\n vn2 = this.v_K.ex.y * x.x + b.y;\n\n if (x.x >= 0.0 && vn2 >= 0.0) {\n // Get the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv1);\n matrix.plusVec2(dv1, vB);\n matrix.plusVec2(dv1, matrix.crossNumVec2(temp, wB, vcp1.rB));\n matrix.minusVec2(dv1, vA);\n matrix.minusVec2(dv1, matrix.crossNumVec2(temp, wA, vcp1.rA));\n\n // Compute normal velocity\n vn1 = matrix.dotVec2(dv1, normal);\n\n if (_ASSERT) console.assert(math_abs(vn1 - vcp1.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 3: vn2 = 0 and x1 = 0\n //\n // vn1 = a11 * 0 + a12 * x2 + b1'\n // 0 = a21 * 0 + a22 * x2 + b2'\n //\n x.x = 0.0;\n x.y = -vcp2.normalMass * b.y;\n vn1 = this.v_K.ey.x * x.y + b.x;\n vn2 = 0.0;\n\n if (x.y >= 0.0 && vn1 >= 0.0) {\n // Resubstitute for the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n matrix.zeroVec2(dv2);\n matrix.plusVec2(dv2, vB);\n matrix.plusVec2(dv2, matrix.crossNumVec2(temp, wB, vcp2.rB));\n matrix.minusVec2(dv2, vA);\n matrix.minusVec2(dv2, matrix.crossNumVec2(temp, wA, vcp2.rA));\n\n // Compute normal velocity\n vn2 = matrix.dotVec2(dv2, normal);\n\n if (_ASSERT) console.assert(math_abs(vn2 - vcp2.velocityBias) < k_errorTol);\n }\n break;\n }\n\n //\n // Case 4: x1 = 0 and x2 = 0\n //\n // vn1 = b1\n // vn2 = b2;\n //\n x.x = 0.0;\n x.y = 0.0;\n vn1 = b.x;\n vn2 = b.y;\n\n if (vn1 >= 0.0 && vn2 >= 0.0) {\n // Resubstitute for the incremental impulse\n matrix.subVec2(d, x, a);\n\n // Apply incremental impulse\n matrix.scaleVec2(P1, d.x, normal);\n matrix.scaleVec2(P2, d.y, normal);\n\n // vA.subCombine(mA, P1, mA, P2);\n matrix.combine3Vec2(vA, -mA, P1, -mA, P2, 1, vA);\n wA -= iA * (matrix.crossVec2Vec2(vcp1.rA, P1) + matrix.crossVec2Vec2(vcp2.rA, P2));\n\n // vB.addCombine(mB, P1, mB, P2);\n matrix.combine3Vec2(vB, mB, P1, mB, P2, 1, vB);\n wB += iB * (matrix.crossVec2Vec2(vcp1.rB, P1) + matrix.crossVec2Vec2(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n break;\n }\n\n // No solution, give up. This is hit sometimes, but it doesn't seem to\n // matter.\n break;\n }\n }\n\n matrix.copyVec2(velocityA.v, vA);\n velocityA.w = wA;\n\n matrix.copyVec2(velocityB.v, vB);\n velocityB.w = wB;\n }\n\n /** @internal */\n static addType(type1: ShapeType, type2: ShapeType, callback: EvaluateFunction): void {\n s_registers[type1] = s_registers[type1] || {};\n s_registers[type1][type2] = callback;\n }\n\n /** @internal */\n static create(fixtureA: Fixture, indexA: number, fixtureB: Fixture, indexB: number): Contact | null {\n const typeA = fixtureA.m_shape.m_type;\n const typeB = fixtureB.m_shape.m_type;\n\n const contact = contactPool.allocate();\n let evaluateFcn;\n if (evaluateFcn = s_registers[typeA] && s_registers[typeA][typeB]) {\n contact.initialize(fixtureA, indexA, fixtureB, indexB, evaluateFcn);\n } else if (evaluateFcn = s_registers[typeB] && s_registers[typeB][typeA]) {\n contact.initialize(fixtureB, indexB, fixtureA, indexA, evaluateFcn);\n } else {\n return null;\n }\n\n // Contact creation may swap fixtures.\n fixtureA = contact.m_fixtureA;\n fixtureB = contact.m_fixtureB;\n indexA = contact.getChildIndexA();\n indexB = contact.getChildIndexB();\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n\n // Connect to body A\n contact.m_nodeA.contact = contact;\n contact.m_nodeA.other = bodyB;\n\n contact.m_nodeA.prev = null;\n contact.m_nodeA.next = bodyA.m_contactList;\n if (bodyA.m_contactList != null) {\n bodyA.m_contactList.prev = contact.m_nodeA;\n }\n bodyA.m_contactList = contact.m_nodeA;\n\n // Connect to body B\n contact.m_nodeB.contact = contact;\n contact.m_nodeB.other = bodyA;\n\n contact.m_nodeB.prev = null;\n contact.m_nodeB.next = bodyB.m_contactList;\n if (bodyB.m_contactList != null) {\n bodyB.m_contactList.prev = contact.m_nodeB;\n }\n bodyB.m_contactList = contact.m_nodeB;\n\n // Wake up the bodies\n if (fixtureA.isSensor() == false && fixtureB.isSensor() == false) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n\n return contact;\n }\n\n /** @internal */\n static destroy(contact: Contact, listener: { endContact: (contact: Contact) => void }): void {\n const fixtureA = contact.m_fixtureA;\n const fixtureB = contact.m_fixtureB;\n if (fixtureA === null || fixtureB === null) return;\n const bodyA = fixtureA.m_body;\n const bodyB = fixtureB.m_body;\n if (bodyA === null || bodyB === null) return;\n\n if (contact.isTouching()) {\n listener.endContact(contact);\n }\n\n // Remove from body 1\n if (contact.m_nodeA.prev) {\n contact.m_nodeA.prev.next = contact.m_nodeA.next;\n }\n\n if (contact.m_nodeA.next) {\n contact.m_nodeA.next.prev = contact.m_nodeA.prev;\n }\n\n if (contact.m_nodeA == bodyA.m_contactList) {\n bodyA.m_contactList = contact.m_nodeA.next;\n }\n\n // Remove from body 2\n if (contact.m_nodeB.prev) {\n contact.m_nodeB.prev.next = contact.m_nodeB.next;\n }\n\n if (contact.m_nodeB.next) {\n contact.m_nodeB.next.prev = contact.m_nodeB.prev;\n }\n\n if (contact.m_nodeB == bodyB.m_contactList) {\n bodyB.m_contactList = contact.m_nodeB.next;\n }\n\n if (contact.m_manifold.pointCount > 0 && !fixtureA.m_isSensor && !fixtureB.m_isSensor) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n\n // const typeA = fixtureA.getType();\n // const typeB = fixtureB.getType();\n\n // const destroyFcn = s_registers[typeA][typeB].destroyFcn;\n // if (typeof destroyFcn === 'function') {\n // destroyFcn(contact);\n // }\n\n contactPool.release(contact);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../util/options\";\nimport { Vec2, Vec2Value } from \"../common/Vec2\";\nimport { BroadPhase } from \"../collision/BroadPhase\";\nimport { Solver, ContactImpulse, TimeStep } from \"./Solver\";\nimport { Body, BodyDef } from \"./Body\";\nimport { Joint } from \"./Joint\";\nimport { Contact } from \"./Contact\";\nimport { AABBValue, RayCastInput, RayCastOutput } from \"../collision/AABB\";\nimport { Fixture, FixtureProxy } from \"./Fixture\";\nimport { Manifold } from \"../collision/Manifold\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\nexport interface WorldDef {\n /** [default: { x : 0, y : 0}] */\n gravity?: Vec2Value;\n\n /** [default: true] */\n allowSleep?: boolean;\n\n /** [default: true] */\n warmStarting?: boolean;\n\n /** [default: true] */\n continuousPhysics?: boolean;\n\n /** [default: false] */\n subStepping?: boolean;\n\n /** [default: true] */\n blockSolve?: boolean;\n\n /** @internal [8] For the velocity constraint solver. */\n velocityIterations?: number;\n\n /** @internal [3] For the position constraint solver. */\n positionIterations?: number;\n}\n\n/** @internal */ const DEFAULTS: WorldDef = {\n gravity : Vec2.zero(),\n allowSleep : true,\n warmStarting : true,\n continuousPhysics : true,\n subStepping : false,\n blockSolve : true,\n velocityIterations : 8,\n positionIterations : 3\n};\n\n/**\n * Callback function for ray casts, see {@link World.rayCast}.\n *\n * Called for each fixture found in the query.\n * The returned value replaces the ray-cast input maxFraction.\n * You control how the ray cast proceeds by returning a numeric/float value.\n * \n * - `0` to terminate the ray cast\n * - `fraction` to clip the ray cast at current point\n * - `1` don't clip the ray and continue\n * - `-1` (or anything else) to continue\n *\n * @param fixture The fixture hit by the ray\n * @param point The point of initial intersection\n * @param normal The normal vector at the point of intersection\n * @param fraction The fraction along the ray at the point of intersection\n *\n * @returns A number to update the maxFraction\n */\nexport type WorldRayCastCallback = (fixture: Fixture, point: Vec2, normal: Vec2, fraction: number) => number;\n\n/**\n * Called for each fixture found in the query AABB. It may return `false` to terminate the query.\n */\nexport type WorldAABBQueryCallback = (fixture: Fixture) => boolean;\n\ndeclare module \"./World\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(deg: WorldDef): World;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(gravity: Vec2): World;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function World(): World;\n}\n\n/**\n * The `World` class contains the bodies and joints. It manages all aspects\n * of the simulation and allows for asynchronous queries (like AABB queries\n * and ray-casts). Much of your interactions with Planck.js will be with a\n * World object.\n */\n// @ts-expect-error\nexport class World {\n /** @internal */ m_solver: Solver;\n /** @internal */ m_broadPhase: BroadPhase;\n /** @internal */ m_contactList: Contact | null;\n /** @internal */ m_contactCount: number;\n /** @internal */ m_bodyList: Body | null;\n /** @internal */ m_bodyCount: number;\n /** @internal */ m_jointList: Joint | null;\n /** @internal */ m_jointCount: number;\n /** @internal */ m_stepComplete: boolean;\n /** @internal */ m_allowSleep: boolean;\n /** @internal */ m_gravity: Vec2;\n /** @internal */ m_clearForces: boolean;\n /** @internal */ m_newFixture: boolean;\n /** @internal */ m_locked: boolean;\n /** @internal */ m_warmStarting: boolean;\n /** @internal */ m_continuousPhysics: boolean;\n /** @internal */ m_subStepping: boolean;\n /** @internal */ m_blockSolve: boolean;\n /** @internal */ m_velocityIterations: number;\n /** @internal */ m_positionIterations: number;\n /** @internal */ m_t: number;\n\n /** @internal */ m_step_callback: ((world: World) => unknown)[];\n\n // TODO\n /** @internal */ _listeners: {\n [key: string]: any[]\n };\n\n /**\n * @param def World definition or gravity vector.\n */\n constructor(def?: WorldDef | Vec2Value) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof World)) {\n return new World(def);\n }\n\n this.s_step = new TimeStep();\n\n\n if (!def) {\n def = {};\n } else if (Vec2.isValid(def)) {\n def = { gravity: def as Vec2 };\n }\n\n def = options(def, DEFAULTS) as WorldDef;\n\n this.m_solver = new Solver(this);\n\n this.m_broadPhase = new BroadPhase();\n\n this.m_contactList = null;\n this.m_contactCount = 0;\n\n this.m_bodyList = null;\n this.m_bodyCount = 0;\n\n this.m_jointList = null;\n this.m_jointCount = 0;\n\n this.m_stepComplete = true;\n\n this.m_allowSleep = def.allowSleep;\n this.m_gravity = Vec2.clone(def.gravity);\n\n this.m_clearForces = true;\n this.m_newFixture = false;\n this.m_locked = false;\n\n // These are for debugging the solver.\n this.m_warmStarting = def.warmStarting;\n this.m_continuousPhysics = def.continuousPhysics;\n this.m_subStepping = def.subStepping;\n\n this.m_blockSolve = def.blockSolve;\n this.m_velocityIterations = def.velocityIterations;\n this.m_positionIterations = def.positionIterations;\n\n this.m_t = 0;\n\n this.m_step_callback = [];\n }\n\n /** @internal */\n _serialize(): object {\n const bodies = [];\n const joints = [];\n\n for (let b = this.getBodyList(); b; b = b.getNext()) {\n bodies.push(b);\n }\n\n for (let j = this.getJointList(); j; j = j.getNext()) {\n // @ts-ignore\n if (typeof j._serialize === \"function\") {\n joints.push(j);\n }\n }\n\n return {\n gravity: this.m_gravity,\n bodies,\n joints,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, context: any, restore: any): World {\n if (!data) {\n return new World();\n }\n\n const world = new World(data.gravity);\n\n if (data.bodies) {\n for (let i = data.bodies.length - 1; i >= 0; i -= 1) {\n world._addBody(restore(Body, data.bodies[i], world));\n }\n }\n\n if (data.joints) {\n for (let i = data.joints.length - 1; i >= 0; i--) {\n world.createJoint(restore(Joint, data.joints[i], world));\n }\n }\n\n return world;\n }\n\n /**\n * Get the world body list. With the returned body, use Body.getNext to get the\n * next body in the world list. A null body indicates the end of the list.\n *\n * @return the head of the world body list.\n */\n getBodyList(): Body | null {\n return this.m_bodyList;\n }\n\n /**\n * Get the world joint list. With the returned joint, use Joint.getNext to get\n * the next joint in the world list. A null joint indicates the end of the list.\n *\n * @return the head of the world joint list.\n */\n getJointList(): Joint | null {\n return this.m_jointList;\n }\n\n /**\n * Get the world contact list. With the returned contact, use Contact.getNext to\n * get the next contact in the world list. A null contact indicates the end of\n * the list.\n *\n * Warning: contacts are created and destroyed in the middle of a time step.\n * Use ContactListener to avoid missing contacts.\n *\n * @return the head of the world contact list.\n */\n getContactList(): Contact | null {\n return this.m_contactList;\n }\n\n getBodyCount(): number {\n return this.m_bodyCount;\n }\n\n getJointCount(): number {\n return this.m_jointCount;\n }\n\n /**\n * Get the number of contacts (each may have 0 or more contact points).\n */\n getContactCount(): number {\n return this.m_contactCount;\n }\n\n /**\n * Change the global gravity vector.\n */\n setGravity(gravity: Vec2Value): void {\n this.m_gravity.set(gravity);\n }\n\n /**\n * Get the global gravity vector.\n */\n getGravity(): Vec2 {\n return this.m_gravity;\n }\n\n /**\n * Is the world locked (in the middle of a time step).\n */\n isLocked(): boolean {\n return this.m_locked;\n }\n\n /**\n * Enable/disable sleep.\n */\n setAllowSleeping(flag: boolean): void {\n if (flag == this.m_allowSleep) {\n return;\n }\n\n this.m_allowSleep = flag;\n if (this.m_allowSleep == false) {\n for (let b = this.m_bodyList; b; b = b.m_next) {\n b.setAwake(true);\n }\n }\n }\n\n getAllowSleeping(): boolean {\n return this.m_allowSleep;\n }\n\n /**\n * Enable/disable warm starting. For testing.\n */\n setWarmStarting(flag: boolean): void {\n this.m_warmStarting = flag;\n }\n\n getWarmStarting(): boolean {\n return this.m_warmStarting;\n }\n\n /**\n * Enable/disable continuous physics. For testing.\n */\n setContinuousPhysics(flag: boolean): void {\n this.m_continuousPhysics = flag;\n }\n\n getContinuousPhysics(): boolean {\n return this.m_continuousPhysics;\n }\n\n /**\n * Enable/disable single stepped continuous physics. For testing.\n */\n setSubStepping(flag: boolean): void {\n this.m_subStepping = flag;\n }\n\n getSubStepping(): boolean {\n return this.m_subStepping;\n }\n\n /**\n * Set flag to control automatic clearing of forces after each time step.\n */\n setAutoClearForces(flag: boolean): void {\n this.m_clearForces = flag;\n }\n\n /**\n * Get the flag that controls automatic clearing of forces after each time step.\n */\n getAutoClearForces(): boolean {\n return this.m_clearForces;\n }\n\n /**\n * Manually clear the force buffer on all bodies. By default, forces are cleared\n * automatically after each call to step. The default behavior is modified by\n * calling setAutoClearForces. The purpose of this function is to support\n * sub-stepping. Sub-stepping is often used to maintain a fixed sized time step\n * under a variable frame-rate. When you perform sub-stepping you will disable\n * auto clearing of forces and instead call clearForces after all sub-steps are\n * complete in one pass of your game loop.\n *\n * See {@link World.setAutoClearForces}\n */\n clearForces(): void {\n for (let body = this.m_bodyList; body; body = body.getNext()) {\n body.m_force.setZero();\n body.m_torque = 0.0;\n }\n }\n\n /**\n * Query the world for all fixtures that potentially overlap the provided AABB.\n *\n * @param aabb The query box.\n * @param callback Called for each fixture found in the query AABB. It may return `false` to terminate the query.\n */\n queryAABB(aabb: AABBValue, callback: WorldAABBQueryCallback): void {\n if (_ASSERT) console.assert(typeof callback === \"function\");\n const broadPhase = this.m_broadPhase;\n this.m_broadPhase.query(aabb, function(proxyId: number): boolean { // TODO GC\n const proxy = broadPhase.getUserData(proxyId);\n return callback(proxy.fixture);\n });\n }\n\n /**\n * Ray-cast the world for all fixtures in the path of the ray. Your callback\n * controls whether you get the closest point, any point, or n-points. The\n * ray-cast ignores shapes that contain the starting point.\n *\n * @param point1 The ray starting point\n * @param point2 The ray ending point\n * @param callback A function that is called for each fixture that is hit by the ray. You control how the ray cast proceeds by returning a numeric/float value.\n */\n rayCast(point1: Vec2Value, point2: Vec2Value, callback: WorldRayCastCallback): void {\n if (_ASSERT) console.assert(typeof callback === \"function\");\n const broadPhase = this.m_broadPhase;\n\n this.m_broadPhase.rayCast({\n maxFraction : 1.0,\n p1 : point1,\n p2 : point2\n }, function(input: RayCastInput, proxyId: number): number { // TODO GC\n const proxy = broadPhase.getUserData(proxyId);\n const fixture = proxy.fixture;\n const index = proxy.childIndex;\n // @ts-ignore\n const output: RayCastOutput = {}; // TODO GC\n const hit = fixture.rayCast(output, input, index);\n if (hit) {\n const fraction = output.fraction;\n const point = Vec2.add(Vec2.mulNumVec2((1.0 - fraction), input.p1), Vec2.mulNumVec2(fraction, input.p2));\n return callback(fixture, point, output.normal, fraction);\n }\n return input.maxFraction;\n });\n }\n\n /**\n * Get the number of broad-phase proxies.\n */\n getProxyCount(): number {\n return this.m_broadPhase.getProxyCount();\n }\n\n /**\n * Get the height of broad-phase dynamic tree.\n */\n getTreeHeight(): number {\n return this.m_broadPhase.getTreeHeight();\n }\n\n /**\n * Get the balance of broad-phase dynamic tree.\n */\n getTreeBalance(): number {\n return this.m_broadPhase.getTreeBalance();\n }\n\n /**\n * Get the quality metric of broad-phase dynamic tree. The smaller the better.\n * The minimum is 1.\n */\n getTreeQuality(): number {\n return this.m_broadPhase.getTreeQuality();\n }\n\n /**\n * Shift the world origin. Useful for large worlds. The body shift formula is:\n * position -= newOrigin\n *\n * @param newOrigin The new origin with respect to the old origin\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return;\n }\n\n for (let b = this.m_bodyList; b; b = b.m_next) {\n b.m_xf.p.sub(newOrigin);\n b.m_sweep.c0.sub(newOrigin);\n b.m_sweep.c.sub(newOrigin);\n }\n\n for (let j = this.m_jointList; j; j = j.m_next) {\n j.shiftOrigin(newOrigin);\n }\n\n this.m_broadPhase.shiftOrigin(newOrigin);\n }\n\n /** @internal Used for deserialize. */\n _addBody(body: Body): void {\n if (_ASSERT) console.assert(this.isLocked() === false);\n if (this.isLocked()) {\n return;\n }\n\n // Add to world doubly linked list.\n body.m_prev = null;\n body.m_next = this.m_bodyList;\n if (this.m_bodyList) {\n this.m_bodyList.m_prev = body;\n }\n this.m_bodyList = body;\n ++this.m_bodyCount;\n }\n\n /**\n * Create a rigid body given a definition. No reference to the definition is\n * retained.\n *\n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n createBody(def?: BodyDef): Body;\n createBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createBody(arg1?, arg2?) {\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return null;\n }\n\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n\n const body = new Body(this, def);\n this._addBody(body);\n return body;\n }\n\n createDynamicBody(def?: BodyDef): Body;\n createDynamicBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createDynamicBody(arg1?, arg2?) {\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n def.type = \"dynamic\";\n return this.createBody(def);\n }\n\n createKinematicBody(def?: BodyDef): Body;\n createKinematicBody(position: Vec2Value, angle?: number): Body;\n // tslint:disable-next-line:typedef\n createKinematicBody(arg1?, arg2?) {\n let def: BodyDef = {};\n if (!arg1) {\n } else if (Vec2.isValid(arg1)) {\n def = { position : arg1, angle: arg2 };\n } else if (typeof arg1 === \"object\") {\n def = arg1;\n }\n def.type = \"kinematic\";\n return this.createBody(def);\n }\n\n /**\n * Destroy a body from the world.\n *\n * Warning: This automatically deletes all associated shapes and joints.\n *\n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n destroyBody(b: Body): boolean {\n if (_ASSERT) console.assert(this.m_bodyCount > 0);\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return;\n }\n\n if (b.m_destroyed) {\n return false;\n }\n\n // Delete the attached joints.\n let je = b.m_jointList;\n while (je) {\n const je0 = je;\n je = je.next;\n\n this.publish(\"remove-joint\", je0.joint);\n this.destroyJoint(je0.joint);\n\n b.m_jointList = je;\n }\n b.m_jointList = null;\n\n // Delete the attached contacts.\n let ce = b.m_contactList;\n while (ce) {\n const ce0 = ce;\n ce = ce.next;\n\n this.destroyContact(ce0.contact);\n\n b.m_contactList = ce;\n }\n b.m_contactList = null;\n\n // Delete the attached fixtures. This destroys broad-phase proxies.\n let f = b.m_fixtureList;\n while (f) {\n const f0 = f;\n f = f.m_next;\n\n this.publish(\"remove-fixture\", f0);\n f0.destroyProxies(this.m_broadPhase);\n\n b.m_fixtureList = f;\n }\n b.m_fixtureList = null;\n\n // Remove world body list.\n if (b.m_prev) {\n b.m_prev.m_next = b.m_next;\n }\n\n if (b.m_next) {\n b.m_next.m_prev = b.m_prev;\n }\n\n if (b == this.m_bodyList) {\n this.m_bodyList = b.m_next;\n }\n\n b.m_destroyed = true;\n\n --this.m_bodyCount;\n\n this.publish(\"remove-body\", b);\n\n return true;\n }\n\n /**\n * Create a joint to constrain bodies together. No reference to the definition\n * is retained. This may cause the connected bodies to cease colliding.\n *\n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n createJoint(joint: T): T | null {\n if (_ASSERT) console.assert(!!joint.m_bodyA);\n if (_ASSERT) console.assert(!!joint.m_bodyB);\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return null;\n }\n\n // Connect to the world list.\n joint.m_prev = null;\n joint.m_next = this.m_jointList;\n if (this.m_jointList) {\n this.m_jointList.m_prev = joint;\n }\n this.m_jointList = joint;\n ++this.m_jointCount;\n\n // Connect to the bodies' doubly linked lists.\n joint.m_edgeA.joint = joint;\n joint.m_edgeA.other = joint.m_bodyB;\n joint.m_edgeA.prev = null;\n joint.m_edgeA.next = joint.m_bodyA.m_jointList;\n if (joint.m_bodyA.m_jointList)\n joint.m_bodyA.m_jointList.prev = joint.m_edgeA;\n joint.m_bodyA.m_jointList = joint.m_edgeA;\n\n joint.m_edgeB.joint = joint;\n joint.m_edgeB.other = joint.m_bodyA;\n joint.m_edgeB.prev = null;\n joint.m_edgeB.next = joint.m_bodyB.m_jointList;\n if (joint.m_bodyB.m_jointList)\n joint.m_bodyB.m_jointList.prev = joint.m_edgeB;\n joint.m_bodyB.m_jointList = joint.m_edgeB;\n\n // If the joint prevents collisions, then flag any contacts for filtering.\n if (joint.m_collideConnected == false) {\n for (let edge = joint.m_bodyB.getContactList(); edge; edge = edge.next) {\n if (edge.other == joint.m_bodyA) {\n // Flag the contact for filtering at the next time step (where either\n // body is awake).\n edge.contact.flagForFiltering();\n }\n }\n }\n\n // Note: creating a joint doesn't wake the bodies.\n\n return joint;\n }\n\n /**\n * Destroy a joint.\n * \n * Warning: This may cause the connected bodies to begin colliding.\n * \n * Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.\n */\n destroyJoint(joint: Joint): void {\n if (_ASSERT) console.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return;\n }\n\n // Remove from the doubly linked list.\n if (joint.m_prev) {\n joint.m_prev.m_next = joint.m_next;\n }\n\n if (joint.m_next) {\n joint.m_next.m_prev = joint.m_prev;\n }\n\n if (joint == this.m_jointList) {\n this.m_jointList = joint.m_next;\n }\n\n // Disconnect from bodies.\n const bodyA = joint.m_bodyA;\n const bodyB = joint.m_bodyB;\n\n // Wake up connected bodies.\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n\n // Remove from body 1.\n if (joint.m_edgeA.prev) {\n joint.m_edgeA.prev.next = joint.m_edgeA.next;\n }\n\n if (joint.m_edgeA.next) {\n joint.m_edgeA.next.prev = joint.m_edgeA.prev;\n }\n\n if (joint.m_edgeA == bodyA.m_jointList) {\n bodyA.m_jointList = joint.m_edgeA.next;\n }\n\n joint.m_edgeA.prev = null;\n joint.m_edgeA.next = null;\n\n // Remove from body 2\n if (joint.m_edgeB.prev) {\n joint.m_edgeB.prev.next = joint.m_edgeB.next;\n }\n\n if (joint.m_edgeB.next) {\n joint.m_edgeB.next.prev = joint.m_edgeB.prev;\n }\n\n if (joint.m_edgeB == bodyB.m_jointList) {\n bodyB.m_jointList = joint.m_edgeB.next;\n }\n\n joint.m_edgeB.prev = null;\n joint.m_edgeB.next = null;\n\n if (_ASSERT) console.assert(this.m_jointCount > 0);\n --this.m_jointCount;\n\n // If the joint prevents collisions, then flag any contacts for filtering.\n if (joint.m_collideConnected == false) {\n let edge = bodyB.getContactList();\n while (edge) {\n if (edge.other == bodyA) {\n // Flag the contact for filtering at the next time step (where either\n // body is awake).\n edge.contact.flagForFiltering();\n }\n\n edge = edge.next;\n }\n }\n\n this.publish(\"remove-joint\", joint);\n }\n\n /** @internal */\n s_step: TimeStep; // reuse\n\n /**\n * Take a time step. This performs collision detection, integration, and\n * constraint solution.\n *\n * Broad-phase, narrow-phase, solve and solve time of impacts.\n *\n * @param timeStep Time step, this should not vary.\n */\n step(timeStep: number, velocityIterations?: number, positionIterations?: number): void {\n this.publish(\"pre-step\", timeStep);\n\n if ((velocityIterations | 0) !== velocityIterations) {\n // TODO: remove this in future\n velocityIterations = 0;\n }\n\n velocityIterations = velocityIterations || this.m_velocityIterations;\n positionIterations = positionIterations || this.m_positionIterations;\n\n // If new fixtures were added, we need to find the new contacts.\n if (this.m_newFixture) {\n this.findNewContacts();\n this.m_newFixture = false;\n }\n\n this.m_locked = true;\n\n this.s_step.reset(timeStep);\n this.s_step.velocityIterations = velocityIterations;\n this.s_step.positionIterations = positionIterations;\n this.s_step.warmStarting = this.m_warmStarting;\n this.s_step.blockSolve = this.m_blockSolve;\n\n // Update contacts. This is where some contacts are destroyed.\n this.updateContacts();\n\n // Integrate velocities, solve velocity constraints, and integrate positions.\n if (this.m_stepComplete && timeStep > 0.0) {\n this.m_solver.solveWorld(this.s_step);\n\n // Synchronize fixtures, check for out of range bodies.\n for (let b = this.m_bodyList; b; b = b.getNext()) {\n // If a body was not in an island then it did not move.\n if (b.m_islandFlag == false) {\n continue;\n }\n\n if (b.isStatic()) {\n continue;\n }\n\n // Update fixtures (for broad-phase).\n b.synchronizeFixtures();\n }\n // Look for new contacts.\n this.findNewContacts();\n }\n\n // Handle TOI events.\n if (this.m_continuousPhysics && timeStep > 0.0) {\n this.m_solver.solveWorldTOI(this.s_step);\n }\n\n if (this.m_clearForces) {\n this.clearForces();\n }\n\n this.m_locked = false;\n\n let callback: (world: World) => unknown;\n while(callback = this.m_step_callback.shift()) {\n callback(this);\n }\n\n this.publish(\"post-step\", timeStep);\n }\n\n /**\n * Queue a function to be called after ongoing simulation step. If no simulation is in progress call it immediately.\n */\n queueUpdate(callback: (world: World) => unknown): void {\n if (!this.isLocked()) {\n callback(this);\n } else {\n this.m_step_callback.push(callback);\n }\n }\n\n /**\n * @internal\n * Call this method to find new contacts.\n */\n findNewContacts(): void {\n this.m_broadPhase.updatePairs(\n (proxyA: FixtureProxy, proxyB: FixtureProxy) => this.createContact(proxyA, proxyB)\n );\n }\n\n /**\n * @internal\n * Callback for broad-phase.\n */\n createContact(proxyA: FixtureProxy, proxyB: FixtureProxy): void {\n const fixtureA = proxyA.fixture;\n const fixtureB = proxyB.fixture;\n\n const indexA = proxyA.childIndex;\n const indexB = proxyB.childIndex;\n\n const bodyA = fixtureA.getBody();\n const bodyB = fixtureB.getBody();\n\n // Are the fixtures on the same body?\n if (bodyA == bodyB) {\n return;\n }\n\n // TODO_ERIN use a hash table to remove a potential bottleneck when both\n // bodies have a lot of contacts.\n // Does a contact already exist?\n let edge = bodyB.getContactList(); // ContactEdge\n while (edge) {\n if (edge.other == bodyA) {\n const fA = edge.contact.getFixtureA();\n const fB = edge.contact.getFixtureB();\n const iA = edge.contact.getChildIndexA();\n const iB = edge.contact.getChildIndexB();\n\n if (fA == fixtureA && fB == fixtureB && iA == indexA && iB == indexB) {\n // A contact already exists.\n return;\n }\n\n if (fA == fixtureB && fB == fixtureA && iA == indexB && iB == indexA) {\n // A contact already exists.\n return;\n }\n }\n\n edge = edge.next;\n }\n\n if (bodyB.shouldCollide(bodyA) == false) {\n return;\n }\n if (fixtureB.shouldCollide(fixtureA) == false) {\n return;\n }\n\n // Call the factory.\n const contact = Contact.create(fixtureA, indexA, fixtureB, indexB);\n if (contact == null) {\n return;\n }\n\n // Insert into the world.\n contact.m_prev = null;\n if (this.m_contactList != null) {\n contact.m_next = this.m_contactList;\n this.m_contactList.m_prev = contact;\n }\n this.m_contactList = contact;\n\n ++this.m_contactCount;\n }\n\n /**\n * @internal\n * Removes old non-overlapping contacts, applies filters and updates contacts.\n */\n updateContacts(): void {\n // Update awake contacts.\n let c: Contact;\n let next_c = this.m_contactList;\n while (c = next_c) {\n next_c = c.getNext();\n const fixtureA = c.getFixtureA();\n const fixtureB = c.getFixtureB();\n const indexA = c.getChildIndexA();\n const indexB = c.getChildIndexB();\n const bodyA = fixtureA.getBody();\n const bodyB = fixtureB.getBody();\n\n // Is this contact flagged for filtering?\n if (c.m_filterFlag) {\n if (bodyB.shouldCollide(bodyA) == false) {\n this.destroyContact(c);\n continue;\n }\n\n if (fixtureB.shouldCollide(fixtureA) == false) {\n this.destroyContact(c);\n continue;\n }\n\n // Clear the filtering flag.\n c.m_filterFlag = false;\n }\n\n const activeA = bodyA.isAwake() && !bodyA.isStatic();\n const activeB = bodyB.isAwake() && !bodyB.isStatic();\n\n // At least one body must be awake and it must be dynamic or kinematic.\n if (activeA == false && activeB == false) {\n continue;\n }\n\n const proxyIdA = fixtureA.m_proxies[indexA].proxyId;\n const proxyIdB = fixtureB.m_proxies[indexB].proxyId;\n const overlap = this.m_broadPhase.testOverlap(proxyIdA, proxyIdB);\n\n // Here we destroy contacts that cease to overlap in the broad-phase.\n if (overlap == false) {\n this.destroyContact(c);\n continue;\n }\n\n // The contact persists.\n c.update(this);\n }\n }\n\n /** @internal */\n destroyContact(contact: Contact): void {\n // Remove from the world.\n if (contact.m_prev) {\n contact.m_prev.m_next = contact.m_next;\n }\n if (contact.m_next) {\n contact.m_next.m_prev = contact.m_prev;\n }\n if (contact == this.m_contactList) {\n this.m_contactList = contact.m_next;\n }\n\n Contact.destroy(contact, this);\n\n --this.m_contactCount;\n }\n\n\n /**\n * Called when two fixtures begin to touch.\n *\n * Implement contact callbacks to get contact information. You can use these\n * results for things like sounds and game logic. You can also get contact\n * results by traversing the contact lists after the time step. However, you\n * might miss some contacts because continuous physics leads to sub-stepping.\n * Additionally you may receive multiple callbacks for the same contact in a\n * single time step. You should strive to make your callbacks efficient because\n * there may be many callbacks per time step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"begin-contact\", listener: (contact: Contact) => void): World;\n /**\n * Called when two fixtures cease to touch.\n *\n * Implement contact callbacks to get contact information. You can use these\n * results for things like sounds and game logic. You can also get contact\n * results by traversing the contact lists after the time step. However, you\n * might miss some contacts because continuous physics leads to sub-stepping.\n * Additionally you may receive multiple callbacks for the same contact in a\n * single time step. You should strive to make your callbacks efficient because\n * there may be many callbacks per time step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"end-contact\", listener: (contact: Contact) => void): World;\n /**\n * This is called after a contact is updated. This allows you to inspect a\n * contact before it goes to the solver. If you are careful, you can modify the\n * contact manifold (e.g. disable contact). A copy of the old manifold is\n * provided so that you can detect changes. Note: this is called only for awake\n * bodies. Note: this is called even when the number of contact points is zero.\n * Note: this is not called for sensors. Note: if you set the number of contact\n * points to zero, you will not get an end-contact callback. However, you may get\n * a begin-contact callback the next step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"pre-solve\", listener: (contact: Contact, oldManifold: Manifold) => void): World;\n /**\n * This lets you inspect a contact after the solver is finished. This is useful\n * for inspecting impulses. Note: the contact manifold does not include time of\n * impact impulses, which can be arbitrarily large if the sub-step is small.\n * Hence the impulse is provided explicitly in a separate data structure. Note:\n * this is only called for contacts that are touching, solid, and awake.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n on(name: \"post-solve\", listener: (contact: Contact, impulse: ContactImpulse) => void): World;\n /** Listener is called whenever a body is removed. */\n on(name: \"remove-body\", listener: (body: Body) => void): World;\n /** Listener is called whenever a joint is removed implicitly or explicitly. */\n on(name: \"remove-joint\", listener: (joint: Joint) => void): World;\n /** Listener is called whenever a fixture is removed implicitly or explicitly. */\n on(name: \"remove-fixture\", listener: (fixture: Fixture) => void): World;\n /**\n * Register an event listener.\n */\n // tslint:disable-next-line:typedef\n on(name, listener) {\n if (typeof name !== \"string\" || typeof listener !== \"function\") {\n return this;\n }\n if (!this._listeners) {\n this._listeners = {};\n }\n if (!this._listeners[name]) {\n this._listeners[name] = [];\n }\n this._listeners[name].push(listener);\n return this;\n }\n\n off(name: \"begin-contact\", listener: (contact: Contact) => void): World;\n off(name: \"end-contact\", listener: (contact: Contact) => void): World;\n off(name: \"pre-solve\", listener: (contact: Contact, oldManifold: Manifold) => void): World;\n off(name: \"post-solve\", listener: (contact: Contact, impulse: ContactImpulse) => void): World;\n off(name: \"remove-body\", listener: (body: Body) => void): World;\n off(name: \"remove-joint\", listener: (joint: Joint) => void): World;\n off(name: \"remove-fixture\", listener: (fixture: Fixture) => void): World;\n /**\n * Remove an event listener.\n */\n // tslint:disable-next-line:typedef\n off(name, listener) {\n if (typeof name !== \"string\" || typeof listener !== \"function\") {\n return this;\n }\n const listeners = this._listeners && this._listeners[name];\n if (!listeners || !listeners.length) {\n return this;\n }\n const index = listeners.indexOf(listener);\n if (index >= 0) {\n listeners.splice(index, 1);\n }\n return this;\n }\n\n publish(name: string, arg1?: any, arg2?: any, arg3?: any): number {\n const listeners = this._listeners && this._listeners[name];\n if (!listeners || !listeners.length) {\n return 0;\n }\n for (let l = 0; l < listeners.length; l++) {\n listeners[l].call(this, arg1, arg2, arg3);\n }\n return listeners.length;\n }\n\n /** @internal */\n beginContact(contact: Contact): void {\n this.publish(\"begin-contact\", contact);\n }\n\n /** @internal */\n endContact(contact: Contact): void {\n this.publish(\"end-contact\", contact);\n }\n\n /** @internal */\n preSolve(contact: Contact, oldManifold: Manifold): void {\n this.publish(\"pre-solve\", contact, oldManifold);\n }\n\n /** @internal */\n postSolve(contact: Contact, impulse: ContactImpulse): void {\n this.publish(\"post-solve\", contact, impulse);\n }\n\n /**\n * Joints and fixtures are destroyed when their associated body is destroyed.\n * Register a destruction listener so that you may nullify references to these\n * joints and shapes.\n *\n * `function(object)` is called when any joint or fixture is about to\n * be destroyed due to the destruction of one of its attached or parent bodies.\n */\n\n /**\n * Register a contact filter to provide specific control over collision.\n * Otherwise the default filter is used (defaultFilter). The listener is owned\n * by you and must remain in scope.\n *\n * Moved to Fixture.\n */\n}","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/** 3D vector */\nexport interface Vec3Value {\n x: number;\n y: number;\n z: number;\n}\n\ndeclare module \"./Vec3\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(x: number, y: number, z: number): Vec3;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(obj: Vec3Value): Vec3;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function Vec3(): Vec3;\n}\n\n/** 3D vector */\n// @ts-expect-error\nexport class Vec3 {\n x: number;\n y: number;\n z: number;\n\n constructor(x: number, y: number, z: number);\n constructor(obj: Vec3Value);\n constructor();\n constructor(x?, y?, z?) {\n if (_CONSTRUCTOR_FACTORY && !(this instanceof Vec3)) {\n return new Vec3(x, y, z);\n }\n if (typeof x === \"undefined\") {\n this.x = 0;\n this.y = 0;\n this.z = 0;\n } else if (typeof x === \"object\") {\n this.x = x.x;\n this.y = x.y;\n this.z = x.z;\n } else {\n this.x = x;\n this.y = y;\n this.z = z;\n }\n if (_ASSERT) Vec3.assert(this);\n }\n\n /** @internal */\n _serialize(): object {\n return {\n x: this.x,\n y: this.y,\n z: this.z\n };\n }\n\n /** @internal */\n static _deserialize(data: any): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = data.x;\n obj.y = data.y;\n obj.z = data.z;\n return obj;\n }\n\n /** @hidden */\n static neo(x: number, y: number, z: number): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = x;\n obj.y = y;\n obj.z = z;\n return obj;\n }\n\n static zero(): Vec3 {\n const obj = Object.create(Vec3.prototype);\n obj.x = 0;\n obj.y = 0;\n obj.z = 0;\n return obj;\n }\n\n static clone(v: Vec3Value): Vec3 {\n if (_ASSERT) Vec3.assert(v);\n return Vec3.neo(v.x, v.y, v.z);\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n /** Does this vector contain finite coordinates? */\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Number.isFinite(obj.x) && Number.isFinite(obj.y) && Number.isFinite(obj.z);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Vec3.isValid(o), \"Invalid Vec3!\", o);\n }\n\n setZero(): Vec3 {\n this.x = 0.0;\n this.y = 0.0;\n this.z = 0.0;\n return this;\n }\n\n set(x: number, y: number, z: number): Vec3 {\n this.x = x;\n this.y = y;\n this.z = z;\n return this;\n }\n\n add(w: Vec3Value): Vec3 {\n this.x += w.x;\n this.y += w.y;\n this.z += w.z;\n return this;\n }\n\n sub(w: Vec3Value): Vec3 {\n this.x -= w.x;\n this.y -= w.y;\n this.z -= w.z;\n return this;\n }\n\n mul(m: number): Vec3 {\n this.x *= m;\n this.y *= m;\n this.z *= m;\n return this;\n }\n\n static areEqual(v: Vec3Value, w: Vec3Value): boolean {\n if (_ASSERT) Vec3.assert(v);\n if (_ASSERT) Vec3.assert(w);\n return v === w ||\n typeof v === \"object\" && v !== null &&\n typeof w === \"object\" && w !== null &&\n v.x === w.x && v.y === w.y && v.z === w.z;\n }\n\n /** Dot product on two vectors */\n static dot(v: Vec3Value, w: Vec3Value): number {\n return v.x * w.x + v.y * w.y + v.z * w.z;\n }\n\n /** Cross product on two vectors */\n static cross(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(\n v.y * w.z - v.z * w.y,\n v.z * w.x - v.x * w.z,\n v.x * w.y - v.y * w.x\n );\n }\n\n static add(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(v.x + w.x, v.y + w.y, v.z + w.z);\n }\n\n static sub(v: Vec3Value, w: Vec3Value): Vec3 {\n return new Vec3(v.x - w.x, v.y - w.y, v.z - w.z);\n }\n\n static mul(v: Vec3Value, m: number): Vec3 {\n return new Vec3(m * v.x, m * v.y, m * v.z);\n }\n\n neg(): Vec3 {\n this.x = -this.x;\n this.y = -this.y;\n this.z = -this.z;\n return this;\n }\n\n static neg(v: Vec3Value): Vec3 {\n return new Vec3(-v.x, -v.y, -v.z);\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport * as matrix from \"../../common/Matrix\";\nimport { Shape } from \"../Shape\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { AABB, AABBValue, RayCastInput, RayCastOutput } from \"../AABB\";\nimport { MassData } from \"../../dynamics/Body\";\nimport { DistanceProxy } from \"../Distance\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const v2 = matrix.vec2(0, 0);\n\ndeclare module \"./EdgeShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function EdgeShape(v1?: Vec2Value, v2?: Vec2Value): EdgeShape;\n}\n\n/**\n * A line segment (edge) shape. These can be connected in chains or loops to\n * other edge shapes. The connectivity information is used to ensure correct\n * contact normals.\n */\n// @ts-expect-error\nexport class EdgeShape extends Shape {\n static TYPE = \"edge\" as const;\n /** @hidden */ m_type: \"edge\";\n\n /** @hidden */ m_radius: number;\n\n // These are the edge vertices\n /** @hidden */ m_vertex1: Vec2;\n /** @hidden */ m_vertex2: Vec2;\n\n // Optional adjacent vertices. These are used for smooth collision.\n // Used by chain shape.\n /** @hidden */ m_vertex0: Vec2;\n /** @hidden */ m_vertex3: Vec2;\n /** @hidden */ m_hasVertex0: boolean;\n /** @hidden */ m_hasVertex3: boolean;\n\n constructor(v1?: Vec2Value, v2?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof EdgeShape)) {\n return new EdgeShape(v1, v2);\n }\n\n super();\n\n this.m_type = EdgeShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n\n this.m_vertex1 = v1 ? Vec2.clone(v1) : Vec2.zero();\n this.m_vertex2 = v2 ? Vec2.clone(v2) : Vec2.zero();\n\n this.m_vertex0 = Vec2.zero();\n this.m_vertex3 = Vec2.zero();\n this.m_hasVertex0 = false;\n this.m_hasVertex3 = false;\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n vertex1: this.m_vertex1,\n vertex2: this.m_vertex2,\n\n vertex0: this.m_vertex0,\n vertex3: this.m_vertex3,\n hasVertex0: this.m_hasVertex0,\n hasVertex3: this.m_hasVertex3,\n };\n }\n\n /** @internal */\n static _deserialize(data: any): EdgeShape {\n const shape = new EdgeShape(data.vertex1, data.vertex2);\n if (shape.m_hasVertex0) {\n shape.setPrevVertex(data.vertex0);\n }\n if (shape.m_hasVertex3) {\n shape.setNextVertex(data.vertex3);\n }\n return shape;\n }\n\n /** @hidden */\n _reset(): void {\n // noop\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n getType(): \"edge\" {\n return this.m_type;\n }\n\n /** @internal @deprecated */\n setNext(v?: Vec2Value): EdgeShape {\n return this.setNextVertex(v);\n }\n\n /**\n * Optional next vertex, used for smooth collision.\n */\n setNextVertex(v?: Vec2Value): EdgeShape {\n if (v) {\n this.m_vertex3.setVec2(v);\n this.m_hasVertex3 = true;\n } else {\n this.m_vertex3.setZero();\n this.m_hasVertex3 = false;\n }\n return this;\n }\n\n /**\n * Optional next vertex, used for smooth collision.\n */\n getNextVertex(): Vec2 {\n return this.m_vertex3;\n }\n\n /** @internal @deprecated */\n setPrev(v?: Vec2Value): EdgeShape {\n return this.setPrevVertex(v);\n }\n\n /**\n * Optional prev vertex, used for smooth collision.\n */\n setPrevVertex(v?: Vec2Value): EdgeShape {\n if (v) {\n this.m_vertex0.setVec2(v);\n this.m_hasVertex0 = true;\n } else {\n this.m_vertex0.setZero();\n this.m_hasVertex0 = false;\n }\n return this;\n }\n\n /**\n * Optional prev vertex, used for smooth collision.\n */\n getPrevVertex(): Vec2 {\n return this.m_vertex0;\n }\n\n /**\n * Set this as an isolated edge.\n */\n _set(v1: Vec2Value, v2: Vec2Value): EdgeShape {\n this.m_vertex1.setVec2(v1);\n this.m_vertex2.setVec2(v2);\n this.m_hasVertex0 = false;\n this.m_hasVertex3 = false;\n return this;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): EdgeShape {\n const clone = new EdgeShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_vertex1.setVec2(this.m_vertex1);\n clone.m_vertex2.setVec2(this.m_vertex2);\n clone.m_vertex0.setVec2(this.m_vertex0);\n clone.m_vertex3.setVec2(this.m_vertex3);\n clone.m_hasVertex0 = this.m_hasVertex0;\n clone.m_hasVertex3 = this.m_hasVertex3;\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): false {\n return false;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n // p = p1 + t * d\n // v = v1 + s * e\n // p1 + t * d = v1 + s * e\n // s * e - t * d = p1 - v1\n\n // NOT_USED(childIndex);\n\n // Put the ray into the edge's frame of reference.\n const p1 = Rot.mulTVec2(xf.q, Vec2.sub(input.p1, xf.p));\n const p2 = Rot.mulTVec2(xf.q, Vec2.sub(input.p2, xf.p));\n const d = Vec2.sub(p2, p1);\n\n const v1 = this.m_vertex1;\n const v2 = this.m_vertex2;\n const e = Vec2.sub(v2, v1);\n const normal = Vec2.neo(e.y, -e.x);\n normal.normalize();\n\n // q = p1 + t * d\n // dot(normal, q - v1) = 0\n // dot(normal, p1 - v1) + t * dot(normal, d) = 0\n const numerator = Vec2.dot(normal, Vec2.sub(v1, p1));\n const denominator = Vec2.dot(normal, d);\n\n if (denominator == 0.0) {\n return false;\n }\n\n const t = numerator / denominator;\n if (t < 0.0 || input.maxFraction < t) {\n return false;\n }\n\n const q = Vec2.add(p1, Vec2.mulNumVec2(t, d));\n\n // q = v1 + s * r\n // s = dot(q - v1, r) / dot(r, r)\n const r = Vec2.sub(v2, v1);\n const rr = Vec2.dot(r, r);\n if (rr == 0.0) {\n return false;\n }\n\n const s = Vec2.dot(Vec2.sub(q, v1), r) / rr;\n if (s < 0.0 || 1.0 < s) {\n return false;\n }\n\n output.fraction = t;\n if (numerator > 0.0) {\n output.normal = Rot.mulVec2(xf.q, normal).neg();\n } else {\n output.normal = Rot.mulVec2(xf.q, normal);\n }\n return true;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n matrix.transformVec2(v1, xf, this.m_vertex1);\n matrix.transformVec2(v2, xf, this.m_vertex2);\n\n AABB.combinePoints(aabb, v1, v2);\n AABB.extend(aabb, this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density?: number): void {\n massData.mass = 0.0;\n matrix.combine2Vec2(massData.center, 0.5, this.m_vertex1, 0.5, this.m_vertex2);\n massData.I = 0.0;\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n proxy.m_vertices[0] = this.m_vertex1;\n proxy.m_vertices[1] = this.m_vertex2;\n proxy.m_vertices.length = 2;\n proxy.m_count = 2;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Edge = EdgeShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport type { MassData } from \"../../dynamics/Body\";\nimport { AABBValue, RayCastOutput, RayCastInput, AABB } from \"../AABB\";\nimport { DistanceProxy } from \"../Distance\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Shape } from \"../Shape\";\nimport { EdgeShape } from \"./EdgeShape\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const v2 = matrix.vec2(0, 0);\n\ndeclare module \"./ChainShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function ChainShape(vertices?: Vec2Value[], loop?: boolean): ChainShape;\n}\n\n/**\n * A chain shape is a free form sequence of line segments. The chain has\n * two-sided collision, so you can use inside and outside collision. Therefore,\n * you may use any winding order. Connectivity information is used to create\n * smooth collisions.\n *\n * WARNING: The chain will not collide properly if there are self-intersections.\n */\n// @ts-expect-error\nexport class ChainShape extends Shape {\n static TYPE = \"chain\" as const;\n /** @hidden */ m_type: \"chain\";\n\n /** @hidden */ m_radius: number;\n\n /** @hidden */ m_vertices: Vec2[];\n /** @hidden */ m_count: number;\n /** @hidden */ m_prevVertex: Vec2 | null;\n /** @hidden */ m_nextVertex: Vec2 | null;\n /** @hidden */ m_hasPrevVertex: boolean;\n /** @hidden */ m_hasNextVertex: boolean;\n\n /** @hidden */ m_isLoop: boolean;\n\n constructor(vertices?: Vec2Value[], loop?: boolean) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof ChainShape)) {\n return new ChainShape(vertices, loop);\n }\n\n super();\n\n this.m_type = ChainShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n this.m_vertices = [];\n this.m_count = 0;\n this.m_prevVertex = null;\n this.m_nextVertex = null;\n this.m_hasPrevVertex = false;\n this.m_hasNextVertex = false;\n\n this.m_isLoop = !!loop;\n\n if (vertices && vertices.length) {\n if (loop) {\n this._createLoop(vertices);\n } else {\n this._createChain(vertices);\n }\n }\n }\n\n /** @internal */\n _serialize(): object {\n const data = {\n type: this.m_type,\n vertices: this.m_isLoop ? this.m_vertices.slice(0, this.m_vertices.length - 1) : this.m_vertices,\n isLoop: this.m_isLoop,\n hasPrevVertex: this.m_hasPrevVertex,\n hasNextVertex: this.m_hasNextVertex,\n prevVertex: null as Vec2 | null,\n nextVertex: null as Vec2 | null,\n };\n if (this.m_prevVertex) {\n data.prevVertex = this.m_prevVertex;\n }\n if (this.m_nextVertex) {\n data.nextVertex = this.m_nextVertex;\n }\n return data;\n }\n\n /** @internal */\n static _deserialize(data: any, fixture: any, restore: any): ChainShape {\n const vertices: Vec2[] = [];\n if (data.vertices) {\n for (let i = 0; i < data.vertices.length; i++) {\n vertices.push(restore(Vec2, data.vertices[i]));\n }\n }\n const shape = new ChainShape(vertices, data.isLoop);\n if (data.prevVertex) {\n shape.setPrevVertex(data.prevVertex);\n }\n if (data.nextVertex) {\n shape.setNextVertex(data.nextVertex);\n }\n return shape;\n }\n\n // clear() {\n // this.m_vertices.length = 0;\n // this.m_count = 0;\n // }\n\n getType(): \"chain\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n /**\n * @internal\n * Create a loop. This automatically adjusts connectivity.\n *\n * @param vertices an array of vertices, these are copied\n */\n _createLoop(vertices: Vec2Value[]): ChainShape {\n if (_ASSERT) console.assert(this.m_vertices.length == 0 && this.m_count == 0);\n if (_ASSERT) console.assert(vertices.length >= 3);\n if (vertices.length < 3) {\n return;\n }\n\n for (let i = 1; i < vertices.length; ++i) {\n const v1 = vertices[i - 1];\n const v2 = vertices[i];\n // If the code crashes here, it means your vertices are too close together.\n if (_ASSERT) console.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);\n }\n\n this.m_vertices = [];\n this.m_count = vertices.length + 1;\n for (let i = 0; i < vertices.length; ++i) {\n this.m_vertices[i] = Vec2.clone(vertices[i]);\n }\n this.m_vertices[vertices.length] = Vec2.clone(vertices[0]);\n\n this.m_prevVertex = this.m_vertices[this.m_count - 2];\n this.m_nextVertex = this.m_vertices[1];\n this.m_hasPrevVertex = true;\n this.m_hasNextVertex = true;\n return this;\n }\n\n /**\n * @internal\n * Create a chain with isolated end vertices.\n *\n * @param vertices an array of vertices, these are copied\n */\n _createChain(vertices: Vec2Value[]): ChainShape {\n if (_ASSERT) console.assert(this.m_vertices.length == 0 && this.m_count == 0);\n if (_ASSERT) console.assert(vertices.length >= 2);\n for (let i = 1; i < vertices.length; ++i) {\n const v1 = vertices[i - 1];\n const v2 = vertices[i];\n // If the code crashes here, it means your vertices are too close together.\n if (_ASSERT) console.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);\n }\n\n this.m_vertices = [];\n this.m_count = vertices.length;\n for (let i = 0; i < vertices.length; ++i) {\n this.m_vertices[i] = Vec2.clone(vertices[i]);\n }\n\n this.m_prevVertex = null;\n this.m_nextVertex = null;\n this.m_hasPrevVertex = false;\n this.m_hasNextVertex = false;\n return this;\n }\n\n /** @hidden */\n _reset(): void {\n if (this.m_isLoop) {\n this._createLoop(this.m_vertices.slice(0, this.m_vertices.length - 1));\n } else {\n this._createChain(this.m_vertices);\n }\n }\n\n /**\n * Establish connectivity to a vertex that precedes the first vertex. Don't call\n * this for loops.\n */\n setPrevVertex(prevVertex: Vec2): void {\n // todo: copy or reference\n this.m_prevVertex = prevVertex;\n this.m_hasPrevVertex = true;\n }\n\n getPrevVertex(): Vec2 {\n return this.m_prevVertex;\n }\n\n /**\n * Establish connectivity to a vertex that follows the last vertex. Don't call\n * this for loops.\n */\n setNextVertex(nextVertex: Vec2): void {\n // todo: copy or reference\n this.m_nextVertex = nextVertex;\n this.m_hasNextVertex = true;\n }\n\n getNextVertex(): Vec2 {\n return this.m_nextVertex;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): ChainShape {\n const clone = new ChainShape();\n clone._createChain(this.m_vertices);\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_prevVertex = this.m_prevVertex;\n clone.m_nextVertex = this.m_nextVertex;\n clone.m_hasPrevVertex = this.m_hasPrevVertex;\n clone.m_hasNextVertex = this.m_hasNextVertex;\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): number {\n // edge count = vertex count - 1\n return this.m_count - 1;\n }\n\n // Get a child edge.\n getChildEdge(edge: EdgeShape, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count - 1);\n edge.m_type = EdgeShape.TYPE;\n edge.m_radius = this.m_radius;\n\n edge.m_vertex1 = this.m_vertices[childIndex];\n edge.m_vertex2 = this.m_vertices[childIndex + 1];\n\n if (childIndex > 0) {\n edge.m_vertex0 = this.m_vertices[childIndex - 1];\n edge.m_hasVertex0 = true;\n } else {\n edge.m_vertex0 = this.m_prevVertex;\n edge.m_hasVertex0 = this.m_hasPrevVertex;\n }\n\n if (childIndex < this.m_count - 2) {\n edge.m_vertex3 = this.m_vertices[childIndex + 2];\n edge.m_hasVertex3 = true;\n } else {\n edge.m_vertex3 = this.m_nextVertex;\n edge.m_hasVertex3 = this.m_hasNextVertex;\n }\n }\n\n getVertex(index: number): Vec2 {\n if (_ASSERT) console.assert(0 <= index && index <= this.m_count);\n if (index < this.m_count) {\n return this.m_vertices[index];\n } else {\n return this.m_vertices[0];\n }\n }\n\n isLoop(): boolean {\n return this.m_isLoop;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * This always return false.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): false {\n return false;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n\n const edgeShape = new EdgeShape(this.getVertex(childIndex), this.getVertex(childIndex + 1));\n return edgeShape.rayCast(output, input, xf, 0);\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n\n matrix.transformVec2(v1, xf, this.getVertex(childIndex));\n matrix.transformVec2(v2, xf, this.getVertex(childIndex + 1));\n\n AABB.combinePoints(aabb, v1, v2);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * Chains have zero mass.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density?: number): void {\n massData.mass = 0.0;\n matrix.zeroVec2(massData.center);\n massData.I = 0.0;\n }\n\n computeDistanceProxy(proxy: DistanceProxy, childIndex: number): void {\n if (_ASSERT) console.assert(0 <= childIndex && childIndex < this.m_count);\n proxy.m_vertices[0] = this.getVertex(childIndex);\n proxy.m_vertices[1] = this.getVertex(childIndex + 1);\n proxy.m_count = 2;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Chain = ChainShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport type { MassData } from \"../../dynamics/Body\";\nimport { RayCastOutput, RayCastInput, AABBValue } from \"../AABB\";\nimport { DistanceProxy } from \"../Distance\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Shape } from \"../Shape\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const e = matrix.vec2(0, 0);\n/** @internal */ const e1 = matrix.vec2(0, 0);\n/** @internal */ const e2 = matrix.vec2(0, 0);\n/** @internal */ const center = matrix.vec2(0, 0);\n/** @internal */ const s = matrix.vec2(0, 0);\n\ndeclare module \"./PolygonShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PolygonShape(vertices?: Vec2Value[]): PolygonShape;\n}\n\n/**\n * A convex polygon. It is assumed that the interior of the polygon is to the\n * left of each edge. Polygons have a maximum number of vertices equal to\n * Settings.maxPolygonVertices. In most cases you should not need many vertices\n * for a convex polygon. extends Shape\n */\n// @ts-expect-error\nexport class PolygonShape extends Shape {\n static TYPE = \"polygon\" as const;\n /** @hidden */ m_type: \"polygon\";\n\n /** @hidden */ m_centroid: Vec2;\n /** @hidden */ m_vertices: Vec2[]; // [Settings.maxPolygonVertices]\n /** @hidden */ m_normals: Vec2[]; // [Settings.maxPolygonVertices]\n /** @hidden */ m_count: number;\n /** @hidden */ m_radius: number;\n\n constructor(vertices?: Vec2Value[]) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PolygonShape)) {\n return new PolygonShape(vertices);\n }\n\n super();\n\n this.m_type = PolygonShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n this.m_centroid = Vec2.zero();\n this.m_vertices = [];\n this.m_normals = [];\n this.m_count = 0;\n\n if (vertices && vertices.length) {\n this._set(vertices);\n }\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n vertices: this.m_vertices,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, fixture: any, restore: any): PolygonShape {\n const vertices: Vec2[] = [];\n if (data.vertices) {\n for (let i = 0; i < data.vertices.length; i++) {\n vertices.push(restore(Vec2, data.vertices[i]));\n }\n }\n\n const shape = new PolygonShape(vertices);\n return shape;\n }\n\n getType(): \"polygon\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): PolygonShape {\n const clone = new PolygonShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_count = this.m_count;\n clone.m_centroid.setVec2(this.m_centroid);\n for (let i = 0; i < this.m_count; i++) {\n clone.m_vertices.push(this.m_vertices[i].clone());\n }\n for (let i = 0; i < this.m_normals.length; i++) {\n clone.m_normals.push(this.m_normals[i].clone());\n }\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /** @hidden */\n _reset(): void {\n this._set(this.m_vertices);\n }\n\n /**\n * @internal\n *\n * Create a convex hull from the given array of local points. The count must be\n * in the range [3, Settings.maxPolygonVertices].\n *\n * Warning: the points may be re-ordered, even if they form a convex polygon\n * Warning: collinear points are handled but not removed. Collinear points may\n * lead to poor stacking behavior.\n */\n _set(vertices: Vec2Value[]): void {\n if (_ASSERT) console.assert(3 <= vertices.length && vertices.length <= Settings.maxPolygonVertices);\n if (vertices.length < 3) {\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n let n = math_min(vertices.length, Settings.maxPolygonVertices);\n\n // Perform welding and copy vertices into local buffer.\n const ps: Vec2[] = []; // [Settings.maxPolygonVertices];\n for (let i = 0; i < n; ++i) {\n const v = vertices[i];\n\n let unique = true;\n for (let j = 0; j < ps.length; ++j) {\n if (Vec2.distanceSquared(v, ps[j]) < 0.25 * Settings.linearSlopSquared) {\n unique = false;\n break;\n }\n }\n\n if (unique) {\n ps.push(Vec2.clone(v));\n }\n }\n\n n = ps.length;\n if (n < 3) {\n // Polygon is degenerate.\n if (_ASSERT) console.assert(false);\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n // Create the convex hull using the Gift wrapping algorithm\n // http://en.wikipedia.org/wiki/Gift_wrapping_algorithm\n\n // Find the right most point on the hull (in case of multiple points bottom most is used)\n let i0 = 0;\n let x0 = ps[0].x;\n for (let i = 1; i < n; ++i) {\n const x = ps[i].x;\n if (x > x0 || (x === x0 && ps[i].y < ps[i0].y)) {\n i0 = i;\n x0 = x;\n }\n }\n\n const hull = [] as number[]; // [Settings.maxPolygonVertices];\n let m = 0;\n let ih = i0;\n\n while (true) {\n if (_ASSERT) console.assert(m < Settings.maxPolygonVertices);\n hull[m] = ih;\n\n let ie = 0;\n for (let j = 1; j < n; ++j) {\n if (ie === ih) {\n ie = j;\n continue;\n }\n\n const r = Vec2.sub(ps[ie], ps[hull[m]]);\n const v = Vec2.sub(ps[j], ps[hull[m]]);\n const c = Vec2.crossVec2Vec2(r, v);\n // c < 0 means counter-clockwise wrapping, c > 0 means clockwise wrapping\n if (c < 0.0) {\n ie = j;\n }\n\n // Collinearity check\n if (c === 0.0 && v.lengthSquared() > r.lengthSquared()) {\n ie = j;\n }\n }\n\n ++m;\n ih = ie;\n\n if (ie === i0) {\n break;\n }\n }\n\n if (m < 3) {\n // Polygon is degenerate.\n if (_ASSERT) console.assert(false);\n this._setAsBox(1.0, 1.0);\n return;\n }\n\n this.m_count = m;\n\n // Copy vertices.\n this.m_vertices = [];\n for (let i = 0; i < m; ++i) {\n this.m_vertices[i] = ps[hull[i]];\n }\n\n // Compute normals. Ensure the edges have non-zero length.\n for (let i = 0; i < m; ++i) {\n const i1 = i;\n const i2 = i + 1 < m ? i + 1 : 0;\n const edge = Vec2.sub(this.m_vertices[i2], this.m_vertices[i1]);\n if (_ASSERT) console.assert(edge.lengthSquared() > EPSILON * EPSILON);\n this.m_normals[i] = Vec2.crossVec2Num(edge, 1.0);\n this.m_normals[i].normalize();\n }\n\n // Compute the polygon centroid.\n this.m_centroid = computeCentroid(this.m_vertices, m);\n }\n\n /** @internal */ _setAsBox(hx: number, hy: number, center?: Vec2Value, angle?: number): void {\n // start with right-bottom, counter-clockwise, as in Gift wrapping algorithm in PolygonShape._set()\n this.m_vertices[0] = Vec2.neo(hx, -hy);\n this.m_vertices[1] = Vec2.neo(hx, hy);\n this.m_vertices[2] = Vec2.neo(-hx, hy);\n this.m_vertices[3] = Vec2.neo(-hx, -hy);\n\n this.m_normals[0] = Vec2.neo(1.0, 0.0);\n this.m_normals[1] = Vec2.neo(0.0, 1.0);\n this.m_normals[2] = Vec2.neo(-1.0, 0.0);\n this.m_normals[3] = Vec2.neo(0.0, -1.0);\n\n this.m_count = 4;\n\n if (center && Vec2.isValid(center)) {\n angle = angle || 0;\n\n matrix.copyVec2(this.m_centroid, center);\n\n const xf = Transform.identity();\n xf.p.setVec2(center);\n xf.q.setAngle(angle);\n\n // Transform vertices and normals.\n for (let i = 0; i < this.m_count; ++i) {\n this.m_vertices[i] = Transform.mulVec2(xf, this.m_vertices[i]);\n this.m_normals[i] = Rot.mulVec2(xf.q, this.m_normals[i]);\n }\n }\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): boolean {\n const pLocal = matrix.detransformVec2(temp, xf, p);\n\n for (let i = 0; i < this.m_count; ++i) {\n const dot = matrix.dotVec2(this.m_normals[i], pLocal) - matrix.dotVec2(this.m_normals[i], this.m_vertices[i]);\n if (dot > 0.0) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n\n // Put the ray into the polygon's frame of reference.\n const p1 = Rot.mulTVec2(xf.q, Vec2.sub(input.p1, xf.p));\n const p2 = Rot.mulTVec2(xf.q, Vec2.sub(input.p2, xf.p));\n const d = Vec2.sub(p2, p1);\n\n let lower = 0.0;\n let upper = input.maxFraction;\n\n let index = -1;\n\n for (let i = 0; i < this.m_count; ++i) {\n // p = p1 + a * d\n // dot(normal, p - v) = 0\n // dot(normal, p1 - v) + a * dot(normal, d) = 0\n const numerator = Vec2.dot(this.m_normals[i], Vec2.sub(this.m_vertices[i], p1));\n const denominator = Vec2.dot(this.m_normals[i], d);\n\n if (denominator == 0.0) {\n if (numerator < 0.0) {\n return false;\n }\n } else {\n // Note: we want this predicate without division:\n // lower < numerator / denominator, where denominator < 0\n // Since denominator < 0, we have to flip the inequality:\n // lower < numerator / denominator <==> denominator * lower > numerator.\n if (denominator < 0.0 && numerator < lower * denominator) {\n // Increase lower.\n // The segment enters this half-space.\n lower = numerator / denominator;\n index = i;\n } else if (denominator > 0.0 && numerator < upper * denominator) {\n // Decrease upper.\n // The segment exits this half-space.\n upper = numerator / denominator;\n }\n }\n\n // The use of epsilon here causes the assert on lower to trip\n // in some cases. Apparently the use of epsilon was to make edge\n // shapes work, but now those are handled separately.\n // if (upper < lower - matrix.EPSILON)\n if (upper < lower) {\n return false;\n }\n }\n\n if (_ASSERT) console.assert(0.0 <= lower && lower <= input.maxFraction);\n\n if (index >= 0) {\n output.fraction = lower;\n output.normal = Rot.mulVec2(xf.q, this.m_normals[index]);\n return true;\n }\n\n return false;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (let i = 0; i < this.m_count; ++i) {\n const v = matrix.transformVec2(temp, xf, this.m_vertices[i]);\n minX = math_min(minX, v.x);\n maxX = math_max(maxX, v.x);\n minY = math_min(minY, v.y);\n maxY = math_max(maxY, v.y);\n }\n\n matrix.setVec2(aabb.lowerBound, minX - this.m_radius, minY - this.m_radius);\n matrix.setVec2(aabb.upperBound, maxX + this.m_radius, maxY + this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density: number): void {\n // Polygon mass, centroid, and inertia.\n // Let rho be the polygon density in mass per unit area.\n // Then:\n // mass = rho * int(dA)\n // centroid.x = (1/mass) * rho * int(x * dA)\n // centroid.y = (1/mass) * rho * int(y * dA)\n // I = rho * int((x*x + y*y) * dA)\n //\n // We can compute these integrals by summing all the integrals\n // for each triangle of the polygon. To evaluate the integral\n // for a single triangle, we make a change of variables to\n // the (u,v) coordinates of the triangle:\n // x = x0 + e1x * u + e2x * v\n // y = y0 + e1y * u + e2y * v\n // where 0 <= u && 0 <= v && u + v <= 1.\n //\n // We integrate u from [0,1-v] and then v from [0,1].\n // We also need to use the Jacobian of the transformation:\n // D = cross(e1, e2)\n //\n // Simplification: triangle centroid = (1/3) * (p1 + p2 + p3)\n //\n // The rest of the derivation is handled by computer algebra.\n\n if (_ASSERT) console.assert(this.m_count >= 3);\n\n matrix.zeroVec2(center);\n let area = 0.0;\n let I = 0.0;\n\n // s is the reference point for forming triangles.\n // It's location doesn't change the result (except for rounding error).\n matrix.zeroVec2(s);\n\n // This code would put the reference point inside the polygon.\n for (let i = 0; i < this.m_count; ++i) {\n matrix.plusVec2(s, this.m_vertices[i]);\n }\n matrix.scaleVec2(s, 1.0 / this.m_count, s);\n\n const k_inv3 = 1.0 / 3.0;\n\n for (let i = 0; i < this.m_count; ++i) {\n // Triangle vertices.\n matrix.subVec2(e1, this.m_vertices[i], s);\n if ( i + 1 < this.m_count) {\n matrix.subVec2(e2, this.m_vertices[i + 1], s);\n } else {\n matrix.subVec2(e2, this.m_vertices[0], s);\n }\n\n const D = matrix.crossVec2Vec2(e1, e2);\n\n const triangleArea = 0.5 * D;\n area += triangleArea;\n\n // Area weighted centroid\n matrix.combine2Vec2(temp, triangleArea * k_inv3, e1, triangleArea * k_inv3, e2);\n matrix.plusVec2(center, temp);\n\n const ex1 = e1.x;\n const ey1 = e1.y;\n const ex2 = e2.x;\n const ey2 = e2.y;\n\n const intx2 = ex1 * ex1 + ex2 * ex1 + ex2 * ex2;\n const inty2 = ey1 * ey1 + ey2 * ey1 + ey2 * ey2;\n\n I += (0.25 * k_inv3 * D) * (intx2 + inty2);\n }\n\n // Total mass\n massData.mass = density * area;\n\n // Center of mass\n if (_ASSERT) console.assert(area > EPSILON);\n matrix.scaleVec2(center, 1.0 / area, center);\n matrix.addVec2(massData.center, center, s);\n\n // Inertia tensor relative to the local origin (point s).\n massData.I = density * I;\n\n // Shift to center of mass then to original body origin.\n massData.I += massData.mass * (matrix.dotVec2(massData.center, massData.center) - matrix.dotVec2(center, center));\n }\n\n /**\n * Validate convexity. This is a very time consuming operation.\n * @returns true if valid\n */\n validate(): boolean {\n for (let i = 0; i < this.m_count; ++i) {\n const i1 = i;\n const i2 = i < this.m_count - 1 ? i1 + 1 : 0;\n const p = this.m_vertices[i1];\n matrix.subVec2(e, this.m_vertices[i2], p);\n\n for (let j = 0; j < this.m_count; ++j) {\n if (j == i1 || j == i2) {\n continue;\n }\n\n const c = matrix.crossVec2Vec2(e, matrix.subVec2(temp, this.m_vertices[j], p));\n if (c < 0.0) {\n return false;\n }\n }\n }\n\n return true;\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n for (let i = 0; i < this.m_count; ++i) {\n proxy.m_vertices[i] = this.m_vertices[i];\n }\n proxy.m_vertices.length = this.m_count;\n proxy.m_count = this.m_count;\n proxy.m_radius = this.m_radius;\n }\n}\n\n/** @internal */ function computeCentroid(vs: Vec2[], count: number): Vec2 {\n if (_ASSERT) console.assert(count >= 3);\n\n const c = Vec2.zero();\n let area = 0.0;\n\n // pRef is the reference point for forming triangles.\n // It's location doesn't change the result (except for rounding error).\n const pRef = Vec2.zero();\n if (false) {\n // This code would put the reference point inside the polygon.\n for (let i = 0; i < count; ++i) {\n pRef.add(vs[i]);\n }\n pRef.mul(1.0 / count);\n }\n\n const inv3 = 1.0 / 3.0;\n\n for (let i = 0; i < count; ++i) {\n // Triangle vertices.\n const p1 = pRef;\n const p2 = vs[i];\n const p3 = i + 1 < count ? vs[i + 1] : vs[0];\n\n const e1 = Vec2.sub(p2, p1);\n const e2 = Vec2.sub(p3, p1);\n\n const D = Vec2.crossVec2Vec2(e1, e2);\n\n const triangleArea = 0.5 * D;\n area += triangleArea;\n\n // Area weighted centroid\n matrix.combine3Vec2(temp, 1, p1, 1, p2, 1, p3);\n matrix.plusScaleVec2(c, triangleArea * inv3, temp);\n }\n\n // Centroid\n if (_ASSERT) console.assert(area > EPSILON);\n c.mul(1.0 / area);\n return c;\n}\n\nexport const Polygon = PolygonShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Rot } from \"../../common/Rot\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Shape } from \"../Shape\";\nimport { AABBValue, RayCastInput, RayCastOutput } from \"../AABB\";\nimport { Transform, TransformValue } from \"../../common/Transform\";\nimport { MassData } from \"../../dynamics/Body\";\nimport { DistanceProxy } from \"../Distance\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_sqrt = Math.sqrt;\n/** @internal */ const math_PI = Math.PI;\n\n/** @internal */ const temp = matrix.vec2(0, 0);\n\ndeclare module \"./CircleShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function CircleShape(position: Vec2Value, radius?: number): CircleShape;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function CircleShape(radius?: number): CircleShape;\n}\n\n/** Circle shape. */\n// @ts-expect-error\nexport class CircleShape extends Shape {\n static TYPE = \"circle\" as const;\n /** @hidden */ m_type: \"circle\";\n\n /** @hidden */ m_p: Vec2;\n /** @hidden */ m_radius: number;\n\n constructor(position: Vec2Value, radius?: number);\n constructor(radius?: number);\n constructor(a: any, b?: any) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof CircleShape)) {\n return new CircleShape(a, b);\n }\n\n super();\n\n this.m_type = CircleShape.TYPE;\n this.m_p = Vec2.zero();\n this.m_radius = 1;\n\n if (typeof a === \"object\" && Vec2.isValid(a)) {\n this.m_p.setVec2(a);\n\n if (typeof b === \"number\") {\n this.m_radius = b;\n }\n\n } else if (typeof a === \"number\") {\n this.m_radius = a;\n }\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n\n p: this.m_p,\n radius: this.m_radius,\n };\n }\n\n /** @internal */\n static _deserialize(data: any): CircleShape {\n return new CircleShape(data.p, data.radius);\n }\n\n /** @hidden */\n _reset(): void {\n // noop\n }\n\n getType(): \"circle\" {\n return this.m_type;\n }\n\n getRadius(): number {\n return this.m_radius;\n }\n\n getCenter(): Vec2 {\n return this.m_p;\n }\n\n /**\n * @internal @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\n _clone(): CircleShape {\n const clone = new CircleShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_p = this.m_p.clone();\n return clone;\n }\n\n /**\n * Get the number of child primitives.\n */\n getChildCount(): 1 {\n return 1;\n }\n\n /**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n *\n * @param xf The shape world transform.\n * @param p A point in world coordinates.\n */\n testPoint(xf: TransformValue, p: Vec2Value): boolean {\n const center = matrix.transformVec2(temp, xf, this.m_p);\n return matrix.distSqrVec2(p, center) <= this.m_radius * this.m_radius;\n }\n\n /**\n * Cast a ray against a child shape.\n *\n * @param output The ray-cast results.\n * @param input The ray-cast input parameters.\n * @param xf The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\n rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean {\n // Collision Detection in Interactive 3D Environments by Gino van den Bergen\n // From Section 3.1.2\n // x = s + a * r\n // norm(x) = radius\n\n const position = Vec2.add(xf.p, Rot.mulVec2(xf.q, this.m_p));\n const s = Vec2.sub(input.p1, position);\n const b = Vec2.dot(s, s) - this.m_radius * this.m_radius;\n\n // Solve quadratic equation.\n const r = Vec2.sub(input.p2, input.p1);\n const c = Vec2.dot(s, r);\n const rr = Vec2.dot(r, r);\n const sigma = c * c - rr * b;\n\n // Check for negative discriminant and short segment.\n if (sigma < 0.0 || rr < EPSILON) {\n return false;\n }\n\n // Find the point of intersection of the line with the circle.\n let a = -(c + math_sqrt(sigma));\n\n // Is the intersection point on the segment?\n if (0.0 <= a && a <= input.maxFraction * rr) {\n a /= rr;\n output.fraction = a;\n output.normal = Vec2.add(s, Vec2.mulNumVec2(a, r));\n output.normal.normalize();\n return true;\n }\n\n return false;\n }\n\n /**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n *\n * @param aabb Returns the axis aligned box.\n * @param xf The world transform of the shape.\n * @param childIndex The child shape\n */\n computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void {\n const p = matrix.transformVec2(temp, xf, this.m_p);\n\n matrix.setVec2(aabb.lowerBound, p.x - this.m_radius, p.y - this.m_radius);\n matrix.setVec2(aabb.upperBound, p.x + this.m_radius, p.y + this.m_radius);\n }\n\n /**\n * Compute the mass properties of this shape using its dimensions and density.\n * The inertia tensor is computed about the local origin.\n *\n * @param massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\n computeMass(massData: MassData, density: number): void {\n massData.mass = density * math_PI * this.m_radius * this.m_radius;\n matrix.copyVec2(massData.center, this.m_p);\n // inertia about the local origin\n massData.I = massData.mass * (0.5 * this.m_radius * this.m_radius + matrix.lengthSqrVec2(this.m_p));\n }\n\n computeDistanceProxy(proxy: DistanceProxy): void {\n proxy.m_vertices[0] = this.m_p;\n proxy.m_vertices.length = 1;\n proxy.m_count = 1;\n proxy.m_radius = this.m_radius;\n }\n}\n\nexport const Circle = CircleShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Distance joint definition. This requires defining an anchor point on both\n * bodies and the non-zero length of the distance joint. The definition uses\n * local anchor points so that the initial configuration can violate the\n * constraint slightly. This helps when saving and loading a game. Warning: Do\n * not use a zero or short length.\n */\nexport interface DistanceJointOpt extends JointOpt {\n /**\n * The mass-spring-damper frequency in Hertz. A value of 0 disables softness.\n */\n frequencyHz?: number;\n /**\n * The damping ratio. 0 = no damping, 1 = critical damping.\n */\n dampingRatio?: number;\n /**\n * Distance length.\n */\n length?: number;\n}\n/**\n * Distance joint definition. This requires defining an anchor point on both\n * bodies and the non-zero length of the distance joint. The definition uses\n * local anchor points so that the initial configuration can violate the\n * constraint slightly. This helps when saving and loading a game. Warning: Do\n * not use a zero or short length.\n */\nexport interface DistanceJointDef extends JointDef, DistanceJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n frequencyHz : 0.0,\n dampingRatio : 0.0\n};\n\ndeclare module \"./DistanceJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function DistanceJoint(def: DistanceJointDef): DistanceJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function DistanceJoint(def: DistanceJointOpt, bodyA: Body, bodyB: Body, anchorA: Vec2Value, anchorB: Vec2Value): DistanceJoint;\n}\n\n/**\n * A distance joint constrains two points on two bodies to remain at a fixed\n * distance from each other. You can view this as a massless, rigid rod.\n */\n// @ts-expect-error\nexport class DistanceJoint extends Joint {\n static TYPE = \"distance-joint\" as const;\n\n // Solver shared\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_length: number;\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_gamma: number;\n /** @internal */ m_bias: number;\n\n // Solver temp\n /** @internal */ m_u: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: number;\n\n /**\n * @param def DistanceJoint definition.\n */\n constructor(def: DistanceJointDef);\n /**\n * @param anchorA Anchor A in global coordination.\n * @param anchorB Anchor B in global coordination.\n */\n constructor(def: DistanceJointOpt, bodyA: Body, bodyB: Body, anchorA?: Vec2Value, anchorB?: Vec2Value);\n constructor(def: DistanceJointDef, bodyA?: Body, bodyB?: Body, anchorA?: Vec2Value, anchorB?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof DistanceJoint)) {\n return new DistanceJoint(def, bodyA, bodyB, anchorA, anchorB);\n }\n\n // order of constructor arguments is changed in v0.2\n if (bodyB && anchorA && (\"m_type\" in anchorA) && (\"x\" in bodyB) && (\"y\" in bodyB)) {\n const temp = bodyB;\n bodyB = anchorA as any as Body;\n anchorA = temp as any as Vec2;\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = DistanceJoint.TYPE;\n\n // Solver shared\n this.m_localAnchorA = Vec2.clone(anchorA ? bodyA.getLocalPoint(anchorA) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchorB ? bodyB.getLocalPoint(anchorB) : def.localAnchorB || Vec2.zero());\n this.m_length = Number.isFinite(def.length) ? def.length :\n Vec2.distance(bodyA.getWorldPoint(this.m_localAnchorA), bodyB.getWorldPoint(this.m_localAnchorB));\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n this.m_impulse = 0.0;\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n\n // 1-D constrained system\n // m (v2 - v1) = lambda\n // v2 + (beta/h) * x1 + gamma * lambda = 0, gamma has units of inverse mass.\n // x2 = x1 + h * v2\n\n // 1-D mass-damper-spring system\n // m (v2 - v1) + h * d * v2 + h * k *\n\n // C = norm(p2 - p1) - L\n // u = (p2 - p1) / norm(p2 - p1)\n // Cdot = dot(u, v2 + cross(w2, r2) - v1 - cross(w1, r1))\n // J = [-u -cross(r1, u) u cross(r2, u)]\n // K = J * invM * JT\n // = invMass1 + invI1 * cross(r1, u)^2 + invMass2 + invI2 * cross(r2, u)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n length: this.m_length,\n\n impulse: this.m_impulse,\n gamma: this.m_gamma,\n bias: this.m_bias,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): DistanceJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new DistanceJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n\n if (def.length > 0) {\n this.m_length = +def.length;\n } else if (def.length < 0) { // don't change length\n } else if (def.anchorA || def.anchorA || def.anchorA || def.anchorA) {\n this.m_length = Vec2.distance(\n this.m_bodyA.getWorldPoint(this.m_localAnchorA),\n this.m_bodyB.getWorldPoint(this.m_localAnchorB)\n );\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the natural length. Manipulating the length can lead to non-physical\n * behavior when the frequency is zero.\n */\n setLength(length: number): void {\n this.m_length = length;\n }\n\n /**\n * Get the natural length.\n */\n getLength(): number {\n return this.m_length;\n }\n\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_u).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n this.m_u = Vec2.sub(Vec2.add(cB, this.m_rB), Vec2.add(cA, this.m_rA));\n\n // Handle singularity.\n const length = this.m_u.length();\n if (length > Settings.linearSlop) {\n this.m_u.mul(1.0 / length);\n } else {\n this.m_u.setNum(0.0, 0.0);\n }\n\n const crAu = Vec2.crossVec2Vec2(this.m_rA, this.m_u);\n const crBu = Vec2.crossVec2Vec2(this.m_rB, this.m_u);\n let invMass = this.m_invMassA + this.m_invIA * crAu * crAu + this.m_invMassB + this.m_invIB * crBu * crBu;\n\n // Compute the effective mass matrix.\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n\n if (this.m_frequencyHz > 0.0) {\n const C = length - this.m_length;\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * this.m_mass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = this.m_mass * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (d + h * k);\n this.m_gamma = this.m_gamma != 0.0 ? 1.0 / this.m_gamma : 0.0;\n this.m_bias = C * h * k * this.m_gamma;\n\n invMass += this.m_gamma;\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n } else {\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n }\n\n if (step.warmStarting) {\n // Scale the impulse to support a variable time step.\n this.m_impulse *= step.dtRatio;\n\n const P = Vec2.mulNumVec2(this.m_impulse, this.m_u);\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Cdot = dot(u, v + cross(w, r))\n const vpA = Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA));\n const vpB = Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB));\n const Cdot = Vec2.dot(this.m_u, vpB) - Vec2.dot(this.m_u, vpA);\n\n const impulse = -this.m_mass * (Cdot + this.m_bias + this.m_gamma * this.m_impulse);\n this.m_impulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_u);\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n if (this.m_frequencyHz > 0.0) {\n // There is no position correction for soft distance constraints.\n return true;\n }\n\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n const u = Vec2.sub(Vec2.add(cB, rB), Vec2.add(cA, rA));\n\n const length = u.normalize();\n const C = clamp(length - this.m_length, -Settings.maxLinearCorrection, Settings.maxLinearCorrection);\n\n const impulse = -this.m_mass * C;\n const P = Vec2.mulNumVec2(impulse, u);\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * Vec2.crossVec2Vec2(rA, P);\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, P);\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return math_abs(C) < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Friction joint definition.\n */\nexport interface FrictionJointOpt extends JointOpt {\n /**\n * The maximum friction force in N.\n */\n maxForce?: number;\n /**\n * The maximum friction torque in N-m.\n */\n maxTorque?: number;\n}\n\n/**\n * Friction joint definition.\n */\nexport interface FrictionJointDef extends JointDef, FrictionJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 0.0,\n maxTorque : 0.0,\n};\n\ndeclare module \"./FrictionJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function FrictionJoint(def: FrictionJointDef): FrictionJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function FrictionJoint(def: FrictionJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): FrictionJoint;\n}\n\n/**\n * Friction joint. This is used for top-down friction. It provides 2D\n * translational friction and angular friction.\n */\n// @ts-expect-error\nexport class FrictionJoint extends Joint {\n static TYPE = \"friction-joint\" as const;\n\n /** @internal */ m_type: \"friction-joint\";\n\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n\n // Solver shared\n /** @internal */ m_linearImpulse: Vec2;\n /** @internal */ m_angularImpulse: number;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_maxTorque: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_linearMass: Mat22;\n /** @internal */ m_angularMass: number;\n\n constructor(def: FrictionJointDef);\n /**\n * @param anchor Anchor in global coordination.\n */\n constructor(def: FrictionJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: FrictionJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof FrictionJoint)) {\n return new FrictionJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = FrictionJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n\n // Solver shared\n this.m_linearImpulse = Vec2.zero();\n this.m_angularImpulse = 0.0;\n this.m_maxForce = def.maxForce;\n this.m_maxTorque = def.maxTorque;\n\n // Point-to-point constraint\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Angle constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n maxForce: this.m_maxForce,\n maxTorque: this.m_maxTorque,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): FrictionJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new FrictionJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.maxTorque)) {\n this.m_maxTorque = def.maxTorque;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the maximum friction force in N.\n */\n setMaxForce(force: number): void {\n if (_ASSERT) console.assert(Number.isFinite(force) && force >= 0.0);\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum friction force in N.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the maximum friction torque in N*m.\n */\n setMaxTorque(torque: number): void {\n if (_ASSERT) console.assert(Number.isFinite(torque) && torque >= 0.0);\n this.m_maxTorque = torque;\n }\n\n /**\n * Get the maximum friction torque in N*m.\n */\n getMaxTorque(): number {\n return this.m_maxTorque;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_linearImpulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_angularImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective mass matrix.\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat22();\n K.ex.x = mA + mB + iA * this.m_rA.y * this.m_rA.y + iB * this.m_rB.y\n * this.m_rB.y;\n K.ex.y = -iA * this.m_rA.x * this.m_rA.y - iB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * this.m_rA.x * this.m_rA.x + iB * this.m_rB.x\n * this.m_rB.x;\n\n this.m_linearMass = K.getInverse();\n\n this.m_angularMass = iA + iB;\n if (this.m_angularMass > 0.0) {\n this.m_angularMass = 1.0 / this.m_angularMass;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_linearImpulse.mul(step.dtRatio);\n this.m_angularImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_linearImpulse.x, this.m_linearImpulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_angularImpulse);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_angularImpulse);\n\n } else {\n this.m_linearImpulse.setZero();\n this.m_angularImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const h = step.dt;\n\n // Solve angular friction\n {\n const Cdot = wB - wA;\n let impulse = -this.m_angularMass * Cdot;\n\n const oldImpulse = this.m_angularImpulse;\n const maxImpulse = h * this.m_maxTorque;\n this.m_angularImpulse = clamp(this.m_angularImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_angularImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve linear friction\n {\n const Cdot = Vec2.sub(\n Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB)),\n Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA))\n );\n\n let impulse = Vec2.neg(Mat22.mulVec2(this.m_linearMass, Cdot));\n const oldImpulse = this.m_linearImpulse;\n this.m_linearImpulse.add(impulse);\n\n const maxImpulse = h * this.m_maxForce;\n\n if (this.m_linearImpulse.lengthSquared() > maxImpulse * maxImpulse) {\n this.m_linearImpulse.normalize();\n this.m_linearImpulse.mul(maxImpulse);\n }\n\n impulse = Vec2.sub(this.m_linearImpulse, oldImpulse);\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Vec2, Vec2Value } from \"./Vec2\";\nimport { Vec3, Vec3Value } from \"./Vec3\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\n/**\n * A 3-by-3 matrix. Stored in column-major order.\n */\nexport class Mat33 {\n ex: Vec3;\n ey: Vec3;\n ez: Vec3;\n\n constructor(a: Vec3Value, b: Vec3Value, c: Vec3Value);\n constructor();\n constructor(a?: Vec3Value, b?: Vec3Value, c?: Vec3Value) {\n if (typeof a === \"object\" && a !== null) {\n this.ex = Vec3.clone(a);\n this.ey = Vec3.clone(b);\n this.ez = Vec3.clone(c);\n } else {\n this.ex = Vec3.zero();\n this.ey = Vec3.zero();\n this.ez = Vec3.zero();\n }\n }\n\n /** @hidden */\n toString(): string {\n return JSON.stringify(this);\n }\n\n static isValid(obj: any): boolean {\n if (obj === null || typeof obj === \"undefined\") {\n return false;\n }\n return Vec3.isValid(obj.ex) && Vec3.isValid(obj.ey) && Vec3.isValid(obj.ez);\n }\n\n static assert(o: any): void {\n if (_ASSERT) console.assert(!Mat33.isValid(o), \"Invalid Mat33!\", o);\n }\n\n /**\n * Set this matrix to all zeros.\n */\n setZero(): Mat33 {\n this.ex.setZero();\n this.ey.setZero();\n this.ez.setZero();\n return this;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases.\n */\n solve33(v: Vec3Value): Vec3 {\n // let det = matrix.dotVec3(this.ex, matrix.newCrossVec3(this.ey, this.ez));\n let cross_x = this.ey.y * this.ez.z - this.ey.z * this.ez.y;\n let cross_y = this.ey.z * this.ez.x - this.ey.x * this.ez.z;\n let cross_z = this.ey.x * this.ez.y - this.ey.y * this.ez.x;\n let det = this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const r = new Vec3();\n // r.x = det * matrix.dotVec3(v, matrix.newCrossVec3(this.ey, this.ez));\n cross_x = this.ey.y * this.ez.z - this.ey.z * this.ez.y;\n cross_y = this.ey.z * this.ez.x - this.ey.x * this.ez.z;\n cross_z = this.ey.x * this.ez.y - this.ey.y * this.ez.x;\n r.x = det * (v.x * cross_x + v.y * cross_y + v.z * cross_z);\n\n // r.y = det * matrix.dotVec3(this.ex, matrix.newCrossVec3(v, this.ez));\n cross_x = v.y * this.ez.z - v.z * this.ez.y;\n cross_y = v.z * this.ez.x - v.x * this.ez.z;\n cross_z = v.x * this.ez.y - v.y * this.ez.x;\n r.y = det * (this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z);\n\n // r.z = det * matrix.dotVec3(this.ex, matrix.newCrossVec3(this.ey, v));\n cross_x = this.ey.y * v.z - this.ey.z * v.y;\n cross_y = this.ey.z * v.x - this.ey.x * v.z;\n cross_z = this.ey.x * v.y - this.ey.y * v.x;\n r.z = det * (this.ex.x * cross_x + this.ex.y * cross_y + this.ex.z * cross_z);\n return r;\n }\n\n /**\n * Solve A * x = b, where b is a column vector. This is more efficient than\n * computing the inverse in one-shot cases. Solve only the upper 2-by-2 matrix\n * equation.\n */\n solve22(v: Vec2Value): Vec2 {\n const a11 = this.ex.x;\n const a12 = this.ey.x;\n const a21 = this.ex.y;\n const a22 = this.ey.y;\n let det = a11 * a22 - a12 * a21;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const r = Vec2.zero();\n r.x = det * (a22 * v.x - a12 * v.y);\n r.y = det * (a11 * v.y - a21 * v.x);\n return r;\n }\n\n /**\n * Get the inverse of this matrix as a 2-by-2. Returns the zero matrix if\n * singular.\n */\n getInverse22(M: Mat33): void {\n const a = this.ex.x;\n const b = this.ey.x;\n const c = this.ex.y;\n const d = this.ey.y;\n let det = a * d - b * c;\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n M.ex.x = det * d;\n M.ey.x = -det * b;\n M.ex.z = 0.0;\n M.ex.y = -det * c;\n M.ey.y = det * a;\n M.ey.z = 0.0;\n M.ez.x = 0.0;\n M.ez.y = 0.0;\n M.ez.z = 0.0;\n }\n\n /**\n * Get the symmetric inverse of this matrix as a 3-by-3. Returns the zero matrix\n * if singular.\n */\n getSymInverse33(M: Mat33): void {\n let det = Vec3.dot(this.ex, Vec3.cross(this.ey, this.ez));\n if (det !== 0.0) {\n det = 1.0 / det;\n }\n const a11 = this.ex.x;\n const a12 = this.ey.x;\n const a13 = this.ez.x;\n const a22 = this.ey.y;\n const a23 = this.ez.y;\n const a33 = this.ez.z;\n\n M.ex.x = det * (a22 * a33 - a23 * a23);\n M.ex.y = det * (a13 * a23 - a12 * a33);\n M.ex.z = det * (a12 * a23 - a13 * a22);\n\n M.ey.x = M.ex.y;\n M.ey.y = det * (a11 * a33 - a13 * a13);\n M.ey.z = det * (a13 * a12 - a11 * a23);\n\n M.ez.x = M.ex.z;\n M.ez.y = M.ey.z;\n M.ez.z = det * (a11 * a22 - a12 * a12);\n }\n\n /**\n * Multiply a matrix times a vector.\n */\n static mul(a: Mat33, b: Vec2Value): Vec2;\n static mul(a: Mat33, b: Vec3Value): Vec3;\n static mul(a, b) {\n if (_ASSERT) Mat33.assert(a);\n if (b && \"z\" in b && \"y\" in b && \"x\" in b) {\n if (_ASSERT) Vec3.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y + a.ez.x * b.z;\n const y = a.ex.y * b.x + a.ey.y * b.y + a.ez.y * b.z;\n const z = a.ex.z * b.x + a.ey.z * b.y + a.ez.z * b.z;\n return new Vec3(x, y, z);\n\n } else if (b && \"y\" in b && \"x\" in b) {\n if (_ASSERT) Vec2.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y;\n const y = a.ex.y * b.x + a.ey.y * b.y;\n return Vec2.neo(x, y);\n }\n\n if (_ASSERT) console.assert(false);\n }\n\n static mulVec3(a: Mat33, b: Vec3Value): Vec3 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Vec3.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y + a.ez.x * b.z;\n const y = a.ex.y * b.x + a.ey.y * b.y + a.ez.y * b.z;\n const z = a.ex.z * b.x + a.ey.z * b.y + a.ez.z * b.z;\n return new Vec3(x, y, z);\n }\n\n static mulVec2(a: Mat33, b: Vec2Value): Vec2 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Vec2.assert(b);\n const x = a.ex.x * b.x + a.ey.x * b.y;\n const y = a.ex.y * b.x + a.ey.y * b.y;\n return Vec2.neo(x, y);\n }\n\n static add(a: Mat33, b: Mat33): Mat33 {\n if (_ASSERT) Mat33.assert(a);\n if (_ASSERT) Mat33.assert(b);\n return new Mat33(\n Vec3.add(a.ex, b.ex),\n Vec3.add(a.ey, b.ey),\n Vec3.add(a.ez, b.ez)\n );\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n\n\n// todo: use string?\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3,\n} \n\n/**\n * Revolute joint definition. This requires defining an anchor point where the\n * bodies are joined. The definition uses local anchor points so that the\n * initial configuration can violate the constraint slightly. You also need to\n * specify the initial relative angle for joint limits. This helps when saving\n * and loading a game.\n *\n * The local anchor points are measured from the body's origin rather than the\n * center of mass because: 1. you might not know where the center of mass will\n * be. 2. if you add/remove shapes from a body and recompute the mass, the\n * joints will be broken.\n */\nexport interface RevoluteJointOpt extends JointOpt {\n /**\n * The lower angle for the joint limit (radians).\n */\n lowerAngle?: number;\n /**\n * The upper angle for the joint limit (radians).\n */\n upperAngle?: number;\n /**\n * The maximum motor torque used to achieve the desired motor speed. Usually\n * in N-m.\n */\n maxMotorTorque?: number;\n /**\n * The desired motor speed. Usually in radians per second.\n */\n motorSpeed?: number;\n /**\n * A flag to enable joint limits.\n */\n enableLimit?: boolean;\n /**\n * A flag to enable the joint motor.\n */\n enableMotor?: boolean;\n}\n\n/**\n * Revolute joint definition. This requires defining an anchor point where the\n * bodies are joined. The definition uses local anchor points so that the\n * initial configuration can violate the constraint slightly. You also need to\n * specify the initial relative angle for joint limits. This helps when saving\n * and loading a game.\n *\n * The local anchor points are measured from the body's origin rather than the\n * center of mass because: 1. you might not know where the center of mass will\n * be. 2. if you add/remove shapes from a body and recompute the mass, the\n * joints will be broken.\n */\nexport interface RevoluteJointDef extends JointDef, RevoluteJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The bodyB angle minus bodyA angle in the reference state (radians).\n */\n referenceAngle?: number;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n lowerAngle : 0.0,\n upperAngle : 0.0,\n maxMotorTorque : 0.0,\n motorSpeed : 0.0,\n enableLimit : false,\n enableMotor : false\n};\n\ndeclare module \"./RevoluteJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RevoluteJoint(def: RevoluteJointDef): RevoluteJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RevoluteJoint(def: RevoluteJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): RevoluteJoint;\n}\n\n/**\n * A revolute joint constrains two bodies to share a common point while they are\n * free to rotate about the point. The relative rotation about the shared point\n * is the joint angle. You can limit the relative rotation with a joint limit\n * that specifies a lower and upper angle. You can use a motor to drive the\n * relative rotation about the shared point. A maximum motor torque is provided\n * so that infinite forces are not generated.\n */\n// @ts-expect-error\nexport class RevoluteJoint extends Joint {\n static TYPE = \"revolute-joint\" as const;\n\n /** @internal */ m_type: \"revolute-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngle: number;\n /** @internal */ m_impulse: Vec3;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_lowerAngle: number;\n /** @internal */ m_upperAngle: number;\n /** @internal */ m_maxMotorTorque: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableLimit: boolean;\n /** @internal */ m_enableMotor: boolean;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n // effective mass for point-to-point constraint.\n /** @internal */ m_mass: Mat33;\n // effective mass for motor/limit angular constraint.\n /** @internal */ m_motorMass: number;\n /** @internal */ m_limitState: number;\n\n constructor(def: RevoluteJointDef);\n constructor(def: RevoluteJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: RevoluteJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof RevoluteJoint)) {\n return new RevoluteJoint(def, bodyA, bodyB, anchor);\n }\n\n def = def ?? {} as RevoluteJointDef;\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_mass = new Mat33();\n this.m_limitState = LimitState.inactiveLimit;\n\n this.m_type = RevoluteJoint.TYPE;\n\n if (Vec2.isValid(anchor)) {\n this.m_localAnchorA = bodyA.getLocalPoint(anchor);\n } else if (Vec2.isValid(def.localAnchorA)) {\n this.m_localAnchorA = Vec2.clone(def.localAnchorA);\n } else {\n this.m_localAnchorA = Vec2.zero();\n }\n\n if (Vec2.isValid(anchor)) {\n this.m_localAnchorB = bodyB.getLocalPoint(anchor);\n } else if (Vec2.isValid(def.localAnchorB)) {\n this.m_localAnchorB = Vec2.clone(def.localAnchorB);\n } else {\n this.m_localAnchorB = Vec2.zero();\n }\n\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n } else {\n this.m_referenceAngle = bodyB.getAngle() - bodyA.getAngle();\n }\n\n this.m_impulse = new Vec3();\n this.m_motorImpulse = 0.0;\n\n this.m_lowerAngle = def.lowerAngle ?? DEFAULTS.lowerAngle;\n this.m_upperAngle = def.upperAngle ?? DEFAULTS.upperAngle;\n this.m_maxMotorTorque = def.maxMotorTorque ?? DEFAULTS.maxMotorTorque;\n this.m_motorSpeed = def.motorSpeed ?? DEFAULTS.motorSpeed;\n this.m_enableLimit = def.enableLimit ?? DEFAULTS.enableLimit;\n this.m_enableMotor = def.enableMotor ?? DEFAULTS.enableMotor;\n\n // Point-to-point constraint\n // C = p2 - p1\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Motor constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n lowerAngle: this.m_lowerAngle,\n upperAngle: this.m_upperAngle,\n maxMotorTorque: this.m_maxMotorTorque,\n motorSpeed: this.m_motorSpeed,\n enableLimit: this.m_enableLimit,\n enableMotor: this.m_enableMotor,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any):RevoluteJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new RevoluteJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n }\n if (def.enableLimit !== undefined) {\n this.m_enableLimit = def.enableLimit;\n }\n if (Number.isFinite(def.lowerAngle)) {\n this.m_lowerAngle = def.lowerAngle;\n }\n if (Number.isFinite(def.upperAngle)) {\n this.m_upperAngle = def.upperAngle;\n }\n if (Number.isFinite(def.maxMotorTorque)) {\n this.m_maxMotorTorque = def.maxMotorTorque;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n if (def.enableMotor !== undefined) {\n this.m_enableMotor = def.enableMotor;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Get the current joint angle in radians.\n */\n getJointAngle(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n return bB.m_sweep.a - bA.m_sweep.a - this.m_referenceAngle;\n }\n\n /**\n * Get the current joint angle speed in radians per second.\n */\n getJointSpeed(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n return bB.m_angularVelocity - bA.m_angularVelocity;\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Get the current motor torque given the inverse time step. Unit is N*m.\n */\n getMotorTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Set the motor speed in radians per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Get the motor speed in radians per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Set the maximum motor torque, usually in N-m.\n */\n setMaxMotorTorque(torque: number): void {\n if (torque == this.m_maxMotorTorque) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorTorque = torque;\n }\n\n getMaxMotorTorque(): number {\n return this.m_maxMotorTorque;\n }\n\n /**\n * Is the joint limit enabled?\n */\n isLimitEnabled(): boolean {\n return this.m_enableLimit;\n }\n\n /**\n * Enable/disable the joint limit.\n */\n enableLimit(flag: boolean): void {\n if (flag != this.m_enableLimit) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableLimit = flag;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Get the lower joint limit in radians.\n */\n getLowerLimit(): number {\n return this.m_lowerAngle;\n }\n\n /**\n * Get the upper joint limit in radians.\n */\n getUpperLimit(): number {\n return this.m_upperAngle;\n }\n\n /**\n * Set the joint limits in radians.\n */\n setLimits(lower: number, upper: number): void {\n if (_ASSERT) console.assert(lower <= upper);\n\n if (lower != this.m_lowerAngle || upper != this.m_upperAngle) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_impulse.z = 0.0;\n this.m_lowerAngle = lower;\n this.m_upperAngle = upper;\n }\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force given the inverse time step. Unit is N.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.neo(this.m_impulse.x, this.m_impulse.y).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque due to the joint limit given the inverse time step.\n * Unit is N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.z;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const fixedRotation = (iA + iB === 0.0);\n\n this.m_mass.ex.x = mA + mB + this.m_rA.y * this.m_rA.y * iA + this.m_rB.y * this.m_rB.y * iB;\n this.m_mass.ey.x = -this.m_rA.y * this.m_rA.x * iA - this.m_rB.y * this.m_rB.x * iB;\n this.m_mass.ez.x = -this.m_rA.y * iA - this.m_rB.y * iB;\n this.m_mass.ex.y = this.m_mass.ey.x;\n this.m_mass.ey.y = mA + mB + this.m_rA.x * this.m_rA.x * iA + this.m_rB.x * this.m_rB.x * iB;\n this.m_mass.ez.y = this.m_rA.x * iA + this.m_rB.x * iB;\n this.m_mass.ex.z = this.m_mass.ez.x;\n this.m_mass.ey.z = this.m_mass.ez.y;\n this.m_mass.ez.z = iA + iB;\n\n this.m_motorMass = iA + iB;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n\n if (this.m_enableMotor == false || fixedRotation) {\n this.m_motorImpulse = 0.0;\n }\n\n if (this.m_enableLimit && fixedRotation == false) {\n const jointAngle = aB - aA - this.m_referenceAngle;\n\n if (math_abs(this.m_upperAngle - this.m_lowerAngle) < 2.0 * Settings.angularSlop) {\n this.m_limitState = LimitState.equalLimits;\n\n } else if (jointAngle <= this.m_lowerAngle) {\n if (this.m_limitState != LimitState.atLowerLimit) {\n this.m_impulse.z = 0.0;\n }\n this.m_limitState = LimitState.atLowerLimit;\n\n } else if (jointAngle >= this.m_upperAngle) {\n if (this.m_limitState != LimitState.atUpperLimit) {\n this.m_impulse.z = 0.0;\n }\n this.m_limitState = LimitState.atUpperLimit;\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_impulse.mul(step.dtRatio);\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_impulse.x, this.m_impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_motorImpulse + this.m_impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_motorImpulse + this.m_impulse.z);\n\n } else {\n this.m_impulse.setZero();\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const fixedRotation = (iA + iB === 0.0);\n\n // Solve motor constraint.\n if (this.m_enableMotor && this.m_limitState != LimitState.equalLimits && fixedRotation == false) {\n const Cdot = wB - wA - this.m_motorSpeed;\n let impulse = -this.m_motorMass * Cdot;\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorTorque;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve limit constraint.\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit && fixedRotation == false) {\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const Cdot2 = wB - wA;\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const impulse = Vec3.neg(this.m_mass.solve33(Cdot));\n\n if (this.m_limitState == LimitState.equalLimits) {\n this.m_impulse.add(impulse);\n\n } else if (this.m_limitState == LimitState.atLowerLimit) {\n const newImpulse = this.m_impulse.z + impulse.z;\n\n if (newImpulse < 0.0) {\n const rhs = Vec2.combine(-1, Cdot1, this.m_impulse.z, Vec2.neo(this.m_mass.ez.x, this.m_mass.ez.y));\n const reduced = this.m_mass.solve22(rhs);\n impulse.x = reduced.x;\n impulse.y = reduced.y;\n impulse.z = -this.m_impulse.z;\n this.m_impulse.x += reduced.x;\n this.m_impulse.y += reduced.y;\n this.m_impulse.z = 0.0;\n\n } else {\n this.m_impulse.add(impulse);\n }\n\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n const newImpulse = this.m_impulse.z + impulse.z;\n\n if (newImpulse > 0.0) {\n const rhs = Vec2.combine(-1, Cdot1, this.m_impulse.z, Vec2.neo(this.m_mass.ez.x, this.m_mass.ez.y));\n const reduced = this.m_mass.solve22(rhs);\n impulse.x = reduced.x;\n impulse.y = reduced.y;\n impulse.z = -this.m_impulse.z;\n this.m_impulse.x += reduced.x;\n this.m_impulse.y += reduced.y;\n this.m_impulse.z = 0.0;\n\n } else {\n this.m_impulse.add(impulse);\n }\n }\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + impulse.z);\n\n } else {\n // Solve point-to-point constraint\n const Cdot = Vec2.zero();\n Cdot.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const impulse = this.m_mass.solve22(Vec2.neg(Cdot));\n\n this.m_impulse.x += impulse.x;\n this.m_impulse.y += impulse.y;\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n let angularError = 0.0;\n let positionError = 0.0;\n\n const fixedRotation = (this.m_invIA + this.m_invIB == 0.0);\n\n // Solve angular limit constraint.\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit && fixedRotation == false) {\n const angle = aB - aA - this.m_referenceAngle;\n let limitImpulse = 0.0;\n\n if (this.m_limitState == LimitState.equalLimits) {\n // Prevent large angular corrections\n const C = clamp(angle - this.m_lowerAngle, -Settings.maxAngularCorrection, Settings.maxAngularCorrection);\n limitImpulse = -this.m_motorMass * C;\n angularError = math_abs(C);\n\n } else if (this.m_limitState == LimitState.atLowerLimit) {\n let C = angle - this.m_lowerAngle;\n angularError = -C;\n\n // Prevent large angular corrections and allow some slop.\n C = clamp(C + Settings.angularSlop, -Settings.maxAngularCorrection, 0.0);\n limitImpulse = -this.m_motorMass * C;\n\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n let C = angle - this.m_upperAngle;\n angularError = C;\n\n // Prevent large angular corrections and allow some slop.\n C = clamp(C - Settings.angularSlop, 0.0, Settings.maxAngularCorrection);\n limitImpulse = -this.m_motorMass * C;\n }\n\n aA -= this.m_invIA * limitImpulse;\n aB += this.m_invIB * limitImpulse;\n }\n\n // Solve point-to-point constraint.\n {\n qA.setAngle(aA);\n qB.setAngle(aB);\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n const C = Vec2.zero();\n C.addCombine(1, cB, 1, rB);\n C.subCombine(1, cA, 1, rA);\n positionError = C.length();\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat22();\n K.ex.x = mA + mB + iA * rA.y * rA.y + iB * rB.y * rB.y;\n K.ex.y = -iA * rA.x * rA.y - iB * rB.x * rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * rA.x * rA.x + iB * rB.x * rB.x;\n\n const impulse = Vec2.neg(K.solve(C));\n\n cA.subMul(mA, impulse);\n aA -= iA * Vec2.crossVec2Vec2(rA, impulse);\n\n cB.addMul(mB, impulse);\n aB += iB * Vec2.crossVec2Vec2(rB, impulse);\n }\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return positionError <= Settings.linearSlop && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_max = Math.max;\n/** @internal */ const math_min = Math.min;\n\n\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3, \n}\n\n/**\n * Prismatic joint definition. This requires defining a line of motion using an\n * axis and an anchor point. The definition uses local anchor points and a local\n * axis so that the initial configuration can violate the constraint slightly.\n * The joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface PrismaticJointOpt extends JointOpt {\n /**\n * Enable/disable the joint limit.\n */\n enableLimit?: boolean;\n /**\n * The lower translation limit, usually in meters.\n */\n lowerTranslation?: number;\n /**\n * The upper translation limit, usually in meters.\n */\n upperTranslation?: number;\n /**\n * Enable/disable the joint motor.\n */\n enableMotor?: boolean;\n /**\n * The maximum motor torque, usually in N-m.\n */\n maxMotorForce?: number;\n /**\n * The desired motor speed in radians per second.\n */\n motorSpeed?: number;\n}\n\n/**\n * Prismatic joint definition. This requires defining a line of motion using an\n * axis and an anchor point. The definition uses local anchor points and a local\n * axis so that the initial configuration can violate the constraint slightly.\n * The joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface PrismaticJointDef extends JointDef, PrismaticJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The local translation unit axis in bodyA.\n */\n localAxisA: Vec2Value;\n /**\n * referenceAngle The constrained angle between the bodies:\n * bodyB_angle - bodyA_angle.\n */\n referenceAngle?: number;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n enableLimit : false,\n lowerTranslation : 0.0,\n upperTranslation : 0.0,\n enableMotor : false,\n maxMotorForce : 0.0,\n motorSpeed : 0.0\n};\n\ndeclare module \"./PrismaticJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PrismaticJoint(def: PrismaticJointDef): PrismaticJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PrismaticJoint(def: PrismaticJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value, axis: Vec2Value): PrismaticJoint;\n}\n\n/**\n * A prismatic joint. This joint provides one degree of freedom: translation\n * along an axis fixed in bodyA. Relative rotation is prevented. You can use a\n * joint limit to restrict the range of motion and a joint motor to drive the\n * motion or to model joint friction.\n */\n// @ts-expect-error\nexport class PrismaticJoint extends Joint {\n static TYPE = \"prismatic-joint\" as const;\n\n /** @internal */ m_type: \"prismatic-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_localXAxisA: Vec2;\n /** @internal */ m_localYAxisA: Vec2;\n /** @internal */ m_referenceAngle: number;\n /** @internal */ m_impulse: Vec3;\n /** @internal */ m_motorMass: number;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_lowerTranslation: number;\n /** @internal */ m_upperTranslation: number;\n /** @internal */ m_maxMotorForce: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableLimit: boolean;\n /** @internal */ m_enableMotor: boolean;\n /** @internal */ m_limitState: number; // TODO enum\n /** @internal */ m_axis: Vec2;\n /** @internal */ m_perp: Vec2;\n // Solver temp\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_s1: number;\n /** @internal */ m_s2: number;\n /** @internal */ m_a1: number;\n /** @internal */ m_a2: number;\n /** @internal */ m_K: Mat33;\n\n constructor(def: PrismaticJointDef);\n constructor(def: PrismaticJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value, axis?: Vec2Value);\n constructor(def: PrismaticJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value, axis?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PrismaticJoint)) {\n return new PrismaticJoint(def, bodyA, bodyB, anchor, axis);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = PrismaticJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n this.m_localXAxisA = Vec2.clone(axis ? bodyA.getLocalVector(axis) : def.localAxisA || Vec2.neo(1.0, 0.0));\n this.m_localXAxisA.normalize();\n this.m_localYAxisA = Vec2.crossNumVec2(1.0, this.m_localXAxisA);\n this.m_referenceAngle = Number.isFinite(def.referenceAngle) ? def.referenceAngle : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_impulse = new Vec3();\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n\n this.m_lowerTranslation = def.lowerTranslation;\n this.m_upperTranslation = def.upperTranslation;\n this.m_maxMotorForce = def.maxMotorForce;\n this.m_motorSpeed = def.motorSpeed;\n this.m_enableLimit = def.enableLimit;\n this.m_enableMotor = def.enableMotor;\n this.m_limitState = LimitState.inactiveLimit;\n\n this.m_axis = Vec2.zero();\n this.m_perp = Vec2.zero();\n\n this.m_K = new Mat33();\n\n // Linear constraint (point-to-line)\n // d = p2 - p1 = x2 + r2 - x1 - r1\n // C = dot(perp, d)\n // Cdot = dot(d, cross(w1, perp)) + dot(perp, v2 + cross(w2, r2) - v1 -\n // cross(w1, r1))\n // = -dot(perp, v1) - dot(cross(d + r1, perp), w1) + dot(perp, v2) +\n // dot(cross(r2, perp), v2)\n // J = [-perp, -cross(d + r1, perp), perp, cross(r2,perp)]\n //\n // Angular constraint\n // C = a2 - a1 + a_initial\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n //\n // K = J * invM * JT\n //\n // J = [-a -s1 a s2]\n // [0 -1 0 1]\n // a = perp\n // s1 = cross(d + r1, a) = cross(p2 - x1, a)\n // s2 = cross(r2, a) = cross(p2 - x2, a)\n\n // Motor/Limit linear constraint\n // C = dot(ax1, d)\n // Cdot = = -dot(ax1, v1) - dot(cross(d + r1, ax1), w1) + dot(ax1, v2) +\n // dot(cross(r2, ax1), v2)\n // J = [-ax1 -cross(d+r1,ax1) ax1 cross(r2,ax1)]\n\n // Block Solver\n // We develop a block solver that includes the joint limit. This makes the\n // limit stiff (inelastic) even\n // when the mass has poor distribution (leading to large torques about the\n // joint anchor points).\n //\n // The Jacobian has 3 rows:\n // J = [-uT -s1 uT s2] // linear\n // [0 -1 0 1] // angular\n // [-vT -a1 vT a2] // limit\n //\n // u = perp\n // v = axis\n // s1 = cross(d + r1, u), s2 = cross(r2, u)\n // a1 = cross(d + r1, v), a2 = cross(r2, v)\n\n // M * (v2 - v1) = JT * df\n // J * v2 = bias\n //\n // v2 = v1 + invM * JT * df\n // J * (v1 + invM * JT * df) = bias\n // K * df = bias - J * v1 = -Cdot\n // K = J * invM * JT\n // Cdot = J * v1 - bias\n //\n // Now solve for f2.\n // df = f2 - f1\n // K * (f2 - f1) = -Cdot\n // f2 = invK * (-Cdot) + f1\n //\n // Clamp accumulated limit impulse.\n // lower: f2(3) = max(f2(3), 0)\n // upper: f2(3) = min(f2(3), 0)\n //\n // Solve for correct f2(1:2)\n // K(1:2, 1:2) * f2(1:2) = -Cdot(1:2) - K(1:2,3) * f2(3) + K(1:2,1:3) * f1\n // = -Cdot(1:2) - K(1:2,3) * f2(3) + K(1:2,1:2) * f1(1:2) + K(1:2,3) * f1(3)\n // K(1:2, 1:2) * f2(1:2) = -Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3)) +\n // K(1:2,1:2) * f1(1:2)\n // f2(1:2) = invK(1:2,1:2) * (-Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3))) +\n // f1(1:2)\n //\n // Now compute impulse to be applied:\n // df = f2 - f1\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n lowerTranslation: this.m_lowerTranslation,\n upperTranslation: this.m_upperTranslation,\n maxMotorForce: this.m_maxMotorForce,\n motorSpeed: this.m_motorSpeed,\n enableLimit: this.m_enableLimit,\n enableMotor: this.m_enableMotor,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n localAxisA: this.m_localXAxisA,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): PrismaticJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.localAxisA = Vec2.clone(data.localAxisA);\n const joint = new PrismaticJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (def.localAxisA) {\n this.m_localXAxisA.setVec2(def.localAxisA);\n this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1.0, def.localAxisA));\n }\n if (Number.isFinite(def.referenceAngle)) {\n this.m_referenceAngle = def.referenceAngle;\n }\n if (typeof def.enableLimit !== \"undefined\") {\n this.m_enableLimit = !!def.enableLimit;\n }\n if (Number.isFinite(def.lowerTranslation)) {\n this.m_lowerTranslation = def.lowerTranslation;\n }\n if (Number.isFinite(def.upperTranslation)) {\n this.m_upperTranslation = def.upperTranslation;\n }\n if (typeof def.enableMotor !== \"undefined\") {\n this.m_enableMotor = !!def.enableMotor;\n }\n if (Number.isFinite(def.maxMotorForce)) {\n this.m_maxMotorForce = def.maxMotorForce;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * The local joint axis relative to bodyA.\n */\n getLocalAxisA(): Vec2 {\n return this.m_localXAxisA;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Get the current joint translation, usually in meters.\n */\n getJointTranslation(): number {\n const pA = this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n const pB = this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n const d = Vec2.sub(pB, pA);\n const axis = this.m_bodyA.getWorldVector(this.m_localXAxisA);\n\n const translation = Vec2.dot(d, axis);\n return translation;\n }\n\n /**\n * Get the current joint translation speed, usually in meters per second.\n */\n getJointSpeed(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n\n const rA = Rot.mulVec2(bA.m_xf.q, Vec2.sub(this.m_localAnchorA, bA.m_sweep.localCenter));\n const rB = Rot.mulVec2(bB.m_xf.q, Vec2.sub(this.m_localAnchorB, bB.m_sweep.localCenter));\n const p1 = Vec2.add(bA.m_sweep.c, rA);\n const p2 = Vec2.add(bB.m_sweep.c, rB);\n const d = Vec2.sub(p2, p1);\n const axis = Rot.mulVec2(bA.m_xf.q, this.m_localXAxisA);\n\n const vA = bA.m_linearVelocity;\n const vB = bB.m_linearVelocity;\n const wA = bA.m_angularVelocity;\n const wB = bB.m_angularVelocity;\n\n const speed = Vec2.dot(d, Vec2.crossNumVec2(wA, axis)) + Vec2.dot(axis, Vec2.sub(Vec2.addCrossNumVec2(vB, wB, rB), Vec2.addCrossNumVec2(vA, wA, rA)));\n return speed;\n }\n\n /**\n * Is the joint limit enabled?\n */\n isLimitEnabled(): boolean {\n return this.m_enableLimit;\n }\n\n /**\n * Enable/disable the joint limit.\n */\n enableLimit(flag: boolean): void {\n if (flag != this.m_enableLimit) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableLimit = flag;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Get the lower joint limit, usually in meters.\n */\n getLowerLimit(): number {\n return this.m_lowerTranslation;\n }\n\n /**\n * Get the upper joint limit, usually in meters.\n */\n getUpperLimit(): number {\n return this.m_upperTranslation;\n }\n\n /**\n * Set the joint limits, usually in meters.\n */\n setLimits(lower: number, upper: number): void {\n if (_ASSERT) console.assert(lower <= upper);\n if (lower != this.m_lowerTranslation || upper != this.m_upperTranslation) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_lowerTranslation = lower;\n this.m_upperTranslation = upper;\n this.m_impulse.z = 0.0;\n }\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Set the motor speed, usually in meters per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Set the maximum motor force, usually in N.\n */\n setMaxMotorForce(force: number): void {\n if (force == this.m_maxMotorForce) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorForce = force;\n }\n\n getMaxMotorForce(): number {\n return this.m_maxMotorForce;\n }\n\n /**\n * Get the motor speed, usually in meters per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Get the current motor force given the inverse time step, usually in N.\n */\n getMotorForce(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.combine(this.m_impulse.x, this.m_perp, this.m_motorImpulse + this.m_impulse.z, this.m_axis).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.y;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective masses.\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Compute motor Jacobian and effective mass.\n {\n this.m_axis = Rot.mulVec2(qA, this.m_localXAxisA);\n this.m_a1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_axis);\n this.m_a2 = Vec2.crossVec2Vec2(rB, this.m_axis);\n\n this.m_motorMass = mA + mB + iA * this.m_a1 * this.m_a1 + iB * this.m_a2\n * this.m_a2;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n }\n\n // Prismatic constraint.\n {\n this.m_perp = Rot.mulVec2(qA, this.m_localYAxisA);\n\n this.m_s1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_perp);\n this.m_s2 = Vec2.crossVec2Vec2(rB, this.m_perp);\n\n const s1test = Vec2.crossVec2Vec2(rA, this.m_perp);\n\n const k11 = mA + mB + iA * this.m_s1 * this.m_s1 + iB * this.m_s2 * this.m_s2;\n const k12 = iA * this.m_s1 + iB * this.m_s2;\n const k13 = iA * this.m_s1 * this.m_a1 + iB * this.m_s2 * this.m_a2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n // For bodies with fixed rotation.\n k22 = 1.0;\n }\n const k23 = iA * this.m_a1 + iB * this.m_a2;\n const k33 = mA + mB + iA * this.m_a1 * this.m_a1 + iB * this.m_a2 * this.m_a2;\n\n this.m_K.ex.set(k11, k12, k13);\n this.m_K.ey.set(k12, k22, k23);\n this.m_K.ez.set(k13, k23, k33);\n }\n\n // Compute motor and limit terms.\n if (this.m_enableLimit) {\n\n const jointTranslation = Vec2.dot(this.m_axis, d);\n if (math_abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * Settings.linearSlop) {\n this.m_limitState = LimitState.equalLimits;\n\n } else if (jointTranslation <= this.m_lowerTranslation) {\n if (this.m_limitState != LimitState.atLowerLimit) {\n this.m_limitState = LimitState.atLowerLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else if (jointTranslation >= this.m_upperTranslation) {\n if (this.m_limitState != LimitState.atUpperLimit) {\n this.m_limitState = LimitState.atUpperLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = LimitState.inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n if (this.m_enableMotor == false) {\n this.m_motorImpulse = 0.0;\n }\n\n if (step.warmStarting) {\n // Account for variable time step.\n this.m_impulse.mul(step.dtRatio);\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.combine(this.m_impulse.x, this.m_perp, this.m_motorImpulse\n + this.m_impulse.z, this.m_axis);\n const LA = this.m_impulse.x * this.m_s1 + this.m_impulse.y\n + (this.m_motorImpulse + this.m_impulse.z) * this.m_a1;\n const LB = this.m_impulse.x * this.m_s2 + this.m_impulse.y\n + (this.m_motorImpulse + this.m_impulse.z) * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n } else {\n this.m_impulse.setZero();\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Solve linear motor constraint.\n if (this.m_enableMotor && this.m_limitState != LimitState.equalLimits) {\n const Cdot = Vec2.dot(this.m_axis, Vec2.sub(vB, vA)) + this.m_a2 * wB\n - this.m_a1 * wA;\n let impulse = this.m_motorMass * (this.m_motorSpeed - Cdot);\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorForce;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse,\n -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_axis);\n const LA = impulse * this.m_a1;\n const LB = impulse * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n const Cdot1 = Vec2.zero();\n Cdot1.x += Vec2.dot(this.m_perp, vB) + this.m_s2 * wB;\n Cdot1.x -= Vec2.dot(this.m_perp, vA) + this.m_s1 * wA;\n Cdot1.y = wB - wA;\n\n if (this.m_enableLimit && this.m_limitState != LimitState.inactiveLimit) {\n // Solve prismatic and limit constraint in block form.\n let Cdot2 = 0;\n Cdot2 += Vec2.dot(this.m_axis, vB) + this.m_a2 * wB;\n Cdot2 -= Vec2.dot(this.m_axis, vA) + this.m_a1 * wA;\n\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const f1 = Vec3.clone(this.m_impulse);\n let df = this.m_K.solve33(Vec3.neg(Cdot));\n this.m_impulse.add(df);\n\n if (this.m_limitState == LimitState.atLowerLimit) {\n this.m_impulse.z = math_max(this.m_impulse.z, 0.0);\n } else if (this.m_limitState == LimitState.atUpperLimit) {\n this.m_impulse.z = math_min(this.m_impulse.z, 0.0);\n }\n\n // f2(1:2) = invK(1:2,1:2) * (-Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3))) +\n // f1(1:2)\n const b = Vec2.combine(-1, Cdot1, -(this.m_impulse.z - f1.z), Vec2.neo(this.m_K.ez.x, this.m_K.ez.y));\n const f2r = Vec2.add(this.m_K.solve22(b), Vec2.neo(f1.x, f1.y));\n this.m_impulse.x = f2r.x;\n this.m_impulse.y = f2r.y;\n\n df = Vec3.sub(this.m_impulse, f1);\n\n const P = Vec2.combine(df.x, this.m_perp, df.z, this.m_axis);\n const LA = df.x * this.m_s1 + df.y + df.z * this.m_a1;\n const LB = df.x * this.m_s2 + df.y + df.z * this.m_a2;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n } else {\n // Limit is inactive, just solve the prismatic constraint in block form.\n const df = this.m_K.solve22(Vec2.neg(Cdot1));\n this.m_impulse.x += df.x;\n this.m_impulse.y += df.y;\n\n const P = Vec2.mulNumVec2(df.x, this.m_perp);\n const LA = df.x * this.m_s1 + df.y;\n const LB = df.x * this.m_s2 + df.y;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Compute fresh Jacobians\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.sub(Vec2.add(cB, rB), Vec2.add(cA, rA));\n\n const axis = Rot.mulVec2(qA, this.m_localXAxisA);\n const a1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), axis);\n const a2 = Vec2.crossVec2Vec2(rB, axis);\n const perp = Rot.mulVec2(qA, this.m_localYAxisA);\n\n const s1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), perp);\n const s2 = Vec2.crossVec2Vec2(rB, perp);\n\n let impulse = new Vec3();\n const C1 = Vec2.zero();\n C1.x = Vec2.dot(perp, d);\n C1.y = aB - aA - this.m_referenceAngle;\n\n let linearError = math_abs(C1.x);\n const angularError = math_abs(C1.y);\n\n const linearSlop = Settings.linearSlop;\n const maxLinearCorrection = Settings.maxLinearCorrection;\n\n let active = false; // bool\n let C2 = 0.0;\n if (this.m_enableLimit) {\n\n const translation = Vec2.dot(axis, d);\n if (math_abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * linearSlop) {\n // Prevent large angular corrections\n C2 = clamp(translation, -maxLinearCorrection, maxLinearCorrection);\n linearError = math_max(linearError, math_abs(translation));\n active = true;\n\n } else if (translation <= this.m_lowerTranslation) {\n // Prevent large linear corrections and allow some slop.\n C2 = clamp(translation - this.m_lowerTranslation + linearSlop,\n -maxLinearCorrection, 0.0);\n linearError = Math\n .max(linearError, this.m_lowerTranslation - translation);\n active = true;\n\n } else if (translation >= this.m_upperTranslation) {\n // Prevent large linear corrections and allow some slop.\n C2 = clamp(translation - this.m_upperTranslation - linearSlop, 0.0,\n maxLinearCorrection);\n linearError = Math\n .max(linearError, translation - this.m_upperTranslation);\n active = true;\n }\n }\n\n if (active) {\n const k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2;\n const k12 = iA * s1 + iB * s2;\n const k13 = iA * s1 * a1 + iB * s2 * a2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n // For fixed rotation\n k22 = 1.0;\n }\n const k23 = iA * a1 + iB * a2;\n const k33 = mA + mB + iA * a1 * a1 + iB * a2 * a2;\n\n const K = new Mat33();\n K.ex.set(k11, k12, k13);\n K.ey.set(k12, k22, k23);\n K.ez.set(k13, k23, k33);\n\n const C = new Vec3();\n C.x = C1.x;\n C.y = C1.y;\n C.z = C2;\n\n impulse = K.solve33(Vec3.neg(C));\n } else {\n const k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2;\n const k12 = iA * s1 + iB * s2;\n let k22 = iA + iB;\n if (k22 == 0.0) {\n k22 = 1.0;\n }\n\n const K = new Mat22();\n K.ex.setNum(k11, k12);\n K.ey.setNum(k12, k22);\n\n const impulse1 = K.solve(Vec2.neg(C1));\n impulse.x = impulse1.x;\n impulse.y = impulse1.y;\n impulse.z = 0.0;\n }\n\n const P = Vec2.combine(impulse.x, perp, impulse.z, axis);\n const LA = impulse.x * s1 + impulse.y + impulse.z * a1;\n const LB = impulse.x * s2 + impulse.y + impulse.z * a2;\n\n cA.subMul(mA, P);\n aA -= iA * LA;\n cB.addMul(mB, P);\n aB += iB * LB;\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return linearError <= Settings.linearSlop\n && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { } from \"../../common/Math\";\nimport { Vec2 } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { RevoluteJoint } from \"./RevoluteJoint\";\nimport { PrismaticJoint } from \"./PrismaticJoint\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Gear joint definition.\n */\nexport interface GearJointOpt extends JointOpt {\n /**\n * The gear ratio. See {@link GearJoint} for explanation.\n */\n ratio?: number;\n}\n\n/**\n * Gear joint definition.\n */\nexport interface GearJointDef extends JointDef, GearJointOpt {\n /**\n * The first revolute/prismatic joint attached to the gear joint.\n */\n joint1: RevoluteJoint | PrismaticJoint;\n /**\n * The second prismatic/revolute joint attached to the gear joint.\n */\n joint2: RevoluteJoint | PrismaticJoint;\n}\n\n/** @internal */ const DEFAULTS = {\n ratio : 1.0\n};\n\ndeclare module \"./GearJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function GearJoint(def: GearJointDef): GearJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function GearJoint(def: GearJointOpt, bodyA: Body, bodyB: Body, joint1: RevoluteJoint | PrismaticJoint, joint2: RevoluteJoint | PrismaticJoint, ratio?: number): GearJoint;\n}\n\n/**\n * A gear joint is used to connect two joints together. Either joint can be a\n * revolute or prismatic joint. You specify a gear ratio to bind the motions\n * together: coordinate1 + ratio * coordinate2 = constant\n *\n * The ratio can be negative or positive. If one joint is a revolute joint and\n * the other joint is a prismatic joint, then the ratio will have units of\n * length or units of 1/length. Warning: You have to manually destroy the gear\n * joint if joint1 or joint2 is destroyed.\n *\n * This definition requires two existing revolute or prismatic joints (any\n * combination will work).\n */\n// @ts-expect-error\nexport class GearJoint extends Joint {\n static TYPE = \"gear-joint\" as const;\n\n /** @internal */ m_type: \"gear-joint\";\n /** @internal */ m_joint1: RevoluteJoint | PrismaticJoint;\n /** @internal */ m_joint2: RevoluteJoint | PrismaticJoint;\n /** @internal */ m_type1: \"revolute-joint\" | \"prismatic-joint\";\n /** @internal */ m_type2: \"revolute-joint\" | \"prismatic-joint\";\n /** @internal */ m_bodyC: Body;\n /** @internal */ m_localAnchorC: Vec2;\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_referenceAngleA: number;\n /** @internal */ m_localAxisC: Vec2;\n /** @internal */ m_bodyD: Body;\n /** @internal */ m_localAnchorD: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngleB: number;\n /** @internal */ m_localAxisD: Vec2;\n /** @internal */ m_ratio: number;\n /** @internal */ m_constant: number;\n /** @internal */ m_impulse: number;\n\n // Solver temp\n /** @internal */ m_lcA: Vec2;\n /** @internal */ m_lcB: Vec2;\n /** @internal */ m_lcC: Vec2;\n /** @internal */ m_lcD: Vec2;\n /** @internal */ m_mA: number;\n /** @internal */ m_mB: number;\n /** @internal */ m_mC: number;\n /** @internal */ m_mD: number;\n /** @internal */ m_iA: number;\n /** @internal */ m_iB: number;\n /** @internal */ m_iC: number;\n /** @internal */ m_iD: number;\n /** @internal */ m_JvAC: Vec2;\n /** @internal */ m_JvBD: Vec2;\n /** @internal */ m_JwA: number;\n /** @internal */ m_JwB: number;\n /** @internal */ m_JwC: number;\n /** @internal */ m_JwD: number;\n /** @internal */ m_mass: number;\n\n constructor(def: GearJointDef);\n constructor(def: GearJointOpt, bodyA: Body, bodyB: Body, joint1: RevoluteJoint | PrismaticJoint, joint2: RevoluteJoint | PrismaticJoint, ratio?: number);\n constructor(def: GearJointDef, bodyA?: Body, bodyB?: Body, joint1?: RevoluteJoint | PrismaticJoint, joint2?: RevoluteJoint | PrismaticJoint, ratio?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof GearJoint)) {\n return new GearJoint(def, bodyA, bodyB, joint1, joint2, ratio);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = GearJoint.TYPE;\n\n if (_ASSERT) console.assert(joint1.m_type === RevoluteJoint.TYPE || joint1.m_type === PrismaticJoint.TYPE);\n if (_ASSERT) console.assert(joint2.m_type === RevoluteJoint.TYPE || joint2.m_type === PrismaticJoint.TYPE);\n\n this.m_joint1 = joint1 ? joint1 : def.joint1;\n this.m_joint2 = joint2 ? joint2 : def.joint2;\n this.m_ratio = Number.isFinite(ratio) ? ratio : def.ratio;\n\n this.m_type1 = this.m_joint1.getType() as \"revolute-joint\" | \"prismatic-joint\";\n this.m_type2 = this.m_joint2.getType() as \"revolute-joint\" | \"prismatic-joint\";\n\n // joint1 connects body A to body C\n // joint2 connects body B to body D\n\n let coordinateA: number;\n let coordinateB: number;\n\n // TODO_ERIN there might be some problem with the joint edges in Joint.\n\n this.m_bodyC = this.m_joint1.getBodyA();\n this.m_bodyA = this.m_joint1.getBodyB();\n\n // Get geometry of joint1\n const xfA = this.m_bodyA.m_xf;\n const aA = this.m_bodyA.m_sweep.a;\n const xfC = this.m_bodyC.m_xf;\n const aC = this.m_bodyC.m_sweep.a;\n\n if (this.m_type1 === RevoluteJoint.TYPE) {\n const revolute = this.m_joint1 as RevoluteJoint;\n this.m_localAnchorC = revolute.m_localAnchorA;\n this.m_localAnchorA = revolute.m_localAnchorB;\n this.m_referenceAngleA = revolute.m_referenceAngle;\n this.m_localAxisC = Vec2.zero();\n\n coordinateA = aA - aC - this.m_referenceAngleA;\n } else {\n const prismatic = this.m_joint1 as PrismaticJoint;\n this.m_localAnchorC = prismatic.m_localAnchorA;\n this.m_localAnchorA = prismatic.m_localAnchorB;\n this.m_referenceAngleA = prismatic.m_referenceAngle;\n this.m_localAxisC = prismatic.m_localXAxisA;\n\n const pC = this.m_localAnchorC;\n const pA = Rot.mulTVec2(xfC.q, Vec2.add(Rot.mulVec2(xfA.q, this.m_localAnchorA), Vec2.sub(xfA.p, xfC.p)));\n coordinateA = Vec2.dot(pA, this.m_localAxisC) - Vec2.dot(pC, this.m_localAxisC);\n }\n\n this.m_bodyD = this.m_joint2.getBodyA();\n this.m_bodyB = this.m_joint2.getBodyB();\n\n // Get geometry of joint2\n const xfB = this.m_bodyB.m_xf;\n const aB = this.m_bodyB.m_sweep.a;\n const xfD = this.m_bodyD.m_xf;\n const aD = this.m_bodyD.m_sweep.a;\n\n if (this.m_type2 === RevoluteJoint.TYPE) {\n const revolute = this.m_joint2 as RevoluteJoint;\n this.m_localAnchorD = revolute.m_localAnchorA;\n this.m_localAnchorB = revolute.m_localAnchorB;\n this.m_referenceAngleB = revolute.m_referenceAngle;\n this.m_localAxisD = Vec2.zero();\n\n coordinateB = aB - aD - this.m_referenceAngleB;\n } else {\n const prismatic = this.m_joint2 as PrismaticJoint;\n this.m_localAnchorD = prismatic.m_localAnchorA;\n this.m_localAnchorB = prismatic.m_localAnchorB;\n this.m_referenceAngleB = prismatic.m_referenceAngle;\n this.m_localAxisD = prismatic.m_localXAxisA;\n\n const pD = this.m_localAnchorD;\n const pB = Rot.mulTVec2(xfD.q, Vec2.add(Rot.mulVec2(xfB.q, this.m_localAnchorB), Vec2.sub(xfB.p, xfD.p)));\n coordinateB = Vec2.dot(pB, this.m_localAxisD) - Vec2.dot(pD, this.m_localAxisD);\n }\n\n this.m_constant = coordinateA + this.m_ratio * coordinateB;\n\n this.m_impulse = 0.0;\n\n // Gear Joint:\n // C0 = (coordinate1 + ratio * coordinate2)_initial\n // C = (coordinate1 + ratio * coordinate2) - C0 = 0\n // J = [J1 ratio * J2]\n // K = J * invM * JT\n // = J1 * invM1 * J1T + ratio * ratio * J2 * invM2 * J2T\n //\n // Revolute:\n // coordinate = rotation\n // Cdot = angularVelocity\n // J = [0 0 1]\n // K = J * invM * JT = invI\n //\n // Prismatic:\n // coordinate = dot(p - pg, ug)\n // Cdot = dot(v + cross(w, r), ug)\n // J = [ug cross(r, ug)]\n // K = J * invM * JT = invMass + invI * cross(r, ug)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n joint1: this.m_joint1,\n joint2: this.m_joint2,\n ratio: this.m_ratio,\n\n // _constant: this.m_constant,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): GearJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.joint1 = restore(Joint, data.joint1, world);\n data.joint2 = restore(Joint, data.joint2, world);\n const joint = new GearJoint(data);\n // if (data._constant) joint.m_constant = data._constant;\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n // todo: implement other fields\n if (Number.isFinite(def.ratio)) {\n this.m_ratio = def.ratio;\n }\n }\n\n /**\n * Get the first joint.\n */\n getJoint1(): Joint {\n return this.m_joint1;\n }\n\n /**\n * Get the second joint.\n */\n getJoint2(): Joint {\n return this.m_joint2;\n }\n\n /**\n * Set the gear ratio.\n */\n setRatio(ratio: number): void {\n if (_ASSERT) console.assert(Number.isFinite(ratio));\n this.m_ratio = ratio;\n }\n\n /**\n * Get the gear ratio.\n */\n getRatio(): number {\n return this.m_ratio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_JvAC).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n const L = this.m_impulse * this.m_JwA;\n return inv_dt * L;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_lcA = this.m_bodyA.m_sweep.localCenter;\n this.m_lcB = this.m_bodyB.m_sweep.localCenter;\n this.m_lcC = this.m_bodyC.m_sweep.localCenter;\n this.m_lcD = this.m_bodyD.m_sweep.localCenter;\n this.m_mA = this.m_bodyA.m_invMass;\n this.m_mB = this.m_bodyB.m_invMass;\n this.m_mC = this.m_bodyC.m_invMass;\n this.m_mD = this.m_bodyD.m_invMass;\n this.m_iA = this.m_bodyA.m_invI;\n this.m_iB = this.m_bodyB.m_invI;\n this.m_iC = this.m_bodyC.m_invI;\n this.m_iD = this.m_bodyD.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const aC = this.m_bodyC.c_position.a;\n const vC = this.m_bodyC.c_velocity.v;\n let wC = this.m_bodyC.c_velocity.w;\n\n const aD = this.m_bodyD.c_position.a;\n const vD = this.m_bodyD.c_velocity.v;\n let wD = this.m_bodyD.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n const qC = Rot.neo(aC);\n const qD = Rot.neo(aD);\n\n this.m_mass = 0.0;\n\n if (this.m_type1 == RevoluteJoint.TYPE) {\n this.m_JvAC = Vec2.zero();\n this.m_JwA = 1.0;\n this.m_JwC = 1.0;\n this.m_mass += this.m_iA + this.m_iC;\n } else {\n const u = Rot.mulVec2(qC, this.m_localAxisC);\n const rC = Rot.mulSub(qC, this.m_localAnchorC, this.m_lcC);\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_lcA);\n this.m_JvAC = u;\n this.m_JwC = Vec2.crossVec2Vec2(rC, u);\n this.m_JwA = Vec2.crossVec2Vec2(rA, u);\n this.m_mass += this.m_mC + this.m_mA + this.m_iC * this.m_JwC * this.m_JwC + this.m_iA * this.m_JwA * this.m_JwA;\n }\n\n if (this.m_type2 == RevoluteJoint.TYPE) {\n this.m_JvBD = Vec2.zero();\n this.m_JwB = this.m_ratio;\n this.m_JwD = this.m_ratio;\n this.m_mass += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD);\n } else {\n const u = Rot.mulVec2(qD, this.m_localAxisD);\n const rD = Rot.mulSub(qD, this.m_localAnchorD, this.m_lcD);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_lcB);\n this.m_JvBD = Vec2.mulNumVec2(this.m_ratio, u);\n this.m_JwD = this.m_ratio * Vec2.crossVec2Vec2(rD, u);\n this.m_JwB = this.m_ratio * Vec2.crossVec2Vec2(rB, u);\n this.m_mass += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * this.m_JwD * this.m_JwD + this.m_iB * this.m_JwB * this.m_JwB;\n }\n\n // Compute effective mass.\n this.m_mass = this.m_mass > 0.0 ? 1.0 / this.m_mass : 0.0;\n\n if (step.warmStarting) {\n vA.addMul(this.m_mA * this.m_impulse, this.m_JvAC);\n wA += this.m_iA * this.m_impulse * this.m_JwA;\n\n vB.addMul(this.m_mB * this.m_impulse, this.m_JvBD);\n wB += this.m_iB * this.m_impulse * this.m_JwB;\n\n vC.subMul(this.m_mC * this.m_impulse, this.m_JvAC);\n wC -= this.m_iC * this.m_impulse * this.m_JwC;\n\n vD.subMul(this.m_mD * this.m_impulse, this.m_JvBD);\n wD -= this.m_iD * this.m_impulse * this.m_JwD;\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n this.m_bodyC.c_velocity.v.setVec2(vC);\n this.m_bodyC.c_velocity.w = wC;\n this.m_bodyD.c_velocity.v.setVec2(vD);\n this.m_bodyD.c_velocity.w = wD;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n const vC = this.m_bodyC.c_velocity.v;\n let wC = this.m_bodyC.c_velocity.w;\n const vD = this.m_bodyD.c_velocity.v;\n let wD = this.m_bodyD.c_velocity.w;\n\n let Cdot = Vec2.dot(this.m_JvAC, vA) - Vec2.dot(this.m_JvAC, vC) + Vec2.dot(this.m_JvBD, vB) - Vec2.dot(this.m_JvBD, vD);\n Cdot += (this.m_JwA * wA - this.m_JwC * wC) + (this.m_JwB * wB - this.m_JwD * wD);\n\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n vA.addMul(this.m_mA * impulse, this.m_JvAC);\n wA += this.m_iA * impulse * this.m_JwA;\n vB.addMul(this.m_mB * impulse, this.m_JvBD);\n wB += this.m_iB * impulse * this.m_JwB;\n vC.subMul(this.m_mC * impulse, this.m_JvAC);\n wC -= this.m_iC * impulse * this.m_JwC;\n vD.subMul(this.m_mD * impulse, this.m_JvBD);\n wD -= this.m_iD * impulse * this.m_JwD;\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n this.m_bodyC.c_velocity.v.setVec2(vC);\n this.m_bodyC.c_velocity.w = wC;\n this.m_bodyD.c_velocity.v.setVec2(vD);\n this.m_bodyD.c_velocity.w = wD;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n const cC = this.m_bodyC.c_position.c;\n let aC = this.m_bodyC.c_position.a;\n const cD = this.m_bodyD.c_position.c;\n let aD = this.m_bodyD.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n const qC = Rot.neo(aC);\n const qD = Rot.neo(aD);\n\n const linearError = 0.0;\n\n let coordinateA: number;\n let coordinateB: number;\n\n let JvAC: Vec2;\n let JvBD: Vec2;\n let JwA: number;\n let JwB: number;\n let JwC: number;\n let JwD: number;\n let mass = 0.0;\n\n if (this.m_type1 == RevoluteJoint.TYPE) {\n JvAC = Vec2.zero();\n JwA = 1.0;\n JwC = 1.0;\n mass += this.m_iA + this.m_iC;\n\n coordinateA = aA - aC - this.m_referenceAngleA;\n } else {\n const u = Rot.mulVec2(qC, this.m_localAxisC);\n const rC = Rot.mulSub(qC, this.m_localAnchorC, this.m_lcC);\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_lcA);\n JvAC = u;\n JwC = Vec2.crossVec2Vec2(rC, u);\n JwA = Vec2.crossVec2Vec2(rA, u);\n mass += this.m_mC + this.m_mA + this.m_iC * JwC * JwC + this.m_iA * JwA * JwA;\n\n const pC = Vec2.sub(this.m_localAnchorC, this.m_lcC);\n const pA = Rot.mulTVec2(qC, Vec2.add(rA, Vec2.sub(cA, cC)));\n coordinateA = Vec2.dot(Vec2.sub(pA, pC), this.m_localAxisC);\n }\n\n if (this.m_type2 == RevoluteJoint.TYPE) {\n JvBD = Vec2.zero();\n JwB = this.m_ratio;\n JwD = this.m_ratio;\n mass += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD);\n\n coordinateB = aB - aD - this.m_referenceAngleB;\n } else {\n const u = Rot.mulVec2(qD, this.m_localAxisD);\n const rD = Rot.mulSub(qD, this.m_localAnchorD, this.m_lcD);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_lcB);\n JvBD = Vec2.mulNumVec2(this.m_ratio, u);\n JwD = this.m_ratio * Vec2.crossVec2Vec2(rD, u);\n JwB = this.m_ratio * Vec2.crossVec2Vec2(rB, u);\n mass += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * JwD * JwD + this.m_iB * JwB * JwB;\n\n const pD = Vec2.sub(this.m_localAnchorD, this.m_lcD);\n const pB = Rot.mulTVec2(qD, Vec2.add(rB, Vec2.sub(cB, cD)));\n coordinateB = Vec2.dot(pB, this.m_localAxisD) - Vec2.dot(pD, this.m_localAxisD);\n }\n\n const C = (coordinateA + this.m_ratio * coordinateB) - this.m_constant;\n\n let impulse = 0.0;\n if (mass > 0.0) {\n impulse = -C / mass;\n }\n\n cA.addMul(this.m_mA * impulse, JvAC);\n aA += this.m_iA * impulse * JwA;\n cB.addMul(this.m_mB * impulse, JvBD);\n aB += this.m_iB * impulse * JwB;\n cC.subMul(this.m_mC * impulse, JvAC);\n aC -= this.m_iC * impulse * JwC;\n cD.subMul(this.m_mD * impulse, JvBD);\n aD -= this.m_iD * impulse * JwD;\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n this.m_bodyC.c_position.c.setVec2(cC);\n this.m_bodyC.c_position.a = aC;\n this.m_bodyD.c_position.c.setVec2(cD);\n this.m_bodyD.c_position.a = aD;\n\n // TODO_ERIN not implemented\n return linearError < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\n\n/**\n * Motor joint definition.\n */\nexport interface MotorJointOpt extends JointOpt {\n /**\n * The bodyB angle minus bodyA angle in radians.\n */\n angularOffset?: number;\n /**\n * The maximum motor force in N.\n */\n maxForce?: number;\n /**\n * The maximum motor torque in N-m.\n */\n maxTorque?: number;\n /**\n * Position correction factor in the range [0,1].\n */\n correctionFactor?: number;\n /**\n * Position of bodyB minus the position of bodyA, in bodyA's frame, in meters.\n */\n linearOffset?: Vec2Value;\n}\n\n/**\n * Motor joint definition.\n */\nexport interface MotorJointDef extends JointDef, MotorJointOpt {\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 1.0,\n maxTorque : 1.0,\n correctionFactor : 0.3\n};\n\ndeclare module \"./MotorJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MotorJoint(def: MotorJointDef): MotorJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MotorJoint(def: MotorJointOpt, bodyA: Body, bodyB: Body): MotorJoint;\n}\n\n/**\n * A motor joint is used to control the relative motion between two bodies. A\n * typical usage is to control the movement of a dynamic body with respect to\n * the ground.\n */\n// @ts-expect-error\nexport class MotorJoint extends Joint {\n static TYPE = \"motor-joint\" as const;\n\n /** @internal */ m_type: \"motor-joint\";\n /** @internal */ m_linearOffset: Vec2;\n /** @internal */ m_angularOffset: number;\n /** @internal */ m_linearImpulse: Vec2;\n /** @internal */ m_angularImpulse: number;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_maxTorque: number;\n /** @internal */ m_correctionFactor: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_linearError: Vec2;\n /** @internal */ m_angularError: number;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_linearMass: Mat22;\n /** @internal */ m_angularMass: number;\n\n constructor(def: MotorJointDef);\n constructor(def: MotorJointOpt, bodyA: Body, bodyB: Body);\n constructor(def: MotorJointDef | MotorJointOpt, bodyA?: Body, bodyB?: Body) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof MotorJoint)) {\n return new MotorJoint(def, bodyA, bodyB);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = MotorJoint.TYPE;\n\n this.m_linearOffset = Vec2.isValid(def.linearOffset) ? Vec2.clone(def.linearOffset) : bodyA.getLocalPoint(bodyB.getPosition());\n this.m_angularOffset = Number.isFinite(def.angularOffset) ? def.angularOffset : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_linearImpulse = Vec2.zero();\n this.m_angularImpulse = 0.0;\n\n this.m_maxForce = def.maxForce;\n this.m_maxTorque = def.maxTorque;\n this.m_correctionFactor = def.correctionFactor;\n\n // Point-to-point constraint\n // Cdot = v2 - v1\n // = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n //\n // r1 = offset - c1\n // r2 = -c2\n\n // Angle constraint\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n maxForce: this.m_maxForce,\n maxTorque: this.m_maxTorque,\n correctionFactor: this.m_correctionFactor,\n\n linearOffset: this.m_linearOffset,\n angularOffset: this.m_angularOffset,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): MotorJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new MotorJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.angularOffset)) {\n this.m_angularOffset = def.angularOffset;\n }\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.maxTorque)) {\n this.m_maxTorque = def.maxTorque;\n }\n if (Number.isFinite(def.correctionFactor)) {\n this.m_correctionFactor = def.correctionFactor;\n }\n if (Vec2.isValid(def.linearOffset)) {\n this.m_linearOffset.set(def.linearOffset); \n }\n }\n\n /**\n * Set the maximum friction force in N.\n */\n setMaxForce(force: number): void {\n if (_ASSERT) console.assert(Number.isFinite(force) && force >= 0.0);\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum friction force in N.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the maximum friction torque in N*m.\n */\n setMaxTorque(torque: number): void {\n if (_ASSERT) console.assert(Number.isFinite(torque) && torque >= 0.0);\n this.m_maxTorque = torque;\n }\n\n /**\n * Get the maximum friction torque in N*m.\n */\n getMaxTorque(): number {\n return this.m_maxTorque;\n }\n\n /**\n * Set the position correction factor in the range [0,1].\n */\n setCorrectionFactor(factor: number): void {\n if (_ASSERT) console.assert(Number.isFinite(factor) && 0.0 <= factor && factor <= 1.0);\n this.m_correctionFactor = factor;\n }\n\n /**\n * Get the position correction factor in the range [0,1].\n */\n getCorrectionFactor(): number {\n return this.m_correctionFactor;\n }\n\n /**\n * Set/get the target linear offset, in frame A, in meters.\n */\n setLinearOffset(linearOffset: Vec2Value): void {\n if (linearOffset.x != this.m_linearOffset.x || linearOffset.y != this.m_linearOffset.y) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_linearOffset.set(linearOffset);\n }\n }\n\n getLinearOffset(): Vec2 {\n return this.m_linearOffset;\n }\n\n /**\n * Set/get the target angular offset, in radians.\n */\n setAngularOffset(angularOffset: number): void {\n if (angularOffset != this.m_angularOffset) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_angularOffset = angularOffset;\n }\n }\n\n getAngularOffset(): number {\n return this.m_angularOffset;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getPosition();\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getPosition();\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_linearImpulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_angularImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective mass matrix.\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_linearOffset, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.neg(this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n // Upper 2 by 2 of K for point to point\n const K = new Mat22();\n K.ex.x = mA + mB + iA * this.m_rA.y * this.m_rA.y + iB * this.m_rB.y * this.m_rB.y;\n K.ex.y = -iA * this.m_rA.x * this.m_rA.y - iB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * this.m_rA.x * this.m_rA.x + iB * this.m_rB.x * this.m_rB.x;\n\n this.m_linearMass = K.getInverse();\n\n this.m_angularMass = iA + iB;\n if (this.m_angularMass > 0.0) {\n this.m_angularMass = 1.0 / this.m_angularMass;\n }\n\n this.m_linearError = Vec2.zero();\n this.m_linearError.addCombine(1, cB, 1, this.m_rB);\n this.m_linearError.subCombine(1, cA, 1, this.m_rA);\n\n this.m_angularError = aB - aA - this.m_angularOffset;\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_linearImpulse.mul(step.dtRatio);\n this.m_angularImpulse *= step.dtRatio;\n\n const P = Vec2.neo(this.m_linearImpulse.x, this.m_linearImpulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_angularImpulse);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_angularImpulse);\n\n } else {\n this.m_linearImpulse.setZero();\n this.m_angularImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const h = step.dt;\n const inv_h = step.inv_dt;\n\n // Solve angular friction\n {\n const Cdot = wB - wA + inv_h * this.m_correctionFactor * this.m_angularError;\n let impulse = -this.m_angularMass * Cdot;\n\n const oldImpulse = this.m_angularImpulse;\n const maxImpulse = h * this.m_maxTorque;\n this.m_angularImpulse = clamp(this.m_angularImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_angularImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve linear friction\n {\n const Cdot = Vec2.zero();\n Cdot.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n Cdot.addMul(inv_h * this.m_correctionFactor, this.m_linearError);\n\n let impulse = Vec2.neg(Mat22.mulVec2(this.m_linearMass, Cdot));\n const oldImpulse = Vec2.clone(this.m_linearImpulse);\n this.m_linearImpulse.add(impulse);\n\n const maxImpulse = h * this.m_maxForce;\n\n this.m_linearImpulse.clamp(maxImpulse);\n\n impulse = Vec2.sub(this.m_linearImpulse, oldImpulse);\n\n vA.subMul(mA, impulse);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Mat22 } from \"../../common/Mat22\";\nimport { Rot } from \"../../common/Rot\";\nimport { Transform } from \"../../common/Transform\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Mouse joint definition. This requires a world target point, tuning\n * parameters, and the time step.\n */\nexport interface MouseJointOpt extends JointOpt {\n /**\n * [maxForce = 0.0] The maximum constraint force that can be exerted to move\n * the candidate body. Usually you will express as some multiple of the\n * weight (multiplier * mass * gravity).\n */\n maxForce?: number;\n /**\n * [frequencyHz = 5.0] The response speed.\n */\n frequencyHz?: number;\n /**\n * [dampingRatio = 0.7] The damping ratio. 0 = no damping, 1 = critical\n * damping.\n */\n dampingRatio?: number;\n}\n\n/**\n * Mouse joint definition. This requires a world target point, tuning\n * parameters, and the time step.\n */\nexport interface MouseJointDef extends JointDef, MouseJointOpt {\n /**\n * The initial world target point. This is assumed to coincide with the body\n * anchor initially.\n */\n target: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxForce : 0.0,\n frequencyHz : 5.0,\n dampingRatio : 0.7\n};\n\ndeclare module \"./MouseJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MouseJoint(def: MouseJointDef): MouseJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function MouseJoint(def: MouseJointOpt, bodyA: Body, bodyB: Body, target: Vec2Value): MouseJoint;\n}\n\n/**\n * A mouse joint is used to make a point on a body track a specified world\n * point. This a soft constraint with a maximum force. This allows the\n * constraint to stretch and without applying huge forces.\n *\n * You need to call setTarget(target) every time that mouse is \n * moved, to track the new location of the mouse.\n *\n * NOTE: this joint is not documented in the manual because it was developed to\n * be used in the testbed. If you want to learn how to use the mouse joint, look\n * at the testbed.\n */\n// @ts-expect-error\nexport class MouseJoint extends Joint {\n static TYPE = \"mouse-joint\" as const;\n\n /** @internal */ m_type: \"mouse-joint\";\n /** @internal */ m_targetA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_maxForce: number;\n /** @internal */ m_impulse: Vec2;\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n /** @internal */ m_beta: number;\n /** @internal */ m_gamma: number;\n // Solver temp\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: Mat22;\n /** @internal */ m_C: Vec2;\n\n constructor(def: MouseJointDef);\n constructor(def: MouseJointOpt, bodyA: Body, bodyB: Body, target?: Vec2Value);\n constructor(def: MouseJointDef, bodyA?: Body, bodyB?: Body, target?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof MouseJoint)) {\n return new MouseJoint(def, bodyA, bodyB, target);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = MouseJoint.TYPE;\n\n if (_ASSERT) console.assert(Number.isFinite(def.maxForce) && def.maxForce >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.frequencyHz) && def.frequencyHz >= 0.0);\n if (_ASSERT) console.assert(Number.isFinite(def.dampingRatio) && def.dampingRatio >= 0.0);\n\n if (Vec2.isValid(target)) {\n this.m_targetA = Vec2.clone(target);\n } else if (Vec2.isValid(def.target)) {\n this.m_targetA = Vec2.clone(def.target);\n } else {\n this.m_targetA = Vec2.zero();\n }\n\n this.m_localAnchorB = Transform.mulTVec2(bodyB.getTransform(), this.m_targetA);\n\n this.m_maxForce = def.maxForce;\n this.m_impulse = Vec2.zero();\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_beta = 0.0;\n this.m_gamma = 0.0;\n\n // Solver temp\n this.m_rB = Vec2.zero();\n this.m_localCenterB = Vec2.zero();\n this.m_invMassB = 0.0;\n this.m_invIB = 0.0;\n this.m_mass = new Mat22();\n this.m_C = Vec2.zero();\n\n // p = attached point, m = mouse point\n // C = p - m\n // Cdot = v\n // = v + cross(w, r)\n // J = [I r_skew]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n target: this.m_targetA,\n maxForce: this.m_maxForce,\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n _localAnchorB: this.m_localAnchorB,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): MouseJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.target = Vec2.clone(data.target);\n const joint = new MouseJoint(data);\n if (data._localAnchorB) {\n joint.m_localAnchorB = data._localAnchorB;\n }\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.maxForce)) {\n this.m_maxForce = def.maxForce;\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * Use this to update the target point.\n */\n setTarget(target: Vec2Value): void {\n if (Vec2.areEqual(target, this.m_targetA)) return;\n this.m_bodyB.setAwake(true);\n this.m_targetA.set(target);\n }\n\n getTarget(): Vec2 {\n return this.m_targetA;\n }\n\n /**\n * Set the maximum force in Newtons.\n */\n setMaxForce(force: number): void {\n this.m_maxForce = force;\n }\n\n /**\n * Get the maximum force in Newtons.\n */\n getMaxForce(): number {\n return this.m_maxForce;\n }\n\n /**\n * Set the frequency in Hertz.\n */\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n /**\n * Get the frequency in Hertz.\n */\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set the damping ratio (dimensionless).\n */\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n /**\n * Get the damping ratio (dimensionless).\n */\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return Vec2.clone(this.m_targetA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(inv_dt, this.m_impulse);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * 0.0;\n }\n\n /**\n * Shift the origin for any points stored in world coordinates.\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_targetA.sub(newOrigin);\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const position = this.m_bodyB.c_position;\n const velocity = this.m_bodyB.c_velocity;\n\n const cB = position.c;\n const aB = position.a;\n const vB = velocity.v;\n let wB = velocity.w;\n\n const qB = Rot.neo(aB);\n\n const mass = this.m_bodyB.getMass();\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * mass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = mass * (omega * omega);\n\n // magic formulas\n // gamma has units of inverse mass.\n // beta has units of inverse time.\n const h = step.dt;\n if (_ASSERT) console.assert(d + h * k > EPSILON);\n this.m_gamma = h * (d + h * k);\n if (this.m_gamma != 0.0) {\n this.m_gamma = 1.0 / this.m_gamma;\n }\n this.m_beta = h * k * this.m_gamma;\n\n // Compute the effective mass matrix.\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // K = [(1/m1 + 1/m2) * eye(2) - skew(r1) * invI1 * skew(r1) - skew(r2) *\n // invI2 * skew(r2)]\n // = [1/m1+1/m2 0 ] + invI1 * [r1.y*r1.y -r1.x*r1.y] + invI2 * [r1.y*r1.y\n // -r1.x*r1.y]\n // [ 0 1/m1+1/m2] [-r1.x*r1.y r1.x*r1.x] [-r1.x*r1.y r1.x*r1.x]\n const K = new Mat22();\n K.ex.x = this.m_invMassB + this.m_invIB * this.m_rB.y * this.m_rB.y\n + this.m_gamma;\n K.ex.y = -this.m_invIB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = this.m_invMassB + this.m_invIB * this.m_rB.x * this.m_rB.x\n + this.m_gamma;\n\n this.m_mass = K.getInverse();\n\n this.m_C.setVec2(cB);\n this.m_C.addCombine(1, this.m_rB, -1, this.m_targetA);\n this.m_C.mul(this.m_beta);\n\n // Cheat with some damping\n wB *= 0.98;\n\n if (step.warmStarting) {\n this.m_impulse.mul(step.dtRatio);\n vB.addMul(this.m_invMassB, this.m_impulse);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, this.m_impulse);\n\n } else {\n this.m_impulse.setZero();\n }\n\n velocity.v.setVec2(vB);\n velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const velocity = this.m_bodyB.c_velocity;\n const vB = Vec2.clone(velocity.v);\n let wB = velocity.w;\n\n // Cdot = v + cross(w, r)\n\n const Cdot = Vec2.crossNumVec2(wB, this.m_rB);\n Cdot.add(vB);\n\n Cdot.addCombine(1, this.m_C, this.m_gamma, this.m_impulse);\n Cdot.neg();\n\n let impulse = Mat22.mulVec2(this.m_mass, Cdot);\n\n const oldImpulse = Vec2.clone(this.m_impulse);\n this.m_impulse.add(impulse);\n const maxImpulse = step.dt * this.m_maxForce;\n this.m_impulse.clamp(maxImpulse);\n impulse = Vec2.sub(this.m_impulse, oldImpulse);\n\n vB.addMul(this.m_invMassB, impulse);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, impulse);\n\n velocity.v.setVec2(vB);\n velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n return true;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { EPSILON } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n\n\n/**\n * Pulley joint definition. This requires two ground anchors, two dynamic body\n * anchor points, and a pulley ratio.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface PulleyJointOpt extends JointOpt {\n}\n\n/**\n * Pulley joint definition. This requires two ground anchors, two dynamic body\n * anchor points, and a pulley ratio.\n */\nexport interface PulleyJointDef extends JointDef, PulleyJointOpt {\n /**\n * The first ground anchor in world coordinates. This point never moves.\n */\n groundAnchorA: Vec2Value;\n /**\n * The second ground anchor in world coordinates. This point never moves.\n */\n groundAnchorB: Vec2Value;\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The reference length for the segment attached to bodyA.\n */\n lengthA: number;\n /**\n * The reference length for the segment attached to bodyB.\n */\n lengthB: number;\n /**\n * The pulley ratio, used to simulate a block-and-tackle.\n */\n ratio: number;\n\n /** @hidden */ anchorA?: Vec2Value;\n /** @hidden */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n collideConnected : true\n};\n\ndeclare module \"./PulleyJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PulleyJoint(def: PulleyJointDef): PulleyJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function PulleyJoint(def: PulleyJointOpt, bodyA: Body, bodyB: Body, groundA: Vec2Value, groundB: Vec2Value, anchorA: Vec2Value, anchorB: Vec2Value, ratio: number): PulleyJoint;\n}\n\n/**\n * The pulley joint is connected to two bodies and two fixed ground points. The\n * pulley supports a ratio such that: length1 + ratio * length2 <= constant\n *\n * Yes, the force transmitted is scaled by the ratio.\n *\n * Warning: the pulley joint can get a bit squirrelly by itself. They often work\n * better when combined with prismatic joints. You should also cover the the\n * anchor points with static shapes to prevent one side from going to zero\n * length.\n */\n// @ts-expect-error\nexport class PulleyJoint extends Joint {\n static TYPE = \"pulley-joint\" as const;\n // static MIN_PULLEY_LENGTH: number = 2.0; // TODO where this is used?\n\n /** @internal */ m_type: \"pulley-joint\";\n /** @internal */ m_groundAnchorA: Vec2;\n /** @internal */ m_groundAnchorB: Vec2;\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_lengthA: number;\n /** @internal */ m_lengthB: number;\n /** @internal */ m_ratio: number;\n /** @internal */ m_constant: number;\n /** @internal */ m_impulse: number;\n\n // Solver temp\n /** @internal */ m_uA: Vec2;\n /** @internal */ m_uB: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: number;\n\n constructor(def: PulleyJointDef);\n constructor(def: PulleyJointOpt, bodyA: Body, bodyB: Body, groundA?: Vec2Value, groundB?: Vec2Value, anchorA?: Vec2Value, anchorB?: Vec2Value, ratio?: number);\n constructor(def: PulleyJointDef, bodyA?: Body, bodyB?: Body, groundA?: Vec2Value, groundB?: Vec2Value, anchorA?: Vec2Value, anchorB?: Vec2Value, ratio?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof PulleyJoint)) {\n return new PulleyJoint(def, bodyA, bodyB, groundA, groundB, anchorA, anchorB, ratio);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = PulleyJoint.TYPE;\n this.m_groundAnchorA = Vec2.clone(groundA ? groundA : def.groundAnchorA || Vec2.neo(-1.0, 1.0));\n this.m_groundAnchorB = Vec2.clone(groundB ? groundB : def.groundAnchorB || Vec2.neo(1.0, 1.0));\n this.m_localAnchorA = Vec2.clone(anchorA ? bodyA.getLocalPoint(anchorA) : def.localAnchorA || Vec2.neo(-1.0, 0.0));\n this.m_localAnchorB = Vec2.clone(anchorB ? bodyB.getLocalPoint(anchorB) : def.localAnchorB || Vec2.neo(1.0, 0.0));\n this.m_lengthA = Number.isFinite(def.lengthA) ? def.lengthA : Vec2.distance(anchorA, groundA);\n this.m_lengthB = Number.isFinite(def.lengthB) ? def.lengthB : Vec2.distance(anchorB, groundB);\n this.m_ratio = Number.isFinite(ratio) ? ratio : def.ratio;\n\n if (_ASSERT) console.assert(ratio > EPSILON);\n\n this.m_constant = this.m_lengthA + this.m_ratio * this.m_lengthB;\n\n this.m_impulse = 0.0;\n\n // Pulley:\n // length1 = norm(p1 - s1)\n // length2 = norm(p2 - s2)\n // C0 = (length1 + ratio * length2)_initial\n // C = C0 - (length1 + ratio * length2)\n // u1 = (p1 - s1) / norm(p1 - s1)\n // u2 = (p2 - s2) / norm(p2 - s2)\n // Cdot = -dot(u1, v1 + cross(w1, r1)) - ratio * dot(u2, v2 + cross(w2, r2))\n // J = -[u1 cross(r1, u1) ratio * u2 ratio * cross(r2, u2)]\n // K = J * invM * JT\n // = invMass1 + invI1 * cross(r1, u1)^2 + ratio^2 * (invMass2 + invI2 *\n // cross(r2, u2)^2)\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n groundAnchorA: this.m_groundAnchorA,\n groundAnchorB: this.m_groundAnchorB,\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n lengthA: this.m_lengthA,\n lengthB: this.m_lengthB,\n ratio: this.m_ratio,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): PulleyJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new PulleyJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Vec2.isValid(def.groundAnchorA)) {\n this.m_groundAnchorA.set(def.groundAnchorA);\n }\n if (Vec2.isValid(def.groundAnchorB)) {\n this.m_groundAnchorB.set(def.groundAnchorB);\n }\n if (Vec2.isValid(def.localAnchorA)) {\n this.m_localAnchorA.set(def.localAnchorA);\n } else if (Vec2.isValid(def.anchorA)) {\n this.m_localAnchorA.set(this.m_bodyA.getLocalPoint(def.anchorA));\n }\n if (Vec2.isValid(def.localAnchorB)) {\n this.m_localAnchorB.set(def.localAnchorB);\n } else if (Vec2.isValid(def.anchorB)) {\n this.m_localAnchorB.set(this.m_bodyB.getLocalPoint(def.anchorB));\n }\n if (Number.isFinite(def.lengthA)) {\n this.m_lengthA = def.lengthA;\n }\n if (Number.isFinite(def.lengthB)) {\n this.m_lengthB = def.lengthB;\n }\n if (Number.isFinite(def.ratio)) {\n this.m_ratio = def.ratio;\n }\n }\n\n /**\n * Get the first ground anchor.\n */\n getGroundAnchorA(): Vec2 {\n return this.m_groundAnchorA;\n }\n\n /**\n * Get the second ground anchor.\n */\n getGroundAnchorB(): Vec2 {\n return this.m_groundAnchorB;\n }\n\n /**\n * Get the current length of the segment attached to bodyA.\n */\n getLengthA(): number {\n return this.m_lengthA;\n }\n\n /**\n * Get the current length of the segment attached to bodyB.\n */\n getLengthB(): number {\n return this.m_lengthB;\n }\n\n /**\n * Get the pulley ratio.\n */\n getRatio(): number {\n return this.m_ratio;\n }\n\n /**\n * Get the current length of the segment attached to bodyA.\n */\n getCurrentLengthA(): number {\n const p = this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n const s = this.m_groundAnchorA;\n return Vec2.distance(p, s);\n }\n\n /**\n * Get the current length of the segment attached to bodyB.\n */\n getCurrentLengthB(): number {\n const p = this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n const s = this.m_groundAnchorB;\n return Vec2.distance(p, s);\n }\n\n /**\n * Shift the origin for any points stored in world coordinates.\n *\n * @param newOrigin\n */\n shiftOrigin(newOrigin: Vec2Value): void {\n this.m_groundAnchorA.sub(newOrigin);\n this.m_groundAnchorB.sub(newOrigin);\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_uB).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // Get the pulley axes.\n this.m_uA = Vec2.sub(Vec2.add(cA, this.m_rA), this.m_groundAnchorA);\n this.m_uB = Vec2.sub(Vec2.add(cB, this.m_rB), this.m_groundAnchorB);\n\n const lengthA = this.m_uA.length();\n const lengthB = this.m_uB.length();\n\n if (lengthA > 10.0 * Settings.linearSlop) {\n this.m_uA.mul(1.0 / lengthA);\n } else {\n this.m_uA.setZero();\n }\n\n if (lengthB > 10.0 * Settings.linearSlop) {\n this.m_uB.mul(1.0 / lengthB);\n } else {\n this.m_uB.setZero();\n }\n\n // Compute effective mass.\n const ruA = Vec2.crossVec2Vec2(this.m_rA, this.m_uA);\n const ruB = Vec2.crossVec2Vec2(this.m_rB, this.m_uB);\n\n const mA = this.m_invMassA + this.m_invIA * ruA * ruA;\n const mB = this.m_invMassB + this.m_invIB * ruB * ruB;\n\n this.m_mass = mA + this.m_ratio * this.m_ratio * mB;\n\n if (this.m_mass > 0.0) {\n this.m_mass = 1.0 / this.m_mass;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support variable time steps.\n this.m_impulse *= step.dtRatio;\n\n // Warm starting.\n const PA = Vec2.mulNumVec2(-this.m_impulse, this.m_uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * this.m_impulse, this.m_uB);\n\n vA.addMul(this.m_invMassA, PA);\n wA += this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, PA);\n\n vB.addMul(this.m_invMassB, PB);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, PB);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const vpA = Vec2.add(vA, Vec2.crossNumVec2(wA, this.m_rA));\n const vpB = Vec2.add(vB, Vec2.crossNumVec2(wB, this.m_rB));\n\n const Cdot = -Vec2.dot(this.m_uA, vpA) - this.m_ratio * Vec2.dot(this.m_uB, vpB);\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n const PA = Vec2.mulNumVec2(-impulse, this.m_uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * impulse, this.m_uB);\n vA.addMul(this.m_invMassA, PA);\n wA += this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, PA);\n vB.addMul(this.m_invMassB, PB);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, PB);\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // Get the pulley axes.\n const uA = Vec2.sub(Vec2.add(cA, this.m_rA), this.m_groundAnchorA);\n const uB = Vec2.sub(Vec2.add(cB, this.m_rB), this.m_groundAnchorB);\n\n const lengthA = uA.length();\n const lengthB = uB.length();\n\n if (lengthA > 10.0 * Settings.linearSlop) {\n uA.mul(1.0 / lengthA);\n } else {\n uA.setZero();\n }\n\n if (lengthB > 10.0 * Settings.linearSlop) {\n uB.mul(1.0 / lengthB);\n } else {\n uB.setZero();\n }\n\n // Compute effective mass.\n const ruA = Vec2.crossVec2Vec2(rA, uA);\n const ruB = Vec2.crossVec2Vec2(rB, uB);\n\n const mA = this.m_invMassA + this.m_invIA * ruA * ruA;\n const mB = this.m_invMassB + this.m_invIB * ruB * ruB;\n\n let mass = mA + this.m_ratio * this.m_ratio * mB;\n\n if (mass > 0.0) {\n mass = 1.0 / mass;\n }\n\n const C = this.m_constant - lengthA - this.m_ratio * lengthB;\n const linearError = math_abs(C);\n\n const impulse = -mass * C;\n\n const PA = Vec2.mulNumVec2(-impulse, uA);\n const PB = Vec2.mulNumVec2(-this.m_ratio * impulse, uB);\n\n cA.addMul(this.m_invMassA, PA);\n aA += this.m_invIA * Vec2.crossVec2Vec2(rA, PA);\n cB.addMul(this.m_invMassB, PB);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, PB);\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return linearError < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_min = Math.min;\n\n/** @internal */ enum LimitState {\n inactiveLimit = 0,\n atLowerLimit = 1,\n atUpperLimit = 2,\n equalLimits = 3,\n}\n\n/**\n * Rope joint definition. This requires two body anchor points and a maximum\n * lengths. Note: by default the connected objects will not collide. see\n * collideConnected in JointDef.\n */\nexport interface RopeJointOpt extends JointOpt {\n /**\n * The maximum length of the rope.\n * Warning: this must be larger than linearSlop or the joint will have no effect.\n */\n maxLength?: number;\n}\n\n/**\n * Rope joint definition. This requires two body anchor points and a maximum\n * lengths. Note: by default the connected objects will not collide. see\n * collideConnected in JointDef.\n */\nexport interface RopeJointDef extends JointDef, RopeJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n maxLength : 0.0,\n};\n\ndeclare module \"./RopeJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RopeJoint(def: RopeJointDef): RopeJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function RopeJoint(def: RopeJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): RopeJoint;\n}\n\n/**\n * A rope joint enforces a maximum distance between two points on two bodies. It\n * has no other effect.\n *\n * Warning: if you attempt to change the maximum length during the simulation\n * you will get some non-physical behavior.\n *\n * A model that would allow you to dynamically modify the length would have some\n * sponginess, so I chose not to implement it that way. See {@link DistanceJoint} if you\n * want to dynamically control length.\n */\n// @ts-expect-error\nexport class RopeJoint extends Joint {\n static TYPE = \"rope-joint\" as const;\n\n /** @internal */ m_type: \"rope-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n\n /** @internal */ m_maxLength: number;\n\n /** @internal */ m_mass: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_length: number;\n /** @internal */ m_state: number; // TODO enum\n\n // Solver temp\n /** @internal */ m_u: Vec2;\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n\n constructor(def: RopeJointDef);\n constructor(def: RopeJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: RopeJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof RopeJoint)) {\n return new RopeJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = RopeJoint.TYPE;\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.neo(-1.0, 0.0));\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.neo(1.0, 0.0));\n\n this.m_maxLength = def.maxLength;\n\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n this.m_length = 0.0;\n this.m_state = LimitState.inactiveLimit;\n\n // Limit:\n // C = norm(pB - pA) - L\n // u = (pB - pA) / norm(pB - pA)\n // Cdot = dot(u, vB + cross(wB, rB) - vA - cross(wA, rA))\n // J = [-u -cross(rA, u) u cross(rB, u)]\n // K = J * invM * JT\n // = invMassA + invIA * cross(rA, u)^2 + invMassB + invIB * cross(rB, u)^2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n maxLength: this.m_maxLength,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): RopeJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new RopeJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (Number.isFinite(def.maxLength)) {\n this.m_maxLength = def.maxLength;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Set the maximum length of the rope.\n */\n setMaxLength(length: number): void {\n this.m_maxLength = length;\n }\n\n /**\n * Get the maximum length of the rope.\n */\n getMaxLength(): number {\n return this.m_maxLength;\n }\n\n getLimitState(): number {\n // TODO LimitState\n return this.m_state;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.mulNumVec2(this.m_impulse, this.m_u).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return 0.0;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n this.m_rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n this.m_u = Vec2.zero();\n this.m_u.addCombine(1, cB, 1, this.m_rB);\n this.m_u.subCombine(1, cA, 1, this.m_rA);\n\n this.m_length = this.m_u.length();\n\n const C = this.m_length - this.m_maxLength;\n if (C > 0.0) {\n this.m_state = LimitState.atUpperLimit;\n } else {\n this.m_state = LimitState.inactiveLimit;\n }\n\n if (this.m_length > Settings.linearSlop) {\n this.m_u.mul(1.0 / this.m_length);\n } else {\n this.m_u.setZero();\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n return;\n }\n\n // Compute effective mass.\n const crA = Vec2.crossVec2Vec2(this.m_rA, this.m_u);\n const crB = Vec2.crossVec2Vec2(this.m_rB, this.m_u);\n const invMass = this.m_invMassA + this.m_invIA * crA * crA + this.m_invMassB + this.m_invIB * crB * crB;\n\n this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;\n\n if (step.warmStarting) {\n // Scale the impulse to support a variable time step.\n this.m_impulse *= step.dtRatio;\n\n const P = Vec2.mulNumVec2(this.m_impulse, this.m_u);\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Cdot = dot(u, v + cross(w, r))\n const vpA = Vec2.addCrossNumVec2(vA, wA, this.m_rA);\n const vpB = Vec2.addCrossNumVec2(vB, wB, this.m_rB);\n const C = this.m_length - this.m_maxLength;\n let Cdot = Vec2.dot(this.m_u, Vec2.sub(vpB, vpA));\n\n // Predictive constraint.\n if (C < 0.0) {\n Cdot += step.inv_dt * C;\n }\n\n let impulse = -this.m_mass * Cdot;\n const oldImpulse = this.m_impulse;\n this.m_impulse = math_min(0.0, this.m_impulse + impulse);\n impulse = this.m_impulse - oldImpulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_u);\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.crossVec2Vec2(this.m_rA, P);\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.crossVec2Vec2(this.m_rB, P);\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n const rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n const u = Vec2.zero();\n u.addCombine(1, cB, 1, rB);\n u.subCombine(1, cA, 1, rA);\n\n const length = u.normalize();\n let C = length - this.m_maxLength;\n\n C = clamp(C, 0.0, Settings.maxLinearCorrection);\n\n const impulse = -this.m_mass * C;\n const P = Vec2.mulNumVec2(impulse, u);\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * Vec2.crossVec2Vec2(rA, P);\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * Vec2.crossVec2Vec2(rB, P);\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return length - this.m_maxLength < Settings.linearSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Vec3 } from \"../../common/Vec3\";\nimport { Mat33 } from \"../../common/Mat33\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Weld joint definition. You need to specify local anchor points where they are\n * attached and the relative body angle. The position of the anchor points is\n * important for computing the reaction torque.\n */\nexport interface WeldJointOpt extends JointOpt {\n /**\n * The mass-spring-damper frequency in Hertz. Rotation only. Disable softness\n * with a value of 0.\n */\n frequencyHz?: number;\n /**\n * The damping ratio. 0 = no damping, 1 = critical damping.\n */\n dampingRatio?: number;\n /**\n * The bodyB angle minus bodyA angle in the reference state (radians).\n */\n referenceAngle?: number;\n}\n\n/**\n * Weld joint definition. You need to specify local anchor points where they are\n * attached and the relative body angle. The position of the anchor points is\n * important for computing the reaction torque.\n */\nexport interface WeldJointDef extends JointDef, WeldJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n frequencyHz : 0.0,\n dampingRatio : 0.0,\n};\n\ndeclare module \"./WeldJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WeldJoint(def: WeldJointDef): WeldJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WeldJoint(def: WeldJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value): WeldJoint;\n}\n\n/**\n * A weld joint essentially glues two bodies together. A weld joint may distort\n * somewhat because the island constraint solver is approximate.\n */\n// @ts-expect-error\nexport class WeldJoint extends Joint {\n static TYPE = \"weld-joint\" as const;\n\n /** @internal */ m_type: \"weld-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_referenceAngle: number;\n\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n\n /** @internal */ m_impulse: Vec3;\n\n /** @internal */ m_bias: number;\n /** @internal */ m_gamma: number;\n\n // Solver temp\n /** @internal */ m_rA: Vec2;\n /** @internal */ m_rB: Vec2;\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n /** @internal */ m_mass: Mat33;\n\n constructor(def: WeldJointDef);\n constructor(def: WeldJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value);\n constructor(def: WeldJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof WeldJoint)) {\n return new WeldJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = WeldJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n this.m_referenceAngle = Number.isFinite(def.referenceAngle) ? def.referenceAngle : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_impulse = new Vec3();\n\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n\n // Solver temp\n // todo: do we need to initialize?\n // this.m_rA;\n // this.m_rB;\n // this.m_localCenterA;\n // this.m_localCenterB;\n // this.m_invMassA;\n // this.m_invMassB;\n // this.m_invIA;\n // this.m_invIB;\n this.m_mass = new Mat33();\n\n // Point-to-point constraint\n // C = p2 - p1\n // Cdot = v2 - v1\n // / = v2 + cross(w2, r2) - v1 - cross(w1, r1)\n // J = [-I -r1_skew I r2_skew ]\n // Identity used:\n // w k % (rx i + ry j) = w * (-ry i + rx j)\n\n // Angle constraint\n // C = angle2 - angle1 - referenceAngle\n // Cdot = w2 - w1\n // J = [0 0 -1 0 0 1]\n // K = invI1 + invI2\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n referenceAngle: this.m_referenceAngle,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): WeldJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new WeldJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * Get the reference angle.\n */\n getReferenceAngle(): number {\n return this.m_referenceAngle;\n }\n\n /**\n * Set frequency in Hz.\n */\n setFrequency(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n /**\n * Get frequency in Hz.\n */\n getFrequency(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set damping ratio.\n */\n setDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n /**\n * Get damping ratio.\n */\n getDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.neo(this.m_impulse.x, this.m_impulse.y).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_impulse.z;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n this.m_rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // J = [-I -r1_skew I r2_skew]\n // [ 0 -1 0 1]\n // r_skew = [-ry; rx]\n\n // Matlab\n // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]\n // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]\n // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const K = new Mat33();\n K.ex.x = mA + mB + this.m_rA.y * this.m_rA.y * iA + this.m_rB.y * this.m_rB.y\n * iB;\n K.ey.x = -this.m_rA.y * this.m_rA.x * iA - this.m_rB.y * this.m_rB.x * iB;\n K.ez.x = -this.m_rA.y * iA - this.m_rB.y * iB;\n K.ex.y = K.ey.x;\n K.ey.y = mA + mB + this.m_rA.x * this.m_rA.x * iA + this.m_rB.x * this.m_rB.x\n * iB;\n K.ez.y = this.m_rA.x * iA + this.m_rB.x * iB;\n K.ex.z = K.ez.x;\n K.ey.z = K.ez.y;\n K.ez.z = iA + iB;\n\n if (this.m_frequencyHz > 0.0) {\n K.getInverse22(this.m_mass);\n\n let invM = iA + iB;\n const m = invM > 0.0 ? 1.0 / invM : 0.0;\n\n const C = aB - aA - this.m_referenceAngle;\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const d = 2.0 * m * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = m * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (d + h * k);\n this.m_gamma = this.m_gamma != 0.0 ? 1.0 / this.m_gamma : 0.0;\n this.m_bias = C * h * k * this.m_gamma;\n\n invM += this.m_gamma;\n this.m_mass.ez.z = invM != 0.0 ? 1.0 / invM : 0.0;\n } else if (K.ez.z == 0.0) {\n K.getInverse22(this.m_mass);\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n } else {\n K.getSymInverse33(this.m_mass);\n this.m_gamma = 0.0;\n this.m_bias = 0.0;\n }\n\n if (step.warmStarting) {\n // Scale impulses to support a variable time step.\n this.m_impulse.mul(step.dtRatio);\n\n const P = Vec2.neo(this.m_impulse.x, this.m_impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + this.m_impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + this.m_impulse.z);\n\n } else {\n this.m_impulse.setZero();\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n if (this.m_frequencyHz > 0.0) {\n const Cdot2 = wB - wA;\n\n const impulse2 = -this.m_mass.ez.z * (Cdot2 + this.m_bias + this.m_gamma * this.m_impulse.z);\n this.m_impulse.z += impulse2;\n\n wA -= iA * impulse2;\n wB += iB * impulse2;\n\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n\n const impulse1 = Vec2.neg(Mat33.mulVec2(this.m_mass, Cdot1));\n this.m_impulse.x += impulse1.x;\n this.m_impulse.y += impulse1.y;\n\n const P = Vec2.clone(impulse1);\n\n vA.subMul(mA, P);\n wA -= iA * Vec2.crossVec2Vec2(this.m_rA, P);\n\n vB.addMul(mB, P);\n wB += iB * Vec2.crossVec2Vec2(this.m_rB, P);\n } else {\n const Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.crossNumVec2(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.crossNumVec2(wA, this.m_rA));\n const Cdot2 = wB - wA;\n const Cdot = new Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n const impulse = Vec3.neg(Mat33.mulVec3(this.m_mass, Cdot));\n this.m_impulse.add(impulse);\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.crossVec2Vec2(this.m_rA, P) + impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.crossVec2Vec2(this.m_rB, P) + impulse.z);\n }\n\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n let positionError: number;\n let angularError: number;\n\n const K = new Mat33();\n K.ex.x = mA + mB + rA.y * rA.y * iA + rB.y * rB.y * iB;\n K.ey.x = -rA.y * rA.x * iA - rB.y * rB.x * iB;\n K.ez.x = -rA.y * iA - rB.y * iB;\n K.ex.y = K.ey.x;\n K.ey.y = mA + mB + rA.x * rA.x * iA + rB.x * rB.x * iB;\n K.ez.y = rA.x * iA + rB.x * iB;\n K.ex.z = K.ez.x;\n K.ey.z = K.ez.y;\n K.ez.z = iA + iB;\n\n if (this.m_frequencyHz > 0.0) {\n const C1 = Vec2.zero();\n C1.addCombine(1, cB, 1, rB);\n C1.subCombine(1, cA, 1, rA);\n\n positionError = C1.length();\n angularError = 0.0;\n\n const P = Vec2.neg(K.solve22(C1));\n\n cA.subMul(mA, P);\n aA -= iA * Vec2.crossVec2Vec2(rA, P);\n\n cB.addMul(mB, P);\n aB += iB * Vec2.crossVec2Vec2(rB, P);\n } else {\n const C1 = Vec2.zero();\n C1.addCombine(1, cB, 1, rB);\n C1.subCombine(1, cA, 1, rA);\n\n const C2 = aB - aA - this.m_referenceAngle;\n\n positionError = C1.length();\n angularError = math_abs(C2);\n\n const C = new Vec3(C1.x, C1.y, C2);\n\n let impulse = new Vec3();\n if (K.ez.z > 0.0) {\n impulse = Vec3.neg(K.solve33(C));\n } else {\n const impulse2 = Vec2.neg(K.solve22(C1));\n impulse.set(impulse2.x, impulse2.y, 0.0);\n }\n\n const P = Vec2.neo(impulse.x, impulse.y);\n\n cA.subMul(mA, P);\n aA -= iA * (Vec2.crossVec2Vec2(rA, P) + impulse.z);\n\n cB.addMul(mB, P);\n aB += iB * (Vec2.crossVec2Vec2(rB, P) + impulse.z);\n }\n\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n\n return positionError <= Settings.linearSlop && angularError <= Settings.angularSlop;\n }\n\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { options } from \"../../util/options\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { clamp } from \"../../common/Math\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { Rot } from \"../../common/Rot\";\nimport { Joint, JointOpt, JointDef } from \"../Joint\";\nimport { Body } from \"../Body\";\nimport { TimeStep } from \"../Solver\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n/** @internal */ const math_abs = Math.abs;\n/** @internal */ const math_PI = Math.PI;\n\n\n/**\n * Wheel joint definition. This requires defining a line of motion using an axis\n * and an anchor point. The definition uses local anchor points and a local axis\n * so that the initial configuration can violate the constraint slightly. The\n * joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface WheelJointOpt extends JointOpt {\n /**\n * Enable/disable the joint motor.\n */\n enableMotor?: boolean;\n /**\n * The maximum motor torque, usually in N-m.\n */\n maxMotorTorque?: number;\n /**\n * The desired motor speed in radians per second.\n */\n motorSpeed?: number;\n /**\n * Suspension frequency, zero indicates no suspension.\n */\n frequencyHz?: number;\n /**\n * Suspension damping ratio, one indicates critical damping.\n */\n dampingRatio?: number;\n}\n\n/**\n * Wheel joint definition. This requires defining a line of motion using an axis\n * and an anchor point. The definition uses local anchor points and a local axis\n * so that the initial configuration can violate the constraint slightly. The\n * joint translation is zero when the local anchor points coincide in world\n * space. Using local anchors and a local axis helps when saving and loading a\n * game.\n */\nexport interface WheelJointDef extends JointDef, WheelJointOpt {\n /**\n * The local anchor point relative to bodyA's origin.\n */\n localAnchorA: Vec2Value;\n /**\n * The local anchor point relative to bodyB's origin.\n */\n localAnchorB: Vec2Value;\n /**\n * The local translation axis in bodyA.\n */\n localAxisA: Vec2Value;\n\n /** @internal renamed to localAxisA */\n localAxis?: Vec2Value;\n\n /** @internal */ anchorA?: Vec2Value;\n /** @internal */ anchorB?: Vec2Value;\n}\n\n/** @internal */ const DEFAULTS = {\n enableMotor : false,\n maxMotorTorque : 0.0,\n motorSpeed : 0.0,\n frequencyHz : 2.0,\n dampingRatio : 0.7,\n};\n\ndeclare module \"./WheelJoint\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WheelJoint(def: WheelJointDef): WheelJoint;\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function WheelJoint(def: WheelJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2Value, axis: Vec2Value): WheelJoint;\n}\n\n/**\n * A wheel joint. This joint provides two degrees of freedom: translation along\n * an axis fixed in bodyA and rotation in the plane. In other words, it is a\n * point to line constraint with a rotational motor and a linear spring/damper.\n * This joint is designed for vehicle suspensions.\n */\n// @ts-expect-error\nexport class WheelJoint extends Joint {\n static TYPE = \"wheel-joint\" as const;\n\n /** @internal */ m_type: \"wheel-joint\";\n /** @internal */ m_localAnchorA: Vec2;\n /** @internal */ m_localAnchorB: Vec2;\n /** @internal */ m_localXAxisA: Vec2;\n /** @internal */ m_localYAxisA: Vec2;\n\n /** @internal */ m_mass: number;\n /** @internal */ m_impulse: number;\n /** @internal */ m_motorMass: number;\n /** @internal */ m_motorImpulse: number;\n /** @internal */ m_springMass: number;\n /** @internal */ m_springImpulse: number;\n\n /** @internal */ m_maxMotorTorque: number;\n /** @internal */ m_motorSpeed: number;\n /** @internal */ m_enableMotor: boolean;\n\n /** @internal */ m_frequencyHz: number;\n /** @internal */ m_dampingRatio: number;\n\n /** @internal */ m_bias: number;\n /** @internal */ m_gamma: number;\n\n // Solver temp\n /** @internal */ m_localCenterA: Vec2;\n /** @internal */ m_localCenterB: Vec2;\n /** @internal */ m_invMassA: number;\n /** @internal */ m_invMassB: number;\n /** @internal */ m_invIA: number;\n /** @internal */ m_invIB: number;\n\n /** @internal */ m_ax: Vec2;\n /** @internal */ m_ay: Vec2;\n /** @internal */ m_sAx: number;\n /** @internal */ m_sBx: number;\n /** @internal */ m_sAy: number;\n /** @internal */ m_sBy: number;\n\n constructor(def: WheelJointDef);\n constructor(def: WheelJointOpt, bodyA: Body, bodyB: Body, anchor?: Vec2Value, axis?: Vec2Value);\n constructor(def: WheelJointDef, bodyA?: Body, bodyB?: Body, anchor?: Vec2Value, axis?: Vec2Value) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof WheelJoint)) {\n return new WheelJoint(def, bodyA, bodyB, anchor, axis);\n }\n\n def = options(def, DEFAULTS);\n super(def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_ax = Vec2.zero();\n this.m_ay = Vec2.zero();\n\n this.m_type = WheelJoint.TYPE;\n\n this.m_localAnchorA = Vec2.clone(anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.zero());\n this.m_localAnchorB = Vec2.clone(anchor ? bodyB.getLocalPoint(anchor) : def.localAnchorB || Vec2.zero());\n\n if (Vec2.isValid(axis)) {\n this.m_localXAxisA = bodyA.getLocalVector(axis);\n } else if (Vec2.isValid(def.localAxisA)) {\n this.m_localXAxisA = Vec2.clone(def.localAxisA);\n } else if (Vec2.isValid(def.localAxis)) {\n // localAxis is renamed to localAxisA, this is for backward compatibility\n this.m_localXAxisA = Vec2.clone(def.localAxis);\n } else {\n this.m_localXAxisA = Vec2.neo(1.0, 0.0);\n }\n\n this.m_localYAxisA = Vec2.crossNumVec2(1.0, this.m_localXAxisA);\n\n this.m_mass = 0.0;\n this.m_impulse = 0.0;\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n this.m_springMass = 0.0;\n this.m_springImpulse = 0.0;\n\n this.m_maxMotorTorque = def.maxMotorTorque;\n this.m_motorSpeed = def.motorSpeed;\n this.m_enableMotor = def.enableMotor;\n\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n\n // Linear constraint (point-to-line)\n // d = pB - pA = xB + rB - xA - rA\n // C = dot(ay, d)\n // Cdot = dot(d, cross(wA, ay)) + dot(ay, vB + cross(wB, rB) - vA - cross(wA,\n // rA))\n // = -dot(ay, vA) - dot(cross(d + rA, ay), wA) + dot(ay, vB) + dot(cross(rB,\n // ay), vB)\n // J = [-ay, -cross(d + rA, ay), ay, cross(rB, ay)]\n\n // Spring linear constraint\n // C = dot(ax, d)\n // Cdot = = -dot(ax, vA) - dot(cross(d + rA, ax), wA) + dot(ax, vB) +\n // dot(cross(rB, ax), vB)\n // J = [-ax -cross(d+rA, ax) ax cross(rB, ax)]\n\n // Motor rotational constraint\n // Cdot = wB - wA\n // J = [0 0 -1 0 0 1]\n }\n\n /** @internal */\n _serialize(): object {\n return {\n type: this.m_type,\n bodyA: this.m_bodyA,\n bodyB: this.m_bodyB,\n collideConnected: this.m_collideConnected,\n\n enableMotor: this.m_enableMotor,\n maxMotorTorque: this.m_maxMotorTorque,\n motorSpeed: this.m_motorSpeed,\n frequencyHz: this.m_frequencyHz,\n dampingRatio: this.m_dampingRatio,\n\n localAnchorA: this.m_localAnchorA,\n localAnchorB: this.m_localAnchorB,\n localAxisA: this.m_localXAxisA,\n };\n }\n\n /** @internal */\n static _deserialize(data: any, world: any, restore: any): WheelJoint {\n data = {...data};\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n const joint = new WheelJoint(data);\n return joint;\n }\n\n /** @hidden */\n _reset(def: Partial): void {\n if (def.anchorA) {\n this.m_localAnchorA.setVec2(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.setVec2(def.localAnchorA);\n }\n if (def.anchorB) {\n this.m_localAnchorB.setVec2(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.setVec2(def.localAnchorB);\n }\n if (def.localAxisA) {\n this.m_localXAxisA.setVec2(def.localAxisA);\n this.m_localYAxisA.setVec2(Vec2.crossNumVec2(1.0, def.localAxisA));\n }\n if (def.enableMotor !== undefined) {\n this.m_enableMotor = def.enableMotor;\n }\n if (Number.isFinite(def.maxMotorTorque)) {\n this.m_maxMotorTorque = def.maxMotorTorque;\n }\n if (Number.isFinite(def.motorSpeed)) {\n this.m_motorSpeed = def.motorSpeed;\n }\n if (Number.isFinite(def.frequencyHz)) {\n this.m_frequencyHz = def.frequencyHz;\n }\n if (Number.isFinite(def.dampingRatio)) {\n this.m_dampingRatio = def.dampingRatio;\n }\n }\n\n /**\n * The local anchor point relative to bodyA's origin.\n */\n getLocalAnchorA(): Vec2 {\n return this.m_localAnchorA;\n }\n\n /**\n * The local anchor point relative to bodyB's origin.\n */\n getLocalAnchorB(): Vec2 {\n return this.m_localAnchorB;\n }\n\n /**\n * The local joint axis relative to bodyA.\n */\n getLocalAxisA(): Vec2 {\n return this.m_localXAxisA;\n }\n\n /**\n * Get the current joint translation, usually in meters.\n */\n getJointTranslation(): number {\n const bA = this.m_bodyA;\n const bB = this.m_bodyB;\n\n const pA = bA.getWorldPoint(this.m_localAnchorA);\n const pB = bB.getWorldPoint(this.m_localAnchorB);\n const d = Vec2.sub(pB, pA);\n const axis = bA.getWorldVector(this.m_localXAxisA);\n\n const translation = Vec2.dot(d, axis);\n return translation;\n }\n\n /**\n * Get the current joint translation speed, usually in meters per second.\n */\n getJointSpeed(): number {\n const wA = this.m_bodyA.m_angularVelocity;\n const wB = this.m_bodyB.m_angularVelocity;\n return wB - wA;\n }\n\n /**\n * Is the joint motor enabled?\n */\n isMotorEnabled(): boolean {\n return this.m_enableMotor;\n }\n\n /**\n * Enable/disable the joint motor.\n */\n enableMotor(flag: boolean): void {\n if (flag == this.m_enableMotor) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n }\n\n /**\n * Set the motor speed, usually in radians per second.\n */\n setMotorSpeed(speed: number): void {\n if (speed == this.m_motorSpeed) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n }\n\n /**\n * Get the motor speed, usually in radians per second.\n */\n getMotorSpeed(): number {\n return this.m_motorSpeed;\n }\n\n /**\n * Set/Get the maximum motor force, usually in N-m.\n */\n setMaxMotorTorque(torque: number): void {\n if (torque == this.m_maxMotorTorque) return;\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorTorque = torque;\n }\n\n getMaxMotorTorque(): number {\n return this.m_maxMotorTorque;\n }\n\n /**\n * Get the current motor torque given the inverse time step, usually in N-m.\n */\n getMotorTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n /**\n * Set/Get the spring frequency in hertz. Setting the frequency to zero disables\n * the spring.\n */\n setSpringFrequencyHz(hz: number): void {\n this.m_frequencyHz = hz;\n }\n\n getSpringFrequencyHz(): number {\n return this.m_frequencyHz;\n }\n\n /**\n * Set/Get the spring damping ratio\n */\n setSpringDampingRatio(ratio: number): void {\n this.m_dampingRatio = ratio;\n }\n\n getSpringDampingRatio(): number {\n return this.m_dampingRatio;\n }\n\n /**\n * Get the anchor point on bodyA in world coordinates.\n */\n getAnchorA(): Vec2 {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n }\n\n /**\n * Get the anchor point on bodyB in world coordinates.\n */\n getAnchorB(): Vec2 {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n }\n\n /**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n */\n getReactionForce(inv_dt: number): Vec2 {\n return Vec2.combine(this.m_impulse, this.m_ay, this.m_springImpulse, this.m_ax).mul(inv_dt);\n }\n\n /**\n * Get the reaction torque on bodyB in N*m.\n */\n getReactionTorque(inv_dt: number): number {\n return inv_dt * this.m_motorImpulse;\n }\n\n initVelocityConstraints(step: TimeStep): void {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const cA = this.m_bodyA.c_position.c;\n const aA = this.m_bodyA.c_position.a;\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n\n const cB = this.m_bodyB.c_position.c;\n const aB = this.m_bodyB.c_position.a;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n // Compute the effective masses.\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n // Point to line constraint\n {\n this.m_ay = Rot.mulVec2(qA, this.m_localYAxisA);\n this.m_sAy = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_ay);\n this.m_sBy = Vec2.crossVec2Vec2(rB, this.m_ay);\n\n this.m_mass = mA + mB + iA * this.m_sAy * this.m_sAy + iB * this.m_sBy\n * this.m_sBy;\n\n if (this.m_mass > 0.0) {\n this.m_mass = 1.0 / this.m_mass;\n }\n }\n\n // Spring constraint\n this.m_springMass = 0.0;\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n if (this.m_frequencyHz > 0.0) {\n this.m_ax = Rot.mulVec2(qA, this.m_localXAxisA);\n this.m_sAx = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_ax);\n this.m_sBx = Vec2.crossVec2Vec2(rB, this.m_ax);\n\n const invMass = mA + mB + iA * this.m_sAx * this.m_sAx + iB * this.m_sBx\n * this.m_sBx;\n\n if (invMass > 0.0) {\n this.m_springMass = 1.0 / invMass;\n\n const C = Vec2.dot(d, this.m_ax);\n\n // Frequency\n const omega = 2.0 * math_PI * this.m_frequencyHz;\n\n // Damping coefficient\n const damp = 2.0 * this.m_springMass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n const k = this.m_springMass * omega * omega;\n\n // magic formulas\n const h = step.dt;\n this.m_gamma = h * (damp + h * k);\n if (this.m_gamma > 0.0) {\n this.m_gamma = 1.0 / this.m_gamma;\n }\n\n this.m_bias = C * h * k * this.m_gamma;\n\n this.m_springMass = invMass + this.m_gamma;\n if (this.m_springMass > 0.0) {\n this.m_springMass = 1.0 / this.m_springMass;\n }\n }\n } else {\n this.m_springImpulse = 0.0;\n }\n\n // Rotational motor\n if (this.m_enableMotor) {\n this.m_motorMass = iA + iB;\n if (this.m_motorMass > 0.0) {\n this.m_motorMass = 1.0 / this.m_motorMass;\n }\n } else {\n this.m_motorMass = 0.0;\n this.m_motorImpulse = 0.0;\n }\n\n if (step.warmStarting) {\n // Account for variable time step.\n this.m_impulse *= step.dtRatio;\n this.m_springImpulse *= step.dtRatio;\n this.m_motorImpulse *= step.dtRatio;\n\n const P = Vec2.combine(this.m_impulse, this.m_ay, this.m_springImpulse, this.m_ax);\n const LA = this.m_impulse * this.m_sAy + this.m_springImpulse * this.m_sAx + this.m_motorImpulse;\n const LB = this.m_impulse * this.m_sBy + this.m_springImpulse * this.m_sBx + this.m_motorImpulse;\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * LA;\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * LB;\n\n } else {\n this.m_impulse = 0.0;\n this.m_springImpulse = 0.0;\n this.m_motorImpulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n solveVelocityConstraints(step: TimeStep): void {\n const mA = this.m_invMassA;\n const mB = this.m_invMassB;\n const iA = this.m_invIA;\n const iB = this.m_invIB;\n\n const vA = this.m_bodyA.c_velocity.v;\n let wA = this.m_bodyA.c_velocity.w;\n const vB = this.m_bodyB.c_velocity.v;\n let wB = this.m_bodyB.c_velocity.w;\n\n // Solve spring constraint\n {\n const Cdot = Vec2.dot(this.m_ax, vB) - Vec2.dot(this.m_ax, vA) + this.m_sBx * wB - this.m_sAx * wA;\n const impulse = -this.m_springMass * (Cdot + this.m_bias + this.m_gamma * this.m_springImpulse);\n this.m_springImpulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_ax);\n const LA = impulse * this.m_sAx;\n const LB = impulse * this.m_sBx;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n // Solve rotational motor constraint\n {\n const Cdot = wB - wA - this.m_motorSpeed;\n let impulse = -this.m_motorMass * Cdot;\n\n const oldImpulse = this.m_motorImpulse;\n const maxImpulse = step.dt * this.m_maxMotorTorque;\n this.m_motorImpulse = clamp(this.m_motorImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n\n // Solve point to line constraint\n {\n const Cdot = Vec2.dot(this.m_ay, vB) - Vec2.dot(this.m_ay, vA) + this.m_sBy * wB - this.m_sAy * wA;\n const impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n\n const P = Vec2.mulNumVec2(impulse, this.m_ay);\n const LA = impulse * this.m_sAy;\n const LB = impulse * this.m_sBy;\n\n vA.subMul(mA, P);\n wA -= iA * LA;\n\n vB.addMul(mB, P);\n wB += iB * LB;\n }\n\n this.m_bodyA.c_velocity.v.setVec2(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.setVec2(vB);\n this.m_bodyB.c_velocity.w = wB;\n }\n\n /**\n * This returns true if the position errors are within tolerance.\n */\n solvePositionConstraints(step: TimeStep): boolean {\n const cA = this.m_bodyA.c_position.c;\n let aA = this.m_bodyA.c_position.a;\n const cB = this.m_bodyB.c_position.c;\n let aB = this.m_bodyB.c_position.a;\n\n const qA = Rot.neo(aA);\n const qB = Rot.neo(aB);\n\n const rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n const rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n const d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n const ay = Rot.mulVec2(qA, this.m_localYAxisA);\n\n const sAy = Vec2.crossVec2Vec2(Vec2.add(d, rA), ay);\n const sBy = Vec2.crossVec2Vec2(rB, ay);\n\n const C = Vec2.dot(d, ay);\n\n const k = this.m_invMassA + this.m_invMassB + this.m_invIA * this.m_sAy * this.m_sAy + this.m_invIB * this.m_sBy * this.m_sBy;\n\n const impulse = k != 0.0 ? -C / k : 0.0;\n\n const P = Vec2.mulNumVec2(impulse, ay);\n const LA = impulse * sAy;\n const LB = impulse * sBy;\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * LA;\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * LB;\n\n this.m_bodyA.c_position.c.setVec2(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.setVec2(cB);\n this.m_bodyB.c_position.a = aB;\n\n return math_abs(C) <= Settings.linearSlop;\n }\n\n}\n","import { World } from \"../dynamics/World\";\nimport { Body } from \"../dynamics/Body\";\nimport { Joint } from \"../dynamics/Joint\";\nimport { Fixture } from \"../dynamics/Fixture\";\nimport { Shape } from \"../collision/Shape\";\nimport { Vec2 } from \"../common/Vec2\";\nimport { Vec3 } from \"../common/Vec3\";\nimport { ChainShape } from \"../collision/shape/ChainShape\";\n// import { BoxShape } from \"../collision/shape/BoxShape\";\nimport { EdgeShape } from \"../collision/shape/EdgeShape\";\nimport { PolygonShape } from \"../collision/shape/PolygonShape\";\nimport { CircleShape } from \"../collision/shape/CircleShape\";\nimport { DistanceJoint } from \"../dynamics/joint/DistanceJoint\";\nimport { FrictionJoint } from \"../dynamics/joint/FrictionJoint\";\nimport { GearJoint } from \"../dynamics/joint/GearJoint\";\nimport { MotorJoint } from \"../dynamics/joint/MotorJoint\";\nimport { MouseJoint } from \"../dynamics/joint/MouseJoint\";\nimport { PrismaticJoint } from \"../dynamics/joint/PrismaticJoint\";\nimport { PulleyJoint } from \"../dynamics/joint/PulleyJoint\";\nimport { RevoluteJoint } from \"../dynamics/joint/RevoluteJoint\";\nimport { RopeJoint } from \"../dynamics/joint/RopeJoint\";\nimport { WeldJoint } from \"../dynamics/joint/WeldJoint\";\nimport { WheelJoint } from \"../dynamics/joint/WheelJoint\";\n\nlet SID = 0;\n\n// Classes to be serialized as reference objects\nconst SERIALIZE_REF_TYPES = {\n \"World\": World,\n \"Body\": Body,\n \"Joint\": Joint,\n \"Fixture\": Fixture,\n \"Shape\": Shape,\n};\n\n// For deserializing reference objects by reference type\nconst DESERIALIZE_BY_REF_TYPE = {\n \"Vec2\": Vec2,\n \"Vec3\": Vec3,\n \"World\": World,\n \"Body\": Body,\n \"Joint\": Joint,\n \"Fixture\": Fixture,\n \"Shape\": Shape,\n};\n\n// For deserializing data objects by type field\nconst DESERIALIZE_BY_TYPE_FIELD = {\n [Body.STATIC]: Body,\n [Body.DYNAMIC]: Body,\n [Body.KINEMATIC]: Body,\n [ChainShape.TYPE]: ChainShape,\n // [BoxShape.TYPE]: BoxShape,\n [PolygonShape.TYPE]: PolygonShape,\n [EdgeShape.TYPE]: EdgeShape,\n [CircleShape.TYPE]: CircleShape,\n [DistanceJoint.TYPE]: DistanceJoint,\n [FrictionJoint.TYPE]: FrictionJoint,\n [GearJoint.TYPE]: GearJoint,\n [MotorJoint.TYPE]: MotorJoint,\n [MouseJoint.TYPE]: MouseJoint,\n [PrismaticJoint.TYPE]: PrismaticJoint,\n [PulleyJoint.TYPE]: PulleyJoint,\n [RevoluteJoint.TYPE]: RevoluteJoint,\n [RopeJoint.TYPE]: RopeJoint,\n [WeldJoint.TYPE]: WeldJoint,\n [WheelJoint.TYPE]: WheelJoint,\n};\n\n// dummy types\ntype DataType = any;\ntype ObjectType = any;\ntype ClassName = any;\n\ntype SerializedType = object[];\n\ntype RefType = {\n refIndex: number,\n refType: string,\n};\n\ntype SerializerOptions = {\n rootClass: ClassName,\n preSerialize?: (obj: ObjectType) => DataType,\n postSerialize?: (data: DataType, obj: any) => DataType,\n preDeserialize?: (data: DataType) => DataType,\n postDeserialize?: (obj: ObjectType, data: DataType) => ObjectType,\n};\n\nconst DEFAULT_OPTIONS: SerializerOptions = {\n rootClass: World,\n preSerialize: function(obj) { return obj; },\n postSerialize: function(data, obj) { return data; },\n preDeserialize: function(data: DataType) { return data; },\n postDeserialize: function(obj, data) { return obj; },\n};\n\ntype DeserializeChildCallback = (classHint: any, obj: any, context: any) => any;\ntype ClassDeserializerMethod = (data: any, context: any, deserialize: DeserializeChildCallback) => any;\n\nexport class Serializer {\n private options: SerializerOptions;\n constructor(options: SerializerOptions) {\n this.options = {\n ...DEFAULT_OPTIONS,\n ...options,\n };\n }\n\n toJson = (root: T): SerializedType => {\n const preSerialize = this.options.preSerialize;\n const postSerialize = this.options.postSerialize;\n const json = [];\n\n // Breadth-first ref serialization queue\n const refQueue = [root];\n\n const refMemoById: Record = {};\n\n function addToRefQueue(value: any, typeName: string) {\n value.__sid = value.__sid || ++SID;\n if (!refMemoById[value.__sid]) {\n refQueue.push(value);\n const index = json.length + refQueue.length;\n const ref = {\n refIndex: index,\n refType: typeName\n };\n refMemoById[value.__sid] = ref;\n }\n return refMemoById[value.__sid];\n }\n\n function serializeWithHooks(obj: ObjectType) {\n obj = preSerialize(obj);\n let data = obj._serialize();\n data = postSerialize(data, obj);\n return data;\n }\n\n // traverse the object graph\n // ref objects are pushed into the queue\n // other objects are serialize in-place \n function traverse(value: any, noRefType = false) {\n if (typeof value !== \"object\" || value === null) {\n return value;\n }\n // object with _serialize function\n if (typeof value._serialize === \"function\") {\n if (!noRefType) {\n for (const typeName in SERIALIZE_REF_TYPES) {\n if (value instanceof SERIALIZE_REF_TYPES[typeName]) {\n return addToRefQueue(value, typeName);\n }\n }\n }\n // object with _serialize function\n value = serializeWithHooks(value);\n }\n // recursive for arrays any objects\n if (Array.isArray(value)) {\n const newValue = [];\n for (let key = 0; key < value.length; key++) {\n newValue[key] = traverse(value[key]);\n }\n value = newValue;\n\n } else {\n const newValue = {};\n for (const key in value) {\n if (value.hasOwnProperty(key)) {\n newValue[key] = traverse(value[key]);\n }\n }\n value = newValue;\n }\n return value;\n }\n\n while (refQueue.length) {\n const obj = refQueue.shift();\n const str = traverse(obj, true);\n json.push(str);\n }\n\n return json;\n };\n\n fromJson = (json: SerializedType): T => {\n const preDeserialize = this.options.preDeserialize;\n const postDeserialize = this.options.postDeserialize;\n const rootClass = this.options.rootClass;\n\n const deserializedRefMemoByIndex: Record = {};\n\n function deserializeWithHooks(classHint: ClassName, data: DataType, context: any): ObjectType {\n if (!classHint || !classHint._deserialize) {\n classHint = DESERIALIZE_BY_TYPE_FIELD[data.type];\n }\n const deserializer = classHint && classHint._deserialize;\n if (!deserializer) {\n return;\n }\n data = preDeserialize(data);\n const classDeserializeFn = classHint._deserialize as ClassDeserializerMethod;\n let obj = classDeserializeFn(data, context, deserializeChild);\n obj = postDeserialize(obj, data);\n return obj;\n }\n\n /**\n * Recursive callback function to deserialize a child data object or reference object.\n * \n * @param classHint suggested class to deserialize obj to\n * @param dataOrRef data or reference object\n * @param context for example world when deserializing bodies and joints\n */\n function deserializeChild(classHint: ClassName, dataOrRef: DataType | RefType, context: any) {\n const isRefObject = dataOrRef.refIndex && dataOrRef.refType;\n if (!isRefObject) {\n return deserializeWithHooks(classHint, dataOrRef, context); \n }\n const ref = dataOrRef as RefType;\n if (DESERIALIZE_BY_REF_TYPE[ref.refType]) {\n classHint = DESERIALIZE_BY_REF_TYPE[ref.refType];\n }\n const refIndex = ref.refIndex;\n if (!deserializedRefMemoByIndex[refIndex]) {\n const data = json[refIndex];\n const obj = deserializeWithHooks(classHint, data, context);\n deserializedRefMemoByIndex[refIndex] = obj;\n }\n return deserializedRefMemoByIndex[refIndex];\n }\n\n const root = deserializeWithHooks(rootClass, json[0], null);\n\n return root;\n };\n\n static toJson: (root: World) => SerializedType;\n static fromJson: (json: SerializedType) => World;\n}\n\nconst worldSerializer = new Serializer({\n rootClass: World,\n});\n\nSerializer.fromJson = worldSerializer.fromJson;\nSerializer.toJson = worldSerializer.toJson;\n","import type { AABBValue } from \"../collision/AABB\";\nimport type { World } from \"../dynamics/World\";\nimport type { Joint } from \"../dynamics/Joint\";\nimport type { Fixture } from \"../dynamics/Fixture\";\nimport type { Body } from \"../dynamics/Body\";\n\nexport interface Style {\n stroke?: string;\n fill?: string;\n lineWidth?: number;\n}\n\ntype KEY = \"0\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" |\n \"8\" | \"9\" | \"A\" | \"B\" | \"C\" | \"D\" | \"E\" | \"F\" | \"G\" |\n \"H\" | \"I\" | \"J\" | \"K\" | \"L\" | \"M\" | \"N\" | \"O\" | \"P\" |\n \"Q\" | \"R\" | \"S\" | \"T\" | \"U\" | \"V\" | \"W\" | \"X\" | \"Y\" |\n \"Z\" | \"right\" | \"left\" | \"up\" | \"down\" | \"fire\";\n\nexport type ActiveKeys = { [key in KEY]?: boolean };\n\ntype TestbedMountOptions = { [key: string]: any };\n\nexport abstract class Testbed {\n /**\n * Mounts testbed. Call start with a world to start simulation and rendering.\n */\n static mount(options?: TestbedMountOptions): Testbed {\n throw new Error(\"Not implemented\");\n }\n\n /**\n * Mounts testbed if needed, then starts simulation and rendering.\n * \n * If you need to customize testbed before starting, first run `const testbed = Testbed.mount()` and then `testbed.start()`.\n */\n static start(world: World): Testbed {\n const testbed = Testbed.mount();\n testbed.start(world);\n return testbed;\n }\n\n /** World viewbox width. */\n width: number = 80;\n\n /** World viewbox height. */\n height: number = 60;\n\n /** World viewbox center vertical offset. */\n x: number = 0;\n\n /** World viewbox center horizontal offset. */\n y: number = -10;\n\n /** @hidden */\n scaleY: number = -1;\n\n /** World simulation step frequency */\n hz: number = 60;\n\n /** World simulation speed, default is 1 */\n speed: number = 1;\n\n background: string = \"#222222\";\n\n mouseForce?: number;\n activeKeys: ActiveKeys = {};\n\n /** callback, to be implemented by user */\n step = (dt: number, t: number): void => {\n return;\n };\n\n /** callback, to be implemented by user */\n keydown = (keyCode: number, label: string): void => {\n return;\n };\n\n /** callback, to be implemented by user */\n keyup = (keyCode: number, label: string): void => {\n return;\n };\n\n abstract status(name: string, value: any): void;\n abstract status(value: object | string): void;\n\n abstract info(text: string): void;\n\n color(r: number, g: number, b: number): string {\n r = r * 256 | 0;\n g = g * 256 | 0;\n b = b * 256 | 0;\n return \"rgb(\" + r + \", \" + g + \", \" + b + \")\";\n }\n\n abstract drawPoint(p: {x: number, y: number}, r: any, color: string): void;\n abstract drawCircle(p: {x: number, y: number}, r: number, color: string): void;\n abstract drawEdge(a: {x: number, y: number}, b: {x: number, y: number}, color: string): void;\n abstract drawSegment(a: {x: number, y: number}, b: {x: number, y: number}, color: string): void;\n abstract drawPolygon(points: Array<{x: number, y: number}>, color: string): void;\n abstract drawAABB(aabb: AABBValue, color: string): void;\n\n abstract start(world: World): void;\n\n abstract findOne(query: string): (Body | Joint | Fixture | null);\n abstract findAll(query: string): (Body | Joint | Fixture)[];\n}\n\ntype TestbedFactoryOptions = string | TestbedMountOptions;\n\n/** @deprecated */\ntype TestbedCallback = (testbed: Testbed) => (World | undefined);\n\n/** @deprecated */\nexport function testbed(callback: TestbedCallback): void;\n/** @deprecated */\nexport function testbed(options: TestbedFactoryOptions, callback: TestbedCallback): void;\n/** @internal */\nexport function testbed(a?: any, b?: any) {\n let callback: TestbedCallback | undefined;\n let options;\n if (typeof a === \"function\") {\n callback = a;\n options = b;\n } else if (typeof b === \"function\") {\n callback = b;\n options = a;\n } else {\n options = a ?? b;\n }\n const testbed = Testbed.mount(options);\n if (callback) {\n // this is for backwards compatibility\n const world = callback(testbed) || (testbed as any).world;\n testbed.start(world);\n } else {\n return testbed;\n }\n}\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport type { Vec2Value } from \"../../common/Vec2\";\nimport { PolygonShape } from \"./PolygonShape\";\n\n\n/** @internal */ const _CONSTRUCTOR_FACTORY = typeof CONSTRUCTOR_FACTORY === \"undefined\" ? false : CONSTRUCTOR_FACTORY;\n\ndeclare module \"./BoxShape\" {\n /** @hidden @deprecated Use new keyword. */\n // @ts-expect-error\n function BoxShape(halfWidth: number, halfHeight: number, center?: Vec2Value, angle?: number): BoxShape;\n}\n\n/**\n * A rectangle polygon which extend PolygonShape.\n */\n// @ts-expect-error\nexport class BoxShape extends PolygonShape {\n // note that box is serialized/deserialized as polygon\n static TYPE = \"polygon\" as const;\n\n /**\n * \n * @param halfWidth \n * @param halfHeight \n * @param center coordinate of the center of the box relative to the body\n * @param angle angle of the box relative to the body\n */\n constructor(halfWidth: number, halfHeight: number, center?: Vec2Value, angle?: number) {\n // @ts-ignore\n if (_CONSTRUCTOR_FACTORY && !(this instanceof BoxShape)) {\n return new BoxShape(halfWidth, halfHeight, center, angle);\n }\n\n super();\n\n this._setAsBox(halfWidth, halfHeight, center, angle);\n }\n}\n\nexport const Box = BoxShape;\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { CircleShape } from \"./CircleShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(CircleShape.TYPE, CircleShape.TYPE, CircleCircleContact);\n\n/** @internal */ function CircleCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == CircleShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n CollideCircles(manifold, fixtureA.getShape() as CircleShape, xfA, fixtureB.getShape() as CircleShape, xfB);\n}\n\n/** @internal */ const pA = matrix.vec2(0, 0);\n/** @internal */ const pB = matrix.vec2(0, 0);\n\nexport const CollideCircles = function (manifold: Manifold, circleA: CircleShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n matrix.transformVec2(pA, xfA, circleA.m_p);\n matrix.transformVec2(pB, xfB, circleB.m_p);\n\n const distSqr = matrix.distSqrVec2(pB, pA);\n const rA = circleA.m_radius;\n const rB = circleB.m_radius;\n const radius = rA + rB;\n if (distSqr > radius * radius) {\n return;\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.copyVec2(manifold.localPoint, circleA.m_p);\n matrix.zeroVec2(manifold.localNormal);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { TransformValue } from \"../../common/Transform\";\nimport * as matrix from \"../../common/Matrix\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { EdgeShape } from \"./EdgeShape\";\nimport { ChainShape } from \"./ChainShape\";\nimport { CircleShape } from \"./CircleShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(EdgeShape.TYPE, CircleShape.TYPE, EdgeCircleContact);\nContact.addType(ChainShape.TYPE, CircleShape.TYPE, ChainCircleContact);\n\n/** @internal */ function EdgeCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == EdgeShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n\n const shapeA = fixtureA.getShape() as EdgeShape;\n const shapeB = fixtureB.getShape() as CircleShape;\n\n CollideEdgeCircle(manifold, shapeA, xfA, shapeB, xfB);\n}\n\nfunction ChainCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == ChainShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n\n const chain = fixtureA.getShape() as ChainShape;\n const edge = new EdgeShape();\n chain.getChildEdge(edge, indexA);\n\n const shapeA = edge;\n const shapeB = fixtureB.getShape() as CircleShape;\n\n CollideEdgeCircle(manifold, shapeA, xfA, shapeB, xfB);\n}\n\n/** @internal */ const e = matrix.vec2(0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const e1 = matrix.vec2(0, 0);\n/** @internal */ const e2 = matrix.vec2(0, 0);\n/** @internal */ const Q = matrix.vec2(0, 0);\n/** @internal */ const P = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n\n// Compute contact points for edge versus circle.\n// This accounts for edge connectivity.\nexport const CollideEdgeCircle = function (manifold: Manifold, edgeA: EdgeShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n // Compute circle in frame of edge\n matrix.retransformVec2(Q, xfB, xfA, circleB.m_p);\n\n const A = edgeA.m_vertex1;\n const B = edgeA.m_vertex2;\n matrix.subVec2(e, B, A);\n\n // Barycentric coordinates\n const u = matrix.dotVec2(e, B) - matrix.dotVec2(e, Q);\n const v = matrix.dotVec2(e, Q) - matrix.dotVec2(e, A);\n\n const radius = edgeA.m_radius + circleB.m_radius;\n\n // Region A\n if (v <= 0.0) {\n matrix.copyVec2(P, A);\n const dd = matrix.distSqrVec2(Q, A);\n if (dd > radius * radius) {\n return;\n }\n\n // Is there an edge connected to A?\n if (edgeA.m_hasVertex0) {\n const A1 = edgeA.m_vertex0;\n const B1 = A;\n matrix.subVec2(e1, B1, A1);\n const u1 = matrix.dotVec2(e1, B1) - matrix.dotVec2(e1, Q);\n\n // Is the circle in Region AB of the previous edge?\n if (u1 > 0.0) {\n return;\n }\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.zeroVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, P);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n return;\n }\n\n // Region B\n if (u <= 0.0) {\n matrix.copyVec2(P, B);\n const dd = matrix.distSqrVec2(Q, P);\n if (dd > radius * radius) {\n return;\n }\n\n // Is there an edge connected to B?\n if (edgeA.m_hasVertex3) {\n const B2 = edgeA.m_vertex3;\n const A2 = B;\n matrix.subVec2(e2, B2, A2);\n const v2 = matrix.dotVec2(e2, Q) - matrix.dotVec2(e2, A2);\n\n // Is the circle in Region AB of the next edge?\n if (v2 > 0.0) {\n return;\n }\n }\n\n manifold.type = ManifoldType.e_circles;\n matrix.zeroVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, P);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(1, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n\n return;\n }\n\n // Region AB\n const den = matrix.lengthSqrVec2(e);\n if (_ASSERT) console.assert(den > 0.0);\n matrix.combine2Vec2(P, u / den, A, v / den, B);\n const dd = matrix.distSqrVec2(Q, P);\n if (dd > radius * radius) {\n return;\n }\n\n matrix.crossNumVec2(n, 1, e);\n if (matrix.dotVec2(n, Q) - matrix.dotVec2(n, A) < 0.0) {\n matrix.negVec2(n);\n }\n matrix.normalizeVec2(n);\n\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, n);\n matrix.copyVec2(manifold.localPoint, A);\n manifold.pointCount = 1;\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_face, 0, ContactFeatureType.e_vertex);\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { TransformValue } from \"../../common/Transform\";\nimport * as matrix from \"../../common/Matrix\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Manifold, clipSegmentToLine, ClipVertex, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n/** @internal */ const incidentEdge = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints1 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints2 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipSegmentToLineNormal = matrix.vec2(0, 0);\n/** @internal */ const v1 = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n/** @internal */ const temp = matrix.vec2(0, 0);\n/** @internal */ const v11 = matrix.vec2(0, 0);\n/** @internal */ const v12 = matrix.vec2(0, 0);\n/** @internal */ const localTangent = matrix.vec2(0, 0);\n/** @internal */ const localNormal = matrix.vec2(0, 0);\n/** @internal */ const planePoint = matrix.vec2(0, 0);\n/** @internal */ const tangent = matrix.vec2(0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const normal1 = matrix.vec2(0, 0);\n\n\nContact.addType(PolygonShape.TYPE, PolygonShape.TYPE, PolygonContact);\n\n/** @internal */ function PolygonContact(\n manifold: Manifold,\n xfA: TransformValue,\n fixtureA: Fixture,\n indexA: number,\n xfB: TransformValue,\n fixtureB: Fixture,\n indexB: number,\n): void {\n if (_ASSERT) console.assert(fixtureA.getType() == PolygonShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == PolygonShape.TYPE);\n CollidePolygons(manifold, fixtureA.getShape() as PolygonShape, xfA, fixtureB.getShape() as PolygonShape, xfB);\n}\n\n/** @internal */ interface MaxSeparation {\n maxSeparation: number;\n bestIndex: number;\n}\n\n/**\n * Find the max separation between poly1 and poly2 using edge normals from\n * poly1.\n */\n/** @internal */ function findMaxSeparation(\n poly1: PolygonShape,\n xf1: TransformValue,\n poly2: PolygonShape,\n xf2: TransformValue,\n output: MaxSeparation,\n): void {\n const count1 = poly1.m_count;\n const count2 = poly2.m_count;\n const n1s = poly1.m_normals;\n const v1s = poly1.m_vertices;\n const v2s = poly2.m_vertices;\n\n matrix.detransformTransform(xf, xf2, xf1);\n\n let bestIndex = 0;\n let maxSeparation = -Infinity;\n for (let i = 0; i < count1; ++i) {\n // Get poly1 normal in frame2.\n matrix.rotVec2(n, xf.q, n1s[i]);\n matrix.transformVec2(v1, xf, v1s[i]);\n\n // Find deepest point for normal i.\n let si = Infinity;\n for (let j = 0; j < count2; ++j) {\n const sij = matrix.dotVec2(n, v2s[j]) - matrix.dotVec2(n, v1);\n if (sij < si) {\n si = sij;\n }\n }\n\n if (si > maxSeparation) {\n maxSeparation = si;\n bestIndex = i;\n }\n }\n\n // used to keep last FindMaxSeparation call values\n output.maxSeparation = maxSeparation;\n output.bestIndex = bestIndex;\n}\n\n/** @internal */ function findIncidentEdge(\n clipVertex: ClipVertex[],\n poly1: PolygonShape,\n xf1: TransformValue,\n edge1: number,\n poly2: PolygonShape,\n xf2: TransformValue,\n): void {\n const normals1 = poly1.m_normals;\n\n const count2 = poly2.m_count;\n const vertices2 = poly2.m_vertices;\n const normals2 = poly2.m_normals;\n\n if (_ASSERT) console.assert(0 <= edge1 && edge1 < poly1.m_count);\n\n // Get the normal of the reference edge in poly2's frame.\n matrix.rerotVec2(normal1, xf2.q, xf1.q, normals1[edge1]);\n\n // Find the incident edge on poly2.\n let index = 0;\n let minDot = Infinity;\n for (let i = 0; i < count2; ++i) {\n const dot = matrix.dotVec2(normal1, normals2[i]);\n if (dot < minDot) {\n minDot = dot;\n index = i;\n }\n }\n\n // Build the clip vertices for the incident edge.\n const i1 = index;\n const i2 = i1 + 1 < count2 ? i1 + 1 : 0;\n\n matrix.transformVec2(clipVertex[0].v, xf2, vertices2[i1]);\n clipVertex[0].id.setFeatures(edge1, ContactFeatureType.e_face, i1, ContactFeatureType.e_vertex);\n\n matrix.transformVec2(clipVertex[1].v, xf2, vertices2[i2]);\n clipVertex[1].id.setFeatures(edge1, ContactFeatureType.e_face, i2, ContactFeatureType.e_vertex);\n}\n\n/** @internal */ const maxSeparation = {\n maxSeparation: 0,\n bestIndex: 0,\n};\n\n/**\n *\n * Find edge normal of max separation on A - return if separating axis is found
\n * Find edge normal of max separation on B - return if separation axis is found
\n * Choose reference edge as min(minA, minB)
\n * Find incident edge
\n * Clip\n *\n * The normal points from 1 to 2\n */\nexport const CollidePolygons = function (\n manifold: Manifold,\n polyA: PolygonShape,\n xfA: TransformValue,\n polyB: PolygonShape,\n xfB: TransformValue,\n): void {\n manifold.pointCount = 0;\n const totalRadius = polyA.m_radius + polyB.m_radius;\n\n findMaxSeparation(polyA, xfA, polyB, xfB, maxSeparation);\n const edgeA = maxSeparation.bestIndex;\n const separationA = maxSeparation.maxSeparation;\n if (separationA > totalRadius)\n return;\n\n findMaxSeparation(polyB, xfB, polyA, xfA, maxSeparation);\n const edgeB = maxSeparation.bestIndex;\n const separationB = maxSeparation.maxSeparation;\n if (separationB > totalRadius)\n return;\n\n let poly1: PolygonShape; // reference polygon\n let poly2: PolygonShape; // incident polygon\n let xf1: TransformValue;\n let xf2: TransformValue;\n let edge1: number; // reference edge\n let flip: boolean;\n const k_tol = 0.1 * Settings.linearSlop;\n\n if (separationB > separationA + k_tol) {\n poly1 = polyB;\n poly2 = polyA;\n xf1 = xfB;\n xf2 = xfA;\n edge1 = edgeB;\n manifold.type = ManifoldType.e_faceB;\n flip = true;\n } else {\n poly1 = polyA;\n poly2 = polyB;\n xf1 = xfA;\n xf2 = xfB;\n edge1 = edgeA;\n manifold.type = ManifoldType.e_faceA;\n flip = false;\n }\n\n incidentEdge[0].recycle();\n incidentEdge[1].recycle();\n findIncidentEdge(incidentEdge, poly1, xf1, edge1, poly2, xf2);\n\n const count1 = poly1.m_count;\n const vertices1 = poly1.m_vertices;\n\n const iv1 = edge1;\n const iv2 = edge1 + 1 < count1 ? edge1 + 1 : 0;\n\n matrix.copyVec2(v11, vertices1[iv1]);\n matrix.copyVec2(v12, vertices1[iv2]);\n\n matrix.subVec2(localTangent, v12, v11);\n matrix.normalizeVec2(localTangent);\n\n matrix.crossVec2Num(localNormal, localTangent, 1.0);\n matrix.combine2Vec2(planePoint, 0.5, v11, 0.5, v12);\n\n matrix.rotVec2(tangent, xf1.q, localTangent);\n matrix.crossVec2Num(normal, tangent, 1.0);\n\n matrix.transformVec2(v11, xf1, v11);\n matrix.transformVec2(v12, xf1, v12);\n\n // Face offset.\n const frontOffset = matrix.dotVec2(normal, v11);\n\n // Side offsets, extended by polytope skin thickness.\n const sideOffset1 = -matrix.dotVec2(tangent, v11) + totalRadius;\n const sideOffset2 = matrix.dotVec2(tangent, v12) + totalRadius;\n\n // Clip incident edge against extruded edge1 side edges.\n clipPoints1[0].recycle();\n clipPoints1[1].recycle();\n clipPoints2[0].recycle();\n clipPoints2[1].recycle();\n\n // Clip to box side 1\n matrix.setVec2(clipSegmentToLineNormal, -tangent.x, -tangent.y);\n const np1 = clipSegmentToLine(clipPoints1, incidentEdge, clipSegmentToLineNormal, sideOffset1, iv1);\n\n if (np1 < 2) {\n return;\n }\n\n // Clip to negative box side 1\n matrix.setVec2(clipSegmentToLineNormal, tangent.x, tangent.y);\n const np2 = clipSegmentToLine(clipPoints2, clipPoints1, clipSegmentToLineNormal, sideOffset2, iv2);\n\n if (np2 < 2) {\n return;\n }\n\n // Now clipPoints2 contains the clipped points.\n matrix.copyVec2(manifold.localNormal, localNormal);\n matrix.copyVec2(manifold.localPoint, planePoint);\n\n let pointCount = 0;\n for (let i = 0; i < clipPoints2.length/* maxManifoldPoints */; ++i) {\n const separation = matrix.dotVec2(normal, clipPoints2[i].v) - frontOffset;\n\n if (separation <= totalRadius) {\n const cp = manifold.points[pointCount];\n matrix.detransformVec2(cp.localPoint, xf2, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n if (flip) {\n // Swap features\n cp.id.swapFeatures();\n }\n ++pointCount;\n }\n }\n\n manifold.pointCount = pointCount;\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { EPSILON } from \"../../common/Math\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { CircleShape } from \"./CircleShape\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Manifold, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\n\nContact.addType(PolygonShape.TYPE, CircleShape.TYPE, PolygonCircleContact);\n\n/** @internal */ function PolygonCircleContact(manifold: Manifold, xfA: TransformValue, fixtureA: Fixture, indexA: number, xfB: TransformValue, fixtureB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fixtureA.getType() == PolygonShape.TYPE);\n if (_ASSERT) console.assert(fixtureB.getType() == CircleShape.TYPE);\n CollidePolygonCircle(manifold, fixtureA.getShape() as PolygonShape, xfA, fixtureB.getShape() as CircleShape, xfB);\n}\n\n/** @internal */ const cLocal = matrix.vec2(0, 0);\n/** @internal */ const faceCenter = matrix.vec2(0, 0);\n\nexport const CollidePolygonCircle = function (manifold: Manifold, polygonA: PolygonShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue): void {\n manifold.pointCount = 0;\n\n // Compute circle position in the frame of the polygon.\n matrix.retransformVec2(cLocal, xfB, xfA, circleB.m_p);\n\n // Find the min separating edge.\n let normalIndex = 0;\n let separation = -Infinity;\n const radius = polygonA.m_radius + circleB.m_radius;\n const vertexCount = polygonA.m_count;\n const vertices = polygonA.m_vertices;\n const normals = polygonA.m_normals;\n\n for (let i = 0; i < vertexCount; ++i) {\n const s = matrix.dotVec2(normals[i], cLocal) - matrix.dotVec2(normals[i], vertices[i]);\n\n if (s > radius) {\n // Early out.\n return;\n }\n\n if (s > separation) {\n separation = s;\n normalIndex = i;\n }\n }\n\n // Vertices that subtend the incident face.\n const vertIndex1 = normalIndex;\n const vertIndex2 = vertIndex1 + 1 < vertexCount ? vertIndex1 + 1 : 0;\n const v1 = vertices[vertIndex1];\n const v2 = vertices[vertIndex2];\n\n // If the center is inside the polygon ...\n if (separation < EPSILON) {\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, normals[normalIndex]);\n matrix.combine2Vec2(manifold.localPoint, 0.5, v1, 0.5, v2);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n return;\n }\n\n // Compute barycentric coordinates\n // u1 = (cLocal - v1) dot (v2 - v1))\n const u1 = matrix.dotVec2(cLocal, v2) - matrix.dotVec2(cLocal, v1) - matrix.dotVec2(v1, v2) + matrix.dotVec2(v1, v1);\n // u2 = (cLocal - v2) dot (v1 - v2)\n const u2 = matrix.dotVec2(cLocal, v1) - matrix.dotVec2(cLocal, v2) - matrix.dotVec2(v2, v1) + matrix.dotVec2(v2, v2);\n if (u1 <= 0.0) {\n if (matrix.distSqrVec2(cLocal, v1) > radius * radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.subVec2(manifold.localNormal, cLocal, v1);\n matrix.normalizeVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, v1);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n } else if (u2 <= 0.0) {\n if (matrix.distSqrVec2(cLocal, v2) > radius * radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.subVec2(manifold.localNormal, cLocal, v2);\n matrix.normalizeVec2(manifold.localNormal);\n matrix.copyVec2(manifold.localPoint, v2);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n } else {\n matrix.combine2Vec2(faceCenter, 0.5, v1, 0.5, v2);\n const separation = matrix.dotVec2(cLocal, normals[vertIndex1]) - matrix.dotVec2(faceCenter, normals[vertIndex1]);\n if (separation > radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = ManifoldType.e_faceA;\n matrix.copyVec2(manifold.localNormal, normals[vertIndex1]);\n matrix.copyVec2(manifold.localPoint, faceCenter);\n matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex);\n }\n};\n","/*\n * Planck.js\n *\n * Copyright (c) Erin Catto, Ali Shakiba\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as matrix from \"../../common/Matrix\";\nimport { TransformValue } from \"../../common/Transform\";\nimport { Vec2, Vec2Value } from \"../../common/Vec2\";\nimport { SettingsInternal as Settings } from \"../../Settings\";\nimport { Contact } from \"../../dynamics/Contact\";\nimport { Manifold, clipSegmentToLine, ClipVertex, ContactFeatureType, ManifoldType } from \"../Manifold\";\nimport { EdgeShape } from \"./EdgeShape\";\nimport { ChainShape } from \"./ChainShape\";\nimport { PolygonShape } from \"./PolygonShape\";\nimport { Fixture } from \"../../dynamics/Fixture\";\n\n\n/** @internal */ const _ASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n/** @internal */ const math_min = Math.min;\n\nContact.addType(EdgeShape.TYPE, PolygonShape.TYPE, EdgePolygonContact);\nContact.addType(ChainShape.TYPE, PolygonShape.TYPE, ChainPolygonContact);\n\n/** @internal */ function EdgePolygonContact(manifold: Manifold, xfA: TransformValue, fA: Fixture, indexA: number, xfB: TransformValue, fB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fA.getType() == EdgeShape.TYPE);\n if (_ASSERT) console.assert(fB.getType() == PolygonShape.TYPE);\n\n CollideEdgePolygon(manifold, fA.getShape() as EdgeShape, xfA, fB.getShape() as PolygonShape, xfB);\n}\n\n// reused\n/** @internal */ const edge_reuse = new EdgeShape();\n\n/** @internal */ function ChainPolygonContact(manifold: Manifold, xfA: TransformValue, fA: Fixture, indexA: number, xfB: TransformValue, fB: Fixture, indexB: number): void {\n if (_ASSERT) console.assert(fA.getType() == ChainShape.TYPE);\n if (_ASSERT) console.assert(fB.getType() == PolygonShape.TYPE);\n\n const chain = fA.getShape() as ChainShape;\n chain.getChildEdge(edge_reuse, indexA);\n\n CollideEdgePolygon(manifold, edge_reuse, xfA, fB.getShape() as PolygonShape, xfB);\n}\n\n/** @internal */ enum EPAxisType {\n e_unknown = -1,\n e_edgeA = 1,\n e_edgeB = 2,\n}\n\n// unused?\n/** @internal */ enum VertexType {\n e_isolated = 0,\n e_concave = 1,\n e_convex = 2,\n}\n\n/**\n * This structure is used to keep track of the best separating axis.\n */\n/** @internal */ class EPAxis {\n type: EPAxisType;\n index: number;\n separation: number;\n}\n\n/**\n * This holds polygon B expressed in frame A.\n */\n/** @internal */ class TempPolygon {\n vertices: Vec2Value[] = []; // [Settings.maxPolygonVertices]\n normals: Vec2Value[] = []; // [Settings.maxPolygonVertices];\n count: number = 0;\n constructor() {\n for (let i = 0; i < Settings.maxPolygonVertices; i++) {\n this.vertices.push(matrix.vec2(0, 0));\n this.normals.push(matrix.vec2(0, 0));\n }\n }\n}\n\n/**\n * Reference face used for clipping\n */\n/** @internal */ class ReferenceFace {\n i1: number;\n i2: number;\n readonly v1 = matrix.vec2(0 ,0);\n readonly v2 = matrix.vec2(0 ,0);\n readonly normal = matrix.vec2(0 ,0);\n readonly sideNormal1 = matrix.vec2(0 ,0);\n sideOffset1: number;\n readonly sideNormal2 = matrix.vec2(0 ,0);\n sideOffset2: number;\n recycle() {\n matrix.zeroVec2(this.v1);\n matrix.zeroVec2(this.v2);\n matrix.zeroVec2(this.normal);\n matrix.zeroVec2(this.sideNormal1);\n matrix.zeroVec2(this.sideNormal2);\n }\n}\n\n// reused\n/** @internal */ const clipPoints1 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const clipPoints2 = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const ie = [ new ClipVertex(), new ClipVertex() ];\n/** @internal */ const edgeAxis = new EPAxis();\n/** @internal */ const polygonAxis = new EPAxis();\n/** @internal */ const polygonBA = new TempPolygon();\n/** @internal */ const rf = new ReferenceFace();\n/** @internal */ const centroidB = matrix.vec2(0, 0);\n/** @internal */ const edge0 = matrix.vec2(0, 0);\n/** @internal */ const edge1 = matrix.vec2(0, 0);\n/** @internal */ const edge2 = matrix.vec2(0, 0);\n/** @internal */ const xf = matrix.transform(0, 0, 0);\n/** @internal */ const normal = matrix.vec2(0, 0);\n/** @internal */ const normal0 = matrix.vec2(0, 0);\n/** @internal */ const normal1 = matrix.vec2(0, 0);\n/** @internal */ const normal2 = matrix.vec2(0, 0);\n/** @internal */ const lowerLimit = matrix.vec2(0, 0);\n/** @internal */ const upperLimit = matrix.vec2(0, 0);\n/** @internal */ const perp = matrix.vec2(0, 0);\n/** @internal */ const n = matrix.vec2(0, 0);\n\n/**\n * This function collides and edge and a polygon, taking into account edge\n * adjacency.\n */\nexport const CollideEdgePolygon = function (manifold: Manifold, edgeA: EdgeShape, xfA: TransformValue, polygonB: PolygonShape, xfB: TransformValue): void {\n // Algorithm:\n // 1. Classify v1 and v2\n // 2. Classify polygon centroid as front or back\n // 3. Flip normal if necessary\n // 4. Initialize normal range to [-pi, pi] about face normal\n // 5. Adjust normal range according to adjacent edges\n // 6. Visit each separating axes, only accept axes within the range\n // 7. Return if _any_ axis indicates separation\n // 8. Clip\n\n // let m_type1: VertexType;\n // let m_type2: VertexType;\n\n matrix.detransformTransform(xf, xfA, xfB);\n matrix.transformVec2(centroidB, xf, polygonB.m_centroid);\n\n const v0 = edgeA.m_vertex0;\n const v1 = edgeA.m_vertex1;\n const v2 = edgeA.m_vertex2;\n const v3 = edgeA.m_vertex3;\n\n const hasVertex0 = edgeA.m_hasVertex0;\n const hasVertex3 = edgeA.m_hasVertex3;\n\n matrix.subVec2(edge1, v2, v1);\n matrix.normalizeVec2(edge1);\n matrix.setVec2(normal1, edge1.y, -edge1.x);\n const offset1 = matrix.dotVec2(normal1, centroidB) - matrix.dotVec2(normal1, v1);\n let offset0 = 0.0;\n let offset2 = 0.0;\n let convex1 = false;\n let convex2 = false;\n\n matrix.zeroVec2(normal0);\n matrix.zeroVec2(normal2);\n\n // Is there a preceding edge?\n if (hasVertex0) {\n matrix.subVec2(edge0, v1, v0);\n matrix.normalizeVec2(edge0);\n matrix.setVec2(normal0, edge0.y, -edge0.x);\n convex1 = matrix.crossVec2Vec2(edge0, edge1) >= 0.0;\n offset0 = Vec2.dot(normal0, centroidB) - Vec2.dot(normal0, v0);\n }\n\n // Is there a following edge?\n if (hasVertex3) {\n matrix.subVec2(edge2, v3, v2);\n matrix.normalizeVec2(edge2);\n matrix.setVec2(normal2, edge2.y, -edge2.x);\n convex2 = Vec2.crossVec2Vec2(edge1, edge2) > 0.0;\n offset2 = Vec2.dot(normal2, centroidB) - Vec2.dot(normal2, v2);\n }\n\n let front: boolean;\n matrix.zeroVec2(normal);\n matrix.zeroVec2(lowerLimit);\n matrix.zeroVec2(upperLimit);\n\n // Determine front or back collision. Determine collision normal limits.\n if (hasVertex0 && hasVertex3) {\n if (convex1 && convex2) {\n front = offset0 >= 0.0 || offset1 >= 0.0 || offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else if (convex1) {\n front = offset0 >= 0.0 || (offset1 >= 0.0 && offset2 >= 0.0);\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else if (convex2) {\n front = offset2 >= 0.0 || (offset0 >= 0.0 && offset1 >= 0.0);\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n } else {\n front = offset0 >= 0.0 && offset1 >= 0.0 && offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n }\n } else if (hasVertex0) {\n if (convex1) {\n front = offset0 >= 0.0 || offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal0);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n }\n } else {\n front = offset0 >= 0.0 && offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.scaleVec2(upperLimit, -1, normal0);\n }\n }\n } else if (hasVertex3) {\n if (convex2) {\n front = offset1 >= 0.0 || offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal2);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal1);\n }\n } else {\n front = offset1 >= 0.0 && offset2 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.copyVec2(upperLimit, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal2);\n matrix.copyVec2(upperLimit, normal1);\n }\n }\n } else {\n front = offset1 >= 0.0;\n if (front) {\n matrix.copyVec2(normal, normal1);\n matrix.scaleVec2(lowerLimit, -1, normal1);\n matrix.scaleVec2(upperLimit, -1, normal1);\n } else {\n matrix.scaleVec2(normal, -1, normal1);\n matrix.copyVec2(lowerLimit, normal1);\n matrix.copyVec2(upperLimit, normal1);\n }\n }\n\n // Get polygonB in frameA\n polygonBA.count = polygonB.m_count;\n for (let i = 0; i < polygonB.m_count; ++i) {\n matrix.transformVec2(polygonBA.vertices[i], xf, polygonB.m_vertices[i]);\n matrix.rotVec2(polygonBA.normals[i], xf.q, polygonB.m_normals[i]);\n }\n\n const radius = polygonB.m_radius + edgeA.m_radius;\n\n manifold.pointCount = 0;\n\n { // ComputeEdgeSeparation\n edgeAxis.type = EPAxisType.e_edgeA;\n edgeAxis.index = front ? 0 : 1;\n edgeAxis.separation = Infinity;\n\n for (let i = 0; i < polygonBA.count; ++i) {\n const v = polygonBA.vertices[i];\n const s = matrix.dotVec2(normal, v) - matrix.dotVec2(normal, v1);\n if (s < edgeAxis.separation) {\n edgeAxis.separation = s;\n }\n }\n }\n\n // If no valid normal can be found than this edge should not collide.\n // @ts-ignore todo: why we need this if here?\n if (edgeAxis.type == EPAxisType.e_unknown) {\n return;\n }\n\n if (edgeAxis.separation > radius) {\n return;\n }\n\n { // ComputePolygonSeparation\n polygonAxis.type = EPAxisType.e_unknown;\n polygonAxis.index = -1;\n polygonAxis.separation = -Infinity;\n\n matrix.setVec2(perp, -normal.y, normal.x);\n\n for (let i = 0; i < polygonBA.count; ++i) {\n matrix.scaleVec2(n, -1, polygonBA.normals[i]);\n\n const s1 = matrix.dotVec2(n, polygonBA.vertices[i]) - matrix.dotVec2(n, v1);\n const s2 = matrix.dotVec2(n, polygonBA.vertices[i]) - matrix.dotVec2(n, v2);\n const s = math_min(s1, s2);\n\n if (s > radius) {\n // No collision\n polygonAxis.type = EPAxisType.e_edgeB;\n polygonAxis.index = i;\n polygonAxis.separation = s;\n break;\n }\n\n // Adjacency\n if (matrix.dotVec2(n, perp) >= 0.0) {\n if (matrix.dotVec2(n, normal) - matrix.dotVec2(upperLimit, normal) < -Settings.angularSlop) {\n continue;\n }\n } else {\n if (matrix.dotVec2(n, normal) - matrix.dotVec2(lowerLimit, normal) < -Settings.angularSlop) {\n continue;\n }\n }\n\n if (s > polygonAxis.separation) {\n polygonAxis.type = EPAxisType.e_edgeB;\n polygonAxis.index = i;\n polygonAxis.separation = s;\n }\n }\n }\n\n if (polygonAxis.type != EPAxisType.e_unknown && polygonAxis.separation > radius) {\n return;\n }\n\n // Use hysteresis for jitter reduction.\n const k_relativeTol = 0.98;\n const k_absoluteTol = 0.001;\n\n let primaryAxis: EPAxis;\n if (polygonAxis.type == EPAxisType.e_unknown) {\n primaryAxis = edgeAxis;\n } else if (polygonAxis.separation > k_relativeTol * edgeAxis.separation + k_absoluteTol) {\n primaryAxis = polygonAxis;\n } else {\n primaryAxis = edgeAxis;\n }\n\n ie[0].recycle();\n ie[1].recycle();\n\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n manifold.type = ManifoldType.e_faceA;\n\n // Search for the polygon normal that is most anti-parallel to the edge\n // normal.\n let bestIndex = 0;\n let bestValue = matrix.dotVec2(normal, polygonBA.normals[0]);\n for (let i = 1; i < polygonBA.count; ++i) {\n const value = matrix.dotVec2(normal, polygonBA.normals[i]);\n if (value < bestValue) {\n bestValue = value;\n bestIndex = i;\n }\n }\n\n const i1 = bestIndex;\n const i2 = i1 + 1 < polygonBA.count ? i1 + 1 : 0;\n\n matrix.copyVec2(ie[0].v, polygonBA.vertices[i1]);\n ie[0].id.setFeatures(0, ContactFeatureType.e_face, i1, ContactFeatureType.e_vertex);\n\n matrix.copyVec2(ie[1].v, polygonBA.vertices[i2]);\n ie[1].id.setFeatures(0, ContactFeatureType.e_face, i2, ContactFeatureType.e_vertex);\n\n if (front) {\n rf.i1 = 0;\n rf.i2 = 1;\n matrix.copyVec2(rf.v1, v1);\n matrix.copyVec2(rf.v2, v2);\n matrix.copyVec2(rf.normal, normal1);\n } else {\n rf.i1 = 1;\n rf.i2 = 0;\n matrix.copyVec2(rf.v1, v2);\n matrix.copyVec2(rf.v2, v1);\n matrix.scaleVec2(rf.normal, -1, normal1);\n }\n } else {\n manifold.type = ManifoldType.e_faceB;\n\n matrix.copyVec2(ie[0].v, v1);\n ie[0].id.setFeatures(0, ContactFeatureType.e_vertex, primaryAxis.index, ContactFeatureType.e_face);\n\n matrix.copyVec2(ie[1].v, v2);\n ie[1].id.setFeatures(0, ContactFeatureType.e_vertex, primaryAxis.index, ContactFeatureType.e_face);\n\n rf.i1 = primaryAxis.index;\n rf.i2 = rf.i1 + 1 < polygonBA.count ? rf.i1 + 1 : 0;\n matrix.copyVec2(rf.v1, polygonBA.vertices[rf.i1]);\n matrix.copyVec2(rf.v2, polygonBA.vertices[rf.i2]);\n matrix.copyVec2(rf.normal, polygonBA.normals[rf.i1]);\n }\n\n matrix.setVec2(rf.sideNormal1, rf.normal.y, -rf.normal.x);\n matrix.setVec2(rf.sideNormal2, -rf.sideNormal1.x, -rf.sideNormal1.y);\n rf.sideOffset1 = matrix.dotVec2(rf.sideNormal1, rf.v1);\n rf.sideOffset2 = matrix.dotVec2(rf.sideNormal2, rf.v2);\n\n // Clip incident edge against extruded edge1 side edges.\n clipPoints1[0].recycle();\n clipPoints1[1].recycle();\n clipPoints2[0].recycle();\n clipPoints2[1].recycle();\n\n // Clip to box side 1\n const np1 = clipSegmentToLine(clipPoints1, ie, rf.sideNormal1, rf.sideOffset1, rf.i1);\n\n if (np1 < Settings.maxManifoldPoints) {\n return;\n }\n\n // Clip to negative box side 1\n const np2 = clipSegmentToLine(clipPoints2, clipPoints1, rf.sideNormal2, rf.sideOffset2, rf.i2);\n\n if (np2 < Settings.maxManifoldPoints) {\n return;\n }\n\n // Now clipPoints2 contains the clipped points.\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n matrix.copyVec2(manifold.localNormal, rf.normal);\n matrix.copyVec2(manifold.localPoint, rf.v1);\n } else {\n matrix.copyVec2(manifold.localNormal, polygonB.m_normals[rf.i1]);\n matrix.copyVec2(manifold.localPoint, polygonB.m_vertices[rf.i1]);\n }\n\n let pointCount = 0;\n for (let i = 0; i < Settings.maxManifoldPoints; ++i) {\n const separation = matrix.dotVec2(rf.normal, clipPoints2[i].v) - matrix.dotVec2(rf.normal, rf.v1);\n\n if (separation <= radius) {\n const cp = manifold.points[pointCount]; // ManifoldPoint\n\n if (primaryAxis.type == EPAxisType.e_edgeA) {\n matrix.detransformVec2(cp.localPoint, xf, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n } else {\n matrix.copyVec2(cp.localPoint, clipPoints2[i].v);\n cp.id.set(clipPoints2[i].id);\n cp.id.swapFeatures();\n }\n\n ++pointCount;\n }\n }\n\n manifold.pointCount = pointCount;\n};\n","import { CollidePolygons } from \"./collision/shape/CollidePolygon\";\nimport { Settings } from \"./Settings\";\nimport { Sweep } from \"./common/Sweep\";\nimport { DynamicTree } from \"./collision/DynamicTree\";\nimport { Manifold } from \"./collision/Manifold\";\nimport { Distance } from \"./collision/Distance\";\nimport { TimeOfImpact } from \"./collision/TimeOfImpact\";\nimport { stats } from \"./util/stats\";\n\n/** @hidden @deprecated Merged with main namespace */\nexport const internal = {\n CollidePolygons,\n Settings,\n Sweep,\n Manifold,\n Distance,\n TimeOfImpact,\n DynamicTree,\n stats\n};\n"],"names":["d","b","__assign","s","n","input","output","x","math_abs","math_sqrt","math_max","math_min","Vec2","v","a","AABB","normal","temp","math_PI","Settings","SettingsInternal","Pool","TreeNode","DynamicTree","c","Iterator","BroadPhase","displacement","math_sin","math_cos","transform","xf","math_atan2","Rot","matrix.vec2","Sweep","matrix.zeroVec2","matrix.transformVec2","matrix.copyVec2","localCenter","matrix.setRotAngle","matrix.combine2Vec2","matrix.minusVec2","matrix.rotVec2","Transform","rotation","Velocity","Position","Shape","FixtureProxy","Fixture","matrix.subVec2","matrix.transform","Body","matrix.plusScaleVec2","matrix.scaleVec2","matrix.dotVec2","matrix.crossNumVec2","matrix.plusVec2","point","JointEdge","Joint","DistanceInput","DistanceOutput","SimplexCache","cache","xfA","xfB","matrix.lengthSqrVec2","matrix.derotVec2","matrix.distVec2","rA","rB","matrix.normalizeVec2","matrix.minusScaleVec2","DistanceProxy","SimplexVertex","Simplex","v1","v2","matrix.setVec2","matrix.crossVec2Vec2","pA","pB","matrix.combine3Vec2","matrix.copyTransform","ShapeCastInput","ShapeCastOutput","simplex","pointA","pointB","TOIInput","TOIOutputState","TOIOutput","SeparationFunctionType","SeparationFunction","matrix.normalizeVec2Length","matrix.crossVec2Num","matrix.negVec2","TimeStep","ContactImpulse","Solver","matrix.mulVec2","Mat22","cA","cB","planePoint","clipPoint","ManifoldType","ContactFeatureType","PointState","ClipVertex","Manifold","ManifoldPoint","ContactID","WorldManifold","ContactEdge","VelocityConstraintPoint","tangent","P","Contact","_a","worldManifold","DEFAULTS","World","oldManifold","Vec3","EdgeShape","e","ChainShape","e1","e2","PolygonShape","ie","center","matrix.detransformVec2","matrix.addVec2","CircleShape","matrix.distSqrVec2","DistanceJoint","vA","vB","FrictionJoint","Mat33","LimitState","RevoluteJoint","PrismaticJoint","translation","perp","GearJoint","MotorJoint","MouseJoint","PulleyJoint","RopeJoint","WeldJoint","WheelJoint","Serializer","options","obj","Testbed","testbed","BoxShape","matrix.retransformVec2","clipPoints1","clipPoints2","normal1","matrix.detransformTransform","maxSeparation","edge1","matrix.rerotVec2","EPAxisType","VertexType","EPAxis","TempPolygon","ReferenceFace","s2"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,IAAI,gBAAgB,SAASA,IAAGC,IAAG;AAC/B,kBAAgB,OAAO,kBAClB,EAAE,WAAW,CAAA,eAAgB,SAAS,SAAUD,IAAGC,IAAG;AAAE,IAAAD,GAAE,YAAYC;AAAA,EAAE,KACzE,SAAUD,IAAGC,IAAG;AAAE,aAAS,KAAKA,GAAG,KAAI,OAAO,UAAU,eAAe,KAAKA,IAAG,CAAC,EAAG,CAAAD,GAAE,CAAC,IAAIC,GAAE,CAAC;AAAA;AACjG,SAAO,cAAcD,IAAGC,EAAC;AAC7B;AAEO,SAAS,UAAUD,IAAGC,IAAG;AAC5B,MAAI,OAAOA,OAAM,cAAcA,OAAM;AACjC,UAAM,IAAI,UAAU,yBAAyB,OAAOA,EAAC,IAAI,+BAA+B;AAC5F,gBAAcD,IAAGC,EAAC;AAClB,WAAS,KAAK;AAAE,SAAK,cAAcD;AAAA,EAAI;AACvC,EAAAA,GAAE,YAAYC,OAAM,OAAO,OAAO,OAAOA,EAAC,KAAK,GAAG,YAAYA,GAAE,WAAW,IAAI,GAAI;AACvF;AAEO,IAAI,WAAW,WAAW;AAC7B,aAAW,OAAO,UAAU,SAASC,UAAS,GAAG;AAC7C,aAASC,IAAG,IAAI,GAAGC,KAAI,UAA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AM;AAC/CA,aAAgB,SAAS,YAAY,GAAG,EAAE;AAAA,EAAA,OACrC;AACLA,aAAgB,SAAS,aAAa,SAAS,UAAU,GAAG,EAAE,CAAC;AAC/DA,aAAgB,SAAS,YAAY,SAAS,WAAW,GAAG,EAAE,CAAC;AAAA,EAAA;AAGjE,MAAI,aAAa;AACjB,WAAS,IAAI,GAAG,IAAInB,iBAAS,mBAAmB,EAAE,GAAG;AACnD,QAAM,aAAaqC,QAAe,GAAG,QAAQ,YAAY,CAAC,EAAE,CAAC,IAAIA,QAAe,GAAG,QAAQ,GAAG,EAAE;AAEhG,QAAI,cAAc,QAAQ;AAClB,UAAA,KAAK,SAAS,OAAO,UAAU;AAEjC,UAAA,YAAY,QAAQ,WAAW,SAAS;AAC1C+E,wBAAuB,GAAG,YAAY,IAAI,YAAY,CAAC,EAAE,CAAC;AAC1D,WAAG,GAAG,IAAI,YAAY,CAAC,EAAE,EAAE;AAAA,MAAA,OACtB;AACLjG,iBAAgB,GAAG,YAAY,YAAY,CAAC,EAAE,CAAC;AAC/C,WAAG,GAAG,IAAI,YAAY,CAAC,EAAE,EAAE;AAC3B,WAAG,GAAG;;AAGN,QAAA;AAAA,IAAA;AAAA,EACJ;AAGF,WAAS,aAAa;AACxB;AC9eO,IAAM,WAAW;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","x_google_ignoreList":[0]} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index de6c764a..ff01e618 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "planck", - "version": "1.1.6", + "version": "1.2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "planck", - "version": "1.1.6", + "version": "1.2.0", "license": "MIT", "devDependencies": { "@changesets/cli": "^2.27.11", diff --git a/package.json b/package.json index b1853ce8..ea2f8ee8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "planck", - "version": "1.1.6", + "version": "1.2.0", "description": "2D JavaScript/TypeScript physics engine for cross-platform HTML5 game development", "homepage": "https://github.com/piqnt/planck.js", "keywords": [