Skip to content

Commit

Permalink
Fix #802 visible range prevents autorotate
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic100 committed Jan 10, 2023
1 parent 9b4d300 commit 2bdcb4d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ home: true
heroImage: logo.png
heroText: Photo Sphere Viewer
heroAlt: Photo Sphere Viewer
tagline: A JavaScript library to display Photo Sphere panoramas
tagline: A JavaScript library to display 360° sphere panoramas
actionText: Get Started →
actionLink: /guide/
features:
Expand Down
41 changes: 26 additions & 15 deletions packages/autorotate-plugin/src/AutorotatePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,23 +304,34 @@ export class AutorotatePlugin extends AbstractPlugin<AutorotatePluginEvents> {
* Launches the standard animation
*/
private __animate() {
this.viewer.dynamics.position.roll(
{
yaw: this.config.autorotateSpeed < 0,
},
Math.abs(this.config.autorotateSpeed / this.viewer.config.moveSpeed)
);

this.viewer.dynamics.position.goto(
{
pitch: this.config.autorotatePitch ?? this.viewer.config.defaultPitch,
},
Math.abs(this.config.autorotateSpeed / this.viewer.config.moveSpeed)
);

// do the zoom before the rotation
let p: PromiseLike<any>;
if (!utils.isNil(this.config.autorotateZoomLvl)) {
this.viewer.dynamics.zoom.goto(this.config.autorotateZoomLvl);
p = this.viewer.animate({
zoom: this.config.autorotateZoomLvl,
// "2" is magic, and kinda related to the "PI/4" in animate()
speed: `${this.viewer.config.zoomSpeed * 2}rpm`,
});
}
else {
p = Promise.resolve();
}

p.then(() => {
this.viewer.dynamics.position.roll(
{
yaw: this.config.autorotateSpeed < 0,
},
Math.abs(this.config.autorotateSpeed / this.viewer.config.moveSpeed)
);

this.viewer.dynamics.position.goto(
{
pitch: this.config.autorotatePitch ?? this.viewer.config.defaultPitch,
},
Math.abs(this.config.autorotateSpeed / this.viewer.config.moveSpeed)
);
});
}

/**
Expand Down

0 comments on commit 2bdcb4d

Please sign in to comment.