spite / GSVPano.js

Google Street View Panorama Util

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Out of sync pano reload issue

JohnHardy opened this issue · comments

I've noticed that when you update the pano location in quick succession (i.e. anything which results in two composePanorama() calls before the first one completes) the images from the first one can overwrite the second one, causing a nasty shearing effect between the two locations.

The fix is simple: just add a request number to each pano, so that we can drop ones which are not relevant any more.

Variables:

_requestNumber = 0,

In the lamda for compsePanorama:

                (function (x, y, iRequest) { 
                    var img = new Image();
                    img.requestNum = iRequest;
                    img.addEventListener('load', function () {
                        self.composeFromTile(x, y, this);
                    });
                    img.crossOrigin = '';
                    img.src = url;  
                })(x, y, _requestNumber);

At the top of composeFromTile:

        // Do we need to drop this request (i.e. it is for an old pano).
        if (texture.requestNum != _requestNumber)
        {
            console.log("(EE) Pano image request number out of sync.  Dropping draw request.");
            return;
        }

Impressive library, thanks for sharing. 👍

John

Thanks, John. I'm working on a new version with support for the new maps services, and a few fixes. I'll add your fix as soon as possible.