src/embed/hotspot-renderer.js
function HotspotRenderer(worldRenderer) {
  this.worldRenderer = worldRenderer;
  this.scene = worldRenderer.scene;

  // Note: this event must be added to document.body and not to window for it to
  // work inside iOS iframes.
  var body = document.body;
  // Bind events for hotspot interaction.
  if (!Util.isMobile()) {
    // Only enable mouse events on desktop.
    body.addEventListener('mousedown', this.onMouseDown_.bind(this), false);
    body.addEventListener('mousemove', this.onMouseMove_.bind(this), false);
    body.addEventListener('mouseup', this.onMouseUp_.bind(this), false);
  }
  body.addEventListener('touchstart', this.onTouchStart_.bind(this), false);
  body.addEventListener('touchend', this.onTouchEnd_.bind(this), false);

  // Add a placeholder for hotspots.
  this.hotspotRoot = new THREE.Object3D();
  // Align the center with the center of the camera too.
  this.hotspotRoot.rotation.y = Math.PI / 2;
  this.scene.add(this.hotspotRoot);

  // All hotspot IDs.
  this.hotspots = {};

  // Currently selected hotspots.
  this.selectedHotspots = {};

  // Hotspots that the last touchstart / mousedown event happened for.
  this.downHotspots = {};

  // For raycasting. Initialize mouse to be off screen initially.
  this.pointer = new THREE.Vector2(1, 1);
  this.raycaster = new THREE.Raycaster();
}
function HotspotRenderer(worldRenderer) {
  this.worldRenderer = worldRenderer;
  this.scene = worldRenderer.scene;

  // Note: this event must be added to document.body and not to window for it to
  // work inside iOS iframes.
  var body = document.body;
  // Bind events for hotspot interaction.
  if (!Util.isMobile()) {
    // Only enable mouse events on desktop.
    body.addEventListener('mousedown', this.onMouseDown_.bind(this), false);
    body.addEventListener('mousemove', this.onMouseMove_.bind(this), false);
    body.addEventListener('mouseup', this.onMouseUp_.bind(this), false);
  }
  body.addEventListener('touchstart', this.onTouchStart_.bind(this), false);
  body.addEventListener('touchend', this.onTouchEnd_.bind(this), false);

  // Add a placeholder for hotspots.
  this.hotspotRoot = new THREE.Object3D();
  // Align the center with the center of the camera too.
  this.hotspotRoot.rotation.y = Math.PI / 2;
  this.scene.add(this.hotspotRoot);

  // All hotspot IDs.
  this.hotspots = {};

  // Currently selected hotspots.
  this.selectedHotspots = {};

  // Hotspots that the last touchstart / mousedown event happened for.
  this.downHotspots = {};

  // For raycasting. Initialize mouse to be off screen initially.
  this.pointer = new THREE.Vector2(1, 1);
  this.raycaster = new THREE.Raycaster();
}
function HotspotRenderer ( worldRenderer ) { this . worldRenderer = worldRenderer ; this . scene = worldRenderer . scene ; // Note: this event must be added to document.body and not to window for it to // work inside iOS iframes. var body = document . body ; // Bind events for hotspot interaction. if ( ! Util . isMobile ( ) ) { // Only enable mouse events on desktop. body . addEventListener ( 'mousedown' , this . onMouseDown_ . bind ( this ) , false ) ; body . addEventListener ( 'mousemove' , this . onMouseMove_ . bind ( this ) , false ) ; body . addEventListener ( 'mouseup' , this . onMouseUp_ . bind ( this ) , false ) ; } body . addEventListener ( 'touchstart' , this . onTouchStart_ . bind ( this ) , false ) ; body . addEventListener ( 'touchend' , this . onTouchEnd_ . bind ( this ) , false ) ; // Add a placeholder for hotspots. this . hotspotRoot = new THREE . Object3D ( ) ; // Align the center with the center of the camera too. this . hotspotRoot . rotation . y = Math . PI / 2 ; this . scene . add ( this . hotspotRoot ) ; // All hotspot IDs. this . hotspots = { } ; // Currently selected hotspots. this . selectedHotspots = { } ; // Hotspots that the last touchstart / mousedown event happened for. this . downHotspots = { } ; // For raycasting. Initialize mouse to be off screen initially. this . pointer = new THREE . Vector2 ( 1 , 1 ) ; this . raycaster = new THREE . Raycaster ( ) ; }
Responsible for rectangular hot spots that the user can interact with.

Specific duties:
Adding and removing hotspots.
Rendering the hotspots (debug mode only).
Notifying when hotspots are interacted with.

Emits the following events:
click (id): a hotspot is clicked.
focus (id): a hotspot is focused.
blur (id): a hotspot is no longer hovered over.
Responsible for rectangular hot spots that the user can interact with .