planck-js
Version:
2D JavaScript/TypeScript physics engine for cross-platform HTML5 game development
1 lines • 923 kB
Source Map (JSON)
{"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","../src/util/DataDriver.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<T>(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<T> {\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<T> {\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