{"id":13344319,"url":"https://github.com/patrick-s-young/use-spring-cannon-hook-example","last_synced_at":"2026-04-17T09:33:04.567Z","repository":{"id":52605272,"uuid":"520719513","full_name":"patrick-s-young/use-spring-cannon-hook-example","owner":"patrick-s-young","description":"React three useSpring cannon hook example","archived":false,"fork":false,"pushed_at":"2022-08-04T18:49:07.000Z","size":298,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-25T15:45:47.386Z","etag":null,"topics":["character-animation","leva","react-three-cannon","react-three-fiber","use-cannon","zustand"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/patrick-s-young.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}},"created_at":"2022-08-03T03:03:18.000Z","updated_at":"2022-08-03T21:59:32.000Z","dependencies_parsed_at":"2022-08-29T08:50:45.603Z","dependency_job_id":null,"html_url":"https://github.com/patrick-s-young/use-spring-cannon-hook-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/patrick-s-young/use-spring-cannon-hook-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrick-s-young%2Fuse-spring-cannon-hook-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrick-s-young%2Fuse-spring-cannon-hook-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrick-s-young%2Fuse-spring-cannon-hook-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrick-s-young%2Fuse-spring-cannon-hook-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patrick-s-young","download_url":"https://codeload.github.com/patrick-s-young/use-spring-cannon-hook-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrick-s-young%2Fuse-spring-cannon-hook-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31923182,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-17T09:10:15.403Z","status":"ssl_error","status_checked_at":"2026-04-17T09:10:14.455Z","response_time":62,"last_error":"SSL_read: 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":["character-animation","leva","react-three-cannon","react-three-fiber","use-cannon","zustand"],"created_at":"2024-07-29T19:33:04.183Z","updated_at":"2026-04-17T09:33:04.546Z","avatar_url":"https://github.com/patrick-s-young.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hook-based Physics With use-cannon  \n\nI have worked extensively with [three.js](https://github.com/mrdoob/three.js/) and [cannon-es](https://github.com/pmndrs/cannon-es) ([Poimandres](https://github.com/pmndrs)' maintained fork of [Stefan Hedman](https://github.com/schteppe)'s [cannon.js](https://github.com/schteppe/cannon.js)). While both of these offer streamlined abstractions of more complicated code, there is still a lot of boilerplate involved.\n\nFortunatley, the React-compatible, hook-based ecosystem developed by [Poimandres]() makes WebXR app development more streamlined and declaritive. \n\nIn this [@react-three/fiber](https://www.npmjs.com/package/@react-three/fiber) example, I leveraged [use-cannons](https://github.com/pmndrs/use-cannon)'s useCompoundBody and useFrame to create the rotating stage. For the 'robot', useSpring was enlisted for the bobbing head. \n\n![01_24fps](https://user-images.githubusercontent.com/42591798/182773111-109324a7-b169-4fd8-b90f-318f2db88903.gif)\n\nThe slider was enabled by [leva](https://github.com/pmndrs/leva), a hook-based GUI library, and [zustand](https://www.npmjs.com/package/zustand), a state management solution. Both are brought to you by - you guessed it - [Poimandres](https://pmnd.rs/).\n\n## View In Sandbox\n[codesandbox.io/s/usecannon-hook-usespring-example-beqvzs](https://codesandbox.io/s/usecannon-hook-usespring-example-beqvzs)\n\n## Running Locally\n\nMake sure you have [Node.js](http://nodejs.org/) installed.\n\n```sh\ngit clone https://github.com/patrick-s-young/use-spring-cannon-hook-example.git # or clone your own fork\ncd use-spring-cannon-hook-example\nnpm install\nnpm start\n```\n\n## Built With\n* [@react-three/fiber](https://www.npmjs.com/package/@react-three/fiber) - React renderer for three.js.\n* [@react-three/cannon](https://www.npmjs.com/package/@react-three/cannon) - React hooks for cannon-es, a rigid body physics engine.\n* [zustand](https://www.npmjs.com/package/zustand) - state-management solution that uses simplified flux principles.\n* [leva](https://github.com/pmndrs/leva) - hook-based GUI library.\n* [@react-three/drei](https://www.npmjs.com/package/@react-three/drei) - Helper library for @react-three/fiber.\n\n## Authors\n\n* **Patrick Young** - [Patrick Young](https://github.com/patrick-s-young)\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrick-s-young%2Fuse-spring-cannon-hook-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatrick-s-young%2Fuse-spring-cannon-hook-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrick-s-young%2Fuse-spring-cannon-hook-example/lists"}