Skip to content

Instantly share code, notes, and snippets.

@korya
Last active April 15, 2020 20:54
Show Gist options
  • Save korya/505e8e543341b12819171d416491f442 to your computer and use it in GitHub Desktop.
Save korya/505e8e543341b12819171d416491f442 to your computer and use it in GitHub Desktop.

iGUIDE Viewer API

Constructor for the API: new IGuideViewer(iframeElement)

Methods:

  • ready() - Returns a Promise that resolves when the iGUIDE is ready to be used.
  • tour.move(position, camera, transitionType) - Transition to a different pano.
  • tour.moveCamera(camera) - Change the user's camera.
  • addEventListener(event, cb) - Subscribe to an event.
  • removeEventListener(event, cb) - Unsubscribe from an event. The cb must be the same reference to a function passed earlier to addEventListener().

Events:

  • ready - This event fires when the iGUIDE is ready to be used.
  • tour:move-start, args (position, camera, transitionType) - This event fires as soon as the user clicks to switch to a new pano or floor, before the transition begins. The arguments can be passed to tour.move() in the same order.
  • tour:camera-move-start args (camera) - This event fires when the user begins rotating the pano. The arguments can be passed to tour.moveCamera() in the same order.
  • tour:camera-move args (camera) - This event fires while the user is rotating the pano. The arguments can be passed to tour.moveCamera() in the same order.
  • tour:camera-move-end, args (camera) - This event fires when the user finishes rotating the pano (and inertia has stopped rotating the pano, if applicable). The arguments can be passed to tour.moveCamera() in the same order.

Usage example:

const master = new IGuideViewer(document.getElementById('master-iframe'));
const slave = new IGuideViewer(document.getElementById('slave-iframe'));

await Promise.all(master.ready(), slave.ready());

master.addEventListener('tour:move-start', (position, camera, transitionType) => {
  slave.tour.move(position, camera, transitionType);
});

master.addEventListener('tour:camera-move-end', camera => {
  slave.tour.moveCamera(camera);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment