src/systems/camera.js
function (newCameraEl) {
    var newCamera;
    var previousCamera = this.spectatorCameraEl;
    var sceneEl = this.sceneEl;
    var spectatorCameraEl;

    // Same camera.
    newCamera = newCameraEl.getObject3D('camera');
    if (!newCamera || newCameraEl === this.spectatorCameraEl) { return; }

    // Disable current camera
    if (previousCamera) {
      previousCamera.setAttribute('camera', 'spectator', false);
    }

    spectatorCameraEl = this.spectatorCameraEl = newCameraEl;

    sceneEl.addEventListener('enter-vr', this.wrapRender);
    sceneEl.addEventListener('exit-vr', this.unwrapRender);

    spectatorCameraEl.setAttribute('camera', 'active', false);
    spectatorCameraEl.play();

    sceneEl.emit('camera-set-spectator', {cameraEl: newCameraEl});
  }
function (newCameraEl) {
    var newCamera;
    var previousCamera = this.spectatorCameraEl;
    var sceneEl = this.sceneEl;
    var spectatorCameraEl;

    // Same camera.
    newCamera = newCameraEl.getObject3D('camera');
    if (!newCamera || newCameraEl === this.spectatorCameraEl) { return; }

    // Disable current camera
    if (previousCamera) {
      previousCamera.setAttribute('camera', 'spectator', false);
    }

    spectatorCameraEl = this.spectatorCameraEl = newCameraEl;

    sceneEl.addEventListener('enter-vr', this.wrapRender);
    sceneEl.addEventListener('exit-vr', this.unwrapRender);

    spectatorCameraEl.setAttribute('camera', 'active', false);
    spectatorCameraEl.play();

    sceneEl.emit('camera-set-spectator', {cameraEl: newCameraEl});
  }
function ( newCameraEl ) { var newCamera ; var previousCamera = this . spectatorCameraEl ; var sceneEl = this . sceneEl ; var spectatorCameraEl ; // Same camera. newCamera = newCameraEl . getObject3D ( 'camera' ) ; if ( ! newCamera || newCameraEl === this . spectatorCameraEl ) { return ; } // Disable current camera if ( previousCamera ) { previousCamera . setAttribute ( 'camera' , 'spectator' , false ) ; } spectatorCameraEl = this . spectatorCameraEl = newCameraEl ; sceneEl . addEventListener ( 'enter-vr' , this . wrapRender ) ; sceneEl . addEventListener ( 'exit-vr' , this . unwrapRender ) ; spectatorCameraEl . setAttribute ( 'camera' , 'active' , false ) ; spectatorCameraEl . play ( ) ; sceneEl . emit ( 'camera-set-spectator' , { cameraEl : newCameraEl } ) ; }
Set spectator camera to render the scene on a 2D display.

@param {Element} newCameraEl - Entity with camera component.
Set spectator camera to render the scene on a 2D display .