All Projects → evancz → First Person Elm

evancz / First Person Elm

Licence: other
First-person navigation in a simple 3D world, written in Elm

Programming Languages

elm
856 projects

First Person 3D Navigation in Elm

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:

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!

Build Locally

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!

Possible Extensions

  • 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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].