{"id":34613467,"url":"https://github.com/codeagent/rb-phys2d","last_synced_at":"2026-04-17T19:03:29.808Z","repository":{"id":46360410,"uuid":"357688512","full_name":"codeagent/rb-phys2d","owner":"codeagent","description":"JavaScript and Typescript rigid body 2d physics engine primarily devised to create complex scenes involved various types of joints and shapes.","archived":false,"fork":false,"pushed_at":"2023-03-22T20:42:57.000Z","size":1606,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-26T03:10:37.364Z","etag":null,"topics":["javascript","physics-2d","physics-simulation","rigid-body-dynamics","typescript"],"latest_commit_sha":null,"homepage":"https://rb-phys2d.stackblitz.io/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codeagent.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-04-13T21:05:27.000Z","updated_at":"2023-02-21T07:41:30.000Z","dependencies_parsed_at":"2022-07-19T22:32:47.874Z","dependency_job_id":"e025eab9-f1df-426f-954f-cbba36e8583b","html_url":"https://github.com/codeagent/rb-phys2d","commit_stats":{"total_commits":271,"total_committers":1,"mean_commits":271.0,"dds":0.0,"last_synced_commit":"eb8881772bd5027582baf592ef754ec83854a1a9"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/codeagent/rb-phys2d","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeagent%2Frb-phys2d","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeagent%2Frb-phys2d/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeagent%2Frb-phys2d/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeagent%2Frb-phys2d/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeagent","download_url":"https://codeload.github.com/codeagent/rb-phys2d/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeagent%2Frb-phys2d/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31941845,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-17T17:29:20.459Z","status":"ssl_error","status_checked_at":"2026-04-17T17:28:47.801Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["javascript","physics-2d","physics-simulation","rigid-body-dynamics","typescript"],"created_at":"2025-12-24T14:18:47.274Z","updated_at":"2026-04-17T19:03:29.803Z","avatar_url":"https://github.com/codeagent.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CI](https://github.com/codeagent/rb-phys2d/actions/workflows/ci.yml/badge.svg)](https://github.com/codeagent/rb-phys2d/actions/workflows/ci.yml)\n[![npm version](https://badge.fury.io/js/rb-phys2d.svg)](https://badge.fury.io/js/rb-phys2d)\n\n# RbPhys2D\n\nJavaScript and Typescript rigid body 2d physics engine primarily devised to create complex scenes involved various types of joints and shapes.\n\n[Examples](https://rb-phys2d.stackblitz.io/)\n\n## Features\n\n- `Circle`, `Box`, `Ellipse`, `Capsule`, `Polygon`\n- Continuous Collision Detection (only between convex shapes yet)\n- Concave `Mesh Shape`\n- Lifecycle `Events`\n- `Distance`, `Prismatic`, `Revolute`, `Weld`, `Wheel`, `Spring`, `Mouse`, `Motor` Joints\n- Physical Material Features: `Restitution`, `Friction`, `Damping`\n- Bodies `Sleeping`\n- World `Islands`\n- [Force-Based Constraint Solver](http://www.mft-spirit.nl/files/MTamis_ConstraintBasedPhysicsSolver.pdf)\n\n## Installation\n\nUsing `npm` package manager:\n\n```bash\nnpm install rb-phys2d\n```\n\n## Getting started\n\n### ESM\n\n1. Install additional npm package for drawing world onto canvas element:\n\n```bash\nnpm install rb-phys2d-renderer\n```\n\n2. Create world:\n\n```typescript\n// gl-matrix is nessesary for vector/matrix operations\nimport { vec2 } from 'gl-matrix';\n// include Box shape and world factory\nimport { Box, createWorld } from \"rb-phys2d\";\n// stuff for rendering and interacting with world through canvas\nimport { createViewport, createWorldRenderer } from \"rb-phys2d-renderer\";\n\n// world is main entry point for almost all api\nconst world = createWorld({ ... })\n\n```\n\n3. Fill world with bodies:\n\n```typescript\n// create static floor\nconst floor = world.createBody({\n  position: vec2.fromValues(0, -5),\n  mass: Number.POSITIVE_INFINITY,\n  inertia: Number.POSITIVE_INFINITY,\n});\nworld.addCollider({ shape: new Box(10, 2), body: floor });\n\n// create dynamic box\nconst box = world.createBody({ mass: 1 });\nworld.addCollider({ shape: new Box(1, 1), body: box });\n```\n\n4. Create viewport and promote world through main loop:\n\n```typescript\nconst canvas = document.getElementById('canvas');\n\nconst viewport = createViewport(canvas)\n  .addMousePickingControl(world)\n  .addViewportAdjustingControl();\n\nconst renderer = createWorldRenderer(viewport, world);\n\n// it is frame duration in seconds\nconst dt = 0.0167;\n\nconst step = () =\u003e {\n  // world simulation starts here\n  world.step(dt);\n\n  // here all rendering happen\n  renderer.clear();\n  renderer.render();\n\n  requestAnimationFrame(step);\n};\n\nrequestAnimationFrame(step);\n```\n\nSee full source code and life demo [here](https://stackblitz.com/edit/rb-phys2d-getting-started?file=index.ts).\n\n### Browser\n\n1. Include necessary bundles into html page\n\n```html\n\u003cscript src=\"./node_modules/gl-matrix/gl-matrix.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"./node_modules/rb-phys2d/dist/bundle/rb-phys2d.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"./node_modules/rb-phys2d-renderer/dist/bundle/rb-phys2d-renderer.js\"\u003e\u003c/script\u003e\n```\n\n2. Use the global accessible objects `rbPhys2d` and `rbPhys2dRenderer` to get access to api.\n\n## Extensions And Plugins\n\n- [rb-phys2d-renderer](https://github.com/codeagent/rb-phys2d-renderer) for world rendering, mouse picking and viewport adjusting\n- [rb-phys2d-threaded](https://github.com/codeagent/rb-phys2d-threaded) for launching `rb-phys2d` in dedicated WebWorker\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first\nto discuss what you would like to change.\n\nPlease make sure to update tests as appropriate.\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeagent%2Frb-phys2d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeagent%2Frb-phys2d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeagent%2Frb-phys2d/lists"}