diff --git a/doc/json-config-parameters.md b/doc/json-config-parameters.md index c7ab4c6..aec0339 100644 --- a/doc/json-config-parameters.md +++ b/doc/json-config-parameters.md @@ -175,6 +175,10 @@ Specifies the pitch of the target scene. Specifies the yaw of the target scene. +#### `targetHfov` + +Specifies the HFOV of the target scene. + ### `hotSpotDebug` When `true`, the mouse pointer's pitch and yaw are logged to the console when diff --git a/src/js/pannellum.js b/src/js/pannellum.js index f59a477..b4217a3 100644 --- a/src/js/pannellum.js +++ b/src/js/pannellum.js @@ -1272,11 +1272,11 @@ function createHotSpots() { } else { if (hs.sceneId) { div.onclick = function() { - loadScene(hs.sceneId, hs.targetPitch, hs.targetYaw); + loadScene(hs.sceneId, hs.targetPitch, hs.targetYaw, hs.targetHfov); return false; }; div.ontouchend = function() { - loadScene(hs.sceneId, hs.targetPitch, hs.targetYaw); + loadScene(hs.sceneId, hs.targetPitch, hs.targetYaw, hs.targetHfov); return false; }; div.style.cursor = 'pointer'; @@ -1599,13 +1599,14 @@ function load() { * @param {string} sceneId - Identifier of scene configuration to merge in. * @param {number} targetPitch - Pitch viewer should be centered on once scene loads. * @param {number} targetYaw - Yaw viewer should be centered on once scene loads. + * @param {number} targetHfov - HFOV viewer should use once scene loads. */ -function loadScene(sceneId, targetPitch, targetYaw) { +function loadScene(sceneId, targetPitch, targetYaw, targetHfov) { loaded = false; oldRenderer = renderer; // Set up fade if specified - var fadeImg, workingPitch, workingYaw; + var fadeImg, workingPitch, workingYaw, workingHfov; if (config.sceneFadeDuration) { fadeImg = new Image(); fadeImg.className = 'pnlm-fade-img'; @@ -1633,6 +1634,11 @@ function loadScene(sceneId, targetPitch, targetYaw) { } else { workingYaw = targetYaw; } + if (targetHfov === 'same') { + workingHfov = config.hfov; + } else { + workingHfov = targetHfov; + } // Destroy hot spots from previous scene destroyHotSpots(); @@ -1648,6 +1654,9 @@ function loadScene(sceneId, targetPitch, targetYaw) { if (workingYaw) { config.yaw = workingYaw; } + if (workingHfov) { + config.hfov = workingHfov; + } load(); } @@ -1845,6 +1854,21 @@ this.mouseEventToCoords = function(event) { return mouseEventToCoords(event); } +/** + * Change scene being viewed. + * @memberof Viewer + * @instance + * @param {string} sceneId - Identifier of scene to switch to. + * @param {number} [pitch] - Pitch to use with new scene + * @param {number} [yaw] - Yaw to use with new scene + * @param {number} [hfov] - HFOV to use with new scene + * @returns {Viewer} `this` + */ +this.loadScene = function(sceneId, pitch, yaw, hfov) { + loadScene(sceneId, pitch, yaw, hfov); + return this; +} + } return {