Skip to content

Matt-Esch/first-person-elm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 --src-dir=src Main.elm
elm-server

And then open http://localhost:8000 to see it in action!

Possible Extensions

  • Add a [skybox][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 [skybox]: http://en.wikipedia.org/wiki/Skybox_(video_games)

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published