{"id":21612455,"url":"https://github.com/altanis/kinetics","last_synced_at":"2025-05-07T15:07:36.015Z","repository":{"id":177924003,"uuid":"616192391","full_name":"Altanis/kinetics","owner":"Altanis","description":"A blazingly fast physics engine for both servers and the web, written in TypeScript 🔥","archived":false,"fork":false,"pushed_at":"2024-08-11T19:31:03.000Z","size":1548,"stargazers_count":199,"open_issues_count":1,"forks_count":6,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-05-07T15:07:00.490Z","etag":null,"topics":["newtonian-mechanics","physics-2d","physics-engine"],"latest_commit_sha":null,"homepage":"https://kinetics.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Altanis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-19T21:34:44.000Z","updated_at":"2025-05-05T13:15:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"6d9f123e-9175-4260-8e52-d6035d5c578e","html_url":"https://github.com/Altanis/kinetics","commit_stats":null,"previous_names":["altanis/kinetics-ts","altanis/kinetics"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Altanis%2Fkinetics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Altanis%2Fkinetics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Altanis%2Fkinetics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Altanis%2Fkinetics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Altanis","download_url":"https://codeload.github.com/Altanis/kinetics/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252902614,"owners_count":21822261,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["newtonian-mechanics","physics-2d","physics-engine"],"created_at":"2024-11-24T21:20:40.190Z","updated_at":"2025-05-07T15:07:35.984Z","avatar_url":"https://github.com/Altanis.png","language":"TypeScript","readme":"\u003c!-- ![image](https://github.com/Altanis/kinetics-ts/assets/38045884/f9985f30-5d88-48bc-89ca-1b917369665f) --\u003e\r\n![image](https://github.com/Altanis/kinetics-ts/blob/main/img/kinetics.jpeg?raw=true)\r\n\u003csub\u003eCredits to SimplyTav for creating this logo.\u003c/sub\u003e\r\n\r\n# About\r\nA blazingly fast, simple 2D physics engine for JavaScript and TypeScript, for both frontend and backend applications.\r\n\r\n## Features\r\n- System/Entity Architecture Support\r\n- Built-in Canvas2D Renderer\r\n- Fast Narrowphase Collision Detection\r\n- Fast Broadphase Collision Detection\r\n- Fast Collision Resolution\r\n- Collision Callbacks\r\n\r\n## Roadmap\r\n- [ ] Custom Forces\r\n- [ ] Make physics more realistic\r\n- [ ] Joints\r\n- [ ] Concave Hulls\r\n- [ ] API Rehaul\r\n\r\n## Usage\r\n```js\r\n/** Create a system with 100 circles. */\r\nconst { System, Circle, Vector } = require(\"kinetics.ts\");\r\n\r\nconst system = new System({\r\n    tickRate: 60,\r\n    friction: 0.1,\r\n    collisionInfo: {\r\n        cellSize: 6,\r\n    },\r\n    bounds: new Vector(1920, 1080)\r\n});\r\n\r\nfor (let i = 0; i \u003c 100; i++) {\r\n    const radius = 10;\r\n\r\n    const entity = new Circle(\r\n        {\r\n            form: {\r\n                vertices: [new Vector(0, 0)],\r\n            },\r\n            radius,\r\n            mass: 10,\r\n            speed: 1,\r\n            rotate: false,\r\n            elasticity: 1,\r\n            angularSpeed: 1,\r\n        },\r\n        system\r\n    );\r\n    system.addEntity(entity);\r\n}\r\n\r\n/** The number of ticks the engine will run per second. */\r\nconst FPS = 60;\r\n/** The ideal time it will take for one system update. */\r\nconst MSPT = 1000 / FPS;\r\n\r\n/** The timestamp of the last engine update. */\r\nlet lastTimestamp = 0;\r\n\r\nsetInterval(() =\u003e {\r\n    let currentTime = performance.now();\r\n    let deltaTime = currentTime - lastTimestamp; // time in between two ticks\r\n    lastTimestamp = currentTime;\r\n\r\n    // `dt` is a sort of error correction mechanism.\r\n    // In the event the interval doesn't run at the specified\r\n    // MSPT, `dt` corrects all time variant operations by scaling\r\n    // them by its value.\r\n    const dt = Math.min((deltaTime / MSPT), 3);\r\n\r\n    system.update(dt);\r\n}, MSPT);\r\n```\r\n\r\n## Installation\r\n\r\nTo install this package on a server or a web framework, use the following command:\r\n\r\n```bash\r\nnpm install kinetics.ts\r\n```\r\n\r\nFor a vanilla HTML/CSS/JS project, use the following script tag:\r\n\r\n```html\r\n\u003cscript src=\"https://cdn.jsdelivr.net/gh/Altanis/kinetics-ts@latest/build/kinetics.min.js\" defer\u003e\u003c/script\u003e\r\n```\r\n\r\nand all of the engine's classes will be available under the `Kinetics` namespace (`window.Kinetics.System`, `window.Kinetics.Entity`, etc.).\r\n\r\n## Benchmarks\r\nA 1920x1080 rectangular system of 1,000 entities was benchmarked, where each entity had a radius randomly selected between 3 and 13. Entity sleeping was disabled for each benchmark.\r\n\r\nSystem Specifications:\r\n- Apple M2 chip\r\n- 8-core CPU with 4 performance cores and 4 efficiency cores\r\n- 8-core GPU\r\n- 16-core Neural Engine\r\n- 100GB/s memory bandwidth\r\n\r\n\u003cimg width=\"870\" alt=\"image\" src=\"https://github.com/Altanis/kinetics-ts/blob/main/img/bench.png?raw=true\"\u003e\r\n\r\nThe benchmarks provide evidence of the engine's exceptional speed and performance in comparison to other alternatives.\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faltanis%2Fkinetics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faltanis%2Fkinetics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faltanis%2Fkinetics/lists"}