-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
106 lines (94 loc) · 4.28 KB
/
index.html
File metadata and controls
106 lines (94 loc) · 4.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@photo-sphere-viewer/core@5/index.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@photo-sphere-viewer/markers-plugin@5/index.min.css">
<title>RobIII's homeoffice in glorious 360 degrees</title>
<link rel="icon" type="image/x-icon" href="/favicon.ico">
<base target="_blank">
<style>
html,
body {
margin: 0;
padding: 0;
background-color: #f8faf7;
}
a {
color: #dcdcdc;
text-decoration: underline;
}
.notfound {
background: url('img/notfound.gif') center center no-repeat;
}
</style>
</head>
<body>
<div id="viewer" style="width: 100vw; height: 100vh;"></div>
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three/build/three.module.js",
"@photo-sphere-viewer/core": "https://cdn.jsdelivr.net/npm/@photo-sphere-viewer/core@5/index.module.js",
"@photo-sphere-viewer/markers-plugin": "https://cdn.jsdelivr.net/npm/@photo-sphere-viewer/markers-plugin@5/index.module.js",
"@photo-sphere-viewer/gyroscope-plugin": "https://cdn.jsdelivr.net/npm/@photo-sphere-viewer/gyroscope-plugin@5/index.module.js",
"@photo-sphere-viewer/stereo-plugin": "https://cdn.jsdelivr.net/npm/@photo-sphere-viewer/stereo-plugin@5/index.module.js"
}
}
</script>
<script type="module">
import { Viewer } from '@photo-sphere-viewer/core';
import { MarkersPlugin } from '@photo-sphere-viewer/markers-plugin';
import { GyroscopePlugin } from '@photo-sphere-viewer/gyroscope-plugin';
import { StereoPlugin } from '@photo-sphere-viewer/stereo-plugin';
import markerdata from './markerdata.js';
const createMarker = (id, marker) => ({
id,
image: `img/pin-${marker.content ? 'blue' : 'red'}.png`,
size: { width: 32, height: 32 },
anchor: 'bottom center',
tooltip: marker.tooltip,
style: { cursor: marker.content ? 'pointer' : 'help' },
content: marker.content,
position: marker.position
});
const getViewerOptions = (imageId) => {
const image = markerdata.images[imageId]; // Get image data
// Iterate image markers and create markers by merging shared markerdata with image-specific markerdata
const markers = Object.entries(image.markers).map(([key, marker]) => createMarker(key, Object.assign(marker, markerdata.markers[key])));
delete image.markers; // Delete 'martkers' property from image
// Build base result object
const defaultimage = {
container: 'viewer',
panorama: `img/${imageId}.jpg`,
navbar: ['zoom', 'move', 'markers', /* 'markersList', */ 'caption', 'stereo', 'gyroscope', 'fullscreen'],
plugins: [
GyroscopePlugin,
StereoPlugin,
[MarkersPlugin, {
markers,
defaultHoverScale: {
amount: 1.2,
duration: 50
}
}]
]
}
// Merge with image object and return result
return Object.assign(defaultimage, image);
};
const searchParams = new URLSearchParams(window.location.search);
const imageId = searchParams.get('i');
if (imageId in markerdata.images) {
const viewer = new Viewer(getViewerOptions(imageId));
// Uncomment below to get position on click
//viewer.addEventListener('click', ({ data }) => {
// navigator.clipboard.writeText(JSON.stringify({ position: { yaw: data.yaw, pitch: data.pitch }}, null, 2));
//});
} else {
document.getElementById("viewer").classList.add('notfound');
}
</script>
</body>
</html>