From 8648b00315219880ffabe5fd466f7cbd17a23a5f Mon Sep 17 00:00:00 2001
From: Brian Peiris <brianpeiris@gmail.com>
Date: Thu, 4 Jan 2018 18:26:50 -0800
Subject: [PATCH] make prettier happy

---
 .prettierrc.json   |  3 ---
 src/utils/webgl.js | 47 ++++++++++++++++++++++++++++++----------------
 2 files changed, 31 insertions(+), 19 deletions(-)
 delete mode 100644 .prettierrc.json

diff --git a/.prettierrc.json b/.prettierrc.json
deleted file mode 100644
index 963354f23..000000000
--- a/.prettierrc.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
-  "printWidth": 120
-}
diff --git a/src/utils/webgl.js b/src/utils/webgl.js
index a209b3e75..2b75320d1 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;
 }
-- 
GitLab