PSV Virtual Tour Demo

by mistic100

HTML

<script src="https://cdn.jsdelivr.net/npm/uevent@2/browser.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photo-sphere-viewer@4/dist/photo-sphere-viewer.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photo-sphere-viewer@4/dist/photo-sphere-viewer.css">
<script src="https://cdn.jsdelivr.net/npm/photo-sphere-viewer@4/dist/plugins/markers.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photo-sphere-viewer@4/dist/plugins/markers.css">
<script src="https://cdn.jsdelivr.net/npm/photo-sphere-viewer@4/dist/plugins/virtual-tour.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photo-sphere-viewer@4/dist/plugins/virtual-tour.css">
<script src="https://cdn.jsdelivr.net/npm/photo-sphere-viewer@4/dist/plugins/gallery.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photo-sphere-viewer@4/dist/plugins/gallery.css">
<div id="photosphere"></div>

CSS

html, body, #photosphere {
  margin: 0;
  width: 100%;
  height: 100%;
}

JavaScript

const base = 'https://photo-sphere-viewer-data.netlify.app/assets/';

const viewer = new PhotoSphereViewer.Viewer({
  container: 'photosphere',
  loadingImg: 'https://photo-sphere-viewer.js.org/assets/photosphere-logo.gif',
  touchmoveTwoFingers: true,
  mousewheelCtrlKey: true,
  caption: 'Cape Florida Light, Key Biscayne <b>&copy; Pixexid</b>',
  defaultLong: '100deg',
  plugins: [
    PhotoSphereViewer.MarkersPlugin,
    PhotoSphereViewer.GalleryPlugin,
    [PhotoSphereViewer.VirtualTourPlugin, {
      positionMode: PhotoSphereViewer.VirtualTourPlugin.MODE_GPS,
      renderMode  : PhotoSphereViewer.VirtualTourPlugin.MODE_3D,
    }],
  ],
  navbar: 'zoom move download gallery caption fullscreen',
});

const virtualTour = viewer.getPlugin(PhotoSphereViewer.VirtualTourPlugin);

virtualTour.setNodes([
  {
    id      : '1',
    panorama: base + 'tour/key-biscayne-1.jpg',
    thumbnail: base + 'tour/key-biscayne-1-thumb.jpg',
    name    : 'One',
    links   : [
      { nodeId: '2' },
    ],
    markers: [
      {
        id: 'marker-1',
        image: 'https://photo-sphere-viewer.js.org/assets/pin-red.png',
        tooltip: 'Cape Florida Light, Key Biscayne',
        width    : 32,
        height   : 32,
        anchor   : 'bottom center',
        longitude: '105deg',
        latitude: '35deg',
      }
    ],
    position: [-80.156479, 25.666725, 3],
    panoData: { poseHeading: 327 },
  },
  {
    id      : '2',
    panorama: base + 'tour/key-biscayne-2.jpg',
    thumbnail: base + 'tour/key-biscayne-2-thumb.jpg',
    name    : 'Two',
    links   : [
      { nodeId: '3' },
      { nodeId: '1' },
    ],
    position: [-80.156168, 25.666623, 3],
    panoData: { poseHeading: 318 },
  },
  {
    id      : '3',
    panorama: base + 'tour/key-biscayne-3.jpg',
    thumbnail: base + 'tour/key-biscayne-3-thumb.jpg',
    name    : 'Three',
    links   : [
      { nodeId: '4' },
      { nodeId: '2' },
      { nodeId: '5' },
    ],
    position: [-80.155932, 25.666498, 5],
  ...