forked from mistic100/Photo-Sphere-Viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin-compass.html
More file actions
119 lines (109 loc) · 5.18 KB
/
Copy pathplugin-compass.html
File metadata and controls
119 lines (109 loc) · 5.18 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
107
108
109
110
111
112
113
114
115
116
117
118
119
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PhotoSphereViewer - compass demo</title>
<link rel="stylesheet" href="/dist/core/index.css" />
<link rel="stylesheet" href="/dist/markers-plugin/index.css" />
<link rel="stylesheet" href="/dist/compass-plugin/index.css" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="photosphere"></div>
<script type="importmap">
{
"imports": {
"three": "/node_modules/three/build/three.module.js",
"@photo-sphere-viewer/core": "/dist/core/index.module.js",
"@photo-sphere-viewer/compass-plugin": "/dist/compass-plugin/index.module.js",
"@photo-sphere-viewer/markers-plugin": "/dist/markers-plugin/index.module.js"
}
}
</script>
<script type="module">
import { Viewer } from '@photo-sphere-viewer/core';
import { CompassPlugin } from '@photo-sphere-viewer/compass-plugin';
import { MarkersPlugin } from '@photo-sphere-viewer/markers-plugin';
const baseUrl = 'https://photo-sphere-viewer-data.netlify.app/assets/';
const viewer = new Viewer({
container: 'photosphere',
panorama: baseUrl + 'sphere.jpg',
caption: 'Parc national du Mercantour <b>© Damien Sorel</b>',
loadingImg: baseUrl + 'loader.gif',
plugins: [
[CompassPlugin, {
// size: '200px',
// coneColor: 'rgba(150, 50, 50, 0.5)',
// navigationColor: 'rgba(200, 200, 0, 0.5)',
// position: 'bottom left',
// navigation: false,
hotspots: [
{ yaw: '0deg' },
{ yaw: '90deg' },
{ yaw: '180deg' },
{ yaw: '270deg' },
],
}],
[MarkersPlugin, {
markers: (() => {
const m = [];
for (let i = 0, l = Math.random() * 2 + 2; i < l; i++) {
m.push({
id: `#${i}`,
position: {
yaw: ((i + Math.random()) * 2 * Math.PI) / l,
pitch: (Math.random() * Math.PI) / 3 - Math.PI / 6,
},
image: baseUrl + 'pictos/pin-red.png',
size: { width: 32, height: 32 },
anchor: 'bottom center',
data: {
compass: '#cc3333',
},
});
}
m.push({
id: 'polygon',
// prettier-ignore
polygonPixels: [
[2941, 1413], [3042, 1402], [3222, 1419], [3433, 1463],
[3480, 1505], [3438, 1538], [3241, 1543], [3041, 1555],
[2854, 1559], [2739, 1516], [2775, 1469], [2941, 1413],
],
svgStyle: {
fill: 'rgba(255,0,0,0.2)',
stroke: 'rgba(255, 0, 50, 0.8)',
strokeWidth: '2px',
},
data: {
compass: 'rgba(255, 0, 50, 0.8)',
},
});
m.push({
id: 'polyline',
// prettier-ignore
polylinePixels: [
2478, 1635, 2184, 1747, 1674, 1953, 1166, 1852,
709, 1669, 301, 1519, 94, 1399, 34, 1356,
],
svgStyle: {
stroke: 'rgba(80, 150, 50, 0.8)',
strokeLinecap: 'round',
strokeLinejoin: 'round',
strokeWidth: '20px',
},
data: {
compass: 'rgba(80, 150, 50, 0.8)',
},
});
return m;
})(),
}],
],
});
const compass = viewer.getPlugin(CompassPlugin);
window.viewer = viewer;
</script>
</body>
</html>