diff --git a/.prettierrc.json b/.prettierrc.json deleted file mode 100644 index 963354f23168f2e9f79b42c261c612cc662e849c..0000000000000000000000000000000000000000 --- a/.prettierrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "printWidth": 120 -} diff --git a/src/utils/webgl.js b/src/utils/webgl.js index a209b3e75efa31f888b3890ef68ba07b9f52253d..2b75320d1d5715e85467382aedf4932925ec69a1 100644 --- a/src/utils/webgl.js +++ b/src/utils/webgl.js @@ -5,30 +5,45 @@ function checkFloatTextureSupport() { const renderer = new THREE.WebGLRenderer(); const scene = new THREE.Scene(); - const dataTexture = new THREE.DataTexture(new Float32Array(2 * 2 * 4), 2, 2, THREE.RGBAFormat, THREE.FloatType); - const box = new THREE.Mesh(new THREE.PlaneBufferGeometry(1, 1), new THREE.MeshBasicMaterial({ map: dataTexture })); + const size = 2; + const data = new Float32Array(size * size * 4); + const dataTexture = new THREE.DataTexture( + data, + size, + size, + THREE.RGBAFormat, + THREE.FloatType + ); + const box = new THREE.Mesh( + new THREE.PlaneBufferGeometry(1, 1), + new THREE.MeshBasicMaterial({ map: dataTexture }) + ); box.material.map.needsUpdate = true; scene.add(box); renderer.render(scene, new THREE.Camera()); - return renderer.context.getError() === 0; + const result = renderer.context.getError() === 0; + renderer.dispose(); + return result; } -let supportsFloatTextures = checkFloatTextureSupport(); +const supportsFloatTextures = checkFloatTextureSupport(); export function patchWebGLRenderingContext() { const originalGetExtension = WebGLRenderingContext.prototype.getExtension; - WebGLRenderingContext.prototype.getExtension = function patchedGetExtension(name) { - // It appears that Galaxy S6 devices falsely report that they support OES_texture_float in Firefox. - // This workaround disables float textures for those devices. - // See https://github.com/mozilla/mr-social-client/issues/32 and https://bugzilla.mozilla.org/show_bug.cgi?id=1338656 - if (name === "OES_texture_float" && /Android.+Firefox/.test(navigator.userAgent)) { - if (supportsFloatTextures === undefined) { - supportsFloatTextures = checkFloatTextureSupport(); - } - if (!supportsFloatTextures) { - return null; - } + function patchedGetExtension(name) { + // It appears that Galaxy S6 devices falsely report that they support + // OES_texture_float in Firefox. This workaround disables float textures + // for those devices. + // See https://github.com/mozilla/mr-social-client/issues/32 and + // https://bugzilla.mozilla.org/show_bug.cgi?id=1338656 + if ( + name === "OES_texture_float" && + /Android.+Firefox/.test(navigator.userAgent) && + !supportsFloatTextures + ) { + return null; } return originalGetExtension.call(this, name); - }; + } + WebGLRenderingContext.prototype.getExtension = patchedGetExtension; }