src/components/look-controls.js
function () {
    var sceneEl = this.el.sceneEl;
    var canvasEl = sceneEl.canvas;

    // Wait for canvas to load.
    if (!canvasEl) {
      sceneEl.addEventListener('render-target-loaded', bind(this.addEventListeners, this));
      return;
    }

    // Mouse events.
    canvasEl.addEventListener('mousedown', this.onMouseDown, false);
    window.addEventListener('mousemove', this.onMouseMove, false);
    window.addEventListener('mouseup', this.onMouseUp, false);

    // Touch events.
    canvasEl.addEventListener('touchstart', this.onTouchStart);
    window.addEventListener('touchmove', this.onTouchMove);
    window.addEventListener('touchend', this.onTouchEnd);

    // sceneEl events.
    sceneEl.addEventListener('enter-vr', this.onEnterVR);
    sceneEl.addEventListener('exit-vr', this.onExitVR);

    // Pointer Lock events.
    if (this.data.pointerLockEnabled) {
      document.addEventListener('pointerlockchange', this.onPointerLockChange, false);
      document.addEventListener('mozpointerlockchange', this.onPointerLockChange, false);
      document.addEventListener('pointerlockerror', this.onPointerLockError, false);
    }
  }
function () {
    var sceneEl = this.el.sceneEl;
    var canvasEl = sceneEl.canvas;

    // Wait for canvas to load.
    if (!canvasEl) {
      sceneEl.addEventListener('render-target-loaded', bind(this.addEventListeners, this));
      return;
    }

    // Mouse events.
    canvasEl.addEventListener('mousedown', this.onMouseDown, false);
    window.addEventListener('mousemove', this.onMouseMove, false);
    window.addEventListener('mouseup', this.onMouseUp, false);

    // Touch events.
    canvasEl.addEventListener('touchstart', this.onTouchStart);
    window.addEventListener('touchmove', this.onTouchMove);
    window.addEventListener('touchend', this.onTouchEnd);

    // sceneEl events.
    sceneEl.addEventListener('enter-vr', this.onEnterVR);
    sceneEl.addEventListener('exit-vr', this.onExitVR);

    // Pointer Lock events.
    if (this.data.pointerLockEnabled) {
      document.addEventListener('pointerlockchange', this.onPointerLockChange, false);
      document.addEventListener('mozpointerlockchange', this.onPointerLockChange, false);
      document.addEventListener('pointerlockerror', this.onPointerLockError, false);
    }
  }
function ( ) { var sceneEl = this . el . sceneEl ; var canvasEl = sceneEl . canvas ; // Wait for canvas to load. if ( ! canvasEl ) { sceneEl . addEventListener ( 'render-target-loaded' , bind ( this . addEventListeners , this ) ) ; return ; } // Mouse events. canvasEl . addEventListener ( 'mousedown' , this . onMouseDown , false ) ; window . addEventListener ( 'mousemove' , this . onMouseMove , false ) ; window . addEventListener ( 'mouseup' , this . onMouseUp , false ) ; // Touch events. canvasEl . addEventListener ( 'touchstart' , this . onTouchStart ) ; window . addEventListener ( 'touchmove' , this . onTouchMove ) ; window . addEventListener ( 'touchend' , this . onTouchEnd ) ; // sceneEl events. sceneEl . addEventListener ( 'enter-vr' , this . onEnterVR ) ; sceneEl . addEventListener ( 'exit-vr' , this . onExitVR ) ; // Pointer Lock events. if ( this . data . pointerLockEnabled ) { document . addEventListener ( 'pointerlockchange' , this . onPointerLockChange , false ) ; document . addEventListener ( 'mozpointerlockchange' , this . onPointerLockChange , false ) ; document . addEventListener ( 'pointerlockerror' , this . onPointerLockError , false ) ; } }
Add mouse and touch event listeners to canvas.
Add mouse and touch event listeners to canvas .