-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js.map
1 lines (1 loc) · 102 KB
/
main.js.map
1
{"version":3,"sources":["webpack://test-iterative-solver/./box.ts","webpack://test-iterative-solver/./circle.ts","webpack://test-iterative-solver/./collider.ts","webpack://test-iterative-solver/./contact.ts","webpack://test-iterative-solver/./line.ts","webpack://test-iterative-solver/./math.ts","webpack://test-iterative-solver/./separating-axis.ts","webpack://test-iterative-solver/./solver.ts","webpack://test-iterative-solver/./transform.ts","webpack://test-iterative-solver/./vector.ts","webpack://test-iterative-solver/webpack/bootstrap","webpack://test-iterative-solver/./main.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAAkC;AAClC,wEAAsC;AACtC,4DAA8B;AAC9B,6FAAmD;AACnD,kEAAkC;AAElC;IAAyB,uBAAQ;IAC7B,aAAmB,KAAa,EAAS,MAAc,EAAE,GAAW;QAApE,YACI,iBAAO,SAGV;QAJkB,WAAK,GAAL,KAAK,CAAQ;QAAS,YAAM,GAAN,MAAM,CAAQ;QAEnD,KAAI,CAAC,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC;QAClB,KAAI,CAAC,IAAI,GAAG,CAAC,CAAC;;IAClB,CAAC;IAED,sBAAI,4BAAW;aAAf;YACI,IAAM,UAAU,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;YACnC,IAAM,SAAS,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;YAEjC,IAAM,MAAM,GAAa;gBACrB,IAAI,eAAM,CAAC,CAAC,SAAS,EAAE,CAAC,UAAU,CAAC;gBACnC,IAAI,eAAM,CAAC,SAAS,EAAE,CAAC,UAAU,CAAC;gBAClC,IAAI,eAAM,CAAC,SAAS,EAAE,UAAU,CAAC;gBACjC,IAAI,eAAM,CAAC,CAAC,SAAS,EAAE,UAAU,CAAC;aACrC,CAAC;YACF,OAAO,MAAM,CAAC;QAClB,CAAC;;;OAAA;IAED,sBAAI,u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AAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACtB;AACL,CAAC,CAAC","file":"main.js","sourcesContent":["import { Circle } from \"./circle\";\r\nimport { Collider } from \"./collider\";\r\nimport { Line } from \"./line\";\r\nimport { SeparatingAxis } from \"./separating-axis\";\r\nimport { Vector } from \"./vector\";\r\n\r\nexport class Box extends Collider {\r\n constructor(public width: number, public height: number, pos: Vector) {\r\n super();\r\n this.xf.pos = pos;\r\n this.mass = 1;\r\n }\r\n\r\n get localPoints(): readonly Vector[] {\r\n const halfHeight = this.height / 2;\r\n const halfWidth = this.width / 2;\r\n\r\n const points: Vector[] = [\r\n new Vector(-halfWidth, -halfHeight),\r\n new Vector(halfWidth, -halfHeight),\r\n new Vector(halfWidth, halfHeight),\r\n new Vector(-halfWidth, halfHeight)\r\n ];\r\n return points;\r\n }\r\n\r\n get points(): readonly Vector[] {\r\n const pos = this.xf.pos;\r\n const rot = this.xf.rotation;\r\n\r\n const halfHeight = this.height / 2;\r\n const halfWidth = this.width / 2;\r\n\r\n const points: Vector[] = [\r\n pos.add(new Vector(-halfWidth, -halfHeight)),\r\n pos.add(new Vector(halfWidth, -halfHeight)),\r\n pos.add(new Vector(halfWidth, halfHeight)),\r\n pos.add(new Vector(-halfWidth, halfHeight))\r\n ].map(p => p.rotate(rot, pos));\r\n\r\n return points;\r\n } \r\n\r\n get inverseMass() {\r\n return this.static ? 0 : 1 / this.mass;\r\n }\r\n\r\n get inertia() {\r\n // https://en.wikipedia.org/wiki/List_of_moments_of_inertia\r\n return (this.mass/12) * (this.width + this.height * this.height);\r\n }\r\n\r\n get inverseInertia() {\r\n return this.static ? 0 : 1 / this.inertia;\r\n }\r\n\r\n collide(other: Circle | Line | Box) {\r\n if (other instanceof Circle) {\r\n return SeparatingAxis.findCircleBoxContact(other, this);\r\n }\r\n\r\n if (other instanceof Box) {\r\n return SeparatingAxis.findBoxBoxContact(this, other)\r\n }\r\n\r\n if (other instanceof Line) {\r\n null; // TODO line\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * ```\r\n * +----- 0 \"top\" -----+\r\n * | |\r\n * | 3 \"left\" | 1 \"right\"\r\n * | |\r\n * | |\r\n * +----- 2 \"bottom\"---+\r\n * ```\r\n * @param index \r\n */\r\n getSide(index: number): [Vector, Vector] {\r\n const pts = this.points;\r\n const len = this.points.length;\r\n return [pts[index], pts[(index + 1) % len]];\r\n }\r\n\r\n getLocalSide(index: number): [Vector, Vector] {\r\n const pts = this.localPoints;\r\n const len = this.localPoints.length;\r\n return [pts[index], pts[(index + 1) % len]];\r\n }\r\n\r\n /**\r\n * Find the point on the shape furthest in the direction specified\r\n */\r\n getFurthestPoint(direction: Vector): Vector {\r\n const pts = this.points;\r\n let furthestPoint = pts[0];\r\n let maxDistance = -Number.MAX_VALUE;\r\n for (let i = 0; i < pts.length; i++) {\r\n const distance = direction.dot(pts[i]);\r\n if (distance > maxDistance) {\r\n maxDistance = distance;\r\n furthestPoint = pts[i];\r\n }\r\n }\r\n return furthestPoint;\r\n }\r\n\r\n getFurthestLocalPoint(direction: Vector): Vector {\r\n const pts = this.localPoints;\r\n let furthestPoint = pts[0];\r\n let maxDistance = -Number.MAX_VALUE;\r\n for (let i = 0; i < pts.length; i++) {\r\n const distance = direction.dot(pts[i]);\r\n if (distance > maxDistance) {\r\n maxDistance = distance;\r\n furthestPoint = pts[i];\r\n }\r\n }\r\n return furthestPoint;\r\n }\r\n\r\n findSide(direction: Vector): [Vector, Vector] {\r\n let bestSide = this.getSide(0);\r\n let maxDistance = -Number.MAX_VALUE;\r\n for (let side = 0; side < 4; side++) {\r\n let currentSide = this.getSide(side);\r\n const sideNormal = currentSide[1].sub(currentSide[0]).normal();\r\n const mostDirection = sideNormal.dot(direction);\r\n if (mostDirection > maxDistance) {\r\n bestSide = currentSide;\r\n maxDistance = mostDirection;\r\n }\r\n }\r\n return bestSide;\r\n }\r\n\r\n findLocalSide(direction: Vector): [Vector, Vector] {\r\n let bestSide = this.getLocalSide(0);\r\n let maxDistance = -Number.MAX_VALUE;\r\n for (let side = 0; side < 4; side++) {\r\n let currentSide = this.getLocalSide(side);\r\n const sideNormal = currentSide[1].sub(currentSide[0]).normal();\r\n const mostDirection = sideNormal.dot(direction);\r\n if (mostDirection > maxDistance) {\r\n bestSide = currentSide;\r\n maxDistance = mostDirection;\r\n }\r\n }\r\n return bestSide;\r\n }\r\n\r\n draw(ctx: CanvasRenderingContext2D, flags: any) {\r\n\r\n for (let side = 0; side < 4; side++) {\r\n let currentSide = this.getSide(side);\r\n ctx.save();\r\n ctx.beginPath();\r\n ctx.strokeStyle = 'green'\r\n ctx.moveTo(currentSide[0].x, currentSide[0].y);\r\n ctx.lineTo(currentSide[1].x, currentSide[1].y);\r\n ctx.closePath();\r\n ctx.stroke();\r\n ctx.restore();\r\n }\r\n if (flags[\"Debug\"]) {\r\n ctx.fillStyle = 'yellow';\r\n ctx.fillText('id: ' + this.id, this.xf.pos.x, this.xf.pos.y);\r\n }\r\n }\r\n}","import { Box } from \"./box\";\r\nimport { Collider } from \"./collider\";\r\nimport { Contact } from \"./contact\";\r\nimport { Line } from \"./line\";\r\nimport { SeparatingAxis } from \"./separating-axis\";\r\nimport { Vector } from \"./vector\";\r\n\r\nexport class Circle extends Collider {\r\n constructor(public radius: number, pos: Vector) {\r\n super();\r\n this.xf.pos = pos;\r\n this.mass = 1;\r\n }\r\n\r\n get inverseMass() {\r\n return this.static ? 0 : 1 / this.mass;\r\n }\r\n\r\n get inertia() {\r\n return (this.mass * this.radius * this.radius) / 2;\r\n }\r\n\r\n get inverseInertia() {\r\n return this.static ? 0 : 1 / this.inertia;\r\n }\r\n\r\n /**\r\n * Returns a contact in the direction from `this` -> `other`\r\n * @param other \r\n * @returns \r\n */\r\n collide(other: Circle | Line | Box, contact?: Contact): Contact | null {\r\n if (other instanceof Circle) {\r\n return SeparatingAxis.findCircleCircleContact(this, other);\r\n }\r\n\r\n if (other instanceof Box) {\r\n return SeparatingAxis.findCircleBoxContact(this, other)\r\n }\r\n\r\n if (other instanceof Line) {\r\n return other.collide(this);\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Apply impulse at a point\r\n * @param point \r\n * @param impulse \r\n * @returns \r\n */\r\n applyImpulse(point: Vector, impulse: Vector) {\r\n if (this.static) {\r\n return;\r\n }\r\n\r\n const distanceFromCenter = point.sub(this.xf.pos);\r\n\r\n this.m.vel = this.m.vel.add(impulse.scale(this.inverseMass));\r\n this.m.angularVelocity += this.inverseInertia * distanceFromCenter.cross(impulse);\r\n }\r\n\r\n /**\r\n * Find the point on the shape furthest in the direction specified\r\n */\r\n getFurthestPoint(direction: Vector): Vector {\r\n const dir = direction.normalize();\r\n return this.xf.pos.add(dir.scale(this.radius));\r\n }\r\n\r\n getFurthestLocalPoint(direction: Vector): Vector {\r\n const dir = direction.normalize();\r\n return dir.scale(this.radius);\r\n }\r\n\r\n draw(ctx: CanvasRenderingContext2D, flags?: any) {\r\n ctx.beginPath();\r\n ctx.fillStyle = 'blue';\r\n ctx.arc(this.xf.pos.x, this.xf.pos.y, this.radius, 0, Math.PI * 2);\r\n ctx.closePath();\r\n ctx.fill();\r\n\r\n if (flags[\"Debug\"]) {\r\n ctx.fillStyle = 'yellow';\r\n ctx.fillText('id: ' + this.id, this.xf.pos.x, this.xf.pos.y);\r\n }\r\n\r\n ctx.save();\r\n ctx.translate(this.xf.pos.x, this.xf.pos.y);\r\n ctx.rotate(this.xf.rotation);\r\n ctx.beginPath()\r\n ctx.strokeStyle = 'black';\r\n ctx.moveTo(0, 0);\r\n ctx.lineTo(0 + this.radius, 0);\r\n ctx.closePath();\r\n ctx.stroke();\r\n ctx.restore();\r\n }\r\n}","import { Contact } from \"./contact\";\r\nimport { Motion, Transform } from \"./transform\";\r\nimport { Vector } from \"./vector\";\r\n\r\nexport abstract class Collider {\r\n private static _ID = 0;\r\n public id = Collider._ID++;\r\n public static = false;\r\n public mass = 1;\r\n \r\n public bounciness = 0.1;\r\n public friction = .99;\r\n public xf = new Transform();\r\n public m = new Motion();\r\n\r\n get inverseMass() {\r\n return this.static ? 0 : 1 / this.mass;\r\n }\r\n\r\n get inertia() {\r\n return this.mass;\r\n }\r\n\r\n get inverseInertia() {\r\n return this.static ? 0 : 1 / this.inertia;\r\n }\r\n\r\n /**\r\n * Apply impulse at a point\r\n * @param point \r\n * @param impulse \r\n * @returns \r\n */\r\n applyImpulse(point: Vector, impulse: Vector) {\r\n if (this.static) {\r\n return;\r\n }\r\n\r\n const distanceFromCenter = point.sub(this.xf.pos);\r\n\r\n this.m.vel = this.m.vel.add(impulse.scale(this.inverseMass));\r\n this.m.angularVelocity += this.inverseInertia * distanceFromCenter.cross(impulse);\r\n }\r\n\r\n applyLinearImpulse(impulse: Vector) {\r\n if (this.static) {\r\n return;\r\n }\r\n\r\n this.m.vel = this.m.vel.add(impulse.scale(this.inverseMass));\r\n }\r\n\r\n applyAngularImpulse(point: Vector, impulse: Vector) {\r\n if (this.static) {\r\n return;\r\n }\r\n\r\n const distanceFromCenter = point.sub(this.xf.pos);\r\n\r\n this.m.angularVelocity += this.inverseInertia * distanceFromCenter.cross(impulse);\r\n }\r\n\r\n abstract collide(collider: Collider, contact?: Contact): Contact | null;\r\n abstract draw(ctx: CanvasRenderingContext2D, flags: any): void;\r\n}","import { Collider } from \"./collider\";\r\nimport { ContactInfo } from \"./separating-axis\";\r\nimport { Vector } from \"./vector\";\r\n\r\n/**\r\n * Represents contact between two rigid bodies\r\n * \r\n * Meant to be re-used over multiple frames\r\n */\r\nexport class Contact {\r\n\r\n /**\r\n * The unique id between 2 bodies\r\n */\r\n public get id() {\r\n return Contact.GetId(this.bodyA, this.bodyB);\r\n }\r\n\r\n /**\r\n * Get the id of 2 bodies\r\n * @param bodyA \r\n * @param bodyB \r\n * @returns \r\n */\r\n public static GetId(bodyA: Collider, bodyB: Collider) {\r\n if (bodyA.id < bodyB.id) {\r\n return `${bodyA.id}+${bodyB.id}`;\r\n } else {\r\n return `${bodyB.id}+${bodyA.id}`;\r\n }\r\n }\r\n\r\n constructor(\r\n public bodyA: Collider,\r\n public bodyB: Collider,\r\n /**\r\n * Normals point away from bodyA\r\n */\r\n public normal: Vector,\r\n /**\r\n * Tangent to collision normal \r\n */\r\n public tangent: Vector,\r\n // TODO should this just be part of contact?\r\n public info: ContactInfo,\r\n /**\r\n * World space contact points\r\n */\r\n public points: Vector[] = [],\r\n /**\r\n * Local space contact points\r\n */\r\n public locals: Vector[] = []\r\n ) {}\r\n}","import { Circle } from \"./circle\";\r\nimport { Collider } from \"./collider\";\r\nimport { Contact } from \"./contact\";\r\nimport { assert } from \"./math\";\r\nimport { ContactInfo } from \"./separating-axis\";\r\nimport { Vector } from \"./vector\";\r\n\r\nexport class Line extends Collider {\r\n static = true;\r\n constructor(public begin: Vector, public end: Vector) {\r\n super();\r\n this.xf.pos = begin.add(end).scale(.5);\r\n }\r\n\r\n getSeparation(other: Circle) {\r\n // center of the circle\r\n const cc = other.xf.pos;\r\n // vector in the direction of the edge\r\n const e = this.end.sub(this.begin);\r\n // amount of overlap with the circle's center along the edge direction\r\n const u = e.dot(this.end.sub(cc));\r\n const v = e.dot(cc.sub(this.begin));\r\n\r\n const den = e.dot(e);\r\n const pointOnEdge = this.begin\r\n .scale(u)\r\n .add(this.end.scale(v))\r\n .scale(1 / den);\r\n const d = cc.sub(pointOnEdge);\r\n\r\n const dd = d.dot(d);\r\n\r\n const sep = -Math.abs(other.radius - Math.sqrt(dd));\r\n \r\n return sep;\r\n }\r\n \r\n collide(other: Circle | Line, contact?: Contact): Contact | null {\r\n if (other instanceof Circle) {\r\n\r\n // center of the circle\r\n const cc = other.xf.pos;\r\n // vector in the direction of the edge\r\n const e = this.end.sub(this.begin);\r\n \r\n // amount of overlap with the circle's center along the edge direction\r\n const u = e.dot(this.end.sub(cc));\r\n const v = e.dot(cc.sub(this.begin));\r\n \r\n // Potential region A collision (circle is on the left side of the edge, before the beginning)\r\n if (v <= 0) {\r\n const da = this.begin.sub(cc);\r\n const dda = da.dot(da); // quick and dirty way of calc'n distance in r^2 terms saves some sqrts\r\n // save some sqrts\r\n if (dda > other.radius * other.radius) {\r\n return null; // no collision\r\n }\r\n // RETURN CONTACT\r\n let separation = da.normalize().scale(other.radius - Math.sqrt(dda));\r\n let normal = da.normalize();\r\n let info: ContactInfo = {\r\n collider: other,\r\n separation: other.radius - Math.sqrt(dda),\r\n axis: normal,\r\n point: this.begin\r\n }\r\n return new Contact(other, this, normal, normal.perpendicular(), info, [this.begin]);\r\n }\r\n \r\n // Potential region B collision (circle is on the right side of the edge, after the end)\r\n if (u <= 0) {\r\n const db = this.end.sub(cc);\r\n const ddb = db.dot(db);\r\n if (ddb > other.radius * other.radius) {\r\n return null;\r\n }\r\n // RETURN CONTACT\r\n let separation = db.normalize().scale(other.radius - Math.sqrt(ddb));\r\n let normal = db.normalize();\r\n let info: ContactInfo = {\r\n collider: other,\r\n separation: other.radius - Math.sqrt(ddb),\r\n axis: normal,\r\n point: this.end\r\n }\r\n return new Contact(other, this, normal, normal.perpendicular(), info, [this.end]);\r\n }\r\n\r\n // Otherwise potential region AB collision (circle is in the middle of the edge between the beginning and end)\r\n const den = e.dot(e);\r\n const pointOnEdge = this.begin\r\n .scale(u)\r\n .add(this.end.scale(v))\r\n .scale(1 / den);\r\n const d = cc.sub(pointOnEdge);\r\n\r\n const dd = d.dot(d);\r\n if (dd > other.radius * other.radius) {\r\n return null; // no collision\r\n }\r\n\r\n let n = e.perpendicular();\r\n // flip correct direction\r\n if (n.dot(cc.sub(this.begin)) < 0) {\r\n n.x = -n.x;\r\n n.y = -n.y;\r\n }\r\n\r\n n = n.normalize();\r\n\r\n const mvt = n.scale(Math.abs(other.radius - Math.sqrt(dd)));\r\n\r\n let info: ContactInfo = {\r\n collider: other,\r\n separation: other.radius - Math.sqrt(dd),\r\n axis: n,\r\n point: this.begin\r\n }\r\n // RETURN CONTACT\r\n return new Contact(this, other, n, n.perpendicular(), info, [pointOnEdge]);\r\n }\r\n\r\n return null;\r\n }\r\n\r\n draw(ctx: CanvasRenderingContext2D, flags: any) {\r\n ctx.save();\r\n ctx.beginPath();\r\n ctx.strokeStyle = 'green'\r\n ctx.moveTo(this.begin.x, this.begin.y);\r\n ctx.lineTo(this.end.x, this.end.y);\r\n ctx.closePath();\r\n ctx.stroke();\r\n ctx.restore();\r\n\r\n if (flags[\"Debug\"]) {\r\n ctx.fillStyle = 'yellow';\r\n ctx.fillText('id: ' + this.id, this.xf.pos.x, this.xf.pos.y);\r\n }\r\n }\r\n}","export const clamp = (val: number, min: number, max: number) => {\r\n return Math.max(Math.min(val, max), min);\r\n}\r\n\r\nexport const assert = (shouldBeTrue: boolean, message: string) => {\r\n if (!shouldBeTrue) {\r\n throw new Error(message)\r\n }\r\n}\r\n\r\nexport const shuffle = (list: any[]) => {\r\n // knuth shuffle\r\n let currentIndex = list.length;\r\n let randomIndex = 0;\r\n let tmp = null;\r\n while (currentIndex > 0) {\r\n // Pick a remaining element...\r\n randomIndex = Math.floor(Math.random() * currentIndex);\r\n currentIndex--;\r\n\r\n // And swap it with the current element.\r\n tmp = list[currentIndex];\r\n list[currentIndex] = list[randomIndex];\r\n list[randomIndex] = tmp;\r\n }\r\n return list;\r\n}","import { Box } from \"./box\";\r\nimport { Circle } from \"./circle\";\r\nimport { Collider } from \"./collider\";\r\nimport { Contact } from \"./contact\";\r\nimport { Vector } from \"./vector\";\r\n\r\nexport interface ContactInfo {\r\n\r\n /**\r\n * Collider A\r\n */\r\n collider: Collider,\r\n\r\n /**\r\n * Signed value (negative means overlap, positive no overlap)\r\n */\r\n separation: number,\r\n\r\n /**\r\n * Axis of separation from the collider's perpective\r\n */\r\n axis: Vector,\r\n\r\n /**\r\n * Side of separation (reference) from the collider's perpsective\r\n */\r\n\r\n side?: [Vector, Vector],\r\n\r\n /**\r\n * Local side of separation (reference) from the collider's perspective\r\n */\r\n localSide?: [Vector, Vector],\r\n \r\n /**\r\n * Index of the separation side (reference) from the collider's perspective\r\n */\r\n sideId?: number,\r\n\r\n /**\r\n * Point on collider B (incident point)\r\n */\r\n point: Vector;\r\n\r\n /**\r\n * Local point on collider B (incident point)\r\n */\r\n localPoint?: Vector;\r\n}\r\n\r\nexport class SeparatingAxis {\r\n\r\n static findBoxBoxSeparation(boxA: Box, boxB: Box): ContactInfo {\r\n let bestSeparation = -Number.MAX_VALUE;\r\n let bestSide: [Vector, Vector] | null = null;\r\n let bestAxis: Vector | null = null;\r\n let bestSideIndex: number = -1;\r\n let bestOtherPoint: Vector | null = null;\r\n for (let i = 0; i < 4; i++){\r\n const side = boxA.getSide(i);\r\n const axis = side[1].sub(side[0]).normal();\r\n const vertB = boxB.getFurthestPoint(axis.negate());\r\n // Separation on side i's axis\r\n const vertSeparation = SeparatingAxis.distanceToPoint(side[0], side[1], vertB, true); \r\n if (vertSeparation > bestSeparation) {\r\n bestSeparation = vertSeparation;\r\n bestSide = side;\r\n bestAxis = axis;\r\n bestSideIndex = i;\r\n bestOtherPoint = vertB\r\n }\r\n }\r\n\r\n return {\r\n collider: boxA,\r\n separation: bestSeparation,\r\n axis: bestAxis as Vector,\r\n side: bestSide as [Vector, Vector],\r\n localSide: boxA.getLocalSide(bestSideIndex),\r\n sideId: bestSideIndex,\r\n point: bestOtherPoint as Vector,\r\n localPoint: boxB.getFurthestLocalPoint(bestAxis!.negate())\r\n }\r\n }\r\n\r\n static findBoxBoxContact(boxA: Box, boxB: Box): Contact | null {\r\n const separationA = SeparatingAxis.findBoxBoxSeparation(boxA, boxB);\r\n // If there is no overlap from boxA's perspective we can end early\r\n if (separationA.separation > 0) {\r\n return null;\r\n } \r\n\r\n const separationB = SeparatingAxis.findBoxBoxSeparation(boxB, boxA);\r\n // If there is no overlap from boxB's perspective exit now\r\n if (separationB.separation > 0) {\r\n return null;\r\n }\r\n\r\n // Separations are both negative, we want to pick the least negative (minimal movement)\r\n const separation = separationA.separation > separationB.separation ? separationA : separationB;\r\n\r\n // The incident side is the most opposite from the axes of collision on the other shape\r\n const other = separation.collider === boxA ? boxB : boxA;\r\n const incident = other.findSide(separation.axis.negate());\r\n\r\n // Clip incident side by the perpendicular lines at each end of the reference side\r\n // https://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman_algorithm\r\n const reference = separation.side as [Vector, Vector];\r\n const refDir = reference[1].sub(reference[0]).normalize();\r\n \r\n // Find our contact points by clipping the incident by the collision side\r\n const clipRight = SeparatingAxis._clip(incident[0], incident[1], refDir.negate(), -refDir.dot(reference[0]));\r\n let clipLeft: [Vector, Vector] | null = null;\r\n if (clipRight) {\r\n clipLeft = SeparatingAxis._clip(clipRight[0], clipRight[1], refDir, refDir.dot(reference[1]));\r\n }\r\n\r\n if (clipLeft) {\r\n // We only want clip points below the reference edge, discard the others\r\n const points = clipLeft.filter(p => {\r\n return SeparatingAxis._below(reference[0], reference[1], p);\r\n });\r\n\r\n let normal = separation.axis;\r\n let tangent = normal.perpendicular();\r\n // Point Contact A -> B\r\n if (boxB.xf.pos.sub(boxA.xf.pos).dot(normal) < 0) {\r\n normal = normal.negate();\r\n tangent = normal.perpendicular();\r\n }\r\n // Points are clipped from incident which is the other collider\r\n // Store those as locals\r\n let localPoints: Vector[] = [];\r\n if (separation.collider === boxA) {\r\n localPoints = points.map(p => boxB.xf.inverse(p));\r\n } else {\r\n localPoints = points.map(p => boxA.xf.inverse(p));\r\n }\r\n return new Contact(boxA, boxB, normal, normal.perpendicular(), separation, points, localPoints);\r\n }\r\n return null;\r\n }\r\n\r\n static findBoxCircleSeparation(box: Box, circle: Circle): ContactInfo {\r\n const circleDir = circle.xf.pos.sub(box.xf.pos).normalize();\r\n const boxDir = box.xf.pos.sub(circle.xf.pos).normalize();\r\n const circlePoint = circle.xf.pos.add(boxDir.scale(circle.radius));\r\n \r\n let bestSeparation = -Number.MAX_VALUE;\r\n let bestSide: [Vector, Vector] | null = null;\r\n let bestAxis: Vector | null = null;\r\n let bestSideIndex: number = -1;\r\n let bestOtherPoint: Vector | null = null;\r\n\r\n // Test poly axes against circle point\r\n for (let i = 0; i < 4; i++){\r\n const side = box.getSide(i);\r\n const axis = side[1].sub(side[0]).normal();\r\n const circlePoint = circle.xf.pos.add(axis.negate().scale(circle.radius));\r\n // Separation on side i's axis\r\n const vertSeparation = SeparatingAxis.distanceToPoint(side[0], side[1], circlePoint, true); \r\n if (vertSeparation > bestSeparation) {\r\n bestSeparation = vertSeparation;\r\n bestSide = side;\r\n bestAxis = axis;\r\n bestSideIndex = i;\r\n bestOtherPoint = circlePoint\r\n }\r\n }\r\n // Test the circle -> box axis against each point of the box\r\n let minCircleSeparation = Number.MAX_VALUE;\r\n let minCircleSide = 0;\r\n for (let i = 0; i < 4; i++) {\r\n // project box points on the circle axis\r\n \r\n const projection = circleDir.dot(box.points[i]);\r\n\r\n const minCircle = circleDir.dot(circle.xf.pos) - circle.radius;\r\n\r\n const maxCircle = circleDir.dot(circle.xf.pos) + circle.radius;\r\n const separation = Math.min(minCircle - projection, maxCircle - projection);\r\n\r\n if (separation < minCircleSeparation) {\r\n minCircleSeparation = separation;\r\n minCircleSide = i;\r\n }\r\n }\r\n\r\n if (minCircleSeparation > bestSeparation) {\r\n let boxPt = box.getFurthestPoint(circleDir);\r\n bestSeparation = minCircleSeparation;\r\n bestSide = box.getSide(minCircleSide);\r\n bestAxis = circle.xf.pos.sub(boxPt).normalize();\r\n bestSideIndex = minCircleSide;\r\n bestOtherPoint = box.getFurthestPoint(circleDir);\r\n }\r\n\r\n return {\r\n collider: box,\r\n separation: bestSeparation,\r\n axis: bestAxis as Vector,\r\n side: bestSide as [Vector, Vector],\r\n sideId: bestSideIndex,\r\n point: bestOtherPoint as Vector\r\n }\r\n }\r\n\r\n static findCircleBoxContact(circle: Circle, box: Box): Contact | null {\r\n let separation = SeparatingAxis.findBoxCircleSeparation(box, circle);\r\n if (separation.separation > 0) {\r\n return null;\r\n }\r\n\r\n // make sure that the minAxis is pointing away from circle\r\n let boxDir = box.xf.pos.sub(circle.xf.pos);\r\n let axis = separation.axis;\r\n axis = axis.dot(boxDir) < 0 ? axis.negate() : axis;\r\n\r\n const point = circle.getFurthestPoint(axis);\r\n const normal = axis;\r\n\r\n return new Contact(\r\n circle,\r\n box,\r\n normal,\r\n normal.perpendicular(),\r\n separation,\r\n [point],\r\n [circle.xf.inverse(point)]\r\n );\r\n }\r\n\r\n static findCircleCircleContact(circleA: Circle, circleB: Circle): Contact | null {\r\n \r\n const combinedRadius = circleB.radius + circleA.radius;\r\n const distance = circleB.xf.pos.distance(circleA.xf.pos);\r\n if (distance < combinedRadius) {\r\n const separation = combinedRadius - distance;\r\n \r\n // normal points from A -> B\r\n const direction = circleB.xf.pos.sub(circleA.xf.pos);\r\n const normal = direction.normalize();\r\n const tangent = normal.perpendicular();\r\n const point = circleA.xf.pos.add(normal.scale(circleA.radius));\r\n const info: ContactInfo = {\r\n collider: circleA,\r\n separation: separation,\r\n axis: normal,\r\n point: point\r\n }\r\n return new Contact(circleA, circleB, normal, tangent, info, [point]);\r\n }\r\n return null;\r\n }\r\n\r\n /**\r\n * Find the perpendicular distance from the line to a point\r\n * https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line\r\n * @param point\r\n */\r\n static distanceToPoint(begin: Vector, end: Vector, point: Vector, signed: boolean = false) {\r\n const x0 = point.x;\r\n const y0 = point.y;\r\n \r\n const l = end.distance(begin);\r\n \r\n const dy = end.y - begin.y;\r\n const dx = end.x - begin.x;\r\n const distance = (dy * x0 - dx * y0 + end.x * begin.y - end.y * begin.x) / l;\r\n return signed ? distance : Math.abs(distance);\r\n }\r\n\r\n /**\r\n * Clips along a line returning a new line given a direction and a length\r\n * ```\r\n * Clip Dir +--------> Clip Size\r\n * Begin *---------|-------------* End\r\n * Clipped line *---------* \r\n * ```\r\n * \r\n **/\r\n private static _clip(begin: Vector, end: Vector, clipDir: Vector, size: number): [Vector, Vector] | null {\r\n let dir = clipDir;\r\n dir = dir.normalize();\r\n\r\n\r\n const near = dir.dot(begin) - size;\r\n const far = dir.dot(end) - size;\r\n\r\n let results = [];\r\n if (near <= 0) {\r\n results.push(begin);\r\n }\r\n if (far <= 0) {\r\n results.push(end);\r\n }\r\n\r\n if (near * far < 0) {\r\n const clipTime = near / (near - far);\r\n results.push(begin.add(end.sub(begin).scale(clipTime)));\r\n }\r\n if (results.length !== 2) {\r\n return null;\r\n }\r\n\r\n return [results[0], results[1]];\r\n }\r\n\r\n private static _below(begin: Vector, end: Vector, point: Vector): boolean {\r\n let above2 = ((end.x - begin.x) * (point.y - begin.y) - \r\n (end.y - begin.y) * (point.x - begin.x))\r\n return above2 >= 0;\r\n }\r\n}","import { Box } from \"./box\";\r\nimport { Circle } from \"./circle\";\r\nimport { Contact } from \"./contact\";\r\nimport { Line } from \"./line\";\r\nimport { clamp } from \"./math\";\r\nimport { SeparatingAxis } from \"./separating-axis\";\r\nimport { Vector } from \"./vector\";\r\n\r\n/**\r\n * Holds information about contact points, meant to be reused over multiple frames of contact\r\n */\r\n export class ContactConstraintPoint {\r\n\r\n constructor(public point: Vector, public local: Vector, public contact: Contact) {}\r\n\r\n public getRelativeVelocity() {\r\n const bodyA = this.contact.bodyA;\r\n const bodyB = this.contact.bodyB;\r\n // Relative velocity in linear terms\r\n // Angular to linear velocity formula -> omega = velocity/radius so omega x radius = velocity\r\n const velA = bodyA.m.vel.add(Vector.cross(bodyA.m.angularVelocity, this.aToContact));\r\n const velB = bodyB.m.vel.add(Vector.cross(bodyB.m.angularVelocity, this.bToContact));\r\n\r\n return velB.sub(velA);\r\n }\r\n\r\n /**\r\n * Impulse accumulated over time in normal direction\r\n */\r\n public normalImpulse: number = 0;\r\n\r\n /**\r\n * Impulse accumulated over time in the tangent direction\r\n */\r\n public tangentImpulse: number = 0;\r\n\r\n /**\r\n * Effective mass seen in the normal direction\r\n */\r\n public normalMass: number = 0;\r\n \r\n /**\r\n * Effective mass seen in the tangent direction\r\n */\r\n public tangentMass: number = 0;\r\n\r\n /** \r\n * Direction from center of mass of bodyA to contact point\r\n */\r\n public aToContact: Vector = new Vector(0, 0);\r\n\r\n /** \r\n * Direction from center of mass of bodyB to contact point\r\n */\r\n public bToContact: Vector = new Vector(0, 0);\r\n}\r\n\r\nexport class Solver {\r\n constructor(public flags: any) {}\r\n lastFrameContacts: Map<string, Contact> = new Map();\r\n\r\n // map contact id to contact points\r\n idToContactConstraint: Map<string, ContactConstraintPoint[]> = new Map();\r\n\r\n getContactConstraints(id: string) {\r\n return this.idToContactConstraint.get(id) ?? [];\r\n }\r\n\r\n preSolve(contacts: Contact[]) {\r\n // Keep track of contacts that done\r\n let finishedContactIds = Array.from(this.idToContactConstraint.keys());\r\n for (let contact of contacts) {\r\n // Remove all current contacts that are not done\r\n let index = finishedContactIds.indexOf(contact.id);\r\n if (index > -1) {\r\n finishedContactIds.splice(index, 1);\r\n }\r\n let constraints = this.idToContactConstraint.get(contact.id) ?? [];\r\n \r\n let pointIndex = 0;\r\n constraints.length = contact.points.length;\r\n\r\n for (let point of contact.points) {\r\n const bodyA = contact.bodyA;\r\n const bodyB = contact.bodyB;\r\n const normal = contact.normal;\r\n const tangent = contact.tangent;\r\n\r\n const aToContact = point.sub(bodyA.xf.pos);\r\n const bToContact = point.sub(bodyB.xf.pos);\r\n \r\n const aToContactNormal = aToContact.cross(normal);\r\n const bToContactNormal = bToContact.cross(normal);\r\n\r\n const normalMass = bodyA.inverseMass + bodyB.inverseMass + \r\n bodyA.inverseInertia * aToContactNormal * aToContactNormal +\r\n bodyB.inverseInertia * bToContactNormal * bToContactNormal;\r\n\r\n const aToContactTangent = aToContact.cross(tangent);\r\n const bToContactTangent = bToContact.cross(tangent);\r\n \r\n const tangentMass = bodyA.inverseMass + bodyB.inverseMass +\r\n bodyA.inverseInertia * aToContactTangent * aToContactTangent +\r\n bodyB.inverseInertia * bToContactTangent * bToContactTangent;\r\n\r\n // Preserve normal/tangent impulse by re-using the contact point if it's close\r\n if (constraints[pointIndex] && constraints[pointIndex]?.point?.squareDistance(point) < 4) {\r\n constraints[pointIndex].point = point;\r\n constraints[pointIndex].local = contact.locals[pointIndex]\r\n } else {\r\n // new contact if its' not close or doesn't exist\r\n constraints[pointIndex] = new ContactConstraintPoint(point, contact.locals[pointIndex], contact);\r\n }\r\n\r\n // Update contact point calculations\r\n constraints[pointIndex].aToContact = aToContact;\r\n constraints[pointIndex].bToContact = bToContact;\r\n constraints[pointIndex].normalMass = normalMass;\r\n constraints[pointIndex].tangentMass = tangentMass;\r\n\r\n pointIndex++\r\n }\r\n this.idToContactConstraint.set(contact.id, constraints);\r\n }\r\n\r\n // Clean up any contacts that did not occur last frame\r\n for (const id of finishedContactIds) {\r\n this.idToContactConstraint.delete(id);\r\n }\r\n }\r\n\r\n postSolve(contacts: Contact[]) {\r\n // Store contacts\r\n this.lastFrameContacts.clear();\r\n for (const c of contacts) {\r\n this.lastFrameContacts.set(c.id, c);\r\n }\r\n }\r\n\r\n /**\r\n * Warm up body's based on previous frame contact points\r\n * @param contacts \r\n */\r\n warmStart(contacts: Contact[]) {\r\n for (let contact of contacts) {\r\n let constraints = this.idToContactConstraint.get(contact.id) ?? [];\r\n for (let constraint of constraints) {\r\n const normalImpulse = contact.normal.scale(constraint.normalImpulse);\r\n const tangentImpulse = contact.tangent.scale(constraint.tangentImpulse);\r\n\r\n const impulse = normalImpulse.add(tangentImpulse);\r\n contact.bodyA.applyImpulse(constraint.point, impulse.negate());\r\n contact.bodyB.applyImpulse(constraint.point, impulse);\r\n }\r\n }\r\n }\r\n\r\n private _getSeparation(contact: Contact, point: Vector) {\r\n let bodyA = contact.bodyA;\r\n let bodyB = contact.bodyB;\r\n if (bodyA instanceof Circle && bodyB instanceof Circle) {\r\n const combinedRadius = bodyA.radius + bodyB.radius;\r\n const distance = bodyA.xf.pos.distance(bodyB.xf.pos);\r\n const separation = combinedRadius - distance;\r\n return -separation;\r\n }\r\n\r\n if (bodyA instanceof Circle && bodyB instanceof Line) {\r\n return bodyB.getSeparation(bodyA);\r\n }\r\n\r\n if (bodyA instanceof Line && bodyB instanceof Circle) {\r\n return bodyA.getSeparation(bodyB);\r\n }\r\n\r\n if (bodyA instanceof Box && bodyB instanceof Box) {\r\n if (contact.info.localSide) {\r\n let side: [Vector, Vector];\r\n let worldPoint: Vector;\r\n if (contact.info.collider === bodyA) {\r\n side = [bodyA.xf.apply(contact.info.localSide[0]), bodyA.xf.apply(contact.info.localSide[1])];\r\n worldPoint = bodyB.xf.apply(point);\r\n } else {\r\n side = [bodyB.xf.apply(contact.info.localSide[0]), bodyB.xf.apply(contact.info.localSide[1])];\r\n worldPoint = bodyA.xf.apply(point);\r\n }\r\n\r\n return SeparatingAxis.distanceToPoint(side[0], side[1], worldPoint, true);\r\n }\r\n }\r\n\r\n if (bodyA instanceof Box && bodyB instanceof Circle ||\r\n bodyB instanceof Box && bodyA instanceof Circle) {\r\n if (contact.info.side) {\r\n return SeparatingAxis.distanceToPoint(contact.info.side[0], contact.info.side[1], bodyA.xf.apply(point), true);\r\n }\r\n }\r\n\r\n return 0\r\n }\r\n \r\n\r\n /**\r\n * Iteratively solve the position overlap constraint\r\n * @param contacts \r\n */\r\n solvePosition(contacts: Contact[]) {\r\n for (let contact of contacts) {\r\n let constraints = this.idToContactConstraint.get(contact.id) ?? [];\r\n for (let point of constraints) {\r\n const bodyA = contact.bodyA;\r\n const bodyB = contact.bodyB;\r\n const normal = contact.normal;\r\n const separation = this._getSeparation(contact, point.local);\r\n\r\n const steeringConstant = this.flags['Steering Factor']; // 0.2\r\n const maxCorrection = -5;\r\n const slop = this.flags['Slop']; // .5;\r\n\r\n // Clamp to avoid over-correction\r\n // Remember that we are shooting for 0 overlap in the end\r\n const steeringForce = clamp(steeringConstant * (separation + slop), maxCorrection, 0);\r\n const impulse = normal.scale(-steeringForce / point.normalMass);\r\n\r\n \r\n // This is a pseudo impulse, meaning we aren't doing a real impulse calculation\r\n // We adjust position and rotation instead of doing the velocity\r\n if (!bodyA.static) {\r\n bodyA.xf.pos = bodyA.xf.pos.add(impulse.negate().scale(bodyA.inverseMass));\r\n bodyA.xf.rotation -= point.aToContact.cross(impulse) * bodyA.inverseInertia;\r\n }\r\n\r\n if (!bodyB.static) {\r\n bodyB.xf.pos = bodyB.xf.pos.add(impulse.scale(bodyB.inverseMass));\r\n bodyB.xf.rotation += point.bToContact.cross(impulse) * bodyB.inverseInertia;\r\n }\r\n\r\n }\r\n }\r\n }\r\n\r\n solveVelocity(contacts: Contact[]) {\r\n for (let contact of contacts) {\r\n const bodyA = contact.bodyA;\r\n const bodyB = contact.bodyB;\r\n\r\n const restitution = bodyA.bounciness * bodyB.bounciness;\r\n const friction = Math.min(bodyA.friction, bodyB.friction);\r\n let constraints = this.idToContactConstraint.get(contact.id) ?? [];\r\n\r\n for (let point of constraints) {\r\n const relativeVelocity = point.getRelativeVelocity();\r\n\r\n // Negate velocity in tangent direction to simulate friction\r\n const tangentVelocity = -relativeVelocity.dot(contact.tangent);\r\n let impulseDelta = tangentVelocity / point.tangentMass;\r\n\r\n // Clamping based in Erin Catto's GDC 2006 talk\r\n // Correct clamping https://github.com/erincatto/box2d-lite/blob/master/docs/GDC2006_Catto_Erin_PhysicsTutorial.pdf\r\n // Accumulated fiction impulse is always between -uMaxFriction < dT < uMaxFriction\r\n // But deltas can vary\r\n const maxFriction = friction * point.normalImpulse;\r\n const newImpulse = clamp(point.tangentImpulse + impulseDelta, -maxFriction, maxFriction);\r\n impulseDelta = newImpulse - point.tangentImpulse;\r\n point.tangentImpulse = newImpulse;\r\n\r\n const impulse = contact.tangent.scale(impulseDelta);\r\n bodyA.applyImpulse(point.point, impulse.negate());\r\n bodyB.applyImpulse(point.point, impulse);\r\n }\r\n\r\n for (let point of constraints) {\r\n // Need to recalc relative velocity because the previous step could have changed vel\r\n const relativeVelocity = point.getRelativeVelocity();\r\n\r\n // Compute impulse in normal direction\r\n const normalVelocity = relativeVelocity.dot(contact.normal);\r\n // See https://en.wikipedia.org/wiki/Collision_response\r\n let impulseDelta = (-(1 + restitution) * normalVelocity) / point.normalMass;\r\n\r\n // Clamping based in Erin Catto's GDC 2014 talk\r\n // Accumulated impulse stored in the contact is always positive (dV > 0)\r\n // But deltas can be negative\r\n const newImpulse = Math.max(point.normalImpulse + impulseDelta, 0);\r\n impulseDelta = newImpulse - point.normalImpulse;\r\n point.normalImpulse = newImpulse;\r\n\r\n const impulse = contact.normal.scale(impulseDelta);\r\n bodyA.applyImpulse(point.point, impulse.negate());\r\n bodyB.applyImpulse(point.point, impulse);\r\n }\r\n }\r\n }\r\n}","import { Vector } from \"./vector\";\r\n\r\nexport class Transform {\r\n public pos: Vector = new Vector(0, 0);\r\n public rotation: number = 0;\r\n apply(vec: Vector) {\r\n return vec.rotate(this.rotation).add(this.pos);\r\n }\r\n inverse(vec: Vector) {\r\n return vec.sub(this.pos).rotate(-this.rotation);\r\n }\r\n}\r\n\r\nexport class Motion {\r\n public vel: Vector = new Vector(0, 0);\r\n public acc: Vector = new Vector(0, 0);\r\n\r\n public angularVelocity: number = 0;\r\n}","export class Vector {\r\n constructor(public x: number, public y: number) {}\r\n distance(other?: Vector) {\r\n if (!other) {\r\n other = new Vector(0, 0);\r\n }\r\n const dx = this.x - other.x;\r\n const dy = this.y - other.y;\r\n return Math.sqrt(dx * dx + dy * dy);\r\n }\r\n\r\n squareDistance(other: Vector) {\r\n const dx = this.x - other.x;\r\n const dy = this.y - other.y;\r\n return dx * dx + dy * dy;\r\n }\r\n\r\n normalize(): Vector {\r\n const d = this.distance(new Vector(0, 0));\r\n return new Vector(this.x / d, this.y / d);\r\n }\r\n\r\n size(): number {\r\n return this.distance(new Vector(0, 0));\r\n }\r\n\r\n scale(val: number): Vector {\r\n return new Vector(this.x * val, this.y * val);\r\n }\r\n\r\n negate(): Vector {\r\n return this.scale(-1);\r\n }\r\n\r\n /**\r\n * Returns the perpendicular vector to this one\r\n */\r\n perpendicular(): Vector {\r\n return new Vector(this.y, -this.x);\r\n }\r\n\r\n /**\r\n * Returns the normal vector to this one, same as the perpendicular of length 1\r\n */\r\n normal(): Vector {\r\n return this.perpendicular().normalize();\r\n }\r\n\r\n dot(other: Vector): number {\r\n return this.x * other.x + this.y * other.y;\r\n }\r\n\r\n /**\r\n * Performs a 2D cross product with scalar. 2D cross products with a scalar return a vector.\r\n * @param v The scalar to cross\r\n */\r\n cross(v: number): Vector;\r\n /**\r\n * Performs a 2D cross product with another vector. 2D cross products return a scalar value not a vector.\r\n * @param v The vector to cross\r\n */\r\n cross(v: Vector): number;\r\n cross(v: number | Vector): number | Vector {\r\n if (v instanceof Vector) {\r\n return this.x * v.y - this.y * v.x;\r\n } else {\r\n return new Vector(v * this.y, -v * this.x);\r\n }\r\n }\r\n\r\n add(other: Vector): Vector {\r\n return new Vector(this.x + other.x, this.y + other.y);\r\n }\r\n\r\n /**\r\n * Creates a vector in the direcion of `other` -> `this`\r\n * @param other \r\n * @returns \r\n */\r\n sub(other: Vector): Vector {\r\n return new Vector(this.x - other.x, this.y - other.y);\r\n }\r\n\r\n\r\n /**\r\n * Rotates the current vector around a point by a certain number of\r\n * degrees in radians\r\n */\r\n rotate(angle: number, anchor?: Vector): Vector {\r\n if (!anchor) {\r\n anchor = new Vector(0, 0);\r\n }\r\n const sinAngle = Math.sin(angle);\r\n const cosAngle = Math.cos(angle);\r\n const x = cosAngle * (this.x - anchor.x) - sinAngle * (this.y - anchor.y) + anchor.x;\r\n const y = sinAngle * (this.x - anchor.x) + cosAngle * (this.y - anchor.y) + anchor.y;\r\n return new Vector(x, y);\r\n }\r\n\r\n static cross(num: number, vec: Vector) {\r\n return new Vector(-num * vec.y, num * vec.x)\r\n }\r\n}\r\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tif(__webpack_module_cache__[moduleId]) {\n\t\treturn __webpack_module_cache__[moduleId].exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","import { Box } from \"./box\";\r\nimport { Circle } from \"./circle\";\r\nimport { Collider } from \"./collider\";\r\nimport { Contact } from \"./contact\";\r\nimport { Line } from \"./line\";\r\nimport { clamp } from \"./math\";\r\nimport { Solver } from \"./solver\";\r\nimport { Vector } from \"./vector\";\r\n\r\nconst canvas = document.createElement('canvas');\r\ncanvas.width = 800;\r\ncanvas.height = 600;\r\nconst ctx = canvas.getContext('2d') as CanvasRenderingContext2D;\r\ndocument.body.appendChild(canvas);\r\n\r\n\r\nconst gui = new dat.GUI({ name: 'Iterative Solver' });\r\nconst flags: Record<string, number | boolean> = {\r\n \"Debug\": true,\r\n \"Points\": true,\r\n \"Normals\": true,\r\n \"RelativeVel\": true,\r\n \"Warming\": true,\r\n \"Steering Factor\": .2,\r\n \"Slop\": .5,\r\n \"Position Iterations\": 3,\r\n \"Velocity Iterations\": 8,\r\n \"Gravity Value\": 400,\r\n \"Gravity\": false\r\n}\r\nfor (let key in flags) {\r\n if (typeof flags[key] === 'number') {\r\n switch(key) {\r\n case \"Steering Factor\": {\r\n gui.add(flags, key, .05, 1, .05);\r\n break;\r\n }\r\n case \"Slop\": {\r\n gui.add(flags, key, .5, 5, .5);\r\n break;\r\n }\r\n case \"Gravity Value\": {\r\n gui.add(flags, key, 0, 1000, 1);\r\n break;\r\n }\r\n default: {\r\n gui.add(flags, key, 0, 20, 1);\r\n }\r\n }\r\n }\r\n if (typeof flags[key] === 'boolean') {\r\n gui.add(flags, key);\r\n }\r\n}\r\n\r\nconst entities: Collider[] = [\r\n // new Line(new Vector(50, 550), new Vector(750, 550)),\r\n new Box(500, 20, new Vector(canvas.width / 2, 550)),\r\n new Line(new Vector(100, 100), new Vector(300, 650)),\r\n new Line(new Vector(500, 650), new Vector(700, 100)),\r\n // new Circle(40, new Vector(canvas.width / 2, 400)),\r\n // new Box(40, 40, new Vector(canvas.width / 2, 400)),\r\n // new Circle(40, new Vector(canvas.width / 2, 300)),\r\n // new Circle(40, new Vector(canvas.width / 2, 200)),\r\n // new Circle(40, new Vector(canvas.width / 2, 100)),\r\n // new Circle(40, new Vector(canvas.width / 2, 0)),\r\n // new Circle(40, new Vector(canvas.width / 2, -100)),\r\n // new Circle(40, new Vector(canvas.width / 2, -200)),\r\n];\r\n(window as any).entities = entities;\r\nentities[0].static = true;\r\n// entities[entities.length - 1].xf.rotation = Math.PI / 5;\r\n\r\nlet solver = new Solver(flags);\r\nlet contacts: Contact[] = [];\r\nconst update = (elapsed: number) => {\r\n let acc = new Vector(0, 0);\r\n if (flags['Gravity']) {\r\n acc = new Vector(0, flags['Gravity Value'] as number);\r\n }\r\n\r\n // Integrate motion\r\n for (let circle of entities) {\r\n if (!circle.static) {\r\n circle.m.vel = circle.m.vel.add(acc.scale(elapsed));\r\n circle.m.angularVelocity = clamp(circle.m.angularVelocity, -1, 1);\r\n }\r\n }\r\n\r\n // Naive descrete collision detection (broadphase + narrowphase)\r\n // We re-use contacts from the previous frame if they exist\r\n contacts = []\r\n for (let i = 0; i < entities.length; i++) {\r\n for (let j = i + 1; j < entities.length; j++) {\r\n let colliderA = entities[i];\r\n let colliderB = entities[j];\r\n let contact = colliderA.collide(colliderB);\r\n if (contact) {\r\n contacts.push(contact);\r\n }\r\n \r\n }\r\n }\r\n\r\n // Initialize contact information\r\n solver.preSolve(contacts);\r\n \r\n // Warm start impulses for velocity constraint\r\n // This helps with simulation coherence by reusing work from previous frames\r\n // Practically this will cancel gravity on big stacks\r\n if (flags[\"Warming\"]) {\r\n solver.warmStart(contacts);\r\n } else {\r\n for (let contact of contacts) {\r\n let constraints = solver.getContactConstraints(contact.id);\r\n for (let constraint of constraints) {\r\n constraint.normalImpulse = 0;\r\n constraint.tangentImpulse = 0;\r\n }\r\n }\r\n }\r\n\r\n // The velocity constraint is that no contacts are moving relative to each other along the normal\r\n // in other words relative velocity between contacts should approach 0 on the normal\r\n for (let i = 0; i < flags['Velocity Iterations']; i++) {\r\n solver.solveVelocity(contacts);\r\n }\r\n\r\n // Integrate positions\r\n for (let circle of entities) {\r\n if (!circle.static) {\r\n let offset = circle.m.vel.scale(elapsed).add(acc.scale(0.5 * elapsed * elapsed));\r\n circle.xf.pos = circle.xf.pos.add(offset);\r\n circle.xf.rotation += clamp(circle.m.angularVelocity, -1, 1) * elapsed;\r\n while (circle.xf.rotation > Math.PI * 2) {\r\n circle.xf.rotation -= Math.PI * 2;\r\n }\r\n while (circle.xf.rotation < 0) {\r\n circle.xf.rotation += Math.PI * 2;\r\n }\r\n }\r\n }\r\n\r\n // The constraint is separation should approach 0\r\n for (let i = 0; i < flags['Position Iterations']; i++) {\r\n solver.solvePosition(contacts);\r\n }\r\n\r\n solver.postSolve(contacts);\r\n}\r\n\r\n\r\nconst draw = (elapsed: number) => {\r\n ctx.save();\r\n ctx.fillStyle = 'black';\r\n ctx.fillRect(0, 0, canvas.width, canvas.height);\r\n\r\n for (let e of entities) {\r\n e.draw(ctx, flags);\r\n }\r\n\r\n if (flags[\"Debug\"]) {\r\n for (let contact of contacts) {\r\n let contactPoints = solver.getContactConstraints(contact.id);\r\n for (let p of contactPoints) {\r\n if (flags[\"Points\"]) {\r\n ctx.beginPath();\r\n ctx.strokeStyle = 'yellow'\r\n ctx.arc(p.point.x, p.point.y, 5, 0, Math.PI * 2);\r\n ctx.closePath();\r\n ctx.stroke();\r\n }\r\n\r\n if (flags[\"Normals\"]) {\r\n ctx.beginPath();\r\n ctx.strokeStyle = 'red'\r\n ctx.moveTo(p.point.x, p.point.y);\r\n ctx.lineTo(p.point.x + contact.normal.x * 10, p.point.y + contact.normal.y * 10);\r\n ctx.closePath();\r\n ctx.stroke();\r\n }\r\n\r\n if (flags[\"RelativeVel\"]) {\r\n ctx.beginPath();\r\n ctx.strokeStyle = 'blue'\r\n ctx.moveTo(p.point.x, p.point.y);\r\n ctx.lineTo(p.point.x + p.getRelativeVelocity().x, p.point.y + p.getRelativeVelocity().y);\r\n ctx.closePath();\r\n ctx.stroke();\r\n }\r\n\r\n if (flags[\"Impulse\"]) {\r\n ctx.fillStyle = 'yellow';\r\n ctx.fillText('N- ' + p.normalImpulse.toFixed(1), p.point.x + 10, p.point.y);\r\n ctx.fillText('T- ' + p.tangentImpulse.toFixed(1), p.point.x + 10, p.point.y + 10);\r\n }\r\n }\r\n }\r\n\r\n for (let circle of entities) {\r\n \r\n ctx.beginPath();\r\n ctx.strokeStyle = 'green';\r\n ctx.moveTo(circle.xf.pos.x, circle.xf.pos.y);\r\n ctx.lineTo(circle.xf.pos.x + circle.m.vel.x, circle.xf.pos.y + circle.m.vel.y);\r\n ctx.closePath();\r\n ctx.stroke();\r\n }\r\n }\r\n ctx.restore();\r\n}\r\n\r\nlet singleStep = false;\r\nlet lastMs = 0;\r\nconst mainloop = (currentMs: number) => {\r\n if (singleStep) {\r\n return;\r\n }\r\n\r\n let seconds = (currentMs - lastMs) / 1000;\r\n if (seconds > .1) {\r\n seconds = .016;\r\n }\r\n\r\n update(seconds);\r\n draw(seconds);\r\n\r\n lastMs = currentMs;\r\n requestAnimationFrame(mainloop);\r\n}\r\n\r\nmainloop(.016);\r\n\r\ndocument.addEventListener('keydown', (ev) => {\r\n if (ev.code === 'KeyS') {\r\n singleStep = true;\r\n update(.016);\r\n draw(.016);\r\n }\r\n if (ev.code === 'KeyT') {\r\n singleStep = false;\r\n lastMs = 0;\r\n mainloop(.016);\r\n }\r\n\r\n if (ev.code === 'KeyI') {\r\n entities[3].applyImpulse(entities[3].xf.pos, new Vector(0, -5500));\r\n entities[4].applyImpulse(entities[4].xf.pos, new Vector(0, 5500));\r\n }\r\n\r\n if (ev.code === 'KeyC') {\r\n entities.push(new Circle(40, new Vector(canvas.width / 2, 0)));\r\n }\r\n\r\n if (ev.code === 'KeyB') {\r\n let box = new Box(100, 40, new Vector(canvas.width / 2, 300));\r\n box.bounciness = .1;\r\n entities.push(box);\r\n }\r\n})\r\n"],"sourceRoot":""}