google / marzipano

A 360° media viewer for the modern web.
http://www.marzipano.net
Apache License 2.0
1.99k stars 995 forks source link

'Stage not in sync with viewer' when calling scene.switchTo during a scene-switch transition #441

Closed Cloov closed 2 years ago

Cloov commented 2 years ago

Hi,

Just as the title says: I'm getting the error Stage not in sync with viewer, when using scene.switchTo during an existing transition.

My setup

I have a number of panoramas that the user can switch between. Each time a button is pressed in the navigation menu, a scene is created (if it doesn't already exist), and my Viewer will transition to that scene, by calling switchTo on that scene.

The transition I use for all of these switches lasts 1000 milliseconds. I aim to use a custom transition func, but I've removed this while I track down this issue. The error occurs with just the transitionDuration option present, and occurs whether or not I use a custom transition func.

I have no references to layers in my code; I understand that layers will be in use, but I don't attempt to do anything manually or differently with layers.


I haven't been able to ascertain whether this kind of scene-switch interruption behaviour is supported - is it? Originally, I used the Transitions example on the Marzipano website, following this to arrive at my first implementation, but I suppose I'm trying to interrupt a transition between two scenes, with a transition to a third.

I looked at the Viewer.js source code and the API docs, and it's my understanding that the switchScene method cancels any existing transition, and goes on to say in commentary that 'This ensures that the stage contains layers from exactly one scene before the transition begins.' I can see the code for this, specifically the tweenDone function, so hopefully I'm just missing a step or misusing something, and this cleanup will help me eventually.

A workaround for my implementation

I would be happy to introduce a compromise in my implementation, whereby, if a transition between two scenes is already taking place, the oldest of the two scenes currently engaged in transition could be removed from the stage, but I don't know how to do that - there are methods to destroy layers and scenes, but I don't see any methods to simply remove something immediately from a viewer.

Another workaround that I'd be happy with, is to be able to force a transition to finish early, and allow Marzipano to tidy up the Stage as it normally would at that point, by removing the outward scene.

To summarise all of this thinking into more lightweight questions:

Thanks