Example #1
0
  constructor(canvas, useTextureNoise = true, fov = 65, viewOffset = [ 0, 0 ]) {

    super();

    this.pointer = Pointer.get(canvas);

    this.camera = new THREE.PerspectiveCamera( fov, window.innerWidth / window.innerHeight, 0.1, 100000);

    this.camera.setViewOffset( 
      window.innerWidth + viewOffset[0], 
      window.innerHeight+ viewOffset[1], 
      ...viewOffset, window.innerWidth , window.innerHeight )

    App.onSceneChange.add(this.onSceneChange, this);

    // Lighting

    let ambientLight = new THREE.AmbientLight(0xeeeeee);
    this.add(ambientLight);

    let directionalLight = new THREE.DirectionalLight();
    directionalLight.position.set(1, 1, 1);
    this.add(directionalLight);

    /*
        The character object is the focal point of the interaction.
        This is the point at which the lines geometry is generated
        and the camera follows
    */
    this.character = new THREE.Vector3();

    this.background = new Background(this.character, useTextureNoise );
    if (!/\bnobackground\b/.test(window.location.search)) {
      this.add(this.background);
    }
    
    this.path = new Path();
    this.path.update();

    // this.tunnel = new Tunnel(this.path);
    // this.add(this.tunnel);

    this.lines = new Lines(this.character);
    this.add(this.lines);

    if(/\bdebugcamera\b/.test(window.location.search)) {
      this.camera.position.z = 1;
      this.controls = new THREE.TrackballControls(this.camera);
    }
    else {
      this.controls = new CameraControls(this.camera, this.character );
    }

    SoundManager.play("Drone_02", {
      loop: true
    });

    for (let i = 0; i < 100; i++) {
      this.update();
    }

    App.onResize.add(this.resize, this);
  }