Skip to content

maxwase/kami

Repository files navigation

Kami

Kami is a paper-folding simulation built to be driven by a physical hinge, using folding device APIs when available.

Try it online at https://maxwase.github.io/kami

!important Posture API only works in a limited set of browsers! Check out the compatibility here.

See it in action

kami.mp4

Options

The game tries its best to auto-detect your device's folding posture and capabilities, but you can also manually set them using the "Show Options" button in the top-left.

  1. Invert fold direction -- By default, Kami assumes the accelerometer is on the right half of the screen. It tries to detect the direction you fold your device (left to right, top to bottom, etc). If it guesses wrong, set it manually here.
  2. Stability threshold -- This setting controls how sensitive posture detection is to small movements. A lower value means even small tilts count as a fold, while a higher value requires faster folds.
  3. X and Y axis -- The problem of the century persists: Where is the center of the device?

Requirements

  • Node.js 18+ (Vite 7)
  • pnpm 9+
  • A modern browser to actually test folding. Note that the API is only available on localhost or HTTPS connections.

Build and run

pnpm install
pnpm run dev    # start Vite dev server
pnpm run build  # type-check + production build to dist/

Credits

  • Foldy bird -- Flappy bird controlled with hinge flaps! It's surprising how 2 people can independently come up with the same idea! Lyra, however, published it first, so congrats!
  • LidAngleSensor -- An amazing reversed-engineering of the MacBook's lid angle sensor, which inspired me to experiment with foldables!

Future of the project

I'm primarily a backend developer, so the code quality here is probably not the best; a lot of it was AI-generated over a weekend. I want to rewrite this in Rust, WebAssembly, Bevy, or Tauri to make it cross-platform and to add more complex folding puzzles. If you have any thoughts or suggestions, please contact me via telegram or email :)

About

Origami simulator driven by a physical hinge

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published