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SAAS8M,GAC7B,OAAOklB,KAAK3mB,MAAQyB,CACtB,C,gBCTA,IAAIpY,EAA0B,oBAAVrlB,OAAgCA,MAChDC,EAA4B,oBAAXC,QAAiCA,OAEtDE,EAAQioB,MAAQ,WACThD,GACLu9B,QAAQC,IAAIjlD,MAAMglD,QAASE,UAC7B,EAEA1iD,EAAQoC,OAAS,SAASugD,EAAWC,EAAKH,GACxC,GAAK5iD,IACD8iD,EAEJ,MADAF,GAAOD,QAAQC,IAAIA,GACb,IAAItzB,MAAMyzB,EAClB,C,YCb8B,oBAAVhjD,OAAgCA,MACpB,oBAAXE,QAAiCA,OAE/B6iB,OAAOjoB,UAAUmoD,qBAExC9iD,EAAOC,QAAU,SAAS4d,EAAOklC,GAC3BllC,UACFA,EAAQ,CAAC,GAGX,IAAID,EAASgF,OAAOuiB,OAAO,CAAC,EAAGtnB,GAE/B,IAAM,IAAIrI,KAAOutC,EACXA,EAASpM,eAAenhC,SAA8B,IAAfqI,EAAMrI,KAC/CoI,EAAOpI,GAAOutC,EAASvtC,IAI3B,GAA4C,mBAAjCoN,OAAOogC,sBAEhB,IADA,IAAIC,EAAUrgC,OAAOogC,sBAAsBD,GAClCnjD,EAAI,EAAGA,EAAIqjD,EAAQt9C,OAAQ/F,IAAK,CACvC,IAAIsjD,EAASD,EAAQrjD,GACjBmjD,EAASD,qBAAqBI,SAAiC,IAAfrlC,EAAMrI,KACxDoI,EAAOslC,GAAUH,EAASG,GAE9B,CAGF,OAAOtlC,CACT,C","sources":["webpack://ch.enlightware.gamecreator/./node_modules/idb/build/esm/index.js","webpack://ch.enlightware.gamecreator/./node_modules/idb/build/esm/wrap-idb-value.js","webpack://ch.enlightware.gamecreator/./node_modules/idb/build/esm/async-iterators.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/Body.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/Contact.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/Fixture.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/Joint.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/Manifold.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/Settings.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/Shape.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/Solver.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/World.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/collision/AABB.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/collision/BroadPhase.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/collision/Distance.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/collision/DynamicTree.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/collision/TimeOfImpact.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/common/Mat22.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/common/Mat33.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/common/Math.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/common/Position.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/common/Rot.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/common/Sweep.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/common/Transform.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/common/Vec2.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/common/Vec3.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/common/Velocity.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/common/stats.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/index.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/joint/DistanceJoint.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/joint/FrictionJoint.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/joint/GearJoint.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/joint/MotorJoint.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/joint/MouseJoint.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/joint/PrismaticJoint.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/joint/PulleyJoint.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/joint/RevoluteJoint.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/joint/RopeJoint.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/joint/WeldJoint.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/joint/WheelJoint.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/serializer/index.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/shape/BoxShape.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/shape/ChainShape.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/shape/CircleShape.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/shape/CollideCircle.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/shape/CollideCirclePolygone.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/shape/CollideEdgeCircle.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/shape/CollideEdgePolygon.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/shape/CollidePolygon.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/shape/EdgeShape.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/shape/PolygonShape.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/util/Pool.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/util/Timer.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/util/common.js","webpack://ch.enlightware.gamecreator/./node_modules/planck-js/lib/util/options.js"],"sourcesContent":["import { w as wrap, r as replaceTraps } from './wrap-idb-value.js';\nexport { u as unwrap, w as wrap } from './wrap-idb-value.js';\n\n/**\n * Open a database.\n *\n * @param name Name of the database.\n * @param version Schema version.\n * @param callbacks Additional callbacks.\n */\nfunction openDB(name, version, { blocked, upgrade, blocking, terminated } = {}) {\n const request = indexedDB.open(name, version);\n const openPromise = wrap(request);\n if (upgrade) {\n request.addEventListener('upgradeneeded', (event) => {\n upgrade(wrap(request.result), event.oldVersion, event.newVersion, wrap(request.transaction));\n });\n }\n if (blocked)\n request.addEventListener('blocked', () => blocked());\n openPromise\n .then((db) => {\n if (terminated)\n db.addEventListener('close', () => terminated());\n if (blocking)\n db.addEventListener('versionchange', () => blocking());\n })\n .catch(() => { });\n return openPromise;\n}\n/**\n * Delete a database.\n *\n * @param name Name of the database.\n */\nfunction deleteDB(name, { blocked } = {}) {\n const request = indexedDB.deleteDatabase(name);\n if (blocked)\n request.addEventListener('blocked', () => blocked());\n return wrap(request).then(() => undefined);\n}\n\nconst readMethods = ['get', 'getKey', 'getAll', 'getAllKeys', 'count'];\nconst writeMethods = ['put', 'add', 'delete', 'clear'];\nconst cachedMethods = new Map();\nfunction getMethod(target, prop) {\n if (!(target instanceof IDBDatabase &&\n !(prop in target) &&\n typeof prop === 'string')) {\n return;\n }\n if (cachedMethods.get(prop))\n return cachedMethods.get(prop);\n const targetFuncName = prop.replace(/FromIndex$/, '');\n const useIndex = prop !== targetFuncName;\n const isWrite = writeMethods.includes(targetFuncName);\n if (\n // Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge.\n !(targetFuncName in (useIndex ? IDBIndex : IDBObjectStore).prototype) ||\n !(isWrite || readMethods.includes(targetFuncName))) {\n return;\n }\n const method = async function (storeName, ...args) {\n // isWrite ? 'readwrite' : undefined gzipps better, but fails in Edge :(\n const tx = this.transaction(storeName, isWrite ? 'readwrite' : 'readonly');\n let target = tx.store;\n if (useIndex)\n target = target.index(args.shift());\n // Must reject if op rejects.\n // If it's a write operation, must reject if tx.done rejects.\n // Must reject with op rejection first.\n // Must resolve with op value.\n // Must handle both promises (no unhandled rejections)\n return (await Promise.all([\n target[targetFuncName](...args),\n isWrite && tx.done,\n ]))[0];\n };\n cachedMethods.set(prop, method);\n return method;\n}\nreplaceTraps((oldTraps) => ({\n ...oldTraps,\n get: (target, prop, receiver) => getMethod(target, prop) || oldTraps.get(target, prop, receiver),\n has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop),\n}));\n\nexport { deleteDB, openDB };\n","const instanceOfAny = (object, constructors) => constructors.some((c) => object instanceof c);\n\nlet idbProxyableTypes;\nlet cursorAdvanceMethods;\n// This is a function to prevent it throwing up in node environments.\nfunction getIdbProxyableTypes() {\n return (idbProxyableTypes ||\n (idbProxyableTypes = [\n IDBDatabase,\n IDBObjectStore,\n IDBIndex,\n IDBCursor,\n IDBTransaction,\n ]));\n}\n// This is a function to prevent it throwing up in node environments.\nfunction getCursorAdvanceMethods() {\n return (cursorAdvanceMethods ||\n (cursorAdvanceMethods = [\n IDBCursor.prototype.advance,\n IDBCursor.prototype.continue,\n IDBCursor.prototype.continuePrimaryKey,\n ]));\n}\nconst cursorRequestMap = new WeakMap();\nconst transactionDoneMap = new WeakMap();\nconst transactionStoreNamesMap = new WeakMap();\nconst transformCache = new WeakMap();\nconst reverseTransformCache = new WeakMap();\nfunction promisifyRequest(request) {\n const promise = new Promise((resolve, reject) => {\n const unlisten = () => {\n request.removeEventListener('success', success);\n request.removeEventListener('error', error);\n };\n const success = () => {\n resolve(wrap(request.result));\n unlisten();\n };\n const error = () => {\n reject(request.error);\n unlisten();\n };\n request.addEventListener('success', success);\n request.addEventListener('error', error);\n });\n promise\n .then((value) => {\n // Since cursoring reuses the IDBRequest (*sigh*), we cache it for later retrieval\n // (see wrapFunction).\n if (value instanceof IDBCursor) {\n cursorRequestMap.set(value, request);\n }\n // Catching to avoid \"Uncaught Promise exceptions\"\n })\n .catch(() => { });\n // This mapping exists in reverseTransformCache but doesn't doesn't exist in transformCache. This\n // is because we create many promises from a single IDBRequest.\n reverseTransformCache.set(promise, request);\n return promise;\n}\nfunction cacheDonePromiseForTransaction(tx) {\n // Early bail if we've already created a done promise for this transaction.\n if (transactionDoneMap.has(tx))\n return;\n const done = new Promise((resolve, reject) => {\n const unlisten = () => {\n tx.removeEventListener('complete', complete);\n tx.removeEventListener('error', error);\n tx.removeEventListener('abort', error);\n };\n const complete = () => {\n resolve();\n unlisten();\n };\n const error = () => {\n reject(tx.error || new DOMException('AbortError', 'AbortError'));\n unlisten();\n };\n tx.addEventListener('complete', complete);\n tx.addEventListener('error', error);\n tx.addEventListener('abort', error);\n });\n // Cache it for later retrieval.\n transactionDoneMap.set(tx, done);\n}\nlet idbProxyTraps = {\n get(target, prop, receiver) {\n if (target instanceof IDBTransaction) {\n // Special handling for transaction.done.\n if (prop === 'done')\n return transactionDoneMap.get(target);\n // Polyfill for objectStoreNames because of Edge.\n if (prop === 'objectStoreNames') {\n return target.objectStoreNames || transactionStoreNamesMap.get(target);\n }\n // Make tx.store return the only store in the transaction, or undefined if there are many.\n if (prop === 'store') {\n return receiver.objectStoreNames[1]\n ? undefined\n : receiver.objectStore(receiver.objectStoreNames[0]);\n }\n }\n // Else transform whatever we get back.\n return wrap(target[prop]);\n },\n set(target, prop, value) {\n target[prop] = value;\n return true;\n },\n has(target, prop) {\n if (target instanceof IDBTransaction &&\n (prop === 'done' || prop === 'store')) {\n return true;\n }\n return prop in target;\n },\n};\nfunction replaceTraps(callback) {\n idbProxyTraps = callback(idbProxyTraps);\n}\nfunction wrapFunction(func) {\n // Due to expected object equality (which is enforced by the caching in `wrap`), we\n // only create one new func per func.\n // Edge doesn't support objectStoreNames (booo), so we polyfill it here.\n if (func === IDBDatabase.prototype.transaction &&\n !('objectStoreNames' in IDBTransaction.prototype)) {\n return function (storeNames, ...args) {\n const tx = func.call(unwrap(this), storeNames, ...args);\n transactionStoreNamesMap.set(tx, storeNames.sort ? storeNames.sort() : [storeNames]);\n return wrap(tx);\n };\n }\n // Cursor methods are special, as the behaviour is a little more different to standard IDB. In\n // IDB, you advance the cursor and wait for a new 'success' on the IDBRequest that gave you the\n // cursor. It's kinda like a promise that can resolve with many values. That doesn't make sense\n // with real promises, so each advance methods returns a new promise for the cursor object, or\n // undefined if the end of the cursor has been reached.\n if (getCursorAdvanceMethods().includes(func)) {\n return function (...args) {\n // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use\n // the original object.\n func.apply(unwrap(this), args);\n return wrap(cursorRequestMap.get(this));\n };\n }\n return function (...args) {\n // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use\n // the original object.\n return wrap(func.apply(unwrap(this), args));\n };\n}\nfunction transformCachableValue(value) {\n if (typeof value === 'function')\n return wrapFunction(value);\n // This doesn't return, it just creates a 'done' promise for the transaction,\n // which is later returned for transaction.done (see idbObjectHandler).\n if (value instanceof IDBTransaction)\n cacheDonePromiseForTransaction(value);\n if (instanceOfAny(value, getIdbProxyableTypes()))\n return new Proxy(value, idbProxyTraps);\n // Return the same value back if we're not going to transform it.\n return value;\n}\nfunction wrap(value) {\n // We sometimes generate multiple promises from a single IDBRequest (eg when cursoring), because\n // IDB is weird and a single IDBRequest can yield many responses, so these can't be cached.\n if (value instanceof IDBRequest)\n return promisifyRequest(value);\n // If we've already transformed this value before, reuse the transformed value.\n // This is faster, but it also provides object equality.\n if (transformCache.has(value))\n return transformCache.get(value);\n const newValue = transformCachableValue(value);\n // Not all types are transformed.\n // These may be primitive types, so they can't be WeakMap keys.\n if (newValue !== value) {\n transformCache.set(value, newValue);\n reverseTransformCache.set(newValue, value);\n }\n return newValue;\n}\nconst unwrap = (value) => reverseTransformCache.get(value);\n\nexport { reverseTransformCache as a, instanceOfAny as i, replaceTraps as r, unwrap as u, wrap as w };\n","import { r as replaceTraps, i as instanceOfAny, a as reverseTransformCache, u as unwrap } from './wrap-idb-value.js';\n\nconst advanceMethodProps = ['continue', 'continuePrimaryKey', 'advance'];\nconst methodMap = {};\nconst advanceResults = new WeakMap();\nconst ittrProxiedCursorToOriginalProxy = new WeakMap();\nconst cursorIteratorTraps = {\n get(target, prop) {\n if (!advanceMethodProps.includes(prop))\n return target[prop];\n let cachedFunc = methodMap[prop];\n if (!cachedFunc) {\n cachedFunc = methodMap[prop] = function (...args) {\n advanceResults.set(this, ittrProxiedCursorToOriginalProxy.get(this)[prop](...args));\n };\n }\n return cachedFunc;\n },\n};\nasync function* iterate(...args) {\n // tslint:disable-next-line:no-this-assignment\n let cursor = this;\n if (!(cursor instanceof IDBCursor)) {\n cursor = await cursor.openCursor(...args);\n }\n if (!cursor)\n return;\n cursor = cursor;\n const proxiedCursor = new Proxy(cursor, cursorIteratorTraps);\n ittrProxiedCursorToOriginalProxy.set(proxiedCursor, cursor);\n // Map this double-proxy back to the original, so other cursor methods work.\n reverseTransformCache.set(proxiedCursor, unwrap(cursor));\n while (cursor) {\n yield proxiedCursor;\n // If one of the advancing methods was not called, call continue().\n cursor = await (advanceResults.get(proxiedCursor) || cursor.continue());\n advanceResults.delete(proxiedCursor);\n }\n}\nfunction isIteratorProp(target, prop) {\n return ((prop === Symbol.asyncIterator &&\n instanceOfAny(target, [IDBIndex, IDBObjectStore, IDBCursor])) ||\n (prop === 'iterate' && instanceOfAny(target, [IDBIndex, IDBObjectStore])));\n}\nreplaceTraps((oldTraps) => ({\n ...oldTraps,\n get(target, prop, receiver) {\n if (isIteratorProp(target, prop))\n return iterate;\n return oldTraps.get(target, prop, receiver);\n },\n has(target, prop) {\n return isIteratorProp(target, prop) || oldTraps.has(target, prop);\n },\n}));\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = Body;\n\nvar common = require('./util/common');\nvar options = require('./util/options');\n\nvar Vec2 = require('./common/Vec2');\nvar Rot = require('./common/Rot');\nvar Math = require('./common/Math');\nvar Sweep = require('./common/Sweep');\nvar Transform = require('./common/Transform');\nvar Velocity = require('./common/Velocity');\nvar Position = require('./common/Position');\n\nvar Fixture = require('./Fixture');\nvar Shape = require('./Shape');\n\nvar staticBody = Body.STATIC = 'static';\nvar kinematicBody = Body.KINEMATIC = 'kinematic';\nvar dynamicBody = Body.DYNAMIC = 'dynamic';\n\n/**\n * @typedef {Object} BodyDef\n *\n * @prop type 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 * @prop position The world position of the body. Avoid creating bodies at the\n * origin since this can lead to many overlapping shapes.\n *\n * @prop angle The world angle of the body in radians.\n *\n * @prop linearVelocity The linear velocity of the body's origin in world\n * co-ordinates.\n *\n * @prop angularVelocity\n *\n * @prop linearDamping 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 *\n * @prop angularDamping 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 *\n * @prop fixedRotation Should this body be prevented from rotating? Useful for\n * characters.\n *\n * @prop bullet 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 * @prop active Does this body start out active?\n *\n * @prop awake Is this body initially awake or sleeping?\n *\n * @prop allowSleep Set this flag to false if this body should never fall\n * asleep. Note that this increases CPU usage.\n */\nvar BodyDef = {\n type : staticBody,\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 * @class\n * \n * A rigid body composed of one or more fixtures.\n * \n * @param {World} world\n * @param {BodyDef} def\n */\nfunction Body(world, def) {\n\n def = options(def, BodyDef);\n\n _ASSERT && common.assert(Vec2.isValid(def.position));\n _ASSERT && common.assert(Vec2.isValid(def.linearVelocity));\n _ASSERT && common.assert(Math.isFinite(def.angle));\n _ASSERT && common.assert(Math.isFinite(def.angularVelocity));\n _ASSERT && common.assert(Math.isFinite(def.angularDamping) && def.angularDamping >= 0.0);\n _ASSERT && common.assert(Math.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 == dynamicBody) {\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 = Vec2.clone(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\nBody.prototype._serialize = function() {\n var fixtures = [];\n for (var 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: fixtures,\n };\n};\n\nBody._deserialize = function(data, world, restore) {\n var body = new Body(world, data);\n\n if (data.fixtures) {\n for (var i = data.fixtures.length - 1; i >= 0; i--) {\n var fixture = restore(Fixture, data.fixtures[i], body);\n body._addFixture(fixture);\n }\n }\n return body;\n};\n\nBody.prototype.isWorldLocked = function() {\n return this.m_world && this.m_world.isLocked() ? true : false;\n};\n\nBody.prototype.getWorld = function() {\n return this.m_world;\n};\n\nBody.prototype.getNext = function() {\n return this.m_next;\n};\n\nBody.prototype.setUserData = function(data) {\n this.m_userData = data;\n};\n\nBody.prototype.getUserData = function() {\n return this.m_userData;\n};\n\nBody.prototype.getFixtureList = function() {\n return this.m_fixtureList;\n};\n\nBody.prototype.getJointList = function() {\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 */\nBody.prototype.getContactList = function() {\n return this.m_contactList;\n};\n\nBody.prototype.isStatic = function() {\n return this.m_type == staticBody;\n};\n\nBody.prototype.isDynamic = function() {\n return this.m_type == dynamicBody;\n};\n\nBody.prototype.isKinematic = function() {\n return this.m_type == kinematicBody;\n};\n\n/**\n * This will alter the mass and velocity.\n */\nBody.prototype.setStatic = function() {\n this.setType(staticBody);\n return this;\n};\n\nBody.prototype.setDynamic = function() {\n this.setType(dynamicBody);\n return this;\n};\n\nBody.prototype.setKinematic = function() {\n this.setType(kinematicBody);\n return this;\n};\n\n/**\n * @private\n */\nBody.prototype.getType = function() {\n return this.m_type;\n};\n\n/**\n * \n * @private\n */\nBody.prototype.setType = function(type) {\n _ASSERT && common.assert(type === staticBody || type === kinematicBody || type === dynamicBody);\n _ASSERT && common.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 == staticBody) {\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 var ce = this.m_contactList;\n while (ce) {\n var 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 var broadPhase = this.m_world.m_broadPhase;\n for (var f = this.m_fixtureList; f; f = f.m_next) {\n var proxyCount = f.m_proxyCount;\n for (var i = 0; i < proxyCount; ++i) {\n broadPhase.touchProxy(f.m_proxies[i].proxyId);\n }\n }\n};\n\nBody.prototype.isBullet = function() {\n return this.m_bulletFlag;\n};\n\n/**\n * Should this body be treated like a bullet for continuous collision detection?\n */\nBody.prototype.setBullet = function(flag) {\n this.m_bulletFlag = !!flag;\n};\n\nBody.prototype.isSleepingAllowed = function() {\n return this.m_autoSleepFlag;\n};\n\nBody.prototype.setSleepingAllowed = function(flag) {\n this.m_autoSleepFlag = !!flag;\n if (this.m_autoSleepFlag == false) {\n this.setAwake(true);\n }\n};\n\nBody.prototype.isAwake = function() {\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 */\nBody.prototype.setAwake = function(flag) {\n if (flag) {\n if (this.m_awakeFlag == false) {\n this.m_awakeFlag = true;\n this.m_sleepTime = 0.0;\n }\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\nBody.prototype.isActive = function() {\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 */\nBody.prototype.setActive = function(flag) {\n _ASSERT && common.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 var broadPhase = this.m_world.m_broadPhase;\n for (var f = this.m_fixtureList; f; f = f.m_next) {\n f.createProxies(broadPhase, this.m_xf);\n }\n // Contacts are created the next time step.\n\n } else {\n // Destroy all proxies.\n var broadPhase = this.m_world.m_broadPhase;\n for (var f = this.m_fixtureList; f; f = f.m_next) {\n f.destroyProxies(broadPhase);\n }\n\n // Destroy the attached contacts.\n var ce = this.m_contactList;\n while (ce) {\n var ce0 = ce;\n ce = ce.next;\n this.m_world.destroyContact(ce0.contact);\n }\n this.m_contactList = null;\n }\n};\n\nBody.prototype.isFixedRotation = function() {\n return this.m_fixedRotationFlag;\n};\n\n/**\n * Set this body to have fixed rotation. This causes the mass to be reset.\n */\nBody.prototype.setFixedRotation = function(flag) {\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 */\nBody.prototype.getTransform = function() {\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 */\nBody.prototype.setTransform = function(position, angle) {\n _ASSERT && common.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return;\n }\n\n this.m_xf.set(position, angle);\n this.m_sweep.setTransform(this.m_xf);\n\n var broadPhase = this.m_world.m_broadPhase;\n for (var f = this.m_fixtureList; f; f = f.m_next) {\n f.synchronize(broadPhase, this.m_xf, this.m_xf);\n }\n};\n\nBody.prototype.synchronizeTransform = function() {\n this.m_sweep.getTransform(this.m_xf, 1);\n};\n\n/**\n * Update fixtures in broad-phase.\n */\nBody.prototype.synchronizeFixtures = function() {\n var xf = Transform.identity();\n\n this.m_sweep.getTransform(xf, 0);\n\n var broadPhase = this.m_world.m_broadPhase;\n for (var 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 */\nBody.prototype.advance = function(alpha) {\n // Advance to the new safe time. This doesn't sync the broad-phase.\n this.m_sweep.advance(alpha);\n this.m_sweep.c.set(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 */\nBody.prototype.getPosition = function() {\n return this.m_xf.p;\n};\n\nBody.prototype.setPosition = function(p) {\n this.setTransform(p, this.m_sweep.a);\n};\n\n/**\n * Get the current world rotation angle in radians.\n */\nBody.prototype.getAngle = function() {\n return this.m_sweep.a;\n};\n\nBody.prototype.setAngle = function(angle) {\n this.setTransform(this.m_xf.p, angle);\n};\n\n/**\n * Get the world position of the center of mass.\n */\nBody.prototype.getWorldCenter = function() {\n return this.m_sweep.c;\n};\n\n/**\n * Get the local position of the center of mass.\n */\nBody.prototype.getLocalCenter = function() {\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 */\nBody.prototype.getLinearVelocity = function() {\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 */\nBody.prototype.getLinearVelocityFromWorldPoint = function(worldPoint) {\n var localCenter = Vec2.sub(worldPoint, this.m_sweep.c);\n return Vec2.add(this.m_linearVelocity, Vec2.cross(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 */\nBody.prototype.getLinearVelocityFromLocalPoint = function(localPoint) {\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 */\nBody.prototype.setLinearVelocity = function(v) {\n if (this.m_type == staticBody) {\n return;\n }\n if (Vec2.dot(v, v) > 0.0) {\n this.setAwake(true);\n }\n this.m_linearVelocity.set(v);\n};\n\n/**\n * Get the angular velocity.\n * \n * @returns the angular velocity in radians/second.\n */\nBody.prototype.getAngularVelocity = function() {\n return this.m_angularVelocity;\n};\n\n/**\n * Set the angular velocity.\n * \n * @param omega The new angular velocity in radians/second.\n */\nBody.prototype.setAngularVelocity = function(w) {\n if (this.m_type == staticBody) {\n return;\n }\n if (w * w > 0.0) {\n this.setAwake(true);\n }\n this.m_angularVelocity = w;\n};\n\nBody.prototype.getLinearDamping = function() {\n return this.m_linearDamping;\n};\n\nBody.prototype.setLinearDamping = function(linearDamping) {\n this.m_linearDamping = linearDamping;\n};\n\nBody.prototype.getAngularDamping = function() {\n return this.m_angularDamping;\n};\n\nBody.prototype.setAngularDamping = function(angularDamping) {\n this.m_angularDamping = angularDamping;\n};\n\nBody.prototype.getGravityScale = function() {\n return this.m_gravityScale;\n};\n\n/**\n * Scale the gravity applied to this body.\n */\nBody.prototype.setGravityScale = function(scale) {\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 */\nBody.prototype.getMass = function() {\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 */\nBody.prototype.getInertia = function() {\n return this.m_I + this.m_mass\n * Vec2.dot(this.m_sweep.localCenter, this.m_sweep.localCenter);\n};\n\n/**\n * @typedef {Object} MassData This holds the mass data computed for a shape.\n * \n * @prop mass The mass of the shape, usually in kilograms.\n * @prop center The position of the shape's centroid relative to the shape's\n * origin.\n * @prop I The rotational inertia of the shape about the local origin.\n */\nfunction MassData() {\n this.mass = 0;\n this.center = Vec2.zero();\n this.I = 0;\n};\n\n/**\n * Copy the mass data of the body to data.\n */\nBody.prototype.getMassData = function(data) {\n data.mass = this.m_mass;\n data.I = this.getInertia();\n data.center.set(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 */\nBody.prototype.resetMassData = function() {\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 this.m_sweep.localCenter.setZero();\n\n // Static and kinematic bodies have zero mass.\n if (this.isStatic() || this.isKinematic()) {\n this.m_sweep.c0.set(this.m_xf.p);\n this.m_sweep.c.set(this.m_xf.p);\n this.m_sweep.a0 = this.m_sweep.a;\n return;\n }\n\n _ASSERT && common.assert(this.isDynamic());\n\n // Accumulate mass over all fixtures.\n var localCenter = Vec2.zero();\n for (var f = this.m_fixtureList; f; f = f.m_next) {\n if (f.m_density == 0.0) {\n continue;\n }\n\n var massData = new MassData();\n f.getMassData(massData);\n this.m_mass += massData.mass;\n localCenter.addMul(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 localCenter.mul(this.m_invMass);\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 * Vec2.dot(localCenter, localCenter);\n _ASSERT && common.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 var oldCenter = Vec2.clone(this.m_sweep.c);\n this.m_sweep.setLocalCenter(localCenter, this.m_xf);\n\n // Update center of mass velocity.\n this.m_linearVelocity.add(Vec2.cross(this.m_angularVelocity, Vec2.sub(\n this.m_sweep.c, oldCenter)));\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 */\nBody.prototype.setMassData = function(massData) {\n _ASSERT && common.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return;\n }\n\n if (this.m_type != dynamicBody) {\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\n * Vec2.dot(massData.center, massData.center);\n _ASSERT && common.assert(this.m_I > 0.0);\n this.m_invI = 1.0 / this.m_I;\n }\n\n // Move center of mass.\n var oldCenter = Vec2.clone(this.m_sweep.c);\n this.m_sweep.setLocalCenter(massData.center, this.m_xf);\n\n // Update center of mass velocity.\n this.m_linearVelocity.add(Vec2.cross(this.m_angularVelocity, Vec2.sub(\n this.m_sweep.c, oldCenter)));\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 */\nBody.prototype.applyForce = function(force, point, wake) {\n if (this.m_type != dynamicBody) {\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.cross(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 */\nBody.prototype.applyForceToCenter = function(force, wake) {\n if (this.m_type != dynamicBody) {\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 */\nBody.prototype.applyTorque = function(torque, wake) {\n if (this.m_type != dynamicBody) {\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 */\nBody.prototype.applyLinearImpulse = function(impulse, point, wake) {\n if (this.m_type != dynamicBody) {\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.cross(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 */\nBody.prototype.applyAngularImpulse = function(impulse, wake) {\n if (this.m_type != dynamicBody) {\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 prevent connected bodies (by joints) from colliding,\n * depending on the joint's collideConnected flag.\n */\nBody.prototype.shouldCollide = function(that) {\n // At least one body should be dynamic.\n if (this.m_type != dynamicBody && that.m_type != dynamicBody) {\n return false;\n }\n // Does a joint prevent collision?\n for (var 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/**\n * @internal Used for deserialize.\n */\nBody.prototype._addFixture = function(fixture) {\n _ASSERT && common.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return null;\n }\n\n if (this.m_activeFlag) {\n var 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 * @param {Shape|FixtureDef} shape Shape or fixture definition.\n * @param {FixtureDef|number} fixdef Fixture definition or just density.\n */\nBody.prototype.createFixture = function(shape, fixdef) {\n _ASSERT && common.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return null;\n }\n\n var 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 */\nBody.prototype.destroyFixture = function(fixture) {\n _ASSERT && common.assert(this.isWorldLocked() == false);\n\n if (this.isWorldLocked() == true) {\n return;\n }\n\n _ASSERT && common.assert(fixture.m_body == this);\n\n // Remove the fixture from this body's singly linked list.\n var found = false;\n if (this.m_fixtureList === fixture) {\n this.m_fixtureList = fixture.m_next;\n found = true;\n\n } else {\n var 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 _ASSERT && common.assert(found);\n\n // Destroy any contacts associated with the fixture.\n var edge = this.m_contactList;\n while (edge) {\n var c = edge.contact;\n edge = edge.next;\n\n var fixtureA = c.getFixtureA();\n var 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 var 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 */\nBody.prototype.getWorldPoint = function(localPoint) {\n return Transform.mulVec2(this.m_xf, localPoint);\n};\n\n/**\n * Get the corresponding world vector of a local vector.\n */\nBody.prototype.getWorldVector = function(localVector) {\n return Rot.mulVec2(this.m_xf.q, localVector);\n};\n\n/**\n * Gets the corresponding local point of a world point.\n */\nBody.prototype.getLocalPoint = function(worldPoint) {\n return Transform.mulTVec2(this.m_xf, worldPoint);\n};\n\n/**\n * \n * Gets the corresponding local vector of a world vector.\n */\nBody.prototype.getLocalVector = function(worldVector) {\n return Rot.mulTVec2(this.m_xf.q, worldVector);\n};\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nvar DEBUG_SOLVER = false;\n\nvar common = require('./util/common');\n\nvar Math = require('./common/Math');\nvar Vec2 = require('./common/Vec2');\nvar Transform = require('./common/Transform');\nvar Mat22 = require('./common/Mat22');\nvar Rot = require('./common/Rot');\n\nvar Settings = require('./Settings');\nvar Manifold = require('./Manifold');\nvar Distance = require('./collision/Distance');\n\nmodule.exports = Contact;\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 * \n * @prop {Contact} contact The contact\n * @prop {ContactEdge} prev The previous contact edge in the body's contact list\n * @prop {ContactEdge} next The next contact edge in the body's contact list\n * @prop {Body} other Provides quick access to the other body attached.\n */\nfunction ContactEdge(contact) {\n this.contact = contact;\n this.prev;\n this.next;\n this.other;\n};\n\n/**\n * @function Contact~evaluate\n * \n * @param manifold\n * @param xfA\n * @param fixtureA\n * @param indexA\n * @param xfB\n * @param fixtureB\n * @param indexB\n */\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 * \n * @param {Fixture} fA\n * @param {int} indexA\n * @param {Fixture} fB\n * @param {int} indexB\n * @param {Contact~evaluate} evaluateFcn\n */\nfunction Contact(fA, indexA, fB, indexB, evaluateFcn) {\n // Nodes for connecting bodies.\n this.m_nodeA = new ContactEdge(this);\n this.m_nodeB = new ContactEdge(this);\n\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_manifold = new Manifold();\n\n this.m_prev = null;\n this.m_next = null;\n\n this.m_toi = 1.0;\n this.m_toiCount = 0;\n // This contact has a valid TOI in m_toi\n this.m_toiFlag = false;\n\n this.m_friction = mixFriction(this.m_fixtureA.m_friction,\n this.m_fixtureB.m_friction);\n this.m_restitution = mixRestitution(this.m_fixtureA.m_restitution,\n this.m_fixtureB.m_restitution);\n\n this.m_tangentSpeed = 0.0;\n\n // This contact can be disabled (by user)\n this.m_enabledFlag = true;\n\n // Used when crawling contact graph when forming islands.\n this.m_islandFlag = false;\n\n // Set when the shapes are touching.\n this.m_touchingFlag = false;\n\n // This contact needs filtering because a fixture filter was changed.\n this.m_filterFlag = false;\n\n // This bullet contact had a TOI event\n this.m_bulletHitFlag = false;\n\n this.v_points = []; // VelocityConstraintPoint[maxManifoldPoints]\n this.v_normal = Vec2.zero();\n this.v_normalMass = new Mat22();\n this.v_K = new Mat22();\n this.v_pointCount;\n\n this.v_tangentSpeed;\n this.v_friction;\n this.v_restitution;\n\n this.v_invMassA;\n this.v_invMassB;\n this.v_invIA;\n this.v_invIB;\n\n this.p_localPoints = [] // Vec2[maxManifoldPoints];\n this.p_localNormal = Vec2.zero();\n this.p_localPoint = Vec2.zero();\n this.p_localCenterA = Vec2.zero();\n this.p_localCenterB = Vec2.zero();\n this.p_type; // Manifold.Type\n this.p_radiusA;\n this.p_radiusB;\n this.p_pointCount;\n\n this.p_invMassA;\n this.p_invMassB;\n this.p_invIA;\n this.p_invIB;\n}\n\nContact.prototype.initConstraint = function(step) {\n var fixtureA = this.m_fixtureA;\n var fixtureB = this.m_fixtureB;\n\n var shapeA = fixtureA.getShape();\n var shapeB = fixtureB.getShape();\n\n var bodyA = fixtureA.getBody();\n var bodyB = fixtureB.getBody();\n\n var manifold = this.getManifold();\n\n var pointCount = manifold.pointCount;\n _ASSERT && common.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 this.p_localCenterA = Vec2.clone(bodyA.m_sweep.localCenter);\n this.p_localCenterB = Vec2.clone(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 this.p_localNormal = Vec2.clone(manifold.localNormal);\n this.p_localPoint = Vec2.clone(manifold.localPoint);\n this.p_pointCount = pointCount;\n\n for (var j = 0; j < pointCount; ++j) {\n var cp = manifold.points[j]; // ManifoldPoint\n var vcp = this.v_points[j] = new VelocityConstraintPoint();\n\n if (step.warmStarting) {\n vcp.normalImpulse = step.dtRatio * cp.normalImpulse;\n vcp.tangentImpulse = step.dtRatio * cp.tangentImpulse;\n\n } else {\n vcp.normalImpulse = 0.0;\n vcp.tangentImpulse = 0.0;\n }\n\n vcp.rA.setZero();\n vcp.rB.setZero();\n vcp.normalMass = 0.0;\n vcp.tangentMass = 0.0;\n vcp.velocityBias = 0.0;\n\n this.p_localPoints[j] = Vec2.clone(cp.localPoint);\n\n }\n};\n\n/**\n * Get the contact manifold. Do not modify the manifold unless you understand\n * the internals of the library.\n */\nContact.prototype.getManifold = function() {\n return this.m_manifold;\n}\n\n/**\n * Get the world manifold.\n * \n * @param {WorldManifold} [worldManifold]\n */\nContact.prototype.getWorldManifold = function(worldManifold) {\n var bodyA = this.m_fixtureA.getBody();\n var bodyB = this.m_fixtureB.getBody();\n var shapeA = this.m_fixtureA.getShape();\n var shapeB = this.m_fixtureB.getShape();\n\n return this.m_manifold.getWorldManifold(worldManifold, bodyA.getTransform(),\n shapeA.m_radius, bodyB.getTransform(), shapeB.m_radius);\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 */\nContact.prototype.setEnabled = function(flag) {\n this.m_enabledFlag = !!flag;\n}\n\n/**\n * Has this contact been disabled?\n */\nContact.prototype.isEnabled = function() {\n return this.m_enabledFlag;\n}\n\n/**\n * Is this contact touching?\n */\nContact.prototype.isTouching = function() {\n return this.m_touchingFlag;\n}\n\n/**\n * Get the next contact in the world's contact list.\n */\nContact.prototype.getNext = function() {\n return this.m_next;\n}\n\n/**\n * Get fixture A in this contact.\n */\nContact.prototype.getFixtureA = function() {\n return this.m_fixtureA;\n}\n\n/**\n * Get fixture B in this contact.\n */\nContact.prototype.getFixtureB = function() {\n return this.m_fixtureB;\n}\n\n/**\n * Get the child primitive index for fixture A.\n */\nContact.prototype.getChildIndexA = function() {\n return this.m_indexA;\n}\n\n/**\n * Get the child primitive index for fixture B.\n */\nContact.prototype.getChildIndexB = function() {\n return this.m_indexB;\n}\n\n/**\n * Flag this contact for filtering. Filtering will occur the next time step.\n */\nContact.prototype.flagForFiltering = function() {\n this.m_filterFlag = true;\n}\n\n/**\n * Override the default friction mixture. You can call this in\n * ContactListener.preSolve. This value persists until set or reset.\n */\nContact.prototype.setFriction = function(friction) {\n this.m_friction = friction;\n}\n\n/**\n * Get the friction.\n */\nContact.prototype.getFriction = function() {\n return this.m_friction;\n}\n\n/**\n * Reset the friction mixture to the default value.\n */\nContact.prototype.resetFriction = function() {\n this.m_friction = mixFriction(this.m_fixtureA.m_friction,\n this.m_fixtureB.m_friction);\n}\n\n/**\n * Override the default restitution mixture. You can call this in\n * ContactListener.preSolve. The value persists until you set or reset.\n */\nContact.prototype.setRestitution = function(restitution) {\n this.m_restitution = restitution;\n}\n\n/**\n * Get the restitution.\n */\nContact.prototype.getRestitution = function() {\n return this.m_restitution;\n}\n\n/**\n * Reset the restitution to the default value.\n */\nContact.prototype.resetRestitution = function() {\n this.m_restitution = mixRestitution(this.m_fixtureA.m_restitution,\n this.m_fixtureB.m_restitution);\n}\n\n/**\n * Set the desired tangent speed for a conveyor belt behavior. In meters per\n * second.\n */\nContact.prototype.setTangentSpeed = function(speed) {\n this.m_tangentSpeed = speed;\n}\n\n/**\n * Get the desired tangent speed. In meters per second.\n */\nContact.prototype.getTangentSpeed = function() {\n return this.m_tangentSpeed;\n}\n\n/**\n * Called by Update method, and implemented by subclasses.\n */\nContact.prototype.evaluate = function(manifold, xfA, xfB) {\n this.m_evaluateFcn(manifold, xfA, this.m_fixtureA, this.m_indexA, xfB,\n this.m_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 {function} listener.beginContact\n * @param {function} listener.endContact\n * @param {function} listener.preSolve\n */\nContact.prototype.update = function(listener) {\n\n // Re-enable this contact.\n this.m_enabledFlag = true;\n\n var touching = false;\n var wasTouching = this.m_touchingFlag;\n\n var sensorA = this.m_fixtureA.isSensor();\n var sensorB = this.m_fixtureB.isSensor();\n var sensor = sensorA || sensorB;\n\n var bodyA = this.m_fixtureA.getBody();\n var bodyB = this.m_fixtureB.getBody();\n var xfA = bodyA.getTransform();\n var xfB = bodyB.getTransform();\n\n // Is this contact a sensor?\n if (sensor) {\n var shapeA = this.m_fixtureA.getShape();\n var shapeB = this.m_fixtureB.getShape();\n touching = Distance.testOverlap(shapeA, this.m_indexA, shapeB,\n this.m_indexB, xfA, xfB);\n\n // Sensors don't generate manifolds.\n this.m_manifold.pointCount = 0;\n } else {\n\n // TODO reuse manifold\n var oldManifold = this.m_manifold;\n this.m_manifold = new Manifold();\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 (var i = 0; i < this.m_manifold.pointCount; ++i) {\n var nmp = this.m_manifold.points[i];\n nmp.normalImpulse = 0.0;\n nmp.tangentImpulse = 0.0;\n\n for (var j = 0; j < oldManifold.pointCount; ++j) {\n var omp = oldManifold.points[j];\n if (omp.id.key == nmp.id.key) { // ContactID.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 if (wasTouching == false && touching == true && listener) {\n listener.beginContact(this);\n }\n\n if (wasTouching == true && touching == false && listener) {\n listener.endContact(this);\n }\n\n if (sensor == false && touching && listener) {\n listener.preSolve(this, oldManifold);\n }\n}\n\nContact.prototype.solvePositionConstraint = function(step) {\n return this._solvePositionConstraint(step, false);\n}\n\nContact.prototype.solvePositionConstraintTOI = function(step, toiA, toiB) {\n return this._solvePositionConstraint(step, true, toiA, toiB);\n}\n\nContact.prototype._solvePositionConstraint = function(step, toi, toiA, toiB) {\n\n var fixtureA = this.m_fixtureA;\n var fixtureB = this.m_fixtureB;\n\n var bodyA = fixtureA.getBody();\n var bodyB = fixtureB.getBody();\n\n var velocityA = bodyA.c_velocity;\n var velocityB = bodyB.c_velocity;\n var positionA = bodyA.c_position;\n var positionB = bodyB.c_position;\n\n var localCenterA = Vec2.clone(this.p_localCenterA);\n var localCenterB = Vec2.clone(this.p_localCenterB);\n\n var mA = 0.0;\n var iA = 0.0;\n if (!toi || (bodyA == toiA || bodyA == toiB)) {\n mA = this.p_invMassA;\n iA = this.p_invIA;\n }\n\n var mB = 0.0;\n var iB = 0.0;\n if (!toi || (bodyB == toiA || bodyB == toiB)) {\n mB = this.p_invMassB;\n iB = this.p_invIB;\n }\n\n var cA = Vec2.clone(positionA.c);\n var aA = positionA.a;\n\n var cB = Vec2.clone(positionB.c);\n var aB = positionB.a;\n\n var minSeparation = 0.0;\n\n // Solve normal constraints\n for (var j = 0; j < this.p_pointCount; ++j) {\n var xfA = Transform.identity();\n var xfB = Transform.identity();\n xfA.q.set(aA);\n xfB.q.set(aB);\n xfA.p = Vec2.sub(cA, Rot.mulVec2(xfA.q, localCenterA));\n xfB.p = Vec2.sub(cB, Rot.mulVec2(xfB.q, localCenterB));\n\n // PositionSolverManifold\n var normal, point, separation;\n switch (this.p_type) {\n case Manifold.e_circles:\n var pointA = Transform.mulVec2(xfA, this.p_localPoint);\n var pointB = Transform.mulVec2(xfB, this.p_localPoints[0]);\n normal = Vec2.sub(pointB, pointA);\n normal.normalize();\n point = Vec2.combine(0.5, pointA, 0.5, pointB);\n separation = Vec2.dot(Vec2.sub(pointB, pointA), normal) - this.p_radiusA\n - this.p_radiusB;\n break;\n\n case Manifold.e_faceA:\n normal = Rot.mulVec2(xfA.q, this.p_localNormal);\n var planePoint = Transform.mulVec2(xfA, this.p_localPoint);\n var clipPoint = Transform.mulVec2(xfB, this.p_localPoints[j]);\n separation = Vec2.dot(Vec2.sub(clipPoint, planePoint), normal)\n - this.p_radiusA - this.p_radiusB;\n point = clipPoint;\n break;\n\n case Manifold.e_faceB:\n normal = Rot.mulVec2(xfB.q, this.p_localNormal);\n var planePoint = Transform.mulVec2(xfB, this.p_localPoint);\n var clipPoint = Transform.mulVec2(xfA, this.p_localPoints[j]);\n separation = Vec2.dot(Vec2.sub(clipPoint, planePoint), normal)\n - this.p_radiusA - this.p_radiusB;\n point = clipPoint;\n\n // Ensure normal points from A to B\n normal.mul(-1);\n break;\n }\n\n var rA = Vec2.sub(point, cA);\n var rB = Vec2.sub(point, cB);\n\n // Track max constraint error.\n minSeparation = Math.min(minSeparation, separation);\n\n var baumgarte = toi ? Settings.toiBaugarte : Settings.baumgarte;\n var linearSlop = Settings.linearSlop;\n var maxLinearCorrection = Settings.maxLinearCorrection;\n\n // Prevent large corrections and allow slop.\n var C = Math.clamp(baumgarte * (separation + linearSlop),\n -maxLinearCorrection, 0.0);\n\n // Compute the effective mass.\n var rnA = Vec2.cross(rA, normal);\n var rnB = Vec2.cross(rB, normal);\n var K = mA + mB + iA * rnA * rnA + iB * rnB * rnB;\n\n // Compute normal impulse\n var impulse = K > 0.0 ? -C / K : 0.0;\n\n var P = Vec2.mul(impulse, normal);\n\n cA.subMul(mA, P);\n aA -= iA * Vec2.cross(rA, P);\n\n cB.addMul(mB, P);\n aB += iB * Vec2.cross(rB, P);\n }\n\n positionA.c.set(cA);\n positionA.a = aA;\n\n positionB.c.set(cB);\n positionB.a = aB;\n\n return minSeparation;\n}\n\n// TODO merge with ManifoldPoint\nfunction VelocityConstraintPoint() {\n this.rA = Vec2.zero();\n this.rB = Vec2.zero();\n this.normalImpulse = 0;\n this.tangentImpulse = 0;\n this.normalMass = 0;\n this.tangentMass = 0;\n this.velocityBias = 0;\n}\n\nContact.prototype.initVelocityConstraint = function(step) {\n var fixtureA = this.m_fixtureA;\n var fixtureB = this.m_fixtureB;\n\n var bodyA = fixtureA.getBody();\n var bodyB = fixtureB.getBody();\n\n var velocityA = bodyA.c_velocity;\n var velocityB = bodyB.c_velocity;\n\n var positionA = bodyA.c_position;\n var positionB = bodyB.c_position;\n\n var radiusA = this.p_radiusA;\n var radiusB = this.p_radiusB;\n var manifold = this.getManifold();\n\n var mA = this.v_invMassA;\n var mB = this.v_invMassB;\n var iA = this.v_invIA;\n var iB = this.v_invIB;\n var localCenterA = Vec2.clone(this.p_localCenterA);\n var localCenterB = Vec2.clone(this.p_localCenterB);\n\n var cA = Vec2.clone(positionA.c);\n var aA = positionA.a;\n var vA = Vec2.clone(velocityA.v);\n var wA = velocityA.w;\n\n var cB = Vec2.clone(positionB.c);\n var aB = positionB.a;\n var vB = Vec2.clone(velocityB.v);\n var wB = velocityB.w;\n\n _ASSERT && common.assert(manifold.pointCount > 0);\n\n var xfA = Transform.identity();\n var xfB = Transform.identity();\n xfA.q.set(aA);\n xfB.q.set(aB);\n xfA.p.setCombine(1, cA, -1, Rot.mulVec2(xfA.q, localCenterA));\n xfB.p.setCombine(1, cB, -1, Rot.mulVec2(xfB.q, localCenterB));\n\n var worldManifold = manifold.getWorldManifold(null, xfA, radiusA, xfB, radiusB);\n\n this.v_normal.set(worldManifold.normal);\n\n for (var j = 0; j < this.v_pointCount; ++j) {\n var vcp = this.v_points[j]; // VelocityConstraintPoint\n\n vcp.rA.set(Vec2.sub(worldManifold.points[j], cA));\n vcp.rB.set(Vec2.sub(worldManifold.points[j], cB));\n\n var rnA = Vec2.cross(vcp.rA, this.v_normal);\n var rnB = Vec2.cross(vcp.rB, this.v_normal);\n\n var kNormal = mA + mB + iA * rnA * rnA + iB * rnB * rnB;\n\n vcp.normalMass = kNormal > 0.0 ? 1.0 / kNormal : 0.0;\n\n var tangent = Vec2.cross(this.v_normal, 1.0);\n\n var rtA = Vec2.cross(vcp.rA, tangent);\n var rtB = Vec2.cross(vcp.rB, tangent);\n\n var 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 var vRel = Vec2.dot(this.v_normal, vB)\n + Vec2.dot(this.v_normal, Vec2.cross(wB, vcp.rB))\n - Vec2.dot(this.v_normal, vA)\n - Vec2.dot(this.v_normal, Vec2.cross(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 var vcp1 = this.v_points[0]; // VelocityConstraintPoint\n var vcp2 = this.v_points[1]; // VelocityConstraintPoint\n\n var rn1A = Vec2.cross(vcp1.rA, this.v_normal);\n var rn1B = Vec2.cross(vcp1.rB, this.v_normal);\n var rn2A = Vec2.cross(vcp2.rA, this.v_normal);\n var rn2B = Vec2.cross(vcp2.rB, this.v_normal);\n\n var k11 = mA + mB + iA * rn1A * rn1A + iB * rn1B * rn1B;\n var k22 = mA + mB + iA * rn2A * rn2A + iB * rn2B * rn2B;\n var k12 = mA + mB + iA * rn1A * rn2A + iB * rn1B * rn2B;\n\n // Ensure a reasonable condition number.\n var 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.set(k11, k12);\n this.v_K.ey.set(k12, k22);\n this.v_normalMass.set(this.v_K.getInverse());\n } else {\n // The constraints are redundant, just use one.\n // TODO_ERIN use deepest?\n this.v_pointCount = 1;\n }\n }\n\n positionA.c.set(cA);\n positionA.a = aA;\n velocityA.v.set(vA);\n velocityA.w = wA;\n\n positionB.c.set(cB);\n positionB.a = aB;\n velocityB.v.set(vB);\n velocityB.w = wB;\n};\n\nContact.prototype.warmStartConstraint = function(step) {\n var fixtureA = this.m_fixtureA;\n var fixtureB = this.m_fixtureB;\n\n var bodyA = fixtureA.getBody();\n var bodyB = fixtureB.getBody();\n\n var velocityA = bodyA.c_velocity;\n var velocityB = bodyB.c_velocity;\n var positionA = bodyA.c_position;\n var positionB = bodyB.c_position;\n\n var mA = this.v_invMassA;\n var iA = this.v_invIA;\n var mB = this.v_invMassB;\n var iB = this.v_invIB;\n\n var vA = Vec2.clone(velocityA.v);\n var wA = velocityA.w;\n var vB = Vec2.clone(velocityB.v);\n var wB = velocityB.w;\n\n var normal = this.v_normal;\n var tangent = Vec2.cross(normal, 1.0);\n\n for (var j = 0; j < this.v_pointCount; ++j) {\n var vcp = this.v_points[j]; // VelocityConstraintPoint\n\n var P = Vec2.combine(vcp.normalImpulse, normal, vcp.tangentImpulse, tangent);\n wA -= iA * Vec2.cross(vcp.rA, P);\n vA.subMul(mA, P);\n wB += iB * Vec2.cross(vcp.rB, P);\n vB.addMul(mB, P);\n }\n\n velocityA.v.set(vA);\n velocityA.w = wA;\n velocityB.v.set(vB);\n velocityB.w = wB;\n};\n\nContact.prototype.storeConstraintImpulses = function(step) {\n var manifold = this.m_manifold;\n for (var 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\nContact.prototype.solveVelocityConstraint = function(step) {\n var bodyA = this.m_fixtureA.m_body;\n var bodyB = this.m_fixtureB.m_body;\n\n var velocityA = bodyA.c_velocity;\n var positionA = bodyA.c_position;\n\n var velocityB = bodyB.c_velocity;\n var positionB = bodyB.c_position;\n\n var mA = this.v_invMassA;\n var iA = this.v_invIA;\n var mB = this.v_invMassB;\n var iB = this.v_invIB;\n\n var vA = Vec2.clone(velocityA.v);\n var wA = velocityA.w;\n var vB = Vec2.clone(velocityB.v);\n var wB = velocityB.w;\n\n var normal = this.v_normal;\n var tangent = Vec2.cross(normal, 1.0);\n var friction = this.v_friction;\n\n _ASSERT && common.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 (var j = 0; j < this.v_pointCount; ++j) {\n var vcp = this.v_points[j]; // VelocityConstraintPoint\n\n // Relative velocity at contact\n var dv = Vec2.zero();\n dv.addCombine(1, vB, 1, Vec2.cross(wB, vcp.rB));\n dv.subCombine(1, vA, 1, Vec2.cross(wA, vcp.rA));\n\n // Compute tangent force\n var vt = Vec2.dot(dv, tangent) - this.v_tangentSpeed;\n var lambda = vcp.tangentMass * (-vt);\n\n // Clamp the accumulated force\n var maxFriction = friction * vcp.normalImpulse;\n var newImpulse = Math.clamp(vcp.tangentImpulse + lambda, -maxFriction,\n maxFriction);\n lambda = newImpulse - vcp.tangentImpulse;\n vcp.tangentImpulse = newImpulse;\n\n // Apply contact impulse\n var P = Vec2.mul(lambda, tangent);\n\n vA.subMul(mA, P);\n wA -= iA * Vec2.cross(vcp.rA, P);\n\n vB.addMul(mB, P);\n wB += iB * Vec2.cross(vcp.rB, P);\n }\n\n // Solve normal constraints\n if (this.v_pointCount == 1 || step.blockSolve == false) {\n for (var i = 0; i < this.v_pointCount; ++i) {\n var vcp = this.v_points[i]; // VelocityConstraintPoint\n\n // Relative velocity at contact\n var dv = Vec2.zero();\n dv.addCombine(1, vB, 1, Vec2.cross(wB, vcp.rB));\n dv.subCombine(1, vA, 1, Vec2.cross(wA, vcp.rA));\n\n // Compute normal impulse\n var vn = Vec2.dot(dv, normal);\n var lambda = -vcp.normalMass * (vn - vcp.velocityBias);\n\n // Clamp the accumulated impulse\n var newImpulse = Math.max(vcp.normalImpulse + lambda, 0.0);\n lambda = newImpulse - vcp.normalImpulse;\n vcp.normalImpulse = newImpulse;\n\n // Apply contact impulse\n var P = Vec2.mul(lambda, normal);\n\n vA.subMul(mA, P);\n wA -= iA * Vec2.cross(vcp.rA, P);\n\n vB.addMul(mB, P);\n wB += iB * Vec2.cross(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, , vn >= 0, x >= 0 and vn_i * x_i = 0 with i =\n // 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 var vcp1 = this.v_points[0]; // VelocityConstraintPoint\n var vcp2 = this.v_points[1]; // VelocityConstraintPoint\n\n var a = Vec2.neo(vcp1.normalImpulse, vcp2.normalImpulse);\n _ASSERT && common.assert(a.x >= 0.0 && a.y >= 0.0);\n\n // Relative velocity at contact\n var dv1 = Vec2.zero().add(vB).add(Vec2.cross(wB, vcp1.rB)).sub(vA).sub(Vec2.cross(wA, vcp1.rA));\n var dv2 = Vec2.zero().add(vB).add(Vec2.cross(wB, vcp2.rB)).sub(vA).sub(Vec2.cross(wA, vcp2.rA));\n\n // Compute normal velocity\n var vn1 = Vec2.dot(dv1, normal);\n var vn2 = Vec2.dot(dv2, normal);\n\n var b = Vec2.neo(vn1 - vcp1.velocityBias, vn2 - vcp2.velocityBias);\n\n // Compute b'\n b.sub(Mat22.mulVec2(this.v_K, a));\n\n var k_errorTol = 1e-3;\n // NOT_USED(k_errorTol);\n\n for (;;) {\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 var x = Mat22.mulVec2(this.v_normalMass, b).neg();\n\n if (x.x >= 0.0 && x.y >= 0.0) {\n // Get the incremental impulse\n var d = Vec2.sub(x, a);\n\n // Apply incremental impulse\n var P1 = Vec2.mul(d.x, normal);\n var P2 = Vec2.mul(d.y, normal);\n\n vA.subCombine(mA, P1, mA, P2);\n wA -= iA * (Vec2.cross(vcp1.rA, P1) + Vec2.cross(vcp2.rA, P2));\n\n vB.addCombine(mB, P1, mB, P2);\n wB += iB * (Vec2.cross(vcp1.rB, P1) + Vec2.cross(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n dv1 = vB + Vec2.cross(wB, vcp1.rB) - vA - Vec2.cross(wA, vcp1.rA);\n dv2 = vB + Vec2.cross(wB, vcp2.rB) - vA - Vec2.cross(wA, vcp2.rA);\n\n // Compute normal velocity\n vn1 = Dot(dv1, normal);\n vn2 = Dot(dv2, normal);\n\n _ASSERT && common.assert(Abs(vn1 - vcp1.velocityBias) < k_errorTol);\n _ASSERT && common.assert(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 var d = Vec2.sub(x, a);\n\n // Apply incremental impulse\n var P1 = Vec2.mul(d.x, normal);\n var P2 = Vec2.mul(d.y, normal);\n vA.subCombine(mA, P1, mA, P2);\n wA -= iA * (Vec2.cross(vcp1.rA, P1) + Vec2.cross(vcp2.rA, P2));\n\n vB.addCombine(mB, P1, mB, P2);\n wB += iB * (Vec2.cross(vcp1.rB, P1) + Vec2.cross(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n var dv1B = Vec2.add(vB, Vec2.cross(wB, vcp1.rB));\n var dv1A = Vec2.add(vA, Vec2.cross(wA, vcp1.rA));\n var dv1 = Vec2.sub(dv1B, dv1A);\n\n // Compute normal velocity\n vn1 = Vec2.dot(dv1, normal);\n\n _ASSERT && common.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 var d = Vec2.sub(x, a);\n\n // Apply incremental impulse\n var P1 = Vec2.mul(d.x, normal);\n var P2 = Vec2.mul(d.y, normal);\n vA.subCombine(mA, P1, mA, P2);\n wA -= iA * (Vec2.cross(vcp1.rA, P1) + Vec2.cross(vcp2.rA, P2));\n\n vB.addCombine(mB, P1, mB, P2);\n wB += iB * (Vec2.cross(vcp1.rB, P1) + Vec2.cross(vcp2.rB, P2));\n\n // Accumulate\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n\n if (DEBUG_SOLVER) {\n // Postconditions\n var dv2B = Vec2.add(vB, Vec2.cross(wB, vcp2.rB));\n var dv2A = Vec2.add(vA, Vec2.cross(wA, vcp2.rA));\n var dv1 = Vec2.sub(dv2B, dv2A);\n\n // Compute normal velocity\n vn2 = Vec2.dot(dv2, normal);\n\n _ASSERT && common.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 var d = Vec2.sub(x, a);\n\n // Apply incremental impulse\n var P1 = Vec2.mul(d.x, normal);\n var P2 = Vec2.mul(d.y, normal);\n vA.subCombine(mA, P1, mA, P2);\n wA -= iA * (Vec2.cross(vcp1.rA, P1) + Vec2.cross(vcp2.rA, P2));\n\n vB.addCombine(mB, P1, mB, P2);\n wB += iB * (Vec2.cross(vcp1.rB, P1) + Vec2.cross(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 velocityA.v.set(vA);\n velocityA.w = wA;\n\n velocityB.v.set(vB);\n velocityB.w = wB;\n};\n\n/**\n * Friction mixing law. The idea is to allow either fixture to drive the\n * restitution to zero. For example, anything slides on ice.\n */\nfunction mixFriction(friction1, friction2) {\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 */\nfunction mixRestitution(restitution1, restitution2) {\n return restitution1 > restitution2 ? restitution1 : restitution2;\n}\n\nvar s_registers = [];\n\n/**\n * @param fn function(fixtureA, indexA, fixtureB, indexB) Contact\n */\nContact.addType = function(type1, type2, callback) {\n\n s_registers[type1] = s_registers[type1] || {};\n s_registers[type1][type2] = callback;\n}\n\nContact.create = function(fixtureA, indexA, fixtureB, indexB) {\n var typeA = fixtureA.getType(); // Shape.Type\n var typeB = fixtureB.getType(); // Shape.Type\n\n // TODO: pool contacts\n var contact, evaluateFcn;\n if (evaluateFcn = s_registers[typeA] && s_registers[typeA][typeB]) {\n contact = new Contact(fixtureA, indexA, fixtureB, indexB, evaluateFcn);\n } else if (evaluateFcn = s_registers[typeB] && s_registers[typeB][typeA]) {\n contact = new Contact(fixtureB, indexB, fixtureA, indexA, evaluateFcn);\n } else {\n return null;\n }\n\n // Contact creation may swap fixtures.\n fixtureA = contact.getFixtureA();\n fixtureB = contact.getFixtureB();\n indexA = contact.getChildIndexA();\n indexB = contact.getChildIndexB();\n var bodyA = fixtureA.getBody();\n var bodyB = fixtureB.getBody();\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\nContact.destroy = function(contact, listener) {\n var fixtureA = contact.m_fixtureA;\n var fixtureB = contact.m_fixtureB;\n\n var bodyA = fixtureA.getBody();\n var bodyB = fixtureB.getBody();\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.isSensor() == false\n && fixtureB.isSensor() == false) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n\n var typeA = fixtureA.getType(); // Shape.Type\n var typeB = fixtureB.getType(); // Shape.Type\n\n var destroyFcn = s_registers[typeA][typeB].destroyFcn;\n if (typeof destroyFcn === 'function') {\n destroyFcn(contact);\n }\n};\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = Fixture;\n\nvar common = require('./util/common');\nvar options = require('./util/options');\n\nvar Math = require('./common/Math');\nvar Vec2 = require('./common/Vec2');\n\nvar AABB = require('./collision/AABB');\n\nvar Shape = require('./Shape');\n\n/**\n * @typedef {Object} FixtureDef\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 * \n * @prop friction The friction coefficient, usually in the range [0,1]\n * @prop restitution The restitution (elasticity) usually in the range [0,1]\n * @prop density The density, usually in kg/m^2\n * @prop isSensor A sensor shape collects contact information but never\n * generates a collision response\n * @prop userData\n * @prop filterGroupIndex Zero, positive or negative collision group. Fixtures with same positive groupIndex always collide and fixtures with same\n * negative groupIndex never collide.\n * @prop filterCategoryBits Collision category bit or bits that this fixture belongs\n * to. If groupIndex is zero or not matching, then at least one bit in this fixture\n * categoryBits should match other fixture maskBits and vice versa.\n * @prop filterMaskBits Collision category bit or bits that this fixture accept for\n * collision.\n */\nvar FixtureDef = {\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 */\nfunction FixtureProxy(fixture, childIndex) {\n this.aabb = new AABB();\n this.fixture = fixture;\n this.childIndex = childIndex;\n this.proxyId;\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. Fixtures are\n * created via Body.createFixture.\n * \n * @param {Body} body\n * @param {Shape|FixtureDef} shape Shape of fixture definition.\n * @param {FixtureDef|number} def Fixture definition or number.\n */\nfunction Fixture(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, FixtureDef);\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 var childCount = this.m_shape.getChildCount();\n for (var i = 0; i < childCount; ++i) {\n this.m_proxies[i] = new FixtureProxy(this, i);\n }\n\n this.m_userData = def.userData;\n};\n\n/**\n * Re-setup fixture.\n * @private\n */\nFixture.prototype._reset = function() {\n var body = this.getBody();\n var broadPhase = body.m_world.m_broadPhase;\n this.destroyProxies(broadPhase);\n if (this.m_shape._reset) {\n this.m_shape._reset();\n }\n var childCount = this.m_shape.getChildCount();\n for (var 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\nFixture.prototype._serialize = function() {\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\nFixture._deserialize = function(data, body, restore) {\n var shape = restore(Shape, data.shape);\n var 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 */\nFixture.prototype.getType = function() {\n return this.m_shape.getType();\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 */\nFixture.prototype.getShape = function() {\n return this.m_shape;\n}\n/**\n * A sensor shape collects contact information but never generates a collision\n * response.\n */\nFixture.prototype.isSensor = function() {\n return this.m_isSensor;\n}\n\n/**\n * Set if this fixture is a sensor.\n */\nFixture.prototype.setSensor = function(sensor) {\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// Fixture.prototype.getFilterData = function() {\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 */\nFixture.prototype.getUserData = function() {\n return this.m_userData;\n}\n\n/**\n * Set the user data. Use this to store your application specific data.\n */\nFixture.prototype.setUserData = function(data) {\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 */\nFixture.prototype.getBody = function() {\n return this.m_body;\n}\n\n/**\n * Get the next fixture in the parent body's fixture list.\n */\nFixture.prototype.getNext = function() {\n return this.m_next;\n}\n\n/**\n * Get the density of this fixture.\n */\nFixture.prototype.getDensity = function() {\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 */\nFixture.prototype.setDensity = function(density) {\n _ASSERT && common.assert(Math.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 */\nFixture.prototype.getFriction = function() {\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 */\nFixture.prototype.setFriction = function(friction) {\n this.m_friction = friction;\n}\n\n/**\n * Get the coefficient of restitution.\n */\nFixture.prototype.getRestitution = function() {\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 */\nFixture.prototype.setRestitution = function(restitution) {\n this.m_restitution = restitution;\n}\n\n/**\n * Test a point in world coordinates for containment in this fixture.\n */\nFixture.prototype.testPoint = function(p) {\n return this.m_shape.testPoint(this.m_body.getTransform(), p);\n}\n\n/**\n * Cast a ray against this shape.\n */\nFixture.prototype.rayCast = function(output, input, childIndex) {\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 */\nFixture.prototype.getMassData = function(massData) {\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 */\nFixture.prototype.getAABB = function(childIndex) {\n _ASSERT && common.assert(0 <= childIndex && childIndex < this.m_proxyCount);\n return this.m_proxies[childIndex].aabb;\n}\n\n/**\n * These support body activation/deactivation.\n */\nFixture.prototype.createProxies = function(broadPhase, xf) {\n _ASSERT && common.assert(this.m_proxyCount == 0);\n\n // Create proxies in the broad-phase.\n this.m_proxyCount = this.m_shape.getChildCount();\n\n for (var i = 0; i < this.m_proxyCount; ++i) {\n var 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\nFixture.prototype.destroyProxies = function(broadPhase) {\n // Destroy proxies in the broad-phase.\n for (var i = 0; i < this.m_proxyCount; ++i) {\n var 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 */\nFixture.prototype.synchronize = function(broadPhase, xf1, xf2) {\n for (var i = 0; i < this.m_proxyCount; ++i) {\n var proxy = this.m_proxies[i];\n // Compute an AABB that covers the swept shape (may miss some rotation\n // effect).\n var aabb1 = new AABB();\n var aabb2 = new AABB();\n this.m_shape.computeAABB(aabb1, xf1, proxy.childIndex);\n this.m_shape.computeAABB(aabb2, xf2, proxy.childIndex);\n\n proxy.aabb.combine(aabb1, aabb2);\n\n var displacement = Vec2.sub(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 */\nFixture.prototype.setFilterData = function(filter) {\n this.m_filterGroupIndex = filter.groupIndex;\n this.m_filterCategoryBits = filter.categoryBits;\n this.m_filterMaskBits = filter.maskBits;\n this.refilter();\n}\n\nFixture.prototype.getFilterGroupIndex = function() {\n return this.m_filterGroupIndex;\n}\n\nFixture.prototype.setFilterGroupIndex = function(groupIndex) {\n return this.m_filterGroupIndex = groupIndex;\n}\n\nFixture.prototype.getFilterCategoryBits = function() {\n return this.m_filterCategoryBits;\n}\n\nFixture.prototype.setFilterCategoryBits = function(categoryBits) {\n this.m_filterCategoryBits = categoryBits;\n}\n\nFixture.prototype.getFilterMaskBits = function() {\n return this.m_filterMaskBits;\n}\n\nFixture.prototype.setFilterMaskBits = function(maskBits) {\n this.m_filterMaskBits = maskBits;\n}\n\n/**\n * Call this if you want to establish collision that was previously disabled by\n * ContactFilter.\n */\nFixture.prototype.refilter = function() {\n if (this.m_body == null) {\n return;\n }\n\n // Flag associated contacts for filtering.\n var edge = this.m_body.getContactList();\n while (edge) {\n var contact = edge.contact;\n var fixtureA = contact.getFixtureA();\n var fixtureB = contact.getFixtureB();\n if (fixtureA == this || fixtureB == this) {\n contact.flagForFiltering();\n }\n\n edge = edge.next;\n }\n\n var 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 var broadPhase = world.m_broadPhase;\n for (var 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 * @param {Fixture} that\n */\nFixture.prototype.shouldCollide = function(that) {\n\n if (that.m_filterGroupIndex === this.m_filterGroupIndex && that.m_filterGroupIndex !== 0) {\n return that.m_filterGroupIndex > 0;\n }\n\n var collideA = (that.m_filterMaskBits & this.m_filterCategoryBits) !== 0;\n var collideB = (that.m_filterCategoryBits & this.m_filterMaskBits) !== 0;\n var collide = collideA && collideB;\n return collide;\n}\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = Joint;\n\nvar common = require('./util/common');\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 * \n * @prop {Body} other provides quick access to the other body attached.\n * @prop {Joint} joint the joint\n * @prop {JointEdge} prev the previous joint edge in the body's joint list\n * @prop {JointEdge} next the next joint edge in the body's joint list\n */\nfunction JointEdge() {\n this.other = null;\n this.joint = null;\n this.prev = null;\n this.next = null;\n};\n\n/**\n * @typedef {Object} JointDef\n *\n * Joint definitions are used to construct joints.\n * \n * @prop userData Use this to attach application specific data to your joints.\n * void userData;\n * @prop {boolean} collideConnected Set this flag to true if the attached bodies\n * should collide.\n *\n * @prop {Body} bodyA The first attached body.\n * @prop {Body} bodyB The second attached body.\n */\n\nvar 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 * \n * @param {JointDef} def\n */\nfunction Joint(def, bodyA, bodyB) {\n bodyA = def.bodyA || bodyA;\n bodyB = def.bodyB || bodyB;\n\n _ASSERT && common.assert(bodyA);\n _ASSERT && common.assert(bodyB);\n _ASSERT && common.assert(bodyA != bodyB);\n\n this.m_type = 'unknown-joint';\n\n this.m_bodyA = bodyA;\n this.m_bodyB = bodyB;\n\n this.m_index = 0;\n this.m_collideConnected = !!def.collideConnected;\n\n this.m_prev = null;\n this.m_next = null;\n\n this.m_edgeA = new JointEdge();\n this.m_edgeB = new JointEdge();\n\n this.m_islandFlag = false;\n this.m_userData = def.userData;\n};\n\nJoint.TYPES = {};\n\nJoint._deserialize = function(data, context, restore) {\n var clazz = Joint.TYPES[data.type];\n return clazz && restore(clazz, data);\n};\n\n/**\n * Short-cut function to determine if either body is inactive.\n * \n * @returns {boolean}\n */\nJoint.prototype.isActive = function() {\n return this.m_bodyA.isActive() && this.m_bodyB.isActive();\n}\n\n/**\n * Get the type of the concrete joint.\n * \n * @returns JointType\n */\nJoint.prototype.getType = function() {\n return this.m_type;\n}\n\n/**\n * Get the first body attached to this joint.\n * \n * @returns Body\n */\nJoint.prototype.getBodyA = function() {\n return this.m_bodyA;\n}\n\n/**\n * Get the second body attached to this joint.\n * \n * @returns Body\n */\nJoint.prototype.getBodyB = function() {\n return this.m_bodyB;\n}\n\n/**\n * Get the next joint the world joint list.\n * \n * @returns Joint\n */\nJoint.prototype.getNext = function() {\n return this.m_next;\n}\n\nJoint.prototype.getUserData = function() {\n return this.m_userData;\n}\n\nJoint.prototype.setUserData = function(data) {\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 * @returns {boolean}\n */\nJoint.prototype.getCollideConnected = function() {\n return this.m_collideConnected;\n};\n\n/**\n * Get the anchor point on bodyA in world coordinates.\n * \n * @return {Vec2}\n */\nJoint.prototype.getAnchorA = function() {\n};\n\n/**\n * Get the anchor point on bodyB in world coordinates.\n * \n * @return {Vec2}\n */\nJoint.prototype.getAnchorB = function() {\n};\n\n/**\n * Get the reaction force on bodyB at the joint anchor in Newtons.\n * \n * @param {float} inv_dt\n * @return {Vec2}\n */\nJoint.prototype.getReactionForce = function(inv_dt) {\n};\n\n/**\n * Get the reaction torque on bodyB in N*m.\n * \n * @param {float} inv_dt\n * @return {float}\n */\nJoint.prototype.getReactionTorque = function(inv_dt) {\n};\n\n/**\n * Shift the origin for any points stored in world coordinates.\n * \n * @param {Vec2} newOrigin\n */\nJoint.prototype.shiftOrigin = function(newOrigin) {\n};\n\n/**\n */\nJoint.prototype.initVelocityConstraints = function(step) {\n};\n\n/**\n */\nJoint.prototype.solveVelocityConstraints = function(step) {\n};\n\n/**\n * This returns true if the position errors are within tolerance.\n */\nJoint.prototype.solvePositionConstraints = function(step) {\n};\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nvar common = require('./util/common');\n\nvar Vec2 = require('./common/Vec2');\nvar Transform = require('./common/Transform');\nvar Math = require('./common/Math');\nvar Rot = require('./common/Rot');\n\nmodule.exports = Manifold;\nmodule.exports.clipSegmentToLine = clipSegmentToLine;\nmodule.exports.clipVertex = ClipVertex;\nmodule.exports.getPointStates = getPointStates;\nmodule.exports.PointState = PointState;\n\n// Manifold Type\nManifold.e_circles = 0;\nManifold.e_faceA = 1;\nManifold.e_faceB = 2;\n\n// ContactFeature Type\nManifold.e_vertex = 0;\nManifold.e_face = 1;\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 * \n * @prop type e_circle, e_faceA, e_faceB\n * @prop localPoint Usage depends on manifold type:
\n * e_circles: the local center of circleA
\n * e_faceA: the center of faceA
\n * e_faceB: the center of faceB\n * @prop localNormal Usage depends on manifold type:
\n * e_circles: not used
\n * e_faceA: the normal on polygonA
\n * e_faceB: the normal on polygonB\n * @prop points The points of contact {ManifoldPoint[]}\n * @prop pointCount The number of manifold points\n */\nfunction Manifold() {\n this.type;\n this.localNormal = Vec2.zero();\n this.localPoint = Vec2.zero();\n this.points = [ new ManifoldPoint(), new ManifoldPoint() ];\n this.pointCount = 0;\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 * \n * @prop {Vec2} localPoint Usage depends on manifold type:
\n * e_circles: the local center of circleB
\n * e_faceA: the local center of cirlceB or the clip point of polygonB
\n * e_faceB: the clip point of polygonA.\n * @prop normalImpulse The non-penetration impulse\n * @prop tangentImpulse The friction impulse\n * @prop {ContactID} id Uniquely identifies a contact point between two shapes\n * to facilatate warm starting\n */\nfunction ManifoldPoint() {\n this.localPoint = Vec2.zero();\n this.normalImpulse = 0;\n this.tangentImpulse = 0;\n this.id = new ContactID();\n};\n\n/**\n * Contact ids to facilitate warm starting.\n * \n * @prop {ContactFeature} cf\n * @prop key Used to quickly compare contact ids.\n * \n */\nfunction ContactID() {\n this.cf = new ContactFeature();\n};\n\nObject.defineProperty(ContactID.prototype, 'key', {\n get: function() {\n return this.cf.indexA + this.cf.indexB * 4 + this.cf.typeA * 16 + this.cf.typeB * 64;\n },\n enumerable: true,\n configurable: true\n});\n\nContactID.prototype.set = function(o) {\n // this.key = o.key;\n this.cf.set(o.cf);\n};\n\n/**\n * The features that intersect to form the contact point.\n * \n * @prop indexA Feature index on shapeA\n * @prop indexB Feature index on shapeB\n * @prop typeA The feature type on shapeA\n * @prop typeB The feature type on shapeB\n */\nfunction ContactFeature() {\n this.indexA;\n this.indexB;\n this.typeA;\n this.typeB;\n};\n\nContactFeature.prototype.set = function(o) {\n this.indexA = o.indexA;\n this.indexB = o.indexB;\n this.typeA = o.typeA;\n this.typeB = o.typeB;\n};\n\n/**\n * This is used to compute the current state of a contact manifold.\n * \n * @prop normal World vector pointing from A to B\n * @prop points World contact point (point of intersection)\n * @prop separations A negative value indicates overlap, in meters\n */\nfunction WorldManifold() {\n this.normal;\n this.points = []; // [maxManifoldPoints]\n this.separations = []; // float[maxManifoldPoints]\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 * @param {WorldManifold} [wm]\n */\nManifold.prototype.getWorldManifold = function(wm, xfA, radiusA, xfB, radiusB) {\n if (this.pointCount == 0) {\n return;\n }\n\n wm = wm || new WorldManifold();\n\n var normal = wm.normal;\n var points = wm.points;\n var separations = wm.separations;\n\n // TODO: improve\n switch (this.type) {\n case Manifold.e_circles:\n normal = Vec2.neo(1.0, 0.0);\n var pointA = Transform.mulVec2(xfA, this.localPoint);\n var pointB = Transform.mulVec2(xfB, this.points[0].localPoint);\n var dist = Vec2.sub(pointB, pointA);\n if (Vec2.lengthSquared(dist) > Math.EPSILON * Math.EPSILON) {\n normal.set(dist);\n normal.normalize();\n }\n var cA = pointA.clone().addMul(radiusA, normal);\n var cB = pointB.clone().addMul(-radiusB, normal);\n points[0] = Vec2.mid(cA, cB);\n separations[0] = Vec2.dot(Vec2.sub(cB, cA), normal);\n points.length = 1;\n separations.length = 1;\n break;\n\n case Manifold.e_faceA:\n normal = Rot.mulVec2(xfA.q, this.localNormal);\n var planePoint = Transform.mulVec2(xfA, this.localPoint);\n\n for (var i = 0; i < this.pointCount; ++i) {\n var clipPoint = Transform.mulVec2(xfB, this.points[i].localPoint);\n var cA = Vec2.clone(clipPoint).addMul(radiusA - Vec2.dot(Vec2.sub(clipPoint, planePoint), normal), normal);\n var cB = Vec2.clone(clipPoint).subMul(radiusB, normal);\n points[i] = Vec2.mid(cA, cB);\n separations[i] = Vec2.dot(Vec2.sub(cB, cA), normal);\n }\n points.length = this.pointCount;\n separations.length = this.pointCount;\n break;\n\n case Manifold.e_faceB:\n normal = Rot.mulVec2(xfB.q, this.localNormal);\n var planePoint = Transform.mulVec2(xfB, this.localPoint);\n\n for (var i = 0; i < this.pointCount; ++i) {\n var clipPoint = Transform.mulVec2(xfA, this.points[i].localPoint);\n var cB = Vec2.combine(1, clipPoint, radiusB - Vec2.dot(Vec2.sub(clipPoint, planePoint), normal), normal);\n var cA = Vec2.combine(1, clipPoint, -radiusA, normal);\n points[i] = Vec2.mid(cA, cB);\n separations[i] = Vec2.dot(Vec2.sub(cA, cB), normal);\n }\n points.length = this.pointCount;\n separations.length = this.pointCount;\n // Ensure normal points from A to B.\n normal.mul(-1);\n break;\n }\n\n wm.normal = normal;\n wm.points = points;\n wm.separations = separations;\n return wm;\n}\n\n/**\n * This is used for determining the state of contact points.\n * \n * @prop {0} nullState Point does not exist\n * @prop {1} addState Point was added in the update\n * @prop {2} persistState Point persisted across the update\n * @prop {3} removeState Point was removed in the update\n */\nvar PointState = {\n // TODO: use constants\n nullState : 0,\n addState : 1,\n persistState : 2,\n removeState : 3\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 * \n * @param {PointState[Settings.maxManifoldPoints]} state1\n * @param {PointState[Settings.maxManifoldPoints]} state2\n */\nfunction getPointStates(state1, state2, manifold1, manifold2) {\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 (var i = 0; i < manifold1.pointCount; ++i) {\n var id = manifold1.points[i].id;// ContactID\n\n state1[i] = PointState.removeState;\n\n for (var 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 (var i = 0; i < manifold2.pointCount; ++i) {\n var id = manifold2.points[i].id;// ContactID\n\n state2[i] = PointState.addState;\n\n for (var 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 * Used for computing contact manifolds.\n * \n * @prop {Vec2} v\n * @prop {ContactID} id\n */\nfunction ClipVertex() {\n this.v = Vec2.zero();\n this.id = new ContactID();\n};\n\nClipVertex.prototype.set = function(o) {\n this.v.set(o.v);\n this.id.set(o.id);\n};\n\n/**\n * Clipping for contact manifolds. Sutherland-Hodgman clipping.\n * \n * @param {ClipVertex[2]} vOut\n * @param {ClipVertex[2]} vIn\n */\nfunction clipSegmentToLine(vOut, vIn, normal, offset, vertexIndexA) {\n // Start with no output points\n var numOut = 0;\n\n // Calculate the distance of end points to the line\n var distance0 = Vec2.dot(normal, vIn[0].v) - offset;\n var distance1 = Vec2.dot(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 var interp = distance0 / (distance0 - distance1);\n vOut[numOut].v.setCombine(1 - interp, vIn[0].v, interp, vIn[1].v);\n\n // VertexA is hitting edgeB.\n vOut[numOut].id.cf.indexA = vertexIndexA;\n vOut[numOut].id.cf.indexB = vIn[0].id.cf.indexB;\n vOut[numOut].id.cf.typeA = Manifold.e_vertex;\n vOut[numOut].id.cf.typeB = Manifold.e_face;\n ++numOut;\n }\n\n return numOut;\n}\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\n// TODO merge with World options?\n\nvar Settings = exports;\n\n/**\n * Tuning constants based on meters-kilograms-seconds (MKS) units.\n */\n\n// Collision\n/**\n * The maximum number of contact points between two convex shapes. Do not change\n * this value.\n */\nSettings.maxManifoldPoints = 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 */\nSettings.maxPolygonVertices = 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 */\nSettings.aabbExtension = 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 */\nSettings.aabbMultiplier = 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 */\nSettings.linearSlop = 0.005;\nSettings.linearSlopSquared = Settings.linearSlop * Settings.linearSlop;\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 */\nSettings.angularSlop = (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 */\nSettings.polygonRadius = (2.0 * Settings.linearSlop);\n\n/**\n * Maximum number of sub-steps per contact in continuous physics simulation.\n */\nSettings.maxSubSteps = 8;\n\n// Dynamics\n\n/**\n * Maximum number of contacts to be handled to solve a TOI impact.\n */\nSettings.maxTOIContacts = 32;\n\n/**\n * Maximum iterations to solve a TOI.\n */\nSettings.maxTOIIterations = 20;\n\n/**\n * Maximum iterations to find Distance.\n */\nSettings.maxDistnceIterations = 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 */\nSettings.velocityThreshold = 1.0;\n\n/**\n * The maximum linear position correction used when solving constraints. This\n * helps to prevent overshoot.\n */\nSettings.maxLinearCorrection = 0.2;\n\n/**\n * The maximum angular position correction used when solving constraints. This\n * helps to prevent overshoot.\n */\nSettings.maxAngularCorrection = (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 this.\n */\nSettings.maxTranslation = 2.0;\nSettings.maxTranslationSquared = (Settings.maxTranslation * Settings.maxTranslation);\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 this.\n */\nSettings.maxRotation = (0.5 * Math.PI)\nSettings.maxRotationSquared = (Settings.maxRotation * Settings.maxRotation)\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 */\nSettings.baumgarte = 0.2;\nSettings.toiBaugarte = 0.75;\n\n// Sleep\n\n/**\n * The time that a body must be still before it will go to sleep.\n */\nSettings.timeToSleep = 0.5;\n\n/**\n * A body cannot sleep if its linear velocity is above this tolerance.\n */\nSettings.linearSleepTolerance = 0.01;\n\nSettings.linearSleepToleranceSqr = Math.pow(Settings.linearSleepTolerance, 2);\n\n/**\n * A body cannot sleep if its angular velocity is above this tolerance.\n */\nSettings.angularSleepTolerance = (2.0 / 180.0 * Math.PI);\n\nSettings.angularSleepToleranceSqr = Math.pow(Settings.angularSleepTolerance, 2);\n\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = Shape;\n\nvar Math = require('./common/Math');\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 */\nfunction Shape() {\n this.m_type;\n this.m_radius;\n}\n\nShape.prototype._reset = function() {\n};\n\nShape.prototype._serialize = function() {\n return {};\n};\n\nShape.TYPES = {};\n\nShape._deserialize = function(data, context, restore) {\n var clazz = Shape.TYPES[data.type];\n return clazz && restore(clazz, data);\n};\n\nShape.isValid = function(shape) {\n return !!shape;\n};\n\nShape.prototype.getRadius = function() {\n return this.m_radius;\n};\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 */\nShape.prototype.getType = function() {\n return this.m_type;\n};\n\n/**\n * @deprecated Shapes should be treated as immutable.\n *\n * clone the concrete shape.\n */\nShape.prototype._clone = function() {\n};\n\n/**\n * // Get the number of child primitives.\n */\nShape.prototype.getChildCount = function() {\n};\n\n/**\n * Test a point for containment in this shape. This only works for convex\n * shapes.\n * \n * @param {Transform} xf The shape world transform.\n * @param p A point in world coordinates.\n */\nShape.prototype.testPoint = function(xf, p) {\n};\n\n/**\n * Cast a ray against a child shape.\n * \n * @param {RayCastOutput} output The ray-cast results.\n * @param {RayCastInput} input The ray-cast input parameters.\n * @param {Transform} transform The transform to be applied to the shape.\n * @param childIndex The child shape index\n */\nShape.prototype.rayCast = function(output, input, transform, childIndex) {\n};\n\n/**\n * Given a transform, compute the associated axis aligned bounding box for a\n * child shape.\n * \n * @param {AABB} aabb Returns the axis aligned box.\n * @param {Transform} xf The world transform of the shape.\n * @param childIndex The child shape\n */\nShape.prototype.computeAABB = function(aabb, xf, childIndex) {\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} massData Returns the mass data for this shape.\n * @param density The density in kilograms per meter squared.\n */\nShape.prototype.computeMass = function(massData, density) {\n};\n\n/**\n * @param {DistanceProxy} proxy\n */\nShape.prototype.computeDistanceProxy = function(proxy) {\n};\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = Solver;\nmodule.exports.TimeStep = TimeStep;\n\nvar Settings = require('./Settings');\nvar common = require('./util/common');\n\nvar Vec2 = require('./common/Vec2');\nvar Math = require('./common/Math');\n\nvar Body = require('./Body');\nvar Contact = require('./Contact');\nvar Joint = require('./Joint');\n\nvar TimeOfImpact = require('./collision/TimeOfImpact');\nvar TOIInput = TimeOfImpact.Input;\nvar TOIOutput = TimeOfImpact.Output;\n\nvar Distance = require('./collision/Distance');\nvar DistanceInput = Distance.Input;\nvar DistanceOutput = Distance.Output;\nvar DistanceProxy = Distance.Proxy;\nvar SimplexCache = Distance.Cache;\n\nfunction TimeStep(dt) {\n this.dt = 0; // time step\n this.inv_dt = 0; // inverse time step (0 if dt == 0)\n this.velocityIterations = 0;\n this.positionIterations = 0;\n this.warmStarting = false;\n this.blockSolve = true;\n\n // timestep ratio for variable timestep\n this.inv_dt0 = 0.0;\n this.dtRatio = 1; // dt * inv_dt0\n}\n\nTimeStep.prototype.reset = function(dt) {\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 * Finds and solves islands. An island is a connected subset of the world.\n * \n * @param {World} world\n */\nfunction Solver(world) {\n this.m_world = world;\n this.m_stack = [];\n this.m_bodies = [];\n this.m_contacts = [];\n this.m_joints = [];\n}\n\nSolver.prototype.clear = function() {\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\nSolver.prototype.addBody = function(body) {\n _ASSERT && common.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\nSolver.prototype.addContact = function(contact) {\n _ASSERT && common.assert(contact instanceof Contact, 'Not a Contact!', contact);\n this.m_contacts.push(contact);\n};\n\nSolver.prototype.addJoint = function(joint) {\n _ASSERT && common.assert(joint instanceof Joint, 'Not a Joint!', joint);\n this.m_joints.push(joint);\n};\n\n/**\n * @param {TimeStep} step\n */\nSolver.prototype.solveWorld = function(step) {\n var world = this.m_world;\n\n // Clear all the island flags.\n for (var b = world.m_bodyList; b; b = b.m_next) {\n b.m_islandFlag = false;\n }\n for (var c = world.m_contactList; c; c = c.m_next) {\n c.m_islandFlag = false;\n }\n for (var j = world.m_jointList; j; j = j.m_next) {\n j.m_islandFlag = false;\n }\n\n // Build and simulate all awake islands.\n var stack = this.m_stack;\n var loop = -1;\n for (var 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 var b = stack.pop();\n _ASSERT && common.assert(b.isActive() == true);\n this.addBody(b);\n\n // Make sure the body is awake.\n b.setAwake(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 (var ce = b.m_contactList; ce; ce = ce.next) {\n var 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 var sensorA = contact.m_fixtureA.m_isSensor;\n var 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 var other = ce.other;\n\n // Was the other body already added to this island?\n if (other.m_islandFlag) {\n continue;\n }\n\n // _ASSERT && common.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 (var je = b.m_jointList; je; je = je.next) {\n if (je.joint.m_islandFlag == true) {\n continue;\n }\n\n var 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 // _ASSERT && common.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 (var 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 var b = this.m_bodies[i];\n if (b.isStatic()) {\n b.m_islandFlag = false;\n }\n }\n }\n}\n\n/**\n * @param {TimeStep} step\n */\nSolver.prototype.solveIsland = function(step) {\n // B2: Island Solve\n var world = this.m_world;\n var gravity = world.m_gravity;\n var allowSleep = world.m_allowSleep;\n\n var h = step.dt;\n\n // Integrate velocities and apply damping. Initialize the body state.\n for (var i = 0; i < this.m_bodies.length; ++i) {\n var body = this.m_bodies[i];\n\n var c = Vec2.clone(body.m_sweep.c);\n var a = body.m_sweep.a;\n var v = Vec2.clone(body.m_linearVelocity);\n var w = body.m_angularVelocity;\n\n // Store positions for continuous collision.\n body.m_sweep.c0.set(body.m_sweep.c);\n body.m_sweep.a0 = body.m_sweep.a;\n\n if (body.isDynamic()) {\n // Integrate velocities.\n v.addMul(h * body.m_gravityScale, gravity);\n v.addMul(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 v.mul(1.0 / (1.0 + h * body.m_linearDamping));\n w *= 1.0 / (1.0 + h * body.m_angularDamping);\n }\n\n body.c_position.c = c;\n body.c_position.a = a;\n body.c_velocity.v = v;\n body.c_velocity.w = w;\n }\n\n for (var i = 0; i < this.m_contacts.length; ++i) {\n var contact = this.m_contacts[i];\n contact.initConstraint(step);\n }\n\n _DEBUG && this.printBodies('M: ');\n\n for (var i = 0; i < this.m_contacts.length; ++i) {\n var contact = this.m_contacts[i];\n contact.initVelocityConstraint(step);\n }\n\n _DEBUG && this.printBodies('R: ');\n\n if (step.warmStarting) {\n // Warm start.\n for (var i = 0; i < this.m_contacts.length; ++i) {\n var contact = this.m_contacts[i];\n contact.warmStartConstraint(step);\n }\n }\n\n _DEBUG && this.printBodies('Q: ');\n \n for (var i = 0; i < this.m_joints.length; ++i) {\n var joint = this.m_joints[i];\n joint.initVelocityConstraints(step);\n }\n\n _DEBUG && this.printBodies('E: ');\n\n // Solve velocity constraints\n for (var i = 0; i < step.velocityIterations; ++i) {\n for (var j = 0; j < this.m_joints.length; ++j) {\n var joint = this.m_joints[j];\n joint.solveVelocityConstraints(step);\n }\n\n for (var j = 0; j < this.m_contacts.length; ++j) {\n var contact = this.m_contacts[j];\n contact.solveVelocityConstraint(step);\n }\n }\n\n _DEBUG && this.printBodies('D: ');\n\n // Store impulses for warm starting\n for (var i = 0; i < this.m_contacts.length; ++i) {\n var contact = this.m_contacts[i];\n contact.storeConstraintImpulses(step);\n }\n\n _DEBUG && this.printBodies('C: ');\n\n // Integrate positions\n for (var i = 0; i < this.m_bodies.length; ++i) {\n var body = this.m_bodies[i];\n\n var c = Vec2.clone(body.c_position.c);\n var a = body.c_position.a;\n var v = Vec2.clone(body.c_velocity.v);\n var w = body.c_velocity.w;\n\n // Check for large velocities\n var translation = Vec2.mul(h, v);\n if (Vec2.lengthSquared(translation) > Settings.maxTranslationSquared) {\n var ratio = Settings.maxTranslation / translation.length();\n v.mul(ratio);\n }\n\n var rotation = h * w;\n if (rotation * rotation > Settings.maxRotationSquared) {\n var ratio = Settings.maxRotation / Math.abs(rotation);\n w *= ratio;\n }\n\n // Integrate\n c.addMul(h, v);\n a += h * w;\n\n body.c_position.c.set(c);\n body.c_position.a = a;\n body.c_velocity.v.set(v);\n body.c_velocity.w = w;\n }\n\n _DEBUG && this.printBodies('B: ');\n\n // Solve position constraints\n var positionSolved = false;\n for (var i = 0; i < step.positionIterations; ++i) {\n var minSeparation = 0.0;\n for (var j = 0; j < this.m_contacts.length; ++j) {\n var contact = this.m_contacts[j];\n var 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 var contactsOkay = minSeparation >= -3.0 * Settings.linearSlop;\n\n var jointsOkay = true;\n for (var j = 0; j < this.m_joints.length; ++j) {\n var joint = this.m_joints[j];\n var 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 _DEBUG && this.printBodies('L: ');\n\n // Copy state buffers back to the bodies\n for (var i = 0; i < this.m_bodies.length; ++i) {\n var body = this.m_bodies[i];\n\n body.m_sweep.c.set(body.c_position.c);\n body.m_sweep.a = body.c_position.a;\n body.m_linearVelocity.set(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 var minSleepTime = Infinity;\n\n var linTolSqr = Settings.linearSleepToleranceSqr;\n var angTolSqr = Settings.angularSleepToleranceSqr;\n\n for (var i = 0; i < this.m_bodies.length; ++i) {\n var 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 || (Vec2.lengthSquared(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 (var i = 0; i < this.m_bodies.length; ++i) {\n var body = this.m_bodies[i];\n body.setAwake(false);\n }\n }\n }\n};\n\nSolver.prototype.printBodies = function(tag) {\n for (var i = 0; i < this.m_bodies.length; ++i) {\n var b = this.m_bodies[i];\n common.debug(tag, b.c_position.a, b.c_position.c.x, b.c_position.c.y, b.c_velocity.w, b.c_velocity.v.x, b.c_velocity.v.y);\n }\n};\n\nvar s_subStep = new TimeStep(); // reuse\n\n/**\n * Find TOI contacts and solve them.\n *\n * @param {TimeStep} step\n */\nSolver.prototype.solveWorldTOI = function(step) {\n var world = this.m_world;\n\n if (world.m_stepComplete) {\n for (var 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 (var 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 for (;;) {\n // Find the first TOI.\n var minContact = null; // Contact\n var minAlpha = 1.0;\n\n for (var 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 var alpha = 1.0;\n if (c.m_toiFlag) {\n // This contact has a valid cached TOI.\n alpha = c.m_toi;\n } else {\n var fA = c.getFixtureA();\n var fB = c.getFixtureB();\n\n // Is there a sensor?\n if (fA.isSensor() || fB.isSensor()) {\n continue;\n }\n\n var bA = fA.getBody();\n var bB = fB.getBody();\n\n _ASSERT && common.assert(bA.isDynamic() || bB.isDynamic());\n\n var activeA = bA.isAwake() && !bA.isStatic();\n var 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 var collideA = bA.isBullet() || !bA.isDynamic();\n var 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 var 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 _ASSERT && common.assert(alpha0 < 1.0);\n\n var indexA = c.getChildIndexA();\n var indexB = c.getChildIndexB();\n\n var sweepA = bA.m_sweep;\n var sweepB = bB.m_sweep;\n\n // Compute the time of impact in interval [0, minTOI]\n var input = new TOIInput(); // TODO: reuse\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 var output = new TOIOutput(); // TODO: reuse\n TimeOfImpact(output, input);\n\n // Beta is the fraction of the remaining portion of the [time?].\n var beta = output.t;\n if (output.state == TOIOutput.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 * Math.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 var fA = minContact.getFixtureA();\n var fB = minContact.getFixtureB();\n var bA = fA.getBody();\n var bB = fB.getBody();\n\n var backup1 = bA.m_sweep.clone();\n var backup2 = bB.m_sweep.clone();\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 var bodies = [ bA, bB ];\n for (var i = 0; i < bodies.length; ++i) {\n var body = bodies[i];\n if (body.isDynamic()) {\n for (var 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 var 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 var other = ce.other;\n if (other.isDynamic() && !body.isBullet() && !other.isBullet()) {\n continue;\n }\n\n // Skip sensors.\n var sensorA = contact.m_fixtureA.m_isSensor;\n var sensorB = contact.m_fixtureB.m_isSensor;\n if (sensorA || sensorB) {\n continue;\n }\n\n // Tentatively advance the body to the TOI.\n var backup = other.m_sweep.clone();\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 (var i = 0; i < this.m_bodies.length; ++i) {\n var 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 (var 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 if (_DEBUG) for (var b = world.m_bodyList; b; b = b.m_next) {\n var c = b.m_sweep.c;\n var a = b.m_sweep.a;\n var v = b.m_linearVelocity;\n var w = b.m_angularVelocity;\n }\n}\n\n/**\n * @param {TimeStep} subStep\n * @param toiA\n * @param toiB\n */\nSolver.prototype.solveIslandTOI = function(subStep, toiA, toiB) {\n var world = this.m_world;\n\n // Initialize the body state.\n for (var i = 0; i < this.m_bodies.length; ++i) {\n var body = this.m_bodies[i];\n body.c_position.c.set(body.m_sweep.c);\n body.c_position.a = body.m_sweep.a;\n body.c_velocity.v.set(body.m_linearVelocity);\n body.c_velocity.w = body.m_angularVelocity;\n }\n\n for (var i = 0; i < this.m_contacts.length; ++i) {\n var contact = this.m_contacts[i];\n contact.initConstraint(subStep);\n }\n\n // Solve position constraints.\n for (var i = 0; i < subStep.positionIterations; ++i) {\n var minSeparation = 0.0;\n for (var j = 0; j < this.m_contacts.length; ++j) {\n var contact = this.m_contacts[j];\n var 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 var 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 (var i = 0; i < this.m_contacts.length; ++i) {\n var c = this.m_contacts[i];\n var fA = c.getFixtureA();\n var fB = c.getFixtureB();\n\n var bA = fA.getBody();\n var bB = fB.getBody();\n\n var indexA = c.getChildIndexA();\n var indexB = c.getChildIndexB();\n\n var input = new DistanceInput();\n input.proxyA.set(fA.getShape(), indexA);\n input.proxyB.set(fB.getShape(), indexB);\n input.transformA = bA.getTransform();\n input.transformB = bB.getTransform();\n input.useRadii = false;\n\n var output = new DistanceOutput();\n var 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 toiA.m_sweep.c0.set(toiA.c_position.c);\n toiA.m_sweep.a0 = toiA.c_position.a;\n toiB.m_sweep.c0.set(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 (var i = 0; i < this.m_contacts.length; ++i) {\n var contact = this.m_contacts[i];\n contact.initVelocityConstraint(subStep);\n }\n\n // Solve velocity constraints.\n for (var i = 0; i < subStep.velocityIterations; ++i) {\n for (var j = 0; j < this.m_contacts.length; ++j) {\n var 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 var h = subStep.dt;\n\n // Integrate positions\n for (var i = 0; i < this.m_bodies.length; ++i) {\n var body = this.m_bodies[i];\n\n var c = Vec2.clone(body.c_position.c);\n var a = body.c_position.a;\n var v = Vec2.clone(body.c_velocity.v);\n var w = body.c_velocity.w;\n\n // Check for large velocities\n var translation = Vec2.mul(h, v);\n if (Vec2.dot(translation, translation) > Settings.maxTranslationSquared) {\n var ratio = Settings.maxTranslation / translation.length();\n v.mul(ratio);\n }\n\n var rotation = h * w;\n if (rotation * rotation > Settings.maxRotationSquared) {\n var ratio = Settings.maxRotation / Math.abs(rotation);\n w *= ratio;\n }\n\n // Integrate\n c.addMul(h, v);\n a += h * w;\n\n body.c_position.c = c;\n body.c_position.a = a;\n body.c_velocity.v = v;\n body.c_velocity.w = w;\n\n // Sync bodies\n body.m_sweep.c = c;\n body.m_sweep.a = a;\n body.m_linearVelocity = v;\n body.m_angularVelocity = w;\n body.synchronizeTransform();\n }\n\n this.postSolveIsland();\n};\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 */\nfunction ContactImpulse() {\n this.normalImpulses = [];\n this.tangentImpulses = [];\n};\n\nSolver.prototype.postSolveIsland = function() {\n // TODO: report contact.v_points instead of new object?\n var impulse = new ContactImpulse();\n for (var c = 0; c < this.m_contacts.length; ++c) {\n var contact = this.m_contacts[c];\n for (var p = 0; p < contact.v_points.length; ++p) {\n impulse.normalImpulses.push(contact.v_points[p].normalImpulse);\n impulse.tangentImpulses.push(contact.v_points[p].tangentImpulse);\n }\n this.m_world.postSolve(contact, impulse);\n }\n};\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = World;\n\nvar options = require('./util/options');\nvar common = require('./util/common');\nvar Vec2 = require('./common/Vec2');\nvar BroadPhase = require('./collision/BroadPhase');\nvar Solver = require('./Solver');\nvar Body = require('./Body');\nvar Joint = require('./Joint');\nvar Contact = require('./Contact');\n\n/**\n * @typedef {Object} WorldDef\n *\n * @prop {Vec2} [gravity = { x : 0, y : 0}]\n * @prop {boolean} [allowSleep = true]\n * @prop {boolean} [warmStarting = true]\n * @prop {boolean} [continuousPhysics = true]\n * @prop {boolean} [subStepping = false]\n * @prop {boolean} [blockSolve = true]\n * @prop {int} [velocityIterations = 8] For the velocity constraint solver.\n * @prop {int} [positionIterations = 3] For the position constraint solver.\n */\nvar 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 * @param {WorldDef|Vec2} def World definition or gravity vector.\n */\nfunction World(def) {\n if (!(this instanceof World)) {\n return new World(def);\n }\n\n if (def && Vec2.isValid(def)) {\n def = {gravity : def};\n }\n\n def = options(def, 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 // Broad-phase callback.\n this.addPair = this.createContact.bind(this);\n}\n\nWorld.prototype._serialize = function() {\n var bodies = [];\n var joints = [];\n\n for (var b = this.getBodyList(); b; b = b.getNext()) {\n bodies.push(b);\n }\n\n for (var j = this.getJointList(); j; j = j.getNext()) {\n if (typeof j._serialize === 'function') {\n joints.push(j);\n }\n }\n\n return {\n gravity: this.m_gravity,\n bodies: bodies,\n joints: joints,\n };\n};\n\nWorld._deserialize = function(data, context, restore) {\n if (!data) {\n return new World();\n }\n\n var world = new World(data.gravity);\n\n if (data.bodies) {\n for(var 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(var 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 */\nWorld.prototype.getBodyList = function() {\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 */\nWorld.prototype.getJointList = function() {\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 * @return the head of the world contact list. Warning: contacts are created and\n * destroyed in the middle of a time step. Use ContactListener to avoid\n * missing contacts.\n */\nWorld.prototype.getContactList = function() {\n return this.m_contactList;\n}\n\nWorld.prototype.getBodyCount = function() {\n return this.m_bodyCount;\n}\n\nWorld.prototype.getJointCount = function() {\n return this.m_jointCount;\n}\n\n/**\n * Get the number of contacts (each may have 0 or more contact points).\n */\nWorld.prototype.getContactCount = function() {\n return this.m_contactCount;\n}\n\n/**\n * Change the global gravity vector.\n */\nWorld.prototype.setGravity = function(gravity) {\n this.m_gravity = gravity;\n}\n\n/**\n * Get the global gravity vector.\n */\nWorld.prototype.getGravity = function() {\n return this.m_gravity;\n}\n\n/**\n * Is the world locked (in the middle of a time step).\n */\nWorld.prototype.isLocked = function() {\n return this.m_locked;\n}\n\n/**\n * Enable/disable sleep.\n */\nWorld.prototype.setAllowSleeping = function(flag) {\n if (flag == this.m_allowSleep) {\n return;\n }\n\n this.m_allowSleep = flag;\n if (this.m_allowSleep == false) {\n for (var b = this.m_bodyList; b; b = b.m_next) {\n b.setAwake(true);\n }\n }\n}\n\nWorld.prototype.getAllowSleeping = function() {\n return this.m_allowSleep;\n}\n\n/**\n * Enable/disable warm starting. For testing.\n */\nWorld.prototype.setWarmStarting = function(flag) {\n this.m_warmStarting = flag;\n}\n\nWorld.prototype.getWarmStarting = function() {\n return this.m_warmStarting;\n}\n\n/**\n * Enable/disable continuous physics. For testing.\n */\nWorld.prototype.setContinuousPhysics = function(flag) {\n this.m_continuousPhysics = flag;\n}\n\nWorld.prototype.getContinuousPhysics = function() {\n return this.m_continuousPhysics;\n}\n\n/**\n * Enable/disable single stepped continuous physics. For testing.\n */\nWorld.prototype.setSubStepping = function(flag) {\n this.m_subStepping = flag;\n}\n\nWorld.prototype.getSubStepping = function() {\n return this.m_subStepping;\n}\n\n/**\n * Set flag to control automatic clearing of forces after each time step.\n */\nWorld.prototype.setAutoClearForces = function(flag) {\n this.m_clearForces = flag;\n}\n\n/**\n * Get the flag that controls automatic clearing of forces after each time step.\n */\nWorld.prototype.getAutoClearForces = function() {\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 setAutoClearForces\n */\nWorld.prototype.clearForces = function() {\n for (var body = this.m_bodyList; body; body = body.getNext()) {\n body.m_force.setZero();\n body.m_torque = 0.0;\n }\n}\n\n/**\n * @function World~rayCastCallback\n *\n * @param fixture\n */\n\n/**\n * Query the world for all fixtures that potentially overlap the provided AABB.\n *\n * @param {World~queryCallback} queryCallback Called for each fixture\n * found in the query AABB. It may return `false` to terminate the\n * query.\n *\n * @param aabb The query box.\n */\nWorld.prototype.queryAABB = function(aabb, queryCallback) {\n _ASSERT && common.assert(typeof queryCallback === 'function');\n var broadPhase = this.m_broadPhase;\n this.m_broadPhase.query(aabb, function(proxyId) { //TODO GC\n var proxy = broadPhase.getUserData(proxyId); // FixtureProxy\n return queryCallback(proxy.fixture);\n });\n}\n\n/**\n * @function World~rayCastCallback\n *\n * Callback class for ray casts. See World.rayCast\n *\n * Called for each fixture found in the query. You control how the ray cast\n * proceeds by returning a float: return -1: ignore this fixture and continue\n * return 0: terminate the ray cast return fraction: clip the ray to this point\n * return 1: don't clip the ray and 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\n *\n * @return {float} -1 to filter, 0 to terminate, fraction to clip the ray for\n * closest hit, 1 to continue\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 {World~RayCastCallback} reportFixtureCallback A user implemented\n * callback function.\n * @param point1 The ray starting point\n * @param point2 The ray ending point\n */\nWorld.prototype.rayCast = function(point1, point2, reportFixtureCallback) {\n _ASSERT && common.assert(typeof reportFixtureCallback === 'function');\n var broadPhase = this.m_broadPhase;\n\n this.m_broadPhase.rayCast({\n maxFraction : 1.0,\n p1 : point1,\n p2 : point2\n }, function(input, proxyId) { // TODO GC\n var proxy = broadPhase.getUserData(proxyId); // FixtureProxy\n var fixture = proxy.fixture;\n var index = proxy.childIndex;\n var output = {}; // TODO GC\n var hit = fixture.rayCast(output, input, index);\n if (hit) {\n var fraction = output.fraction;\n var point = Vec2.add(Vec2.mul((1.0 - fraction), input.p1), Vec2.mul(fraction, input.p2));\n return reportFixtureCallback(fixture, point, output.normal, fraction);\n }\n return input.maxFraction;\n });\n}\n\n/**\n * Get the number of broad-phase proxies.\n */\nWorld.prototype.getProxyCount = function() {\n return this.m_broadPhase.getProxyCount();\n}\n\n/**\n * Get the height of broad-phase dynamic tree.\n */\nWorld.prototype.getTreeHeight = function() {\n return this.m_broadPhase.getTreeHeight();\n}\n\n/**\n * Get the balance of broad-phase dynamic tree.\n *\n * @returns {int}\n */\nWorld.prototype.getTreeBalance = function() {\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 * @returns {float}\n */\nWorld.prototype.getTreeQuality = function() {\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 {Vec2} newOrigin The new origin with respect to the old origin\n */\nWorld.prototype.shiftOrigin = function(newOrigin) {\n _ASSERT && common.assert(this.m_locked == false);\n if (this.m_locked) {\n return;\n }\n\n for (var 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 (var j = this.m_jointList; j; j = j.m_next) {\n j.shiftOrigin(newOrigin);\n }\n\n this.m_broadPhase.shiftOrigin(newOrigin);\n}\n\n/**\n * @internal Used for deserialize.\n */\nWorld.prototype._addBody = function(body) {\n _ASSERT && common.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 * @param {BodyDef|Vec2} def Body definition or position.\n * @param {float} angle Body angle if def is position.\n */\nWorld.prototype.createBody = function(def, angle) {\n _ASSERT && common.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return null;\n }\n\n if (def && Vec2.isValid(def)) {\n def = {\n position : def,\n angle : angle\n };\n }\n\n var body = new Body(this, def);\n\n this._addBody(body);\n\n return body;\n}\n\nWorld.prototype.createDynamicBody = function(def, angle) {\n if (!def) {\n def = {};\n } else if (Vec2.isValid(def)) {\n def = { position : def, angle : angle };\n }\n def.type = 'dynamic';\n return this.createBody(def);\n}\n\nWorld.prototype.createKinematicBody = function(def, angle) {\n if (!def) {\n def = {};\n } else if (Vec2.isValid(def)) {\n def = { position : def, angle : angle };\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 * @param {Body} b\n */\nWorld.prototype.destroyBody = function(b) {\n _ASSERT && common.assert(this.m_bodyCount > 0);\n _ASSERT && common.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 var je = b.m_jointList;\n while (je) {\n var 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 var ce = b.m_contactList;\n while (ce) {\n var 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 var f = b.m_fixtureList;\n while (f) {\n var 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 * @param {Joint} join\n * @param {Body} bodyB\n * @param {Body} bodyA\n */\nWorld.prototype.createJoint = function(joint) {\n _ASSERT && common.assert(!!joint.m_bodyA);\n _ASSERT && common.assert(!!joint.m_bodyB);\n _ASSERT && common.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 (var 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 * @param {Joint} join\n */\nWorld.prototype.destroyJoint = function(joint) {\n _ASSERT && common.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 var bodyA = joint.m_bodyA;\n var 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 _ASSERT && common.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 var 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\nvar s_step = new Solver.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 {float} timeStep Time step, this should not vary.\n * @param {int} velocityIterations\n * @param {int} positionIterations\n */\nWorld.prototype.step = function(timeStep, velocityIterations, positionIterations) {\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 s_step.reset(timeStep);\n s_step.velocityIterations = velocityIterations;\n s_step.positionIterations = positionIterations;\n s_step.warmStarting = this.m_warmStarting;\n 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(s_step);\n\n // Synchronize fixtures, check for out of range bodies.\n for (var 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(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 * Call this method to find new contacts.\n */\nWorld.prototype.findNewContacts = function() {\n this.m_broadPhase.updatePairs(this.addPair);\n}\n\n/**\n * @private\n *\n * @param {FixtureProxy} proxyA\n * @param {FixtureProxy} proxyB\n */\nWorld.prototype.createContact = function(proxyA, proxyB) {\n var fixtureA = proxyA.fixture;\n var fixtureB = proxyB.fixture;\n\n var indexA = proxyA.childIndex;\n var indexB = proxyB.childIndex;\n\n var bodyA = fixtureA.getBody();\n var 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 var edge = bodyB.getContactList(); // ContactEdge\n while (edge) {\n if (edge.other == bodyA) {\n var fA = edge.contact.getFixtureA();\n var fB = edge.contact.getFixtureB();\n var iA = edge.contact.getChildIndexA();\n var 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 var 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 * Removes old non-overlapping contacts, applies filters and updates contacts.\n */\nWorld.prototype.updateContacts = function() {\n // Update awake contacts.\n var c, next_c = this.m_contactList;\n while (c = next_c) {\n next_c = c.getNext()\n var fixtureA = c.getFixtureA();\n var fixtureB = c.getFixtureB();\n var indexA = c.getChildIndexA();\n var indexB = c.getChildIndexB();\n var bodyA = fixtureA.getBody();\n var 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 var activeA = bodyA.isAwake() && !bodyA.isStatic();\n var 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 var proxyIdA = fixtureA.m_proxies[indexA].proxyId;\n var proxyIdB = fixtureB.m_proxies[indexB].proxyId;\n var 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/**\n * @param {Contact} contact\n */\nWorld.prototype.destroyContact = function(contact) {\n Contact.destroy(contact, this);\n\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 --this.m_contactCount;\n}\n\nWorld.prototype._listeners = null;\n\n/**\n * Register an event listener.\n *\n * @param {string} name\n * @param {function} listener\n */\nWorld.prototype.on = function(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/**\n * Remove an event listener.\n *\n * @param {string} name\n * @param {function} listener\n */\nWorld.prototype.off = function(name, listener) {\n if (typeof name !== 'string' || typeof listener !== 'function') {\n return this;\n }\n var listeners = this._listeners && this._listeners[name];\n if (!listeners || !listeners.length) {\n return this;\n }\n var index = listeners.indexOf(listener);\n if (index >= 0) {\n listeners.splice(index, 1);\n }\n return this;\n};\n\nWorld.prototype.publish = function(name, arg1, arg2, arg3) {\n var listeners = this._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].call(this, arg1, arg2, arg3);\n }\n return listeners.length;\n};\n\n/**\n * @event World#remove-body\n * @event World#remove-joint\n * @event World#remove-fixture\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 * @private\n * @param {Contact} contact\n */\nWorld.prototype.beginContact = function(contact) {\n this.publish('begin-contact', contact);\n};\n\n/**\n * @event World#begin-contact\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\n/**\n * @private\n * @param {Contact} contact\n */\nWorld.prototype.endContact = function(contact) {\n this.publish('end-contact', contact);\n};\n\n/**\n * @event World#end-contact\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\n/**\n * @private\n * @param {Contact} contact\n * @param {Manifold} oldManifold\n */\nWorld.prototype.preSolve = function(contact, oldManifold) {\n this.publish('pre-solve', contact, oldManifold);\n};\n\n/**\n * @event World#pre-solve\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 endContact callback. However, you may get\n * a beginContact callback the next step.\n *\n * Warning: You cannot create/destroy world entities inside these callbacks.\n */\n\n/**\n * @private\n * @param {Contact} contact\n * @param {ContactImpulse} impulse\n */\nWorld.prototype.postSolve = function(contact, impulse) {\n this.publish('post-solve', contact, impulse);\n};\n\n/**\n * @event World#post-solve\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\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 * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nvar Settings = require('../Settings');\nvar common = require('../util/common');\nvar Math = require('../common/Math');\nvar Vec2 = require('../common/Vec2');\n\nmodule.exports = AABB;\n\nfunction AABB(lower, upper) {\n if (!(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.set(lower);\n }\n if (typeof upper === 'object') {\n this.upperBound.set(upper);\n } else if (typeof lower === 'object') {\n this.upperBound.set(lower);\n }\n};\n\n/**\n * Verify that the bounds are sorted.\n */\nAABB.prototype.isValid = function() {\n return AABB.isValid(this);\n}\n\nAABB.isValid = function(aabb) {\n var d = Vec2.sub(aabb.upperBound, aabb.lowerBound);\n var valid = d.x >= 0.0 && d.y >= 0.0 && Vec2.isValid(aabb.lowerBound) && Vec2.isValid(aabb.upperBound);\n return valid;\n}\n\nAABB.assert = function(o) {\n if (!_ASSERT) return;\n if (!AABB.isValid(o)) {\n _DEBUG && common.debug(o);\n throw new Error('Invalid AABB!');\n }\n}\n\n/**\n * Get the center of the AABB.\n */\nAABB.prototype.getCenter = function() {\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 */\nAABB.prototype.getExtents = function() {\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 */\nAABB.prototype.getPerimeter = function() {\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 */\nAABB.prototype.combine = function(a, b) {\n b = b || this;\n\n var lowerA = a.lowerBound;\n var upperA = a.upperBound;\n var lowerB = b.lowerBound;\n var upperB = b.upperBound;\n\n var lowerX = Math.min(lowerA.x, lowerB.x);\n var lowerY = Math.min(lowerA.y, lowerB.y);\n var upperX = Math.max(upperB.x, upperA.x);\n var upperY = Math.max(upperB.y, upperA.y);\n\n this.lowerBound.set(lowerX, lowerY);\n this.upperBound.set(upperX, upperY);\n}\n\nAABB.prototype.combinePoints = function(a, b) {\n this.lowerBound.set(Math.min(a.x, b.x), Math.min(a.y, b.y));\n this.upperBound.set(Math.max(a.x, b.x), Math.max(a.y, b.y));\n}\n\nAABB.prototype.set = function(aabb) {\n this.lowerBound.set(aabb.lowerBound.x, aabb.lowerBound.y);\n this.upperBound.set(aabb.upperBound.x, aabb.upperBound.y);\n}\n\nAABB.prototype.contains = function(aabb) {\n var 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\nAABB.prototype.extend = function(value) {\n AABB.extend(this, value);\n return this;\n}\n\nAABB.extend = function(aabb, value) {\n aabb.lowerBound.x -= value;\n aabb.lowerBound.y -= value;\n aabb.upperBound.x += value;\n aabb.upperBound.y += value;\n}\n\nAABB.testOverlap = function(a, b) {\n var d1x = b.lowerBound.x - a.upperBound.x;\n var d2x = a.lowerBound.x - b.upperBound.x;\n\n var d1y = b.lowerBound.y - a.upperBound.y;\n var 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\nAABB.areEqual = function(a, b) {\n return Vec2.areEqual(a.lowerBound, b.lowerBound) && Vec2.areEqual(a.upperBound, b.upperBound);\n}\n\nAABB.diff = function(a, b) {\n var wD = Math.max(0, Math.min(a.upperBound.x, b.upperBound.x) - Math.max(b.lowerBound.x, a.lowerBound.x))\n var hD = Math.max(0, Math.min(a.upperBound.y, b.upperBound.y) - Math.max(b.lowerBound.y, a.lowerBound.y));\n\n var wA = a.upperBound.x - a.lowerBound.x;\n var hA = a.upperBound.y - a.lowerBound.y;\n\n var wB = b.upperBound.x - b.lowerBound.x;\n var hB = b.upperBound.y - b.lowerBound.y;\n\n return wA * hA + wB * hB - wD * hD;\n};\n\n/**\n * @typedef RayCastInput\n *\n * Ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).\n *\n * @prop {Vec2} p1\n * @prop {Vec2} p2\n * @prop {number} maxFraction\n */\n\n/**\n * @typedef RayCastInput\n *\n * Ray-cast output data. The ray hits at p1 + fraction * (p2 - p1), where p1 and\n * p2 come from RayCastInput.\n *\n * @prop {Vec2} normal\n * @prop {number} fraction\n */\n\n/**\n * @param {RayCastOutput} output\n * @param {RayCastInput} input\n * @returns {boolean}\n */\nAABB.prototype.rayCast = function(output, input) {\n // From Real-time Collision Detection, p179.\n\n var tmin = -Infinity;\n var tmax = Infinity;\n\n var p = input.p1;\n var d = Vec2.sub(input.p2, input.p1);\n var absD = Vec2.abs(d);\n\n var normal = Vec2.zero();\n\n for (var f = 'x'; f !== null; f = (f === 'x' ? 'y' : null)) {\n if (absD.x < Math.EPSILON) {\n // Parallel.\n if (p[f] < this.lowerBound[f] || this.upperBound[f] < p[f]) {\n return false;\n }\n } else {\n var inv_d = 1.0 / d[f];\n var t1 = (this.lowerBound[f] - p[f]) * inv_d;\n var t2 = (this.upperBound[f] - p[f]) * inv_d;\n\n // Sign of the normal vector.\n var s = -1.0;\n\n if (t1 > t2) {\n var temp = t1;\n t1 = t2, 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\nAABB.prototype.toString = function() {\n return JSON.stringify(this);\n}\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nvar Settings = require('../Settings');\nvar common = require('../util/common');\nvar Math = require('../common/Math');\nvar AABB = require('./AABB');\nvar DynamicTree = require('./DynamicTree');\n\nmodule.exports = BroadPhase;\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 */\nfunction BroadPhase() {\n this.m_tree = new DynamicTree();\n this.m_proxyCount = 0;\n this.m_moveBuffer = [];\n this.queryCallback = this.queryCallback.bind(this);\n};\n\n/**\n * Get user data from a proxy. Returns null if the id is invalid.\n */\nBroadPhase.prototype.getUserData = function(proxyId) {\n return this.m_tree.getUserData(proxyId);\n}\n\n/**\n * Test overlap of fat AABBs.\n */\nBroadPhase.prototype.testOverlap = function(proxyIdA, proxyIdB) {\n var aabbA = this.m_tree.getFatAABB(proxyIdA);\n var aabbB = this.m_tree.getFatAABB(proxyIdB);\n return AABB.testOverlap(aabbA, aabbB);\n}\n\n/**\n * Get the fat AABB for a proxy.\n */\nBroadPhase.prototype.getFatAABB = function(proxyId) {\n return this.m_tree.getFatAABB(proxyId);\n}\n\n/**\n * Get the number of proxies.\n */\nBroadPhase.prototype.getProxyCount = function() {\n return this.m_proxyCount;\n}\n\n/**\n * Get the height of the embedded tree.\n */\nBroadPhase.prototype.getTreeHeight = function() {\n return this.m_tree.getHeight();\n}\n\n/**\n * Get the balance (integer) of the embedded tree.\n */\nBroadPhase.prototype.getTreeBalance = function() {\n return this.m_tree.getMaxBalance();\n}\n\n/**\n * Get the quality metric of the embedded tree.\n */\nBroadPhase.prototype.getTreeQuality = function() {\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 */\nBroadPhase.prototype.query = function(aabb, queryCallback) {\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 +\n * maxFraction * (p2 - p1).\n * @param rayCastCallback A function that is called for each proxy that is hit by\n * the ray.\n */\nBroadPhase.prototype.rayCast = function(input, rayCastCallback) {\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 */\nBroadPhase.prototype.shiftOrigin = function(newOrigin) {\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 */\nBroadPhase.prototype.createProxy = function(aabb, userData) {\n _ASSERT && common.assert(AABB.isValid(aabb));\n var proxyId = this.m_tree.createProxy(aabb, userData);\n this.m_proxyCount++;\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 */\nBroadPhase.prototype.destroyProxy = function(proxyId) {\n this.unbufferMove(proxyId);\n this.m_proxyCount--;\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 */\nBroadPhase.prototype.moveProxy = function(proxyId, aabb, displacement) {\n _ASSERT && common.assert(AABB.isValid(aabb));\n var 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 */\nBroadPhase.prototype.touchProxy = function(proxyId) {\n this.bufferMove(proxyId);\n}\n\nBroadPhase.prototype.bufferMove = function(proxyId) {\n this.m_moveBuffer.push(proxyId);\n}\n\nBroadPhase.prototype.unbufferMove = function(proxyId) {\n for (var 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 * @function BroadPhase~addPair\n * @param {Object} userDataA\n * @param {Object} userDataB\n */\n\n/**\n * Update the pairs. This results in pair callbacks. This can only add pairs.\n * \n * @param {BroadPhase~AddPair} addPairCallback\n */\nBroadPhase.prototype.updatePairs = function(addPairCallback) {\n _ASSERT && common.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 var 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\nBroadPhase.prototype.queryCallback = function(proxyId) {\n // A proxy cannot form a pair with itself.\n if (proxyId == this.m_queryProxyId) {\n return true;\n }\n\n var proxyIdA = Math.min(proxyId, this.m_queryProxyId);\n var proxyIdB = Math.max(proxyId, this.m_queryProxyId);\n\n // TODO: Skip any duplicate pairs.\n\n var userDataA = this.m_tree.getUserData(proxyIdA);\n var 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 * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = Distance;\n\nmodule.exports.Input = DistanceInput;\nmodule.exports.Output = DistanceOutput;\nmodule.exports.Proxy = DistanceProxy;\nmodule.exports.Cache = SimplexCache;\n\nvar Settings = require('../Settings');\nvar common = require('../util/common');\n\nvar stats = require('../common/stats');\n\nvar Math = require('../common/Math');\nvar Vec2 = require('../common/Vec2');\nvar Vec3 = require('../common/Vec3');\nvar Mat22 = require('../common/Mat22');\nvar Mat33 = require('../common/Mat33');\nvar Rot = require('../common/Rot');\nvar Sweep = require('../common/Sweep');\nvar Transform = require('../common/Transform');\nvar Velocity = require('../common/Velocity');\nvar Position = require('../common/Position');\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 */\nfunction DistanceInput() {\n this.proxyA = new DistanceProxy();\n this.proxyB = new DistanceProxy();\n this.transformA = null;\n this.transformB = null;\n this.useRadii = false;\n};\n\n/**\n * Output for Distance.\n *\n * @prop {Vec2} pointA closest point on shapeA\n * @prop {Vec2} pointB closest point on shapeB\n * @prop distance\n * @prop iterations number of GJK iterations used\n */\nfunction DistanceOutput() {\n this.pointA = Vec2.zero();\n this.pointB = Vec2.zero();\n this.distance;\n this.iterations;\n}\n\n/**\n * Used to warm start Distance. Set count to zero on first call.\n *\n * @prop {number} metric length or area\n * @prop {array} indexA vertices on shape A\n * @prop {array} indexB vertices on shape B\n * @prop {number} count\n */\nfunction SimplexCache() {\n this.metric = 0;\n this.indexA = [];\n this.indexB = [];\n this.count = 0;\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 *\n * @param {DistanceOutput} output\n * @param {SimplexCache} cache\n * @param {DistanceInput} input\n */\nfunction Distance(output, cache, input) {\n ++stats.gjkCalls;\n\n var proxyA = input.proxyA;\n var proxyB = input.proxyB;\n var xfA = input.transformA;\n var xfB = input.transformB;\n\n // Initialize the simplex.\n var simplex = new Simplex();\n simplex.readCache(cache, proxyA, xfA, proxyB, xfB);\n\n // Get simplex vertices as an array.\n var vertices = simplex.m_v;// SimplexVertex\n var k_maxIters = Settings.maxDistnceIterations;\n\n // These store the vertices of the last simplex so that we\n // can check for duplicates and prevent cycling.\n var saveA = [];\n var saveB = []; // int[3]\n var saveCount = 0;\n\n var distanceSqr1 = Infinity;\n var distanceSqr2 = Infinity;\n\n // Main iteration loop.\n var iter = 0;\n while (iter < k_maxIters) {\n // Copy simplex so we can identify duplicates.\n saveCount = simplex.m_count;\n for (var 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 // Compute closest point.\n var p = simplex.getClosestPoint();\n distanceSqr2 = p.lengthSquared();\n\n // Ensure progress\n if (distanceSqr2 >= distanceSqr1) {\n // break;\n }\n distanceSqr1 = distanceSqr2;\n\n // Get search direction.\n var d = simplex.getSearchDirection();\n\n // Ensure the search direction is numerically fit.\n if (d.lengthSquared() < Math.EPSILON * Math.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 var vertex = vertices[simplex.m_count]; // SimplexVertex\n\n vertex.indexA = proxyA.getSupport(Rot.mulTVec2(xfA.q, Vec2.neg(d)));\n vertex.wA = Transform.mulVec2(xfA, proxyA.getVertex(vertex.indexA));\n\n vertex.indexB = proxyB.getSupport(Rot.mulTVec2(xfB.q, d));\n vertex.wB = Transform.mulVec2(xfB, proxyB.getVertex(vertex.indexB));\n\n vertex.w = Vec2.sub(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 var duplicate = false;\n for (var 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 = Vec2.distance(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 var rA = proxyA.m_radius;\n var rB = proxyB.m_radius;\n\n if (output.distance > rA + rB && output.distance > Math.EPSILON) {\n // Shapes are still no overlapped.\n // Move the witness points to the outer surface.\n output.distance -= rA + rB;\n var normal = Vec2.sub(output.pointB, output.pointA);\n normal.normalize();\n output.pointA.addMul(rA, normal);\n output.pointB.subMul(rB, normal);\n } else {\n // Shapes are overlapped when radii are considered.\n // Move the witness points to the middle.\n var p = Vec2.mid(output.pointA, output.pointB);\n output.pointA.set(p);\n output.pointB.set(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 */\nfunction DistanceProxy() {\n this.m_buffer = []; // Vec2[2]\n this.m_vertices = []; // Vec2[]\n this.m_count = 0;\n this.m_radius = 0;\n};\n\n/**\n * Get the vertex count.\n */\nDistanceProxy.prototype.getVertexCount = function() {\n return this.m_count;\n}\n\n/**\n * Get a vertex by index. Used by Distance.\n */\nDistanceProxy.prototype.getVertex = function(index) {\n _ASSERT && common.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 */\nDistanceProxy.prototype.getSupport = function(d) {\n var bestIndex = 0;\n var bestValue = Vec2.dot(this.m_vertices[0], d);\n for (var i = 0; i < this.m_count; ++i) {\n var value = Vec2.dot(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 */\nDistanceProxy.prototype.getSupportVertex = function(d) {\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 */\nDistanceProxy.prototype.set = function(shape, index) {\n // TODO remove, use shape instead\n _ASSERT && common.assert(typeof shape.computeDistanceProxy === 'function');\n shape.computeDistanceProxy(this, index);\n}\n\nfunction SimplexVertex() {\n this.indexA; // wA index\n this.indexB; // wB index\n this.wA = Vec2.zero(); // support point in proxyA\n this.wB = Vec2.zero(); // support point in proxyB\n this.w = Vec2.zero(); // wB - wA\n this.a; // barycentric coordinate for closest point\n};\n\nSimplexVertex.prototype.set = function(v) {\n this.indexA = v.indexA;\n this.indexB = v.indexB;\n this.wA = Vec2.clone(v.wA);\n this.wB = Vec2.clone(v.wB);\n this.w = Vec2.clone(v.w);\n this.a = v.a;\n};\n\nfunction Simplex() {\n this.m_v1 = new SimplexVertex();\n this.m_v2 = new SimplexVertex();\n this.m_v3 = new SimplexVertex();\n this.m_v = [ this.m_v1, this.m_v2, this.m_v3 ];\n this.m_count;\n};\n\nSimplex.prototype.print = function() {\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// (SimplexCache, DistanceProxy, ...)\nSimplex.prototype.readCache = function(cache, proxyA, transformA, proxyB, transformB) {\n _ASSERT && common.assert(cache.count <= 3);\n\n // Copy data from cache.\n this.m_count = cache.count;\n for (var i = 0; i < this.m_count; ++i) {\n var v = this.m_v[i];\n v.indexA = cache.indexA[i];\n v.indexB = cache.indexB[i];\n var wALocal = proxyA.getVertex(v.indexA);\n var wBLocal = proxyB.getVertex(v.indexB);\n v.wA = Transform.mulVec2(transformA, wALocal);\n v.wB = Transform.mulVec2(transformB, wBLocal);\n v.w = Vec2.sub(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 var metric1 = cache.metric;\n var metric2 = this.getMetric();\n if (metric2 < 0.5 * metric1 || 2.0 * metric1 < metric2\n || metric2 < Math.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 var v = this.m_v[0];// SimplexVertex\n v.indexA = 0;\n v.indexB = 0;\n var wALocal = proxyA.getVertex(0);\n var wBLocal = proxyB.getVertex(0);\n v.wA = Transform.mulVec2(transformA, wALocal);\n v.wB = Transform.mulVec2(transformB, wBLocal);\n v.w = Vec2.sub(v.wB, v.wA);\n v.a = 1.0;\n this.m_count = 1;\n }\n}\n\n// (SimplexCache)\nSimplex.prototype.writeCache = function(cache) {\n cache.metric = this.getMetric();\n cache.count = this.m_count;\n for (var 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\nSimplex.prototype.getSearchDirection = function() {\n switch (this.m_count) {\n case 1:\n return Vec2.neg(this.m_v1.w);\n\n case 2: {\n var e12 = Vec2.sub(this.m_v2.w, this.m_v1.w);\n var sgn = Vec2.cross(e12, Vec2.neg(this.m_v1.w));\n if (sgn > 0.0) {\n // Origin is left of e12.\n return Vec2.cross(1.0, e12);\n } else {\n // Origin is right of e12.\n return Vec2.cross(e12, 1.0);\n }\n }\n\n default:\n _ASSERT && common.assert(false);\n return Vec2.zero();\n }\n}\n\nSimplex.prototype.getClosestPoint = function() {\n switch (this.m_count) {\n case 0:\n _ASSERT && common.assert(false);\n return Vec2.zero();\n\n case 1:\n return Vec2.clone(this.m_v1.w);\n\n case 2:\n return Vec2.combine(this.m_v1.a, this.m_v1.w, this.m_v2.a, this.m_v2.w);\n\n case 3:\n return Vec2.zero();\n\n default:\n _ASSERT && common.assert(false);\n return Vec2.zero();\n }\n}\n\nSimplex.prototype.getWitnessPoints = function(pA, pB) {\n switch (this.m_count) {\n case 0:\n _ASSERT && common.assert(false);\n break;\n\n case 1:\n pA.set(this.m_v1.wA);\n pB.set(this.m_v1.wB);\n break;\n\n case 2:\n pA.setCombine(this.m_v1.a, this.m_v1.wA, this.m_v2.a, this.m_v2.wA);\n pB.setCombine(this.m_v1.a, this.m_v1.wB, this.m_v2.a, this.m_v2.wB);\n break;\n\n case 3:\n pA.setCombine(this.m_v1.a, this.m_v1.wA, this.m_v2.a, this.m_v2.wA);\n pA.addMul(this.m_v3.a, this.m_v3.wA);\n pB.set(pA);\n break;\n\n default:\n _ASSERT && common.assert(false);\n break;\n }\n}\n\nSimplex.prototype.getMetric = function() {\n switch (this.m_count) {\n case 0:\n _ASSERT && common.assert(false);\n return 0.0;\n\n case 1:\n return 0.0;\n\n case 2:\n return Vec2.distance(this.m_v1.w, this.m_v2.w);\n\n case 3:\n return Vec2.cross(Vec2.sub(this.m_v2.w, this.m_v1.w), Vec2.sub(this.m_v3.w,\n this.m_v1.w));\n\n default:\n _ASSERT && common.assert(false);\n return 0.0;\n }\n}\n\nSimplex.prototype.solve = function() {\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 _ASSERT && common.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\nSimplex.prototype.solve2 = function() {\n var w1 = this.m_v1.w;\n var w2 = this.m_v2.w;\n var e12 = Vec2.sub(w2, w1);\n\n // w1 region\n var d12_2 = -Vec2.dot(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 var d12_1 = Vec2.dot(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 var 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\nSimplex.prototype.solve3 = function() {\n var w1 = this.m_v1.w;\n var w2 = this.m_v2.w;\n var w3 = this.m_v3.w;\n\n // Edge12\n // [1 1 ][a1] = [1]\n // [w1.e12 w2.e12][a2] = [0]\n // a3 = 0\n var e12 = Vec2.sub(w2, w1);\n var w1e12 = Vec2.dot(w1, e12);\n var w2e12 = Vec2.dot(w2, e12);\n var d12_1 = w2e12;\n var d12_2 = -w1e12;\n\n // Edge13\n // [1 1 ][a1] = [1]\n // [w1.e13 w3.e13][a3] = [0]\n // a2 = 0\n var e13 = Vec2.sub(w3, w1);\n var w1e13 = Vec2.dot(w1, e13);\n var w3e13 = Vec2.dot(w3, e13);\n var d13_1 = w3e13;\n var d13_2 = -w1e13;\n\n // Edge23\n // [1 1 ][a2] = [1]\n // [w2.e23 w3.e23][a3] = [0]\n // a1 = 0\n var e23 = Vec2.sub(w3, w2);// Vec2\n var w2e23 = Vec2.dot(w2, e23);\n var w3e23 = Vec2.dot(w3, e23);\n var d23_1 = w3e23;\n var d23_2 = -w2e23;\n\n // Triangle123\n var n123 = Vec2.cross(e12, e13);\n\n var d123_1 = n123 * Vec2.cross(w2, w3);\n var d123_2 = n123 * Vec2.cross(w3, w1);\n var d123_3 = n123 * Vec2.cross(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 var 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 var 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 var 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 var 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 * Determine if two generic shapes overlap.\n */\nDistance.testOverlap = function(shapeA, indexA, shapeB, indexB, xfA, xfB) {\n var input = new DistanceInput();\n input.proxyA.set(shapeA, indexA);\n input.proxyB.set(shapeB, indexB);\n input.transformA = xfA;\n input.transformB = xfB;\n input.useRadii = true;\n\n var cache = new SimplexCache();\n\n var output = new DistanceOutput();\n Distance(output, cache, input);\n\n return output.distance < 10.0 * Math.EPSILON;\n}\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nvar Settings = require('../Settings');\nvar common = require('../util/common');\nvar Pool = require('../util/Pool');\nvar Vec2 = require('../common/Vec2');\nvar Math = require('../common/Math');\nvar AABB = require('./AABB');\n\nmodule.exports = DynamicTree;\n\n/**\n * A node in the dynamic tree. The client does not interact with this directly.\n * \n * @prop {AABB} aabb Enlarged AABB\n * @prop {integer} height 0: leaf, -1: free node\n */\nfunction TreeNode(id) {\n this.id = id;\n this.aabb = new AABB();\n this.userData = null;\n this.parent = null;\n this.child1 = null;\n this.child2 = null;\n this.height = -1;\n\n this.toString = function() {\n return this.id + \": \" + this.userData;\n }\n};\n\nTreeNode.prototype.isLeaf = function() {\n return this.child1 == null;\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 */\nfunction DynamicTree() {\n this.m_root = null;\n this.m_nodes = {}\n this.m_lastProxyId = 0;\n\n this.m_pool = new Pool({\n create : function() {\n return new TreeNode();\n }\n });\n};\n\n/**\n * Get proxy user data.\n * \n * @return the proxy user data or 0 if the id is invalid.\n */\nDynamicTree.prototype.getUserData = function(id) {\n var node = this.m_nodes[id];\n _ASSERT && common.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 */\nDynamicTree.prototype.getFatAABB = function(id) {\n var node = this.m_nodes[id];\n _ASSERT && common.assert(!!node);\n return node.aabb;\n}\n\nDynamicTree.prototype.allocateNode = function() {\n var node = this.m_pool.allocate();\n node.id = ++this.m_lastProxyId;\n node.userData = null;\n node.parent = null;\n node.child1 = null;\n node.child2 = null;\n node.height = -1;\n this.m_nodes[node.id] = node;\n return node;\n}\n\nDynamicTree.prototype.freeNode = function(node) {\n this.m_pool.release(node);\n node.height = -1;\n delete this.m_nodes[node.id];\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 */\nDynamicTree.prototype.createProxy = function(aabb, userData) {\n _ASSERT && common.assert(AABB.isValid(aabb))\n\n var 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 */\nDynamicTree.prototype.destroyProxy = function(id) {\n var node = this.m_nodes[id];\n\n _ASSERT && common.assert(!!node);\n _ASSERT && common.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 id\n * @param aabb\n * @param {Vec2} d Displacement\n * \n * @return true if the proxy was re-inserted.\n */\nDynamicTree.prototype.moveProxy = function(id, aabb, d) {\n _ASSERT && common.assert(AABB.isValid(aabb));\n _ASSERT && common.assert(!d || Vec2.isValid(d));\n\n var node = this.m_nodes[id];\n\n _ASSERT && common.assert(!!node);\n _ASSERT && common.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 // var 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\nDynamicTree.prototype.insertLeaf = function(leaf) {\n _ASSERT && common.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 var leafAABB = leaf.aabb;\n var index = this.m_root;\n while (index.isLeaf() == false) {\n var child1 = index.child1;\n var child2 = index.child2;\n\n var area = index.aabb.getPerimeter();\n\n var combinedAABB = new AABB();\n combinedAABB.combine(index.aabb, leafAABB);\n var combinedArea = combinedAABB.getPerimeter();\n\n // Cost of creating a new parent for this node and the new leaf\n var cost = 2.0 * combinedArea;\n\n // Minimum cost of pushing the leaf further down the tree\n var inheritanceCost = 2.0 * (combinedArea - area);\n\n // Cost of descending into child1\n var cost1;\n if (child1.isLeaf()) {\n var aabb = new AABB();\n aabb.combine(leafAABB, child1.aabb);\n cost1 = aabb.getPerimeter() + inheritanceCost;\n } else {\n var aabb = new AABB();\n aabb.combine(leafAABB, child1.aabb);\n var oldArea = child1.aabb.getPerimeter();\n var newArea = aabb.getPerimeter();\n cost1 = (newArea - oldArea) + inheritanceCost;\n }\n\n // Cost of descending into child2\n var cost2;\n if (child2.isLeaf()) {\n var aabb = new AABB();\n aabb.combine(leafAABB, child2.aabb);\n cost2 = aabb.getPerimeter() + inheritanceCost;\n } else {\n var aabb = new AABB();\n aabb.combine(leafAABB, child2.aabb);\n var oldArea = child2.aabb.getPerimeter();\n var newArea = aabb.getPerimeter();\n cost2 = newArea - oldArea + inheritanceCost;\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 var sibling = index;\n\n // Create a new parent.\n var oldParent = sibling.parent;\n var 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 var child1 = index.child1;\n var child2 = index.child2;\n\n _ASSERT && common.assert(child1 != null);\n _ASSERT && common.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\nDynamicTree.prototype.removeLeaf = function(leaf) {\n if (leaf == this.m_root) {\n this.m_root = null;\n return;\n }\n\n var parent = leaf.parent;\n var grandParent = parent.parent;\n var 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 var index = grandParent;\n while (index != null) {\n index = this.balance(index);\n\n var child1 = index.child1;\n var 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 */\nDynamicTree.prototype.balance = function(iA) {\n _ASSERT && common.assert(iA != null);\n\n var A = iA;\n if (A.isLeaf() || A.height < 2) {\n return iA;\n }\n\n var B = A.child1;\n var C = A.child2;\n\n var balance = C.height - B.height;\n\n // Rotate C up\n if (balance > 1) {\n var F = C.child1;\n var 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 var D = B.child1;\n var 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 */\nDynamicTree.prototype.getHeight = function() {\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 */\nDynamicTree.prototype.getAreaRatio = function() {\n if (this.m_root == null) {\n return 0.0;\n }\n\n var root = this.m_root;\n var rootArea = root.aabb.getPerimeter();\n\n var totalArea = 0.0;\n var node, it = 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 iteratorPool.release(it);\n\n return totalArea / rootArea;\n}\n\n/**\n * Compute the height of a sub-tree.\n */\nDynamicTree.prototype.computeHeight = function(id) {\n var node;\n if (typeof id !== 'undefined') {\n node = this.m_nodes[id];\n } else {\n node = this.m_root;\n }\n\n // _ASSERT && common.assert(0 <= id && id < this.m_nodeCapacity);\n\n if (node.isLeaf()) {\n return 0;\n }\n\n var height1 = this.computeHeight(node.child1.id);\n var height2 = this.computeHeight(node.child2.id);\n return 1 + Math.max(height1, height2);\n}\n\nDynamicTree.prototype.validateStructure = function(node) {\n if (node == null) {\n return;\n }\n\n if (node == this.m_root) {\n _ASSERT && common.assert(node.parent == null);\n }\n\n var child1 = node.child1;\n var child2 = node.child2;\n\n if (node.isLeaf()) {\n _ASSERT && common.assert(child1 == null);\n _ASSERT && common.assert(child2 == null);\n _ASSERT && common.assert(node.height == 0);\n return;\n }\n\n // _ASSERT && common.assert(0 <= child1 && child1 < this.m_nodeCapacity);\n // _ASSERT && common.assert(0 <= child2 && child2 < this.m_nodeCapacity);\n\n _ASSERT && common.assert(child1.parent == node);\n _ASSERT && common.assert(child2.parent == node);\n\n this.validateStructure(child1);\n this.validateStructure(child2);\n}\n\nDynamicTree.prototype.validateMetrics = function(node) {\n if (node == null) {\n return;\n }\n\n var child1 = node.child1;\n var child2 = node.child2;\n\n if (node.isLeaf()) {\n _ASSERT && common.assert(child1 == null);\n _ASSERT && common.assert(child2 == null);\n _ASSERT && common.assert(node.height == 0);\n return;\n }\n\n // _ASSERT && common.assert(0 <= child1 && child1 < this.m_nodeCapacity);\n // _ASSERT && common.assert(0 <= child2 && child2 < this.m_nodeCapacity);\n\n var height1 = child1.height;\n var height2 = child2.height;\n var height = 1 + Math.max(height1, height2);\n _ASSERT && common.assert(node.height == height);\n\n var aabb = new AABB();\n aabb.combine(child1.aabb, child2.aabb);\n\n _ASSERT && common.assert(AABB.areEqual(aabb, node.aabb));\n\n this.validateMetrics(child1);\n this.validateMetrics(child2);\n}\n\n// Validate this tree. For testing.\nDynamicTree.prototype.validate = function() {\n this.validateStructure(this.m_root);\n this.validateMetrics(this.m_root);\n\n _ASSERT && common.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 */\nDynamicTree.prototype.getMaxBalance = function() {\n var maxBalance = 0;\n var node, it = iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n if (node.height <= 1) {\n continue;\n }\n\n _ASSERT && common.assert(node.isLeaf() == false);\n\n var balance = Math.abs(node.child2.height - node.child1.height);\n maxBalance = Math.max(maxBalance, balance);\n }\n iteratorPool.release(it);\n\n return maxBalance;\n}\n\n/**\n * Build an optimal tree. Very expensive. For testing.\n */\nDynamicTree.prototype.rebuildBottomUp = function() {\n var nodes = [];\n var count = 0;\n\n // Build array of leaves. Free the rest.\n var node, it = 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 iteratorPool.release(it);\n\n while (count > 1) {\n var minCost = Infinity;\n var iMin = -1, jMin = -1;\n for (var i = 0; i < count; ++i) {\n var aabbi = nodes[i].aabb;\n for (var j = i + 1; j < count; ++j) {\n var aabbj = nodes[j].aabb;\n var b = new AABB();\n b.combine(aabbi, aabbj);\n var cost = b.getPerimeter();\n if (cost < minCost) {\n iMin = i;\n jMin = j;\n minCost = cost;\n }\n }\n }\n\n var child1 = nodes[iMin];\n var child2 = nodes[jMin];\n\n var 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 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 */\nDynamicTree.prototype.shiftOrigin = function(newOrigin) {\n // Build array of leaves. Free the rest.\n var node, it = iteratorPool.allocate().preorder(this.m_root);\n while (node = it.next()) {\n var 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 iteratorPool.release(it);\n}\n\n/**\n * @function {DynamicTree~queryCallback}\n * \n * @param id Node id.\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 * @param {DynamicTree~queryCallback} queryCallback\n */\nDynamicTree.prototype.query = function(aabb, queryCallback) {\n _ASSERT && common.assert(typeof queryCallback === 'function')\n var stack = stackPool.allocate();\n\n stack.push(this.m_root);\n while (stack.length > 0) {\n var node = stack.pop();\n if (node == null) {\n continue;\n }\n\n if (AABB.testOverlap(node.aabb, aabb)) {\n if (node.isLeaf()) {\n var 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 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 +\n * maxFraction * (p2 - p1).\n * @param rayCastCallback A function that is called for each proxy that is hit by\n * the ray.\n */\nDynamicTree.prototype.rayCast = function(input, rayCastCallback) { // TODO GC\n _ASSERT && common.assert(typeof rayCastCallback === 'function')\n var p1 = input.p1;\n var p2 = input.p2;\n var r = Vec2.sub(p2, p1);\n _ASSERT && common.assert(r.lengthSquared() > 0.0);\n r.normalize();\n\n // v is perpendicular to the segment.\n var v = Vec2.cross(1.0, r);\n var abs_v = Vec2.abs(v);\n\n // Separating axis for segment (Gino, p80).\n // |dot(v, p1 - c)| > dot(|v|, h)\n\n var maxFraction = input.maxFraction;\n\n // Build a bounding box for the segment.\n var segmentAABB = new AABB();\n var t = Vec2.combine((1 - maxFraction), p1, maxFraction, p2);\n segmentAABB.combinePoints(p1, t);\n\n var stack = stackPool.allocate();\n var subInput = inputPool.allocate();\n\n stack.push(this.m_root);\n while (stack.length > 0) {\n var 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 var c = node.aabb.getCenter();\n var h = node.aabb.getExtents();\n var separation = Math.abs(Vec2.dot(v, Vec2.sub(p1, c)))\n - 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 var value = rayCastCallback(subInput, node.id);\n\n if (value == 0.0) {\n // The client has terminated the ray cast.\n return;\n }\n\n 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\n stackPool.release(stack);\n inputPool.release(subInput);\n}\n\nvar inputPool = new Pool({\n create : function() {\n return {};\n },\n release : function(stack) {\n }\n});\n\nvar stackPool = new Pool({\n create : function() {\n return [];\n },\n release : function(stack) {\n stack.length = 0;\n }\n});\n\nvar iteratorPool = new Pool({\n create : function() {\n return new Iterator();\n },\n release : function(iterator) {\n iterator.close();\n }\n});\n\nfunction Iterator() {\n var parents = [];\n var states = [];\n return {\n preorder : function(root) {\n parents.length = 0;\n parents.push(root);\n states.length = 0;\n states.push(0);\n return this;\n },\n next : function() {\n while (parents.length > 0) {\n var i = parents.length - 1;\n var node = parents[i];\n if (states[i] === 0) {\n states[i] = 1;\n return node;\n }\n if (states[i] === 1) {\n states[i] = 2;\n if (node.child1) {\n parents.push(node.child1);\n states.push(1);\n return node.child1;\n }\n }\n if (states[i] === 2) {\n states[i] = 3;\n if (node.child2) {\n parents.push(node.child2);\n states.push(1);\n return node.child2;\n }\n }\n parents.pop();\n states.pop();\n }\n },\n close : function() {\n parents.length = 0;\n }\n };\n}\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = TimeOfImpact;\nmodule.exports.Input = TOIInput;\nmodule.exports.Output = TOIOutput;\n\nvar Settings = require('../Settings');\n\nvar common = require('../util/common');\nvar Timer = require('../util/Timer');\n\nvar stats = require('../common/stats');\n\nvar Math = require('../common/Math');\nvar Vec2 = require('../common/Vec2');\nvar Vec3 = require('../common/Vec3');\nvar Mat22 = require('../common/Mat22');\nvar Mat33 = require('../common/Mat33');\nvar Rot = require('../common/Rot');\nvar Sweep = require('../common/Sweep');\nvar Transform = require('../common/Transform');\nvar Velocity = require('../common/Velocity');\nvar Position = require('../common/Position');\n\nvar Distance = require('./Distance');\nvar DistanceInput = Distance.Input;\nvar DistanceOutput = Distance.Output;\nvar DistanceProxy = Distance.Proxy;\nvar SimplexCache = Distance.Cache;\n\n/**\n * Input parameters for TimeOfImpact.\n * \n * @prop {DistanceProxy} proxyA\n * @prop {DistanceProxy} proxyB\n * @prop {Sweep} sweepA\n * @prop {Sweep} sweepB\n * @prop tMax defines sweep interval [0, tMax]\n */\nfunction TOIInput() {\n this.proxyA = new DistanceProxy();\n this.proxyB = new DistanceProxy();\n this.sweepA = new Sweep();\n this.sweepB = new Sweep();\n this.tMax;\n};\n\n// TOIOutput State\nTOIOutput.e_unknown = 0;\nTOIOutput.e_failed = 1;\nTOIOutput.e_overlapped = 2;\nTOIOutput.e_touching = 3;\nTOIOutput.e_separated = 4;\n\n/**\n * Output parameters for TimeOfImpact.\n * \n * @prop state\n * @prop t\n */\nfunction TOIOutput() {\n this.state;\n this.t;\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/**\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 collision. 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 */\nfunction TimeOfImpact(output, input) {\n var timer = Timer.now();\n\n ++stats.toiCalls;\n\n output.state = TOIOutput.e_unknown;\n output.t = input.tMax;\n\n var proxyA = input.proxyA; // DistanceProxy\n var proxyB = input.proxyB; // DistanceProxy\n\n var sweepA = input.sweepA; // Sweep\n var 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 var tMax = input.tMax;\n\n var totalRadius = proxyA.m_radius + proxyB.m_radius;\n var target = Math.max(Settings.linearSlop, totalRadius - 3.0 * Settings.linearSlop);\n var tolerance = 0.25 * Settings.linearSlop;\n _ASSERT && common.assert(target > tolerance);\n\n var t1 = 0.0;\n var k_maxIterations = Settings.maxTOIIterations;\n var iter = 0;\n\n // Prepare input for distance query.\n var cache = new SimplexCache();\n\n var distanceInput = new DistanceInput();\n distanceInput.proxyA = input.proxyA;\n distanceInput.proxyB = input.proxyB;\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 for (;;) {\n var xfA = Transform.identity();\n var xfB = Transform.identity();\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 distanceInput.transformA = xfA;\n distanceInput.transformB = xfB;\n var distanceOutput = new DistanceOutput();\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 = TOIOutput.e_overlapped;\n output.t = 0.0;\n break;\n }\n\n if (distanceOutput.distance < target + tolerance) {\n // Victory!\n output.state = TOIOutput.e_touching;\n output.t = t1;\n break;\n }\n\n // Initialize the separating axis.\n var fcn = new SeparationFunction();\n fcn.initialize(cache, proxyA, sweepA, proxyB, sweepB, t1);\n\n // if (false) {\n // // Dump the curve seen by the root finder\n // var N = 100;\n // var dx = 1.0 / N;\n // var xs = []; // [ N + 1 ];\n // var fs = []; // [ N + 1 ];\n // var x = 0.0;\n // for (var i = 0; i <= N; ++i) {\n // sweepA.getTransform(xfA, x);\n // sweepB.getTransform(xfB, x);\n // var 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 var done = false;\n var t2 = tMax;\n var pushBackIter = 0;\n for (;;) {\n // Find the deepest point at t2. Store the witness point indices.\n var s2 = fcn.findMinSeparation(t2);\n var indexA = fcn.indexA;\n var indexB = fcn.indexB;\n\n // Is the final configuration separated?\n if (s2 > target + tolerance) {\n // Victory!\n output.state = TOIOutput.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 var s1 = fcn.evaluate(t1);\n var indexA = fcn.indexA;\n var indexB = fcn.indexB;\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 = TOIOutput.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 = TOIOutput.e_touching;\n output.t = t1;\n done = true;\n break;\n }\n\n // Compute 1D root of: f(x) - target = 0\n var rootIterCount = 0;\n var a1 = t1, a2 = t2;\n for (;;) {\n // Use a mix of the secant rule and bisection.\n var 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 var s = fcn.evaluate(t);\n var indexA = fcn.indexA;\n var indexB = fcn.indexB;\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 = TOIOutput.e_failed;\n output.t = t1;\n break;\n }\n }\n\n stats.toiMaxIters = Math.max(stats.toiMaxIters, iter);\n\n var time = Timer.diff(timer);\n stats.toiMaxTime = Math.max(stats.toiMaxTime, time);\n stats.toiTime += time;\n}\n\n// SeparationFunction Type\nvar e_points = 1;\nvar e_faceA = 2;\nvar e_faceB = 3;\n\nfunction SeparationFunction() {\n this.m_proxyA = new DistanceProxy();\n this.m_proxyB = new DistanceProxy();\n this.m_sweepA;// Sweep\n this.m_sweepB;// Sweep\n this.indexA;// integer\n this.indexB;// integer\n this.m_type;\n this.m_localPoint = Vec2.zero();\n this.m_axis = Vec2.zero();\n};\n\n// TODO_ERIN might not need to return the separation\n\n/**\n * @param {SimplexCache} cache\n * @param {DistanceProxy} proxyA\n * @param {Sweep} sweepA\n * @param {DistanceProxy} proxyB\n * @param {Sweep} sweepB\n * @param {float} t1\n */\nSeparationFunction.prototype.initialize = function(cache, proxyA, sweepA, proxyB, sweepB, t1) {\n this.m_proxyA = proxyA;\n this.m_proxyB = proxyB;\n var count = cache.count;\n _ASSERT && common.assert(0 < count && count < 3);\n\n this.m_sweepA = sweepA;\n this.m_sweepB = sweepB;\n\n var xfA = Transform.identity();\n var xfB = Transform.identity();\n this.m_sweepA.getTransform(xfA, t1);\n this.m_sweepB.getTransform(xfB, t1);\n\n if (count == 1) {\n this.m_type = e_points;\n var localPointA = this.m_proxyA.getVertex(cache.indexA[0]);\n var localPointB = this.m_proxyB.getVertex(cache.indexB[0]);\n var pointA = Transform.mulVec2(xfA, localPointA);\n var pointB = Transform.mulVec2(xfB, localPointB);\n this.m_axis.setCombine(1, pointB, -1, pointA);\n var s = this.m_axis.normalize();\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 = e_faceB;\n var localPointB1 = proxyB.getVertex(cache.indexB[0]);\n var localPointB2 = proxyB.getVertex(cache.indexB[1]);\n\n this.m_axis = Vec2.cross(Vec2.sub(localPointB2, localPointB1), 1.0);\n this.m_axis.normalize();\n var normal = Rot.mulVec2(xfB.q, this.m_axis);\n\n this.m_localPoint = Vec2.mid(localPointB1, localPointB2);\n var pointB = Transform.mulVec2(xfB, this.m_localPoint);\n\n var localPointA = proxyA.getVertex(cache.indexA[0]);\n var pointA = Transform.mulVec2(xfA, localPointA);\n\n var s = Vec2.dot(pointA, normal) - Vec2.dot(pointB, normal);\n if (s < 0.0) {\n this.m_axis = Vec2.neg(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 = e_faceA;\n var localPointA1 = this.m_proxyA.getVertex(cache.indexA[0]);\n var localPointA2 = this.m_proxyA.getVertex(cache.indexA[1]);\n\n this.m_axis = Vec2.cross(Vec2.sub(localPointA2, localPointA1), 1.0);\n this.m_axis.normalize();\n var normal = Rot.mulVec2(xfA.q, this.m_axis);\n\n this.m_localPoint = Vec2.mid(localPointA1, localPointA2);\n var pointA = Transform.mulVec2(xfA, this.m_localPoint);\n\n var localPointB = this.m_proxyB.getVertex(cache.indexB[0]);\n var pointB = Transform.mulVec2(xfB, localPointB);\n\n var s = Vec2.dot(pointB, normal) - Vec2.dot(pointA, normal);\n if (s < 0.0) {\n this.m_axis = Vec2.neg(this.m_axis);\n s = -s;\n }\n return s;\n }\n};\n\nSeparationFunction.prototype.compute = function(find, t) {\n // It was findMinSeparation and evaluate\n var xfA = Transform.identity();\n var xfB = Transform.identity();\n this.m_sweepA.getTransform(xfA, t);\n this.m_sweepB.getTransform(xfB, t);\n\n switch (this.m_type) {\n case e_points: {\n if (find) {\n var axisA = Rot.mulTVec2(xfA.q, this.m_axis);\n var axisB = Rot.mulTVec2(xfB.q, Vec2.neg(this.m_axis));\n\n this.indexA = this.m_proxyA.getSupport(axisA);\n this.indexB = this.m_proxyB.getSupport(axisB);\n }\n\n var localPointA = this.m_proxyA.getVertex(this.indexA);\n var localPointB = this.m_proxyB.getVertex(this.indexB);\n\n var pointA = Transform.mulVec2(xfA, localPointA);\n var pointB = Transform.mulVec2(xfB, localPointB);\n\n var sep = Vec2.dot(pointB, this.m_axis) - Vec2.dot(pointA, this.m_axis);\n return sep;\n }\n\n case e_faceA: {\n var normal = Rot.mulVec2(xfA.q, this.m_axis);\n var pointA = Transform.mulVec2(xfA, this.m_localPoint);\n\n if (find) {\n var axisB = Rot.mulTVec2(xfB.q, Vec2.neg(normal));\n\n this.indexA = -1;\n this.indexB = this.m_proxyB.getSupport(axisB);\n }\n\n var localPointB = this.m_proxyB.getVertex(this.indexB);\n var pointB = Transform.mulVec2(xfB, localPointB);\n\n var sep = Vec2.dot(pointB, normal) - Vec2.dot(pointA, normal);\n return sep;\n }\n\n case e_faceB: {\n var normal = Rot.mulVec2(xfB.q, this.m_axis);\n var pointB = Transform.mulVec2(xfB, this.m_localPoint);\n\n if (find) {\n var axisA = Rot.mulTVec2(xfA.q, Vec2.neg(normal));\n\n this.indexB = -1;\n this.indexA = this.m_proxyA.getSupport(axisA);\n }\n\n var localPointA = this.m_proxyA.getVertex(this.indexA);\n var pointA = Transform.mulVec2(xfA, localPointA);\n\n var sep = Vec2.dot(pointA, normal) - Vec2.dot(pointB, normal);\n return sep;\n }\n\n default:\n _ASSERT && common.assert(false);\n if (find) {\n this.indexA = -1;\n this.indexB = -1;\n }\n return 0.0;\n }\n};\n\nSeparationFunction.prototype.findMinSeparation = function(t) {\n return this.compute(true, t);\n};\n\nSeparationFunction.prototype.evaluate = function(t) {\n return this.compute(false, t);\n};\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = Mat22;\n\nvar common = require('../util/common');\nvar Math = require('./Math');\nvar Vec2 = require('./Vec2');\n\n/**\n * A 2-by-2 matrix. Stored in column-major order.\n */\nfunction Mat22(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\nMat22.prototype.toString = function() {\n return JSON.stringify(this);\n};\n\nMat22.isValid = function(o) {\n return o && Vec2.isValid(o.ex) && Vec2.isValid(o.ey);\n};\n\nMat22.assert = function(o) {\n if (!_ASSERT) return;\n if (!Mat22.isValid(o)) {\n _DEBUG && common.debug(o);\n throw new Error('Invalid Mat22!');\n }\n};\n\nMat22.prototype.set = function(a, b, c, d) {\n if (typeof a === 'number' && typeof b === 'number' && typeof c === 'number'\n && typeof d === 'number') {\n this.ex.set(a, c);\n this.ey.set(b, d);\n\n } else if (typeof a === 'object' && typeof b === 'object') {\n this.ex.set(a);\n this.ey.set(b);\n\n } else if (typeof a === 'object') {\n _ASSERT && Mat22.assert(a);\n this.ex.set(a.ex);\n this.ey.set(a.ey);\n\n } else {\n _ASSERT && common.assert(false);\n }\n}\n\nMat22.prototype.setIdentity = function() {\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\nMat22.prototype.setZero = function() {\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\nMat22.prototype.getInverse = function() {\n var a = this.ex.x;\n var b = this.ey.x;\n var c = this.ex.y;\n var d = this.ey.y;\n var det = a * d - b * c;\n if (det != 0.0) {\n det = 1.0 / det;\n }\n var 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 */\nMat22.prototype.solve = function(v) {\n _ASSERT && Vec2.assert(v);\n var a = this.ex.x;\n var b = this.ey.x;\n var c = this.ex.y;\n var d = this.ey.y;\n var det = a * d - b * c;\n if (det != 0.0) {\n det = 1.0 / det;\n }\n var 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 */\nMat22.mul = function(mx, v) {\n if (v && 'x' in v && 'y' in v) {\n _ASSERT && Vec2.assert(v);\n var x = mx.ex.x * v.x + mx.ey.x * v.y;\n var 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 _ASSERT && Mat22.assert(v);\n // return new Mat22(Vec2.mul(mx, v.ex), Vec2.mul(mx, v.ey));\n var a = mx.ex.x * v.ex.x + mx.ey.x * v.ex.y;\n var b = mx.ex.x * v.ey.x + mx.ey.x * v.ey.y;\n var c = mx.ex.y * v.ex.x + mx.ey.y * v.ex.y;\n var d = mx.ex.y * v.ey.x + mx.ey.y * v.ey.y;\n return new Mat22(a, b, c, d);\n }\n\n _ASSERT && common.assert(false);\n}\n\nMat22.mulVec2 = function(mx, v) {\n _ASSERT && Vec2.assert(v);\n var x = mx.ex.x * v.x + mx.ey.x * v.y;\n var y = mx.ex.y * v.x + mx.ey.y * v.y;\n return Vec2.neo(x, y);\n}\n\nMat22.mulMat22 = function(mx, v) {\n _ASSERT && Mat22.assert(v);\n // return new Mat22(Vec2.mul(mx, v.ex), Vec2.mul(mx, v.ey));\n var a = mx.ex.x * v.ex.x + mx.ey.x * v.ex.y;\n var b = mx.ex.x * v.ey.x + mx.ey.x * v.ey.y;\n var c = mx.ex.y * v.ex.x + mx.ey.y * v.ex.y;\n var d = mx.ex.y * v.ey.x + mx.ey.y * v.ey.y;\n return new Mat22(a, b, c, d);\n _ASSERT && common.assert(false);\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 */\nMat22.mulT = function(mx, v) {\n if (v && 'x' in v && 'y' in v) { // Vec2\n _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 _ASSERT && Mat22.assert(v);\n var c1 = Vec2.neo(Vec2.dot(mx.ex, v.ex), Vec2.dot(mx.ey, v.ex));\n var c2 = Vec2.neo(Vec2.dot(mx.ex, v.ey), Vec2.dot(mx.ey, v.ey));\n return new Mat22(c1, c2);\n }\n\n _ASSERT && common.assert(false);\n}\n\nMat22.mulTVec2 = function(mx, v) {\n _ASSERT && Mat22.assert(mx);\n _ASSERT && Vec2.assert(v);\n return Vec2.neo(Vec2.dot(v, mx.ex), Vec2.dot(v, mx.ey));\n}\n\nMat22.mulTMat22 = function(mx, v) {\n _ASSERT && Mat22.assert(mx);\n _ASSERT && Mat22.assert(v);\n var c1 = Vec2.neo(Vec2.dot(mx.ex, v.ex), Vec2.dot(mx.ey, v.ex));\n var c2 = Vec2.neo(Vec2.dot(mx.ex, v.ey), Vec2.dot(mx.ey, v.ey));\n return new Mat22(c1, c2);\n}\n\nMat22.abs = function(mx) {\n _ASSERT && Mat22.assert(mx);\n return new Mat22(Vec2.abs(mx.ex), Vec2.abs(mx.ey));\n}\n\nMat22.add = function(mx1, mx2) {\n _ASSERT && Mat22.assert(mx1);\n _ASSERT && Mat22.assert(mx2);\n return new Mat22(Vec2.add(mx1.ex, mx2.ex), Vec2.add(mx1.ey, mx2.ey));\n}\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = Mat33;\n\nvar common = require('../util/common');\nvar Math = require('./Math');\nvar Vec2 = require('./Vec2');\nvar Vec3 = require('./Vec3');\n\n/**\n * A 3-by-3 matrix. Stored in column-major order.\n */\nfunction Mat33(a, b, c) {\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();\n this.ey = Vec3();\n this.ez = Vec3();\n }\n};\n\nMat33.prototype.toString = function() {\n return JSON.stringify(this);\n};\n\nMat33.isValid = function(o) {\n return o && Vec3.isValid(o.ex) && Vec3.isValid(o.ey) && Vec3.isValid(o.ez);\n};\n\nMat33.assert = function(o) {\n if (!_ASSERT) return;\n if (!Mat33.isValid(o)) {\n _DEBUG && common.debug(o);\n throw new Error('Invalid Mat33!');\n }\n};\n\n/**\n * Set this matrix to all zeros.\n */\nMat33.prototype.setZero = function() {\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 * @param {Vec3} v\n * @returns {Vec3}\n */\nMat33.prototype.solve33 = function(v) {\n var det = Vec3.dot(this.ex, Vec3.cross(this.ey, this.ez));\n if (det != 0.0) {\n det = 1.0 / det;\n }\n var r = new Vec3();\n r.x = det * Vec3.dot(v, Vec3.cross(this.ey, this.ez));\n r.y = det * Vec3.dot(this.ex, Vec3.cross(v, this.ez));\n r.z = det * Vec3.dot(this.ex, Vec3.cross(this.ey, v));\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 * @param {Vec2} v\n * \n * @returns {Vec2}\n */\nMat33.prototype.solve22 = function(v) {\n var a11 = this.ex.x;\n var a12 = this.ey.x;\n var a21 = this.ex.y;\n var a22 = this.ey.y;\n var det = a11 * a22 - a12 * a21;\n if (det != 0.0) {\n det = 1.0 / det;\n }\n var 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 * @param {Mat33} M\n */\nMat33.prototype.getInverse22 = function(M) {\n var a = this.ex.x;\n var b = this.ey.x;\n var c = this.ex.y;\n var d = this.ey.y;\n var 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 * @param {Mat33} M\n */\nMat33.prototype.getSymInverse33 = function(M) {\n var det = Vec3.dot(this.ex, Vec3.cross(this.ey, this.ez));\n if (det != 0.0) {\n det = 1.0 / det;\n }\n var a11 = this.ex.x;\n var a12 = this.ey.x;\n var a13 = this.ez.x;\n var a22 = this.ey.y;\n var a23 = this.ez.y;\n var 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 * @param {Mat33} a\n * @param {Vec3|Vec2} b\n * \n * @returns {Vec3|Vec2}\n */\nMat33.mul = function(a, b) {\n _ASSERT && Mat33.assert(a);\n if (b && 'z' in b && 'y' in b && 'x' in b) {\n _ASSERT && Vec3.assert(b);\n var x = a.ex.x * b.x + a.ey.x * b.y + a.ez.x * b.z;\n var y = a.ex.y * b.x + a.ey.y * b.y + a.ez.y * b.z;\n var 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 _ASSERT && Vec2.assert(b);\n var x = a.ex.x * b.x + a.ey.x * b.y;\n var y = a.ex.y * b.x + a.ey.y * b.y;\n return Vec2.neo(x, y);\n }\n\n _ASSERT && common.assert(false);\n}\n\nMat33.mulVec3 = function(a, b) {\n _ASSERT && Mat33.assert(a);\n _ASSERT && Vec3.assert(b);\n var x = a.ex.x * b.x + a.ey.x * b.y + a.ez.x * b.z;\n var y = a.ex.y * b.x + a.ey.y * b.y + a.ez.y * b.z;\n var 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\nMat33.mulVec2 = function(a, b) {\n _ASSERT && Mat33.assert(a);\n _ASSERT && Vec2.assert(b);\n var x = a.ex.x * b.x + a.ey.x * b.y;\n var y = a.ex.y * b.x + a.ey.y * b.y;\n return Vec2.neo(x, y);\n}\n\nMat33.add = function(a, b) {\n _ASSERT && Mat33.assert(a);\n _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 * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nvar common = require('../util/common');\nvar native = Math;\nvar math = module.exports = Object.create(native);\n\nmath.EPSILON = 1e-9; // TODO\n\n/**\n * This function is used to ensure that a floating point number is not a NaN or\n * infinity.\n */\nmath.isFinite = function(x) {\n return (typeof x === 'number') && isFinite(x) && !isNaN(x);\n}\n\nmath.assert = function(x) {\n if (!_ASSERT) return;\n if (!math.isFinite(x)) {\n _DEBUG && common.debug(x);\n throw new Error('Invalid Number!');\n }\n}\n\n/**\n * TODO: This is a approximate yet fast inverse square-root.\n */\nmath.invSqrt = function(x) {\n // TODO\n return 1 / native.sqrt(x);\n}\n\n/**\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 */\nmath.nextPowerOfTwo = function(x) {\n // TODO\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\nmath.isPowerOfTwo = function(x) {\n return x > 0 && (x & (x - 1)) == 0;\n}\n\nmath.mod = function(num, min, max) {\n if (typeof min === 'undefined') {\n max = 1, min = 0;\n } else if (typeof max === 'undefined') {\n max = min, 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\nmath.clamp = function(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};\n\nmath.random = function(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 : native.random() * (max - min) + min;\n};\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = Position;\n\nvar Vec2 = require('./Vec2');\nvar Rot = require('./Rot');\n\n/**\n * @prop {Vec2} c location\n * @prop {float} a angle\n */\nfunction Position() {\n this.c = Vec2.zero();\n this.a = 0;\n}\n\nPosition.prototype.getTransform = function(xf, p) {\n xf.q.set(this.a);\n xf.p.set(Vec2.sub(this.c, Rot.mulVec2(xf.q, p)));\n return xf;\n}\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = Rot;\n\nvar common = require('../util/common');\nvar Vec2 = require('./Vec2');\nvar Math = require('./Math');\n\n// TODO merge with Transform\n\n/**\n * Initialize from an angle in radians.\n */\nfunction Rot(angle) {\n if (!(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.set(angle);\n } else {\n this.setIdentity();\n }\n}\n\nRot.neo = function(angle) {\n var obj = Object.create(Rot.prototype);\n obj.setAngle(angle);\n return obj;\n};\n\nRot.clone = function(rot) {\n _ASSERT && Rot.assert(rot);\n var obj = Object.create(Rot.prototype);\n obj.s = rot.s;\n obj.c = rot.c;\n return obj;\n};\n\nRot.identity = function() {\n var obj = Object.create(Rot.prototype);\n obj.s = 0.0;\n obj.c = 1.0;\n return obj;\n};\n\nRot.isValid = function(o) {\n return o && Math.isFinite(o.s) && Math.isFinite(o.c);\n}\n\nRot.assert = function(o) {\n if (!_ASSERT) return;\n if (!Rot.isValid(o)) {\n _DEBUG && common.debug(o);\n throw new Error('Invalid Rot!');\n }\n}\n\n/**\n * Set to the identity rotation.\n */\nRot.prototype.setIdentity = function() {\n this.s = 0.0;\n this.c = 1.0;\n}\n\nRot.prototype.set = function(angle) {\n if (typeof angle === 'object') {\n _ASSERT && Rot.assert(angle);\n this.s = angle.s;\n this.c = angle.c;\n\n } else {\n _ASSERT && Math.assert(angle);\n // TODO_ERIN optimize\n this.s = Math.sin(angle);\n this.c = Math.cos(angle);\n }\n}\n\n/**\n * Set using an angle in radians.\n */\nRot.prototype.setAngle = function(angle) {\n _ASSERT && Math.assert(angle);\n // TODO_ERIN optimize\n this.s = Math.sin(angle);\n this.c = Math.cos(angle);\n};\n\n/**\n * Get the angle in radians.\n */\nRot.prototype.getAngle = function() {\n return Math.atan2(this.s, this.c);\n}\n\n/**\n * Get the x-axis.\n */\nRot.prototype.getXAxis = function() {\n return Vec2.neo(this.c, this.s);\n}\n\n/**\n * Get the u-axis.\n */\nRot.prototype.getYAxis = function() {\n return Vec2.neo(-this.s, this.c);\n}\n\n/**\n * Multiply two rotations: q * r\n * \n * @returns Rot\n * \n * Rotate a vector\n * \n * @returns Vec2\n */\nRot.mul = function(rot, m) {\n _ASSERT && Rot.assert(rot);\n if ('c' in m && 's' in m) {\n _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 var 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 _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\nRot.mulRot = function(rot, m) {\n _ASSERT && Rot.assert(rot);\n _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 var 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\nRot.mulVec2 = function(rot, m) {\n _ASSERT && Rot.assert(rot);\n _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\nRot.mulSub = function(rot, v, w) {\n var x = rot.c * (v.x - w.x) - rot.s * (v.y - w.y);\n var y = rot.s * (v.x - w.x) + rot.c * (v.y - w.y);\n return Vec2.neo(x, y);\n}\n\n/**\n * Transpose multiply two rotations: qT * r\n * \n * @returns Rot\n * \n * Inverse rotate a vector\n * \n * @returns Vec2\n */\nRot.mulT = function(rot, m) {\n if ('c' in m && 's' in m) {\n _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 var 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 _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\nRot.mulTRot = function(rot, m) {\n _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 var 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\nRot.mulTVec2 = function(rot, m) {\n _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 * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = Sweep;\n\nvar common = require('../util/common');\nvar Math = require('./Math');\nvar Vec2 = require('./Vec2');\nvar Rot = require('./Rot');\nvar Transform = require('./Transform');\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 * \n * @prop {Vec2} localCenter Local center of mass position\n * @prop {Vec2} c World center position\n * @prop {float} a World angle\n * @prop {float} alpha0 Fraction of the current time step in the range [0,1], c0\n * and a0 are c and a at alpha0.\n */\nfunction Sweep(c, a) {\n _ASSERT && common.assert(typeof c === 'undefined');\n _ASSERT && common.assert(typeof a === 'undefined');\n this.localCenter = Vec2.zero();\n this.c = Vec2.zero();\n this.a = 0;\n this.alpha0 = 0;\n this.c0 = Vec2.zero();\n this.a0 = 0;\n}\n\nSweep.prototype.setTransform = function(xf) {\n var c = Transform.mulVec2(xf, this.localCenter);\n this.c.set(c);\n this.c0.set(c);\n\n this.a = xf.q.getAngle();\n this.a0 = xf.q.getAngle();\n};\n\nSweep.prototype.setLocalCenter = function(localCenter, xf) {\n this.localCenter.set(localCenter);\n\n var c = Transform.mulVec2(xf, this.localCenter);\n this.c.set(c);\n this.c0.set(c);\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 */\nSweep.prototype.getTransform = function(xf, beta) {\n beta = typeof beta === 'undefined' ? 0 : beta;\n xf.q.setAngle((1.0 - beta) * this.a0 + beta * this.a);\n xf.p.setCombine((1.0 - beta), this.c0, beta, this.c);\n\n // shift to origin\n xf.p.sub(Rot.mulVec2(xf.q, this.localCenter));\n};\n\n/**\n * Advance the sweep forward, yielding a new initial state.\n * \n * @param {float} alpha The new initial time\n */\nSweep.prototype.advance = function(alpha) {\n _ASSERT && common.assert(this.alpha0 < 1.0);\n var beta = (alpha - this.alpha0) / (1.0 - this.alpha0);\n this.c0.setCombine(beta, this.c, 1 - beta, this.c0);\n this.a0 = beta * this.a + (1 - beta) * this.a0;\n this.alpha0 = alpha;\n};\n\nSweep.prototype.forward = function() {\n this.a0 = this.a;\n this.c0.set(this.c);\n};\n\n/**\n * normalize the angles in radians to be between -pi and pi.\n */\nSweep.prototype.normalize = function() {\n var a0 = Math.mod(this.a0, -Math.PI, +Math.PI);\n this.a -= this.a0 - a0;\n this.a0 = a0;\n};\n\nSweep.prototype.clone = function() {\n var clone = new Sweep();\n clone.localCenter.set(this.localCenter);\n clone.alpha0 = this.alpha0;\n clone.a0 = this.a0;\n clone.a = this.a;\n clone.c0.set(this.c0);\n clone.c.set(this.c);\n return clone;\n};\n\nSweep.prototype.set = function(that) {\n this.localCenter.set(that.localCenter);\n this.alpha0 = that.alpha0;\n this.a0 = that.a0;\n this.a = that.a;\n this.c0.set(that.c0);\n this.c.set(that.c);\n};\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = Transform;\n\nvar common = require('../util/common');\nvar Vec2 = require('./Vec2');\nvar Rot = require('./Rot');\n\n// TODO merge with Rot\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 * @prop {Vec2} position\n * @prop {Rot} rotation\n */\nfunction Transform(position, rotation) {\n if (!(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.set(position);\n }\n if (typeof rotation !== 'undefined') {\n this.q.set(rotation);\n }\n};\n\nTransform.clone = function(xf) {\n var obj = Object.create(Transform.prototype);\n obj.p = Vec2.clone(xf.p);\n obj.q = Rot.clone(xf.q);\n return obj;\n};\n\nTransform.neo = function(position, rotation) {\n var obj = Object.create(Transform.prototype);\n obj.p = Vec2.clone(position);\n obj.q = Rot.clone(rotation);\n return obj;\n};\n\nTransform.identity = function() {\n var obj = Object.create(Transform.prototype);\n obj.p = Vec2.zero();\n obj.q = Rot.identity();\n return obj;\n};\n\n/**\n * Set this to the identity transform.\n */\nTransform.prototype.setIdentity = function() {\n this.p.setZero();\n this.q.setIdentity();\n}\n\n/**\n * Set this based on the position and angle.\n */\nTransform.prototype.set = function(a, b) {\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\nTransform.isValid = function(o) {\n return o && Vec2.isValid(o.p) && Rot.isValid(o.q);\n}\n\nTransform.assert = function(o) {\n if (!_ASSERT) return;\n if (!Transform.isValid(o)) {\n _DEBUG && common.debug(o);\n throw new Error('Invalid Transform!');\n }\n}\n\n/**\n * @param {Transform} a\n * @param {Vec2} b\n * @returns {Vec2}\n *\n * @param {Transform} a\n * @param {Transform} b\n * @returns {Transform}\n */\nTransform.mul = function(a, b) {\n _ASSERT && Transform.assert(a);\n if (Array.isArray(b)) {\n var arr = [];\n for (var 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 _ASSERT && Vec2.assert(b);\n var x = (a.q.c * b.x - a.q.s * b.y) + a.p.x;\n var y = (a.q.s * b.x + a.q.c * b.y) + a.p.y;\n return Vec2.neo(x, y);\n\n } else if ('p' in b && 'q' in b) {\n _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 var 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\n/**\n * @deprecated Use mulFn instead.\n */\nTransform.mulAll = function(a, b) {\n _ASSERT && Transform.assert(a);\n var arr = [];\n for (var i = 0; i < b.length; i++) {\n arr[i] = Transform.mul(a, b[i]);\n }\n return arr;\n}\n\n/**\n * @experimental\n */\nTransform.mulFn = function(a) {\n _ASSERT && Transform.assert(a);\n return function(b) {\n return Transform.mul(a, b);\n };\n}\n\nTransform.mulVec2 = function(a, b) {\n _ASSERT && Transform.assert(a);\n _ASSERT && Vec2.assert(b);\n var x = (a.q.c * b.x - a.q.s * b.y) + a.p.x;\n var y = (a.q.s * b.x + a.q.c * b.y) + a.p.y;\n return Vec2.neo(x, y);\n}\n\nTransform.mulXf = function(a, b) {\n _ASSERT && Transform.assert(a);\n _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 var 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/**\n * @param {Transform} a\n * @param {Vec2} b\n * @returns {Vec2}\n *\n * @param {Transform} a\n * @param {Transform} b\n * @returns {Transform}\n */\nTransform.mulT = function(a, b) {\n _ASSERT && Transform.assert(a);\n if ('x' in b && 'y' in b) {\n _ASSERT && Vec2.assert(b)\n var px = b.x - a.p.x;\n var py = b.y - a.p.y;\n var x = (a.q.c * px + a.q.s * py);\n var y = (-a.q.s * px + a.q.c * py);\n return Vec2.neo(x, y);\n\n } else if ('p' in b && 'q' in b) {\n _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 var xf = Transform.identity();\n xf.q.set(Rot.mulTRot(a.q, b.q));\n xf.p.set(Rot.mulTVec2(a.q, Vec2.sub(b.p, a.p)));\n return xf;\n }\n}\n\nTransform.mulTVec2 = function(a, b) {\n _ASSERT && Transform.assert(a);\n _ASSERT && Vec2.assert(b)\n var px = b.x - a.p.x;\n var py = b.y - a.p.y;\n var x = (a.q.c * px + a.q.s * py);\n var y = (-a.q.s * px + a.q.c * py);\n return Vec2.neo(x, y);\n}\n\nTransform.mulTXf = function(a, b) {\n _ASSERT && Transform.assert(a);\n _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 var xf = Transform.identity();\n xf.q.set(Rot.mulTRot(a.q, b.q));\n xf.p.set(Rot.mulTVec2(a.q, Vec2.sub(b.p, a.p)));\n return xf;\n}\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = Vec2;\n\nvar common = require('../util/common');\nvar Math = require('./Math');\n\nfunction Vec2(x, y) {\n if (!(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 _ASSERT && Vec2.assert(this);\n}\n\nVec2.prototype._serialize = function() {\n return {\n x: this.x,\n y: this.y\n };\n};\n\nVec2._deserialize = function(data) {\n var obj = Object.create(Vec2.prototype);\n obj.x = data.x;\n obj.y = data.y;\n return obj;\n};\n\nVec2.zero = function() {\n var obj = Object.create(Vec2.prototype);\n obj.x = 0;\n obj.y = 0;\n return obj;\n};\n\nVec2.neo = function(x, y) {\n var obj = Object.create(Vec2.prototype);\n obj.x = x;\n obj.y = y;\n return obj;\n};\n\nVec2.clone = function(v) {\n _ASSERT && Vec2.assert(v);\n return Vec2.neo(v.x, v.y);\n};\n\nVec2.prototype.toString = function() {\n return JSON.stringify(this);\n};\n\n/**\n * Does this vector contain finite coordinates?\n */\nVec2.isValid = function(v) {\n return v && Math.isFinite(v.x) && Math.isFinite(v.y);\n}\n\nVec2.assert = function(o) {\n if (!_ASSERT) return;\n if (!Vec2.isValid(o)) {\n _DEBUG && common.debug(o);\n throw new Error('Invalid Vec2!');\n }\n}\n\nVec2.prototype.clone = function() {\n return Vec2.clone(this);\n}\n\n/**\n * Set this vector to all zeros.\n * \n * @returns this\n */\nVec2.prototype.setZero = function() {\n this.x = 0.0;\n this.y = 0.0;\n return this;\n}\n\n/**\n * Set this vector to some specified coordinates.\n * \n * @returns this\n */\nVec2.prototype.set = function(x, y) {\n if (typeof x === 'object') {\n _ASSERT && Vec2.assert(x);\n this.x = x.x;\n this.y = x.y;\n } else {\n _ASSERT && Math.assert(x);\n _ASSERT && Math.assert(y);\n this.x = x;\n this.y = y;\n }\n return this;\n}\n\n/**\n * @deprecated Use setCombine or setMul\n */\nVec2.prototype.wSet = function(a, v, b, w) {\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 */\nVec2.prototype.setCombine = function(a, v, b, w) {\n _ASSERT && Math.assert(a);\n _ASSERT && Vec2.assert(v);\n _ASSERT && Math.assert(b);\n _ASSERT && Vec2.assert(w);\n var x = a * v.x + b * w.x;\n var 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\nVec2.prototype.setMul = function(a, v) {\n _ASSERT && Math.assert(a);\n _ASSERT && Vec2.assert(v);\n var x = a * v.x;\n var 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 */\nVec2.prototype.add = function(w) {\n _ASSERT && Vec2.assert(w);\n this.x += w.x;\n this.y += w.y;\n return this;\n}\n\n/**\n * @deprecated Use addCombine or addMul\n */\nVec2.prototype.wAdd = function(a, v, b, w) {\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 */\nVec2.prototype.addCombine = function(a, v, b, w) {\n _ASSERT && Math.assert(a);\n _ASSERT && Vec2.assert(v);\n _ASSERT && Math.assert(b);\n _ASSERT && Vec2.assert(w);\n\n var x = a * v.x + b * w.x;\n var 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\nVec2.prototype.addMul = function(a, v) {\n _ASSERT && Math.assert(a);\n _ASSERT && Vec2.assert(v);\n var x = a * v.x;\n var 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 */\nVec2.prototype.wSub = function(a, v, b, w) {\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 */\nVec2.prototype.subCombine = function(a, v, b, w) {\n _ASSERT && Math.assert(a);\n _ASSERT && Vec2.assert(v);\n _ASSERT && Math.assert(b);\n _ASSERT && Vec2.assert(w);\n var x = a * v.x + b * w.x;\n var 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\nVec2.prototype.subMul = function(a, v) {\n _ASSERT && Math.assert(a);\n _ASSERT && Vec2.assert(v);\n var x = a * v.x;\n var 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 */\nVec2.prototype.sub = function(w) {\n _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 */\nVec2.prototype.mul = function(m) {\n _ASSERT && Math.assert(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 */\nVec2.prototype.length = function() {\n return Vec2.lengthOf(this);\n}\n\n/**\n * Get the length squared.\n */\nVec2.prototype.lengthSquared = function() {\n return Vec2.lengthSquared(this);\n}\n\n/**\n * Convert this vector into a unit vector.\n * \n * @returns old length\n */\nVec2.prototype.normalize = function() {\n var length = this.length();\n if (length < Math.EPSILON) {\n return 0.0;\n }\n var invLength = 1.0 / length;\n this.x *= invLength;\n this.y *= invLength;\n return length;\n}\n\n/**\n * Get the length of this vector (the norm).\n *\n * For performance, use this instead of lengthSquared (if possible).\n */\nVec2.lengthOf = function(v) {\n _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 */\nVec2.lengthSquared = function(v) {\n _ASSERT && Vec2.assert(v);\n return v.x * v.x + v.y * v.y;\n}\n\nVec2.distance = function(v, w) {\n _ASSERT && Vec2.assert(v);\n _ASSERT && Vec2.assert(w);\n var dx = v.x - w.x, dy = v.y - w.y;\n return Math.sqrt(dx * dx + dy * dy);\n}\n\nVec2.distanceSquared = function(v, w) {\n _ASSERT && Vec2.assert(v);\n _ASSERT && Vec2.assert(w);\n var dx = v.x - w.x, dy = v.y - w.y;\n return dx * dx + dy * dy;\n}\n\nVec2.areEqual = function(v, w) {\n _ASSERT && Vec2.assert(v);\n _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 */\nVec2.skew = function(v) {\n _ASSERT && Vec2.assert(v);\n return Vec2.neo(-v.y, v.x);\n}\n\n/**\n * Perform the dot product on two vectors.\n */\nVec2.dot = function(v, w) {\n _ASSERT && Vec2.assert(v);\n _ASSERT && Vec2.assert(w);\n return v.x * w.x + v.y * w.y;\n}\n\n/**\n * Perform the cross product on two vectors. In 2D this produces a scalar.\n * \n * Perform the cross product on a vector and a scalar. In 2D this produces a\n * vector.\n */\nVec2.cross = function(v, w) {\n if (typeof w === 'number') {\n _ASSERT && Vec2.assert(v);\n _ASSERT && Math.assert(w);\n return Vec2.neo(w * v.y, -w * v.x);\n\n } else if (typeof v === 'number') {\n _ASSERT && Math.assert(v);\n _ASSERT && Vec2.assert(w);\n return Vec2.neo(-v * w.y, v * w.x);\n\n } else {\n _ASSERT && Vec2.assert(v);\n _ASSERT && Vec2.assert(w);\n return v.x * w.y - v.y * w.x\n }\n}\n\n/**\n * Returns `a + (v x w)`\n */\nVec2.addCross = function(a, v, w) {\n if (typeof w === 'number') {\n _ASSERT && Vec2.assert(v);\n _ASSERT && Math.assert(w);\n return Vec2.neo(w * v.y + a.x, -w * v.x + a.y);\n\n } else if (typeof v === 'number') {\n _ASSERT && Math.assert(v);\n _ASSERT && Vec2.assert(w);\n return Vec2.neo(-v * w.y + a.x, v * w.x + a.y);\n }\n\n _ASSERT && common.assert(false);\n}\n\nVec2.add = function(v, w) {\n _ASSERT && Vec2.assert(v);\n _ASSERT && Vec2.assert(w);\n return Vec2.neo(v.x + w.x, v.y + w.y);\n}\n\n/**\n * @deprecated Use combine\n */\nVec2.wAdd = function(a, v, b, w) {\n if (typeof b !== 'undefined' || typeof w !== 'undefined') {\n return Vec2.combine(a, v, b, w);\n } else {\n return Vec2.mul(a, v);\n }\n}\n\nVec2.combine = function(a, v, b, w) {\n return Vec2.zero().setCombine(a, v, b, w);\n}\n\nVec2.sub = function(v, w) {\n _ASSERT && Vec2.assert(v);\n _ASSERT && Vec2.assert(w);\n return Vec2.neo(v.x - w.x, v.y - w.y);\n}\n\nVec2.mul = function(a, b) {\n if (typeof a === 'object') {\n _ASSERT && Vec2.assert(a);\n _ASSERT && Math.assert(b);\n return Vec2.neo(a.x * b, a.y * b);\n\n } else if (typeof b === 'object') {\n _ASSERT && Math.assert(a);\n _ASSERT && Vec2.assert(b);\n return Vec2.neo(a * b.x, a * b.y);\n }\n}\n\nVec2.prototype.neg = function() {\n this.x = -this.x;\n this.y = -this.y;\n return this;\n}\n\nVec2.neg = function(v) {\n _ASSERT && Vec2.assert(v);\n return Vec2.neo(-v.x, -v.y);\n}\n\nVec2.abs = function(v) {\n _ASSERT && Vec2.assert(v);\n return Vec2.neo(Math.abs(v.x), Math.abs(v.y));\n}\n\nVec2.mid = function(v, w) {\n _ASSERT && Vec2.assert(v);\n _ASSERT && Vec2.assert(w);\n return Vec2.neo((v.x + w.x) * 0.5, (v.y + w.y) * 0.5);\n}\n\nVec2.upper = function(v, w) {\n _ASSERT && Vec2.assert(v);\n _ASSERT && Vec2.assert(w);\n return Vec2.neo(Math.max(v.x, w.x), Math.max(v.y, w.y));\n}\n\nVec2.lower = function(v, w) {\n _ASSERT && Vec2.assert(v);\n _ASSERT && Vec2.assert(w);\n return Vec2.neo(Math.min(v.x, w.x), Math.min(v.y, w.y));\n}\n\nVec2.prototype.clamp = function(max) {\n var lengthSqr = this.x * this.x + this.y * this.y;\n if (lengthSqr > max * max) {\n var invLength = Math.invSqrt(lengthSqr);\n this.x *= invLength * max;\n this.y *= invLength * max;\n }\n return this;\n}\n\nVec2.clamp = function(v, max) {\n v = Vec2.neo(v.x, v.y);\n v.clamp(max);\n return v;\n}\n\n/**\n * @experimental\n */\nVec2.scaleFn = function (x, y) {\n return function (v) {\n return Vec2.neo(v.x * x, v.y * y);\n };\n}\n\n/**\n * @experimental\n */\nVec2.translateFn = function(x, y) {\n return function (v) {\n return Vec2.neo(v.x + x, v.y + y);\n };\n}\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = Vec3;\n\nvar common = require('../util/common');\nvar Math = require('./Math');\n\nfunction Vec3(x, y, z) {\n if (!(this instanceof Vec3)) {\n return new Vec3(x, y, z);\n }\n if (typeof x === 'undefined') {\n this.x = 0, this.y = 0, this.z = 0;\n } else if (typeof x === 'object') {\n this.x = x.x, this.y = x.y, this.z = x.z;\n } else {\n this.x = x, this.y = y, this.z = z;\n }\n _ASSERT && Vec3.assert(this);\n};\n\nVec3.prototype._serialize = function() {\n return {\n x: this.x,\n y: this.y,\n z: this.z\n };\n};\n\nVec3._deserialize = function(data) {\n var 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\nVec3.neo = function(x, y, z) {\n var obj = Object.create(Vec3.prototype);\n obj.x = x;\n obj.y = y;\n obj.z = z;\n return obj;\n};\n\nVec3.clone = function(v) {\n _ASSERT && Vec3.assert(v);\n return Vec3.neo(v.x, v.y, v.z);\n};\n\nVec3.prototype.toString = function() {\n return JSON.stringify(this);\n};\n\n/**\n * Does this vector contain finite coordinates?\n */\nVec3.isValid = function(v) {\n return v && Math.isFinite(v.x) && Math.isFinite(v.y) && Math.isFinite(v.z);\n}\n\nVec3.assert = function(o) {\n if (!_ASSERT) return;\n if (!Vec3.isValid(o)) {\n _DEBUG && common.debug(o);\n throw new Error('Invalid Vec3!');\n }\n}\n\nVec3.prototype.setZero = function() {\n this.x = 0.0;\n this.y = 0.0;\n this.z = 0.0;\n return this;\n}\n\nVec3.prototype.set = function(x, y, z) {\n this.x = x;\n this.y = y;\n this.z = z;\n return this;\n}\n\nVec3.prototype.add = function(w) {\n this.x += w.x;\n this.y += w.y;\n this.z += w.z;\n return this;\n}\n\nVec3.prototype.sub = function(w) {\n this.x -= w.x;\n this.y -= w.y;\n this.z -= w.z;\n return this;\n}\n\nVec3.prototype.mul = function(m) {\n this.x *= m;\n this.y *= m;\n this.z *= m;\n return this;\n}\n\nVec3.areEqual = function(v, w) {\n _ASSERT && Vec3.assert(v);\n _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/**\n * Perform the dot product on two vectors.\n */\nVec3.dot = function(v, w) {\n return v.x * w.x + v.y * w.y + v.z * w.z;\n}\n\n/**\n * Perform the cross product on two vectors. In 2D this produces a scalar.\n */\nVec3.cross = function(v, w) {\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\nVec3.add = function(v, w) {\n return new Vec3(v.x + w.x, v.y + w.y, v.z + w.z);\n}\n\nVec3.sub = function(v, w) {\n return new Vec3(v.x - w.x, v.y - w.y, v.z - w.z);\n}\n\nVec3.mul = function(v, m) {\n return new Vec3(m * v.x, m * v.y, m * v.z);\n}\n\nVec3.prototype.neg = function() {\n this.x = -this.x;\n this.y = -this.y;\n this.z = -this.z;\n return this;\n}\n\nVec3.neg = function(v) {\n return new Vec3(-v.x, -v.y, -v.z);\n}\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = Velocity;\n\nvar Vec2 = require('./Vec2');\n\n/**\n * @prop {Vec2} v linear\n * @prop {float} w angular\n */\nfunction Velocity() {\n this.v = Vec2.zero();\n this.w = 0;\n}\n","var _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nexports.toString = function(newline) {\n newline = typeof newline === 'string' ? newline : '\\n';\n var string = \"\";\n for (var 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};","exports.internal = {};\n\nexports.Serializer = require('./serializer');\n\nexports.Math = require('./common/Math');\nexports.Vec2 = require('./common/Vec2');\nexports.Vec3 = require('./common/Vec3');\nexports.Mat22 = require('./common/Mat22');\nexports.Mat33 = require('./common/Mat33');\nexports.Transform = require('./common/Transform');\nexports.Rot = require('./common/Rot');\n\nexports.AABB = require('./collision/AABB');\n\nexports.Shape = require('./Shape');\nexports.Fixture = require('./Fixture');\nexports.Body = require('./Body');\nexports.Contact = require('./Contact');\nexports.Joint = require('./Joint');\nexports.World = require('./World');\n\nexports.Circle = require('./shape/CircleShape');\nexports.Edge = require('./shape/EdgeShape');\nexports.Polygon = require('./shape/PolygonShape');\nexports.Chain = require('./shape/ChainShape');\nexports.Box = require('./shape/BoxShape');\n\nrequire('./shape/CollideCircle');\nrequire('./shape/CollideEdgeCircle');\nexports.internal.CollidePolygons = require('./shape/CollidePolygon');\nrequire('./shape/CollideCirclePolygone');\nrequire('./shape/CollideEdgePolygon');\n\nexports.DistanceJoint = require('./joint/DistanceJoint');\nexports.FrictionJoint = require('./joint/FrictionJoint');\nexports.GearJoint = require('./joint/GearJoint');\nexports.MotorJoint = require('./joint/MotorJoint');\nexports.MouseJoint = require('./joint/MouseJoint');\nexports.PrismaticJoint = require('./joint/PrismaticJoint');\nexports.PulleyJoint = require('./joint/PulleyJoint');\nexports.RevoluteJoint = require('./joint/RevoluteJoint');\nexports.RopeJoint = require('./joint/RopeJoint');\nexports.WeldJoint = require('./joint/WeldJoint');\nexports.WheelJoint = require('./joint/WheelJoint');\n\nexports.Settings = require('./Settings');\n\nexports.internal.Sweep = require('./common/Sweep');\nexports.internal.stats = require('./common/stats'); // todo: remove this\nexports.internal.Manifold = require('./Manifold');\nexports.internal.Distance = require('./collision/Distance');\nexports.internal.TimeOfImpact = require('./collision/TimeOfImpact');\nexports.internal.DynamicTree = require('./collision/DynamicTree');\nexports.internal.Settings = exports.Settings;\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = DistanceJoint;\n\nvar options = require('../util/options');\nvar Settings = require('../Settings');\n\nvar Math = require('../common/Math');\nvar Vec2 = require('../common/Vec2');\nvar Vec3 = require('../common/Vec3');\nvar Mat22 = require('../common/Mat22');\nvar Mat33 = require('../common/Mat33');\nvar Rot = require('../common/Rot');\nvar Sweep = require('../common/Sweep');\nvar Transform = require('../common/Transform');\nvar Velocity = require('../common/Velocity');\nvar Position = require('../common/Position');\n\nvar Joint = require('../Joint');\nvar Body = require('../Body');\n\nDistanceJoint.TYPE = 'distance-joint';\nJoint.TYPES[DistanceJoint.TYPE] = DistanceJoint;\n\nDistanceJoint._super = Joint;\nDistanceJoint.prototype = Object.create(DistanceJoint._super.prototype);\n\n/**\n * @typedef {Object} DistanceJointDef\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 * \n * @prop {float} frequencyHz The mass-spring-damper frequency in Hertz. A value\n * of 0 disables softness.\n * @prop {float} dampingRatio The damping ratio. 0 = no damping, 1 = critical\n * damping.\n *\n * @prop {Vec2} localAnchorA The local anchor point relative to bodyA's origin.\n * @prop {Vec2} localAnchorB The local anchor point relative to bodyB's origin.\n * @prop {number} length Distance length.\n */\n\nvar DEFAULTS = {\n frequencyHz : 0.0,\n dampingRatio : 0.0\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 * @param {DistanceJointDef} def\n * @param {Body} bodyA\n * @param {Body} bodyB\n * @param {Vec2} anchorA Anchor A in global coordination.\n * @param {Vec2} anchorB Anchor B in global coordination.\n */\nfunction DistanceJoint(def, bodyA, bodyB, anchorA, anchorB) {\n if (!(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 var temp = bodyB;\n bodyB = anchorA;\n anchorA = temp;\n }\n\n def = options(def, DEFAULTS);\n Joint.call(this, 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 = Math.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 // Solver temp\n this.m_u; // Vec2\n this.m_rA; // Vec2\n this.m_rB; // Vec2\n this.m_localCenterA; // Vec2\n this.m_localCenterB; // Vec2\n this.m_invMassA;\n this.m_invMassB;\n this.m_invIA;\n this.m_invIB;\n this.m_mass;\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\nDistanceJoint.prototype._serialize = function() {\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\nDistanceJoint._deserialize = function(data, world, restore) {\n data = Object.assign({}, data);\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n var joint = new DistanceJoint(data);\n return joint;\n};\n\n/**\n * @internal\n */\nDistanceJoint.prototype._setAnchors = function(def) {\n if (def.anchorA) {\n this.m_localAnchorA.set(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.set(def.localAnchorA);\n }\n\n if (def.anchorB) {\n this.m_localAnchorB.set(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.set(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}\n\n/**\n * The local anchor point relative to bodyA's origin.\n */\nDistanceJoint.prototype.getLocalAnchorA = function() {\n return this.m_localAnchorA;\n}\n\n/**\n * The local anchor point relative to bodyB's origin.\n */\nDistanceJoint.prototype.getLocalAnchorB = function() {\n return this.m_localAnchorB;\n}\n\n/**\n * Set/get the natural length. Manipulating the length can lead to non-physical\n * behavior when the frequency is zero.\n */\nDistanceJoint.prototype.setLength = function(length) {\n this.m_length = length;\n}\n\nDistanceJoint.prototype.getLength = function() {\n return this.m_length;\n}\n\nDistanceJoint.prototype.setFrequency = function(hz) {\n this.m_frequencyHz = hz;\n}\n\nDistanceJoint.prototype.getFrequency = function() {\n return this.m_frequencyHz;\n}\n\nDistanceJoint.prototype.setDampingRatio = function(ratio) {\n this.m_dampingRatio = ratio;\n}\n\nDistanceJoint.prototype.getDampingRatio = function() {\n return this.m_dampingRatio;\n}\n\nDistanceJoint.prototype.getAnchorA = function() {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n}\n\nDistanceJoint.prototype.getAnchorB = function() {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n}\n\nDistanceJoint.prototype.getReactionForce = function(inv_dt) {\n return Vec2.mul(this.m_impulse, this.m_u).mul(inv_dt);\n}\n\nDistanceJoint.prototype.getReactionTorque = function(inv_dt) {\n return 0.0;\n}\n\nDistanceJoint.prototype.initVelocityConstraints = function(step) {\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 var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n\n var qA = Rot.neo(aA);\n var 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 var length = this.m_u.length();\n if (length > Settings.linearSlop) {\n this.m_u.mul(1.0 / length);\n } else {\n this.m_u.set(0.0, 0.0);\n }\n\n var crAu = Vec2.cross(this.m_rA, this.m_u);\n var crBu = Vec2.cross(this.m_rB, this.m_u);\n var invMass = this.m_invMassA + this.m_invIA * crAu * crAu + this.m_invMassB\n + 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 var C = length - this.m_length;\n\n // Frequency\n var omega = 2.0 * Math.PI * this.m_frequencyHz;\n\n // Damping coefficient\n var d = 2.0 * this.m_mass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n var k = this.m_mass * omega * omega;\n\n // magic formulas\n var 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 var P = Vec2.mul(this.m_impulse, this.m_u);\n\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.cross(this.m_rA, P);\n\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.cross(this.m_rB, P);\n\n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.set(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.set(vB);\n this.m_bodyB.c_velocity.w = wB;\n}\n\nDistanceJoint.prototype.solveVelocityConstraints = function(step) {\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n\n // Cdot = dot(u, v + cross(w, r))\n var vpA = Vec2.add(vA, Vec2.cross(wA, this.m_rA));\n var vpB = Vec2.add(vB, Vec2.cross(wB, this.m_rB));\n var Cdot = Vec2.dot(this.m_u, vpB) - Vec2.dot(this.m_u, vpA);\n\n var impulse = -this.m_mass\n * (Cdot + this.m_bias + this.m_gamma * this.m_impulse);\n this.m_impulse += impulse;\n\n var P = Vec2.mul(impulse, this.m_u);\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.cross(this.m_rA, P);\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.cross(this.m_rB, P);\n\n this.m_bodyA.c_velocity.v.set(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.set(vB);\n this.m_bodyB.c_velocity.w = wB;\n}\n\nDistanceJoint.prototype.solvePositionConstraints = function(step) {\n if (this.m_frequencyHz > 0.0) {\n // There is no position correction for soft distance constraints.\n return true;\n }\n\n var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n\n var qA = Rot.neo(aA);\n var qB = Rot.neo(aB);\n\n var rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n var rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n var u = Vec2.sub(Vec2.add(cB, rB), Vec2.add(cA, rA));\n\n var length = u.normalize();\n var C = length - this.m_length;\n C = Math\n .clamp(C, -Settings.maxLinearCorrection, Settings.maxLinearCorrection);\n\n var impulse = -this.m_mass * C;\n var P = Vec2.mul(impulse, u);\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * Vec2.cross(rA, P);\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * Vec2.cross(rB, P);\n\n this.m_bodyA.c_position.c.set(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.set(cB);\n this.m_bodyB.c_position.a = aB;\n\n return Math.abs(C) < Settings.linearSlop;\n}\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = FrictionJoint;\n\nvar common = require('../util/common');\nvar options = require('../util/options');\nvar Settings = require('../Settings');\n\nvar Math = require('../common/Math');\nvar Vec2 = require('../common/Vec2');\nvar Vec3 = require('../common/Vec3');\nvar Mat22 = require('../common/Mat22');\nvar Mat33 = require('../common/Mat33');\nvar Rot = require('../common/Rot');\nvar Sweep = require('../common/Sweep');\nvar Transform = require('../common/Transform');\nvar Velocity = require('../common/Velocity');\nvar Position = require('../common/Position');\n\nvar Joint = require('../Joint');\nvar Body = require('../Body');\n\nFrictionJoint.TYPE = 'friction-joint';\nJoint.TYPES[FrictionJoint.TYPE] = FrictionJoint;\n\nFrictionJoint._super = Joint;\nFrictionJoint.prototype = Object.create(FrictionJoint._super.prototype);\n\n/**\n * @typedef {Object} FrictionJointDef\n *\n * Friction joint definition.\n * \n * @prop {float} maxForce The maximum friction force in N.\n * @prop {float} maxTorque The maximum friction torque in N-m.\n *\n * @prop {Vec2} localAnchorA The local anchor point relative to bodyA's origin.\n * @prop {Vec2} localAnchorB The local anchor point relative to bodyB's origin.\n */\n\nvar DEFAULTS = {\n maxForce : 0.0,\n maxTorque : 0.0,\n};\n\n/**\n * Friction joint. This is used for top-down friction. It provides 2D\n * translational friction and angular friction.\n *\n * @param {FrictionJointDef} def\n * @param {Body} bodyA\n * @param {Body} bodyB\n * @param {Vec2} anchor Anchor in global coordination.\n */\nfunction FrictionJoint(def, bodyA, bodyB, anchor) {\n if (!(this instanceof FrictionJoint)) {\n return new FrictionJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n Joint.call(this, 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 // Solver temp\n this.m_rA; // Vec2\n this.m_rB; // Vec2\n this.m_localCenterA; // Vec2\n this.m_localCenterB; // Vec2\n this.m_invMassA; // float\n this.m_invMassB; // float\n this.m_invIA; // float\n this.m_invIB; // float\n this.m_linearMass; // Mat22\n this.m_angularMass; // float\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\nFrictionJoint.prototype._serialize = function() {\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\nFrictionJoint._deserialize = function(data, world, restore) {\n data = Object.assign({}, data);\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n var joint = new FrictionJoint(data);\n return joint;\n};\n\n/**\n * @internal\n */\nFrictionJoint.prototype._setAnchors = function(def) {\n if (def.anchorA) {\n this.m_localAnchorA.set(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.set(def.localAnchorA);\n }\n\n if (def.anchorB) {\n this.m_localAnchorB.set(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.set(def.localAnchorB);\n }\n}\n\n\n/**\n * The local anchor point relative to bodyA's origin.\n */\nFrictionJoint.prototype.getLocalAnchorA = function() {\n return this.m_localAnchorA;\n}\n\n/**\n * The local anchor point relative to bodyB's origin.\n */\nFrictionJoint.prototype.getLocalAnchorB = function() {\n return this.m_localAnchorB;\n}\n\n/**\n * Set the maximum friction force in N.\n */\nFrictionJoint.prototype.setMaxForce = function(force) {\n _ASSERT && common.assert(Math.isFinite(force) && force >= 0.0);\n this.m_maxForce = force;\n}\n\n/**\n * Get the maximum friction force in N.\n */\nFrictionJoint.prototype.getMaxForce = function() {\n return this.m_maxForce;\n}\n\n/**\n * Set the maximum friction torque in N*m.\n */\nFrictionJoint.prototype.setMaxTorque = function(torque) {\n _ASSERT && common.assert(Math.isFinite(torque) && torque >= 0.0);\n this.m_maxTorque = torque;\n}\n\n/**\n * Get the maximum friction torque in N*m.\n */\nFrictionJoint.prototype.getMaxTorque = function() {\n return this.m_maxTorque;\n}\n\nFrictionJoint.prototype.getAnchorA = function() {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n}\n\nFrictionJoint.prototype.getAnchorB = function() {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n}\n\nFrictionJoint.prototype.getReactionForce = function(inv_dt) {\n return Vec2.mul(inv_dt, this.m_linearImpulse);\n}\n\nFrictionJoint.prototype.getReactionTorque = function(inv_dt) {\n return inv_dt * this.m_angularImpulse;\n}\n\nFrictionJoint.prototype.initVelocityConstraints = function(step) {\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 var aA = this.m_bodyA.c_position.a;\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n\n var aB = this.m_bodyB.c_position.a;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n\n var qA = Rot.neo(aA), 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 var mA = this.m_invMassA, mB = this.m_invMassB; // float\n var iA = this.m_invIA, iB = this.m_invIB; // float\n\n var 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 var P = Vec2.neo(this.m_linearImpulse.x, this.m_linearImpulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.cross(this.m_rA, P) + this.m_angularImpulse);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.cross(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\nFrictionJoint.prototype.solveVelocityConstraints = function(step) {\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n\n var mA = this.m_invMassA, mB = this.m_invMassB; // float\n var iA = this.m_invIA, iB = this.m_invIB; // float\n\n var h = step.dt; // float\n\n // Solve angular friction\n {\n var Cdot = wB - wA; // float\n var impulse = -this.m_angularMass * Cdot; // float\n\n var oldImpulse = this.m_angularImpulse; // float\n var maxImpulse = h * this.m_maxTorque; // float\n this.m_angularImpulse = Math.clamp(this.m_angularImpulse + impulse,\n -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 var Cdot = Vec2.sub(Vec2.add(vB, Vec2.cross(wB, this.m_rB)), Vec2.add(vA,\n Vec2.cross(wA, this.m_rA))); // Vec2\n\n var impulse = Vec2.neg(Mat22.mulVec2(this.m_linearMass, Cdot)); // Vec2\n var oldImpulse = this.m_linearImpulse; // Vec2\n this.m_linearImpulse.add(impulse);\n\n var maxImpulse = h * this.m_maxForce; // float\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.cross(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.cross(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\nFrictionJoint.prototype.solvePositionConstraints = function(step) {\n return true;\n}\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = GearJoint;\n\nvar common = require('../util/common');\nvar options = require('../util/options');\nvar Settings = require('../Settings');\n\nvar Math = require('../common/Math');\nvar Vec2 = require('../common/Vec2');\nvar Vec3 = require('../common/Vec3');\nvar Mat22 = require('../common/Mat22');\nvar Mat33 = require('../common/Mat33');\nvar Rot = require('../common/Rot');\nvar Sweep = require('../common/Sweep');\nvar Transform = require('../common/Transform');\nvar Velocity = require('../common/Velocity');\nvar Position = require('../common/Position');\n\nvar Joint = require('../Joint');\nvar Body = require('../Body');\n\nvar RevoluteJoint = require('./RevoluteJoint');\nvar PrismaticJoint = require('./PrismaticJoint');\n\nGearJoint.TYPE = 'gear-joint';\nJoint.TYPES[GearJoint.TYPE] = GearJoint;\n\nGearJoint._super = Joint;\nGearJoint.prototype = Object.create(GearJoint._super.prototype);\n\n/**\n * @typedef {Object} GearJointDef\n *\n * Gear joint definition.\n *\n * @prop {float} ratio The gear ratio. See GearJoint for explanation.\n *\n * @prop {RevoluteJoint|PrismaticJoint} joint1 The first revolute/prismatic\n * joint attached to the gear joint.\n * @prop {PrismaticJoint|RevoluteJoint} joint2 The second prismatic/revolute\n * joint attached to the gear joint.\n */\n\nvar DEFAULTS = {\n ratio : 1.0\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 * @param {GearJointDef} def\n * @param {Body} bodyA\n * @param {Body} bodyB\n */\nfunction GearJoint(def, bodyA, bodyB, joint1, joint2, ratio) {\n if (!(this instanceof GearJoint)) {\n return new GearJoint(def, bodyA, bodyB, joint1, joint2, ratio);\n }\n\n def = options(def, DEFAULTS);\n Joint.call(this, def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = GearJoint.TYPE;\n\n _ASSERT && common.assert(joint1.m_type === RevoluteJoint.TYPE\n || joint1.m_type === PrismaticJoint.TYPE);\n _ASSERT && common.assert(joint2.m_type === RevoluteJoint.TYPE\n || 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 = Math.isFinite(ratio) ? ratio : def.ratio;\n\n this.m_type1 = this.m_joint1.getType();\n this.m_type2 = this.m_joint2.getType();\n\n // joint1 connects body A to body C\n // joint2 connects body B to body D\n\n var coordinateA, coordinateB; // float\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 var xfA = this.m_bodyA.m_xf;\n var aA = this.m_bodyA.m_sweep.a;\n var xfC = this.m_bodyC.m_xf;\n var aC = this.m_bodyC.m_sweep.a;\n\n if (this.m_type1 === RevoluteJoint.TYPE) {\n var revolute = this.m_joint1;// 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 var prismatic = this.m_joint1; // 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 var pC = this.m_localAnchorC;\n var pA = Rot.mulTVec2(xfC.q, Vec2.add(Rot.mul(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 var xfB = this.m_bodyB.m_xf;\n var aB = this.m_bodyB.m_sweep.a;\n var xfD = this.m_bodyD.m_xf;\n var aD = this.m_bodyD.m_sweep.a;\n\n if (this.m_type2 === RevoluteJoint.TYPE) {\n var revolute = this.m_joint2; // 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 var prismatic = this.m_joint2; // 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 var pD = this.m_localAnchorD;\n var pB = Rot.mulTVec2(xfD.q, Vec2.add(Rot.mul(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 // Solver temp\n this.m_lcA, this.m_lcB, this.m_lcC, this.m_lcD; // Vec2\n this.m_mA, this.m_mB, this.m_mC, this.m_mD; // float\n this.m_iA, this.m_iB, this.m_iC, this.m_iD; // float\n this.m_JvAC, this.m_JvBD; // Vec2\n this.m_JwA, this.m_JwB, this.m_JwC, this.m_JwD; // float\n this.m_mass; // float\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\nGearJoint.prototype._serialize = function() {\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\nGearJoint._deserialize = function(data, world, restore) {\n data = Object.assign({}, 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 var joint = new GearJoint(data);\n // if (data._constant) joint.m_constant = data._constant;\n return joint;\n};\n\n/**\n * Get the first joint.\n */\nGearJoint.prototype.getJoint1 = function() {\n return this.m_joint1;\n}\n\n/**\n * Get the second joint.\n */\nGearJoint.prototype.getJoint2 = function() {\n return this.m_joint2;\n}\n\n/**\n * Set/Get the gear ratio.\n */\nGearJoint.prototype.setRatio = function(ratio) {\n _ASSERT && common.assert(Math.isFinite(ratio));\n this.m_ratio = ratio;\n}\n\nGearJoint.prototype.getRatio = function() {\n return this.m_ratio;\n}\n\nGearJoint.prototype.getAnchorA = function() {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n}\n\nGearJoint.prototype.getAnchorB = function() {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n}\n\nGearJoint.prototype.getReactionForce = function(inv_dt) {\n return Vec2.mul(this.m_impulse, this.m_JvAC).mul(inv_dt);\n}\n\nGearJoint.prototype.getReactionTorque = function(inv_dt) {\n var L = this.m_impulse * this.m_JwA; // float\n return inv_dt * L;\n}\n\nGearJoint.prototype.initVelocityConstraints = function(step) {\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 var aA = this.m_bodyA.c_position.a;\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n\n var aB = this.m_bodyB.c_position.a;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n\n var aC = this.m_bodyC.c_position.a;\n var vC = this.m_bodyC.c_velocity.v;\n var wC = this.m_bodyC.c_velocity.w;\n\n var aD = this.m_bodyD.c_position.a;\n var vD = this.m_bodyD.c_velocity.v;\n var wD = this.m_bodyD.c_velocity.w;\n\n var qA = Rot.neo(aA);\n var qB = Rot.neo(aB);\n var qC = Rot.neo(aC);\n var 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 var u = Rot.mulVec2(qC, this.m_localAxisC); // Vec2\n var rC = Rot.mulSub(qC, this.m_localAnchorC, this.m_lcC); // Vec2\n var rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_lcA); // Vec2\n this.m_JvAC = u;\n this.m_JwC = Vec2.cross(rC, u);\n this.m_JwA = Vec2.cross(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 var u = Rot.mulVec2(qD, this.m_localAxisD); // Vec2\n var rD = Rot.mulSub(qD, this.m_localAnchorD, this.m_lcD); // Vec2\n var rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_lcB); // Vec2\n this.m_JvBD = Vec2.mul(this.m_ratio, u);\n this.m_JwD = this.m_ratio * Vec2.cross(rD, u);\n this.m_JwB = this.m_ratio * Vec2.cross(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.set(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.set(vB);\n this.m_bodyB.c_velocity.w = wB;\n this.m_bodyC.c_velocity.v.set(vC);\n this.m_bodyC.c_velocity.w = wC;\n this.m_bodyD.c_velocity.v.set(vD);\n this.m_bodyD.c_velocity.w = wD;\n}\n\nGearJoint.prototype.solveVelocityConstraints = function(step) {\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n var vC = this.m_bodyC.c_velocity.v;\n var wC = this.m_bodyC.c_velocity.w;\n var vD = this.m_bodyD.c_velocity.v;\n var wD = this.m_bodyD.c_velocity.w;\n\n var Cdot = Vec2.dot(this.m_JvAC, vA) - Vec2.dot(this.m_JvAC, vC)\n + Vec2.dot(this.m_JvBD, vB) - Vec2.dot(this.m_JvBD, vD); // float\n Cdot += (this.m_JwA * wA - this.m_JwC * wC)\n + (this.m_JwB * wB - this.m_JwD * wD);\n\n var impulse = -this.m_mass * Cdot; // float\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.set(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.set(vB);\n this.m_bodyB.c_velocity.w = wB;\n this.m_bodyC.c_velocity.v.set(vC);\n this.m_bodyC.c_velocity.w = wC;\n this.m_bodyD.c_velocity.v.set(vD);\n this.m_bodyD.c_velocity.w = wD;\n}\n\nGearJoint.prototype.solvePositionConstraints = function(step) {\n var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n var cC = this.m_bodyC.c_position.c;\n var aC = this.m_bodyC.c_position.a;\n var cD = this.m_bodyD.c_position.c;\n var aD = this.m_bodyD.c_position.a;\n\n var qA = Rot.neo(aA);\n var qB = Rot.neo(aB);\n var qC = Rot.neo(aC);\n var qD = Rot.neo(aD);\n\n var linearError = 0.0; // float\n\n var coordinateA, coordinateB; // float\n\n var JvAC, JvBD; // Vec2\n var JwA, JwB, JwC, JwD; // float\n var mass = 0.0; // float\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 var u = Rot.mulVec2(qC, this.m_localAxisC); // Vec2\n var rC = Rot.mulSub(qC, this.m_localAnchorC, this.m_lcC); // Vec2\n var rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_lcA); // Vec2\n JvAC = u;\n JwC = Vec2.cross(rC, u);\n JwA = Vec2.cross(rA, u);\n mass += this.m_mC + this.m_mA + this.m_iC * JwC * JwC + this.m_iA * JwA * JwA;\n\n var pC = Vec2.sub(this.m_localAnchorC, this.m_lcC); // Vec2\n var pA = Rot.mulTVec2(qC, Vec2.add(rA, Vec2.sub(cA, cC))); // Vec2\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 var u = Rot.mulVec2(qD, this.m_localAxisD);\n var rD = Rot.mulSub(qD, this.m_localAnchorD, this.m_lcD);\n var rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_lcB);\n JvBD = Vec2.mul(this.m_ratio, u);\n JwD = this.m_ratio * Vec2.cross(rD, u);\n JwB = this.m_ratio * Vec2.cross(rB, u);\n mass += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD\n * JwD * JwD + this.m_iB * JwB * JwB;\n\n var pD = Vec2.sub(this.m_localAnchorD, this.m_lcD); // Vec2\n var pB = Rot.mulTVec2(qD, Vec2.add(rB, Vec2.sub(cB, cD))); // Vec2\n coordinateB = Vec2.dot(pB, this.m_localAxisD)\n - Vec2.dot(pD, this.m_localAxisD);\n }\n\n var C = (coordinateA + this.m_ratio * coordinateB) - this.m_constant; // float\n\n var impulse = 0.0; // float\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.set(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.set(cB);\n this.m_bodyB.c_position.a = aB;\n this.m_bodyC.c_position.c.set(cC);\n this.m_bodyC.c_position.a = aC;\n this.m_bodyD.c_position.c.set(cD);\n this.m_bodyD.c_position.a = aD;\n\n // TODO_ERIN not implemented\n return linearError < Settings.linearSlop;\n}\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = MotorJoint;\n\nvar common = require('../util/common');\nvar options = require('../util/options');\nvar Settings = require('../Settings');\n\nvar Math = require('../common/Math');\nvar Vec2 = require('../common/Vec2');\nvar Vec3 = require('../common/Vec3');\nvar Mat22 = require('../common/Mat22');\nvar Mat33 = require('../common/Mat33');\nvar Rot = require('../common/Rot');\nvar Sweep = require('../common/Sweep');\nvar Transform = require('../common/Transform');\nvar Velocity = require('../common/Velocity');\nvar Position = require('../common/Position');\n\nvar Joint = require('../Joint');\nvar Body = require('../Body');\n\nMotorJoint.TYPE = 'motor-joint';\nJoint.TYPES[MotorJoint.TYPE] = MotorJoint;\n\nMotorJoint._super = Joint;\nMotorJoint.prototype = Object.create(MotorJoint._super.prototype);\n\n/**\n * @typedef {Object} MotorJointDef\n *\n * Motor joint definition.\n * \n * @prop {float} angularOffset The bodyB angle minus bodyA angle in radians.\n * @prop {float} maxForce The maximum motor force in N.\n * @prop {float} maxTorque The maximum motor torque in N-m.\n * @prop {float} correctionFactor Position correction factor in the range [0,1].\n * @prop {Vec2} linearOffset Position of bodyB minus the position of bodyA, in\n * bodyA's frame, in meters.\n */\n\nvar DEFAULTS = {\n maxForce : 1.0,\n maxTorque : 1.0,\n correctionFactor : 0.3\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 * @param {MotorJointDef} def\n * @param {Body} bodyA\n * @param {Body} bodyB\n */\nfunction MotorJoint(def, bodyA, bodyB) {\n if (!(this instanceof MotorJoint)) {\n return new MotorJoint(def, bodyA, bodyB);\n }\n\n def = options(def, DEFAULTS);\n Joint.call(this, 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 = Math.isFinite(def.linearOffset) ? def.linearOffset : bodyA.getLocalPoint(bodyB.getPosition());\n this.m_angularOffset = Math.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 // Solver temp\n this.m_rA; // Vec2\n this.m_rB; // Vec2\n this.m_localCenterA; // Vec2\n this.m_localCenterB; // Vec2\n this.m_linearError; // Vec2\n this.m_angularError; // float\n this.m_invMassA; // float\n this.m_invMassB; // float\n this.m_invIA; // float\n this.m_invIB; // float\n this.m_linearMass; // Mat22\n this.m_angularMass; // float\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\nMotorJoint.prototype._serialize = function() {\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\nMotorJoint._deserialize = function(data, world, restore) {\n data = Object.assign({}, data);\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n var joint = new MotorJoint(data);\n return joint;\n};\n\n/**\n * @internal\n */\nMotorJoint.prototype._setAnchors = function(def) {\n if (def.anchorA) {\n this.m_localAnchorA.set(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.set(def.localAnchorA);\n }\n\n if (def.anchorB) {\n this.m_localAnchorB.set(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.set(def.localAnchorB);\n }\n}\n\n/**\n * Set the maximum friction force in N.\n */\nMotorJoint.prototype.setMaxForce = function(force) {\n _ASSERT && common.assert(Math.isFinite(force) && force >= 0.0);\n this.m_maxForce = force;\n}\n\n/**\n * Get the maximum friction force in N.\n */\nMotorJoint.prototype.getMaxForce = function() {\n return this.m_maxForce;\n}\n\n/**\n * Set the maximum friction torque in N*m.\n */\nMotorJoint.prototype.setMaxTorque = function(torque) {\n _ASSERT && common.assert(Math.isFinite(torque) && torque >= 0.0);\n this.m_maxTorque = torque;\n}\n\n/**\n * Get the maximum friction torque in N*m.\n */\nMotorJoint.prototype.getMaxTorque = function() {\n return this.m_maxTorque;\n}\n\n/**\n * Set the position correction factor in the range [0,1].\n */\nMotorJoint.prototype.setCorrectionFactor = function(factor) {\n _ASSERT && common.assert(Math.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 */\nMotorJoint.prototype.getCorrectionFactor = function() {\n return this.m_correctionFactor;\n}\n\n/**\n * Set/get the target linear offset, in frame A, in meters.\n */\nMotorJoint.prototype.setLinearOffset = function(linearOffset) {\n if (linearOffset.x != this.m_linearOffset.x\n || linearOffset.y != this.m_linearOffset.y) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_linearOffset = linearOffset;\n }\n}\n\nMotorJoint.prototype.getLinearOffset = function() {\n return this.m_linearOffset;\n}\n\n/**\n * Set/get the target angular offset, in radians.\n */\nMotorJoint.prototype.setAngularOffset = function(angularOffset) {\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\nMotorJoint.prototype.getAngularOffset = function() {\n return this.m_angularOffset;\n}\n\nMotorJoint.prototype.getAnchorA = function() {\n return this.m_bodyA.getPosition();\n}\n\nMotorJoint.prototype.getAnchorB = function() {\n return this.m_bodyB.getPosition();\n}\n\nMotorJoint.prototype.getReactionForce = function(inv_dt) {\n return Vec2.mul(inv_dt, this.m_linearImpulse);\n}\n\nMotorJoint.prototype.getReactionTorque = function(inv_dt) {\n return inv_dt * this.m_angularImpulse;\n}\n\nMotorJoint.prototype.initVelocityConstraints = function(step) {\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 var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n\n var qA = Rot.neo(aA), qB = Rot.neo(aB);\n\n // Compute the effective mass matrix.\n this.m_rA = Rot.mulVec2(qA, Vec2.neg(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 // [ 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 var mA = this.m_invMassA;\n var mB = this.m_invMassB;\n var iA = this.m_invIA;\n var iB = this.m_invIB;\n\n var 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 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 this.m_linearError.sub(Rot.mulVec2(qA, this.m_linearOffset));\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 var P = Vec2.neo(this.m_linearImpulse.x, this.m_linearImpulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.cross(this.m_rA, P) + this.m_angularImpulse);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.cross(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\nMotorJoint.prototype.solveVelocityConstraints = function(step) {\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n\n var mA = this.m_invMassA, mB = this.m_invMassB;\n var iA = this.m_invIA, iB = this.m_invIB;\n\n var h = step.dt;\n var inv_h = step.inv_dt;\n\n // Solve angular friction\n {\n var Cdot = wB - wA + inv_h * this.m_correctionFactor * this.m_angularError;\n var impulse = -this.m_angularMass * Cdot;\n\n var oldImpulse = this.m_angularImpulse;\n var maxImpulse = h * this.m_maxTorque;\n this.m_angularImpulse = Math.clamp(this.m_angularImpulse + impulse,\n -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 var Cdot = Vec2.zero();\n Cdot.addCombine(1, vB, 1, Vec2.cross(wB, this.m_rB));\n Cdot.subCombine(1, vA, 1, Vec2.cross(wA, this.m_rA));\n Cdot.addMul(inv_h * this.m_correctionFactor, this.m_linearError);\n\n var impulse = Vec2.neg(Mat22.mulVec2(this.m_linearMass, Cdot));\n var oldImpulse = Vec2.clone(this.m_linearImpulse);\n this.m_linearImpulse.add(impulse);\n\n var 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.cross(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.cross(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\nMotorJoint.prototype.solvePositionConstraints = function(step) {\n return true;\n}\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = MouseJoint;\n\nvar common = require('../util/common');\nvar options = require('../util/options');\n\nvar Math = require('../common/Math');\nvar Vec2 = require('../common/Vec2');\nvar Vec3 = require('../common/Vec3');\nvar Mat22 = require('../common/Mat22');\nvar Mat33 = require('../common/Mat33');\nvar Rot = require('../common/Rot');\nvar Sweep = require('../common/Sweep');\nvar Transform = require('../common/Transform');\nvar Velocity = require('../common/Velocity');\nvar Position = require('../common/Position');\n\nvar Joint = require('../Joint');\nvar Body = require('../Body');\n\nMouseJoint.TYPE = 'mouse-joint';\nJoint.TYPES[MouseJoint.TYPE] = MouseJoint;\n\nMouseJoint._super = Joint;\nMouseJoint.prototype = Object.create(MouseJoint._super.prototype);\n\n/**\n * @typedef {Object} MouseJointDef\n *\n * Mouse joint definition. This requires a world target point, tuning\n * parameters, and the time step.\n * \n * @prop [maxForce = 0.0] The maximum constraint force that can be exerted to\n * move the candidate body. Usually you will express as some multiple of\n * the weight (multiplier * mass * gravity).\n * @prop [frequencyHz = 5.0] The response speed.\n * @prop [dampingRatio = 0.7] The damping ratio. 0 = no damping, 1 = critical\n * damping.\n *\n * @prop {Vec2} target The initial world target point. This is assumed to\n * coincide with the body anchor initially.\n */\n\nvar DEFAULTS = {\n maxForce : 0.0,\n frequencyHz : 5.0,\n dampingRatio : 0.7\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 * 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 * @param {MouseJointDef} def\n * @param {Body} bodyA\n * @param {Body} bodyB\n */\nfunction MouseJoint(def, bodyA, bodyB, target) {\n if (!(this instanceof MouseJoint)) {\n return new MouseJoint(def, bodyA, bodyB, target);\n }\n\n def = options(def, DEFAULTS);\n Joint.call(this, def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = MouseJoint.TYPE;\n\n _ASSERT && common.assert(Math.isFinite(def.maxForce) && def.maxForce >= 0.0);\n _ASSERT && common.assert(Math.isFinite(def.frequencyHz) && def.frequencyHz >= 0.0);\n _ASSERT && common.assert(Math.isFinite(def.dampingRatio) && def.dampingRatio >= 0.0);\n\n this.m_targetA = target ? Vec2.clone(target) : def.target || Vec2.zero();\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.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\nMouseJoint.prototype._serialize = function() {\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\nMouseJoint._deserialize = function(data, world, restore) {\n data = Object.assign({}, data);\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.target = Vec2(data.target);\n var joint = new MouseJoint(data);\n if (data._localAnchorB) {\n joint.m_localAnchorB = data._localAnchorB;\n }\n return joint;\n};\n\n/**\n * Use this to update the target point.\n */\nMouseJoint.prototype.setTarget = function(target) {\n if (this.m_bodyB.isAwake() == false) {\n this.m_bodyB.setAwake(true);\n }\n this.m_targetA = Vec2.clone(target);\n}\n\nMouseJoint.prototype.getTarget = function() {\n return this.m_targetA;\n}\n\n/**\n * Set/get the maximum force in Newtons.\n */\nMouseJoint.prototype.setMaxForce = function(force) {\n this.m_maxForce = force;\n}\n\nMouseJoint.getMaxForce = function() {\n return this.m_maxForce;\n}\n\n/**\n * Set/get the frequency in Hertz.\n */\nMouseJoint.prototype.setFrequency = function(hz) {\n this.m_frequencyHz = hz;\n}\n\nMouseJoint.prototype.getFrequency = function() {\n return this.m_frequencyHz;\n}\n\n/**\n * Set/get the damping ratio (dimensionless).\n */\nMouseJoint.prototype.setDampingRatio = function(ratio) {\n this.m_dampingRatio = ratio;\n}\n\nMouseJoint.prototype.getDampingRatio = function() {\n return this.m_dampingRatio;\n}\n\nMouseJoint.prototype.getAnchorA = function() {\n return Vec2.clone(this.m_targetA);\n}\n\nMouseJoint.prototype.getAnchorB = function() {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n}\n\nMouseJoint.prototype.getReactionForce = function(inv_dt) {\n return Vec2.mul(inv_dt, this.m_impulse);\n}\n\nMouseJoint.prototype.getReactionTorque = function(inv_dt) {\n return inv_dt * 0.0;\n}\n\nMouseJoint.prototype.shiftOrigin = function(newOrigin) {\n this.m_targetA.sub(newOrigin);\n}\n\nMouseJoint.prototype.initVelocityConstraints = function(step) {\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 var position = this.m_bodyB.c_position;\n var velocity = this.m_bodyB.c_velocity;\n\n var cB = position.c;\n var aB = position.a;\n var vB = velocity.v;\n var wB = velocity.w;\n\n var qB = Rot.neo(aB);\n\n var mass = this.m_bodyB.getMass();\n\n // Frequency\n var omega = 2.0 * Math.PI * this.m_frequencyHz;\n\n // Damping coefficient\n var d = 2.0 * mass * this.m_dampingRatio * omega;\n\n // Spring stiffness\n var k = mass * (omega * omega);\n\n // magic formulas\n // gamma has units of inverse mass.\n // beta has units of inverse time.\n var h = step.dt;\n _ASSERT && common.assert(d + h * k > Math.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 var 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.set(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.cross(this.m_rB, this.m_impulse);\n\n } else {\n this.m_impulse.setZero();\n }\n\n velocity.v.set(vB);\n velocity.w = wB;\n}\n\nMouseJoint.prototype.solveVelocityConstraints = function(step) {\n var velocity = this.m_bodyB.c_velocity;\n var vB = Vec2.clone(velocity.v);\n var wB = velocity.w;\n\n // Cdot = v + cross(w, r)\n\n var Cdot = Vec2.cross(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 var impulse = Mat22.mulVec2(this.m_mass, Cdot);\n\n var oldImpulse = Vec2.clone(this.m_impulse);\n this.m_impulse.add(impulse);\n var 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.cross(this.m_rB, impulse);\n\n velocity.v.set(vB);\n velocity.w = wB;\n}\n\nMouseJoint.prototype.solvePositionConstraints = function(step) {\n return true;\n}\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = PrismaticJoint;\n\nvar common = require('../util/common');\nvar options = require('../util/options');\nvar Settings = require('../Settings');\n\nvar Math = require('../common/Math');\nvar Vec2 = require('../common/Vec2');\nvar Vec3 = require('../common/Vec3');\nvar Mat22 = require('../common/Mat22');\nvar Mat33 = require('../common/Mat33');\nvar Rot = require('../common/Rot');\nvar Sweep = require('../common/Sweep');\nvar Transform = require('../common/Transform');\nvar Velocity = require('../common/Velocity');\nvar Position = require('../common/Position');\n\nvar Joint = require('../Joint');\nvar Body = require('../Body');\n\nvar inactiveLimit = 0;\nvar atLowerLimit = 1;\nvar atUpperLimit = 2;\nvar equalLimits = 3;\n\nPrismaticJoint.TYPE = 'prismatic-joint';\nJoint.TYPES[PrismaticJoint.TYPE] = PrismaticJoint;\n\nPrismaticJoint._super = Joint;\nPrismaticJoint.prototype = Object.create(PrismaticJoint._super.prototype);\n\n/**\n * @typedef {Object} PrismaticJointDef\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 * \n * @prop {boolean} enableLimit Enable/disable the joint limit.\n * @prop {float} lowerTranslation The lower translation limit, usually in\n * meters.\n * @prop {float} upperTranslation The upper translation limit, usually in\n * meters.\n * @prop {boolean} enableMotor Enable/disable the joint motor.\n * @prop {float} maxMotorForce The maximum motor torque, usually in N-m.\n * @prop {float} motorSpeed The desired motor speed in radians per second.\n *\n * @prop {Vec2} localAnchorA The local anchor point relative to bodyA's origin.\n * @prop {Vec2} localAnchorB The local anchor point relative to bodyB's origin.\n * @prop {Vec2} localAxisA The local translation unit axis in bodyA.\n * @prop {float} referenceAngle The constrained angle between the bodies:\n * bodyB_angle - bodyA_angle.\n */\n\nvar 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\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 * @param {PrismaticJointDef} def\n * @param {Body} bodyA\n * @param {Body} bodyB\n */\nfunction PrismaticJoint(def, bodyA, bodyB, anchor, axis) {\n if (!(this instanceof PrismaticJoint)) {\n return new PrismaticJoint(def, bodyA, bodyB, anchor, axis);\n }\n\n def = options(def, DEFAULTS);\n Joint.call(this, 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.cross(1.0, this.m_localXAxisA);\n this.m_referenceAngle = Math.isFinite(def.referenceAngle) ? def.referenceAngle : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_impulse = 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 = inactiveLimit;\n\n this.m_axis = Vec2.zero();\n this.m_perp = Vec2.zero();\n\n // Solver temp\n this.m_localCenterA; // Vec2\n this.m_localCenterB; // Vec2\n this.m_invMassA; // float\n this.m_invMassB; // float\n this.m_invIA; // float\n this.m_invIB; // float\n this.m_axis, this.m_perp; // Vec2\n this.m_s1, this.m_s2; // float\n this.m_a1, this.m_a2; // float\n this.m_K = new Mat33();\n this.m_motorMass; // float\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\nPrismaticJoint.prototype._serialize = function() {\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\nPrismaticJoint._deserialize = function(data, world, restore) {\n data = Object.assign({}, data);\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n data.localAxisA = Vec2(data.localAxisA);\n var joint = new PrismaticJoint(data);\n return joint;\n};\n\n/**\n * @internal\n */\nPrismaticJoint.prototype._setAnchors = function(def) {\n if (def.anchorA) {\n this.m_localAnchorA.set(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.set(def.localAnchorA);\n }\n\n if (def.anchorB) {\n this.m_localAnchorB.set(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.set(def.localAnchorB);\n }\n\n if (def.localAxisA) {\n this.m_localXAxisA.set(def.localAxisA);\n this.m_localYAxisA.set(Vec2.cross(1.0, def.localAxisA));\n }\n}\n\n/**\n * The local anchor point relative to bodyA's origin.\n */\nPrismaticJoint.prototype.getLocalAnchorA = function() {\n return this.m_localAnchorA;\n}\n\n/**\n * The local anchor point relative to bodyB's origin.\n */\nPrismaticJoint.prototype.getLocalAnchorB = function() {\n return this.m_localAnchorB;\n}\n\n/**\n * The local joint axis relative to bodyA.\n */\nPrismaticJoint.prototype.getLocalAxisA = function() {\n return this.m_localXAxisA;\n}\n\n/**\n * Get the reference angle.\n */\nPrismaticJoint.prototype.getReferenceAngle = function() {\n return this.m_referenceAngle;\n}\n\n/**\n * Get the current joint translation, usually in meters.\n */\nPrismaticJoint.prototype.getJointTranslation = function() {\n var pA = this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n var pB = this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n var d = Vec2.sub(pB, pA);\n var axis = this.m_bodyA.getWorldVector(this.m_localXAxisA);\n\n var translation = Vec2.dot(d, axis);\n return translation;\n}\n\n/**\n * Get the current joint translation speed, usually in meters per second.\n */\nPrismaticJoint.prototype.getJointSpeed = function() {\n var bA = this.m_bodyA;\n var bB = this.m_bodyB;\n\n var rA = Rot.mulVec2(bA.m_xf.q, Vec2.sub(this.m_localAnchorA, bA.m_sweep.localCenter)); // Vec2\n var rB = Rot.mulVec2(bB.m_xf.q, Vec2.sub(this.m_localAnchorB, bB.m_sweep.localCenter)); // Vec2\n var p1 = Vec2.add(bA.m_sweep.c, rA); // Vec2\n var p2 = Vec2.add(bB.m_sweep.c, rB); // Vec2\n var d = Vec2.sub(p2, p1); // Vec2\n var axis = Rot.mulVec2(bA.m_xf.q, this.m_localXAxisA); // Vec2\n\n var vA = bA.m_linearVelocity; // Vec2\n var vB = bB.m_linearVelocity; // Vec2\n var wA = bA.m_angularVelocity; // float\n var wB = bB.m_angularVelocity; // float\n\n var speed = Vec2.dot(d, Vec2.cross(wA, axis))\n + Vec2.dot(axis, Vec2.sub(Vec2.addCross(vB, wB, rB), Vec2.addCross(vA, wA, rA))); // float\n return speed;\n}\n\n/**\n * Is the joint limit enabled?\n */\nPrismaticJoint.prototype.isLimitEnabled = function() {\n return this.m_enableLimit;\n}\n\n/**\n * Enable/disable the joint limit.\n */\nPrismaticJoint.prototype.enableLimit = function(flag) {\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 */\nPrismaticJoint.prototype.getLowerLimit = function() {\n return this.m_lowerTranslation;\n}\n\n/**\n * Get the upper joint limit, usually in meters.\n */\nPrismaticJoint.prototype.getUpperLimit = function() {\n return this.m_upperTranslation;\n}\n\n/**\n * Set the joint limits, usually in meters.\n */\nPrismaticJoint.prototype.setLimits = function(lower, upper) {\n _ASSERT && common.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 */\nPrismaticJoint.prototype.isMotorEnabled = function() {\n return this.m_enableMotor;\n}\n\n/**\n * Enable/disable the joint motor.\n */\nPrismaticJoint.prototype.enableMotor = function(flag) {\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 */\nPrismaticJoint.prototype.setMotorSpeed = function(speed) {\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 */\nPrismaticJoint.prototype.setMaxMotorForce = function(force) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorForce = force;\n}\n\nPrismaticJoint.prototype.getMaxMotorForce = function() {\n return this.m_maxMotorForce;\n}\n\n/**\n * Get the motor speed, usually in meters per second.\n */\nPrismaticJoint.prototype.getMotorSpeed = function() {\n return this.m_motorSpeed;\n}\n\n/**\n * Get the current motor force given the inverse time step, usually in N.\n */\nPrismaticJoint.prototype.getMotorForce = function(inv_dt) {\n return inv_dt * this.m_motorImpulse;\n}\n\nPrismaticJoint.prototype.getAnchorA = function() {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n}\n\nPrismaticJoint.prototype.getAnchorB = function() {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n}\n\nPrismaticJoint.prototype.getReactionForce = function(inv_dt) {\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\nPrismaticJoint.prototype.getReactionTorque = function(inv_dt) {\n return inv_dt * this.m_impulse.y;\n}\n\nPrismaticJoint.prototype.initVelocityConstraints = function(step) {\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 var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n\n var qA = Rot.neo(aA);\n var qB = Rot.neo(aB);\n\n // Compute the effective masses.\n var rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n var rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n var d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n var mA = this.m_invMassA, mB = this.m_invMassB;\n var iA = this.m_invIA, 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.cross(Vec2.add(d, rA), this.m_axis);\n this.m_a2 = Vec2.cross(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.cross(Vec2.add(d, rA), this.m_perp);\n this.m_s2 = Vec2.cross(rB, this.m_perp);\n\n var s1test = Vec2.cross(rA, this.m_perp);\n\n var k11 = mA + mB + iA * this.m_s1 * this.m_s1 + iB * this.m_s2 * this.m_s2;\n var k12 = iA * this.m_s1 + iB * this.m_s2;\n var k13 = iA * this.m_s1 * this.m_a1 + iB * this.m_s2 * this.m_a2;\n var k22 = iA + iB;\n if (k22 == 0.0) {\n // For bodies with fixed rotation.\n k22 = 1.0;\n }\n var k23 = iA * this.m_a1 + iB * this.m_a2;\n var 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 var jointTranslation = Vec2.dot(this.m_axis, d); // float\n if (Math.abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * Settings.linearSlop) {\n this.m_limitState = equalLimits;\n\n } else if (jointTranslation <= this.m_lowerTranslation) {\n if (this.m_limitState != atLowerLimit) {\n this.m_limitState = atLowerLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else if (jointTranslation >= this.m_upperTranslation) {\n if (this.m_limitState != atUpperLimit) {\n this.m_limitState = atUpperLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_limitState = inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_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 var P = Vec2.combine(this.m_impulse.x, this.m_perp, this.m_motorImpulse\n + this.m_impulse.z, this.m_axis);\n var LA = this.m_impulse.x * this.m_s1 + this.m_impulse.y\n + (this.m_motorImpulse + this.m_impulse.z) * this.m_a1;\n var 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.set(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.set(vB);\n this.m_bodyB.c_velocity.w = wB;\n}\n\nPrismaticJoint.prototype.solveVelocityConstraints = function(step) {\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n\n var mA = this.m_invMassA;\n var mB = this.m_invMassB;\n var iA = this.m_invIA;\n var iB = this.m_invIB;\n\n // Solve linear motor constraint.\n if (this.m_enableMotor && this.m_limitState != equalLimits) {\n var Cdot = Vec2.dot(this.m_axis, Vec2.sub(vB, vA)) + this.m_a2 * wB\n - this.m_a1 * wA;\n var impulse = this.m_motorMass * (this.m_motorSpeed - Cdot);\n var oldImpulse = this.m_motorImpulse;\n var maxImpulse = step.dt * this.m_maxMotorForce;\n this.m_motorImpulse = Math.clamp(this.m_motorImpulse + impulse,\n -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n\n var P = Vec2.mul(impulse, this.m_axis);\n var LA = impulse * this.m_a1;\n var 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 var 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 != inactiveLimit) {\n // Solve prismatic and limit constraint in block form.\n var 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 var Cdot = Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n var f1 = Vec3(this.m_impulse);\n var df = this.m_K.solve33(Vec3.neg(Cdot)); // Vec3\n this.m_impulse.add(df);\n\n if (this.m_limitState == atLowerLimit) {\n this.m_impulse.z = Math.max(this.m_impulse.z, 0.0);\n } else if (this.m_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 var b = Vec2.combine(-1, Cdot1, -(this.m_impulse.z - f1.z), Vec2.neo(this.m_K.ez.x, this.m_K.ez.y)); // Vec2\n var f2r = Vec2.add(this.m_K.solve22(b), Vec2.neo(f1.x, f1.y)); // Vec2\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 var P = Vec2.combine(df.x, this.m_perp, df.z, this.m_axis); // Vec2\n var LA = df.x * this.m_s1 + df.y + df.z * this.m_a1; // float\n var LB = df.x * this.m_s2 + df.y + df.z * this.m_a2; // float\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 var df = this.m_K.solve22(Vec2.neg(Cdot1)); // Vec2\n this.m_impulse.x += df.x;\n this.m_impulse.y += df.y;\n\n var P = Vec2.mul(df.x, this.m_perp); // Vec2\n var LA = df.x * this.m_s1 + df.y; // float\n var LB = df.x * this.m_s2 + df.y; // float\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\nPrismaticJoint.prototype.solvePositionConstraints = function(step) {\n var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n\n var qA = Rot.neo(aA);\n var qB = Rot.neo(aB);\n\n var mA = this.m_invMassA;\n var mB = this.m_invMassB;\n var iA = this.m_invIA;\n var iB = this.m_invIB;\n\n // Compute fresh Jacobians\n var rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA)); // Vec2\n var rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB)); // Vec2\n var d = Vec2.sub(Vec2.add(cB, rB), Vec2.add(cA, rA)); // Vec2\n\n var axis = Rot.mulVec2(qA, this.m_localXAxisA); // Vec2\n var a1 = Vec2.cross(Vec2.add(d, rA), axis); // float\n var a2 = Vec2.cross(rB, axis); // float\n var perp = Rot.mulVec2(qA, this.m_localYAxisA); // Vec2\n\n var s1 = Vec2.cross(Vec2.add(d, rA), perp); // float\n var s2 = Vec2.cross(rB, perp); // float\n\n var impulse = Vec3();\n var C1 = Vec2.zero(); // Vec2\n C1.x = Vec2.dot(perp, d);\n C1.y = aB - aA - this.m_referenceAngle;\n\n var linearError = Math.abs(C1.x); // float\n var angularError = Math.abs(C1.y); // float\n\n var linearSlop = Settings.linearSlop;\n var maxLinearCorrection = Settings.maxLinearCorrection;\n\n var active = false; // bool\n var C2 = 0.0; // float\n if (this.m_enableLimit) {\n\n var translation = Vec2.dot(axis, d); // float\n if (Math.abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * linearSlop) {\n // Prevent large angular corrections\n C2 = Math.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 = Math.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 = Math.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 var k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2; // float\n var k12 = iA * s1 + iB * s2; // float\n var k13 = iA * s1 * a1 + iB * s2 * a2; // float\n var k22 = iA + iB; // float\n if (k22 == 0.0) {\n // For fixed rotation\n k22 = 1.0;\n }\n var k23 = iA * a1 + iB * a2; // float\n var k33 = mA + mB + iA * a1 * a1 + iB * a2 * a2; // float\n\n var 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 var C = 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 var k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2; // float\n var k12 = iA * s1 + iB * s2; // float\n var k22 = iA + iB; // float\n if (k22 == 0.0) {\n k22 = 1.0;\n }\n\n var K = new Mat22();\n K.ex.set(k11, k12);\n K.ey.set(k12, k22);\n\n var impulse1 = K.solve(Vec2.neg(C1)); // Vec2\n impulse.x = impulse1.x;\n impulse.y = impulse1.y;\n impulse.z = 0.0;\n }\n\n var P = Vec2.combine(impulse.x, perp, impulse.z, axis); // Vec2\n var LA = impulse.x * s1 + impulse.y + impulse.z * a1; // float\n var LB = impulse.x * s2 + impulse.y + impulse.z * a2; // float\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 * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = PulleyJoint;\n\nvar common = require('../util/common');\nvar options = require('../util/options');\nvar Settings = require('../Settings');\n\nvar Math = require('../common/Math');\nvar Vec2 = require('../common/Vec2');\nvar Vec3 = require('../common/Vec3');\nvar Mat22 = require('../common/Mat22');\nvar Mat33 = require('../common/Mat33');\nvar Rot = require('../common/Rot');\nvar Sweep = require('../common/Sweep');\nvar Transform = require('../common/Transform');\nvar Velocity = require('../common/Velocity');\nvar Position = require('../common/Position');\n\nvar Joint = require('../Joint');\nvar Body = require('../Body');\n\nPulleyJoint.TYPE = 'pulley-joint';\nPulleyJoint.MIN_PULLEY_LENGTH = 2.0; // minPulleyLength\nJoint.TYPES[PulleyJoint.TYPE] = PulleyJoint;\n\nPulleyJoint._super = Joint;\nPulleyJoint.prototype = Object.create(PulleyJoint._super.prototype);\n\n/**\n * @typedef {Object} PulleyJointDef\n *\n * Pulley joint definition. This requires two ground anchors, two dynamic body\n * anchor points, and a pulley ratio.\n *\n * @prop {Vec2} groundAnchorA The first ground anchor in world coordinates.\n * This point never moves.\n * @prop {Vec2} groundAnchorB The second ground anchor in world coordinates.\n * This point never moves.\n * @prop {Vec2} localAnchorA The local anchor point relative to bodyA's origin.\n * @prop {Vec2} localAnchorB The local anchor point relative to bodyB's origin.\n * @prop {float} ratio The pulley ratio, used to simulate a block-and-tackle.\n * @prop {float} lengthA The reference length for the segment attached to bodyA.\n * @prop {float} lengthB The reference length for the segment attached to bodyB.\n */\nvar PulleyJointDef = {\n collideConnected : true\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 * @param {PulleyJointDef} def\n * @param {Body} bodyA\n * @param {Body} bodyB\n */\nfunction PulleyJoint(def, bodyA, bodyB, groundA, groundB, anchorA, anchorB, ratio) {\n if (!(this instanceof PulleyJoint)) {\n return new PulleyJoint(def, bodyA, bodyB, groundA, groundB, anchorA, anchorB, ratio);\n }\n\n def = options(def, PulleyJointDef);\n Joint.call(this, def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = PulleyJoint.TYPE;\n this.m_groundAnchorA = groundA ? groundA : def.groundAnchorA || Vec2.neo(-1.0, 1.0);\n this.m_groundAnchorB = groundB ? groundB : def.groundAnchorB || Vec2.neo(1.0, 1.0);\n this.m_localAnchorA = anchorA ? bodyA.getLocalPoint(anchorA) : def.localAnchorA || Vec2.neo(-1.0, 0.0);\n this.m_localAnchorB = anchorB ? bodyB.getLocalPoint(anchorB) : def.localAnchorB || Vec2.neo(1.0, 0.0);\n this.m_lengthA = Math.isFinite(def.lengthA) ? def.lengthA : Vec2.distance(anchorA, groundA);\n this.m_lengthB = Math.isFinite(def.lengthB) ? def.lengthB : Vec2.distance(anchorB, groundB);\n this.m_ratio = Math.isFinite(ratio) ? ratio : def.ratio;\n\n _ASSERT && common.assert(ratio > Math.EPSILON);\n\n this.m_constant = this.m_lengthA + this.m_ratio * this.m_lengthB;\n\n this.m_impulse = 0.0;\n\n // Solver temp\n this.m_uA; // Vec2\n this.m_uB; // Vec2\n this.m_rA; // Vec2\n this.m_rB; // Vec2\n this.m_localCenterA; // Vec2\n this.m_localCenterB; // Vec2\n this.m_invMassA; // float\n this.m_invMassB; // float\n this.m_invIA; // float\n this.m_invIB; // float\n this.m_mass; // float\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\nPulleyJoint.prototype._serialize = function() {\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\nPulleyJoint._deserialize = function(data, world, restore) {\n data = Object.assign({}, data);\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n var joint = new PulleyJoint(data);\n return joint;\n};\n\n/**\n * Get the first ground anchor.\n */\nPulleyJoint.prototype.getGroundAnchorA = function() {\n return this.m_groundAnchorA;\n}\n\n/**\n * Get the second ground anchor.\n */\nPulleyJoint.prototype.getGroundAnchorB = function() {\n return this.m_groundAnchorB;\n}\n\n/**\n * Get the current length of the segment attached to bodyA.\n */\nPulleyJoint.prototype.getLengthA = function() {\n return this.m_lengthA;\n}\n\n/**\n * Get the current length of the segment attached to bodyB.\n */\nPulleyJoint.prototype.getLengthB = function() {\n return this.m_lengthB;\n}\n\n/**\n * Get the pulley ratio.\n */\nPulleyJoint.prototype.getRatio = function() {\n return this.m_ratio;\n}\n\n/**\n * Get the current length of the segment attached to bodyA.\n */\nPulleyJoint.prototype.getCurrentLengthA = function() {\n var p = this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n var 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 */\nPulleyJoint.prototype.getCurrentLengthB = function() {\n var p = this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n var s = this.m_groundAnchorB;\n return Vec2.distance(p, s);\n}\n\nPulleyJoint.prototype.shiftOrigin = function(newOrigin) {\n this.m_groundAnchorA.sub(newOrigin);\n this.m_groundAnchorB.sub(newOrigin);\n}\n\nPulleyJoint.prototype.getAnchorA = function() {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n}\n\nPulleyJoint.prototype.getAnchorB = function() {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n}\n\nPulleyJoint.prototype.getReactionForce = function(inv_dt) {\n return Vec2.mul(this.m_impulse, this.m_uB).mul(inv_dt);\n}\n\nPulleyJoint.prototype.getReactionTorque = function(inv_dt) {\n return 0.0;\n}\n\nPulleyJoint.prototype.initVelocityConstraints = function(step) {\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 var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n\n var qA = Rot.neo(aA);\n var 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 var lengthA = this.m_uA.length();\n var 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 var ruA = Vec2.cross(this.m_rA, this.m_uA); // float\n var ruB = Vec2.cross(this.m_rB, this.m_uB); // float\n\n var mA = this.m_invMassA + this.m_invIA * ruA * ruA; // float\n var mB = this.m_invMassB + this.m_invIB * ruB * ruB; // float\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 var PA = Vec2.mul(-this.m_impulse, this.m_uA);\n var PB = Vec2.mul(-this.m_ratio * this.m_impulse, this.m_uB);\n\n vA.addMul(this.m_invMassA, PA);\n wA += this.m_invIA * Vec2.cross(this.m_rA, PA);\n\n vB.addMul(this.m_invMassB, PB);\n wB += this.m_invIB * Vec2.cross(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\nPulleyJoint.prototype.solveVelocityConstraints = function(step) {\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n\n var vpA = Vec2.add(vA, Vec2.cross(wA, this.m_rA));\n var vpB = Vec2.add(vB, Vec2.cross(wB, this.m_rB));\n\n var Cdot = -Vec2.dot(this.m_uA, vpA) - this.m_ratio\n * Vec2.dot(this.m_uB, vpB); // float\n var impulse = -this.m_mass * Cdot; // float\n this.m_impulse += impulse;\n\n var PA = Vec2.mul(-impulse, this.m_uA); // Vec2\n var PB = Vec2.mul(-this.m_ratio * impulse, this.m_uB); // Vec2\n vA.addMul(this.m_invMassA, PA);\n wA += this.m_invIA * Vec2.cross(this.m_rA, PA);\n vB.addMul(this.m_invMassB, PB);\n wB += this.m_invIB * Vec2.cross(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\nPulleyJoint.prototype.solvePositionConstraints = function(step) {\n var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n\n var qA = Rot.neo(aA), qB = Rot.neo(aB);\n\n var rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n var rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n // Get the pulley axes.\n var uA = Vec2.sub(Vec2.add(cA, this.m_rA), this.m_groundAnchorA);\n var uB = Vec2.sub(Vec2.add(cB, this.m_rB), this.m_groundAnchorB);\n\n var lengthA = uA.length();\n var 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 var ruA = Vec2.cross(rA, uA);\n var ruB = Vec2.cross(rB, uB);\n\n var mA = this.m_invMassA + this.m_invIA * ruA * ruA; // float\n var mB = this.m_invMassB + this.m_invIB * ruB * ruB; // float\n\n var mass = mA + this.m_ratio * this.m_ratio * mB; // float\n\n if (mass > 0.0) {\n mass = 1.0 / mass;\n }\n\n var C = this.m_constant - lengthA - this.m_ratio * lengthB; // float\n var linearError = Math.abs(C); // float\n\n var impulse = -mass * C; // float\n\n var PA = Vec2.mul(-impulse, uA); // Vec2\n var PB = Vec2.mul(-this.m_ratio * impulse, uB); // Vec2\n\n cA.addMul(this.m_invMassA, PA);\n aA += this.m_invIA * Vec2.cross(rA, PA);\n cB.addMul(this.m_invMassB, PB);\n aB += this.m_invIB * Vec2.cross(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 * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = RevoluteJoint;\n\nvar common = require('../util/common');\nvar options = require('../util/options');\nvar Settings = require('../Settings');\n\nvar Math = require('../common/Math');\nvar Vec2 = require('../common/Vec2');\nvar Vec3 = require('../common/Vec3');\nvar Mat22 = require('../common/Mat22');\nvar Mat33 = require('../common/Mat33');\nvar Rot = require('../common/Rot');\nvar Sweep = require('../common/Sweep');\nvar Transform = require('../common/Transform');\nvar Velocity = require('../common/Velocity');\nvar Position = require('../common/Position');\n\nvar Joint = require('../Joint');\nvar Body = require('../Body');\n\nvar inactiveLimit = 0;\nvar atLowerLimit = 1;\nvar atUpperLimit = 2;\nvar equalLimits = 3;\n\nRevoluteJoint.TYPE = 'revolute-joint';\nJoint.TYPES[RevoluteJoint.TYPE] = RevoluteJoint;\n\nRevoluteJoint._super = Joint;\nRevoluteJoint.prototype = Object.create(RevoluteJoint._super.prototype);\n\n/**\n * @typedef {Object} RevoluteJointDef\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 *\n * @prop {bool} enableLimit A flag to enable joint limits.\n * @prop {bool} enableMotor A flag to enable the joint motor.\n * @prop {float} lowerAngle The lower angle for the joint limit (radians).\n * @prop {float} upperAngle The upper angle for the joint limit (radians).\n * @prop {float} motorSpeed The desired motor speed. Usually in radians per\n * second.\n * @prop {float} maxMotorTorque The maximum motor torque used to achieve the\n * desired motor speed. Usually in N-m.\n *\n * @prop {Vec2} localAnchorA The local anchor point relative to bodyA's origin.\n * @prop {Vec2} localAnchorB The local anchor point relative to bodyB's origin.\n * @prop {float} referenceAngle The bodyB angle minus bodyA angle in the\n * reference state (radians).\n */\n\nvar 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\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 * @param {RevoluteJointDef} def\n * @param {Body} bodyA\n * @param {Body} bodyB\n */\nfunction RevoluteJoint(def, bodyA, bodyB, anchor) {\n if (!(this instanceof RevoluteJoint)) {\n return new RevoluteJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n Joint.call(this, def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = RevoluteJoint.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 = Math.isFinite(def.referenceAngle) ? def.referenceAngle : bodyB.getAngle() - bodyA.getAngle();\n\n this.m_impulse = Vec3();\n this.m_motorImpulse = 0.0;\n\n this.m_lowerAngle = def.lowerAngle;\n this.m_upperAngle = def.upperAngle;\n this.m_maxMotorTorque = def.maxMotorTorque;\n this.m_motorSpeed = def.motorSpeed;\n this.m_enableLimit = def.enableLimit;\n this.m_enableMotor = def.enableMotor;\n\n // Solver temp\n this.m_rA; // Vec2\n this.m_rB; // Vec2\n this.m_localCenterA; // Vec2\n this.m_localCenterB; // Vec2\n this.m_invMassA; // float\n this.m_invMassB; // float\n this.m_invIA; // float\n this.m_invIB; // float\n // effective mass for point-to-point constraint.\n this.m_mass = new Mat33();\n // effective mass for motor/limit angular constraint.\n this.m_motorMass; // float\n this.m_limitState = inactiveLimit;\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\nRevoluteJoint.prototype._serialize = function() {\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\nRevoluteJoint._deserialize = function(data, world, restore) {\n data = Object.assign({}, data);\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n var joint = new RevoluteJoint(data);\n return joint;\n};\n\n/**\n * @internal\n */\nRevoluteJoint.prototype._setAnchors = function(def) {\n if (def.anchorA) {\n this.m_localAnchorA.set(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.set(def.localAnchorA);\n }\n\n if (def.anchorB) {\n this.m_localAnchorB.set(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.set(def.localAnchorB);\n }\n}\n\n/**\n * The local anchor point relative to bodyA's origin.\n */\nRevoluteJoint.prototype.getLocalAnchorA = function() {\n return this.m_localAnchorA;\n}\n\n/**\n * The local anchor point relative to bodyB's origin.\n */\nRevoluteJoint.prototype.getLocalAnchorB = function() {\n return this.m_localAnchorB;\n}\n\n/**\n * Get the reference angle.\n */\nRevoluteJoint.prototype.getReferenceAngle = function() {\n return this.m_referenceAngle;\n}\n\n/**\n * Get the current joint angle in radians.\n */\nRevoluteJoint.prototype.getJointAngle = function() {\n var bA = this.m_bodyA;\n var 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 */\nRevoluteJoint.prototype.getJointSpeed = function() {\n var bA = this.m_bodyA;\n var bB = this.m_bodyB;\n return bB.m_angularVelocity - bA.m_angularVelocity;\n}\n\n/**\n * Is the joint motor enabled?\n */\nRevoluteJoint.prototype.isMotorEnabled = function() {\n return this.m_enableMotor;\n}\n\n/**\n * Enable/disable the joint motor.\n */\nRevoluteJoint.prototype.enableMotor = function(flag) {\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 */\nRevoluteJoint.prototype.getMotorTorque = function(inv_dt) {\n return inv_dt * this.m_motorImpulse;\n}\n\n/**\n * Set the motor speed in radians per second.\n */\nRevoluteJoint.prototype.setMotorSpeed = function(speed) {\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 */\nRevoluteJoint.prototype.getMotorSpeed = function() {\n return this.m_motorSpeed;\n}\n\n/**\n * Set the maximum motor torque, usually in N-m.\n */\nRevoluteJoint.prototype.setMaxMotorTorque = function(torque) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorTorque = torque;\n}\n\nRevoluteJoint.prototype.getMaxMotorTorque = function() {\n return this.m_maxMotorTorque;\n}\n\n/**\n * Is the joint limit enabled?\n */\nRevoluteJoint.prototype.isLimitEnabled = function() {\n return this.m_enableLimit;\n}\n\n/**\n * Enable/disable the joint limit.\n */\nRevoluteJoint.prototype.enableLimit = function(flag) {\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 */\nRevoluteJoint.prototype.getLowerLimit = function() {\n return this.m_lowerAngle;\n}\n\n/**\n * Get the upper joint limit in radians.\n */\nRevoluteJoint.prototype.getUpperLimit = function() {\n return this.m_upperAngle;\n}\n\n/**\n * Set the joint limits in radians.\n */\nRevoluteJoint.prototype.setLimits = function(lower, upper) {\n _ASSERT && common.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\nRevoluteJoint.prototype.getAnchorA = function() {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n}\n\nRevoluteJoint.prototype.getAnchorB = function() {\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 */\nRevoluteJoint.prototype.getReactionForce = function(inv_dt) {\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 */\nRevoluteJoint.prototype.getReactionTorque = function(inv_dt) {\n return inv_dt * this.m_impulse.z;\n}\n\nRevoluteJoint.prototype.initVelocityConstraints = function(step) {\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 var aA = this.m_bodyA.c_position.a;\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n\n var aB = this.m_bodyB.c_position.a;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n\n var qA = Rot.neo(aA);\n var 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 var mA = this.m_invMassA;\n var mB = this.m_invMassB; // float\n var iA = this.m_invIA;\n var iB = this.m_invIB; // float\n\n var fixedRotation = (iA + iB === 0.0); // bool\n\n this.m_mass.ex.x = mA + mB + this.m_rA.y * this.m_rA.y * iA + this.m_rB.y\n * this.m_rB.y * iB;\n this.m_mass.ey.x = -this.m_rA.y * this.m_rA.x * iA - this.m_rB.y\n * 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\n * 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 var jointAngle = aB - aA - this.m_referenceAngle; // float\n\n if (Math.abs(this.m_upperAngle - this.m_lowerAngle) < 2.0 * Settings.angularSlop) {\n this.m_limitState = equalLimits;\n\n } else if (jointAngle <= this.m_lowerAngle) {\n if (this.m_limitState != atLowerLimit) {\n this.m_impulse.z = 0.0;\n }\n this.m_limitState = atLowerLimit;\n\n } else if (jointAngle >= this.m_upperAngle) {\n if (this.m_limitState != atUpperLimit) {\n this.m_impulse.z = 0.0;\n }\n this.m_limitState = atUpperLimit;\n\n } else {\n this.m_limitState = inactiveLimit;\n this.m_impulse.z = 0.0;\n }\n\n } else {\n this.m_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 var P = Vec2.neo(this.m_impulse.x, this.m_impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.cross(this.m_rA, P) + this.m_motorImpulse + this.m_impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.cross(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\nRevoluteJoint.prototype.solveVelocityConstraints = function(step) {\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n\n var mA = this.m_invMassA;\n var mB = this.m_invMassB; // float\n var iA = this.m_invIA;\n var iB = this.m_invIB; // float\n\n var fixedRotation = (iA + iB === 0.0); // bool\n\n // Solve motor constraint.\n if (this.m_enableMotor && this.m_limitState != equalLimits\n && fixedRotation == false) {\n var Cdot = wB - wA - this.m_motorSpeed; // float\n var impulse = -this.m_motorMass * Cdot; // float\n var oldImpulse = this.m_motorImpulse; // float\n var maxImpulse = step.dt * this.m_maxMotorTorque; // float\n this.m_motorImpulse = Math.clamp(this.m_motorImpulse + impulse,\n -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 != inactiveLimit\n && fixedRotation == false) {\n var Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.cross(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.cross(wA, this.m_rA));\n var Cdot2 = wB - wA; // float\n var Cdot = Vec3(Cdot1.x, Cdot1.y, Cdot2);\n\n var impulse = Vec3.neg(this.m_mass.solve33(Cdot)); // Vec3\n\n if (this.m_limitState == equalLimits) {\n this.m_impulse.add(impulse);\n\n } else if (this.m_limitState == atLowerLimit) {\n var newImpulse = this.m_impulse.z + impulse.z; // float\n\n if (newImpulse < 0.0) {\n var rhs = Vec2.combine(-1, Cdot1, this.m_impulse.z, Vec2.neo(this.m_mass.ez.x, this.m_mass.ez.y)); // Vec2\n var reduced = this.m_mass.solve22(rhs); // Vec2\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 == atUpperLimit) {\n var newImpulse = this.m_impulse.z + impulse.z; // float\n\n if (newImpulse > 0.0) {\n var rhs = Vec2.combine(-1, Cdot1, this.m_impulse.z, Vec2.neo(this.m_mass.ez.x, this.m_mass.ez.y)); // Vec2\n var reduced = this.m_mass.solve22(rhs); // Vec2\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 var P = Vec2.neo(impulse.x, impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.cross(this.m_rA, P) + impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.cross(this.m_rB, P) + impulse.z);\n\n } else {\n // Solve point-to-point constraint\n var Cdot = Vec2.zero();\n Cdot.addCombine(1, vB, 1, Vec2.cross(wB, this.m_rB));\n Cdot.subCombine(1, vA, 1, Vec2.cross(wA, this.m_rA));\n var impulse = this.m_mass.solve22(Vec2.neg(Cdot)); // Vec2\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.cross(this.m_rA, impulse);\n\n vB.addMul(mB, impulse);\n wB += iB * Vec2.cross(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\nRevoluteJoint.prototype.solvePositionConstraints = function(step) {\n var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n\n var qA = Rot.neo(aA);\n var qB = Rot.neo(aB);\n\n var angularError = 0.0; // float\n var positionError = 0.0; // float\n\n var fixedRotation = (this.m_invIA + this.m_invIB == 0.0); // bool\n\n // Solve angular limit constraint.\n if (this.m_enableLimit && this.m_limitState != inactiveLimit\n && fixedRotation == false) {\n var angle = aB - aA - this.m_referenceAngle; // float\n var limitImpulse = 0.0; // float\n\n if (this.m_limitState == equalLimits) {\n // Prevent large angular corrections\n var C = Math.clamp(angle - this.m_lowerAngle,\n -Settings.maxAngularCorrection, Settings.maxAngularCorrection); // float\n limitImpulse = -this.m_motorMass * C;\n angularError = Math.abs(C);\n\n } else if (this.m_limitState == atLowerLimit) {\n var C = angle - this.m_lowerAngle; // float\n angularError = -C;\n\n // Prevent large angular corrections and allow some slop.\n C = Math.clamp(C + Settings.angularSlop, -Settings.maxAngularCorrection,\n 0.0);\n limitImpulse = -this.m_motorMass * C;\n\n } else if (this.m_limitState == atUpperLimit) {\n var C = angle - this.m_upperAngle; // float\n angularError = C;\n\n // Prevent large angular corrections and allow some slop.\n C = Math.clamp(C - Settings.angularSlop, 0.0,\n 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.set(aA);\n qB.set(aB);\n var rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA)); // Vec2\n var rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB)); // Vec2\n\n var C = Vec2.zero();\n C.addCombine(1, cB, 1, rB);\n C.subCombine(1, cA, 1, rA);\n positionError = C.length();\n\n var mA = this.m_invMassA;\n var mB = this.m_invMassB; // float\n var iA = this.m_invIA;\n var iB = this.m_invIB; // float\n\n var 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 var impulse = Vec2.neg(K.solve(C)); // Vec2\n\n cA.subMul(mA, impulse);\n aA -= iA * Vec2.cross(rA, impulse);\n\n cB.addMul(mB, impulse);\n aB += iB * Vec2.cross(rB, impulse);\n }\n\n this.m_bodyA.c_position.c.set(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.set(cB);\n this.m_bodyB.c_position.a = aB;\n\n return positionError <= Settings.linearSlop\n && angularError <= Settings.angularSlop;\n}\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = RopeJoint;\n\nvar options = require('../util/options');\nvar Settings = require('../Settings');\n\nvar Math = require('../common/Math');\nvar Vec2 = require('../common/Vec2');\nvar Vec3 = require('../common/Vec3');\nvar Mat22 = require('../common/Mat22');\nvar Mat33 = require('../common/Mat33');\nvar Rot = require('../common/Rot');\nvar Sweep = require('../common/Sweep');\nvar Transform = require('../common/Transform');\nvar Velocity = require('../common/Velocity');\nvar Position = require('../common/Position');\n\nvar Joint = require('../Joint');\nvar Body = require('../Body');\n\nvar inactiveLimit = 0;\nvar atLowerLimit = 1;\nvar atUpperLimit = 2;\nvar equalLimits = 3;\n\nRopeJoint.TYPE = 'rope-joint';\nJoint.TYPES[RopeJoint.TYPE] = RopeJoint;\n\nRopeJoint._super = Joint;\nRopeJoint.prototype = Object.create(RopeJoint._super.prototype);\n\n/**\n * @typedef {Object} RopeJointDef\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 *\n * @prop {float} maxLength The maximum length of the rope. Warning: this must be\n * larger than linearSlop or the joint will have no effect.\n *\n * @prop {Vec2} def.localAnchorA The local anchor point relative to bodyA's origin.\n * @prop {Vec2} def.localAnchorB The local anchor point relative to bodyB's origin.\n */\n\nvar DEFAULTS = {\n maxLength : 0.0,\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 DistanceJoint if you\n * want to dynamically control length.\n *\n * @param {RopeJointDef} def\n * @param {Body} bodyA\n * @param {Body} bodyB\n */\nfunction RopeJoint(def, bodyA, bodyB, anchor) {\n if (!(this instanceof RopeJoint)) {\n return new RopeJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n Joint.call(this, def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\n\n this.m_type = RopeJoint.TYPE;\n this.m_localAnchorA = anchor ? bodyA.getLocalPoint(anchor) : def.localAnchorA || Vec2.neo(-1.0, 0.0);\n this.m_localAnchorB = 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 = inactiveLimit;\n\n // Solver temp\n this.m_u; // Vec2\n this.m_rA; // Vec2\n this.m_rB; // Vec2\n this.m_localCenterA; // Vec2\n this.m_localCenterB; // Vec2\n this.m_invMassA; // float\n this.m_invMassB; // float\n this.m_invIA; // float\n this.m_invIB; // float\n this.m_mass; // float\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\nRopeJoint.prototype._serialize = function() {\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\nRopeJoint._deserialize = function(data, world, restore) {\n data = Object.assign({}, data);\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n var joint = new RopeJoint(data);\n return joint;\n};\n\n/**\n * The local anchor point relative to bodyA's origin.\n */\nRopeJoint.prototype.getLocalAnchorA = function() {\n return this.m_localAnchorA;\n}\n\n/**\n * The local anchor point relative to bodyB's origin.\n */\nRopeJoint.prototype.getLocalAnchorB = function() {\n return this.m_localAnchorB;\n}\n\n/**\n * Set/Get the maximum length of the rope.\n */\nRopeJoint.prototype.setMaxLength = function(length) {\n this.m_maxLength = length;\n}\n\nRopeJoint.prototype.getMaxLength = function() {\n return this.m_maxLength;\n}\n\nRopeJoint.prototype.getLimitState = function() {\n // TODO LimitState\n return this.m_state;\n}\n\nRopeJoint.prototype.getAnchorA = function() {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n}\n\nRopeJoint.prototype.getAnchorB = function() {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n}\n\nRopeJoint.prototype.getReactionForce = function(inv_dt) {\n return Vec2.mul(this.m_impulse, this.m_u).mul(inv_dt);\n}\n\nRopeJoint.prototype.getReactionTorque = function(inv_dt) {\n return 0.0;\n}\n\nRopeJoint.prototype.initVelocityConstraints = function(step) {\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 var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n\n var qA = Rot.neo(aA);\n var 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); // Vec2\n\n this.m_length = this.m_u.length();\n\n var C = this.m_length - this.m_maxLength; // float\n if (C > 0.0) {\n this.m_state = atUpperLimit;\n } else {\n this.m_state = 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 var crA = Vec2.cross(this.m_rA, this.m_u); // float\n var crB = Vec2.cross(this.m_rB, this.m_u); // float\n var invMass = this.m_invMassA + this.m_invIA * crA * crA + this.m_invMassB\n + this.m_invIB * crB * crB; // float\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 var P = Vec2.mul(this.m_impulse, this.m_u);\n \n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.cross(this.m_rA, P);\n \n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.cross(this.m_rB, P);\n \n } else {\n this.m_impulse = 0.0;\n }\n\n this.m_bodyA.c_velocity.v.set(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.set(vB);\n this.m_bodyB.c_velocity.w = wB;\n}\n\nRopeJoint.prototype.solveVelocityConstraints = function(step) {\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n\n // Cdot = dot(u, v + cross(w, r))\n var vpA = Vec2.addCross(vA, wA, this.m_rA); // Vec2\n var vpB = Vec2.addCross(vB, wB, this.m_rB); // Vec2\n var C = this.m_length - this.m_maxLength; // float\n var Cdot = Vec2.dot(this.m_u, Vec2.sub(vpB, vpA)); // float\n\n // Predictive constraint.\n if (C < 0.0) {\n Cdot += step.inv_dt * C;\n }\n\n var impulse = -this.m_mass * Cdot; // float\n var oldImpulse = this.m_impulse; // float\n this.m_impulse = Math.min(0.0, this.m_impulse + impulse);\n impulse = this.m_impulse - oldImpulse;\n\n var P = Vec2.mul(impulse, this.m_u); // Vec2\n vA.subMul(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.cross(this.m_rA, P);\n vB.addMul(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.cross(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\nRopeJoint.prototype.solvePositionConstraints = function(step) {\n var cA = this.m_bodyA.c_position.c; // Vec2\n var aA = this.m_bodyA.c_position.a; // float\n var cB = this.m_bodyB.c_position.c; // Vec2\n var aB = this.m_bodyB.c_position.a; // float\n\n var qA = Rot.neo(aA);\n var qB = Rot.neo(aB);\n\n var rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n var rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n var u = Vec2.zero();\n u.addCombine(1, cB, 1, rB);\n u.subCombine(1, cA, 1, rA); // Vec2\n\n var length = u.normalize(); // float\n var C = length - this.m_maxLength; // float\n\n C = Math.clamp(C, 0.0, Settings.maxLinearCorrection);\n\n var impulse = -this.m_mass * C; // float\n var P = Vec2.mul(impulse, u); // Vec2\n\n cA.subMul(this.m_invMassA, P);\n aA -= this.m_invIA * Vec2.cross(rA, P);\n cB.addMul(this.m_invMassB, P);\n aB += this.m_invIB * Vec2.cross(rB, P);\n\n this.m_bodyA.c_position.c.set(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.set(cB);\n this.m_bodyB.c_position.a = aB;\n\n return length - this.m_maxLength < Settings.linearSlop;\n}\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = WeldJoint;\n\nvar options = require('../util/options');\nvar Settings = require('../Settings');\n\nvar Math = require('../common/Math');\nvar Vec2 = require('../common/Vec2');\nvar Vec3 = require('../common/Vec3');\nvar Mat22 = require('../common/Mat22');\nvar Mat33 = require('../common/Mat33');\nvar Rot = require('../common/Rot');\nvar Sweep = require('../common/Sweep');\nvar Transform = require('../common/Transform');\nvar Velocity = require('../common/Velocity');\nvar Position = require('../common/Position');\n\nvar Joint = require('../Joint');\nvar Body = require('../Body');\n\nWeldJoint.TYPE = 'weld-joint';\nJoint.TYPES[WeldJoint.TYPE] = WeldJoint;\n\nWeldJoint._super = Joint;\nWeldJoint.prototype = Object.create(WeldJoint._super.prototype);\n\n/**\n * @typedef {Object} WeldJointDef\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 * \n * @prop {float} frequencyHz The mass-spring-damper frequency in Hertz. Rotation\n * only. Disable softness with a value of 0.\n * @prop {float} dampingRatio The damping ratio. 0 = no damping, 1 = critical\n * damping.\n *\n * @prop {Vec2} localAnchorA The local anchor point relative to bodyA's origin.\n * @prop {Vec2} localAnchorB The local anchor point relative to bodyB's origin.\n * @prop {float} referenceAngle The bodyB angle minus bodyA angle in the\n * reference state (radians).\n */\nvar DEFAULTS = {\n frequencyHz : 0.0,\n dampingRatio : 0.0,\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 * @param {WeldJointDef} def\n * @param {Body} bodyA\n * @param {Body} bodyB\n */\nfunction WeldJoint(def, bodyA, bodyB, anchor) {\n if (!(this instanceof WeldJoint)) {\n return new WeldJoint(def, bodyA, bodyB, anchor);\n }\n\n def = options(def, DEFAULTS);\n Joint.call(this, 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 = Math.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 = Vec3();\n\n this.m_bias = 0.0;\n this.m_gamma = 0.0;\n\n // Solver temp\n this.m_rA; // Vec2\n this.m_rB; // Vec2\n this.m_localCenterA; // Vec2\n this.m_localCenterB; // Vec2\n this.m_invMassA; // float\n this.m_invMassB; // float\n this.m_invIA; // float\n this.m_invIB; // float\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\nWeldJoint.prototype._serialize = function() {\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\nWeldJoint._deserialize = function(data, world, restore) {\n data = Object.assign({}, data);\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n var joint = new WeldJoint(data);\n return joint;\n};\n\n/**\n * @internal\n */\nWeldJoint.prototype._setAnchors = function(def) {\n if (def.anchorA) {\n this.m_localAnchorA.set(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.set(def.localAnchorA);\n }\n\n if (def.anchorB) {\n this.m_localAnchorB.set(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.set(def.localAnchorB);\n }\n}\n\n/**\n * The local anchor point relative to bodyA's origin.\n */\nWeldJoint.prototype.getLocalAnchorA = function() {\n return this.m_localAnchorA;\n};\n\n/**\n * The local anchor point relative to bodyB's origin.\n */\nWeldJoint.prototype.getLocalAnchorB = function() {\n return this.m_localAnchorB;\n};\n\n/**\n * Get the reference angle.\n */\nWeldJoint.prototype.getReferenceAngle = function() {\n return this.m_referenceAngle;\n};\n\n/**\n * Set/get frequency in Hz.\n */\nWeldJoint.prototype.setFrequency = function(hz) {\n this.m_frequencyHz = hz;\n};\n\nWeldJoint.prototype.getFrequency = function() {\n return this.m_frequencyHz;\n};\n\n/**\n * Set/get damping ratio.\n */\nWeldJoint.prototype.setDampingRatio = function(ratio) {\n this.m_dampingRatio = ratio;\n};\n\nWeldJoint.prototype.getDampingRatio = function() {\n return this.m_dampingRatio;\n};\n\nWeldJoint.prototype.getAnchorA = function() {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n};\n\nWeldJoint.prototype.getAnchorB = function() {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n};\n\nWeldJoint.prototype.getReactionForce = function(inv_dt) {\n return Vec2.neo(this.m_impulse.x, this.m_impulse.y).mul(inv_dt);\n};\n\nWeldJoint.prototype.getReactionTorque = function(inv_dt) {\n return inv_dt * this.m_impulse.z;\n};\n\nWeldJoint.prototype.initVelocityConstraints = function(step) {\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 var aA = this.m_bodyA.c_position.a;\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n\n var aB = this.m_bodyB.c_position.a;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n\n var qA = Rot.neo(aA), 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 var mA = this.m_invMassA;\n var mB = this.m_invMassB; // float\n var iA = this.m_invIA;\n var iB = this.m_invIB; // float\n\n var 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 var invM = iA + iB; // float\n var m = invM > 0.0 ? 1.0 / invM : 0.0; // float\n\n var C = aB - aA - this.m_referenceAngle; // float\n\n // Frequency\n var omega = 2.0 * Math.PI * this.m_frequencyHz; // float\n\n // Damping coefficient\n var d = 2.0 * m * this.m_dampingRatio * omega; // float\n\n // Spring stiffness\n var k = m * omega * omega; // float\n\n // magic formulas\n var h = step.dt; // float\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 var P = Vec2.neo(this.m_impulse.x, this.m_impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.cross(this.m_rA, P) + this.m_impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.cross(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\nWeldJoint.prototype.solveVelocityConstraints = function(step) {\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n\n var mA = this.m_invMassA;\n var mB = this.m_invMassB; // float\n var iA = this.m_invIA;\n var iB = this.m_invIB; // float\n\n if (this.m_frequencyHz > 0.0) {\n var Cdot2 = wB - wA; // float\n\n var impulse2 = -this.m_mass.ez.z\n * (Cdot2 + this.m_bias + this.m_gamma * this.m_impulse.z); // float\n this.m_impulse.z += impulse2;\n\n wA -= iA * impulse2;\n wB += iB * impulse2;\n\n var Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.cross(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.cross(wA, this.m_rA)); // Vec2\n\n var impulse1 = Vec2.neg(Mat33.mulVec2(this.m_mass, Cdot1)); // Vec2\n this.m_impulse.x += impulse1.x;\n this.m_impulse.y += impulse1.y;\n\n var P = Vec2.clone(impulse1); // Vec2\n\n vA.subMul(mA, P);\n wA -= iA * Vec2.cross(this.m_rA, P);\n\n vB.addMul(mB, P);\n wB += iB * Vec2.cross(this.m_rB, P);\n } else {\n var Cdot1 = Vec2.zero();\n Cdot1.addCombine(1, vB, 1, Vec2.cross(wB, this.m_rB));\n Cdot1.subCombine(1, vA, 1, Vec2.cross(wA, this.m_rA)); // Vec2\n var Cdot2 = wB - wA; // float\n var Cdot = Vec3(Cdot1.x, Cdot1.y, Cdot2); // Vec3\n\n var impulse = Vec3.neg(Mat33.mulVec3(this.m_mass, Cdot)); // Vec3\n this.m_impulse.add(impulse);\n\n var P = Vec2.neo(impulse.x, impulse.y);\n\n vA.subMul(mA, P);\n wA -= iA * (Vec2.cross(this.m_rA, P) + impulse.z);\n\n vB.addMul(mB, P);\n wB += iB * (Vec2.cross(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\nWeldJoint.prototype.solvePositionConstraints = function(step) {\n var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n\n var qA = Rot.neo(aA), qB = Rot.neo(aB);\n\n var mA = this.m_invMassA, mB = this.m_invMassB; // float\n var iA = this.m_invIA, iB = this.m_invIB; // float\n\n var rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n var rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n\n var positionError, angularError; // float\n\n var 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 var C1 = Vec2.zero();\n C1.addCombine(1, cB, 1, rB);\n C1.subCombine(1, cA, 1, rA); // Vec2\n\n positionError = C1.length();\n angularError = 0.0;\n\n var P = Vec2.neg(K.solve22(C1)); // Vec2\n\n cA.subMul(mA, P);\n aA -= iA * Vec2.cross(rA, P);\n\n cB.addMul(mB, P);\n aB += iB * Vec2.cross(rB, P);\n } else {\n var C1 = Vec2.zero();\n C1.addCombine(1, cB, 1, rB);\n C1.subCombine(1, cA, 1, rA);\n\n var C2 = aB - aA - this.m_referenceAngle; // float\n\n positionError = C1.length();\n angularError = Math.abs(C2);\n\n var C = Vec3(C1.x, C1.y, C2);\n\n var impulse = Vec3();\n if (K.ez.z > 0.0) {\n impulse = Vec3.neg(K.solve33(C));\n } else {\n var impulse2 = Vec2.neg(K.solve22(C1));\n impulse.set(impulse2.x, impulse2.y, 0.0);\n }\n\n var P = Vec2.neo(impulse.x, impulse.y);\n\n cA.subMul(mA, P);\n aA -= iA * (Vec2.cross(rA, P) + impulse.z);\n\n cB.addMul(mB, P);\n aB += iB * (Vec2.cross(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\n && angularError <= Settings.angularSlop;\n}\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = WheelJoint;\n\nvar options = require('../util/options');\nvar Settings = require('../Settings');\n\nvar Math = require('../common/Math');\nvar Vec2 = require('../common/Vec2');\nvar Vec3 = require('../common/Vec3');\nvar Mat22 = require('../common/Mat22');\nvar Mat33 = require('../common/Mat33');\nvar Rot = require('../common/Rot');\nvar Sweep = require('../common/Sweep');\nvar Transform = require('../common/Transform');\nvar Velocity = require('../common/Velocity');\nvar Position = require('../common/Position');\n\nvar Joint = require('../Joint');\nvar Body = require('../Body');\n\nWheelJoint.TYPE = 'wheel-joint';\nJoint.TYPES[WheelJoint.TYPE] = WheelJoint;\n\nWheelJoint._super = Joint;\nWheelJoint.prototype = Object.create(WheelJoint._super.prototype);\n\n/**\n * @typedef {Object} WheelJointDef\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 *\n * @prop {boolean} enableMotor Enable/disable the joint motor.\n * @prop {float} maxMotorTorque The maximum motor torque, usually in N-m.\n * @prop {float} motorSpeed The desired motor speed in radians per second.\n * @prop {float} frequencyHz Suspension frequency, zero indicates no suspension.\n * @prop {float} dampingRatio Suspension damping ratio, one indicates critical\n * damping.\n *\n * @prop {Vec2} localAnchorA The local anchor point relative to bodyA's origin.\n * @prop {Vec2} localAnchorB The local anchor point relative to bodyB's origin.\n * @prop {Vec2} localAxisA The local translation axis in bodyA.\n */\nvar DEFAULTS = {\n enableMotor : false,\n maxMotorTorque : 0.0,\n motorSpeed : 0.0,\n frequencyHz : 2.0,\n dampingRatio : 0.7,\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 * @param {WheelJointDef} def\n * @param {Body} bodyA\n * @param {Body} bodyB\n */\nfunction WheelJoint(def, bodyA, bodyB, anchor, axis) {\n if (!(this instanceof WheelJoint)) {\n return new WheelJoint(def, bodyA, bodyB, anchor, axis);\n }\n\n def = options(def, DEFAULTS);\n Joint.call(this, def, bodyA, bodyB);\n bodyA = this.m_bodyA;\n bodyB = this.m_bodyB;\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 this.m_localXAxisA = Vec2.clone(axis ? bodyA.getLocalVector(axis) : def.localAxisA || def.localAxis || Vec2.neo(1.0, 0.0));\n this.m_localYAxisA = Vec2.cross(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 // Solver temp\n this.m_localCenterA; // Vec2\n this.m_localCenterB; // Vec2\n this.m_invMassA; // float\n this.m_invMassB; // float\n this.m_invIA; // float\n this.m_invIB; // float\n\n this.m_ax = Vec2.zero();\n this.m_ay = Vec2.zero(); // Vec2\n this.m_sAx;\n this.m_sBx; // float\n this.m_sAy;\n this.m_sBy; // float\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\nWheelJoint.prototype._serialize = function() {\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\nWheelJoint._deserialize = function(data, world, restore) {\n data = Object.assign({}, data);\n data.bodyA = restore(Body, data.bodyA, world);\n data.bodyB = restore(Body, data.bodyB, world);\n var joint = new WheelJoint(data);\n return joint;\n};\n\n/**\n * @internal\n */\nWheelJoint.prototype._setAnchors = function(def) {\n if (def.anchorA) {\n this.m_localAnchorA.set(this.m_bodyA.getLocalPoint(def.anchorA));\n } else if (def.localAnchorA) {\n this.m_localAnchorA.set(def.localAnchorA);\n }\n\n if (def.anchorB) {\n this.m_localAnchorB.set(this.m_bodyB.getLocalPoint(def.anchorB));\n } else if (def.localAnchorB) {\n this.m_localAnchorB.set(def.localAnchorB);\n }\n\n if (def.localAxisA) {\n this.m_localXAxisA.set(def.localAxisA);\n this.m_localYAxisA.set(Vec2.cross(1.0, def.localAxisA));\n }\n}\n\n/**\n * The local anchor point relative to bodyA's origin.\n */\nWheelJoint.prototype.getLocalAnchorA = function() {\n return this.m_localAnchorA;\n}\n\n/**\n * The local anchor point relative to bodyB's origin.\n */\nWheelJoint.prototype.getLocalAnchorB = function() {\n return this.m_localAnchorB;\n}\n\n/**\n * The local joint axis relative to bodyA.\n */\nWheelJoint.prototype.getLocalAxisA = function() {\n return this.m_localXAxisA;\n}\n\n/**\n * Get the current joint translation, usually in meters.\n */\nWheelJoint.prototype.getJointTranslation = function() {\n var bA = this.m_bodyA;\n var bB = this.m_bodyB;\n\n var pA = bA.getWorldPoint(this.m_localAnchorA); // Vec2\n var pB = bB.getWorldPoint(this.m_localAnchorB); // Vec2\n var d = Vec2.sub(pB, pA); // Vec2\n var axis = bA.getWorldVector(this.m_localXAxisA); // Vec2\n\n var translation = Vec2.dot(d, axis); // float\n return translation;\n}\n\n/**\n * Get the current joint translation speed, usually in meters per second.\n */\nWheelJoint.prototype.getJointSpeed = function() {\n var wA = this.m_bodyA.m_angularVelocity;\n var wB = this.m_bodyB.m_angularVelocity;\n return wB - wA;\n}\n\n/**\n * Is the joint motor enabled?\n */\nWheelJoint.prototype.isMotorEnabled = function() {\n return this.m_enableMotor;\n}\n\n/**\n * Enable/disable the joint motor.\n */\nWheelJoint.prototype.enableMotor = function(flag) {\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 */\nWheelJoint.prototype.setMotorSpeed = function(speed) {\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 */\nWheelJoint.prototype.getMotorSpeed = function() {\n return this.m_motorSpeed;\n}\n\n/**\n * Set/Get the maximum motor force, usually in N-m.\n */\nWheelJoint.prototype.setMaxMotorTorque = function(torque) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorTorque = torque;\n}\n\nWheelJoint.prototype.getMaxMotorTorque = function() {\n return this.m_maxMotorTorque;\n}\n\n/**\n * Get the current motor torque given the inverse time step, usually in N-m.\n */\nWheelJoint.prototype.getMotorTorque = function(inv_dt) {\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 */\nWheelJoint.prototype.setSpringFrequencyHz = function(hz) {\n this.m_frequencyHz = hz;\n}\n\nWheelJoint.prototype.getSpringFrequencyHz = function() {\n return this.m_frequencyHz;\n}\n\n/**\n * Set/Get the spring damping ratio\n */\nWheelJoint.prototype.setSpringDampingRatio = function(ratio) {\n this.m_dampingRatio = ratio;\n}\n\nWheelJoint.prototype.getSpringDampingRatio = function() {\n return this.m_dampingRatio;\n}\n\nWheelJoint.prototype.getAnchorA = function() {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n}\n\nWheelJoint.prototype.getAnchorB = function() {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n}\n\nWheelJoint.prototype.getReactionForce = function(inv_dt) {\n return Vec2.combine(this.m_impulse, this.m_ay, this.m_springImpulse, this.m_ax).mul(inv_dt);\n}\n\nWheelJoint.prototype.getReactionTorque = function(inv_dt) {\n return inv_dt * this.m_motorImpulse;\n}\n\nWheelJoint.prototype.initVelocityConstraints = function(step) {\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 var mA = this.m_invMassA;\n var mB = this.m_invMassB; // float\n var iA = this.m_invIA;\n var iB = this.m_invIB; // float\n\n var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n\n var qA = Rot.neo(aA);\n var qB = Rot.neo(aB);\n\n // Compute the effective masses.\n var rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n var rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n var d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA); // Vec2\n\n // Point to line constraint\n {\n this.m_ay = Rot.mulVec2(qA, this.m_localYAxisA);\n this.m_sAy = Vec2.cross(Vec2.add(d, rA), this.m_ay);\n this.m_sBy = Vec2.cross(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.cross(Vec2.add(d, rA), this.m_ax);\n this.m_sBx = Vec2.cross(rB, this.m_ax);\n\n var invMass = mA + mB + iA * this.m_sAx * this.m_sAx + iB * this.m_sBx\n * this.m_sBx; // float\n\n if (invMass > 0.0) {\n this.m_springMass = 1.0 / invMass;\n\n var C = Vec2.dot(d, this.m_ax); // float\n\n // Frequency\n var omega = 2.0 * Math.PI * this.m_frequencyHz; // float\n\n // Damping coefficient\n var d = 2.0 * this.m_springMass * this.m_dampingRatio * omega; // float\n\n // Spring stiffness\n var k = this.m_springMass * omega * omega; // float\n\n // magic formulas\n var h = step.dt; // float\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\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 var P = Vec2.combine(this.m_impulse, this.m_ay, this.m_springImpulse, this.m_ax);\n var LA = this.m_impulse * this.m_sAy + this.m_springImpulse * this.m_sAx + this.m_motorImpulse;\n var 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.set(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.set(vB);\n this.m_bodyB.c_velocity.w = wB;\n}\n\nWheelJoint.prototype.solveVelocityConstraints = function(step) {\n var mA = this.m_invMassA;\n var mB = this.m_invMassB; // float\n var iA = this.m_invIA;\n var iB = this.m_invIB; // float\n\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n\n // Solve spring constraint\n {\n var Cdot = Vec2.dot(this.m_ax, vB) - Vec2.dot(this.m_ax, vA) + this.m_sBx\n * wB - this.m_sAx * wA; // float\n var impulse = -this.m_springMass\n * (Cdot + this.m_bias + this.m_gamma * this.m_springImpulse); // float\n this.m_springImpulse += impulse;\n\n var P = Vec2.mul(impulse, this.m_ax); // Vec2\n var LA = impulse * this.m_sAx; // float\n var LB = impulse * this.m_sBx; // float\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 var Cdot = wB - wA - this.m_motorSpeed; // float\n var impulse = -this.m_motorMass * Cdot; // float\n\n var oldImpulse = this.m_motorImpulse; // float\n var maxImpulse = step.dt * this.m_maxMotorTorque; // float\n this.m_motorImpulse = Math.clamp(this.m_motorImpulse + impulse,\n -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 var Cdot = Vec2.dot(this.m_ay, vB) - Vec2.dot(this.m_ay, vA) + this.m_sBy\n * wB - this.m_sAy * wA; // float\n var impulse = -this.m_mass * Cdot; // float\n this.m_impulse += impulse;\n\n var P = Vec2.mul(impulse, this.m_ay); // Vec2\n var LA = impulse * this.m_sAy; // float\n var LB = impulse * this.m_sBy; // float\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.set(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.set(vB);\n this.m_bodyB.c_velocity.w = wB;\n}\n\nWheelJoint.prototype.solvePositionConstraints = function(step) {\n var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n\n var qA = Rot.neo(aA);\n var qB = Rot.neo(aB);\n\n var rA = Rot.mulVec2(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n var rB = Rot.mulVec2(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n var d = Vec2.zero();\n d.addCombine(1, cB, 1, rB);\n d.subCombine(1, cA, 1, rA);\n\n var ay = Rot.mulVec2(qA, this.m_localYAxisA);\n\n var sAy = Vec2.cross(Vec2.add(d, rA), ay); // float\n var sBy = Vec2.cross(rB, ay); // float\n\n var C = Vec2.dot(d, ay); // float\n\n var k = this.m_invMassA + this.m_invMassB + this.m_invIA * this.m_sAy\n * this.m_sAy + this.m_invIB * this.m_sBy * this.m_sBy; // float\n\n var impulse; // float\n if (k != 0.0) {\n impulse = -C / k;\n } else {\n impulse = 0.0;\n }\n\n var P = Vec2.mul(impulse, ay); // Vec2\n var LA = impulse * sAy; // float\n var LB = impulse * sBy; // float\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.set(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.set(cB);\n this.m_bodyB.c_position.a = aB;\n\n return Math.abs(C) <= Settings.linearSlop;\n}\n","var World = require('../World');\nvar Body = require('../Body');\nvar Joint = require('../Joint');\nvar Fixture = require('../Fixture');\nvar Shape = require('../Shape');\nvar Vec2 = require('../common/Vec2');\nvar Vec3 = require('../common/Vec3');\n\nvar SID = 0;\n\nfunction Serializer(opts) {\n opts = opts || {};\n\n var rootClass = opts.rootClass || World;\n\n var preSerialize = opts.preSerialize || function (obj) { return obj; };\n var postSerialize = opts.postSerialize || function (data, obj) { return data; };\n\n var preDeserialize = opts.preDeserialize || function (data) { return data; };\n var postDeserialize = opts.postDeserialize || function (obj, data) { return obj; };\n\n // This is used to create ref objects during serialize\n var refTypes = {\n 'World': World,\n 'Body': Body,\n 'Joint': Joint,\n 'Fixture': Fixture,\n 'Shape': Shape,\n };\n\n // This is used by restore to deserialize objects and refs\n var restoreTypes = Object.assign({\n 'Vec2': Vec2,\n 'Vec3': Vec3,\n }, refTypes);\n\n this.toJson = function (root) {\n var json = [];\n\n var queue = [root];\n var refMap = {};\n\n function storeRef(value, typeName) {\n value.__sid = value.__sid || ++SID;\n if (!refMap[value.__sid]) {\n queue.push(value);\n var index = json.length + queue.length;\n var ref = {\n refIndex: index,\n refType: typeName\n };\n refMap[value.__sid] = ref;\n }\n return refMap[value.__sid];\n }\n\n function serialize(obj) {\n obj = preSerialize(obj);\n var data = obj._serialize();\n data = postSerialize(data, obj);\n return data;\n }\n\n function toJson(value, top) {\n if (typeof value !== 'object' || value === null) {\n return value;\n }\n if (typeof value._serialize === 'function') {\n if (value !== top) {\n for (var typeName in refTypes) {\n if (value instanceof refTypes[typeName]) {\n return storeRef(value, typeName);\n }\n }\n }\n value = serialize(value);\n }\n if (Array.isArray(value)) {\n var newValue = [];\n for (var key = 0; key < value.length; key++) {\n newValue[key] = toJson(value[key]);\n }\n value = newValue;\n\n } else {\n var newValue = {};\n for (var key in value) {\n if (value.hasOwnProperty(key)) {\n newValue[key] = toJson(value[key]);\n }\n }\n value = newValue;\n }\n return value;\n }\n\n while (queue.length) {\n var obj = queue.shift();\n var str = toJson(obj, obj);\n json.push(str);\n }\n\n return json;\n };\n\n this.fromJson = function (json) {\n var refMap = {};\n\n function deserialize(cls, data, ctx) {\n data = preDeserialize(data);\n var obj = cls._deserialize(data, ctx, restoreRef);\n obj = postDeserialize(obj, data);\n return obj;\n }\n\n function restoreRef(cls, ref, ctx) {\n if (!ref.refIndex) {\n return cls && cls._deserialize && deserialize(cls, ref, ctx);\n }\n cls = restoreTypes[ref.refType] || cls;\n var index = ref.refIndex;\n if (!refMap[index]) {\n var data = json[index];\n var obj = deserialize(cls, data, ctx);\n refMap[index] = obj;\n }\n return refMap[index];\n }\n\n var root = rootClass._deserialize(json[0], null, restoreRef);\n\n return root;\n }\n}\n\nmodule.exports = Serializer;\n\nvar serializer = new Serializer();\nmodule.exports.toJson = serializer.toJson;\nmodule.exports.fromJson = serializer.fromJson;\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = BoxShape;\n\nvar common = require('../util/common');\nvar PolygonShape = require('./PolygonShape');\n\nBoxShape._super = PolygonShape;\nBoxShape.prototype = Object.create(BoxShape._super.prototype);\n\nBoxShape.TYPE = 'polygon';\n\n/**\n * A rectangle polygon which extend PolygonShape.\n */\nfunction BoxShape(hx, hy, center, angle) {\n if (!(this instanceof BoxShape)) {\n return new BoxShape(hx, hy, center, angle);\n }\n\n BoxShape._super.call(this);\n\n this._setAsBox(hx, hy, center, angle);\n}\n\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = ChainShape;\n\nvar common = require('../util/common');\nvar options = require('../util/options');\nvar Math = require('../common/Math');\nvar Transform = require('../common/Transform');\nvar Rot = require('../common/Rot');\nvar Vec2 = require('../common/Vec2');\nvar AABB = require('../collision/AABB');\nvar Settings = require('../Settings');\nvar Shape = require('../Shape');\nvar EdgeShape = require('./EdgeShape');\n\nChainShape._super = Shape;\nChainShape.prototype = Object.create(ChainShape._super.prototype);\n\nChainShape.TYPE = 'chain';\nShape.TYPES[ChainShape.TYPE] = ChainShape;\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 */\nfunction ChainShape(vertices, loop) {\n if (!(this instanceof ChainShape)) {\n return new ChainShape(vertices, loop);\n }\n\n ChainShape._super.call(this);\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\nChainShape.prototype._serialize = function() {\n const data = {\n type: this.m_type,\n vertices: this.m_vertices,\n isLoop: this.m_isLoop,\n hasPrevVertex: this.m_hasPrevVertex,\n hasNextVertex: this.m_hasNextVertex,\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\nChainShape._deserialize = function(data, fixture, restore) {\n var vertices = [];\n if (data.vertices) {\n for (var i = 0; i < data.vertices.length; i++) {\n vertices.push(restore(Vec2, data.vertices[i]));\n }\n }\n var 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// ChainShape.clear = function() {\n// this.m_vertices.length = 0;\n// this.m_count = 0;\n// }\n\n/**\n * Create a loop. This automatically adjusts connectivity.\n *\n * @param vertices an array of vertices, these are copied\n * @param count the vertex count\n */\nChainShape.prototype._createLoop = function(vertices) {\n _ASSERT && common.assert(this.m_vertices.length == 0 && this.m_count == 0);\n _ASSERT && common.assert(vertices.length >= 3);\n for (var i = 1; i < vertices.length; ++i) {\n var v1 = vertices[i - 1];\n var v2 = vertices[i];\n // If the code crashes here, it means your vertices are too close together.\n _ASSERT && common.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);\n }\n\n this.m_vertices = [];\n this.m_count = vertices.length + 1;\n for (var 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 * Create a chain with isolated end vertices.\n *\n * @param vertices an array of vertices, these are copied\n * @param count the vertex count\n */\nChainShape.prototype._createChain = function(vertices) {\n _ASSERT && common.assert(this.m_vertices.length == 0 && this.m_count == 0);\n _ASSERT && common.assert(vertices.length >= 2);\n for (var i = 1; i < vertices.length; ++i) {\n // If the code crashes here, it means your vertices are too close together.\n var v1 = vertices[i - 1];\n var v2 = vertices[i];\n _ASSERT && common.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);\n }\n\n this.m_count = vertices.length;\n for (var i = 0; i < vertices.length; ++i) {\n this.m_vertices[i] = Vec2.clone(vertices[i]);\n }\n\n this.m_hasPrevVertex = false;\n this.m_hasNextVertex = false;\n this.m_prevVertex = null;\n this.m_nextVertex = null;\n return this;\n}\n\nChainShape.prototype._reset = function() {\n if (this.m_isLoop) {\n this._createLoop(this.m_vertices);\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 */\nChainShape.prototype.setPrevVertex = function(prevVertex) {\n this.m_prevVertex = prevVertex;\n this.m_hasPrevVertex = true;\n}\n\n/**\n * Establish connectivity to a vertex that follows the last vertex. Don't call\n * this for loops.\n */\nChainShape.prototype.setNextVertex = function(nextVertex) {\n this.m_nextVertex = nextVertex;\n this.m_hasNextVertex = true;\n}\n\n/**\n * @deprecated\n */\nChainShape.prototype._clone = function() {\n var 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\nChainShape.prototype.getChildCount = function() {\n // edge count = vertex count - 1\n return this.m_count - 1;\n}\n\n// Get a child edge.\nChainShape.prototype.getChildEdge = function(edge, childIndex) {\n _ASSERT && common.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\nChainShape.prototype.getVertex = function(index) {\n _ASSERT && common.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/**\n * This always return false.\n */\nChainShape.prototype.testPoint = function(xf, p) {\n return false;\n}\n\nChainShape.prototype.rayCast = function(output, input, xf, childIndex) {\n _ASSERT && common.assert(0 <= childIndex && childIndex < this.m_count);\n\n var edgeShape = new EdgeShape(this.getVertex(childIndex), this.getVertex(childIndex + 1));\n return edgeShape.rayCast(output, input, xf, 0);\n}\n\nChainShape.prototype.computeAABB = function(aabb, xf, childIndex) {\n _ASSERT && common.assert(0 <= childIndex && childIndex < this.m_count);\n\n var v1 = Transform.mulVec2(xf, this.getVertex(childIndex));\n var v2 = Transform.mulVec2(xf, this.getVertex(childIndex + 1));\n\n aabb.combinePoints(v1, v2);\n}\n\n/**\n * Chains have zero mass.\n */\nChainShape.prototype.computeMass = function(massData, density) {\n massData.mass = 0.0;\n massData.center = Vec2.neo();\n massData.I = 0.0;\n}\n\nChainShape.prototype.computeDistanceProxy = function(proxy, childIndex) {\n _ASSERT && common.assert(0 <= childIndex && childIndex < this.m_count);\n proxy.m_buffer[0] = this.getVertex(childIndex);\n proxy.m_buffer[1] = this.getVertex(childIndex + 1);\n proxy.m_vertices = proxy.m_buffer;\n proxy.m_count = 2;\n proxy.m_radius = this.m_radius;\n};\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = CircleShape;\n\nvar common = require('../util/common');\nvar options = require('../util/options');\nvar Math = require('../common/Math');\nvar Transform = require('../common/Transform');\nvar Rot = require('../common/Rot');\nvar Vec2 = require('../common/Vec2');\nvar AABB = require('../collision/AABB');\nvar Settings = require('../Settings');\nvar Shape = require('../Shape');\n\nCircleShape._super = Shape;\nCircleShape.prototype = Object.create(CircleShape._super.prototype);\n\nCircleShape.TYPE = 'circle';\nShape.TYPES[CircleShape.TYPE] = CircleShape;\n\nfunction CircleShape(a, b) {\n if (!(this instanceof CircleShape)) {\n return new CircleShape(a, b);\n }\n\n CircleShape._super.call(this);\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.set(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\nCircleShape.prototype._serialize = function() {\n return {\n type: this.m_type,\n\n p: this.m_p,\n radius: this.m_radius,\n };\n};\n\nCircleShape._deserialize = function(data) {\n return new CircleShape(data.p, data.radius);\n};\n\nCircleShape.prototype.getRadius = function() {\n return this.m_radius;\n}\n\nCircleShape.prototype.getCenter = function() {\n return this.m_p;\n}\n\nCircleShape.prototype.getVertex = function(index) {\n _ASSERT && common.assert(index == 0);\n return this.m_p;\n}\n\nCircleShape.prototype.getVertexCount = function(index) {\n return 1;\n}\n\n/**\n * @deprecated\n */\nCircleShape.prototype._clone = function() {\n var 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\nCircleShape.prototype.getChildCount = function() {\n return 1;\n}\n\nCircleShape.prototype.testPoint = function(xf, p) {\n var center = Vec2.add(xf.p, Rot.mulVec2(xf.q, this.m_p));\n var d = Vec2.sub(p, center);\n return Vec2.dot(d, d) <= this.m_radius * this.m_radius;\n}\n\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\nCircleShape.prototype.rayCast = function(output, input, xf, childIndex) {\n\n var position = Vec2.add(xf.p, Rot.mulVec2(xf.q, this.m_p));\n var s = Vec2.sub(input.p1, position);\n var b = Vec2.dot(s, s) - this.m_radius * this.m_radius;\n\n // Solve quadratic equation.\n var r = Vec2.sub(input.p2, input.p1);\n var c = Vec2.dot(s, r);\n var rr = Vec2.dot(r, r);\n var sigma = c * c - rr * b;\n\n // Check for negative discriminant and short segment.\n if (sigma < 0.0 || rr < Math.EPSILON) {\n return false;\n }\n\n // Find the point of intersection of the line with the circle.\n var 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.mul(a, r));\n output.normal.normalize();\n return true;\n }\n\n return false;\n}\n\nCircleShape.prototype.computeAABB = function(aabb, xf, childIndex) {\n var p = Vec2.add(xf.p, Rot.mulVec2(xf.q, this.m_p));\n aabb.lowerBound.set(p.x - this.m_radius, p.y - this.m_radius);\n aabb.upperBound.set(p.x + this.m_radius, p.y + this.m_radius);\n}\n\nCircleShape.prototype.computeMass = function(massData, density) {\n massData.mass = density * Math.PI * this.m_radius * this.m_radius;\n massData.center = this.m_p;\n // inertia about the local origin\n massData.I = massData.mass\n * (0.5 * this.m_radius * this.m_radius + Vec2.dot(this.m_p, this.m_p));\n}\n\nCircleShape.prototype.computeDistanceProxy = function(proxy) {\n proxy.m_vertices.push(this.m_p);\n proxy.m_count = 1;\n proxy.m_radius = this.m_radius;\n};\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nvar common = require('../util/common');\nvar Math = require('../common/Math');\nvar Transform = require('../common/Transform');\nvar Vec2 = require('../common/Vec2');\nvar Settings = require('../Settings');\nvar Shape = require('../Shape');\nvar Contact = require('../Contact');\nvar Manifold = require('../Manifold');\nvar CircleShape = require('./CircleShape');\n\nContact.addType(CircleShape.TYPE, CircleShape.TYPE, CircleCircleContact);\n\nfunction CircleCircleContact(manifold, xfA, fixtureA, indexA, xfB, fixtureB, indexB) {\n _ASSERT && common.assert(fixtureA.getType() == CircleShape.TYPE);\n _ASSERT && common.assert(fixtureB.getType() == CircleShape.TYPE);\n CollideCircles(manifold, fixtureA.getShape(), xfA, fixtureB.getShape(), xfB);\n}\n\nfunction CollideCircles(manifold, circleA, xfA, circleB, xfB) {\n manifold.pointCount = 0;\n\n var pA = Transform.mulVec2(xfA, circleA.m_p);\n var pB = Transform.mulVec2(xfB, circleB.m_p);\n\n var distSqr = Vec2.distanceSquared(pB, pA);\n var rA = circleA.m_radius;\n var rB = circleB.m_radius;\n var radius = rA + rB;\n if (distSqr > radius * radius) {\n return;\n }\n\n manifold.type = Manifold.e_circles;\n manifold.localPoint.set(circleA.m_p);\n manifold.localNormal.setZero();\n manifold.pointCount = 1;\n manifold.points[0].localPoint.set(circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.cf.indexA = 0;\n manifold.points[0].id.cf.typeA = Manifold.e_vertex;\n manifold.points[0].id.cf.indexB = 0;\n manifold.points[0].id.cf.typeB = Manifold.e_vertex;\n}\n\nexports.CollideCircles = CollideCircles;\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nvar common = require('../util/common');\nvar Math = require('../common/Math');\nvar Transform = require('../common/Transform');\nvar Rot = require('../common/Rot');\nvar Vec2 = require('../common/Vec2');\nvar AABB = require('../collision/AABB');\nvar Settings = require('../Settings');\nvar Manifold = require('../Manifold');\nvar Contact = require('../Contact');\nvar Shape = require('../Shape');\nvar CircleShape = require('./CircleShape');\nvar PolygonShape = require('./PolygonShape');\n\nContact.addType(PolygonShape.TYPE, CircleShape.TYPE, PolygonCircleContact);\n\nfunction PolygonCircleContact(manifold, xfA, fixtureA, indexA, xfB, fixtureB, indexB) {\n _ASSERT && common.assert(fixtureA.getType() == PolygonShape.TYPE);\n _ASSERT && common.assert(fixtureB.getType() == CircleShape.TYPE);\n CollidePolygonCircle(manifold, fixtureA.getShape(), xfA, fixtureB.getShape(),\n xfB);\n}\n\nfunction CollidePolygonCircle(manifold, polygonA, xfA, circleB, xfB) {\n manifold.pointCount = 0;\n\n // Compute circle position in the frame of the polygon.\n var c = Transform.mulVec2(xfB, circleB.m_p);\n var cLocal = Transform.mulTVec2(xfA, c);\n\n // Find the min separating edge.\n var normalIndex = 0;\n var separation = -Infinity;\n var radius = polygonA.m_radius + circleB.m_radius;\n var vertexCount = polygonA.m_count;\n var vertices = polygonA.m_vertices;\n var normals = polygonA.m_normals;\n\n for (var i = 0; i < vertexCount; ++i) {\n var s = Vec2.dot(normals[i], Vec2.sub(cLocal, 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 var vertIndex1 = normalIndex;\n var vertIndex2 = vertIndex1 + 1 < vertexCount ? vertIndex1 + 1 : 0;\n var v1 = vertices[vertIndex1];\n var v2 = vertices[vertIndex2];\n\n // If the center is inside the polygon ...\n if (separation < Math.EPSILON) {\n manifold.pointCount = 1;\n manifold.type = Manifold.e_faceA;\n manifold.localNormal.set(normals[normalIndex]);\n manifold.localPoint.setCombine(0.5, v1, 0.5, v2);\n manifold.points[0].localPoint = circleB.m_p;\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.cf.indexA = 0;\n manifold.points[0].id.cf.typeA = Manifold.e_vertex;\n manifold.points[0].id.cf.indexB = 0;\n manifold.points[0].id.cf.typeB = Manifold.e_vertex;\n return;\n }\n\n // Compute barycentric coordinates\n var u1 = Vec2.dot(Vec2.sub(cLocal, v1), Vec2.sub(v2, v1));\n var u2 = Vec2.dot(Vec2.sub(cLocal, v2), Vec2.sub(v1, v2));\n if (u1 <= 0.0) {\n if (Vec2.distanceSquared(cLocal, v1) > radius * radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = Manifold.e_faceA;\n manifold.localNormal.setCombine(1, cLocal, -1, v1);\n manifold.localNormal.normalize();\n manifold.localPoint = v1;\n manifold.points[0].localPoint.set(circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.cf.indexA = 0;\n manifold.points[0].id.cf.typeA = Manifold.e_vertex;\n manifold.points[0].id.cf.indexB = 0;\n manifold.points[0].id.cf.typeB = Manifold.e_vertex;\n } else if (u2 <= 0.0) {\n if (Vec2.distanceSquared(cLocal, v2) > radius * radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = Manifold.e_faceA;\n manifold.localNormal.setCombine(1, cLocal, -1, v2);\n manifold.localNormal.normalize();\n manifold.localPoint.set(v2);\n manifold.points[0].localPoint.set(circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.cf.indexA = 0;\n manifold.points[0].id.cf.typeA = Manifold.e_vertex;\n manifold.points[0].id.cf.indexB = 0;\n manifold.points[0].id.cf.typeB = Manifold.e_vertex;\n } else {\n var faceCenter = Vec2.mid(v1, v2);\n var separation = Vec2.dot(cLocal, normals[vertIndex1])\n - Vec2.dot(faceCenter, normals[vertIndex1]);\n if (separation > radius) {\n return;\n }\n\n manifold.pointCount = 1;\n manifold.type = Manifold.e_faceA;\n manifold.localNormal.set(normals[vertIndex1]);\n manifold.localPoint.set(faceCenter);\n manifold.points[0].localPoint.set(circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.cf.indexA = 0;\n manifold.points[0].id.cf.typeA = Manifold.e_vertex;\n manifold.points[0].id.cf.indexB = 0;\n manifold.points[0].id.cf.typeB = Manifold.e_vertex;\n }\n}\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nvar common = require('../util/common');\nvar Math = require('../common/Math');\nvar Transform = require('../common/Transform');\nvar Vec2 = require('../common/Vec2');\nvar Rot = require('../common/Rot');\nvar Settings = require('../Settings');\nvar Shape = require('../Shape');\nvar Contact = require('../Contact');\nvar Manifold = require('../Manifold');\nvar EdgeShape = require('./EdgeShape');\nvar ChainShape = require('./ChainShape');\nvar CircleShape = require('./CircleShape');\n\nContact.addType(EdgeShape.TYPE, CircleShape.TYPE, EdgeCircleContact);\nContact.addType(ChainShape.TYPE, CircleShape.TYPE, ChainCircleContact);\n\nfunction EdgeCircleContact(manifold, xfA, fixtureA, indexA, xfB, fixtureB,\n indexB) {\n _ASSERT && common.assert(fixtureA.getType() == EdgeShape.TYPE);\n _ASSERT && common.assert(fixtureB.getType() == CircleShape.TYPE);\n\n var shapeA = fixtureA.getShape();\n var shapeB = fixtureB.getShape();\n\n CollideEdgeCircle(manifold, shapeA, xfA, shapeB, xfB);\n}\n\nfunction ChainCircleContact(manifold, xfA, fixtureA, indexA, xfB, fixtureB,\n indexB) {\n _ASSERT && common.assert(fixtureA.getType() == ChainShape.TYPE);\n _ASSERT && common.assert(fixtureB.getType() == CircleShape.TYPE);\n\n var chain = fixtureA.getShape();\n var edge = new EdgeShape();\n chain.getChildEdge(edge, indexA);\n\n var shapeA = edge;\n var shapeB = fixtureB.getShape();\n\n CollideEdgeCircle(manifold, shapeA, xfA, shapeB, xfB);\n}\n\n// Compute contact points for edge versus circle.\n// This accounts for edge connectivity.\nfunction CollideEdgeCircle(manifold, edgeA, xfA, circleB, xfB) {\n manifold.pointCount = 0;\n\n // Compute circle in frame of edge\n var Q = Transform.mulTVec2(xfA, Transform.mulVec2(xfB, circleB.m_p));\n\n var A = edgeA.m_vertex1;\n var B = edgeA.m_vertex2;\n var e = Vec2.sub(B, A);\n\n // Barycentric coordinates\n var u = Vec2.dot(e, Vec2.sub(B, Q));\n var v = Vec2.dot(e, Vec2.sub(Q, A));\n\n var radius = edgeA.m_radius + circleB.m_radius;\n\n // Region A\n if (v <= 0.0) {\n var P = Vec2.clone(A);\n var d = Vec2.sub(Q, P);\n var dd = Vec2.dot(d, d);\n if (dd > radius * radius) {\n return;\n }\n\n // Is there an edge connected to A?\n if (edgeA.m_hasVertex0) {\n var A1 = edgeA.m_vertex0;\n var B1 = A;\n var e1 = Vec2.sub(B1, A1);\n var u1 = Vec2.dot(e1, Vec2.sub(B1, 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 = Manifold.e_circles;\n manifold.localNormal.setZero();\n manifold.localPoint.set(P);\n manifold.pointCount = 1;\n manifold.points[0].localPoint.set(circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.cf.indexA = 0;\n manifold.points[0].id.cf.typeA = Manifold.e_vertex;\n manifold.points[0].id.cf.indexB = 0;\n manifold.points[0].id.cf.typeB = Manifold.e_vertex;\n return;\n }\n\n // Region B\n if (u <= 0.0) {\n var P = Vec2.clone(B);\n var d = Vec2.sub(Q, P);\n var dd = Vec2.dot(d, d);\n if (dd > radius * radius) {\n return;\n }\n\n // Is there an edge connected to B?\n if (edgeA.m_hasVertex3) {\n var B2 = edgeA.m_vertex3;\n var A2 = B;\n var e2 = Vec2.sub(B2, A2);\n var v2 = Vec2.dot(e2, Vec2.sub(Q, 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 = Manifold.e_circles;\n manifold.localNormal.setZero();\n manifold.localPoint.set(P);\n manifold.pointCount = 1;\n manifold.points[0].localPoint.set(circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.cf.indexA = 1;\n manifold.points[0].id.cf.typeA = Manifold.e_vertex;\n manifold.points[0].id.cf.indexB = 0;\n manifold.points[0].id.cf.typeB = Manifold.e_vertex;\n return;\n }\n\n // Region AB\n var den = Vec2.dot(e, e);\n _ASSERT && common.assert(den > 0.0);\n var P = Vec2.combine(u / den, A, v / den, B);\n var d = Vec2.sub(Q, P);\n var dd = Vec2.dot(d, d);\n if (dd > radius * radius) {\n return;\n }\n\n var n = Vec2.neo(-e.y, e.x);\n if (Vec2.dot(n, Vec2.sub(Q, A)) < 0.0) {\n n.set(-n.x, -n.y);\n }\n n.normalize();\n\n manifold.type = Manifold.e_faceA;\n manifold.localNormal = n;\n manifold.localPoint.set(A);\n manifold.pointCount = 1;\n manifold.points[0].localPoint.set(circleB.m_p);\n\n // manifold.points[0].id.key = 0;\n manifold.points[0].id.cf.indexA = 0;\n manifold.points[0].id.cf.typeA = Manifold.e_face;\n manifold.points[0].id.cf.indexB = 0;\n manifold.points[0].id.cf.typeB = Manifold.e_vertex;\n}\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nvar common = require('../util/common');\nvar Math = require('../common/Math');\nvar Transform = require('../common/Transform');\nvar Vec2 = require('../common/Vec2');\nvar Rot = require('../common/Rot');\nvar Settings = require('../Settings');\nvar Shape = require('../Shape');\nvar Contact = require('../Contact');\nvar Manifold = require('../Manifold');\nvar EdgeShape = require('./EdgeShape');\nvar ChainShape = require('./ChainShape');\nvar PolygonShape = require('./PolygonShape');\n\nContact.addType(EdgeShape.TYPE, PolygonShape.TYPE, EdgePolygonContact);\nContact.addType(ChainShape.TYPE, PolygonShape.TYPE, ChainPolygonContact);\n\nfunction EdgePolygonContact(manifold, xfA, fA, indexA, xfB, fB, indexB) {\n _ASSERT && common.assert(fA.getType() == EdgeShape.TYPE);\n _ASSERT && common.assert(fB.getType() == PolygonShape.TYPE);\n\n CollideEdgePolygon(manifold, fA.getShape(), xfA, fB.getShape(), xfB);\n}\n\nfunction ChainPolygonContact(manifold, xfA, fA, indexA, xfB, fB, indexB) {\n _ASSERT && common.assert(fA.getType() == ChainShape.TYPE);\n _ASSERT && common.assert(fB.getType() == PolygonShape.TYPE);\n\n var chain = fA.getShape();\n var edge = new EdgeShape();\n chain.getChildEdge(edge, indexA);\n\n CollideEdgePolygon(manifold, edge, xfA, fB.getShape(), xfB);\n}\n\n// EPAxis Type\nvar e_unknown = -1;\nvar e_edgeA = 1;\nvar e_edgeB = 2;\n\n// VertexType unused?\nvar e_isolated = 0;\nvar e_concave = 1;\nvar e_convex = 2;\n\n// This structure is used to keep track of the best separating axis.\nfunction EPAxis() {\n this.type; // Type\n this.index;\n this.separation;\n};\n\n// This holds polygon B expressed in frame A.\nfunction TempPolygon() {\n this.vertices = []; // Vec2[Settings.maxPolygonVertices]\n this.normals = []; // Vec2[Settings.maxPolygonVertices];\n this.count = 0;\n};\n\n// Reference face used for clipping\nfunction ReferenceFace() {\n this.i1, this.i2; // int\n this.v1, this.v2; // v\n this.normal = Vec2.zero();\n this.sideNormal1 = Vec2.zero();\n this.sideOffset1; // float\n this.sideNormal2 = Vec2.zero();\n this.sideOffset2; // float\n};\n\n// reused\nvar edgeAxis = new EPAxis();\nvar polygonAxis = new EPAxis();\nvar polygonBA = new TempPolygon();\nvar rf = new ReferenceFace();\n\n/**\n * This function collides and edge and a polygon, taking into account edge\n * adjacency.\n */\nfunction CollideEdgePolygon(manifold, edgeA, xfA, polygonB, xfB) {\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 var m_type1, m_type2; // VertexType unused?\n\n var xf = Transform.mulTXf(xfA, xfB);\n\n var centroidB = Transform.mulVec2(xf, polygonB.m_centroid);\n\n var v0 = edgeA.m_vertex0;\n var v1 = edgeA.m_vertex1;\n var v2 = edgeA.m_vertex2;\n var v3 = edgeA.m_vertex3;\n\n var hasVertex0 = edgeA.m_hasVertex0;\n var hasVertex3 = edgeA.m_hasVertex3;\n\n var edge1 = Vec2.sub(v2, v1);\n edge1.normalize();\n var normal1 = Vec2.neo(edge1.y, -edge1.x);\n var offset1 = Vec2.dot(normal1, Vec2.sub(centroidB, v1));\n var offset0 = 0.0;\n var offset2 = 0.0;\n var convex1 = false;\n var convex2 = false;\n\n // Is there a preceding edge?\n if (hasVertex0) {\n var edge0 = Vec2.sub(v1, v0);\n edge0.normalize();\n var normal0 = Vec2.neo(edge0.y, -edge0.x);\n convex1 = Vec2.cross(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 var edge2 = Vec2.sub(v3, v2);\n edge2.normalize();\n var normal2 = Vec2.neo(edge2.y, -edge2.x);\n convex2 = Vec2.cross(edge1, edge2) > 0.0;\n offset2 = Vec2.dot(normal2, centroidB) - Vec2.dot(normal2, v2);\n }\n\n var front;\n var normal = Vec2.zero();\n var lowerLimit = Vec2.zero();\n var upperLimit = Vec2.zero();\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 normal.set(normal1);\n lowerLimit.set(normal0);\n upperLimit.set(normal2);\n } else {\n normal.setMul(-1, normal1);\n lowerLimit.setMul(-1, normal1);\n upperLimit.setMul(-1, normal1);\n }\n } else if (convex1) {\n front = offset0 >= 0.0 || (offset1 >= 0.0 && offset2 >= 0.0);\n if (front) {\n normal.set(normal1);\n lowerLimit.set(normal0);\n upperLimit.set(normal1);\n } else {\n normal.setMul(-1, normal1);\n lowerLimit.setMul(-1, normal2);\n upperLimit.setMul(-1, normal1);\n }\n } else if (convex2) {\n front = offset2 >= 0.0 || (offset0 >= 0.0 && offset1 >= 0.0);\n if (front) {\n normal.set(normal1);\n lowerLimit.set(normal1);\n upperLimit.set(normal2);\n } else {\n normal.setMul(-1, normal1);\n lowerLimit.setMul(-1, normal1);\n upperLimit.setMul(-1, normal0);\n }\n } else {\n front = offset0 >= 0.0 && offset1 >= 0.0 && offset2 >= 0.0;\n if (front) {\n normal.set(normal1);\n lowerLimit.set(normal1);\n upperLimit.set(normal1);\n } else {\n normal.setMul(-1, normal1);\n lowerLimit.setMul(-1, normal2);\n upperLimit.setMul(-1, normal0);\n }\n }\n } else if (hasVertex0) {\n if (convex1) {\n front = offset0 >= 0.0 || offset1 >= 0.0;\n if (front) {\n normal.set(normal1);\n lowerLimit.set(normal0);\n upperLimit.setMul(-1, normal1);\n } else {\n normal.setMul(-1, normal1);\n lowerLimit.set(normal1);\n upperLimit.setMul(-1, normal1);\n }\n } else {\n front = offset0 >= 0.0 && offset1 >= 0.0;\n if (front) {\n normal.set(normal1);\n lowerLimit.set(normal1);\n upperLimit.setMul(-1, normal1);\n } else {\n normal.setMul(-1, normal1);\n lowerLimit.set(normal1);\n upperLimit.setMul(-1, normal0);\n }\n }\n } else if (hasVertex3) {\n if (convex2) {\n front = offset1 >= 0.0 || offset2 >= 0.0;\n if (front) {\n normal.set(normal1);\n lowerLimit.setMul(-1, normal1);\n upperLimit.set(normal2);\n } else {\n normal.setMul(-1, normal1);\n lowerLimit.setMul(-1, normal1);\n upperLimit.set(normal1);\n }\n } else {\n front = offset1 >= 0.0 && offset2 >= 0.0;\n if (front) {\n normal.set(normal1);\n lowerLimit.setMul(-1, normal1);\n upperLimit.set(normal1);\n } else {\n normal.setMul(-1, normal1);\n lowerLimit.setMul(-1, normal2);\n upperLimit.set(normal1);\n }\n }\n } else {\n front = offset1 >= 0.0;\n if (front) {\n normal.set(normal1);\n lowerLimit.setMul(-1, normal1);\n upperLimit.setMul(-1, normal1);\n } else {\n normal.setMul(-1, normal1);\n lowerLimit.set(normal1);\n upperLimit.set(normal1);\n }\n }\n\n // Get polygonB in frameA\n polygonBA.count = polygonB.m_count;\n for (var i = 0; i < polygonB.m_count; ++i) {\n polygonBA.vertices[i] = Transform.mulVec2(xf, polygonB.m_vertices[i]);\n polygonBA.normals[i] = Rot.mulVec2(xf.q, polygonB.m_normals[i]);\n }\n\n var radius = 2.0 * Settings.polygonRadius;\n\n manifold.pointCount = 0;\n\n { // ComputeEdgeSeparation\n edgeAxis.type = e_edgeA;\n edgeAxis.index = front ? 0 : 1;\n edgeAxis.separation = Infinity;\n\n for (var i = 0; i < polygonBA.count; ++i) {\n var s = Vec2.dot(normal, Vec2.sub(polygonBA.vertices[i], 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 if (edgeAxis.type == e_unknown) {\n return;\n }\n\n if (edgeAxis.separation > radius) {\n return;\n }\n\n { // ComputePolygonSeparation\n polygonAxis.type = e_unknown;\n polygonAxis.index = -1;\n polygonAxis.separation = -Infinity;\n\n var perp = Vec2.neo(-normal.y, normal.x);\n\n for (var i = 0; i < polygonBA.count; ++i) {\n var n = Vec2.neg(polygonBA.normals[i]);\n\n var s1 = Vec2.dot(n, Vec2.sub(polygonBA.vertices[i], v1));\n var s2 = Vec2.dot(n, Vec2.sub(polygonBA.vertices[i], v2));\n var s = Math.min(s1, s2);\n\n if (s > radius) {\n // No collision\n polygonAxis.type = e_edgeB;\n polygonAxis.index = i;\n polygonAxis.separation = s;\n break;\n }\n\n // Adjacency\n if (Vec2.dot(n, perp) >= 0.0) {\n if (Vec2.dot(Vec2.sub(n, upperLimit), normal) < -Settings.angularSlop) {\n continue;\n }\n } else {\n if (Vec2.dot(Vec2.sub(n, lowerLimit), normal) < -Settings.angularSlop) {\n continue;\n }\n }\n\n if (s > polygonAxis.separation) {\n polygonAxis.type = e_edgeB;\n polygonAxis.index = i;\n polygonAxis.separation = s;\n }\n }\n }\n\n if (polygonAxis.type != e_unknown && polygonAxis.separation > radius) {\n return;\n }\n\n // Use hysteresis for jitter reduction.\n var k_relativeTol = 0.98;\n var k_absoluteTol = 0.001;\n\n var primaryAxis;\n if (polygonAxis.type == 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 var ie = [ new Manifold.clipVertex(), new Manifold.clipVertex() ];\n\n if (primaryAxis.type == e_edgeA) {\n manifold.type = Manifold.e_faceA;\n\n // Search for the polygon normal that is most anti-parallel to the edge\n // normal.\n var bestIndex = 0;\n var bestValue = Vec2.dot(normal, polygonBA.normals[0]);\n for (var i = 1; i < polygonBA.count; ++i) {\n var value = Vec2.dot(normal, polygonBA.normals[i]);\n if (value < bestValue) {\n bestValue = value;\n bestIndex = i;\n }\n }\n\n var i1 = bestIndex;\n var i2 = i1 + 1 < polygonBA.count ? i1 + 1 : 0;\n\n ie[0].v = polygonBA.vertices[i1];\n ie[0].id.cf.indexA = 0;\n ie[0].id.cf.indexB = i1;\n ie[0].id.cf.typeA = Manifold.e_face;\n ie[0].id.cf.typeB = Manifold.e_vertex;\n\n ie[1].v = polygonBA.vertices[i2];\n ie[1].id.cf.indexA = 0;\n ie[1].id.cf.indexB = i2;\n ie[1].id.cf.typeA = Manifold.e_face;\n ie[1].id.cf.typeB = Manifold.e_vertex;\n\n if (front) {\n rf.i1 = 0;\n rf.i2 = 1;\n rf.v1 = v1;\n rf.v2 = v2;\n rf.normal.set(normal1);\n } else {\n rf.i1 = 1;\n rf.i2 = 0;\n rf.v1 = v2;\n rf.v2 = v1;\n rf.normal.setMul(-1, normal1);\n }\n } else {\n manifold.type = Manifold.e_faceB;\n\n ie[0].v = v1;\n ie[0].id.cf.indexA = 0;\n ie[0].id.cf.indexB = primaryAxis.index;\n ie[0].id.cf.typeA = Manifold.e_vertex;\n ie[0].id.cf.typeB = Manifold.e_face;\n\n ie[1].v = v2;\n ie[1].id.cf.indexA = 0;\n ie[1].id.cf.indexB = primaryAxis.index;\n ie[1].id.cf.typeA = Manifold.e_vertex;\n ie[1].id.cf.typeB = Manifold.e_face;\n\n rf.i1 = primaryAxis.index;\n rf.i2 = rf.i1 + 1 < polygonBA.count ? rf.i1 + 1 : 0;\n rf.v1 = polygonBA.vertices[rf.i1];\n rf.v2 = polygonBA.vertices[rf.i2];\n rf.normal.set(polygonBA.normals[rf.i1]);\n }\n\n rf.sideNormal1.set(rf.normal.y, -rf.normal.x);\n rf.sideNormal2.setMul(-1, rf.sideNormal1);\n rf.sideOffset1 = Vec2.dot(rf.sideNormal1, rf.v1);\n rf.sideOffset2 = Vec2.dot(rf.sideNormal2, rf.v2);\n\n // Clip incident edge against extruded edge1 side edges.\n var clipPoints1 = [ new Manifold.clipVertex(), new Manifold.clipVertex() ];\n var clipPoints2 = [ new Manifold.clipVertex(), new Manifold.clipVertex() ];\n\n var np;\n\n // Clip to box side 1\n np = Manifold.clipSegmentToLine(clipPoints1, ie, rf.sideNormal1, rf.sideOffset1, rf.i1);\n\n if (np < Settings.maxManifoldPoints) {\n return;\n }\n\n // Clip to negative box side 1\n np = Manifold.clipSegmentToLine(clipPoints2, clipPoints1, rf.sideNormal2, rf.sideOffset2, rf.i2);\n\n if (np < Settings.maxManifoldPoints) {\n return;\n }\n\n // Now clipPoints2 contains the clipped points.\n if (primaryAxis.type == e_edgeA) {\n manifold.localNormal = Vec2.clone(rf.normal);\n manifold.localPoint = Vec2.clone(rf.v1);\n } else {\n manifold.localNormal = Vec2.clone(polygonB.m_normals[rf.i1]);\n manifold.localPoint = Vec2.clone(polygonB.m_vertices[rf.i1]);\n }\n\n var pointCount = 0;\n for (var i = 0; i < Settings.maxManifoldPoints; ++i) {\n var separation = Vec2.dot(rf.normal, Vec2.sub(clipPoints2[i].v, rf.v1));\n\n if (separation <= radius) {\n var cp = manifold.points[pointCount]; // ManifoldPoint\n\n if (primaryAxis.type == e_edgeA) {\n cp.localPoint = Transform.mulT(xf, clipPoints2[i].v);\n cp.id = clipPoints2[i].id;\n } else {\n cp.localPoint = clipPoints2[i].v;\n cp.id.cf.typeA = clipPoints2[i].id.cf.typeB;\n cp.id.cf.typeB = clipPoints2[i].id.cf.typeA;\n cp.id.cf.indexA = clipPoints2[i].id.cf.indexB;\n cp.id.cf.indexB = clipPoints2[i].id.cf.indexA;\n }\n\n ++pointCount;\n }\n }\n\n manifold.pointCount = pointCount;\n}\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nvar common = require('../util/common');\nvar Math = require('../common/Math');\nvar Transform = require('../common/Transform');\nvar Rot = require('../common/Rot');\nvar Vec2 = require('../common/Vec2');\nvar AABB = require('../collision/AABB');\nvar Settings = require('../Settings');\nvar Manifold = require('../Manifold');\nvar Contact = require('../Contact');\nvar Shape = require('../Shape');\nvar PolygonShape = require('./PolygonShape');\n\nmodule.exports = CollidePolygons;\n\nContact.addType(PolygonShape.TYPE, PolygonShape.TYPE, PolygonContact);\n\nfunction PolygonContact(manifold, xfA, fixtureA, indexA, xfB, fixtureB, indexB) {\n _ASSERT && common.assert(fixtureA.getType() == PolygonShape.TYPE);\n _ASSERT && common.assert(fixtureB.getType() == PolygonShape.TYPE);\n CollidePolygons(manifold, fixtureA.getShape(), xfA, fixtureB.getShape(), xfB);\n}\n\n/**\n * Find the max separation between poly1 and poly2 using edge normals from\n * poly1.\n */\nfunction FindMaxSeparation(poly1, xf1, poly2, xf2) {\n var count1 = poly1.m_count;\n var count2 = poly2.m_count;\n var n1s = poly1.m_normals;\n var v1s = poly1.m_vertices;\n var v2s = poly2.m_vertices;\n var xf = Transform.mulTXf(xf2, xf1);\n\n var bestIndex = 0;\n var maxSeparation = -Infinity;\n for (var i = 0; i < count1; ++i) {\n // Get poly1 normal in frame2.\n var n = Rot.mulVec2(xf.q, n1s[i]);\n var v1 = Transform.mulVec2(xf, v1s[i]);\n\n // Find deepest point for normal i.\n var si = Infinity;\n for (var j = 0; j < count2; ++j) {\n var sij = Vec2.dot(n, v2s[j]) - Vec2.dot(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 FindMaxSeparation._maxSeparation = maxSeparation;\n FindMaxSeparation._bestIndex = bestIndex;\n}\n\n/**\n * @param {ClipVertex[2]} c\n * @param {int} edge1\n */\nfunction FindIncidentEdge(c, poly1, xf1, edge1, poly2, xf2) {\n var normals1 = poly1.m_normals;\n\n var count2 = poly2.m_count;\n var vertices2 = poly2.m_vertices;\n var normals2 = poly2.m_normals;\n\n _ASSERT && common.assert(0 <= edge1 && edge1 < poly1.m_count);\n\n // Get the normal of the reference edge in poly2's frame.\n var normal1 = Rot.mulT(xf2.q, Rot.mulVec2(xf1.q, normals1[edge1]));\n\n // Find the incident edge on poly2.\n var index = 0;\n var minDot = Infinity;\n for (var i = 0; i < count2; ++i) {\n var dot = Vec2.dot(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 var i1 = index;\n var i2 = i1 + 1 < count2 ? i1 + 1 : 0;\n\n c[0].v = Transform.mulVec2(xf2, vertices2[i1]);\n c[0].id.cf.indexA = edge1;\n c[0].id.cf.indexB = i1;\n c[0].id.cf.typeA = Manifold.e_face;\n c[0].id.cf.typeB = Manifold.e_vertex;\n\n c[1].v = Transform.mulVec2(xf2, vertices2[i2]);\n c[1].id.cf.indexA = edge1;\n c[1].id.cf.indexB = i2;\n c[1].id.cf.typeA = Manifold.e_face;\n c[1].id.cf.typeB = Manifold.e_vertex;\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 */\nfunction CollidePolygons(manifold, polyA, xfA, polyB, xfB) {\n manifold.pointCount = 0;\n var totalRadius = polyA.m_radius + polyB.m_radius;\n\n FindMaxSeparation(polyA, xfA, polyB, xfB);\n var edgeA = FindMaxSeparation._bestIndex;\n var separationA = FindMaxSeparation._maxSeparation;\n if (separationA > totalRadius)\n return;\n\n FindMaxSeparation(polyB, xfB, polyA, xfA);\n var edgeB = FindMaxSeparation._bestIndex;\n var separationB = FindMaxSeparation._maxSeparation;\n if (separationB > totalRadius)\n return;\n\n var poly1; // reference polygon\n var poly2; // incident polygon\n var xf1;\n var xf2;\n var edge1; // reference edge\n var flip;\n var 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 = Manifold.e_faceB;\n flip = 1;\n } else {\n poly1 = polyA;\n poly2 = polyB;\n xf1 = xfA;\n xf2 = xfB;\n edge1 = edgeA;\n manifold.type = Manifold.e_faceA;\n flip = 0;\n }\n\n var incidentEdge = [ new Manifold.clipVertex(), new Manifold.clipVertex() ];\n FindIncidentEdge(incidentEdge, poly1, xf1, edge1, poly2, xf2);\n\n var count1 = poly1.m_count;\n var vertices1 = poly1.m_vertices;\n\n var iv1 = edge1;\n var iv2 = edge1 + 1 < count1 ? edge1 + 1 : 0;\n\n var v11 = vertices1[iv1];\n var v12 = vertices1[iv2];\n\n var localTangent = Vec2.sub(v12, v11);\n localTangent.normalize();\n\n var localNormal = Vec2.cross(localTangent, 1.0);\n var planePoint = Vec2.combine(0.5, v11, 0.5, v12);\n\n var tangent = Rot.mulVec2(xf1.q, localTangent);\n var normal = Vec2.cross(tangent, 1.0);\n\n v11 = Transform.mulVec2(xf1, v11);\n v12 = Transform.mulVec2(xf1, v12);\n\n // Face offset.\n var frontOffset = Vec2.dot(normal, v11);\n\n // Side offsets, extended by polytope skin thickness.\n var sideOffset1 = -Vec2.dot(tangent, v11) + totalRadius;\n var sideOffset2 = Vec2.dot(tangent, v12) + totalRadius;\n\n // Clip incident edge against extruded edge1 side edges.\n var clipPoints1 = [ new Manifold.clipVertex(), new Manifold.clipVertex() ];\n var clipPoints2 = [ new Manifold.clipVertex(), new Manifold.clipVertex() ];\n var np;\n\n // Clip to box side 1\n np = Manifold.clipSegmentToLine(clipPoints1, incidentEdge, Vec2.neg(tangent),\n sideOffset1, iv1);\n\n if (np < 2) {\n return;\n }\n\n // Clip to negative box side 1\n np = Manifold.clipSegmentToLine(clipPoints2, clipPoints1, tangent,\n sideOffset2, iv2);\n\n if (np < 2) {\n return;\n }\n\n // Now clipPoints2 contains the clipped points.\n manifold.localNormal = localNormal;\n manifold.localPoint = planePoint;\n\n var pointCount = 0;\n for (var i = 0; i < clipPoints2.length/* maxManifoldPoints */; ++i) {\n var separation = Vec2.dot(normal, clipPoints2[i].v) - frontOffset;\n\n if (separation <= totalRadius) {\n var cp = manifold.points[pointCount]; // ManifoldPoint\n cp.localPoint.set(Transform.mulTVec2(xf2, clipPoints2[i].v));\n cp.id = clipPoints2[i].id;\n if (flip) {\n // Swap features\n var cf = cp.id.cf; // ContactFeature\n var indexA = cf.indexA;\n var indexB = cf.indexB;\n var typeA = cf.typeA;\n var typeB = cf.typeB;\n cf.indexA = indexB;\n cf.indexB = indexA;\n cf.typeA = typeB;\n cf.typeB = typeA;\n }\n ++pointCount;\n }\n }\n\n manifold.pointCount = pointCount;\n}\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = EdgeShape;\n\nvar options = require('../util/options');\nvar Settings = require('../Settings');\nvar Shape = require('../Shape');\nvar Math = require('../common/Math');\nvar Transform = require('../common/Transform');\nvar Rot = require('../common/Rot');\nvar Vec2 = require('../common/Vec2');\nvar AABB = require('../collision/AABB');\n\nEdgeShape._super = Shape;\nEdgeShape.prototype = Object.create(EdgeShape._super.prototype);\n\nEdgeShape.TYPE = 'edge';\nShape.TYPES[EdgeShape.TYPE] = EdgeShape;\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 */\nfunction EdgeShape(v1, v2) {\n if (!(this instanceof EdgeShape)) {\n return new EdgeShape(v1, v2);\n }\n\n EdgeShape._super.call(this);\n\n this.m_type = EdgeShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n\n // These are the edge vertices\n this.m_vertex1 = v1 ? Vec2.clone(v1) : Vec2.zero();\n this.m_vertex2 = v2 ? Vec2.clone(v2) : Vec2.zero();\n\n // Optional adjacent vertices. These are used for smooth collision.\n // Used by chain shape.\n this.m_vertex0 = Vec2.zero();\n this.m_vertex3 = Vec2.zero();\n this.m_hasVertex0 = false;\n this.m_hasVertex3 = false;\n}\n\nEdgeShape.prototype._serialize = function() {\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\nEdgeShape._deserialize = function(data) {\n var shape = new EdgeShape(data.vertex1, data.vertex2);\n if (shape.hasVertex0) {\n shape.setPrev(data.vertex0);\n }\n if (shape.hasVertex3) {\n shape.setNext(data.vertex3);\n }\n return shape;\n};\n\nEdgeShape.prototype.setNext = function(v3) {\n if (v3) {\n this.m_vertex3.set(v3);\n this.m_hasVertex3 = true;\n } else {\n this.m_vertex3.setZero();\n this.m_hasVertex3 = false;\n }\n return this;\n};\n\nEdgeShape.prototype.setPrev = function(v0) {\n if (v0) {\n this.m_vertex0.set(v0);\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 * Set this as an isolated edge.\n */\nEdgeShape.prototype._set = function(v1, v2) {\n this.m_vertex1.set(v1);\n this.m_vertex2.set(v2);\n this.m_hasVertex0 = false;\n this.m_hasVertex3 = false;\n return this;\n}\n\n/**\n * @deprecated\n */\nEdgeShape.prototype._clone = function() {\n var clone = new EdgeShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_vertex1.set(this.m_vertex1);\n clone.m_vertex2.set(this.m_vertex2);\n clone.m_vertex0.set(this.m_vertex0);\n clone.m_vertex3.set(this.m_vertex3);\n clone.m_hasVertex0 = this.m_hasVertex0;\n clone.m_hasVertex3 = this.m_hasVertex3;\n return clone;\n}\n\nEdgeShape.prototype.getChildCount = function() {\n return 1;\n}\n\nEdgeShape.prototype.testPoint = function(xf, p) {\n return false;\n}\n\n// p = p1 + t * d\n// v = v1 + s * e\n// p1 + t * d = v1 + s * e\n// s * e - t * d = p1 - v1\nEdgeShape.prototype.rayCast = function(output, input, xf, childIndex) {\n // NOT_USED(childIndex);\n\n // Put the ray into the edge's frame of reference.\n var p1 = Rot.mulTVec2(xf.q, Vec2.sub(input.p1, xf.p));\n var p2 = Rot.mulTVec2(xf.q, Vec2.sub(input.p2, xf.p));\n var d = Vec2.sub(p2, p1);\n\n var v1 = this.m_vertex1;\n var v2 = this.m_vertex2;\n var e = Vec2.sub(v2, v1);\n var 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 var numerator = Vec2.dot(normal, Vec2.sub(v1, p1));\n var denominator = Vec2.dot(normal, d);\n\n if (denominator == 0.0) {\n return false;\n }\n\n var t = numerator / denominator;\n if (t < 0.0 || input.maxFraction < t) {\n return false;\n }\n\n var q = Vec2.add(p1, Vec2.mul(t, d));\n\n // q = v1 + s * r\n // s = dot(q - v1, r) / dot(r, r)\n var r = Vec2.sub(v2, v1);\n var rr = Vec2.dot(r, r);\n if (rr == 0.0) {\n return false;\n }\n\n var 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\nEdgeShape.prototype.computeAABB = function(aabb, xf, childIndex) {\n var v1 = Transform.mulVec2(xf, this.m_vertex1);\n var v2 = Transform.mulVec2(xf, this.m_vertex2);\n\n aabb.combinePoints(v1, v2);\n aabb.extend(this.m_radius)\n}\n\nEdgeShape.prototype.computeMass = function(massData, density) {\n massData.mass = 0.0;\n massData.center.setCombine(0.5, this.m_vertex1, 0.5, this.m_vertex2);\n massData.I = 0.0;\n}\n\nEdgeShape.prototype.computeDistanceProxy = function(proxy) {\n proxy.m_vertices.push(this.m_vertex1);\n proxy.m_vertices.push(this.m_vertex2);\n proxy.m_count = 2;\n proxy.m_radius = this.m_radius;\n};\n","/*\n * Planck.js\n * The MIT License\n * Copyright (c) 2021 Erin Catto, Ali Shakiba\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 */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = PolygonShape;\n\nvar common = require('../util/common');\nvar options = require('../util/options');\nvar Math = require('../common/Math');\nvar Transform = require('../common/Transform');\nvar Rot = require('../common/Rot');\nvar Vec2 = require('../common/Vec2');\nvar AABB = require('../collision/AABB');\nvar Settings = require('../Settings');\nvar Shape = require('../Shape');\n\nPolygonShape._super = Shape;\nPolygonShape.prototype = Object.create(PolygonShape._super.prototype);\n\nPolygonShape.TYPE = 'polygon';\nShape.TYPES[PolygonShape.TYPE] = PolygonShape;\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 */\nfunction PolygonShape(vertices) {\n if (!(this instanceof PolygonShape)) {\n return new PolygonShape(vertices);\n }\n\n PolygonShape._super.call(this);\n\n this.m_type = PolygonShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n this.m_centroid = Vec2.zero();\n this.m_vertices = []; // Vec2[Settings.maxPolygonVertices]\n this.m_normals = []; // Vec2[Settings.maxPolygonVertices]\n this.m_count = 0;\n\n if (vertices && vertices.length) {\n this._set(vertices);\n }\n}\n\nPolygonShape.prototype._serialize = function() {\n return {\n type: this.m_type,\n\n vertices: this.m_vertices,\n };\n};\n\nPolygonShape._deserialize = function(data, fixture, restore) {\n var vertices = [];\n if (data.vertices) {\n for (var i = 0; i < data.vertices.length; i++) {\n vertices.push(restore(Vec2, data.vertices[i]));\n }\n }\n\n var shape = new PolygonShape(vertices);\n return shape;\n};\n\nPolygonShape.prototype.getVertex = function(index) {\n _ASSERT && common.assert(0 <= index && index < this.m_count);\n return this.m_vertices[index];\n}\n\n/**\n * @deprecated\n */\nPolygonShape.prototype._clone = function() {\n var 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.set(this.m_centroid);\n for (var i = 0; i < this.m_count; i++) {\n clone.m_vertices.push(this.m_vertices[i].clone());\n }\n for (var i = 0; i < this.m_normals.length; i++) {\n clone.m_normals.push(this.m_normals[i].clone());\n }\n return clone;\n}\n\nPolygonShape.prototype.getChildCount = function() {\n return 1;\n}\n\nfunction ComputeCentroid(vs, count) {\n _ASSERT && common.assert(count >= 3);\n\n var c = Vec2.zero();\n var 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 var pRef = Vec2.zero();\n if (false) {\n // This code would put the reference point inside the polygon.\n for (var i = 0; i < count; ++i) {\n pRef.add(vs[i]);\n }\n pRef.mul(1.0 / count);\n }\n\n var inv3 = 1.0 / 3.0;\n\n for (var i = 0; i < count; ++i) {\n // Triangle vertices.\n var p1 = pRef;\n var p2 = vs[i];\n var p3 = i + 1 < count ? vs[i + 1] : vs[0];\n\n var e1 = Vec2.sub(p2, p1);\n var e2 = Vec2.sub(p3, p1);\n\n var D = Vec2.cross(e1, e2);\n\n var triangleArea = 0.5 * D;\n area += triangleArea;\n\n // Area weighted centroid\n c.addMul(triangleArea * inv3, p1);\n c.addMul(triangleArea * inv3, p2);\n c.addMul(triangleArea * inv3, p3);\n }\n\n // Centroid\n _ASSERT && common.assert(area > Math.EPSILON);\n c.mul(1.0 / area);\n return c;\n}\n\nPolygonShape.prototype._reset = function() {\n this._set(this.m_vertices)\n}\n\n/**\n * @private\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 */\nPolygonShape.prototype._set = function(vertices) {\n _ASSERT && common.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 var n = Math.min(vertices.length, Settings.maxPolygonVertices);\n\n // Perform welding and copy vertices into local buffer.\n var ps = []; // [Settings.maxPolygonVertices];\n for (var i = 0; i < n; ++i) {\n var v = vertices[i];\n\n var unique = true;\n for (var 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(v);\n }\n }\n\n n = ps.length;\n if (n < 3) {\n // Polygon is degenerate.\n _ASSERT && common.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 var i0 = 0;\n var x0 = ps[0].x;\n for (var i = 1; i < n; ++i) {\n var 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 var hull = []; // [Settings.maxPolygonVertices];\n var m = 0;\n var ih = i0;\n\n for (;;) {\n hull[m] = ih;\n\n var ie = 0;\n for (var j = 1; j < n; ++j) {\n if (ie === ih) {\n ie = j;\n continue;\n }\n\n var r = Vec2.sub(ps[ie], ps[hull[m]]);\n var v = Vec2.sub(ps[j], ps[hull[m]]);\n var c = Vec2.cross(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 _ASSERT && common.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 (var 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 (var i = 0; i < m; ++i) {\n var i1 = i;\n var i2 = i + 1 < m ? i + 1 : 0;\n var edge = Vec2.sub(this.m_vertices[i2], this.m_vertices[i1]);\n _ASSERT && common.assert(edge.lengthSquared() > Math.EPSILON * Math.EPSILON);\n this.m_normals[i] = Vec2.cross(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/**\n * @private\n */\nPolygonShape.prototype._setAsBox = function(hx, hy, center, angle) {\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 (Vec2.isValid(center)) {\n angle = angle || 0;\n\n this.m_centroid.set(center);\n\n var xf = Transform.identity();\n xf.p.set(center);\n xf.q.set(angle);\n\n // Transform vertices and normals.\n for (var 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\nPolygonShape.prototype.testPoint = function(xf, p) {\n var pLocal = Rot.mulTVec2(xf.q, Vec2.sub(p, xf.p));\n\n for (var i = 0; i < this.m_count; ++i) {\n var dot = Vec2.dot(this.m_normals[i], Vec2.sub(pLocal, this.m_vertices[i]));\n if (dot > 0.0) {\n return false;\n }\n }\n\n return true;\n}\n\nPolygonShape.prototype.rayCast = function(output, input, xf, childIndex) {\n\n // Put the ray into the polygon's frame of reference.\n var p1 = Rot.mulTVec2(xf.q, Vec2.sub(input.p1, xf.p));\n var p2 = Rot.mulTVec2(xf.q, Vec2.sub(input.p2, xf.p));\n var d = Vec2.sub(p2, p1);\n\n var lower = 0.0;\n var upper = input.maxFraction;\n\n var index = -1;\n\n for (var 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 var numerator = Vec2.dot(this.m_normals[i], Vec2.sub(this.m_vertices[i], p1));\n var 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 - Math.EPSILON)\n if (upper < lower) {\n return false;\n }\n }\n\n _ASSERT && common.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\nPolygonShape.prototype.computeAABB = function(aabb, xf, childIndex) {\n var minX = Infinity, minY = Infinity;\n var maxX = -Infinity, maxY = -Infinity;\n for (var i = 0; i < this.m_count; ++i) {\n var v = Transform.mulVec2(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 aabb.lowerBound.set(minX, minY);\n aabb.upperBound.set(maxX, maxY);\n aabb.extend(this.m_radius);\n}\n\nPolygonShape.prototype.computeMass = function(massData, density) {\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 _ASSERT && common.assert(this.m_count >= 3);\n\n var center = Vec2.zero();\n var area = 0.0;\n var 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 var s = Vec2.zero();\n\n // This code would put the reference point inside the polygon.\n for (var i = 0; i < this.m_count; ++i) {\n s.add(this.m_vertices[i]);\n }\n s.mul(1.0 / this.m_count);\n\n var k_inv3 = 1.0 / 3.0;\n\n for (var i = 0; i < this.m_count; ++i) {\n // Triangle vertices.\n var e1 = Vec2.sub(this.m_vertices[i], s);\n var e2 = i + 1 < this.m_count ? Vec2.sub(this.m_vertices[i + 1], s) : Vec2\n .sub(this.m_vertices[0], s);\n\n var D = Vec2.cross(e1, e2);\n\n var triangleArea = 0.5 * D;\n area += triangleArea;\n\n // Area weighted centroid\n center.addCombine(triangleArea * k_inv3, e1, triangleArea * k_inv3, e2);\n\n var ex1 = e1.x;\n var ey1 = e1.y;\n var ex2 = e2.x;\n var ey2 = e2.y;\n\n var intx2 = ex1 * ex1 + ex2 * ex1 + ex2 * ex2;\n var 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 _ASSERT && common.assert(area > Math.EPSILON);\n center.mul(1.0 / area);\n massData.center.setCombine(1, center, 1, 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\n * (Vec2.dot(massData.center, massData.center) - Vec2.dot(center, center));\n}\n\n// Validate convexity. This is a very time consuming operation.\n// @returns true if valid\nPolygonShape.prototype.validate = function() {\n for (var i = 0; i < this.m_count; ++i) {\n var i1 = i;\n var i2 = i < this.m_count - 1 ? i1 + 1 : 0;\n var p = this.m_vertices[i1];\n var e = Vec2.sub(this.m_vertices[i2], p);\n\n for (var j = 0; j < this.m_count; ++j) {\n if (j == i1 || j == i2) {\n continue;\n }\n\n var v = Vec2.sub(this.m_vertices[j], p);\n var c = Vec2.cross(e, v);\n if (c < 0.0) {\n return false;\n }\n }\n }\n\n return true;\n}\n\nPolygonShape.prototype.computeDistanceProxy = function(proxy) {\n proxy.m_vertices = this.m_vertices;\n proxy.m_count = this.m_count;\n proxy.m_radius = this.m_radius;\n};\n","/*\n * Copyright (c) 2016-2018 Ali Shakiba http://shakiba.me/planck.js\n *\n * This software is provided 'as-is', without any express or implied\n * warranty. In no event will the authors be held liable for any damages\n * arising from the use of this software.\n * Permission is granted to anyone to use this software for any purpose,\n * including commercial applications, and to alter it and redistribute it\n * freely, subject to the following restrictions:\n * 1. The origin of this software must not be misrepresented; you must not\n * claim that you wrote the original software. If you use this software\n * in a product, an acknowledgment in the product documentation would be\n * appreciated but is not required.\n * 2. Altered source versions must be plainly marked as such, and must not be\n * misrepresented as being the original software.\n * 3. This notice may not be removed or altered from any source distribution.\n */\n\nvar _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports = Pool;\n\nfunction Pool(opts) {\n var _list = [];\n var _max = opts.max || Infinity;\n\n var _createFn = opts.create;\n var _outFn = opts.allocate;\n var _inFn = opts.release;\n var _discardFn = opts.discard;\n\n var _createCount = 0;\n var _outCount = 0;\n var _inCount = 0;\n var _discardCount = 0;\n\n this.max = function(n) {\n if (typeof n === 'number') {\n _max = n;\n return this;\n }\n return _max;\n };\n\n this.size = function() {\n return _list.length;\n };\n\n this.allocate = function() {\n var item;\n if (_list.length > 0) {\n item = _list.shift();\n } else {\n _createCount++;\n if (typeof _createFn === 'function') {\n item = _createFn();\n } else {\n item = {};\n }\n }\n _outCount++;\n if (typeof _outFn === 'function') {\n _outFn(item);\n }\n return item;\n };\n\n this.release = function(item) {\n if (_list.length < _max) {\n _inCount++;\n if (typeof _inFn === 'function') {\n _inFn(item);\n }\n _list.push(item);\n } else {\n _discardCount++;\n if (typeof _discardFn === 'function') {\n item = _discardFn(item);\n }\n }\n };\n\n this.toString = function() {\n return \" +\" + _createCount + \" >\" + _outCount + \" <\" + _inCount + \" -\"\n + _discardCount + \" =\" + _list.length + \"/\" + _max;\n };\n}","var _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nmodule.exports.now = function() {\n return Date.now();\n}\n\nmodule.exports.diff = function(time) {\n return Date.now() - time;\n}\n","var _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nexports.debug = function() {\n if (!_DEBUG) return;\n console.log.apply(console, arguments);\n};\n\nexports.assert = function(statement, err, log) {\n if (!_ASSERT) return;\n if (statement) return;\n log && console.log(log);\n throw new Error(err);\n};","var _DEBUG = typeof DEBUG === 'undefined' ? false : DEBUG;\nvar _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;\n\nvar propIsEnumerable = Object.prototype.propertyIsEnumerable;\n\nmodule.exports = function(input, defaults) {\n if (input === null || typeof input === 'undefined') {\n input = {};\n }\n\n var output = Object.assign({}, input);\n\n for ( var 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 var symbols = Object.getOwnPropertySymbols(defaults);\n for (var i = 0; i < symbols.length; i++) {\n var symbol = symbols[i];\n if (defaults.propertyIsEnumerable(symbol) && typeof input[key] === 'undefined') {\n output[symbol] = defaults[symbol];\n }\n }\n }\n\n return output;\n};\n"],"names":["openDB","name","version","blocked","upgrade","blocking","terminated","request","indexedDB","open","openPromise","w","addEventListener","event","result","oldVersion","newVersion","transaction","then","db","catch","readMethods","writeMethods","cachedMethods","Map","getMethod","target","prop","IDBDatabase","get","targetFuncName","replace","useIndex","isWrite","includes","IDBIndex","IDBObjectStore","prototype","method","async","storeName","args","tx","this","store","index","shift","Promise","all","done","set","r","oldTraps","receiver","has","instanceOfAny","object","constructors","some","c","idbProxyableTypes","cursorAdvanceMethods","cursorRequestMap","WeakMap","transactionDoneMap","transactionStoreNamesMap","transformCache","reverseTransformCache","idbProxyTraps","IDBTransaction","objectStoreNames","undefined","objectStore","wrap","value","replaceTraps","callback","wrapFunction","func","IDBCursor","advance","continue","continuePrimaryKey","apply","unwrap","storeNames","call","sort","transformCachableValue","resolve","reject","unlisten","removeEventListener","complete","error","DOMException","cacheDonePromiseForTransaction","Proxy","IDBRequest","promise","success","promisifyRequest","newValue","advanceMethodProps","methodMap","advanceResults","ittrProxiedCursorToOriginalProxy","cursorIteratorTraps","cachedFunc","iterate","cursor","openCursor","proxiedCursor","u","delete","isIteratorProp","Symbol","asyncIterator","i","DEBUG","_ASSERT","ASSERT","module","exports","Body","common","options","Vec2","Rot","Math","Sweep","Transform","Velocity","Position","Fixture","staticBody","STATIC","kinematicBody","KINEMATIC","dynamicBody","DYNAMIC","BodyDef","type","position","zero","angle","linearVelocity","angularVelocity","linearDamping","angularDamping","fixedRotation","bullet","gravityScale","allowSleep","awake","active","userData","world","def","assert","isValid","isFinite","m_world","m_awakeFlag","m_autoSleepFlag","m_bulletFlag","m_fixedRotationFlag","m_activeFlag","m_islandFlag","m_toiFlag","m_userData","m_type","m_mass","m_invMass","m_I","m_invI","m_xf","identity","p","clone","q","setAngle","m_sweep","setTransform","c_velocity","c_position","m_force","m_torque","m_linearVelocity","m_angularVelocity","m_linearDamping","m_angularDamping","m_gravityScale","m_sleepTime","m_jointList","m_contactList","m_fixtureList","m_prev","m_next","m_destroyed","MassData","mass","center","I","_serialize","fixtures","f","push","getAngle","_deserialize","data","restore","body","length","fixture","_addFixture","isWorldLocked","isLocked","getWorld","getNext","setUserData","getUserData","getFixtureList","getJointList","getContactList","isStatic","isDynamic","isKinematic","setStatic","setType","setDynamic","setKinematic","getType","resetMassData","setZero","forward","synchronizeFixtures","setAwake","ce","ce0","next","destroyContact","contact","broadPhase","m_broadPhase","proxyCount","m_proxyCount","touchProxy","m_proxies","proxyId","isBullet","setBullet","flag","isSleepingAllowed","setSleepingAllowed","isAwake","isActive","setActive","createProxies","destroyProxies","isFixedRotation","setFixedRotation","getTransform","synchronize","synchronizeTransform","xf","alpha","c0","a","a0","getPosition","setPosition","getWorldCenter","getLocalCenter","localCenter","getLinearVelocity","getLinearVelocityFromWorldPoint","worldPoint","sub","add","cross","getLinearVelocityFromLocalPoint","localPoint","getWorldPoint","setLinearVelocity","v","dot","getAngularVelocity","setAngularVelocity","getLinearDamping","setLinearDamping","getAngularDamping","setAngularDamping","getGravityScale","setGravityScale","scale","getMass","getInertia","getMassData","m_density","massData","addMul","mul","oldCenter","setLocalCenter","setMassData","applyForce","force","point","wake","applyForceToCenter","applyTorque","torque","applyLinearImpulse","impulse","applyAngularImpulse","shouldCollide","that","jn","other","joint","m_collideConnected","m_newFixture","createFixture","shape","fixdef","destroyFixture","m_body","found","node","edge","fixtureA","getFixtureA","fixtureB","getFixtureB","publish","mulVec2","getWorldVector","localVector","getLocalPoint","mulTVec2","getLocalVector","worldVector","Mat22","Settings","Manifold","Distance","ContactEdge","prev","Contact","fA","indexA","fB","indexB","evaluateFcn","m_nodeA","m_nodeB","m_fixtureA","m_fixtureB","m_indexA","m_indexB","m_evaluateFcn","m_manifold","m_toi","m_toiCount","m_friction","mixFriction","m_restitution","mixRestitution","m_tangentSpeed","m_enabledFlag","m_touchingFlag","m_filterFlag","m_bulletHitFlag","v_points","v_normal","v_normalMass","v_K","v_pointCount","v_tangentSpeed","v_friction","v_restitution","v_invMassA","v_invMassB","v_invIA","v_invIB","p_localPoints","p_localNormal","p_localPoint","p_localCenterA","p_localCenterB","p_type","p_radiusA","p_radiusB","p_pointCount","p_invMassA","p_invMassB","p_invIA","p_invIB","VelocityConstraintPoint","rA","rB","normalImpulse","tangentImpulse","normalMass","tangentMass","velocityBias","friction1","friction2","sqrt","restitution1","restitution2","initConstraint","step","shapeA","getShape","shapeB","bodyA","getBody","bodyB","manifold","getManifold","pointCount","m_radius","localNormal","j","cp","points","vcp","warmStarting","dtRatio","getWorldManifold","worldManifold","setEnabled","isEnabled","isTouching","getChildIndexA","getChildIndexB","flagForFiltering","setFriction","friction","getFriction","resetFriction","setRestitution","restitution","getRestitution","resetRestitution","setTangentSpeed","speed","getTangentSpeed","evaluate","xfA","xfB","update","listener","touching","wasTouching","sensorA","isSensor","sensorB","sensor","testOverlap","oldManifold","nmp","omp","id","key","beginContact","endContact","preSolve","solvePositionConstraint","_solvePositionConstraint","solvePositionConstraintTOI","toiA","toiB","toi","positionA","positionB","localCenterA","localCenterB","mA","iA","mB","iB","cA","aA","cB","aB","minSeparation","normal","separation","e_circles","pointA","pointB","normalize","combine","e_faceA","planePoint","clipPoint","e_faceB","min","baumgarte","toiBaugarte","linearSlop","maxLinearCorrection","C","clamp","rnA","rnB","K","P","subMul","initVelocityConstraint","velocityA","velocityB","radiusA","radiusB","vA","wA","vB","wB","setCombine","kNormal","tangent","rtA","rtB","kTangent","vRel","velocityThreshold","blockSolve","vcp1","vcp2","rn1A","rn1B","rn2A","rn2B","k11","k22","k12","ex","ey","getInverse","warmStartConstraint","storeConstraintImpulses","solveVelocityConstraint","dv","addCombine","subCombine","vt","lambda","maxFriction","newImpulse","vn","max","neo","x","y","dv1","dv2","vn1","vn2","b","neg","d","P1","P2","s_registers","addType","type1","type2","create","typeA","typeB","destroy","destroyFcn","AABB","Shape","FixtureDef","density","filterGroupIndex","filterCategoryBits","filterMaskBits","FixtureProxy","childIndex","aabb","m_isSensor","m_filterGroupIndex","m_filterCategoryBits","m_filterMaskBits","m_shape","childCount","getChildCount","_reset","setSensor","getDensity","setDensity","testPoint","rayCast","output","input","computeMass","getAABB","proxy","computeAABB","createProxy","destroyProxy","xf1","xf2","aabb1","aabb2","displacement","moveProxy","setFilterData","filter","groupIndex","categoryBits","maskBits","refilter","getFilterGroupIndex","setFilterGroupIndex","getFilterCategoryBits","setFilterCategoryBits","getFilterMaskBits","setFilterMaskBits","collideA","collideB","Joint","JointEdge","m_bodyA","m_bodyB","m_index","collideConnected","m_edgeA","m_edgeB","TYPES","context","clazz","getBodyA","getBodyB","getCollideConnected","getAnchorA","getAnchorB","getReactionForce","inv_dt","getReactionTorque","shiftOrigin","newOrigin","initVelocityConstraints","solveVelocityConstraints","solvePositionConstraints","ManifoldPoint","ContactID","cf","ContactFeature","WorldManifold","separations","clipSegmentToLine","vOut","vIn","offset","vertexIndexA","numOut","distance0","distance1","interp","e_vertex","e_face","clipVertex","ClipVertex","getPointStates","state1","state2","manifold1","manifold2","PointState","removeState","persistState","addState","Object","defineProperty","enumerable","configurable","o","wm","dist","lengthSquared","EPSILON","mid","nullState","maxManifoldPoints","maxPolygonVertices","aabbExtension","aabbMultiplier","linearSlopSquared","angularSlop","PI","polygonRadius","maxSubSteps","maxTOIContacts","maxTOIIterations","maxDistnceIterations","maxAngularCorrection","maxTranslation","maxTranslationSquared","maxRotation","maxRotationSquared","timeToSleep","linearSleepTolerance","linearSleepToleranceSqr","pow","angularSleepTolerance","angularSleepToleranceSqr","getRadius","_clone","transform","computeDistanceProxy","_DEBUG","Solver","TimeStep","TimeOfImpact","TOIInput","Input","TOIOutput","Output","Cache","dt","velocityIterations","positionIterations","inv_dt0","m_stack","m_bodies","m_contacts","m_joints","reset","clear","addBody","addContact","addJoint","solveWorld","m_bodyList","stack","seed","pop","je","solveIsland","gravity","m_gravity","m_allowSleep","h","printBodies","translation","ratio","rotation","abs","positionSolved","contactsOkay","jointsOkay","jointOkay","postSolveIsland","minSleepTime","Infinity","linTolSqr","angTolSqr","tag","debug","s_subStep","ContactImpulse","normalImpulses","tangentImpulses","solveWorldTOI","m_stepComplete","alpha0","minContact","minAlpha","bA","bB","activeA","activeB","proxyA","proxyB","sweepA","sweepB","tMax","beta","t","state","e_touching","backup1","backup2","bodies","backup","solveIslandTOI","findNewContacts","m_subStepping","subStep","postSolve","World","BroadPhase","WorldDef","continuousPhysics","subStepping","m_solver","m_contactCount","m_bodyCount","m_jointCount","m_clearForces","m_locked","m_warmStarting","m_continuousPhysics","m_blockSolve","m_velocityIterations","m_positionIterations","m_t","addPair","createContact","bind","joints","getBodyList","_addBody","createJoint","getBodyCount","getJointCount","getContactCount","setGravity","getGravity","setAllowSleeping","getAllowSleeping","setWarmStarting","getWarmStarting","setContinuousPhysics","getContinuousPhysics","setSubStepping","getSubStepping","setAutoClearForces","getAutoClearForces","clearForces","queryAABB","queryCallback","query","point1","point2","reportFixtureCallback","maxFraction","p1","p2","fraction","getProxyCount","getTreeHeight","getTreeBalance","getTreeQuality","createBody","createDynamicBody","createKinematicBody","destroyBody","je0","destroyJoint","f0","s_step","timeStep","updateContacts","updatePairs","next_c","proxyIdA","proxyIdB","_listeners","on","off","listeners","indexOf","splice","arg1","arg2","arg3","l","lower","upper","lowerBound","upperBound","Error","getCenter","getExtents","getPerimeter","lowerA","upperA","lowerB","upperB","lowerX","lowerY","upperX","upperY","combinePoints","contains","extend","d1x","d2x","d1y","d2y","areEqual","diff","wD","hD","tmin","tmax","absD","inv_d","t1","t2","s","temp","toString","JSON","stringify","DynamicTree","m_tree","m_moveBuffer","aabbA","getFatAABB","aabbB","getHeight","getMaxBalance","getAreaRatio","rayCastCallback","bufferMove","unbufferMove","addPairCallback","m_callback","m_queryProxyId","fatAABB","userDataA","userDataB","DistanceInput","DistanceOutput","DistanceProxy","SimplexCache","stats","transformA","transformB","useRadii","distance","iterations","metric","count","cache","gjkCalls","simplex","Simplex","readCache","vertices","m_v","k_maxIters","saveA","saveB","saveCount","iter","m_count","solve","getClosestPoint","getSearchDirection","vertex","getSupport","getVertex","gjkIters","duplicate","gjkMaxIters","getWitnessPoints","writeCache","m_buffer","m_vertices","SimplexVertex","m_v1","m_v2","m_v3","getVertexCount","bestIndex","bestValue","getSupportVertex","print","wALocal","wBLocal","metric1","metric2","getMetric","e12","pA","pB","solve2","solve3","w1","w2","d12_2","d12_1","inv_d12","w3","w1e12","e13","w1e13","d13_1","d13_2","e23","w2e23","d23_1","d23_2","n123","d123_1","d123_2","d123_3","inv_d13","inv_d23","inv_d123","Pool","TreeNode","parent","child1","child2","height","m_root","m_nodes","m_lastProxyId","m_pool","isLeaf","allocateNode","allocate","freeNode","release","insertLeaf","removeLeaf","leaf","leafAABB","area","combinedAABB","cost1","cost2","combinedArea","cost","inheritanceCost","oldArea","sibling","oldParent","newParent","balance","grandParent","A","B","F","G","D","E","rootArea","totalArea","it","iteratorPool","preorder","computeHeight","height1","height2","validateStructure","validateMetrics","validate","maxBalance","rebuildBottomUp","nodes","minCost","iMin","jMin","aabbi","aabbj","stackPool","abs_v","segmentAABB","subInput","inputPool","Iterator","iterator","close","parents","states","root","timer","Timer","now","toiCalls","e_unknown","totalRadius","tolerance","k_maxIterations","distanceInput","distanceOutput","e_overlapped","fcn","SeparationFunction","initialize","pushBackIter","s2","findMinSeparation","e_separated","s1","e_failed","rootIterCount","a1","a2","toiRootIters","toiMaxRootIters","toiIters","toiMaxIters","time","toiMaxTime","toiTime","m_proxyA","m_proxyB","m_sweepA","m_sweepB","m_localPoint","m_axis","localPointA","localPointB","localPointB1","localPointB2","localPointA1","localPointA2","compute","find","axisA","axisB","setIdentity","det","imx","mx","mulMat22","mulT","mulTMat22","mx1","mx2","Mat33","Vec3","ez","solve33","z","solve22","a11","a12","a21","a22","getInverse22","M","getSymInverse33","a13","a23","a33","mulVec3","native","math","isNaN","invSqrt","nextPowerOfTwo","isPowerOfTwo","mod","num","random","obj","rot","sin","cos","atan2","getXAxis","getYAxis","m","qr","mulRot","mulSub","mulTRot","Array","isArray","arr","mulAll","mulFn","mulXf","px","py","mulTXf","wSet","setMul","wAdd","wSub","lengthOf","invLength","dx","dy","distanceSquared","skew","addCross","lengthSqr","scaleFn","translateFn","newline","string","internal","Circle","Polygon","Box","CollidePolygons","DistanceJoint","TYPE","_super","DEFAULTS","frequencyHz","dampingRatio","anchorA","anchorB","m_localAnchorA","localAnchorA","m_localAnchorB","localAnchorB","m_length","m_frequencyHz","m_dampingRatio","m_impulse","m_gamma","m_bias","m_u","m_rA","m_rB","m_localCenterA","m_localCenterB","m_invMassA","m_invMassB","m_invIA","m_invIB","gamma","bias","assign","_setAnchors","getLocalAnchorA","getLocalAnchorB","setLength","getLength","setFrequency","hz","getFrequency","setDampingRatio","getDampingRatio","qA","qB","crAu","crBu","invMass","omega","k","vpA","vpB","Cdot","FrictionJoint","maxForce","maxTorque","anchor","m_linearImpulse","m_angularImpulse","m_maxForce","m_maxTorque","m_linearMass","m_angularMass","setMaxForce","getMaxForce","setMaxTorque","getMaxTorque","oldImpulse","maxImpulse","GearJoint","RevoluteJoint","PrismaticJoint","joint1","joint2","coordinateA","coordinateB","m_joint1","m_joint2","m_ratio","m_type1","m_type2","m_bodyC","xfC","aC","revolute","m_localAnchorC","m_referenceAngleA","m_referenceAngle","m_localAxisC","prismatic","m_localXAxisA","pC","m_bodyD","xfD","aD","m_localAnchorD","m_referenceAngleB","m_localAxisD","pD","m_constant","m_lcA","m_lcB","m_lcC","m_lcD","m_mA","m_mB","m_mC","m_mD","m_iA","m_iB","m_iC","m_iD","m_JvAC","m_JvBD","m_JwA","m_JwB","m_JwC","m_JwD","getJoint1","getJoint2","setRatio","getRatio","vC","wC","vD","qC","qD","rC","rD","JvAC","JvBD","JwA","JwB","JwC","JwD","cC","cD","MotorJoint","correctionFactor","m_linearOffset","linearOffset","m_angularOffset","angularOffset","m_correctionFactor","m_linearError","m_angularError","setCorrectionFactor","factor","getCorrectionFactor","setLinearOffset","getLinearOffset","setAngularOffset","getAngularOffset","inv_h","MouseJoint","m_targetA","m_beta","m_C","_localAnchorB","setTarget","getTarget","velocity","inactiveLimit","enableLimit","lowerTranslation","upperTranslation","enableMotor","maxMotorForce","motorSpeed","axis","localAxisA","m_localYAxisA","referenceAngle","m_motorMass","m_motorImpulse","m_lowerTranslation","m_upperTranslation","m_maxMotorForce","m_motorSpeed","m_enableLimit","m_enableMotor","m_limitState","m_perp","m_s1","m_s2","m_a1","m_a2","m_K","getLocalAxisA","getReferenceAngle","getJointTranslation","getJointSpeed","isLimitEnabled","getLowerLimit","getUpperLimit","setLimits","isMotorEnabled","setMotorSpeed","setMaxMotorForce","getMaxMotorForce","getMotorSpeed","getMotorForce","k13","k23","k33","jointTranslation","LA","LB","Cdot1","Cdot2","f1","df","f2r","perp","C1","linearError","angularError","C2","impulse1","PulleyJoint","MIN_PULLEY_LENGTH","PulleyJointDef","groundA","groundB","m_groundAnchorA","groundAnchorA","m_groundAnchorB","groundAnchorB","m_lengthA","lengthA","m_lengthB","lengthB","m_uA","m_uB","getGroundAnchorA","getGroundAnchorB","getLengthA","getLengthB","getCurrentLengthA","getCurrentLengthB","ruA","ruB","PA","PB","uA","uB","lowerAngle","upperAngle","maxMotorTorque","m_lowerAngle","m_upperAngle","m_maxMotorTorque","getJointAngle","getMotorTorque","setMaxMotorTorque","getMaxMotorTorque","jointAngle","rhs","reduced","positionError","limitImpulse","RopeJoint","maxLength","m_maxLength","m_state","setMaxLength","getMaxLength","getLimitState","crA","crB","WeldJoint","invM","impulse2","WheelJoint","localAxis","m_springMass","m_springImpulse","m_ax","m_ay","m_sAx","m_sBx","m_sAy","m_sBy","setSpringFrequencyHz","getSpringFrequencyHz","setSpringDampingRatio","getSpringDampingRatio","ay","sAy","sBy","SID","Serializer","opts","rootClass","preSerialize","postSerialize","preDeserialize","postDeserialize","refTypes","restoreTypes","toJson","json","queue","refMap","storeRef","typeName","__sid","ref","refIndex","refType","top","serialize","hasOwnProperty","str","fromJson","deserialize","cls","ctx","restoreRef","serializer","BoxShape","PolygonShape","hx","hy","_setAsBox","ChainShape","EdgeShape","loop","m_prevVertex","m_nextVertex","m_hasPrevVertex","m_hasNextVertex","m_isLoop","_createLoop","_createChain","isLoop","hasPrevVertex","hasNextVertex","prevVertex","nextVertex","setPrevVertex","setNextVertex","v1","v2","createChain","getChildEdge","m_vertex1","m_vertex2","m_vertex0","m_hasVertex0","m_vertex3","m_hasVertex3","CircleShape","m_p","radius","rr","sigma","CollideCircles","circleA","circleB","distSqr","polygonA","cLocal","normalIndex","vertexCount","normals","m_normals","vertIndex1","vertIndex2","u1","u2","faceCenter","CollidePolygonCircle","CollideEdgeCircle","edgeA","Q","e","A1","B1","e1","B2","A2","e2","den","n","chain","CollideEdgePolygon","e_edgeA","e_edgeB","EPAxis","edgeAxis","polygonAxis","polygonBA","rf","i1","i2","sideNormal1","sideOffset1","sideNormal2","sideOffset2","polygonB","centroidB","m_centroid","v0","v3","hasVertex0","hasVertex3","edge1","front","normal1","offset1","offset0","offset2","convex1","convex2","edge0","normal0","edge2","normal2","lowerLimit","upperLimit","primaryAxis","ie","clipPoints1","clipPoints2","FindMaxSeparation","poly1","poly2","count1","count2","n1s","v1s","v2s","maxSeparation","si","sij","_maxSeparation","_bestIndex","polyA","polyB","separationA","edgeB","separationB","flip","incidentEdge","normals1","vertices2","normals2","minDot","FindIncidentEdge","vertices1","iv1","iv2","v11","v12","localTangent","frontOffset","vertex1","vertex2","vertex0","vertex3","setPrev","setNext","_set","numerator","denominator","ps","unique","i0","x0","hull","ih","vs","pRef","inv3","p3","triangleArea","ComputeCentroid","pLocal","minX","minY","maxX","maxY","k_inv3","ex1","ey1","ex2","ey2","_list","_max","_createFn","_outFn","_inFn","_discardFn","discard","_createCount","_outCount","_inCount","_discardCount","size","item","Date","console","log","arguments","statement","err","propertyIsEnumerable","defaults","getOwnPropertySymbols","symbols","symbol"],"sourceRoot":""}