Khôi phục góc nhìn và nơi đang xem sau khi reload page
This commit is contained in:
@@ -3,6 +3,14 @@ let currentHotspots = [];
|
||||
let securityApplied = false;
|
||||
let currentSceneOwnerId = null;
|
||||
|
||||
// Lưu lại góc nhìn hiện tại vào localStorage trước khi trang bị reload (F5)
|
||||
window.addEventListener('beforeunload', () => {
|
||||
if (activeViewer) {
|
||||
localStorage.setItem('activeScenePitch', activeViewer.getPitch());
|
||||
localStorage.setItem('activeSceneYaw', activeViewer.getYaw());
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Hàm render tùy chỉnh cho hotspot để hiển thị bong bóng callout kèm ảnh thumbnail.
|
||||
* Thay thế icon mặc định của Pannellum bằng cấu trúc HTML mới.
|
||||
@@ -42,8 +50,10 @@ function renderCustomHotspot(hotSpotDiv, args) {
|
||||
* @param {string} imageUrl - Authorized URL to fetch the secure image stream
|
||||
* @param {Array} hotspots - List of hotspots from the database
|
||||
* @param {string} ownerId - ID of the scene owner
|
||||
* @param {number} initialPitch - Góc nhìn dọc khởi tạo
|
||||
* @param {number} initialYaw - Góc nhìn ngang khởi tạo
|
||||
*/
|
||||
function initPanoramaViewer(imageUrl, hotspots = [], ownerId = null) {
|
||||
function initPanoramaViewer(imageUrl, hotspots = [], ownerId = null, initialPitch = 0, initialYaw = 0) {
|
||||
currentHotspots = hotspots;
|
||||
currentSceneOwnerId = ownerId;
|
||||
const container = document.getElementById('viewer-container');
|
||||
@@ -98,6 +108,8 @@ function initPanoramaViewer(imageUrl, hotspots = [], ownerId = null) {
|
||||
"type": "equirectangular",
|
||||
"panorama": imageUrl,
|
||||
"autoLoad": true,
|
||||
"pitch": initialPitch,
|
||||
"yaw": initialYaw,
|
||||
"showControls": true,
|
||||
"compass": false,
|
||||
"mouseZoom": true,
|
||||
@@ -120,6 +132,8 @@ function closeViewer() {
|
||||
localStorage.removeItem('activeSceneId');
|
||||
localStorage.removeItem('activeScenePrivacy');
|
||||
localStorage.removeItem('activeSceneToken');
|
||||
localStorage.removeItem('activeScenePitch');
|
||||
localStorage.removeItem('activeSceneYaw');
|
||||
|
||||
if (activeViewer) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user