mpetroff / pannellum

Pannellum is a lightweight, free, and open source panorama viewer for the web.
https://pannellum.org/
MIT License
4.23k stars 722 forks source link

Loading scenes in quick succession does not swap to the most recent scene #1144

Closed needsmorecoffee closed 1 year ago

needsmorecoffee commented 1 year ago

I noticed if you call loadScene multiple times in quick succession, it seems to have to wait until the first scene is loaded before it will accept any subsequent load requests.

I tried to get around this by using .on('load') and loading/swapping the next scene there, but I get an error relating to setting the image src:

pannellum.js:674 ERROR TypeError: Cannot set properties of undefined (setting 'src')
    at FileReader.<anonymous> (src\assets\pannellum-latest\js\pannellum.js:642:1)

Is there any other way I can get around this without using setTimeout to add an arbritary delay between scene loads?

mpetroff commented 1 year ago

I just changed the order of where the panoImage object is cleared relative to the load event, so calling loadScene in a load event handler will probably work now (although I did not verify it).