google / marzipano

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

sceneChange transition timing #226

Open jordyno opened 5 years ago

jordyno commented 5 years ago

Hi all, I noticed that scene#switchTo occurs immediately, without waiting for even preview cubes / lower level tiles to load. This results in black areas on page load, depending on initial view and actual cubes position. This is no longer an issue when switching to next scenes. I have tried to reproduce this - see demo . Wouldn't it be better to have an option for scene#switchTo to wait for either specific tile level to finish loading or at least the preview level to load and then initiate the scene switch? Any ideas how to fix this? Thank you!

tjgq commented 5 years ago

The switchScene implementation is already very subtle and I would prefer not to bake this additional logic into it. But I could be persuaded to add e.g. a Scene#isPreviewComplete method (or perhaps a Scene#previewLoaded event), which client code can then call to implement the switching logic as they desire.

jordyno commented 5 years ago

I am actually doing something similar in my application, but seems to be unreliable and trying to figure out why. This is an excerpt of what I have in my textureLoadHandler attached to textureStore, listening for textureLoad:

if(tile.z == 0) {
    previewFacesLoaded++;
    if(previewFacesLoaded == 6) { // PREVIEW OF THE LAYER IS LOADED
      console.log('preview LOADED');
    }
}

not sure if this is the correct and most efficient way to do it, though

jordyno commented 5 years ago

In this case, my problem is not detecting when all preview cubes are loaded (that seems to be working with the above code), but timing the layer's visibility. After I create a layer I call the layer.setEffects({opacity: 0}); , before adding the textureLoad listener. After the preview loads, I tween the layer in. What happens instead is that the preview cubes get displayed in pieces anyway (unpleasant to watch for end users), after the preview loads they disappear and then the tween starts (with opacity 0 to 1).