From 08d44704bf92f903be2960a69adcbd7edcd05cf6 Mon Sep 17 00:00:00 2001
From: Tony Tung <ytung@mozilla.com>
Date: Thu, 9 Aug 2018 09:47:00 -0700
Subject: [PATCH] added disableTunnel parameter to disable the effect with
 qs_truthy.

---
 src/systems/tunnel-effect.js | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/systems/tunnel-effect.js b/src/systems/tunnel-effect.js
index abfdf9bd6..38f8b0ce4 100644
--- a/src/systems/tunnel-effect.js
+++ b/src/systems/tunnel-effect.js
@@ -4,9 +4,13 @@ import "../utils/postprocessing/ShaderPass";
 import "../utils/postprocessing/MaskPass";
 import "../utils/shaders/CopyShader";
 import "../utils/shaders/VignetteShader";
+import qsTruthy from "../utils/qs_truthy";
 
 const STATIC = new THREE.Vector3(0, 0, 0);
 const CLAMP_VELOCITY = 0.01;
+const CLAMP_RADIUS = 0.001;
+const CLAMP_SOFTNESS = 0.001;
+const isDisabled = qsTruthy("disableTunnel");
 
 AFRAME.registerSystem("tunneleffect", {
   schema: {
@@ -62,7 +66,7 @@ AFRAME.registerSystem("tunneleffect", {
   tick: function(time, deltaTime) {
     this.dt = deltaTime;
 
-    if (!this._isPostProcessingReady() || !this.isVR) {
+    if (!this._isPostProcessingReady() || !this.isVR || isDisabled) {
       return;
     }
 
@@ -71,7 +75,11 @@ AFRAME.registerSystem("tunneleffect", {
       // the character stops, so we use the aframe default render func
       const r = this.vignettePass.uniforms["radius"].value;
       const softness = this.vignettePass.uniforms["softness"].value;
-      if (this.isMoving && r < this.targetRadius && softness > this.targetSoftness) {
+      if (
+        this.isMoving &&
+        Math.abs(r - this.targetRadius) > CLAMP_RADIUS &&
+        Math.abs(softness - this.targetSoftness) > CLAMP_SOFTNESS
+      ) {
         if (this.deltaR !== 0 && this.deltaS !== 0) {
           this.deltaR = this.targetRadius - r;
           this.deltaS = softness - this.targetSoftness;
-- 
GitLab