src/components/avatar-replayer.js
function () {
    var cameraEl = this.cameraEl;
    var headMesh;
    var leftEyeMesh;
    var rightEyeMesh;
    var leftEyeBallMesh;
    var rightEyeBallMesh;

    if (cameraEl.getObject3D('mesh') || cameraEl.getObject3D('replayerMesh')) { return; }

    // Head.
    headMesh = new THREE.Mesh();
    headMesh.geometry = new THREE.BoxBufferGeometry(0.3, 0.3, 0.2);
    headMesh.material = new THREE.MeshStandardMaterial({color: 'pink'});
    headMesh.visible = this.data.spectatorMode;

    // Left eye.
    leftEyeMesh = new THREE.Mesh();
    leftEyeMesh.geometry = new THREE.SphereBufferGeometry(0.05);
    leftEyeMesh.material = new THREE.MeshBasicMaterial({color: 'white'});
    leftEyeMesh.position.x -= 0.1;
    leftEyeMesh.position.y += 0.1;
    leftEyeMesh.position.z -= 0.1;
    leftEyeBallMesh = new THREE.Mesh();
    leftEyeBallMesh.geometry = new THREE.SphereBufferGeometry(0.025);
    leftEyeBallMesh.material = new THREE.MeshBasicMaterial({color: 'black'});
    leftEyeBallMesh.position.z -= 0.04;
    leftEyeMesh.add(leftEyeBallMesh);
    headMesh.add(leftEyeMesh);

    // Right eye.
    rightEyeMesh = new THREE.Mesh();
    rightEyeMesh.geometry = new THREE.SphereBufferGeometry(0.05);
    rightEyeMesh.material = new THREE.MeshBasicMaterial({color: 'white'});
    rightEyeMesh.position.x += 0.1;
    rightEyeMesh.position.y += 0.1;
    rightEyeMesh.position.z -= 0.1;
    rightEyeBallMesh = new THREE.Mesh();
    rightEyeBallMesh.geometry = new THREE.SphereBufferGeometry(0.025);
    rightEyeBallMesh.material = new THREE.MeshBasicMaterial({color: 'black'});
    rightEyeBallMesh.position.z -= 0.04;
    rightEyeMesh.add(rightEyeBallMesh);
    headMesh.add(rightEyeMesh);

    cameraEl.setObject3D('replayerMesh', headMesh);
  }
function () {
    var cameraEl = this.cameraEl;
    var headMesh;
    var leftEyeMesh;
    var rightEyeMesh;
    var leftEyeBallMesh;
    var rightEyeBallMesh;

    if (cameraEl.getObject3D('mesh') || cameraEl.getObject3D('replayerMesh')) { return; }

    // Head.
    headMesh = new THREE.Mesh();
    headMesh.geometry = new THREE.BoxBufferGeometry(0.3, 0.3, 0.2);
    headMesh.material = new THREE.MeshStandardMaterial({color: 'pink'});
    headMesh.visible = this.data.spectatorMode;

    // Left eye.
    leftEyeMesh = new THREE.Mesh();
    leftEyeMesh.geometry = new THREE.SphereBufferGeometry(0.05);
    leftEyeMesh.material = new THREE.MeshBasicMaterial({color: 'white'});
    leftEyeMesh.position.x -= 0.1;
    leftEyeMesh.position.y += 0.1;
    leftEyeMesh.position.z -= 0.1;
    leftEyeBallMesh = new THREE.Mesh();
    leftEyeBallMesh.geometry = new THREE.SphereBufferGeometry(0.025);
    leftEyeBallMesh.material = new THREE.MeshBasicMaterial({color: 'black'});
    leftEyeBallMesh.position.z -= 0.04;
    leftEyeMesh.add(leftEyeBallMesh);
    headMesh.add(leftEyeMesh);

    // Right eye.
    rightEyeMesh = new THREE.Mesh();
    rightEyeMesh.geometry = new THREE.SphereBufferGeometry(0.05);
    rightEyeMesh.material = new THREE.MeshBasicMaterial({color: 'white'});
    rightEyeMesh.position.x += 0.1;
    rightEyeMesh.position.y += 0.1;
    rightEyeMesh.position.z -= 0.1;
    rightEyeBallMesh = new THREE.Mesh();
    rightEyeBallMesh.geometry = new THREE.SphereBufferGeometry(0.025);
    rightEyeBallMesh.material = new THREE.MeshBasicMaterial({color: 'black'});
    rightEyeBallMesh.position.z -= 0.04;
    rightEyeMesh.add(rightEyeBallMesh);
    headMesh.add(rightEyeMesh);

    cameraEl.setObject3D('replayerMesh', headMesh);
  }
function ( ) { var cameraEl = this . cameraEl ; var headMesh ; var leftEyeMesh ; var rightEyeMesh ; var leftEyeBallMesh ; var rightEyeBallMesh ; if ( cameraEl . getObject3D ( 'mesh' ) || cameraEl . getObject3D ( 'replayerMesh' ) ) { return ; } // Head. headMesh = new THREE . Mesh ( ) ; headMesh . geometry = new THREE . BoxBufferGeometry ( 0.3 , 0.3 , 0.2 ) ; headMesh . material = new THREE . MeshStandardMaterial ( { color : 'pink' } ) ; headMesh . visible = this . data . spectatorMode ; // Left eye. leftEyeMesh = new THREE . Mesh ( ) ; leftEyeMesh . geometry = new THREE . SphereBufferGeometry ( 0.05 ) ; leftEyeMesh . material = new THREE . MeshBasicMaterial ( { color : 'white' } ) ; leftEyeMesh . position . x -= 0.1 ; leftEyeMesh . position . y += 0.1 ; leftEyeMesh . position . z -= 0.1 ; leftEyeBallMesh = new THREE . Mesh ( ) ; leftEyeBallMesh . geometry = new THREE . SphereBufferGeometry ( 0.025 ) ; leftEyeBallMesh . material = new THREE . MeshBasicMaterial ( { color : 'black' } ) ; leftEyeBallMesh . position . z -= 0.04 ; leftEyeMesh . add ( leftEyeBallMesh ) ; headMesh . add ( leftEyeMesh ) ; // Right eye. rightEyeMesh = new THREE . Mesh ( ) ; rightEyeMesh . geometry = new THREE . SphereBufferGeometry ( 0.05 ) ; rightEyeMesh . material = new THREE . MeshBasicMaterial ( { color : 'white' } ) ; rightEyeMesh . position . x += 0.1 ; rightEyeMesh . position . y += 0.1 ; rightEyeMesh . position . z -= 0.1 ; rightEyeBallMesh = new THREE . Mesh ( ) ; rightEyeBallMesh . geometry = new THREE . SphereBufferGeometry ( 0.025 ) ; rightEyeBallMesh . material = new THREE . MeshBasicMaterial ( { color : 'black' } ) ; rightEyeBallMesh . position . z -= 0.04 ; rightEyeMesh . add ( rightEyeBallMesh ) ; headMesh . add ( rightEyeMesh ) ; cameraEl . setObject3D ( 'replayerMesh' , headMesh ) ; }
Create head geometry for spectator mode.
Always created in case we want to toggle, but only visible during spectator mode.
Create head geometry for spectator mode . Always created in case we want to toggle but only visible during spectator mode .