|
@@ -25,18 +25,36 @@ |
|
|
document.addEventListener('contextmenu', onRightClick, false); |
|
|
document.addEventListener('contextmenu', onRightClick, false); |
|
|
|
|
|
|
|
|
// Declare variables |
|
|
// Declare variables |
|
|
var config, tourConfig = {}, configFromURL, popoutMode = false, renderer, |
|
|
|
|
|
isUserInteracting = false, onMouseDownMouseX = 0, onMouseDownMouseY = 0, |
|
|
|
|
|
onMouseDownYaw = 0, onMouseDownPitch = 0, phi = 0, theta = 0, |
|
|
|
|
|
keysDown = new Array(10), fullWindowActive = false, loaded = false, |
|
|
|
|
|
error = false, isTimedOut = false, listenersAdded = false, |
|
|
|
|
|
about_box = document.getElementById('about_box'), |
|
|
|
|
|
canvas = document.getElementById('canvas'), panoImage, prevTime, |
|
|
|
|
|
|
|
|
var config, |
|
|
|
|
|
tourConfig = {}, |
|
|
|
|
|
configFromURL, |
|
|
|
|
|
popoutMode = false, |
|
|
|
|
|
renderer, |
|
|
|
|
|
isUserInteracting = false, |
|
|
|
|
|
onPointerDownPointerX = 0, |
|
|
|
|
|
onPointerDownPointerY = 0, |
|
|
|
|
|
onPointerDownYaw = 0, |
|
|
|
|
|
onPointerDownPitch = 0, |
|
|
|
|
|
keysDown = new Array(10), |
|
|
|
|
|
fullWindowActive = false, |
|
|
|
|
|
loaded = false, |
|
|
|
|
|
error = false, |
|
|
|
|
|
isTimedOut = false, |
|
|
|
|
|
listenersAdded = false, |
|
|
|
|
|
canvas = document.getElementById('canvas'), |
|
|
|
|
|
panoImage, |
|
|
|
|
|
prevTime, |
|
|
hotspotsCreated = false; |
|
|
hotspotsCreated = false; |
|
|
|
|
|
|
|
|
var defaultConfig = { |
|
|
var defaultConfig = { |
|
|
hfov: 100, pitch: 0, yaw: 0, haov: 360, vaov: 180, voffset: 0, |
|
|
|
|
|
autoRotate: false, type: 'equirectangular' |
|
|
|
|
|
|
|
|
hfov: 100, |
|
|
|
|
|
pitch: 0, |
|
|
|
|
|
yaw: 0, |
|
|
|
|
|
haov: 360, |
|
|
|
|
|
vaov: 180, |
|
|
|
|
|
voffset: 0, |
|
|
|
|
|
autoRotate: false, |
|
|
|
|
|
type: 'equirectangular' |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
// Process options |
|
|
// Process options |
|
@@ -45,13 +63,13 @@ processOptions(); |
|
|
|
|
|
|
|
|
// Initialize viewer |
|
|
// Initialize viewer |
|
|
function init() { |
|
|
function init() { |
|
|
if(config.type == 'cubemap') { |
|
|
|
|
|
panoImage = new Array(); |
|
|
|
|
|
for(var i = 0; i < 6; i++) { |
|
|
|
|
|
|
|
|
if (config.type == 'cubemap') { |
|
|
|
|
|
panoImage = []; |
|
|
|
|
|
for (var i = 0; i < 6; i++) { |
|
|
panoImage.push(new Image()); |
|
|
panoImage.push(new Image()); |
|
|
panoImage[i].crossOrigin = "anonymous"; |
|
|
|
|
|
|
|
|
panoImage[i].crossOrigin = 'anonymous'; |
|
|
} |
|
|
} |
|
|
} else if(config.type == 'multires') { |
|
|
|
|
|
|
|
|
} else if (config.type == 'multires') { |
|
|
var c = JSON.parse(JSON.stringify(config.multiRes)); // Deep copy |
|
|
var c = JSON.parse(JSON.stringify(config.multiRes)); // Deep copy |
|
|
if (config.basePath) { |
|
|
if (config.basePath) { |
|
|
c.basePath = config.basePath + config.multiRes.basePath; |
|
|
c.basePath = config.basePath + config.multiRes.basePath; |
|
@@ -61,14 +79,14 @@ function init() { |
|
|
panoImage = c; |
|
|
panoImage = c; |
|
|
} else { |
|
|
} else { |
|
|
panoImage = new Image(); |
|
|
panoImage = new Image(); |
|
|
panoImage.crossOrigin = "anonymous"; |
|
|
|
|
|
|
|
|
panoImage.crossOrigin = 'anonymous'; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function onImageLoad() { |
|
|
function onImageLoad() { |
|
|
renderer = new libpannellum.renderer(document.getElementById('container'), panoImage, config.type); |
|
|
renderer = new libpannellum.renderer(document.getElementById('container'), panoImage, config.type); |
|
|
|
|
|
|
|
|
// Only add event listeners once |
|
|
// Only add event listeners once |
|
|
if(!listenersAdded) { |
|
|
|
|
|
|
|
|
if (!listenersAdded) { |
|
|
listenersAdded = true; |
|
|
listenersAdded = true; |
|
|
document.addEventListener('mousedown', onDocumentMouseDown, false); |
|
|
document.addEventListener('mousedown', onDocumentMouseDown, false); |
|
|
document.addEventListener('mousemove', onDocumentMouseMove, false); |
|
|
document.addEventListener('mousemove', onDocumentMouseMove, false); |
|
@@ -95,22 +113,21 @@ function init() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
renderInit(); |
|
|
renderInit(); |
|
|
var t = setTimeout('isTimedOut = true', 500); |
|
|
|
|
|
|
|
|
setTimeout(function(){isTimedOut = true;}, 500); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Configure image loading |
|
|
// Configure image loading |
|
|
if(config.type == "cubemap") { |
|
|
|
|
|
|
|
|
if (config.type == 'cubemap') { |
|
|
// Quick loading counter for synchronous loading |
|
|
// Quick loading counter for synchronous loading |
|
|
var itemsToLoad = 6; |
|
|
var itemsToLoad = 6; |
|
|
function loadCounter() { |
|
|
|
|
|
itemsToLoad--; |
|
|
|
|
|
if(itemsToLoad == 0) { |
|
|
|
|
|
onImageLoad(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for(var i = 0; i < panoImage.length; i++) { |
|
|
|
|
|
panoImage[i].onload = loadCounter; |
|
|
|
|
|
|
|
|
for (var i = 0; i < panoImage.length; i++) { |
|
|
|
|
|
panoImage[i].onload = function() { |
|
|
|
|
|
itemsToLoad--; |
|
|
|
|
|
if (itemsToLoad === 0) { |
|
|
|
|
|
onImageLoad(); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
var p = config.cubeMap[i]; |
|
|
var p = config.cubeMap[i]; |
|
|
if (config.basePath) { |
|
|
if (config.basePath) { |
|
|
p = config.basePath + p; |
|
|
p = config.basePath + p; |
|
@@ -119,7 +136,7 @@ function init() { |
|
|
} |
|
|
} |
|
|
panoImage[i].src = p; |
|
|
panoImage[i].src = p; |
|
|
} |
|
|
} |
|
|
} else if(config.type == "multires") { |
|
|
|
|
|
|
|
|
} else if (config.type == 'multires') { |
|
|
onImageLoad(); |
|
|
onImageLoad(); |
|
|
} else { |
|
|
} else { |
|
|
panoImage.onload = onImageLoad; |
|
|
panoImage.onload = onImageLoad; |
|
@@ -180,12 +197,12 @@ function onDocumentMouseMove(event) { |
|
|
if (isUserInteracting) { |
|
|
if (isUserInteracting) { |
|
|
//TODO: This still isn't quite right |
|
|
//TODO: This still isn't quite right |
|
|
config.yaw = ((Math.atan(onPointerDownPointerX / canvas.width * 2 - 1) - Math.atan(event.clientX / canvas.width * 2 - 1)) * 180 / Math.PI * config.hfov / 90) + onPointerDownYaw; |
|
|
config.yaw = ((Math.atan(onPointerDownPointerX / canvas.width * 2 - 1) - Math.atan(event.clientX / canvas.width * 2 - 1)) * 180 / Math.PI * config.hfov / 90) + onPointerDownYaw; |
|
|
vfov = 2 * Math.atan(Math.tan(config.hfov/360*Math.PI) * canvas.height / canvas.width) * 180 / Math.PI; |
|
|
|
|
|
|
|
|
var vfov = 2 * Math.atan(Math.tan(config.hfov/360*Math.PI) * canvas.height / canvas.width) * 180 / Math.PI; |
|
|
config.pitch = ((Math.atan(event.clientY / canvas.height * 2 - 1) - Math.atan(onPointerDownPointerY / canvas.height * 2 - 1)) * 180 / Math.PI * vfov / 90) + onPointerDownPitch; |
|
|
config.pitch = ((Math.atan(event.clientY / canvas.height * 2 - 1) - Math.atan(onPointerDownPointerY / canvas.height * 2 - 1)) * 180 / Math.PI * vfov / 90) + onPointerDownPitch; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function onDocumentMouseUp(event) { |
|
|
|
|
|
|
|
|
function onDocumentMouseUp() { |
|
|
isUserInteracting = false; |
|
|
isUserInteracting = false; |
|
|
document.getElementById('page').className = 'grab'; |
|
|
document.getElementById('page').className = 'grab'; |
|
|
} |
|
|
} |
|
@@ -207,7 +224,7 @@ function onDocumentTouchMove(event) { |
|
|
animate(); |
|
|
animate(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function onDocumentTouchEnd(event) { |
|
|
|
|
|
|
|
|
function onDocumentTouchEnd() { |
|
|
// Do nothing for now |
|
|
// Do nothing for now |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -236,15 +253,15 @@ function onDocumentKeyPress(event) { |
|
|
config.autoRotate = false; |
|
|
config.autoRotate = false; |
|
|
|
|
|
|
|
|
// Record key pressed |
|
|
// Record key pressed |
|
|
keynumber = event.keycode; |
|
|
|
|
|
if(event.which) { |
|
|
|
|
|
|
|
|
var keynumber = event.keycode; |
|
|
|
|
|
if (event.which) { |
|
|
keynumber = event.which; |
|
|
keynumber = event.which; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// If escape key is pressed |
|
|
// If escape key is pressed |
|
|
if(keynumber == 27) { |
|
|
|
|
|
|
|
|
if (keynumber == 27) { |
|
|
// If in full window / popout mode |
|
|
// If in full window / popout mode |
|
|
if(fullWindowActive || popoutMode) { |
|
|
|
|
|
|
|
|
if (fullWindowActive || popoutMode) { |
|
|
toggleFullWindow(); |
|
|
toggleFullWindow(); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
@@ -254,7 +271,7 @@ function onDocumentKeyPress(event) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function clearKeys() { |
|
|
function clearKeys() { |
|
|
for(i = 0; i < 10; i++) { |
|
|
|
|
|
|
|
|
for (var i = 0; i < 10; i++) { |
|
|
keysDown[i] = false; |
|
|
keysDown[i] = false; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -264,8 +281,8 @@ function onDocumentKeyUp(event) { |
|
|
event.preventDefault(); |
|
|
event.preventDefault(); |
|
|
|
|
|
|
|
|
// Record key released |
|
|
// Record key released |
|
|
keynumber = event.keycode; |
|
|
|
|
|
if(event.which) { |
|
|
|
|
|
|
|
|
var keynumber = event.keycode; |
|
|
|
|
|
if (event.which) { |
|
|
keynumber = event.which; |
|
|
keynumber = event.which; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -278,56 +295,56 @@ function changeKey(keynumber, value) { |
|
|
switch(keynumber) { |
|
|
switch(keynumber) { |
|
|
// If minus key is released |
|
|
// If minus key is released |
|
|
case 109: case 189: case 17: |
|
|
case 109: case 189: case 17: |
|
|
if(keysDown[0] != value) { keyChanged = true; } |
|
|
|
|
|
|
|
|
if (keysDown[0] != value) { keyChanged = true; } |
|
|
keysDown[0] = value; break; |
|
|
keysDown[0] = value; break; |
|
|
|
|
|
|
|
|
// If plus key is released |
|
|
// If plus key is released |
|
|
case 107: case 187: case 16: |
|
|
case 107: case 187: case 16: |
|
|
if(keysDown[1] != value) { keyChanged = true; } |
|
|
|
|
|
|
|
|
if (keysDown[1] != value) { keyChanged = true; } |
|
|
keysDown[1] = value; break; |
|
|
keysDown[1] = value; break; |
|
|
|
|
|
|
|
|
// If up arrow is released |
|
|
// If up arrow is released |
|
|
case 38: |
|
|
case 38: |
|
|
if(keysDown[2] != value) { keyChanged = true; } |
|
|
|
|
|
|
|
|
if (keysDown[2] != value) { keyChanged = true; } |
|
|
keysDown[2] = value; break; |
|
|
keysDown[2] = value; break; |
|
|
|
|
|
|
|
|
// If "w" is released |
|
|
// If "w" is released |
|
|
case 87: |
|
|
case 87: |
|
|
if(keysDown[6] != value) { keyChanged = true; } |
|
|
|
|
|
|
|
|
if (keysDown[6] != value) { keyChanged = true; } |
|
|
keysDown[6] = value; break; |
|
|
keysDown[6] = value; break; |
|
|
|
|
|
|
|
|
// If down arrow is released |
|
|
// If down arrow is released |
|
|
case 40: |
|
|
case 40: |
|
|
if(keysDown[3] != value) { keyChanged = true; } |
|
|
|
|
|
|
|
|
if (keysDown[3] != value) { keyChanged = true; } |
|
|
keysDown[3] = value; break; |
|
|
keysDown[3] = value; break; |
|
|
|
|
|
|
|
|
// If "s" is released |
|
|
// If "s" is released |
|
|
case 83: |
|
|
case 83: |
|
|
if(keysDown[7] != value) { keyChanged = true; } |
|
|
|
|
|
|
|
|
if (keysDown[7] != value) { keyChanged = true; } |
|
|
keysDown[7] = value; break; |
|
|
keysDown[7] = value; break; |
|
|
|
|
|
|
|
|
// If left arrow is released |
|
|
// If left arrow is released |
|
|
case 37: |
|
|
case 37: |
|
|
if(keysDown[4] != value) { keyChanged = true; } |
|
|
|
|
|
|
|
|
if (keysDown[4] != value) { keyChanged = true; } |
|
|
keysDown[4] = value; break; |
|
|
keysDown[4] = value; break; |
|
|
|
|
|
|
|
|
// If "a" is released |
|
|
// If "a" is released |
|
|
case 65: |
|
|
case 65: |
|
|
if(keysDown[8] != value) { keyChanged = true; } |
|
|
|
|
|
|
|
|
if (keysDown[8] != value) { keyChanged = true; } |
|
|
keysDown[8] = value; break; |
|
|
keysDown[8] = value; break; |
|
|
|
|
|
|
|
|
// If right arrow is released |
|
|
// If right arrow is released |
|
|
case 39: |
|
|
case 39: |
|
|
if(keysDown[5] != value) { keyChanged = true; } |
|
|
|
|
|
|
|
|
if (keysDown[5] != value) { keyChanged = true; } |
|
|
keysDown[5] = value; break; |
|
|
keysDown[5] = value; break; |
|
|
|
|
|
|
|
|
// If "d" is released |
|
|
// If "d" is released |
|
|
case 68: |
|
|
case 68: |
|
|
if(keysDown[9] != value) { keyChanged = true; } |
|
|
|
|
|
|
|
|
if (keysDown[9] != value) { keyChanged = true; } |
|
|
keysDown[9] = value; |
|
|
keysDown[9] = value; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(keyChanged && value) { |
|
|
|
|
|
|
|
|
if (keyChanged && value) { |
|
|
if (performance.now()) { |
|
|
if (performance.now()) { |
|
|
prevTime = performance.now(); |
|
|
prevTime = performance.now(); |
|
|
} else { |
|
|
} else { |
|
@@ -347,43 +364,43 @@ function keyRepeat() { |
|
|
var diff = (newTime - prevTime) * config.hfov / 1700; |
|
|
var diff = (newTime - prevTime) * config.hfov / 1700; |
|
|
|
|
|
|
|
|
// If minus key is down |
|
|
// If minus key is down |
|
|
if(keysDown[0]) { |
|
|
|
|
|
|
|
|
if (keysDown[0]) { |
|
|
zoomOut(diff); |
|
|
zoomOut(diff); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// If plus key is down |
|
|
// If plus key is down |
|
|
if(keysDown[1]) { |
|
|
|
|
|
|
|
|
if (keysDown[1]) { |
|
|
zoomIn(diff); |
|
|
zoomIn(diff); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// If up arrow or "w" is down |
|
|
// If up arrow or "w" is down |
|
|
if(keysDown[2] || keysDown[6]) { |
|
|
|
|
|
|
|
|
if (keysDown[2] || keysDown[6]) { |
|
|
// Pan up |
|
|
// Pan up |
|
|
config.pitch += diff; |
|
|
config.pitch += diff; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// If down arrow or "s" is down |
|
|
// If down arrow or "s" is down |
|
|
if(keysDown[3] || keysDown[7]) { |
|
|
|
|
|
|
|
|
if (keysDown[3] || keysDown[7]) { |
|
|
// Pan down |
|
|
// Pan down |
|
|
config.pitch -= diff; |
|
|
config.pitch -= diff; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// If left arrow or "a" is down |
|
|
// If left arrow or "a" is down |
|
|
if(keysDown[4] || keysDown[8]) { |
|
|
|
|
|
|
|
|
if (keysDown[4] || keysDown[8]) { |
|
|
// Pan left |
|
|
// Pan left |
|
|
config.yaw -= diff; |
|
|
config.yaw -= diff; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// If right arrow or "d" is down |
|
|
// If right arrow or "d" is down |
|
|
if(keysDown[5] || keysDown[9]) { |
|
|
|
|
|
|
|
|
if (keysDown[5] || keysDown[9]) { |
|
|
// Pan right |
|
|
// Pan right |
|
|
config.yaw += diff; |
|
|
config.yaw += diff; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// If auto-rotate |
|
|
// If auto-rotate |
|
|
if(config.autoRotate) { |
|
|
|
|
|
|
|
|
if (config.autoRotate) { |
|
|
// Pan |
|
|
// Pan |
|
|
if(diff > 0.000001) { |
|
|
|
|
|
|
|
|
if (diff > 0.000001) { |
|
|
config.yaw -= config.autoRotate / 60 * diff; |
|
|
config.yaw -= config.autoRotate / 60 * diff; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -401,23 +418,23 @@ function onDocumentResize() { |
|
|
|
|
|
|
|
|
function animate() { |
|
|
function animate() { |
|
|
render(); |
|
|
render(); |
|
|
if(isUserInteracting) { |
|
|
|
|
|
|
|
|
if (isUserInteracting) { |
|
|
requestAnimationFrame(animate); |
|
|
requestAnimationFrame(animate); |
|
|
} else if(keysDown[0] || keysDown[1] || keysDown[2] || keysDown[3] |
|
|
|
|
|
|
|
|
} else if (keysDown[0] || keysDown[1] || keysDown[2] || keysDown[3] |
|
|
|| keysDown[4] || keysDown[5] || keysDown[6] || keysDown[7] |
|
|
|| keysDown[4] || keysDown[5] || keysDown[6] || keysDown[7] |
|
|
|| keysDown[8] || keysDown[9] || config.autoRotate) { |
|
|
|| keysDown[8] || keysDown[9] || config.autoRotate) { |
|
|
keyRepeat(); |
|
|
keyRepeat(); |
|
|
requestAnimationFrame(animate); |
|
|
requestAnimationFrame(animate); |
|
|
} else if(renderer && renderer.isLoading()) { |
|
|
|
|
|
|
|
|
} else if (renderer && renderer.isLoading()) { |
|
|
requestAnimationFrame(animate); |
|
|
requestAnimationFrame(animate); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function render() { |
|
|
function render() { |
|
|
try { |
|
|
try { |
|
|
if(config.yaw > 180) { |
|
|
|
|
|
|
|
|
if (config.yaw > 180) { |
|
|
config.yaw -= 360; |
|
|
config.yaw -= 360; |
|
|
} else if(config.yaw < -180) { |
|
|
|
|
|
|
|
|
} else if (config.yaw < -180) { |
|
|
config.yaw += 360; |
|
|
config.yaw += 360; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -468,7 +485,7 @@ function renderInit() { |
|
|
function createHotSpots() { |
|
|
function createHotSpots() { |
|
|
if (hotspotsCreated) return; |
|
|
if (hotspotsCreated) return; |
|
|
|
|
|
|
|
|
if(!config.hotSpots) { |
|
|
|
|
|
|
|
|
if (!config.hotSpots) { |
|
|
config.hotSpots = []; |
|
|
config.hotSpots = []; |
|
|
} else { |
|
|
} else { |
|
|
config.hotSpots.forEach(function(hs) { |
|
|
config.hotSpots.forEach(function(hs) { |
|
@@ -478,7 +495,7 @@ function createHotSpots() { |
|
|
var span = document.createElement('span'); |
|
|
var span = document.createElement('span'); |
|
|
span.innerHTML = hs.text; |
|
|
span.innerHTML = hs.text; |
|
|
|
|
|
|
|
|
if(hs.URL) { |
|
|
|
|
|
|
|
|
if (hs.URL) { |
|
|
var a = document.createElement('a'); |
|
|
var a = document.createElement('a'); |
|
|
a.setAttribute('href', hs.URL); |
|
|
a.setAttribute('href', hs.URL); |
|
|
a.setAttribute('target', '_blank'); |
|
|
a.setAttribute('target', '_blank'); |
|
@@ -505,7 +522,7 @@ function createHotSpots() { |
|
|
a.appendChild(image); |
|
|
a.appendChild(image); |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
if(hs.sceneId) { |
|
|
|
|
|
|
|
|
if (hs.sceneId) { |
|
|
div.onclick = function() { |
|
|
div.onclick = function() { |
|
|
loadScene(hs.sceneId); |
|
|
loadScene(hs.sceneId); |
|
|
return false; |
|
|
return false; |
|
@@ -528,7 +545,7 @@ function createHotSpots() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function destroyHotSpots() { |
|
|
function destroyHotSpots() { |
|
|
if(config.hotSpots) { |
|
|
|
|
|
|
|
|
if (config.hotSpots) { |
|
|
config.hotSpots.forEach(function(hs) { |
|
|
config.hotSpots.forEach(function(hs) { |
|
|
var current = hs.div; |
|
|
var current = hs.div; |
|
|
while(current.parentNode.id != 'page') { |
|
|
while(current.parentNode.id != 'page') { |
|
@@ -545,7 +562,7 @@ function renderHotSpots() { |
|
|
var z = Math.sin(hs.pitch * Math.PI / 180) * Math.sin(config.pitch * Math.PI / |
|
|
var z = Math.sin(hs.pitch * Math.PI / 180) * Math.sin(config.pitch * Math.PI / |
|
|
180) + Math.cos(hs.pitch * Math.PI / 180) * Math.cos((hs.yaw + config.yaw) * |
|
|
180) + Math.cos(hs.pitch * Math.PI / 180) * Math.cos((hs.yaw + config.yaw) * |
|
|
Math.PI / 180) * Math.cos(config.pitch * Math.PI / 180); |
|
|
Math.PI / 180) * Math.cos(config.pitch * Math.PI / 180); |
|
|
if((hs.yaw <= 90 && hs.yaw > -90 && z <= 0) || |
|
|
|
|
|
|
|
|
if ((hs.yaw <= 90 && hs.yaw > -90 && z <= 0) || |
|
|
((hs.yaw > 90 || hs.yaw <= -90) && z <= 0)) { |
|
|
((hs.yaw > 90 || hs.yaw <= -90) && z <= 0)) { |
|
|
hs.div.style.visibility = 'hidden'; |
|
|
hs.div.style.visibility = 'hidden'; |
|
|
} else { |
|
|
} else { |
|
@@ -563,11 +580,11 @@ function renderHotSpots() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function parseURLParameters() { |
|
|
function parseURLParameters() { |
|
|
var URL = unescape(window.location.href).split('?'); |
|
|
|
|
|
|
|
|
var URL = decodeURI(window.location.href).split('?'); |
|
|
URL.shift(); |
|
|
URL.shift(); |
|
|
URL = URL[0].split('&'); |
|
|
URL = URL[0].split('&'); |
|
|
var json = '{'; |
|
|
var json = '{'; |
|
|
for(var i = 0; i < URL.length; i++) { |
|
|
|
|
|
|
|
|
for (var i = 0; i < URL.length; i++) { |
|
|
var option = URL[i].split('=')[0]; |
|
|
var option = URL[i].split('=')[0]; |
|
|
var value = URL[i].split('=')[1]; |
|
|
var value = URL[i].split('=')[1]; |
|
|
json += '"' + option + '":'; |
|
|
json += '"' + option + '":'; |
|
@@ -579,7 +596,7 @@ function parseURLParameters() { |
|
|
default: |
|
|
default: |
|
|
json += '"' + value + '"'; |
|
|
json += '"' + value + '"'; |
|
|
} |
|
|
} |
|
|
if(i < URL.length - 1) { |
|
|
|
|
|
|
|
|
if (i < URL.length - 1) { |
|
|
json += ','; |
|
|
json += ','; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -587,7 +604,7 @@ function parseURLParameters() { |
|
|
configFromURL = JSON.parse(json); |
|
|
configFromURL = JSON.parse(json); |
|
|
|
|
|
|
|
|
// Check for JSON configuration file |
|
|
// Check for JSON configuration file |
|
|
if(configFromURL.config) { |
|
|
|
|
|
|
|
|
if (configFromURL.config) { |
|
|
// Get JSON configuration file |
|
|
// Get JSON configuration file |
|
|
var request = new XMLHttpRequest(); |
|
|
var request = new XMLHttpRequest(); |
|
|
request.open('GET', configFromURL.config, false); |
|
|
request.open('GET', configFromURL.config, false); |
|
@@ -598,8 +615,8 @@ function parseURLParameters() { |
|
|
c.basePath = configFromURL.config.substring(0,configFromURL.config.lastIndexOf('/')+1); |
|
|
c.basePath = configFromURL.config.substring(0,configFromURL.config.lastIndexOf('/')+1); |
|
|
|
|
|
|
|
|
// Merge options |
|
|
// Merge options |
|
|
for(var k in c) { |
|
|
|
|
|
if(!configFromURL[k]) { |
|
|
|
|
|
|
|
|
for (var k in c) { |
|
|
|
|
|
if (!configFromURL[k]) { |
|
|
configFromURL[k] = c[k]; |
|
|
configFromURL[k] = c[k]; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -607,7 +624,7 @@ function parseURLParameters() { |
|
|
|
|
|
|
|
|
// Check for virtual tour JSON configuration file |
|
|
// Check for virtual tour JSON configuration file |
|
|
var firstScene = null; |
|
|
var firstScene = null; |
|
|
if(configFromURL.tour) { |
|
|
|
|
|
|
|
|
if (configFromURL.tour) { |
|
|
// Get JSON configuration file |
|
|
// Get JSON configuration file |
|
|
var request = new XMLHttpRequest(); |
|
|
var request = new XMLHttpRequest(); |
|
|
request.open('GET', configFromURL.tour, false); |
|
|
request.open('GET', configFromURL.tour, false); |
|
@@ -618,10 +635,10 @@ function parseURLParameters() { |
|
|
tourConfig.basePath = configFromURL.tour.substring(0,configFromURL.tour.lastIndexOf('/')+1); |
|
|
tourConfig.basePath = configFromURL.tour.substring(0,configFromURL.tour.lastIndexOf('/')+1); |
|
|
|
|
|
|
|
|
// Activate first scene if specified |
|
|
// Activate first scene if specified |
|
|
if(tourConfig.default.firstScene) { |
|
|
|
|
|
|
|
|
if (tourConfig.default.firstScene) { |
|
|
firstScene = tourConfig.default.firstScene; |
|
|
firstScene = tourConfig.default.firstScene; |
|
|
} |
|
|
} |
|
|
if(configFromURL.firstScene) { |
|
|
|
|
|
|
|
|
if (configFromURL.firstScene) { |
|
|
firstScene = configFromURL.firstScene; |
|
|
firstScene = configFromURL.firstScene; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -633,32 +650,32 @@ function mergeConfig(sceneId) { |
|
|
config = {}; |
|
|
config = {}; |
|
|
|
|
|
|
|
|
// Merge default config |
|
|
// Merge default config |
|
|
for(var k in defaultConfig) { |
|
|
|
|
|
|
|
|
for (var k in defaultConfig) { |
|
|
config[k] = defaultConfig[k]; |
|
|
config[k] = defaultConfig[k]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Merge default scene config |
|
|
// Merge default scene config |
|
|
for(var k in tourConfig.default) { |
|
|
|
|
|
|
|
|
for (var k in tourConfig.default) { |
|
|
config[k] = tourConfig.default[k]; |
|
|
config[k] = tourConfig.default[k]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Merge current scene config |
|
|
// Merge current scene config |
|
|
if((sceneId != null) && (sceneId != '') && (tourConfig.scenes) && (tourConfig.scenes[sceneId])) { |
|
|
|
|
|
|
|
|
if ((sceneId !== null) && (sceneId !== '') && (tourConfig.scenes) && (tourConfig.scenes[sceneId])) { |
|
|
var scene = tourConfig.scenes[sceneId]; |
|
|
var scene = tourConfig.scenes[sceneId]; |
|
|
for(var k in scene) { |
|
|
|
|
|
|
|
|
for (var k in scene) { |
|
|
config[k] = scene[k]; |
|
|
config[k] = scene[k]; |
|
|
} |
|
|
} |
|
|
config.activeScene = sceneId; |
|
|
config.activeScene = sceneId; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Merge URL and config file |
|
|
// Merge URL and config file |
|
|
for(var k in configFromURL) { |
|
|
|
|
|
|
|
|
for (var k in configFromURL) { |
|
|
config[k] = configFromURL[k]; |
|
|
config[k] = configFromURL[k]; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function processOptions() { |
|
|
function processOptions() { |
|
|
for(var key in config) { |
|
|
|
|
|
|
|
|
for (var key in config) { |
|
|
switch(key) { |
|
|
switch(key) { |
|
|
case 'title': |
|
|
case 'title': |
|
|
document.getElementById('title_box').innerHTML = config[key]; |
|
|
document.getElementById('title_box').innerHTML = config[key]; |
|
@@ -671,7 +688,7 @@ function processOptions() { |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case 'popout': |
|
|
case 'popout': |
|
|
if(config[key] == 'yes') { |
|
|
|
|
|
|
|
|
if (config[key] == 'yes') { |
|
|
document.getElementById('fullwindowtoggle_button').classList.add('fullwindowtoggle_button_active'); |
|
|
document.getElementById('fullwindowtoggle_button').classList.add('fullwindowtoggle_button_active'); |
|
|
popoutMode = true; |
|
|
popoutMode = true; |
|
|
} |
|
|
} |
|
@@ -689,7 +706,7 @@ function processOptions() { |
|
|
p = tourConfig.basePath + p; |
|
|
p = tourConfig.basePath + p; |
|
|
} |
|
|
} |
|
|
document.body.style.backgroundImage = "url('" + p + "')"; |
|
|
document.body.style.backgroundImage = "url('" + p + "')"; |
|
|
document.body.style.backgroundSize = "auto"; |
|
|
|
|
|
|
|
|
document.body.style.backgroundSize = 'auto'; |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case 'hfov': |
|
|
case 'hfov': |
|
@@ -698,15 +715,15 @@ function processOptions() { |
|
|
|
|
|
|
|
|
case 'pitch': |
|
|
case 'pitch': |
|
|
// Keep pitch within bounds |
|
|
// Keep pitch within bounds |
|
|
if(config.pitch < -85) { |
|
|
|
|
|
|
|
|
if (config.pitch < -85) { |
|
|
config.pitch = -85; |
|
|
config.pitch = -85; |
|
|
} else if(config.pitch > 85) { |
|
|
|
|
|
|
|
|
} else if (config.pitch > 85) { |
|
|
config.pitch = 85; |
|
|
config.pitch = 85; |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case 'autoload': |
|
|
case 'autoload': |
|
|
if(config[key] == 'yes') { |
|
|
|
|
|
|
|
|
if (config[key] == 'yes') { |
|
|
// Show loading box |
|
|
// Show loading box |
|
|
document.getElementById('load_box').style.display = 'inline'; |
|
|
document.getElementById('load_box').style.display = 'inline'; |
|
|
} |
|
|
} |
|
@@ -731,8 +748,8 @@ function processOptions() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function toggleFullWindow() { |
|
|
function toggleFullWindow() { |
|
|
if(loaded && !error) { |
|
|
|
|
|
if(!fullWindowActive && !popoutMode) { |
|
|
|
|
|
|
|
|
if (loaded && !error) { |
|
|
|
|
|
if (!fullWindowActive && !popoutMode) { |
|
|
try { |
|
|
try { |
|
|
var page = document.getElementById('page'); |
|
|
var page = document.getElementById('page'); |
|
|
if (page.requestFullscreen) { |
|
|
if (page.requestFullscreen) { |
|
@@ -758,7 +775,7 @@ function toggleFullWindow() { |
|
|
document.msExitFullscreen(); |
|
|
document.msExitFullscreen(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(popoutMode) { |
|
|
|
|
|
|
|
|
if (popoutMode) { |
|
|
window.close(); |
|
|
window.close(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -766,7 +783,7 @@ function toggleFullWindow() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function onFullScreenChange() { |
|
|
function onFullScreenChange() { |
|
|
if(document.fullscreen || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement) { |
|
|
|
|
|
|
|
|
if (document.fullscreen || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement) { |
|
|
document.getElementById('fullwindowtoggle_button').classList.add('fullwindowtoggle_button_active'); |
|
|
document.getElementById('fullwindowtoggle_button').classList.add('fullwindowtoggle_button_active'); |
|
|
fullWindowActive = true; |
|
|
fullWindowActive = true; |
|
|
} else { |
|
|
} else { |
|
@@ -776,37 +793,37 @@ function onFullScreenChange() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function fullScreenError() { |
|
|
function fullScreenError() { |
|
|
if(!popoutMode) { |
|
|
|
|
|
|
|
|
if (!popoutMode) { |
|
|
// Open new window instead |
|
|
// Open new window instead |
|
|
var windowspecs = 'width=' + screen.width + ',height=' + screen.height + ',left=0,top=0'; |
|
|
var windowspecs = 'width=' + screen.width + ',height=' + screen.height + ',left=0,top=0'; |
|
|
var windowlocation = window.location.href + '&popout=yes'; |
|
|
var windowlocation = window.location.href + '&popout=yes'; |
|
|
windowlocation += '&popoutautoload'; |
|
|
windowlocation += '&popoutautoload'; |
|
|
window.open(windowlocation,null,windowspecs) |
|
|
|
|
|
|
|
|
window.open(windowlocation, null, windowspecs); |
|
|
} else { |
|
|
} else { |
|
|
window.close(); |
|
|
window.close(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function zoomIn(amount) { |
|
|
function zoomIn(amount) { |
|
|
if(loaded) { |
|
|
|
|
|
|
|
|
if (loaded) { |
|
|
setHfov(config.hfov -= amount); |
|
|
setHfov(config.hfov -= amount); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function zoomOut(amount) { |
|
|
function zoomOut(amount) { |
|
|
if(loaded) { |
|
|
|
|
|
|
|
|
if (loaded) { |
|
|
setHfov(config.hfov += amount); |
|
|
setHfov(config.hfov += amount); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function setHfov(i) { |
|
|
function setHfov(i) { |
|
|
// Keep field of view within bounds |
|
|
// Keep field of view within bounds |
|
|
if(i < 50 && config.type != 'multires') { |
|
|
|
|
|
|
|
|
if (i < 50 && config.type != 'multires') { |
|
|
config.hfov = 50; |
|
|
config.hfov = 50; |
|
|
} else if(config.type == 'multires' && i < canvas.width |
|
|
|
|
|
|
|
|
} else if (config.type == 'multires' && i < canvas.width |
|
|
/ (config.multiRes.cubeResolution / 90 * 0.9)) { |
|
|
/ (config.multiRes.cubeResolution / 90 * 0.9)) { |
|
|
config.hfov = canvas.width / (config.multiRes.cubeResolution / 90 * 0.9); |
|
|
config.hfov = canvas.width / (config.multiRes.cubeResolution / 90 * 0.9); |
|
|
} else if(i > 120) { |
|
|
|
|
|
|
|
|
} else if (i > 120) { |
|
|
config.hfov = 120; |
|
|
config.hfov = 120; |
|
|
} else { |
|
|
} else { |
|
|
config.hfov = i; |
|
|
config.hfov = i; |
|
|