Code Monkey home page Code Monkey logo

first-person-elm's Introduction

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.