{"id":30872583,"url":"https://github.com/matsuoka-601/floaty","last_synced_at":"2025-09-07T22:33:24.576Z","repository":{"id":309212645,"uuid":"1034184979","full_name":"matsuoka-601/Floaty","owner":"matsuoka-601","description":"2D fluid \u0026 soft body simulation based on Position Based Dynamics","archived":false,"fork":false,"pushed_at":"2025-08-24T07:21:36.000Z","size":13904,"stargazers_count":29,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-24T14:14:40.136Z","etag":null,"topics":["fluid","parallel","pbd","simulation","softbody","wasm"],"latest_commit_sha":null,"homepage":"https://floaty-fluid.netlify.app/","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/matsuoka-601.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,"zenodo":null}},"created_at":"2025-08-08T01:51:39.000Z","updated_at":"2025-08-24T07:21:39.000Z","dependencies_parsed_at":"2025-08-10T16:38:17.906Z","dependency_job_id":null,"html_url":"https://github.com/matsuoka-601/Floaty","commit_stats":null,"previous_names":["matsuoka-601/floaty"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/matsuoka-601/Floaty","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matsuoka-601%2FFloaty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matsuoka-601%2FFloaty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matsuoka-601%2FFloaty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matsuoka-601%2FFloaty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matsuoka-601","download_url":"https://codeload.github.com/matsuoka-601/Floaty/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matsuoka-601%2FFloaty/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274107089,"owners_count":25223442,"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","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["fluid","parallel","pbd","simulation","softbody","wasm"],"created_at":"2025-09-07T22:07:00.172Z","updated_at":"2025-09-07T22:33:24.538Z","avatar_url":"https://github.com/matsuoka-601.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Floaty\nSoft body \u0026 fluid simulation based on Position Based Dynamics (PBD). \n\n![demo](img/demo.gif)\n\n[Try Demo Here!](https://floaty-fluid.netlify.app)\n\n- **[Position Based Dynamics (PBD)](https://matthias-research.github.io/pages/publications/posBasedDyn.pdf) and [Position Based Fluids (PBF)](https://mmacklin.com/pbf_sig_preprint.pdf)** is used for simulating soft bodies and fluid.\n- **For two-way coupling of soft body and fluid simulation**, a method described in [Unified Particle Physics for Real-Time Applications](https://mmacklin.com/uppfrta_preprint.pdf) is used. \n    - **Buoyancy is naturally simulated** thanks to this paper.\n- The simulation is **accelerated with multithreading using [wasm-bindgen-rayon](https://github.com/RReverser/wasm-bindgen-rayon)**.\n\n## How to run\n```\nnpm install\nnpm run build\nnpm run dev\n```\nIf you have trouble running the repo, feel free to open an issue.\n## Demo Video\n[![alt設定](http://img.youtube.com/vi/lzzW41bLtIo/0.jpg)](https://www.youtube.com/watch?v=lzzW41bLtIo)\n## Overview of The Simulation\n### Soft Bodies\nSoft bodies are simulated using [distance constraint](https://github.com/matsuoka-601/PBDRust/blob/f6eacb716e3d9488d0906437ac7badc4df9f14a1/solver.ts#L9) and [area constraint](https://github.com/matsuoka-601/PBDRust/blob/f6eacb716e3d9488d0906437ac7badc4df9f14a1/solver.ts#L46). \n\nDistance constraints limit adjacent particles of each soft body from moving too far apart or too close together. And area constraints limit the movement of particles so that soft bodies do not collapse.\n\nFor more detail, reading section 3.3 (Constraint Projection) and 4.4 (Cloth Balloons) in the original PBD paper would help.\n### Fluid\nThe simulation of fluid is based on [Position Based Fluids](https://mmacklin.com/pbf_sig_preprint.pdf). That is, $i$ th fluid particle is constrained to satisfy the following density constraint（ $\\rho_0$ is the target density and $\\rho_i$ is the density of $i$ th particle）.\n\n$$\n    C_i(\\boldsymbol{p}_1,\\dots, \\boldsymbol{p}_n) = \\frac{\\rho_i}{\\rho_0}-1=0\n$$\n\nMy initial implementation is based on [the one by Matthias Müller](https://github.com/matthias-research/pages/blob/master/challenges/fluid2d.html). \n\nTo simulate surface tension, [cohesion and curvature term is used](https://github.com/matsuoka-601/PBDRust/blob/ee13d82bf866fcea8be5faf9e5fdbc9db9085f41/src/lib.rs#L303), which is described in [Versatile Surface Tension and Adhesion for SPH Fluids](https://cg.informatik.uni-freiburg.de/publications/2013_SIGGRAPHASIA_surfaceTensionAdhesion.pdf) by Akinci et al.\n### Two-Way Coupling of Fluid and Soft Bodies\nFollowing the framework described in [Unified Particle Physics for Real-Time Applications](https://mmacklin.com/uppfrta_preprint.pdf), two-way coupling of fluid and soft bodies can be naturally simulated.\n\nIn PBF calculations, fluid particles and soft body particles are treated in almost the same way. Buoyancy is automatically achieved using the mass weighted version of PBD (Eq. (4) and (5) in the paper).\n## Some Tricks to Stabilize the Simulation\n### Prevent Soft Bodies from Get Entangling\nThe softbodies can easily get entangled when they collide. To prevent this problem, [repulsive forces are applied between overlapping soft bodies](https://github.com/matsuoka-601/PBDRust/blob/13f187b69d1259da6d52b0a4078263530c859ddd/PBD.ts#L369). They still sometimes get entangled even with this trick, but it's less frequent than it would be without it.\n\nIn addition, [soft body particles within other soft bodies do not interact with those soft bodies](https://github.com/matsuoka-601/PBDRust/blob/main/PBD.ts#L294). This also prevents soft bodies from becoming entangled with each other.\n### Prevent Fluid Particles from Entering Soft Bodies\nTo prevent fluid particles from remaining inside soft bodies, [fluid particles inside soft bodies do not interact with soft body particles](https://github.com/matsuoka-601/PBDRust/blob/13f187b69d1259da6d52b0a4078263530c859ddd/src/lib.rs#L209). Fluid particles naturally go out of the soft bodies thanks to this trick.\n## References\n- [Position Based Dynamics](https://matthias-research.github.io/pages/publications/posBasedDyn.pdf) by Müller et al.\n- [Position Based Fluids](https://mmacklin.com/pbf_sig_preprint.pdf) by Macklin et al.\n- [Unified Particle Physics for Real-Time Applications](https://mmacklin.com/uppfrta_preprint.pdf) by Macklin et al.\n- [Small Steps in Physics Simulation](https://mmacklin.com/smallsteps.pdf) by Macklin et al.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatsuoka-601%2Ffloaty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatsuoka-601%2Ffloaty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatsuoka-601%2Ffloaty/lists"}