Difference between revisions of "Panorama on web pages"
From Publication Station
Line 31: | Line 31: | ||
<style> | <style> | ||
html { | html { | ||
height: 100%; | height: 100%; | ||
Line 46: | Line 46: | ||
} | } | ||
/* | /* | ||
#panorama { | #panorama { | ||
width: 600px; | width: 600px; | ||
Line 57: | Line 56: | ||
<div id="panorama"></div> | <div id="panorama"></div> | ||
<script> | <script> | ||
viewer = pannellum.viewer('panorama', { | |||
"type": "equirectangular", | "type": "equirectangular", | ||
"panorama": "Mars.jpg", | "panorama": "Mars.jpg", | ||
Line 64: | Line 64: | ||
"showFullscreenCtrl":false | "showFullscreenCtrl":false | ||
}); | }); | ||
</script> | |||
</body> | |||
</html> | |||
</source> | </source> | ||
=Interaction= | |||
Programmatic interaction with the panorama can be achieved by using Pannellum API | |||
* <code>viewer.setYaw(10)</code> set Yaw to 10 | |||
* <code>viewer.setYaw(viewer.getYaw()-100)</code> get current yaw and move -100 from it | |||
[[Category:Research]] [[Category:Tutorial]] | [[Category:Research]] [[Category:Tutorial]] |
Revision as of 12:18, 12 December 2016
Pannellum is JavaScript library for displaying and navigate panorama images on web pages. In order to use Pannellum you must:
- Download Pannellum: https://pannellum.org/download/
- Place the downloaded files:
pannellum.css, pannellum.htm, pannellum.js
in a folder - Save a panorama image in the same folder
- Wikimedia commons is a good source of panoramic images under free licenses
- Pannellum images with a maximum of 8000px wide, so you might need to resize the panorama image file
- Use the API example in Pannellum documentation to write your HTML page. An example of the change code can be seen below
- Set the pannellum.viewer with the settings for your image, most important parameters are:
"panorama":
defines the image file to use"type":
the type of the image: equirectangular, cubemap, or multires- A full list of Pannellum parameters and methods can is available in its API documentation
To run it you will need to store the folder with the library, html page and images in webserver.
Example
See live example in http://publicationstation.wdka.hro.nl/pannellum/
HTML code
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>A simple example</title>
<link rel="stylesheet" href="pannellum.css"/>
<script type="text/javascript" src="pannellum.js"></script>
<style>
html {
height: 100%;
}
body {
margin: 0;
padding: 0;
overflow: hidden;
position: fixed;
cursor: default;
width: 100%;
height: 100%;
}
/*
#panorama {
width: 600px;
height: 400px;
}
*/
</style>
</head>
<body>
<div id="panorama"></div>
<script>
viewer = pannellum.viewer('panorama', {
"type": "equirectangular",
"panorama": "Mars.jpg",
"autoLoad": true,
"showFullscreenCtrl":false
});
</script>
</body>
</html>
Interaction
Programmatic interaction with the panorama can be achieved by using Pannellum API
viewer.setYaw(10)
set Yaw to 10viewer.setYaw(viewer.getYaw()-100)
get current yaw and move -100 from it