forked from mistic100/Photo-Sphere-Viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmisc-equirectangular-overlay.html
More file actions
75 lines (65 loc) · 2.67 KB
/
Copy pathmisc-equirectangular-overlay.html
File metadata and controls
75 lines (65 loc) · 2.67 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PhotoSphereViewer - equirectangular overlay demo</title>
<link rel="stylesheet" href="/dist/core/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",
"randomcolor": "https://cdn.jsdelivr.net/npm/randomcolor/+esm",
"@photo-sphere-viewer/core": "/dist/core/index.module.js"
}
}
</script>
<script type="module">
import { Viewer } from '@photo-sphere-viewer/core';
import randomColor from 'randomcolor';
const baseUrl = 'https://photo-sphere-viewer-data.netlify.app/assets/';
const viewer = new Viewer({
container: 'photosphere',
panorama: baseUrl + 'sphere.jpg',
overlay: baseUrl + 'sphere-overlay.png',
overlayOpacity: 0.8,
caption: 'Parc national du Mercantour <b>© Damien Sorel</b>',
loadingImg: baseUrl + 'loader.gif',
navbar: [
{
content: 'Remove overlay',
className: 'custom-button',
onClick: () => {
viewer.setOverlay(null);
},
},
{
content: 'Set overlay',
className: 'custom-button',
onClick: () => {
setOverlay();
},
},
],
});
function setOverlay() {
viewer.textureLoader.loadImage(baseUrl + 'sphere-overlay.png').then((image) => {
const canvas = document.createElement('canvas');
canvas.width = image.width;
canvas.height = image.height;
const ctx = canvas.getContext('2d');
ctx.drawImage(image, 0, 0);
ctx.globalCompositeOperation = 'source-in';
ctx.fillStyle = randomColor({ luminosity: 'bright' });
ctx.fillRect(0, 0, canvas.width, canvas.height);
viewer.setOverlay(canvas.toDataURL(), 0.8);
});
}
window.viewer = viewer;
</script>
</body>
</html>