Kaynağa Gözat

Allow hot spots to specify target HFOV and add `loadScene` method to API.

pull/124/head
Matthew Petroff 8 yıl önce
ebeveyn
işleme
06d398e350
2 değiştirilmiş dosya ile 32 ekleme ve 4 silme
  1. +4
    -0
      doc/json-config-parameters.md
  2. +28
    -4
      src/js/pannellum.js

+ 4
- 0
doc/json-config-parameters.md Dosyayı Görüntüle

@@ -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


+ 28
- 4
src/js/pannellum.js Dosyayı Görüntüle

@@ -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 {


Yükleniyor…
İptal
Kaydet