{"id":22120192,"url":"https://github.com/joshbrew/physics_test","last_synced_at":"2025-03-24T06:27:00.293Z","repository":{"id":65453748,"uuid":"591242800","full_name":"joshbrew/physics_test","owner":"joshbrew","description":"Rapier3D + BablyonJS test","archived":false,"fork":false,"pushed_at":"2024-02-19T20:47:46.000Z","size":3984,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-29T12:14:54.445Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joshbrew.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-20T09:19:35.000Z","updated_at":"2024-02-19T05:46:38.000Z","dependencies_parsed_at":"2023-02-13T19:15:26.917Z","dependency_job_id":"44c7b316-14a6-459c-a40c-44bd89dc4401","html_url":"https://github.com/joshbrew/physics_test","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshbrew%2Fphysics_test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshbrew%2Fphysics_test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshbrew%2Fphysics_test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshbrew%2Fphysics_test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joshbrew","download_url":"https://codeload.github.com/joshbrew/physics_test/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245220105,"owners_count":20579704,"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":[],"created_at":"2024-12-01T14:21:23.818Z","updated_at":"2025-03-24T06:27:00.265Z","avatar_url":"https://github.com/joshbrew.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# physics_test\nRapier3D + BablyonJS test\n\n[Live Demo](https://babylonrapiertest.netlify.app) (do a performance capture to see, note we aren't using instanced meshes yet so increasing geometry count may significantly impact fps)\n\n\u003cimg width=\"311\" alt=\"Capture\" src=\"https://github.com/joshbrew/physics_test/assets/18196383/6a4b30a1-d261-4b38-a4b0-a10109b234fd\"\u003e\n\n\nBabylonJS for rendering. Rapier3D for scene collision and scripting interactions. All entities are physics-based and update the render thread.\n\nPhysics thread relays through a crowd navigation and dynamic nav mesh thread to enable AI behaviors.\n\nBabylonJS thread handles only the render updating while positions and states etc. are determined by the AI and physics threads. \n\nMain thread just passes user inputs to babylonjs to update the render with simple vector calc.\n\n### To run:\n\nFirst ensure the navmesh worker is built with with `npm start`\n\nThen after you can just do:\n\n`tinybuild`\n\n`npm i -g tinybuild \u0026 tinybuild` if you don't have [tinybuild](https://github.com/brainsatplay/tinybuild) installed.\n\n### About\nRapier3D: fancy Rust -\u003e JS WASM physics engine, it's faster than anything else free.\n\nBenchmarks: https://www.dimforge.com/blog/2020/08/25/announcing-the-rapier-physics-engine/\n\nBabylonJS: fancy JS rendering engine, including lots of extras. Little fatter than ThreeJS but heavier on game engine features.\n\nThe app with BabylonJS is about 6.1MB in size in our current bundler settings, not sure why it's so huge.\n\nWith ThreeJS the app is about 2MB, so the physics engine itself is \u003c1MB bundled, since Three comes out to about 1MB by itself. Pretty freakin small though.\n\n### TODO\n\n- Proper AI controls e.g. targeting, snappier impulses\n    -- independent targeting, states, etc (easy shit)\n    -- Use boid grouping behaviors for idle state, cast each AI on init to group the boids within their visible boundaries. Casting = Project a sphere in rapier3d to determine overlaps within a specific radius, then raycast to each overlapping entity to determine if they are in line-of-sight.\n\n- Make obstacle course to run through and avoid the AI\n- Raycast activation for AI based on player visibility (cast from the player to keep this efficient)\n- Figure out if BabylonJS has any bulk lighting solution e.g. global illumination.\n\n\n### Benchmark\n\n![benchmark](./benchmark.png)\n\nBaseline performance is on the order of microseconds. This is just with two crowd entities, a player, a number of other physics objects, and a single light source.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshbrew%2Fphysics_test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoshbrew%2Fphysics_test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshbrew%2Fphysics_test/lists"}