Skip to content

PanoViewer 3.0 User Guide

Jongmoon Yoon edited this page Dec 27, 2018 · 10 revisions

Getting Started

Things to know before you start

  • By default, WebGL only accepts images from the same origin.
  • If you are using an image from another origin, you must configure CORS on the image server.

The same origin must match the following:

  1. Protocol
  2. Host Name
  3. Port

Ref: https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy

1. Loading 360-degree photos

If equirectangular 360 degree photos(Ref) are ready, then half has already been done.

Supported Projection Type

You can create an area where the image will be displayed (div # myPanoViewer), load the view 360 library, and assign the prepared image URL to the image property of the PanoViewer constructor option.

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
    #myPanoViewer {
        position: relative; /* Must be relative or absolute.*/
        width: 600px;
        height: 400px;
    }
    </style>
</head>
<body>

<div id="myPanoViewer"></div>
<script src="//naver.github.io/egjs-view360/release/latest/dist/PanoViewer/view360.panoviewer.pkgd.min.js"></script>
<script>
// create PanoViewer with option
var PanoViewer = eg.view360.PanoViewer;
var container = document.getElementById("myPanoViewer");// Area where the image will be displayed(HTMLElement)
	
var panoViewer = new PanoViewer(container, {
	// If projectionType is not specified, the default is "equirectangular".
    image: "/path/to/image/image.jpg" // Specifies an image of the "equirectangular" type.
  }
);
</script>

</body>
</html>

Go to Example

2. Loading a 360-degree video

view360 supports 360 videos as well as 360 images.

The video loading method is similar to the image loading method. The difference is that if you are loading an image, you must assign a value to the image property of the constructor's options, but if you are loading a video, you must specify the video property of the constructor's options.

In the example below, the video tag you want to play is assigned to the video property.

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
    #myPanoViewer {
        position: relative; /* Must be relative or absolute.*/
        width: 600px;
        height: 400px;
    }
    </style>
</head>
<body>

<div id="myPanoViewer"></div>
<script src="//naver.github.io/egjs-view360/release/latest/dist/PanoViewer/view360.panoviewer.pkgd.min.js"></script>
<!-- Specify the video tag. At this time, display: none is processed so that the video is not displayed as a duplicate. -->
<video id="videoSrc" style="width:100%;height:400px;display:none">
	<source src="../img/PanoViewer/pano.webm" type="video/webm">
	<source src="../img/PanoViewer/pano.mp4" type="video/mp4">
</video>
<script>
// create PanoViewer with option
var PanoViewer = eg.view360.PanoViewer;
var container = document.getElementById("myPanoViewer"); // The area where the video will be displayed (HTMLElement)
var videoTag = document.getElementById("videoSrc");
	
const panoViewer = new PanoViewer(container, {
	// If projectionType is not specified, the default is "equirectangular".
    video: videoTag // Specify an image tag.
  }
);
</script>

</body>
</html>

Go to Example

Usage in es5 & es6 environment

1. es5

<script src="//naver.github.io/egjs-view360/release/latest/dist/PanoViewer/view360.panoviewer.pkgd.min.js"></script>

<script>
	// Use global namespace
	var PanoViewer = eg.view360.PanoViewer;
	
	// create PanoViewer with option
	var panoViewer = new PanoViewer(
	  document.getElementById("myPanoViewer"),
	  {
		image: "/path/to/image/image.jpg"
	  }
	);
</script>

2. es6

import {PanoViewer} from "@egjs/view360"
	
// create PanoViewer with option
const panoViewer = new PanoViewer(
  document.getElementById("myPanoViewer"),
  {
	image: "/path/to/image/image.jpg"
  }
);

Option usage

Related Options

  1. projectionType
  2. image
  3. video

Related Options

  1. yaw
  2. pitch
  3. fov
  4. yawRange
  5. pitchRange
  6. fovRange

Related Options

gyroMode

related option

touchDirection

Event / Error handling

2. Handling errors (using the error event)

API Document

Clone this wiki locally