     document.body.appendChild(@renderer.domElement)
 
     @direction = Dir.NONE
+    @jumping = false
+    @jumpFramesLeft = 0
 
     geometry = new THREE.BoxGeometry(1, 1, 1)
     material = new THREE.MeshBasicMaterial(

    )

    # Set up 31x31x31 world.
    @cubes = []
    for x in [-@worldSize..@worldSize]
      @cubes[x] = []
      for y in [-(@worldSize * 2 + 3)..-2]
        @cubes[x][y] = []
        for z in [-@worldSize..@worldSize]
          cube = new THREE.Mesh(geometry, material)
          @scene.add(cube)
          cube.translateX(x)
          cube.translateY(y)
          cube.translateZ(z)
          @cubes[x][y][z] = cube

    # Bind movement events
    $(window).on 'keydown', (event) =>

      when Dir.NE
        @camera.position.x = Math.min(@camera.position.x + diagStep, @worldSize)
        @camera.position.z = Math.max(@camera.position.z - diagStep, -@worldSize)

    # If jumping, move up a little and decrement frames.
    if @jumping
      @camera.position.y += jumpStep
      @jumpFramesLeft--
      @jumping = (@jumpFramesLeft > 0)

    # If not jumping, check for gravity
    unless @jumping
      loc = @currentLocation()
      loc.y = Math.max(loc.y - 2, -@worldSize)
      unless @isSolid(loc)
        @camera.position.y -= jumpStep

    setTimeout(@move, 25)

  currentLocation: ->
    x =
      if @camera.position.x > 0
        Math.ceil(@camera.position.x)
      else
        Math.floor(@camera.position.x)
    y =
      if @camera.position.y > 0
        Math.ceil(@camera.position.y)
      else
        Math.floor(@camera.position.y)
    z =
      if @camera.position.z > 0
        Math.ceil(@camera.position.z)
      else
        Math.floor(@camera.position.z)
    {
      x: x
      y: y
      z: z
    }

  isSolid: (loc) ->
    @cubes[loc.x] != undefined && @cubes[loc.x][loc.y] != undefined && 
    @cubes[loc.x][loc.y][loc.z] != undefined && @cubes[loc.x][loc.y][loc.z].solid

# Directions Enum for movement
Dir =
