Kaynağa Gözat

Added auto-rotation.

pull/1/merge
Matthew Petroff 12 yıl önce
ebeveyn
işleme
137fa136d2
2 değiştirilmiş dosya ile 39 ekleme ve 1 silme
  1. +10
    -1
      configuration.htm
  2. +29
    -0
      src/js/pannellum.js

+ 10
- 1
configuration.htm Dosyayı Görüntüle

@@ -30,6 +30,9 @@
if(form.autoload.checked) {
embed_code.innerHTML += '&autoload=yes';
}
if(form.autorotate.value != 'none') {
embed_code.innerHTML += '&autorotate=' + escape(form.autorotate.value);
}
if(form.license.value > -1) {
embed_code.innerHTML += '&license=' + escape(form.license.value);
}
@@ -77,9 +80,15 @@
Embed Size:<br>
<input name="embed_width" type="number" min="200" placeholder="Width" required> <input name="embed_height" type="number" min="150" placeholder="Height" required><p>
Initial Parameters:<br>
<input name="fov" type="number" min="40" max="100" placeholder="Field of View"> <input name="lat" type="number" min="-85" max "85" placeholder="Lat"> <input name="lon" type="number" min="-180" max "180" placeholder="Lon"><p>
<input name="fov" type="number" min="40" max="100" placeholder="Field of View"> <input name="lat" type="number" min="-85" max="85" placeholder="Lat"> <input name="lon" type="number" min="-180" max="180" placeholder="Lon"><p>
Include Pannellum Logo: <input name="use_logo" type="checkbox"><p>
Auto Load: <input name="autoload" type="checkbox"><p>
Auto Rotate:
<select name="autorotate">
<option value="none">None</option>
<option value="cw">CW</option>
<option value="ccw">CCW</option>
</select><p>
Creative Commons License:
<select name="license">
<option value="-1">None</option>


+ 29
- 0
src/js/pannellum.js Dosyayı Görüntüle

@@ -126,6 +126,15 @@ if(getURLParameter('autoload') == 'yes' || getURLParameter('popoutautoload') ==
document.getElementById('load_button').style.display = 'table';
}

var autoRotate = false;

if(getURLParameter('autorotate') == 'cw') {
autoRotate = 'cw';
}
if(getURLParameter('autorotate') == 'ccw') {
autoRotate = 'ccw';
}

function init() {
var container, mesh;
@@ -213,6 +222,9 @@ function onDocumentMouseDown(event) {
// but not all of it
window.focus();
// turn off auto-rotation if enabled
autoRotate = false;
isUserInteracting = true;
onPointerDownPointerX = event.clientX;
@@ -287,6 +299,9 @@ function onDocumentKeyPress(event) {
// override default action
event.preventDefault();
// turn off auto-rotation if enabled
autoRotate = false;
// record key pressed
keynumber = event.keycode;
if(event.which) {
@@ -450,6 +465,20 @@ function keyRepeat() {
lon += 1;
animate();
}
// if clockwise auto-rotate
if(autoRotate == 'cw') {
// pan left
lon -= .25;
animate();
}
// if counter-clockwise auto-rotate
if(autoRotate == 'ccw') {
// pan right
lon += .25;
animate();
}
}

function onDocumentResize() {


Yükleniyor…
İptal
Kaydet