Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pannelum load event with multires #1186

Open
aproni34f opened this issue Nov 2, 2023 · 3 comments
Open

Pannelum load event with multires #1186

aproni34f opened this issue Nov 2, 2023 · 3 comments
Labels

Comments

@aproni34f
Copy link

Hi, I have an issue caching load event (with autoLoad:true) when using multires panaorama.

The load event fires before the code viewer.on('load'....

If I add little delay with setTimeout in pannellum.js to this line fireEvent('load'); then load event works with following code, but this is not something I want to do.

Is there a way I can rewrite this code so I can hear the load event after I init panorama? How could I attach listener before I actually set pano data to load?

  `var viewer = pannellum.viewer('panorama', {
	autoLoad:true,
    "type": "multires",
    "multiRes": {
        "basePath": "./multires",
        "path": "/%l/%s%x%y",
        "fallbackPath": "/fallback/%s",
        "extension": "png",
        "tileResolution": 256,
        "maxLevel": 4,
        "cubeResolution": 2048
    }
});

viewer.on('load',
    function () {
        console.log("load");
    }
);`
@mpetroff
Copy link
Owner

mpetroff commented Nov 3, 2023

When constructing a viewer with a multires panorama and autoLoad: true, the panorama will be considered loaded before the pannellum.viewer returns. Thus, there is little reason to have an event listener for this. You could accomplish the same thing by just calling your event handler manually with something along the lines of:

var viewer = pannellum.viewer('panorama', {...});
function loadHandler () {
    console.log("load");
}
viewer.on('load', loadHandler);
loadHandler();

Alternatively, instead of setting autoLoad: true, just call viewer.loadScene(); after adding your event listener.

@aproni34f
Copy link
Author

So with multires, Is there a way of actually knowing when the scene has loaded (maybe with some code mod) so I can fade in scene nicelly?

@mpetroff
Copy link
Owner

mpetroff commented Nov 3, 2023

You can query the loading status with viewer.getRenderer().isLoading().

However, tile loading is linked to rendering for performance reasons, so a scene won't load if it isn't being rendered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants