code: function () {
      var data = this.data;
      var sceneEl = this.el;
      var spectatorCameraEl;
      var spectatorCameraRigEl;
  
      // Developer-defined spectator rig.
      if (this.el.querySelector('#spectatorCameraRig')) {
        this.spectatorCameraEl = sceneEl.querySelector('#spectatorCameraRig');
        return;
      }
  
      // Create spectator camera rig.
      spectatorCameraRigEl = sceneEl.querySelector('#spectatorCameraRig') ||
                             document.createElement('a-entity');
      spectatorCameraRigEl.id = 'spectatorCameraRig';
      spectatorCameraRigEl.setAttribute('position', data.spectatorPosition);
      this.spectatorCameraRigEl = spectatorCameraRigEl;
  
      // Create spectator camera.
      spectatorCameraEl = sceneEl.querySelector('#spectatorCamera') ||
                          document.createElement('a-entity');
      spectatorCameraEl.id = 'spectatorCamera';
      spectatorCameraEl.setAttribute('camera', {active: data.spectatorMode, userHeight: 0});
      spectatorCameraEl.setAttribute('look-controls', '');
      spectatorCameraEl.setAttribute('wasd-controls', {fly: true});
      this.spectatorCameraEl = spectatorCameraEl;
  
      // Append rig.
      spectatorCameraRigEl.appendChild(spectatorCameraEl);
      sceneEl.appendChild(spectatorCameraRigEl);
      sceneEl.emit('spectatorcameracreated');
    }
docs: Create and activate spectator camera if in spectator mode.