Giter Club home page Giter Club logo

elm-webgl-examples's Introduction

Elm Web GL Experiments

I am experimenting with WebGL in Elm and thought I would collect anything useful that comes out in this repo. This code is intended to be more a learning resource than a code resource. I have no prior experience in WebGL and would have liked more basic examples done in Elm than what is currently available.

Landscape

  • Generates landscape/terrain geometry using a noise function.
  • A "player" can be moved across landscape using arrow keys.
  • Has shader with directional lighting.
  • Rotate "scene" using mouse drag

Try it

https://mika.xyz/elm-webgl-experiments/landscape.html

Notes

  • Landscape.Generator returns vertices with normals needed for lighting in the shader. There seems to be MANY ways to calculate normals for a mesh. The simple one used here is sufficient for geometry that "points in one direction" and does not curve into itself.
  • Landscape geometry generated is the simplest possible: quads triangulated in order. I understand some other pattern (Diamond-square) would be more optimal.
  • Lighting is done in vertex shader. One is supposed to get better results calculating lighting in fragment shader...
  • Noise function is a quick implementation of Perlin Noise. Not sure it is at all "correct" but it seems to do its job.
  • Keyboard.elm handles keyboard input. It is not in a production state in any way. :)

Build

yarn/npm install
yarn/npm run landscape

Browse dist/landscape.html

elm-webgl-examples's People

Contributors

mikaxyz avatar

Stargazers

Yanko Simeonoff avatar Ashish Chandwani avatar Austin Ziegler avatar

Watchers

 avatar

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.