First-person navigation in a simple 3D world, written in Elm. The code ended up
extremely short and simple thanks to FRP, elm-webgl
, and Elm's
easy interop with JS!
Make sure you have the latest version of Chrome or Firefox and then click the following image to try out the live demo:
Without a specialized 3D framework, just the basic WebGL bindings, this took about 300 lines of Elm. I tried to keep the code super simple so it is easy to fork and build cooler stuff! This project is also architected to scale nicely as you add more entities.
We needed an additional ~95 lines of JS to use the experimental fullscreen and Pointer Lock APIs. This is an experiment in setting up ports in a general and reusable way. The goal is a general "Port Handler" pattern that lets you pipe signals out to JS to use some native API or have some side-effect. I hope we can iterate on this idea to make it even simpler for Elm code to interact with JS!
After installing the Elm Platform, run the following sequence of commands:
git clone https://github.com/evancz/first-person-elm.git
cd first-person-elm
elm-get install
elm --make --only-js --bundle-runtime --src-dir=src Main.elm
elm-reactor
And then open http://localhost:8000 to see it in action!
- Use more exciting textures
- Add a skybox
- Make it possible to crouch
- Add collisions with boxes
- Make it possible to jump onto boxes
- Try to generate interesting shapes to add to the world
- Procedurally generate terrain