SpatialDiffusion / viewer.html
zimhe
add scripts and examples
a521a3f
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ε…¨ζ™―ε›ΎζŸ₯ηœ‹ε™¨</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pannellum@2.5.6/build/pannellum.css"/>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/pannellum@2.5.6/build/pannellum.js"></script>
<style>
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
overflow: hidden;
}
#panorama {
width: 100%;
height: 100%;
}
.pnlm-load-button {
display: none !important;
}
</style>
</head>
<body>
<div id="panorama"></div>
<script>
// 监听ζ₯θ‡ͺ爢ηͺ—ε£ηš„ζΆˆζ―
window.addEventListener('message', function(event) {
if (event.data.type === 'loadPanorama') {
console.log('Received image URL:', event.data.image);
// ι”€ζ―ηŽ°ζœ‰ηš„ζŸ₯ηœ‹ε™¨οΌˆε¦‚ζžœε­˜εœ¨οΌ‰
if (window.viewer) {
window.viewer.destroy();
}
// εˆ›ε»Ίζ–°ηš„ζŸ₯ηœ‹ε™¨
window.viewer = pannellum.viewer('panorama', {
type: 'equirectangular',
panorama: event.data.image,
autoLoad: true,
autoRotate: -2,
compass: true,
northOffset: 0,
showFullscreenCtrl: true,
showControls: true,
mouseZoom: true,
draggable: true,
friction: 0.2,
minHfov: 50,
maxHfov: 120,
hfov: 100,
onLoad: function() {
console.log('Panorama loaded successfully');
},
onError: function(error) {
console.error('Error loading panorama:', error);
}
});
}
});
</script>
</body>
</html>