Parcourir la source

Fix a number of bugs related to auto-rotate (fixes #235).

pull/238/merge
Matthew Petroff il y a 8 ans
Parent
révision
942daacb4c
1 fichiers modifiés avec 8 ajouts et 5 suppressions
  1. +8
    -5
      src/js/pannellum.js

+ 8
- 5
src/js/pannellum.js Voir le fichier

@@ -1119,13 +1119,12 @@ function keyRepeat() {

// If auto-rotate
var inactivityInterval = Date.now() - latestInteraction;
if (config.autoRotate &&
config.autoRotateStopDelay !== false) {
if (config.autoRotate) {
// Pan
if (newTime - prevTime > 0.001) {
diff = (newTime - prevTime) / 1000;
var yawDiff = (speed.yaw - config.autoRotate * 0.2) * diff
yawDiff = Math.sign(-config.autoRotate) * Math.min(Math.abs(config.autoRotate * diff), Math.abs(yawDiff));
var timeDiff = (newTime - prevTime) / 1000;
var yawDiff = (speed.yaw / timeDiff * diff - config.autoRotate * 0.2) * timeDiff
yawDiff = Math.sign(-config.autoRotate) * Math.min(Math.abs(config.autoRotate * timeDiff), Math.abs(yawDiff));
config.yaw += yawDiff;
}
@@ -1134,6 +1133,8 @@ function keyRepeat() {
config.autoRotateStopDelay -= newTime - prevTime;
if (config.autoRotateStopDelay <= 0) {
config.autoRotateStopDelay = false;
autoRotateSpeed = config.autoRotate;
config.autoRotate = 0;
}
}
}
@@ -2324,6 +2325,7 @@ this.setNorthOffset = function(heading) {
this.startAutoRotate = function(speed) {
speed = speed || autoRotateSpeed || 1;
config.autoRotate = speed;
_this.lookAt(origPitch, undefined, origHfov, 3000);
animateInit();
return this;
};
@@ -2337,6 +2339,7 @@ this.startAutoRotate = function(speed) {
this.stopAutoRotate = function() {
autoRotateSpeed = config.autoRotate ? config.autoRotate : autoRotateSpeed;
config.autoRotate = false;
config.autoRotateInactivityDelay = -1;
return this;
};



Chargement…
Annuler
Enregistrer