motionary 10.5.0 → 10.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +2 -0
- package/CHANGELOG.md +28 -0
- package/README.md +95 -1
- package/bin/motionary-mcp.mjs +160 -11
- package/dist/chunks/{anim-image-DuxvYhq6.cjs → anim-image-CFGpUX7t.cjs} +2 -2
- package/dist/chunks/{anim-image-DuxvYhq6.cjs.map → anim-image-CFGpUX7t.cjs.map} +1 -1
- package/dist/chunks/{anim-image-BlNPv4JG.js → anim-image-CXDD19FH.js} +2 -2
- package/dist/chunks/{anim-image-BlNPv4JG.js.map → anim-image-CXDD19FH.js.map} +1 -1
- package/dist/chunks/{keyframes-Ce1s05n3.cjs → keyframes-DdwGY1gr.cjs} +2 -2
- package/dist/chunks/{keyframes-Ce1s05n3.cjs.map → keyframes-DdwGY1gr.cjs.map} +1 -1
- package/dist/chunks/{keyframes-B8ITIAVa.js → keyframes-DwR6GPej.js} +2 -2
- package/dist/chunks/{keyframes-B8ITIAVa.js.map → keyframes-DwR6GPej.js.map} +1 -1
- package/dist/chunks/{registry-DXdFb2fJ.js → registry-D87dP_aR.js} +3 -3
- package/dist/chunks/{registry-DXdFb2fJ.js.map → registry-D87dP_aR.js.map} +1 -1
- package/dist/chunks/{registry-VhfPSI0v.cjs → registry-DhKZCitb.cjs} +2 -2
- package/dist/chunks/{registry-VhfPSI0v.cjs.map → registry-DhKZCitb.cjs.map} +1 -1
- package/dist/chunks/{ticker-C5RMHMW7.js → ticker-CJYI5Pxc.js} +2 -2
- package/dist/chunks/{ticker-C5RMHMW7.js.map → ticker-CJYI5Pxc.js.map} +1 -1
- package/dist/chunks/{ticker-DvmC6WLS.cjs → ticker-jD9_A9Rh.cjs} +2 -2
- package/dist/chunks/{ticker-DvmC6WLS.cjs.map → ticker-jD9_A9Rh.cjs.map} +1 -1
- package/dist/chunks/{tween-_BGIl6hK.cjs → tween-Dk0QmNe9.cjs} +2 -2
- package/dist/chunks/{tween-_BGIl6hK.cjs.map → tween-Dk0QmNe9.cjs.map} +1 -1
- package/dist/chunks/{tween-CPtm-EdT.js → tween-_Lld1MsF.js} +2 -2
- package/dist/chunks/{tween-CPtm-EdT.js.map → tween-_Lld1MsF.js.map} +1 -1
- package/dist/components/ai.cjs +314 -0
- package/dist/components/ai.cjs.map +1 -0
- package/dist/components/ai.d.cts +58 -0
- package/dist/components/ai.d.ts +58 -0
- package/dist/components/ai.js +311 -0
- package/dist/components/ai.js.map +1 -0
- package/dist/components/lite.cjs +179 -0
- package/dist/components/lite.cjs.map +1 -1
- package/dist/components/lite.js +176 -1
- package/dist/components/lite.js.map +1 -1
- package/dist/components/tokens.cjs +179 -0
- package/dist/components/tokens.cjs.map +1 -1
- package/dist/components/tokens.d.cts +36 -1
- package/dist/components/tokens.d.ts +36 -1
- package/dist/components/tokens.js +176 -1
- package/dist/components/tokens.js.map +1 -1
- package/dist/components/widgets.cjs +985 -221
- package/dist/components/widgets.cjs.map +1 -1
- package/dist/components/widgets.d.cts +606 -4
- package/dist/components/widgets.d.ts +606 -4
- package/dist/components/widgets.js +976 -222
- package/dist/components/widgets.js.map +1 -1
- package/dist/components.cjs +4 -0
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +36 -1
- package/dist/components.d.ts +36 -1
- package/dist/components.js +1 -1
- package/dist/components.umd.js +2 -2
- package/dist/components.umd.js.map +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/llms-full.txt +221 -1
- package/dist/llms.txt +11 -2
- package/dist/manifest.json +580 -1
- package/dist/runtime/format-apng.cjs +4 -4
- package/dist/runtime/format-apng.js +4 -4
- package/dist/runtime/format-css.cjs +4 -4
- package/dist/runtime/format-css.js +4 -4
- package/dist/runtime/format-gif.cjs +4 -4
- package/dist/runtime/format-gif.js +4 -4
- package/dist/runtime/format-gltf.cjs +1 -1
- package/dist/runtime/format-gltf.js +1 -1
- package/dist/runtime/format-motion.cjs +4 -4
- package/dist/runtime/format-motion.js +4 -4
- package/dist/runtime/format-obj.cjs +1 -1
- package/dist/runtime/format-obj.js +1 -1
- package/dist/runtime/format-scene.cjs +241 -0
- package/dist/runtime/format-scene.cjs.map +1 -0
- package/dist/runtime/format-scene.d.cts +349 -0
- package/dist/runtime/format-scene.d.ts +349 -0
- package/dist/runtime/format-scene.iife.js +2 -0
- package/dist/runtime/format-scene.iife.js.map +1 -0
- package/dist/runtime/format-scene.js +233 -0
- package/dist/runtime/format-scene.js.map +1 -0
- package/dist/runtime/format-sprite.cjs +3 -3
- package/dist/runtime/format-sprite.js +3 -3
- package/dist/runtime/format-svg.cjs +3 -3
- package/dist/runtime/format-svg.js +3 -3
- package/dist/runtime/format-webp.cjs +4 -4
- package/dist/runtime/format-webp.js +4 -4
- package/dist/runtime/gl.cjs +1 -1
- package/dist/runtime/gl.js +1 -1
- package/dist/runtime/physics.cjs +739 -0
- package/dist/runtime/physics.cjs.map +1 -0
- package/dist/runtime/physics.d.cts +250 -0
- package/dist/runtime/physics.d.ts +250 -0
- package/dist/runtime/physics.iife.js +2 -0
- package/dist/runtime/physics.iife.js.map +1 -0
- package/dist/runtime/physics.js +731 -0
- package/dist/runtime/physics.js.map +1 -0
- package/dist/runtime/scroll.cjs +2 -2
- package/dist/runtime/scroll.js +2 -2
- package/dist/runtime/smooth.cjs +1 -1
- package/dist/runtime/smooth.js +1 -1
- package/dist/runtime/text.cjs +1 -1
- package/dist/runtime/text.js +1 -1
- package/dist/runtime/vector.cjs +704 -0
- package/dist/runtime/vector.cjs.map +1 -0
- package/dist/runtime/vector.d.cts +306 -0
- package/dist/runtime/vector.d.ts +306 -0
- package/dist/runtime/vector.iife.js +2 -0
- package/dist/runtime/vector.iife.js.map +1 -0
- package/dist/runtime/vector.js +692 -0
- package/dist/runtime/vector.js.map +1 -0
- package/dist/runtime.cjs +3 -3
- package/dist/runtime.d.cts +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.iife.js +1 -1
- package/dist/runtime.iife.js.map +1 -1
- package/dist/runtime.js +5 -5
- package/dist/widgets.umd.js +1 -1
- package/dist/widgets.umd.js.map +1 -1
- package/docs/ROADMAP.md +2 -2
- package/docs/components/README.md +6 -1
- package/docs/components/usa-lottie-player.md +60 -0
- package/docs/components/usa-motion-prompt.md +32 -0
- package/docs/components/usa-physics-playground.md +63 -0
- package/docs/components/usa-rive.md +57 -0
- package/docs/components/usa-token-editor.md +32 -0
- package/docs/components.md +116 -0
- package/docs/runtime/format-scene.md +59 -0
- package/docs/runtime/physics.md +61 -0
- package/docs/runtime/rive.md +55 -0
- package/docs/runtime/vector.md +67 -0
- package/package.json +46 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"physics.cjs","sources":["../../src/runtime/physics.ts"],"sourcesContent":["/**\n * `motionary/runtime/physics` (10.7) — a small 2D rigid-body engine written\n * for Motionary (own implementation and API; no Matter.js / Box2D code):\n *\n * - bodies: circles, boxes and convex polygons (static, dynamic or\n * kinematic), density → mass + moment of inertia, restitution, friction,\n * sensors, collision groups / masks, sleeping;\n * - collisions: sort-and-sweep broad phase, separating-axis narrow phase\n * with clipped contact manifolds (up to 2 points), sequential, accumulated and\n * clamped impulses (normal + Coulomb friction) with a Baumgarte position bias;\n * - constraints: `distance` (rigid or a spring with `stiffness` /\n * `damping`), `pin` (a body point to a world point — also the pointer\n * drag constraint) and `weld`-like stiff distance pairs;\n * - a fixed time step (default 1/60 s) with an accumulator, so results are\n * the same at any frame rate; `world.run()` drives it from the shared\n * runtime ticker (pauses while the ticker sleeps).\n *\n * Pure maths — no DOM: safe in SSR and workers. Units are up to you (the\n * defaults assume pixels: gravity 980 px/s²).\n */\nimport { RUNTIME_VERSION, requireModule, type RuntimeModule } from './registry';\nimport type { CoreApi } from './index';\n\ntype Num = number;\nexport interface Vec2 { x: Num; y: Num }\nconst v = (x = 0, y = 0): Vec2 => ({ x, y });\nconst dot = (a: Vec2, b: Vec2): Num => a.x * b.x + a.y * b.y;\nconst cross = (a: Vec2, b: Vec2): Num => a.x * b.y - a.y * b.x;\nconst sub = (a: Vec2, b: Vec2): Vec2 => v(a.x - b.x, a.y - b.y);\nconst add = (a: Vec2, b: Vec2): Vec2 => v(a.x + b.x, a.y + b.y);\nconst mul = (a: Vec2, s: Num): Vec2 => v(a.x * s, a.y * s);\nconst len = (a: Vec2): Num => Math.hypot(a.x, a.y);\nconst crossSV = (s: Num, a: Vec2): Vec2 => v(-s * a.y, s * a.x);\nconst rot = (a: Vec2, c: Num, s: Num): Vec2 => v(a.x * c - a.y * s, a.x * s + a.y * c);\n\nexport type ShapeKind = 'circle' | 'box' | 'polygon';\nexport interface BodyOptions {\n shape?: ShapeKind;\n x?: Num;\n y?: Num;\n angle?: Num;\n /** circle */\n radius?: Num;\n /** box */\n width?: Num;\n height?: Num;\n /** polygon: local vertices (any winding; made convex-ccw) */\n vertices?: [Num, Num][];\n /** 'dynamic' (default), 'static' (never moves) or 'kinematic' (moves by its velocity, ignores forces / collisions). */\n type?: 'dynamic' | 'static' | 'kinematic';\n /** Mass per unit area (default 0.001 → a 40 px box weighs 1.6). */\n density?: Num;\n /** Overrides density. */\n mass?: Num;\n restitution?: Num;\n friction?: Num;\n vx?: Num;\n vy?: Num;\n angularVelocity?: Num;\n /** Linear / angular damping per second (0–1). */\n damping?: Num;\n angularDamping?: Num;\n /** Collides with nothing, reports overlaps only. */\n sensor?: boolean;\n /** Collision filtering: bodies collide when (a.category & b.mask) && (b.category & a.mask). */\n category?: Num;\n mask?: Num;\n /** No rotation (infinite inertia). */\n fixedRotation?: boolean;\n label?: string;\n /** Anything (e.g. a fill colour for your renderer). */\n data?: unknown;\n}\n\nlet nextId = 1;\n\nexport class Body {\n readonly id = nextId++;\n label: string;\n shape: ShapeKind;\n type: 'dynamic' | 'static' | 'kinematic';\n position: Vec2;\n velocity: Vec2;\n angle: Num;\n angularVelocity: Num;\n force = v();\n torque = 0;\n radius = 0;\n /** Local convex vertices (counter-clockwise) for boxes / polygons. */\n verts: Vec2[] = [];\n normals: Vec2[] = [];\n mass = 0;\n invMass = 0;\n inertia = 0;\n invInertia = 0;\n restitution: Num;\n friction: Num;\n damping: Num;\n angularDamping: Num;\n sensor: boolean;\n category: Num;\n mask: Num;\n sleeping = false;\n sleepTime = 0;\n data: unknown;\n /** Bounding box, refreshed every step. */\n aabb = { minX: 0, minY: 0, maxX: 0, maxY: 0 };\n private wv: Vec2[] = [];\n private wvAngle = NaN;\n private wvPos = v(NaN, NaN);\n\n constructor(o: BodyOptions = {}) {\n this.shape = o.shape || (o.vertices ? 'polygon' : o.radius != null && o.width == null ? 'circle' : 'box');\n this.type = o.type || 'dynamic';\n this.label = o.label || this.shape;\n this.position = v(o.x || 0, o.y || 0);\n this.velocity = v(o.vx || 0, o.vy || 0);\n this.angle = o.angle || 0;\n this.angularVelocity = o.angularVelocity || 0;\n this.restitution = o.restitution ?? 0.2;\n this.friction = o.friction ?? 0.4;\n this.damping = o.damping ?? 0;\n this.angularDamping = o.angularDamping ?? 0.01;\n this.sensor = !!o.sensor;\n this.category = o.category ?? 1;\n this.mask = o.mask ?? 0xffffffff;\n this.data = o.data;\n const density = o.density ?? 0.001;\n let area = 0, I = 0;\n if (this.shape === 'circle') {\n this.radius = o.radius ?? 20;\n area = Math.PI * this.radius ** 2;\n I = 0.5 * this.radius ** 2; // per unit mass\n } else {\n const pts = this.shape === 'box' ? boxVerts(o.width ?? 40, o.height ?? 40) : hull((o.vertices || []).map(([x, y]) => v(x, y)));\n if (pts.length < 3) throw new Error('[motionary] physics: a polygon needs at least 3 non-collinear vertices');\n // centre the polygon on its centroid\n const { c, a, i } = polyMass(pts);\n this.verts = pts.map((p) => sub(p, c));\n area = a;\n I = i;\n this.radius = Math.max(...this.verts.map(len));\n this.normals = this.verts.map((p, k) => {\n const q = this.verts[(k + 1) % this.verts.length];\n const e = sub(q, p);\n const n = v(e.y, -e.x);\n return mul(n, 1 / len(n));\n });\n }\n if (this.type === 'dynamic') {\n this.mass = o.mass ?? density * area;\n this.invMass = this.mass > 0 ? 1 / this.mass : 0;\n this.inertia = o.fixedRotation ? Infinity : this.mass * I;\n this.invInertia = o.fixedRotation || !this.inertia ? 0 : 1 / this.inertia;\n }\n }\n get isStatic(): boolean {\n return this.type === 'static';\n }\n /** Vertices in world space (cached per pose). */\n worldVerts(): Vec2[] {\n if (this.wvAngle !== this.angle || this.wvPos.x !== this.position.x || this.wvPos.y !== this.position.y) {\n const c = Math.cos(this.angle), s = Math.sin(this.angle);\n this.wv = this.verts.map((p) => add(rot(p, c, s), this.position));\n this.wvAngle = this.angle;\n this.wvPos = v(this.position.x, this.position.y);\n }\n return this.wv;\n }\n worldNormal(i: Num): Vec2 {\n return rot(this.normals[i], Math.cos(this.angle), Math.sin(this.angle));\n }\n updateAabb(): void {\n if (this.shape === 'circle') {\n const r = this.radius, p = this.position;\n this.aabb = { minX: p.x - r, minY: p.y - r, maxX: p.x + r, maxY: p.y + r };\n return;\n }\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n for (const p of this.worldVerts()) {\n if (p.x < minX) minX = p.x;\n if (p.y < minY) minY = p.y;\n if (p.x > maxX) maxX = p.x;\n if (p.y > maxY) maxY = p.y;\n }\n this.aabb = { minX, minY, maxX, maxY };\n }\n applyImpulse(j: Vec2, at?: Vec2): void {\n if (this.type !== 'dynamic') return;\n this.wake();\n this.velocity = add(this.velocity, mul(j, this.invMass));\n if (at) this.angularVelocity += cross(sub(at, this.position), j) * this.invInertia;\n }\n applyForce(f: Vec2, at?: Vec2): void {\n if (this.type !== 'dynamic') return;\n this.wake();\n this.force = add(this.force, f);\n if (at) this.torque += cross(sub(at, this.position), f);\n }\n wake(): void {\n this.sleeping = false;\n this.sleepTime = 0;\n }\n /** Is the world point inside this body? */\n contains(x: Num, y: Num): boolean {\n const p = v(x, y);\n if (this.shape === 'circle') return len(sub(p, this.position)) <= this.radius;\n const w = this.worldVerts();\n for (let i = 0; i < w.length; i++) if (dot(this.worldNormal(i), sub(p, w[i])) > 0) return false;\n return true;\n }\n}\n\nfunction boxVerts(w: Num, h: Num): Vec2[] {\n return [v(-w / 2, -h / 2), v(w / 2, -h / 2), v(w / 2, h / 2), v(-w / 2, h / 2)];\n}\n/** Convex hull (monotone chain), counter-clockwise in a y-down screen space = clockwise maths; we keep \"outward normals\" consistent. */\nfunction hull(pts: Vec2[]): Vec2[] {\n const p = pts.slice().sort((a, b) => a.x - b.x || a.y - b.y);\n if (p.length < 3) return p;\n const lower: Vec2[] = [], upper: Vec2[] = [];\n const turn = (o: Vec2, a: Vec2, b: Vec2) => cross(sub(a, o), sub(b, o));\n for (const q of p) {\n while (lower.length >= 2 && turn(lower[lower.length - 2], lower[lower.length - 1], q) <= 0) lower.pop();\n lower.push(q);\n }\n for (let i = p.length - 1; i >= 0; i--) {\n const q = p[i];\n while (upper.length >= 2 && turn(upper[upper.length - 2], upper[upper.length - 1], q) <= 0) upper.pop();\n upper.push(q);\n }\n return lower.slice(0, -1).concat(upper.slice(0, -1));\n}\n/** Area, centroid and polar moment per unit mass of a convex polygon. */\nfunction polyMass(p: Vec2[]): { a: Num; c: Vec2; i: Num } {\n let A = 0, cx = 0, cy = 0, I = 0;\n for (let k = 0; k < p.length; k++) {\n const a = p[k], b = p[(k + 1) % p.length];\n const cr = cross(a, b);\n A += cr;\n cx += (a.x + b.x) * cr;\n cy += (a.y + b.y) * cr;\n I += cr * (dot(a, a) + dot(a, b) + dot(b, b));\n }\n A /= 2;\n const c = v(cx / (6 * A), cy / (6 * A));\n const Io = I / 12; // about the origin, times density\n const iC = Io / A - dot(c, c); // per unit mass, about the centroid\n return { a: Math.abs(A), c, i: Math.abs(iC) };\n}\n\n// ------------------------------------------------------------------ narrow phase\nconst SPECULATIVE = 1;\nconst RESTITUTION_THRESHOLD = 150;\n/** Squared speed (px²/s², incl. the rim speed of rotation) under which a body may fall asleep. */\nconst SLEEP_MOTION = 36;\n/** Inverse mass / inertia as the solver sees them: static, kinematic and sleeping bodies do not move. */\nconst iM = (b: Body): Num => (b.type === 'dynamic' && !b.sleeping ? b.invMass : 0);\nconst iI = (b: Body): Num => (b.type === 'dynamic' && !b.sleeping ? b.invInertia : 0);\nconst motion = (b: Body): Num => dot(b.velocity, b.velocity) + (b.angularVelocity * b.radius) ** 2;\nexport interface Contact { point: Vec2; depth: Num }\nexport interface Manifold { a: Body; b: Body; normal: Vec2; contacts: Contact[] }\n\nfunction circleCircle(a: Body, b: Body): Manifold | null {\n const d = sub(b.position, a.position), dist = len(d), r = a.radius + b.radius;\n if (dist >= r) return null;\n const n = dist > 1e-9 ? mul(d, 1 / dist) : v(0, 1);\n return { a, b, normal: n, contacts: [{ point: add(a.position, mul(n, a.radius - (r - dist) / 2)), depth: r - dist }] };\n}\nfunction polyCircle(p: Body, c: Body): Manifold | null {\n // normal from the polygon to the circle\n const w = p.worldVerts();\n let best = -Infinity, bi = 0;\n for (let i = 0; i < w.length; i++) {\n const s = dot(p.worldNormal(i), sub(c.position, w[i]));\n if (s > c.radius) return null;\n if (s > best) (best = s), (bi = i);\n }\n if (best < 1e-9) {\n // centre inside the polygon\n const n = p.worldNormal(bi);\n return { a: p, b: c, normal: n, contacts: [{ point: sub(c.position, mul(n, c.radius)), depth: c.radius - best }] };\n }\n // closest point on the polygon outline\n let cp = w[0], cd = Infinity;\n for (let i = 0; i < w.length; i++) {\n const a = w[i], b = w[(i + 1) % w.length], e = sub(b, a);\n const t = Math.max(0, Math.min(1, dot(sub(c.position, a), e) / dot(e, e)));\n const q = add(a, mul(e, t)), d = len(sub(c.position, q));\n if (d < cd) (cd = d), (cp = q);\n }\n if (cd >= c.radius) return null;\n const n = cd > 1e-9 ? mul(sub(c.position, cp), 1 / cd) : p.worldNormal(bi);\n return { a: p, b: c, normal: n, contacts: [{ point: cp, depth: c.radius - cd }] };\n}\nfunction maxSeparation(a: Body, b: Body): { s: Num; i: Num } {\n const wa = a.worldVerts(), wb = b.worldVerts();\n let best = -Infinity, bi = 0;\n for (let i = 0; i < wa.length; i++) {\n const n = a.worldNormal(i);\n let m = Infinity;\n for (const q of wb) m = Math.min(m, dot(n, sub(q, wa[i])));\n if (m > best) (best = m), (bi = i);\n }\n return { s: best, i: bi };\n}\nfunction polyPoly(a: Body, b: Body): Manifold | null {\n const A = maxSeparation(a, b);\n if (A.s > 0) return null;\n const B = maxSeparation(b, a);\n if (B.s > 0) return null;\n let ref = a, inc = b, fi = A.i, flip = false;\n if (B.s > A.s * 0.95 + 0.01) (ref = b), (inc = a), (fi = B.i), (flip = true);\n const rw = ref.worldVerts(), iw = inc.worldVerts();\n const n = ref.worldNormal(fi);\n // incident edge: the one whose normal is most anti-parallel to n\n let ii = 0, md = Infinity;\n for (let i = 0; i < iw.length; i++) {\n const d = dot(inc.worldNormal(i), n);\n if (d < md) (md = d), (ii = i);\n }\n let pts = [iw[ii], iw[(ii + 1) % iw.length]];\n const r1 = rw[fi], r2 = rw[(fi + 1) % rw.length];\n const t = mul(sub(r2, r1), 1 / len(sub(r2, r1)));\n // clip against the side planes of the reference edge\n const clip = (ps: Vec2[], dir: Vec2, off: Num): Vec2[] => {\n const out: Vec2[] = [];\n const d0 = dot(dir, ps[0]) - off, d1 = dot(dir, ps[1]) - off;\n if (d0 <= 0) out.push(ps[0]);\n if (d1 <= 0) out.push(ps[1]);\n if (d0 * d1 < 0) out.push(add(ps[0], mul(sub(ps[1], ps[0]), d0 / (d0 - d1))));\n return out;\n };\n pts = clip(pts, mul(t, -1), -dot(t, r1));\n if (pts.length < 2) return null;\n pts = clip(pts, t, dot(t, r2));\n if (pts.length < 2) return null;\n const contacts: Contact[] = [];\n for (const p of pts) {\n const sep = dot(n, sub(p, r1));\n // keep points that are just apart too (speculative): resting stacks keep two contacts instead of rocking on one\n if (sep <= SPECULATIVE) contacts.push({ point: p, depth: -sep });\n }\n if (!contacts.some((c) => c.depth >= 0)) return null;\n return flip ? { a, b, normal: mul(n, -1), contacts } : { a, b, normal: n, contacts };\n}\n/** Contact manifold between two bodies (normal points from a to b), or null. */\nexport function collide(a: Body, b: Body): Manifold | null {\n if (a.shape === 'circle' && b.shape === 'circle') return circleCircle(a, b);\n if (a.shape !== 'circle' && b.shape === 'circle') return polyCircle(a, b);\n if (a.shape === 'circle' && b.shape !== 'circle') {\n const m = polyCircle(b, a);\n return m && { a, b, normal: mul(m.normal, -1), contacts: m.contacts };\n }\n return polyPoly(a, b);\n}\n\n// ------------------------------------------------------------------ constraints\nexport interface ConstraintOptions {\n type: 'distance' | 'pin';\n a: Body;\n /** distance: the other body; pin: omitted. */\n b?: Body;\n /** Anchor on a / b in body-local coordinates (default the centre). */\n anchorA?: [Num, Num];\n anchorB?: [Num, Num];\n /** pin: the world point. */\n point?: [Num, Num];\n /** Rest length (default: the current distance). */\n length?: Num;\n /** 1 = rigid; < 1 = spring (fraction of the error corrected per step). */\n stiffness?: Num;\n /** Spring damping (0–1). */\n damping?: Num;\n label?: string;\n}\nexport class Constraint {\n type: 'distance' | 'pin';\n a: Body;\n b: Body | null;\n anchorA: Vec2;\n anchorB: Vec2;\n point: Vec2;\n length: Num;\n stiffness: Num;\n damping: Num;\n label: string;\n constructor(o: ConstraintOptions) {\n this.type = o.type;\n this.a = o.a;\n this.b = o.b || null;\n this.anchorA = v(...(o.anchorA || [0, 0]));\n this.anchorB = v(...(o.anchorB || [0, 0]));\n this.point = v(...(o.point || [o.a.position.x, o.a.position.y]));\n this.stiffness = o.stiffness ?? 1;\n this.damping = o.damping ?? 0.1;\n this.label = o.label || o.type;\n this.length = o.length ?? len(sub(this.worldB(), this.worldA()));\n }\n worldA(): Vec2 {\n return add(this.a.position, rot(this.anchorA, Math.cos(this.a.angle), Math.sin(this.a.angle)));\n }\n worldB(): Vec2 {\n return this.b ? add(this.b.position, rot(this.anchorB, Math.cos(this.b.angle), Math.sin(this.b.angle))) : this.point;\n }\n /** One velocity iteration (impulse along the constraint axis, with a position bias). */\n solve(h: Num): void {\n const a = this.a, b = this.b;\n const pa = this.worldA(), pb = this.worldB();\n const d = sub(pb, pa), dist = len(d);\n if (dist < 1e-9 && this.length < 1e-9 && this.type === 'distance') return;\n const n = dist > 1e-9 ? mul(d, 1 / dist) : v(1, 0);\n const ra = sub(pa, a.position), rb = b ? sub(pb, b.position) : v();\n const va = add(a.velocity, crossSV(a.angularVelocity, ra));\n const vb = b ? add(b.velocity, crossSV(b.angularVelocity, rb)) : v();\n const vn = dot(sub(vb, va), n);\n const C = dist - this.length;\n const k = a.invMass + (b ? b.invMass : 0) + cross(ra, n) ** 2 * a.invInertia + (b ? cross(rb, n) ** 2 * b.invInertia : 0);\n if (k <= 0) return;\n const beta = this.stiffness >= 1 ? 0.2 : this.stiffness * 0.2;\n let lambda = -(vn * (this.stiffness >= 1 ? 1 : this.damping + this.stiffness) + (beta / h) * C) / k;\n if (this.stiffness < 1) lambda *= this.stiffness;\n const j = mul(n, lambda);\n a.applyImpulse(mul(j, -1), pa);\n b?.applyImpulse(j, pb);\n }\n}\n\n// ------------------------------------------------------------------ world\nexport interface WorldOptions {\n gravity?: [Num, Num];\n /** Velocity iterations per step (default 10). */\n iterations?: Num;\n /** Fixed step in seconds (default 1/60). */\n step?: Num;\n /** Let resting bodies sleep (default true). */\n sleeping?: boolean;\n}\nexport type CollisionListener = (m: Manifold) => void;\n\nexport class World {\n gravity: Vec2;\n iterations: Num;\n fixedStep: Num;\n sleeping: boolean;\n bodies: Body[] = [];\n constraints: Constraint[] = [];\n /** Manifolds of the last step (incl. sensor overlaps, which have no response). */\n contacts: Manifold[] = [];\n time = 0;\n steps = 0;\n private acc = 0;\n private warm = new Map<string, Warm>();\n private listeners = new Set<CollisionListener>();\n private stop: (() => void) | null = null;\n constructor(o: WorldOptions = {}) {\n this.gravity = v(...(o.gravity || [0, 980]));\n this.iterations = o.iterations ?? 10;\n this.fixedStep = o.step ?? 1 / 60;\n this.sleeping = o.sleeping ?? true;\n }\n add<T extends Body | Constraint>(...items: T[]): T {\n for (const it of items) it instanceof Body ? this.bodies.push(it) : this.constraints.push(it as Constraint);\n return items[0];\n }\n body(o: BodyOptions): Body {\n return this.add(new Body(o));\n }\n constraint(o: ConstraintOptions): Constraint {\n return this.add(new Constraint(o));\n }\n remove(...items: (Body | Constraint)[]): void {\n for (const it of items) {\n if (it instanceof Body) {\n this.bodies = this.bodies.filter((b) => b !== it);\n this.constraints = this.constraints.filter((c) => c.a !== it && c.b !== it);\n } else this.constraints = this.constraints.filter((c) => c !== it);\n }\n }\n clear(): void {\n this.bodies = [];\n this.constraints = [];\n this.contacts = [];\n }\n /** Static walls around a w × h box (thickness t outside it). */\n bounds(w: Num, h: Num, t = 50, o: { top?: boolean } = {}): Body[] {\n const walls = [\n new Body({ type: 'static', x: w / 2, y: h + t / 2, width: w + 2 * t, height: t, label: 'floor' }),\n new Body({ type: 'static', x: -t / 2, y: h / 2, width: t, height: h + 2 * t, label: 'wall-left' }),\n new Body({ type: 'static', x: w + t / 2, y: h / 2, width: t, height: h + 2 * t, label: 'wall-right' }),\n ];\n if (o.top !== false) walls.push(new Body({ type: 'static', x: w / 2, y: -t / 2, width: w + 2 * t, height: t, label: 'ceiling' }));\n for (const b of walls) this.add(b);\n return walls;\n }\n onCollision(fn: CollisionListener): () => void {\n this.listeners.add(fn);\n return () => this.listeners.delete(fn);\n }\n /** Bodies under a world point (topmost = last added first). */\n query(x: Num, y: Num): Body[] {\n return this.bodies.filter((b) => b.contains(x, y)).reverse();\n }\n /** Advance by `seconds` of real time in fixed steps (max 8 steps per call). */\n update(seconds: Num): Num {\n this.acc = Math.min(this.acc + seconds, this.fixedStep * 8);\n let n = 0;\n while (this.acc >= this.fixedStep) {\n this.step(this.fixedStep);\n this.acc -= this.fixedStep;\n n++;\n }\n return n;\n }\n /** One fixed step of h seconds. */\n step(h: Num = this.fixedStep): void {\n const bodies = this.bodies;\n // integrate forces\n for (const b of bodies) {\n if (b.type !== 'dynamic' || b.sleeping) continue;\n b.velocity = add(b.velocity, mul(add(this.gravity, mul(b.force, b.invMass)), h));\n b.angularVelocity += b.torque * b.invInertia * h;\n if (b.damping) b.velocity = mul(b.velocity, Math.max(0, 1 - b.damping * h));\n if (b.angularDamping) b.angularVelocity *= Math.max(0, 1 - b.angularDamping * h);\n }\n // broad phase: sort and sweep on x\n for (const b of bodies) b.updateAabb();\n const sorted = bodies.slice().sort((p, q) => p.aabb.minX - q.aabb.minX);\n const manifolds: Manifold[] = [];\n for (let i = 0; i < sorted.length; i++) {\n const a = sorted[i];\n for (let j = i + 1; j < sorted.length; j++) {\n const b = sorted[j];\n if (b.aabb.minX > a.aabb.maxX) break;\n if (b.aabb.minY > a.aabb.maxY || b.aabb.maxY < a.aabb.minY) continue;\n if (a.type !== 'dynamic' && b.type !== 'dynamic') continue;\n if (!(a.category & b.mask) || !(b.category & a.mask)) continue;\n if ((a.sleeping || a.type !== 'dynamic') && (b.sleeping || b.type !== 'dynamic')) continue;\n const m = a.id < b.id ? collide(a, b) : collide(b, a);\n if (!m) continue;\n manifolds.push(m);\n }\n }\n this.contacts = manifolds;\n const solid = manifolds.filter((m) => !m.a.sensor && !m.b.sensor);\n for (const m of solid) {\n // wake a sleeper hit by a moving body\n // wake a sleeper only when something hits it with some speed (resting neighbours do not keep a pile awake)\n if (m.a.sleeping && !m.b.sleeping && m.b.type === 'dynamic' && motion(m.b) > SLEEP_MOTION * 4) m.a.wake();\n if (m.b.sleeping && !m.a.sleeping && m.a.type === 'dynamic' && motion(m.a) > SLEEP_MOTION * 4) m.b.wake();\n }\n // velocity iterations\n const key = (m: Manifold) => m.a.id + ':' + m.b.id;\n for (const m of solid) prepare(m, h, this.warm.get(key(m)));\n for (let it = 0; it < this.iterations; it++) {\n for (const m of solid) resolve(m);\n for (const c of this.constraints) c.solve(h);\n }\n this.warm = new Map(solid.map((m) => [key(m), { pts: m.contacts.map((c) => c.point), pn: (m.contacts as Solved[]).map((c) => c.pn), pt: (m.contacts as Solved[]).map((c) => c.pt) }]));\n // integrate positions\n for (const b of bodies) {\n if (b.type === 'static' || b.sleeping) continue;\n b.position = add(b.position, mul(b.velocity, h));\n b.angle += b.angularVelocity * h;\n b.force = v();\n b.torque = 0;\n }\n // sleeping, per island (bodies linked by contacts / constraints sleep and wake together)\n if (this.sleeping) {\n const parent = new Map<Body, Body>();\n const find = (x: Body): Body => {\n let r = x;\n while (parent.get(r) !== r) r = parent.get(r)!;\n parent.set(x, r);\n return r;\n };\n const dyn = (x: Body | null): x is Body => !!x && x.type === 'dynamic';\n for (const b of bodies) if (dyn(b)) parent.set(b, b);\n const link = (x: Body | null, y: Body | null) => {\n if (dyn(x) && dyn(y)) parent.set(find(x), find(y));\n };\n for (const m of solid) link(m.a, m.b);\n for (const c of this.constraints) link(c.a, c.b);\n const dragged = new Set(this.constraints.filter((c) => c.label === 'drag').map((c) => c.a));\n for (const b of parent.keys()) {\n if (b.sleeping) continue;\n if (motion(b) < SLEEP_MOTION && !dragged.has(b)) b.sleepTime += h;\n else b.sleepTime = 0;\n }\n const islands = new Map<Body, Body[]>();\n for (const b of parent.keys()) {\n const r = find(b);\n islands.set(r, [...(islands.get(r) || []), b]);\n }\n for (const isl of islands.values()) {\n if (isl.some((b) => !b.sleeping && b.sleepTime <= 0.6)) {\n // anything awake and moving keeps (or makes) the whole island awake\n if (isl.some((b) => b.sleeping) && isl.some((b) => !b.sleeping && b.sleepTime === 0)) for (const b of isl) b.wake();\n continue;\n }\n for (const b of isl) {\n b.sleeping = true;\n b.velocity = v();\n b.angularVelocity = 0;\n }\n }\n }\n this.time += h;\n this.steps++;\n if (this.listeners.size) for (const m of manifolds) for (const fn of this.listeners) fn(m);\n }\n /** Drive the world from the shared runtime ticker (needs the core). Returns a stopper. */\n run(): () => void {\n if (this.stop) return this.stop;\n const off = requireModule<CoreApi>('core', 'motionary/runtime/physics').getTicker().add((_, dt) => this.update(Math.min(dt, 100) / 1000));\n this.stop = () => {\n off();\n this.stop = null;\n };\n return this.stop;\n }\n get running(): boolean {\n return !!this.stop;\n }\n /** Total kinetic energy (handy for tests / \"settled\" checks). */\n energy(): Num {\n return this.bodies.reduce((e, b) => e + (b.type === 'dynamic' ? 0.5 * b.mass * dot(b.velocity, b.velocity) + 0.5 * (isFinite(b.inertia) ? b.inertia : 0) * b.angularVelocity ** 2 : 0), 0);\n }\n}\n\ninterface Solved extends Contact { ra: Vec2; rb: Vec2; mn: Num; mt: Num; bias: Num; pn: Num; pt: Num }\n/** Pre-step: effective masses, Baumgarte bias and the restitution target, per contact (accumulated impulses start at 0). */\ntype Warm = { pts: Vec2[]; pn: Num[]; pt: Num[] };\nfunction prepare(m: Manifold, h: Num, warm?: Warm): void {\n const { a, b, normal: n } = m;\n const t = v(n.y, -n.x);\n const e = Math.max(a.restitution, b.restitution);\n for (const c of m.contacts as Solved[]) {\n c.ra = sub(c.point, a.position);\n c.rb = sub(c.point, b.position);\n const kn = iM(a) + iM(b) + cross(c.ra, n) ** 2 * iI(a) + cross(c.rb, n) ** 2 * iI(b);\n const kt = iM(a) + iM(b) + cross(c.ra, t) ** 2 * iI(a) + cross(c.rb, t) ** 2 * iI(b);\n c.mn = kn > 0 ? 1 / kn : 0;\n c.mt = kt > 0 ? 1 / kt : 0;\n const rv = sub(add(b.velocity, crossSV(b.angularVelocity, c.rb)), add(a.velocity, crossSV(a.angularVelocity, c.ra)));\n const vn = dot(rv, n);\n // penetrating: push out (Baumgarte); just apart: allow closing the gap this step but not more\n c.bias = c.depth < 0 ? c.depth / h : Math.max((0.2 / h) * Math.max(0, c.depth - 0.25), vn < -RESTITUTION_THRESHOLD ? -e * vn : 0);\n c.pn = 0;\n c.pt = 0;\n }\n // warm start: reuse last step's impulses for contacts that stayed put (stacks settle instead of creeping)\n if (warm) {\n (m.contacts as Solved[]).forEach((c) => {\n if (c.depth < 0) return;\n // match by position (the clipper may list the two points in either order)\n let i = -1, best = 2;\n warm.pts.forEach((q, k) => {\n const d = len(sub(c.point, q));\n if (d < best) (best = d), (i = k);\n });\n if (i < 0) return;\n c.pn = warm.pn[i];\n c.pt = warm.pt[i];\n applyPair(a, b, add(mul(n, c.pn), mul(t, c.pt)), c.ra, c.rb);\n });\n }\n}\n/** One velocity iteration with accumulated, clamped impulses: friction first (|friction| ≤ μ·normal), then the\n * normal impulses (≥ 0) — two-point manifolds are solved as one 2 × 2 block (a tiny LCP), which keeps boxes resting\n * on boxes from rocking from corner to corner. */\nfunction resolve(m: Manifold): void {\n const { a, b, normal: n } = m;\n const t = v(n.y, -n.x);\n const mu = Math.sqrt(a.friction * b.friction);\n const cs = m.contacts as Solved[];\n const rel = (c: Solved) => sub(add(b.velocity, crossSV(b.angularVelocity, c.rb)), add(a.velocity, crossSV(a.angularVelocity, c.ra)));\n for (const c of cs) {\n let dt = -c.mt * dot(rel(c), t);\n const t0 = c.pt, max = mu * c.pn;\n c.pt = Math.max(-max, Math.min(max, t0 + dt));\n dt = c.pt - t0;\n applyPair(a, b, mul(t, dt), c.ra, c.rb);\n }\n if (cs.length === 2) {\n const [c1, c2] = cs;\n const im = iM, ii = iI;\n const rn1a = cross(c1.ra, n), rn1b = cross(c1.rb, n), rn2a = cross(c2.ra, n), rn2b = cross(c2.rb, n);\n const k11 = im(a) + im(b) + ii(a) * rn1a * rn1a + ii(b) * rn1b * rn1b;\n const k22 = im(a) + im(b) + ii(a) * rn2a * rn2a + ii(b) * rn2b * rn2b;\n const k12 = im(a) + im(b) + ii(a) * rn1a * rn2a + ii(b) * rn1b * rn2b;\n const det = k11 * k22 - k12 * k12;\n if (k11 * k11 < 1000 * det) {\n const a1 = c1.pn, a2 = c2.pn;\n const b1 = dot(rel(c1), n) - c1.bias - (k11 * a1 + k12 * a2);\n const b2 = dot(rel(c2), n) - c2.bias - (k12 * a1 + k22 * a2);\n let x1 = 0, x2 = 0;\n const sol = (): boolean => {\n // 1. both active\n x1 = -(k22 * b1 - k12 * b2) / det;\n x2 = -(k11 * b2 - k12 * b1) / det;\n if (x1 >= 0 && x2 >= 0) return true;\n // 2. only the first\n x1 = -b1 / k11;\n x2 = 0;\n if (x1 >= 0 && k12 * x1 + b2 >= 0) return true;\n // 3. only the second\n x1 = 0;\n x2 = -b2 / k22;\n if (x2 >= 0 && k12 * x2 + b1 >= 0) return true;\n // 4. none\n x1 = x2 = 0;\n return b1 >= 0 && b2 >= 0;\n };\n if (sol()) {\n applyPair(a, b, mul(n, x1 - a1), c1.ra, c1.rb);\n applyPair(a, b, mul(n, x2 - a2), c2.ra, c2.rb);\n c1.pn = x1;\n c2.pn = x2;\n return;\n }\n }\n }\n for (const c of cs) {\n let d = c.mn * (-dot(rel(c), n) + c.bias);\n const p0 = c.pn;\n c.pn = Math.max(p0 + d, 0);\n d = c.pn - p0;\n applyPair(a, b, mul(n, d), c.ra, c.rb);\n }\n}\nfunction applyPair(a: Body, b: Body, J: Vec2, ra: Vec2, rb: Vec2): void {\n if (a.type === 'dynamic' && !a.sleeping) {\n a.velocity = sub(a.velocity, mul(J, a.invMass));\n a.angularVelocity -= cross(ra, J) * a.invInertia;\n }\n if (b.type === 'dynamic' && !b.sleeping) {\n b.velocity = add(b.velocity, mul(J, b.invMass));\n b.angularVelocity += cross(rb, J) * b.invInertia;\n }\n}\n\n/** A world (also registers nothing — pure). */\nexport function createWorld(o: WorldOptions = {}): World {\n return new World(o);\n}\n\n/** Pointer dragging: a soft pin from a body point to a moving world point. */\nexport function dragConstraint(world: World, body: Body, x: Num, y: Num, stiffness = 0.6): { move(x: Num, y: Num): void; release(): void; constraint: Constraint } {\n const c = body.angle;\n const local = rot(sub(v(x, y), body.position), Math.cos(-c), Math.sin(-c));\n const k = world.constraint({ type: 'pin', a: body, anchorA: [local.x, local.y], point: [x, y], length: 0, stiffness, damping: 0.3, label: 'drag' });\n body.wake();\n return {\n constraint: k,\n move(px: Num, py: Num) {\n k.point = v(px, py);\n body.wake();\n },\n release() {\n world.remove(k);\n },\n };\n}\n\nexport interface PhysicsApi {\n createWorld: typeof createWorld;\n World: typeof World;\n Body: typeof Body;\n Constraint: typeof Constraint;\n collide: typeof collide;\n dragConstraint: typeof dragConstraint;\n}\n\n/** The module object for `use(physics)`. */\nexport const physics: RuntimeModule<PhysicsApi> = { id: 'physics',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AC1E,MAAM,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IACnJ,IAAI,CAAC,IAAI,EAAE;IACX,OAAO;AACL,QAAA,UAAU,EAAE,CAAC;QACb,IAAI,CAAC,EAAO,EAAE,EAAO,EAAA;YACnB,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC;YACnB,IAAI,CAAC,IAAI,EAAE;QACb,CAAC;QACD,OAAO,GAAA;AACL,YAAA,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;QACjB,CAAC;KACF;AACH;AAWA;AACO,MAAM,OAAO,GAA8B,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAEC,wBAAe,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE;;;;;;;;"}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/** A runtime module: `{ id, version, api }`, registered with `use()`. */
|
|
2
|
+
interface RuntimeModule<A = unknown> {
|
|
3
|
+
/** Module id: 'core', 'format-css', 'scroll', … (import path `motionary/runtime/<id>`). */
|
|
4
|
+
id: string;
|
|
5
|
+
version: string;
|
|
6
|
+
/** Other modules this one needs (registered first by `use()` callers). */
|
|
7
|
+
requires?: string[];
|
|
8
|
+
/** The module's public API (what `requireModule(id)` returns). */
|
|
9
|
+
api: A;
|
|
10
|
+
/** Optional one-time setup, called on first registration. */
|
|
11
|
+
setup?(registry: RuntimeRegistry): void;
|
|
12
|
+
}
|
|
13
|
+
interface RuntimeRegistry {
|
|
14
|
+
version: string;
|
|
15
|
+
modules: Map<string, RuntimeModule>;
|
|
16
|
+
/** Shared per-page state slots (the ticker lives here). */
|
|
17
|
+
slots: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* `motionary/runtime/physics` (10.7) — a small 2D rigid-body engine written
|
|
22
|
+
* for Motionary (own implementation and API; no Matter.js / Box2D code):
|
|
23
|
+
*
|
|
24
|
+
* - bodies: circles, boxes and convex polygons (static, dynamic or
|
|
25
|
+
* kinematic), density → mass + moment of inertia, restitution, friction,
|
|
26
|
+
* sensors, collision groups / masks, sleeping;
|
|
27
|
+
* - collisions: sort-and-sweep broad phase, separating-axis narrow phase
|
|
28
|
+
* with clipped contact manifolds (up to 2 points), sequential, accumulated and
|
|
29
|
+
* clamped impulses (normal + Coulomb friction) with a Baumgarte position bias;
|
|
30
|
+
* - constraints: `distance` (rigid or a spring with `stiffness` /
|
|
31
|
+
* `damping`), `pin` (a body point to a world point — also the pointer
|
|
32
|
+
* drag constraint) and `weld`-like stiff distance pairs;
|
|
33
|
+
* - a fixed time step (default 1/60 s) with an accumulator, so results are
|
|
34
|
+
* the same at any frame rate; `world.run()` drives it from the shared
|
|
35
|
+
* runtime ticker (pauses while the ticker sleeps).
|
|
36
|
+
*
|
|
37
|
+
* Pure maths — no DOM: safe in SSR and workers. Units are up to you (the
|
|
38
|
+
* defaults assume pixels: gravity 980 px/s²).
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
type Num = number;
|
|
42
|
+
interface Vec2 {
|
|
43
|
+
x: Num;
|
|
44
|
+
y: Num;
|
|
45
|
+
}
|
|
46
|
+
type ShapeKind = 'circle' | 'box' | 'polygon';
|
|
47
|
+
interface BodyOptions {
|
|
48
|
+
shape?: ShapeKind;
|
|
49
|
+
x?: Num;
|
|
50
|
+
y?: Num;
|
|
51
|
+
angle?: Num;
|
|
52
|
+
/** circle */
|
|
53
|
+
radius?: Num;
|
|
54
|
+
/** box */
|
|
55
|
+
width?: Num;
|
|
56
|
+
height?: Num;
|
|
57
|
+
/** polygon: local vertices (any winding; made convex-ccw) */
|
|
58
|
+
vertices?: [Num, Num][];
|
|
59
|
+
/** 'dynamic' (default), 'static' (never moves) or 'kinematic' (moves by its velocity, ignores forces / collisions). */
|
|
60
|
+
type?: 'dynamic' | 'static' | 'kinematic';
|
|
61
|
+
/** Mass per unit area (default 0.001 → a 40 px box weighs 1.6). */
|
|
62
|
+
density?: Num;
|
|
63
|
+
/** Overrides density. */
|
|
64
|
+
mass?: Num;
|
|
65
|
+
restitution?: Num;
|
|
66
|
+
friction?: Num;
|
|
67
|
+
vx?: Num;
|
|
68
|
+
vy?: Num;
|
|
69
|
+
angularVelocity?: Num;
|
|
70
|
+
/** Linear / angular damping per second (0–1). */
|
|
71
|
+
damping?: Num;
|
|
72
|
+
angularDamping?: Num;
|
|
73
|
+
/** Collides with nothing, reports overlaps only. */
|
|
74
|
+
sensor?: boolean;
|
|
75
|
+
/** Collision filtering: bodies collide when (a.category & b.mask) && (b.category & a.mask). */
|
|
76
|
+
category?: Num;
|
|
77
|
+
mask?: Num;
|
|
78
|
+
/** No rotation (infinite inertia). */
|
|
79
|
+
fixedRotation?: boolean;
|
|
80
|
+
label?: string;
|
|
81
|
+
/** Anything (e.g. a fill colour for your renderer). */
|
|
82
|
+
data?: unknown;
|
|
83
|
+
}
|
|
84
|
+
declare class Body {
|
|
85
|
+
readonly id: number;
|
|
86
|
+
label: string;
|
|
87
|
+
shape: ShapeKind;
|
|
88
|
+
type: 'dynamic' | 'static' | 'kinematic';
|
|
89
|
+
position: Vec2;
|
|
90
|
+
velocity: Vec2;
|
|
91
|
+
angle: Num;
|
|
92
|
+
angularVelocity: Num;
|
|
93
|
+
force: Vec2;
|
|
94
|
+
torque: number;
|
|
95
|
+
radius: number;
|
|
96
|
+
/** Local convex vertices (counter-clockwise) for boxes / polygons. */
|
|
97
|
+
verts: Vec2[];
|
|
98
|
+
normals: Vec2[];
|
|
99
|
+
mass: number;
|
|
100
|
+
invMass: number;
|
|
101
|
+
inertia: number;
|
|
102
|
+
invInertia: number;
|
|
103
|
+
restitution: Num;
|
|
104
|
+
friction: Num;
|
|
105
|
+
damping: Num;
|
|
106
|
+
angularDamping: Num;
|
|
107
|
+
sensor: boolean;
|
|
108
|
+
category: Num;
|
|
109
|
+
mask: Num;
|
|
110
|
+
sleeping: boolean;
|
|
111
|
+
sleepTime: number;
|
|
112
|
+
data: unknown;
|
|
113
|
+
/** Bounding box, refreshed every step. */
|
|
114
|
+
aabb: {
|
|
115
|
+
minX: number;
|
|
116
|
+
minY: number;
|
|
117
|
+
maxX: number;
|
|
118
|
+
maxY: number;
|
|
119
|
+
};
|
|
120
|
+
private wv;
|
|
121
|
+
private wvAngle;
|
|
122
|
+
private wvPos;
|
|
123
|
+
constructor(o?: BodyOptions);
|
|
124
|
+
get isStatic(): boolean;
|
|
125
|
+
/** Vertices in world space (cached per pose). */
|
|
126
|
+
worldVerts(): Vec2[];
|
|
127
|
+
worldNormal(i: Num): Vec2;
|
|
128
|
+
updateAabb(): void;
|
|
129
|
+
applyImpulse(j: Vec2, at?: Vec2): void;
|
|
130
|
+
applyForce(f: Vec2, at?: Vec2): void;
|
|
131
|
+
wake(): void;
|
|
132
|
+
/** Is the world point inside this body? */
|
|
133
|
+
contains(x: Num, y: Num): boolean;
|
|
134
|
+
}
|
|
135
|
+
interface Contact {
|
|
136
|
+
point: Vec2;
|
|
137
|
+
depth: Num;
|
|
138
|
+
}
|
|
139
|
+
interface Manifold {
|
|
140
|
+
a: Body;
|
|
141
|
+
b: Body;
|
|
142
|
+
normal: Vec2;
|
|
143
|
+
contacts: Contact[];
|
|
144
|
+
}
|
|
145
|
+
/** Contact manifold between two bodies (normal points from a to b), or null. */
|
|
146
|
+
declare function collide(a: Body, b: Body): Manifold | null;
|
|
147
|
+
interface ConstraintOptions {
|
|
148
|
+
type: 'distance' | 'pin';
|
|
149
|
+
a: Body;
|
|
150
|
+
/** distance: the other body; pin: omitted. */
|
|
151
|
+
b?: Body;
|
|
152
|
+
/** Anchor on a / b in body-local coordinates (default the centre). */
|
|
153
|
+
anchorA?: [Num, Num];
|
|
154
|
+
anchorB?: [Num, Num];
|
|
155
|
+
/** pin: the world point. */
|
|
156
|
+
point?: [Num, Num];
|
|
157
|
+
/** Rest length (default: the current distance). */
|
|
158
|
+
length?: Num;
|
|
159
|
+
/** 1 = rigid; < 1 = spring (fraction of the error corrected per step). */
|
|
160
|
+
stiffness?: Num;
|
|
161
|
+
/** Spring damping (0–1). */
|
|
162
|
+
damping?: Num;
|
|
163
|
+
label?: string;
|
|
164
|
+
}
|
|
165
|
+
declare class Constraint {
|
|
166
|
+
type: 'distance' | 'pin';
|
|
167
|
+
a: Body;
|
|
168
|
+
b: Body | null;
|
|
169
|
+
anchorA: Vec2;
|
|
170
|
+
anchorB: Vec2;
|
|
171
|
+
point: Vec2;
|
|
172
|
+
length: Num;
|
|
173
|
+
stiffness: Num;
|
|
174
|
+
damping: Num;
|
|
175
|
+
label: string;
|
|
176
|
+
constructor(o: ConstraintOptions);
|
|
177
|
+
worldA(): Vec2;
|
|
178
|
+
worldB(): Vec2;
|
|
179
|
+
/** One velocity iteration (impulse along the constraint axis, with a position bias). */
|
|
180
|
+
solve(h: Num): void;
|
|
181
|
+
}
|
|
182
|
+
interface WorldOptions {
|
|
183
|
+
gravity?: [Num, Num];
|
|
184
|
+
/** Velocity iterations per step (default 10). */
|
|
185
|
+
iterations?: Num;
|
|
186
|
+
/** Fixed step in seconds (default 1/60). */
|
|
187
|
+
step?: Num;
|
|
188
|
+
/** Let resting bodies sleep (default true). */
|
|
189
|
+
sleeping?: boolean;
|
|
190
|
+
}
|
|
191
|
+
type CollisionListener = (m: Manifold) => void;
|
|
192
|
+
declare class World {
|
|
193
|
+
gravity: Vec2;
|
|
194
|
+
iterations: Num;
|
|
195
|
+
fixedStep: Num;
|
|
196
|
+
sleeping: boolean;
|
|
197
|
+
bodies: Body[];
|
|
198
|
+
constraints: Constraint[];
|
|
199
|
+
/** Manifolds of the last step (incl. sensor overlaps, which have no response). */
|
|
200
|
+
contacts: Manifold[];
|
|
201
|
+
time: number;
|
|
202
|
+
steps: number;
|
|
203
|
+
private acc;
|
|
204
|
+
private warm;
|
|
205
|
+
private listeners;
|
|
206
|
+
private stop;
|
|
207
|
+
constructor(o?: WorldOptions);
|
|
208
|
+
add<T extends Body | Constraint>(...items: T[]): T;
|
|
209
|
+
body(o: BodyOptions): Body;
|
|
210
|
+
constraint(o: ConstraintOptions): Constraint;
|
|
211
|
+
remove(...items: (Body | Constraint)[]): void;
|
|
212
|
+
clear(): void;
|
|
213
|
+
/** Static walls around a w × h box (thickness t outside it). */
|
|
214
|
+
bounds(w: Num, h: Num, t?: number, o?: {
|
|
215
|
+
top?: boolean;
|
|
216
|
+
}): Body[];
|
|
217
|
+
onCollision(fn: CollisionListener): () => void;
|
|
218
|
+
/** Bodies under a world point (topmost = last added first). */
|
|
219
|
+
query(x: Num, y: Num): Body[];
|
|
220
|
+
/** Advance by `seconds` of real time in fixed steps (max 8 steps per call). */
|
|
221
|
+
update(seconds: Num): Num;
|
|
222
|
+
/** One fixed step of h seconds. */
|
|
223
|
+
step(h?: Num): void;
|
|
224
|
+
/** Drive the world from the shared runtime ticker (needs the core). Returns a stopper. */
|
|
225
|
+
run(): () => void;
|
|
226
|
+
get running(): boolean;
|
|
227
|
+
/** Total kinetic energy (handy for tests / "settled" checks). */
|
|
228
|
+
energy(): Num;
|
|
229
|
+
}
|
|
230
|
+
/** A world (also registers nothing — pure). */
|
|
231
|
+
declare function createWorld(o?: WorldOptions): World;
|
|
232
|
+
/** Pointer dragging: a soft pin from a body point to a moving world point. */
|
|
233
|
+
declare function dragConstraint(world: World, body: Body, x: Num, y: Num, stiffness?: number): {
|
|
234
|
+
move(x: Num, y: Num): void;
|
|
235
|
+
release(): void;
|
|
236
|
+
constraint: Constraint;
|
|
237
|
+
};
|
|
238
|
+
interface PhysicsApi {
|
|
239
|
+
createWorld: typeof createWorld;
|
|
240
|
+
World: typeof World;
|
|
241
|
+
Body: typeof Body;
|
|
242
|
+
Constraint: typeof Constraint;
|
|
243
|
+
collide: typeof collide;
|
|
244
|
+
dragConstraint: typeof dragConstraint;
|
|
245
|
+
}
|
|
246
|
+
/** The module object for `use(physics)`. */
|
|
247
|
+
declare const physics: RuntimeModule<PhysicsApi>;
|
|
248
|
+
|
|
249
|
+
export { Body, Constraint, World, collide, createWorld, dragConstraint, physics };
|
|
250
|
+
export type { BodyOptions, CollisionListener, ConstraintOptions, Contact, Manifold, PhysicsApi, ShapeKind, Vec2, WorldOptions };
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/** A runtime module: `{ id, version, api }`, registered with `use()`. */
|
|
2
|
+
interface RuntimeModule<A = unknown> {
|
|
3
|
+
/** Module id: 'core', 'format-css', 'scroll', … (import path `motionary/runtime/<id>`). */
|
|
4
|
+
id: string;
|
|
5
|
+
version: string;
|
|
6
|
+
/** Other modules this one needs (registered first by `use()` callers). */
|
|
7
|
+
requires?: string[];
|
|
8
|
+
/** The module's public API (what `requireModule(id)` returns). */
|
|
9
|
+
api: A;
|
|
10
|
+
/** Optional one-time setup, called on first registration. */
|
|
11
|
+
setup?(registry: RuntimeRegistry): void;
|
|
12
|
+
}
|
|
13
|
+
interface RuntimeRegistry {
|
|
14
|
+
version: string;
|
|
15
|
+
modules: Map<string, RuntimeModule>;
|
|
16
|
+
/** Shared per-page state slots (the ticker lives here). */
|
|
17
|
+
slots: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* `motionary/runtime/physics` (10.7) — a small 2D rigid-body engine written
|
|
22
|
+
* for Motionary (own implementation and API; no Matter.js / Box2D code):
|
|
23
|
+
*
|
|
24
|
+
* - bodies: circles, boxes and convex polygons (static, dynamic or
|
|
25
|
+
* kinematic), density → mass + moment of inertia, restitution, friction,
|
|
26
|
+
* sensors, collision groups / masks, sleeping;
|
|
27
|
+
* - collisions: sort-and-sweep broad phase, separating-axis narrow phase
|
|
28
|
+
* with clipped contact manifolds (up to 2 points), sequential, accumulated and
|
|
29
|
+
* clamped impulses (normal + Coulomb friction) with a Baumgarte position bias;
|
|
30
|
+
* - constraints: `distance` (rigid or a spring with `stiffness` /
|
|
31
|
+
* `damping`), `pin` (a body point to a world point — also the pointer
|
|
32
|
+
* drag constraint) and `weld`-like stiff distance pairs;
|
|
33
|
+
* - a fixed time step (default 1/60 s) with an accumulator, so results are
|
|
34
|
+
* the same at any frame rate; `world.run()` drives it from the shared
|
|
35
|
+
* runtime ticker (pauses while the ticker sleeps).
|
|
36
|
+
*
|
|
37
|
+
* Pure maths — no DOM: safe in SSR and workers. Units are up to you (the
|
|
38
|
+
* defaults assume pixels: gravity 980 px/s²).
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
type Num = number;
|
|
42
|
+
interface Vec2 {
|
|
43
|
+
x: Num;
|
|
44
|
+
y: Num;
|
|
45
|
+
}
|
|
46
|
+
type ShapeKind = 'circle' | 'box' | 'polygon';
|
|
47
|
+
interface BodyOptions {
|
|
48
|
+
shape?: ShapeKind;
|
|
49
|
+
x?: Num;
|
|
50
|
+
y?: Num;
|
|
51
|
+
angle?: Num;
|
|
52
|
+
/** circle */
|
|
53
|
+
radius?: Num;
|
|
54
|
+
/** box */
|
|
55
|
+
width?: Num;
|
|
56
|
+
height?: Num;
|
|
57
|
+
/** polygon: local vertices (any winding; made convex-ccw) */
|
|
58
|
+
vertices?: [Num, Num][];
|
|
59
|
+
/** 'dynamic' (default), 'static' (never moves) or 'kinematic' (moves by its velocity, ignores forces / collisions). */
|
|
60
|
+
type?: 'dynamic' | 'static' | 'kinematic';
|
|
61
|
+
/** Mass per unit area (default 0.001 → a 40 px box weighs 1.6). */
|
|
62
|
+
density?: Num;
|
|
63
|
+
/** Overrides density. */
|
|
64
|
+
mass?: Num;
|
|
65
|
+
restitution?: Num;
|
|
66
|
+
friction?: Num;
|
|
67
|
+
vx?: Num;
|
|
68
|
+
vy?: Num;
|
|
69
|
+
angularVelocity?: Num;
|
|
70
|
+
/** Linear / angular damping per second (0–1). */
|
|
71
|
+
damping?: Num;
|
|
72
|
+
angularDamping?: Num;
|
|
73
|
+
/** Collides with nothing, reports overlaps only. */
|
|
74
|
+
sensor?: boolean;
|
|
75
|
+
/** Collision filtering: bodies collide when (a.category & b.mask) && (b.category & a.mask). */
|
|
76
|
+
category?: Num;
|
|
77
|
+
mask?: Num;
|
|
78
|
+
/** No rotation (infinite inertia). */
|
|
79
|
+
fixedRotation?: boolean;
|
|
80
|
+
label?: string;
|
|
81
|
+
/** Anything (e.g. a fill colour for your renderer). */
|
|
82
|
+
data?: unknown;
|
|
83
|
+
}
|
|
84
|
+
declare class Body {
|
|
85
|
+
readonly id: number;
|
|
86
|
+
label: string;
|
|
87
|
+
shape: ShapeKind;
|
|
88
|
+
type: 'dynamic' | 'static' | 'kinematic';
|
|
89
|
+
position: Vec2;
|
|
90
|
+
velocity: Vec2;
|
|
91
|
+
angle: Num;
|
|
92
|
+
angularVelocity: Num;
|
|
93
|
+
force: Vec2;
|
|
94
|
+
torque: number;
|
|
95
|
+
radius: number;
|
|
96
|
+
/** Local convex vertices (counter-clockwise) for boxes / polygons. */
|
|
97
|
+
verts: Vec2[];
|
|
98
|
+
normals: Vec2[];
|
|
99
|
+
mass: number;
|
|
100
|
+
invMass: number;
|
|
101
|
+
inertia: number;
|
|
102
|
+
invInertia: number;
|
|
103
|
+
restitution: Num;
|
|
104
|
+
friction: Num;
|
|
105
|
+
damping: Num;
|
|
106
|
+
angularDamping: Num;
|
|
107
|
+
sensor: boolean;
|
|
108
|
+
category: Num;
|
|
109
|
+
mask: Num;
|
|
110
|
+
sleeping: boolean;
|
|
111
|
+
sleepTime: number;
|
|
112
|
+
data: unknown;
|
|
113
|
+
/** Bounding box, refreshed every step. */
|
|
114
|
+
aabb: {
|
|
115
|
+
minX: number;
|
|
116
|
+
minY: number;
|
|
117
|
+
maxX: number;
|
|
118
|
+
maxY: number;
|
|
119
|
+
};
|
|
120
|
+
private wv;
|
|
121
|
+
private wvAngle;
|
|
122
|
+
private wvPos;
|
|
123
|
+
constructor(o?: BodyOptions);
|
|
124
|
+
get isStatic(): boolean;
|
|
125
|
+
/** Vertices in world space (cached per pose). */
|
|
126
|
+
worldVerts(): Vec2[];
|
|
127
|
+
worldNormal(i: Num): Vec2;
|
|
128
|
+
updateAabb(): void;
|
|
129
|
+
applyImpulse(j: Vec2, at?: Vec2): void;
|
|
130
|
+
applyForce(f: Vec2, at?: Vec2): void;
|
|
131
|
+
wake(): void;
|
|
132
|
+
/** Is the world point inside this body? */
|
|
133
|
+
contains(x: Num, y: Num): boolean;
|
|
134
|
+
}
|
|
135
|
+
interface Contact {
|
|
136
|
+
point: Vec2;
|
|
137
|
+
depth: Num;
|
|
138
|
+
}
|
|
139
|
+
interface Manifold {
|
|
140
|
+
a: Body;
|
|
141
|
+
b: Body;
|
|
142
|
+
normal: Vec2;
|
|
143
|
+
contacts: Contact[];
|
|
144
|
+
}
|
|
145
|
+
/** Contact manifold between two bodies (normal points from a to b), or null. */
|
|
146
|
+
declare function collide(a: Body, b: Body): Manifold | null;
|
|
147
|
+
interface ConstraintOptions {
|
|
148
|
+
type: 'distance' | 'pin';
|
|
149
|
+
a: Body;
|
|
150
|
+
/** distance: the other body; pin: omitted. */
|
|
151
|
+
b?: Body;
|
|
152
|
+
/** Anchor on a / b in body-local coordinates (default the centre). */
|
|
153
|
+
anchorA?: [Num, Num];
|
|
154
|
+
anchorB?: [Num, Num];
|
|
155
|
+
/** pin: the world point. */
|
|
156
|
+
point?: [Num, Num];
|
|
157
|
+
/** Rest length (default: the current distance). */
|
|
158
|
+
length?: Num;
|
|
159
|
+
/** 1 = rigid; < 1 = spring (fraction of the error corrected per step). */
|
|
160
|
+
stiffness?: Num;
|
|
161
|
+
/** Spring damping (0–1). */
|
|
162
|
+
damping?: Num;
|
|
163
|
+
label?: string;
|
|
164
|
+
}
|
|
165
|
+
declare class Constraint {
|
|
166
|
+
type: 'distance' | 'pin';
|
|
167
|
+
a: Body;
|
|
168
|
+
b: Body | null;
|
|
169
|
+
anchorA: Vec2;
|
|
170
|
+
anchorB: Vec2;
|
|
171
|
+
point: Vec2;
|
|
172
|
+
length: Num;
|
|
173
|
+
stiffness: Num;
|
|
174
|
+
damping: Num;
|
|
175
|
+
label: string;
|
|
176
|
+
constructor(o: ConstraintOptions);
|
|
177
|
+
worldA(): Vec2;
|
|
178
|
+
worldB(): Vec2;
|
|
179
|
+
/** One velocity iteration (impulse along the constraint axis, with a position bias). */
|
|
180
|
+
solve(h: Num): void;
|
|
181
|
+
}
|
|
182
|
+
interface WorldOptions {
|
|
183
|
+
gravity?: [Num, Num];
|
|
184
|
+
/** Velocity iterations per step (default 10). */
|
|
185
|
+
iterations?: Num;
|
|
186
|
+
/** Fixed step in seconds (default 1/60). */
|
|
187
|
+
step?: Num;
|
|
188
|
+
/** Let resting bodies sleep (default true). */
|
|
189
|
+
sleeping?: boolean;
|
|
190
|
+
}
|
|
191
|
+
type CollisionListener = (m: Manifold) => void;
|
|
192
|
+
declare class World {
|
|
193
|
+
gravity: Vec2;
|
|
194
|
+
iterations: Num;
|
|
195
|
+
fixedStep: Num;
|
|
196
|
+
sleeping: boolean;
|
|
197
|
+
bodies: Body[];
|
|
198
|
+
constraints: Constraint[];
|
|
199
|
+
/** Manifolds of the last step (incl. sensor overlaps, which have no response). */
|
|
200
|
+
contacts: Manifold[];
|
|
201
|
+
time: number;
|
|
202
|
+
steps: number;
|
|
203
|
+
private acc;
|
|
204
|
+
private warm;
|
|
205
|
+
private listeners;
|
|
206
|
+
private stop;
|
|
207
|
+
constructor(o?: WorldOptions);
|
|
208
|
+
add<T extends Body | Constraint>(...items: T[]): T;
|
|
209
|
+
body(o: BodyOptions): Body;
|
|
210
|
+
constraint(o: ConstraintOptions): Constraint;
|
|
211
|
+
remove(...items: (Body | Constraint)[]): void;
|
|
212
|
+
clear(): void;
|
|
213
|
+
/** Static walls around a w × h box (thickness t outside it). */
|
|
214
|
+
bounds(w: Num, h: Num, t?: number, o?: {
|
|
215
|
+
top?: boolean;
|
|
216
|
+
}): Body[];
|
|
217
|
+
onCollision(fn: CollisionListener): () => void;
|
|
218
|
+
/** Bodies under a world point (topmost = last added first). */
|
|
219
|
+
query(x: Num, y: Num): Body[];
|
|
220
|
+
/** Advance by `seconds` of real time in fixed steps (max 8 steps per call). */
|
|
221
|
+
update(seconds: Num): Num;
|
|
222
|
+
/** One fixed step of h seconds. */
|
|
223
|
+
step(h?: Num): void;
|
|
224
|
+
/** Drive the world from the shared runtime ticker (needs the core). Returns a stopper. */
|
|
225
|
+
run(): () => void;
|
|
226
|
+
get running(): boolean;
|
|
227
|
+
/** Total kinetic energy (handy for tests / "settled" checks). */
|
|
228
|
+
energy(): Num;
|
|
229
|
+
}
|
|
230
|
+
/** A world (also registers nothing — pure). */
|
|
231
|
+
declare function createWorld(o?: WorldOptions): World;
|
|
232
|
+
/** Pointer dragging: a soft pin from a body point to a moving world point. */
|
|
233
|
+
declare function dragConstraint(world: World, body: Body, x: Num, y: Num, stiffness?: number): {
|
|
234
|
+
move(x: Num, y: Num): void;
|
|
235
|
+
release(): void;
|
|
236
|
+
constraint: Constraint;
|
|
237
|
+
};
|
|
238
|
+
interface PhysicsApi {
|
|
239
|
+
createWorld: typeof createWorld;
|
|
240
|
+
World: typeof World;
|
|
241
|
+
Body: typeof Body;
|
|
242
|
+
Constraint: typeof Constraint;
|
|
243
|
+
collide: typeof collide;
|
|
244
|
+
dragConstraint: typeof dragConstraint;
|
|
245
|
+
}
|
|
246
|
+
/** The module object for `use(physics)`. */
|
|
247
|
+
declare const physics: RuntimeModule<PhysicsApi>;
|
|
248
|
+
|
|
249
|
+
export { Body, Constraint, World, collide, createWorld, dragConstraint, physics };
|
|
250
|
+
export type { BodyOptions, CollisionListener, ConstraintOptions, Contact, Manifold, PhysicsApi, ShapeKind, Vec2, WorldOptions };
|