{"size": 2951, "ext": "js", "max_stars_repo_path": "app/draw.js", "max_stars_repo_name": "georgewaraw/lunarine", "max_stars_repo_stars_event_min_datetime": "2019-09-26T00:06:55.000Z", "max_stars_repo_stars_event_max_datetime": "2019-10-16T02:42:32.000Z", "max_issues_repo_path": "app/draw.js", "max_issues_repo_name": "georgewaraw/lunarine", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app/draw.js", "max_forks_repo_name": "georgewaraw/lunarine", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31.7311827957, "max_line_length": 112, "alphanum_fraction": 0.6601152152}
import TWEEN from 'es6-tween'
import app from 'app'
import helper from 'helper'
import mesh from 'mesh'
import shader from 'shader'

app.renderer.setAnimationLoop( time => {

  time /= 1000

  TWEEN.update()

  mesh.points.position.set( app.camera.position.x - .5, app.camera.position.y - .5, 6.5 )

  if ( app.state === 'start' ) {

    mesh.sphereLeft.rotation.x = time / 2
    mesh.sphereRight.rotation.x = time / 2
    mesh.cylinder.rotation.x = time / 2
    mesh.octahedron.rotation.y = time / 2

    const amplitude = helper.map( app.audio.analyser.getAverageFrequency(), 63, 255, .1, 3 )

    if ( mesh.octahedron.position.x === -1.5 ) {

      if ( shader.sphereLeft ) shader.sphereLeft.uniforms.uDistort.value = amplitude * 2

      if ( app.camera.position.x === -1.5 && shader.sphereLeft.uniforms.uDistort.value > .2 ) {

        if ( app.post.shader.uniforms.uIntensity.value < 1 ) {

          app.post.shader.uniforms.uIntensity.value += .005

          app.score += .5

        } else app.stop()

      } else if ( app.camera.position.x === 1.5 ) {

        if ( app.post.shader.uniforms.uIntensity.value > .75 ) app.post.shader.uniforms.uIntensity.value -= .005
        else app.post.shader.uniforms.uIntensity.value = .75

      }

    } else if ( mesh.octahedron.position.x === 1.5 ) {

      if ( shader.sphereRight ) shader.sphereRight.uniforms.uDistort.value = amplitude * 2

      if ( app.camera.position.x === 1.5 && shader.sphereRight.uniforms.uDistort.value > .2 ) {

        if ( app.post.shader.uniforms.uIntensity.value < 1 ) {

          app.post.shader.uniforms.uIntensity.value += .005

          app.score += .5

        } else app.stop()

      } else if ( app.camera.position.x === -1.5 ) {

        if ( app.post.shader.uniforms.uIntensity.value > .75 ) app.post.shader.uniforms.uIntensity.value -= .005
        else app.post.shader.uniforms.uIntensity.value = .75

      }

    } else {

      if ( shader.sphereLeft && shader.sphereLeft.uniforms.uDistort.value > .1 )
        shader.sphereLeft.uniforms.uDistort.value = .1
      if ( shader.sphereRight && shader.sphereRight.uniforms.uDistort.value > .1 )
        shader.sphereRight.uniforms.uDistort.value = .1

    }

    if ( shader.cylinder ) shader.cylinder.uniforms.uDistort.value = amplitude
    if ( shader.octahedron ) shader.octahedron.uniforms.uDistort.value = amplitude * 1.25
    if ( shader.points ) shader.points.uniforms.uDistort.value = amplitude

  }

  if ( shader.sphereLeft ) shader.sphereLeft.uniforms.uTime.value = time
  if ( shader.sphereRight ) shader.sphereRight.uniforms.uTime.value = time
  if ( shader.cylinder ) shader.cylinder.uniforms.uTime.value = time
  if ( shader.octahedron ) shader.octahedron.uniforms.uTime.value = time
  if ( shader.points ) shader.points.uniforms.uTime.value = time
  if ( shader.text ) shader.text.uniforms.uTime.value = time

  app.post.shader.uniforms.uTime.value = time

  app.composer.render()

} )
