Photo Sphere Viewer使浏览器变慢

时间:2019-07-30 09:49:06

标签: jquery canvas 360-panorama photosphere

我正在使用Photo Sphere Viewer显示360张图像。我在底部带有其他360图像的菜单。当我单击这些图像之一时,光球会更改查看器中的图像。更改图像约3次以上后,浏览器变慢。

我正在使用的方法是jquery中的“ empty()”以擦除旧的全景图像,然后再次加载“ photoSphereViewer”,我认为这就是问题所在。出于某种原因,当我使用empty时,不会删除缓存上的图像,并且一段时间后它会变慢。我知道存在一种使用“ setPanorama”更改全景图的方法,但是当我尝试使用该方法时,控制台显示错误消息PSV(变量)不是函数。

        //here is the panorama add it to the dom
        $(window).load(function(){

                PSV = new PhotoSphereViewer({
                    panorama: '',
                    container: 'photosphere',
                    default_fov: 65,
                    mousewheel: false,
                    loading_img:'img/loader3.gif',
                    cache_texture:0,
                    transition:{duration:1500, loader:true},

                }); 

        });

        //then a function with ajax (im using php) that set the URL:

            $.ajax({

            type:'post',
            url:'query/menu_r.php',
            data:{consulta:consulta, codigoFull:codigoFull},
            success:function(data){

                ruta = "content/"+recinto+"/"+vista+"/cu"+silestone+"/"+calidad+"/";
                ruta = ruta+data;

                //vacío container del 360.
                //$("#photosphere").empty();

                PSV.setPanorama(ruta, null, true );



            }        
    })

使用旧方法(清空容器并添加新全景图)有效,但是我遇到了此性能问题。因此,我需要找到一种无需每次都重新创建即可清理缓存或设置全景图的方法。任何想法?谢谢!

1 个答案:

答案 0 :(得分:1)

最后我找到了解决方案。如果有人需要的话,我把它放在这里。我最终使用了Pannellum库,并与作者交谈。他给了我一个非常简单有效的解决方案。只需加载一个查看器并使用“ addScene”和“ removeScene”之类的方法,garbabe收集器就不会加载,并且一切运行都很好。如果有人需要更多信息,请参见以下线程:

https://github.com/mpetroff/pannellum/issues/763

干杯!