forked from mistic100/Photo-Sphere-Viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadapter-equirectangular-tiles.html
More file actions
154 lines (144 loc) · 5.92 KB
/
Copy pathadapter-equirectangular-tiles.html
File metadata and controls
154 lines (144 loc) · 5.92 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PhotoSphereViewer - equirectangular tiles 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",
"@photo-sphere-viewer/core": "/dist/core/index.module.js",
"@photo-sphere-viewer/equirectangular-tiles-adapter": "/dist/equirectangular-tiles-adapter/index.module.js",
"@photo-sphere-viewer/gyroscope-plugin": "/dist/gyroscope-plugin/index.module.js"
}
}
</script>
<script type="module">
import { Viewer } from '@photo-sphere-viewer/core';
import { EquirectangularTilesAdapter } from '@photo-sphere-viewer/equirectangular-tiles-adapter';
import { GyroscopePlugin } from '@photo-sphere-viewer/gyroscope-plugin';
const baseUrl = 'https://photo-sphere-viewer-data.netlify.app/assets/';
const panos = [
{
minFov: 30,
options: {
position: {
yaw: 0,
pitch: 0,
},
zoom: 50,
caption: 'Parc national du Mercantour <b>© Damien Sorel</b>',
},
config: {
width: 6656,
cols: 16,
rows: 8,
baseUrl: `${baseUrl}sphere-small.jpg`,
tileUrl: (col, row) => {
if (row === 0 || row === 7) {
return null; // the tile won't be loaded
}
if (col === 8 && row === 4) {
return 'error.jpg';
}
const num = row * 16 + col + 1;
return `${baseUrl}sphere-tiles/image_part_${('000' + num).slice(-3)}.jpg`;
},
},
},
{
minFov: 10,
options: {
position: {
yaw: '52deg',
pitch: 0,
},
zoom: 20,
caption: "Simon's Town <b>© Greg Zall (HDRI Haven)</b>",
},
config: {
baseUrl: `${baseUrl}sphere-tiles-24k/base.jpg`,
levels: [
{
width: 6144,
cols: 16,
rows: 8,
zoomRange: [0, 30],
},
{
width: 12288,
cols: 32,
rows: 16,
zoomRange: [30, 70],
},
{
width: 24576,
cols: 64,
rows: 32,
zoomRange: [70, 100],
},
],
tileUrl: (col, row, level) => {
// skip top and bottom tiles on higher resolutions
if (
(level === 1 && (row <= 4 || row >= 14))
|| (level === 2 && (row <= 13 || row >= 29))
) {
return null;
}
if (
(level === 0 && col === 11 && row === 4)
|| (level === 1 && col === 22 && row === 8)
|| (level === 2 && col === 44 && row === 16)
) {
return 'error.jpg';
}
return `${baseUrl}sphere-tiles-24k/tile_${level}_${col}_${row}.jpg`;
},
},
},
];
const viewer = new Viewer({
container: 'photosphere',
adapter: [EquirectangularTilesAdapter, {
showErrorTile: true,
baseBlur: true,
// debug: true,
}],
plugins: [GyroscopePlugin],
loadingImg: baseUrl + 'loader.gif',
navbar: [
'zoom',
{
id: 'custom',
title: 'Change image',
className: 'custom-button',
content: '🔄',
onClick: (() => {
let i = 0;
return () => {
i = 1 - i;
loadPanorama(panos[i]);
};
})(),
},
'caption',
'gyroscope',
'fullscreen',
],
});
loadPanorama(panos[0]);
function loadPanorama(pano) {
viewer.setOption('minFov', pano.minFov);
return viewer.setPanorama(pano.config, pano.options);
}
window.viewer = viewer;
</script>
</body>
</html>