Install Photo Sphere Viewer
With npm or yarn
1 2
| npm install photo-sphere-viewer yarn add photo-sphere-viewer
|
Dependencies
Your first viewer
Include all JS & CSS files in your page manually or with your favorite bundler and init the viewer.
Direct import
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| <head> <!-- for optimal display on high DPI devices --> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photo-sphere-viewer@4/dist/photo-sphere-viewer.min.css"/> </head>
<script src="https://cdn.jsdelivr.net/npm/three/build/three.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/uevent@2/browser.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/photo-sphere-viewer@4/dist/photo-sphere-viewer.min.js"></script>
<!-- the viewer container must have a defined size --> <div id="viewer" style="width: 100vw; height: 100vh;"></div>
<script> const viewer = new PhotoSphereViewer.Viewer({ container: document.querySelector('#viewer'), panorama: 'path/to/panorama.jpg', }); </script>
|
ES import
1 2 3 4 5 6 7
| <head> <!-- for optimal display on high DPI devices --> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head>
<!-- the viewer container must have a defined size --> <div id="viewer" style="width: 100vw; height: 100vh;"></div>
|
1 2 3 4 5 6
| import { Viewer } from 'photo-sphere-viewer';
const viewer = new Viewer({ container: document.querySelector('#viewer'), panorama: 'path/to/panorama.jpg', });
|
Home page
Photo Sphere Viewer
Github url
Photo Sphere Viewer