简体   繁体   English

Safari iOS 8上的Webgl图像纹理失败

[英]Webgl image texture failure on Safari iOS 8

The following example is working correctly on all major browsers, even on Safari Mac os, but it fails to show the correct image on my iPad with the recent iOS8. 以下示例在所有主流浏览器上都能正常工作,即使在Safari Mac OS上也是如此,但它无法在我的iPad上使用最近的iOS8显示正确的图像。 http://mrdoob.github.io/three.js/examples/webgl_panorama_equirectangular.html http://mrdoob.github.io/three.js/examples/webgl_panorama_equirectangular.html

Also, the following tutorial is not working as well on the iOS8. 此外,以下教程在iOS8上运行不正常。

http://blog.thematicmapping.org/2014/01/photo-spheres-with-threejs.html http://blog.thematicmapping.org/2014/01/photo-spheres-with-threejs.html

How should we show panoramic images in webgl iOS? 我们应该如何在webgl iOS中显示全景图像?

The mobile devices do not allow for textures sizes the same that desktop browsers do. 移动设备不允许纹理大小与桌面浏览器相同。 The texture in the webgl_panorama_equirectangular.html example is 4096x2048 which is big for the mobile devices. webgl_panorama_equirectangular.html示例中的纹理是4096x2048,这对于移动设备来说很重要。 Reduce the size of the texture but keep it power of two. 减小纹理的大小,但保持2的力量。

Visit http://webglreport.com/ on iOS, we see "Max Texture Size: 4096". 访问iOS上的http://webglreport.com/ ,我们看到“Max Texture Size:4096”。 In fact iOS support panorama image up to 4096*2048, however, I believe there is a bug in three.js. 事实上iOS支持全景图像高达4096 * 2048,但是,我相信在three.js中有一个bug。 In my test, if panorama image's size is greater than 4096, it will be scaled automatically to 4096*2048 and it will be rendered correctly. 在我的测试中,如果全景图像的大小大于4096,它将自动缩放到4096 * 2048并且它将被正确渲染。 However if the image size is exactly 4096*2048, scaling does not happen, rendering has problem. 但是,如果图像大小正好是4096 * 2048,则不会进行缩放,渲染会出现问题。

As a workaround, you can make a small change in function clampToMaxSize of three.js: 作为一种解决方法,您可以在函数clampToMaxSize中对three.js进行一些小改动:

Change 更改

if ( image.width > maxSize || image.height > maxSize ) {

To

if ( image.width >= maxSize || image.height >= maxSize ) {

It means we scale image of size 4096*2048. 这意味着我们缩放尺寸为4096 * 2048的图像。 In function clampToMaxSize, the most important thing it does is 在函数clampToMaxSize中,它最重要的是它

context.drawImage( image, 0, 0, image.width, image.height, 0, 0, canvas.width, canvas.height );

2048x2048是IOS8 safari上的最大纹理尺寸,或者使用具有6x 1024x1024纹理的天空盒的全景img 2048x1024在分辨率和性能方面将是更好的解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM