Scene Load Complete Event

1,031 views
Skip to first unread message

Michael Simla

unread,
Jun 19, 2017, 2:43:18 PM6/19/17
to marzipano
Is there any event that is fired when Marzipano starts or is finished rendering a scene?

My client wants to have some sort of loading animation(a spinner or something) to indicate that a panorama is loading. I know that Marzipano lazy loads in the preview and then full res images, but my client doesn't think that is enough.

thanks,
Michael

Tiago Quelhas

unread,
Jun 19, 2017, 6:16:11 PM6/19/17
to Michael Simla, marzipano
You can detect when a scene starts being rendered by listening to the `sceneChange` event on the Viewer object.

No event is emitted when rendering is "finished", but there's an indirect way to detect it. Rendering is "finished" once a texture has been loaded for every visible tile. You can determine this by combining Layer#visibleTiles (to get the list of currently visible tiles) and TextureStore#query (to query the loading state of a tile):

var layer = viewer.scene().layer();
var textureStore = layer.textureStore();
var tileList = [];
layer.visibleTiles(tileList);
for (var i = 0; i < tileList.length; i++) {
  if (!textureStore.query(tileList[i]).hasTexture) {
    // not finished yet
  }
}

To avoid polling repeatedly, you should run this code in response to the TextureStore `textureLoad` event, which is emitted every time a new texture is loaded.

Note that it only makes sense to ask whether rendering is "finished" if the view (i.e. the camera parameters) remains constant. Every time the view changes, new tiles may become visible and start being loaded. In fact, a panorama might be too large to fit entirely in Marzipano's internal cache, so if you continuously move the view around, you may never reach a state where no textures are being loaded.


--
You received this message because you are subscribed to the Google Groups "marzipano" group.
To unsubscribe from this group and stop receiving emails from it, send an email to marzipano+unsubscribe@googlegroups.com.
To post to this group, send email to marz...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/marzipano/a5217b13-c9a4-4c02-b4b8-51be026562d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jordy

unread,
Dec 12, 2017, 7:16:18 PM12/12/17
to marzipano
Trying to get this to work but layer.visibleTiles(tileList); throws an error: "Starting tile is not visible" each time the scene is changed for the first time. Running this inside viewer#sceneChange listener. Any idea where could be the problem?

Thank you!



On Tuesday, June 20, 2017 at 12:16:11 AM UTC+2, Tiago Quelhas wrote:
You can detect when a scene starts being rendered by listening to the `sceneChange` event on the Viewer object.

No event is emitted when rendering is "finished", but there's an indirect way to detect it. Rendering is "finished" once a texture has been loaded for every visible tile. You can determine this by combining Layer#visibleTiles (to get the list of currently visible tiles) and TextureStore#query (to query the loading state of a tile):

var layer = viewer.scene().layer();
var textureStore = layer.textureStore();
var tileList = [];
layer.visibleTiles(tileList);
for (var i = 0; i < tileList.length; i++) {
  if (!textureStore.query(tileList[i]).hasTexture) {
    // not finished yet
  }
}

To avoid polling repeatedly, you should run this code in response to the TextureStore `textureLoad` event, which is emitted every time a new texture is loaded.

Note that it only makes sense to ask whether rendering is "finished" if the view (i.e. the camera parameters) remains constant. Every time the view changes, new tiles may become visible and start being loaded. In fact, a panorama might be too large to fit entirely in Marzipano's internal cache, so if you continuously move the view around, you may never reach a state where no textures are being loaded.

On Mon, Jun 19, 2017 at 11:43 AM, Michael Simla <msi...@gmail.com> wrote:
Is there any event that is fired when Marzipano starts or is finished rendering a scene?

My client wants to have some sort of loading animation(a spinner or something) to indicate that a panorama is loading. I know that Marzipano lazy loads in the preview and then full res images, but my client doesn't think that is enough.

thanks,
Michael

--
You received this message because you are subscribed to the Google Groups "marzipano" group.
To unsubscribe from this group and stop receiving emails from it, send an email to marzipano+...@googlegroups.com.

Tiago Quelhas

unread,
Dec 12, 2017, 8:21:18 PM12/12/17
to Jordy, marzipano
Is the problem perhaps that the viewport is still empty at the time you call visibleTiles? (Set a breakpoint inside visibleTiles and check the return value of view.size()). The viewport size is not set until we render for the first time.

If the viewport has been set, then it looks like a bug in visibleTiles.

To unsubscribe from this group and stop receiving emails from it, send an email to marzipano+unsubscribe@googlegroups.com.

To post to this group, send email to marz...@googlegroups.com.

Jordy

unread,
Dec 13, 2017, 9:23:58 AM12/13/17
to marzipano
You were right, I hooked it to the textureStore#textureLoad event call and it works, thank you!

Tiago Quelhas

unread,
Dec 13, 2017, 4:20:32 PM12/13/17
to Jordy, marzipano
It's actually a little unreasonable for visibleTiles to crash in this situation, so I've modified it to return an empty list instead.

To unsubscribe from this group and stop receiving emails from it, send an email to marzipano+unsubscribe@googlegroups.com.

To post to this group, send email to marz...@googlegroups.com.

Tiago Quelhas

unread,
Sep 17, 2018, 12:10:14 AM9/17/18
to Jordy, marzipano
For the benefit of anyone finding this thread, there is now a `Stage#renderComplete` event that makes implementing a loading indicator much simpler.

ch...@roomvu.com

unread,
Sep 25, 2018, 12:23:09 PM9/25/18
to marzipano
Thank you, I am here for just that purpose, and am relieved to hear this!
Reply all
Reply to author
Forward
0 new messages