src/components/avatar-replayer.js
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');
  }
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');
  }
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' ) ; }
Create and activate spectator camera if in spectator mode.
Create and activate spectator camera if in spectator mode .