[英]Photo Sphere viewer make browser slow
I'm using Photo Sphere Viewer to show 360 images.我正在使用 Photo Sphere Viewer 显示 360 度图像。 I have a menu on the bottom with other 360 images.
我在底部有一个带有其他 360 度图像的菜单。 When i click one of these images, the photosphere change the image in the viewer.
当我单击这些图像之一时,光球会改变查看器中的图像。 After changing the image about 3 or more times, the browser become slow.
更改图像大约 3 次或更多次后,浏览器变慢。
The method I'm using is "empty()" from jquery to erase the old panorama image and then load again a "photoSphereViewer" and i think that's the problem.我使用的方法是 jquery 中的“empty()”来擦除旧的全景图像,然后再次加载“photoSphereViewer”,我认为这就是问题所在。 For some reason, when i use empty doesn't remove the image on the cache and after a time it become slow.
出于某种原因,当我使用 empty 不会删除缓存上的图像,一段时间后它会变慢。 I know that exist a method to change the panorama with "setPanorama", but when I try, the console shows an error that PSV (the variable) is not a function.
我知道存在一种使用“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 );
}
})
With the old method (empty the container and add the new panorama) works, but I have this performance issue.使用旧方法(清空容器并添加新全景图)有效,但我有这个性能问题。 So I need to find a way to clean the cache or set the panorama without create it again everytime.
所以我需要找到一种方法来清理缓存或设置全景图而无需每次都重新创建它。 any idea?
任何的想法? Thanks!!
谢谢!!
finally i found a solution.最后我找到了解决方案。 I let it here if anyone need it someday.
如果有一天有人需要它,我就把它放在这里。 I finally used Pannellum library and I talked with the author.
我终于使用了 Pannellum 库,并与作者交谈。 He gave me a very simple and effective solution.
他给了我一个非常简单有效的解决方案。 Just loading one viewer and using a method like "addScene" and "removeScene" the garbabe collector doesn't load and everything runs pretty well.
只需加载一个查看器并使用“addScene”和“removeScene”之类的方法,garbabe 收集器就不会加载,并且一切运行良好。 If someone needs more information, here is the thread:
如果有人需要更多信息,这里是线程:
https://github.com/mpetroff/pannellum/issues/763 https://github.com/mpetroff/pannellum/issues/763
Cheers!干杯!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.