Tron.js

Felix Palmer | @pheeelicks | www.pheelicks.com

Tron.js

Felix Palmer | @pheeelicks | www.pheelicks.com

Workshop overview

  1. Machine setup
  2. THREE.js basics
  3. Project structure - amd-three.js
  4. Animation & interactivity
  5. Vertex shaders
  6. Fragment shaders
  7. Postprocessing
  8. You're on your own!

Useful links

Machine setup

Get the code!

            git clone git@github.com:felixpalmer/amd-three.js.git
            cd amd-three.js
            ./webserver.sh
            open http://localhost:8000
        

THREE.js

amd-three.js

amd-three.js - 15mins

  1. Try modifying the elements on stage:
    • Add a different geometries
    • Add a new texture file, and apply it to an object
  2. Some basic modelling (this will form the basis of the light-cycle)
    • Make a compound object (use THREE.Object3D.add())
    • Try and make the best light cycle you can using geometry primitives
    • Refactor the code into a separate Require.js module
    • app.lightcycle = new Lightcycle();

Animation and interactivity - 15mins

  1. We already have animation loop setup, just need to make things move
  2. Try updating object positions on every frame. Hint: use THREE.Clock
  3. Add an document.onmousemove listener and update based on mouse position
  4. Try updating the camera position, as well as of objects in the scene

The game

            git clone git@github.com:felixpalmer/tron.js.git
            cd tron.js
            ./webserver.sh
            open http://localhost:3333
        

To the GPU!

Vertex shaders - 15mins

  1. Play around with the vertex shaders in FF dev tools
  2. Create a new vertex shader file, based on js/shaders/simple.vert
  3. Create a new material with this vertex shader attached, see material.simple
  4. Try out some of the built-in functions: mix, pow, mix etc...
  5. Try animating, by passing in the game clock, see engine.vert

Passing data around

Check out Qualifiers section in WebGL cheatsheet

Fragment shaders - 20mins

  1. Play around with the fragment shaders in FF dev tools
  2. Create a new fragment shader file, based on js/shaders/simple.frag
  3. Try out some of the built-in functions: sin, pow, mix etc...
  4. Try animating, by passing in the game clock, see engine.frag

Post-processing

Post-processing - 20mins

You're on your own!