From c9028d2c4e9207c91ed658d27c4808c50e95452d Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Sat, 15 Aug 2015 22:26:08 -0400
Subject: [PATCH] turn off on rendering

---
 js/menus/templates/NavViewMenu.html | 3 ++-
 js/models/AppState.js               | 7 +++++++
 js/three/ThreeModel.js              | 9 +++++++--
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/js/menus/templates/NavViewMenu.html b/js/menus/templates/NavViewMenu.html
index db5339f9..a7446c51 100644
--- a/js/menus/templates/NavViewMenu.html
+++ b/js/menus/templates/NavViewMenu.html
@@ -19,8 +19,9 @@
 <li class="dropdown-submenu">
     <a tabindex="-1">Rendering<span class="pull-right fui-arrow-right"></span></a>
     <ul class="dropdown-menu">
-        <li><a class="appState boolProperty" data-property="renderAmbientOcclusion" href="#">Ambient Occlusion</a></li>
+        <!--<li><a class="appState boolProperty" data-property="renderAmbientOcclusion" href="#">Ambient Occlusion</a></li>-->
         <li><a class="appState boolProperty" data-property="realisticColorScheme" href="#">Realistic Color Scheme</a></li>
+        <li><a class="appState boolProperty" data-property="turnOffRendering" href="#">Turn Off Rendering</a></li>
     </ul>
 </li>
 <li class="dropdown-submenu">
diff --git a/js/models/AppState.js b/js/models/AppState.js
index 76e105b2..1f7c4641 100644
--- a/js/models/AppState.js
+++ b/js/models/AppState.js
@@ -20,6 +20,7 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu
             scriptIsVisible: false,
             consoleIsVisible: false,
             ribbonIsVisible: true,
+            turnOffRendering: false,
 
             basePlaneIsVisible:true,
             highlighterIsVisible:true,
@@ -60,6 +61,7 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu
             this.listenTo(this, "change:currentNav", this._navChanged);
             this.listenTo(this, "change:materialType", this._materialTypeChanged);
             this.listenTo(this, "change:gikLength", this._gikLengthChanged);
+            this.listenTo(this, "change:turnOffRendering", this._renderingOnOff);
 
             this.downKeys = {};//track keypresses to prevent repeat keystrokes on hold
             this.lastCellMode = this.get("cellMode");//store this to toggle on/off hide mode
@@ -139,6 +141,11 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu
             }
         },
 
+        _renderingOnOff: function(){
+            if (!this.get("turnOffRendering")) three.render();
+        },
+
+
         ///////////////////////////////////////////////////////////////////////////////
         /////////////////////KEY BINDINGS//////////////////////////////////////////////
         ///////////////////////////////////////////////////////////////////////////////
diff --git a/js/three/ThreeModel.js b/js/three/ThreeModel.js
index faeb0df8..497e1b36 100644
--- a/js/three/ThreeModel.js
+++ b/js/three/ThreeModel.js
@@ -9,6 +9,11 @@ define(['underscore', 'three'], function(_, THREE){
     var scene = new THREE.Scene();
     var renderer = new THREE.WebGLRenderer({antialias:true});//antialiasing is not supported in ff and on mac+chrome
 
+    var appState;
+    require(['appState'], function(globalAppState){
+        appState = globalAppState;
+    });
+
     //store all meshes to highlight
     var cells = [];
     var compositeCells = [];
@@ -122,7 +127,7 @@ define(['underscore', 'three'], function(_, THREE){
     }
 
     function startAnimationLoop(){
-        if (animationLoopRunning) return;
+        if (appState.get("turnOffRendering") || animationLoopRunning) return;
         stopAnimationFlag = false;
         animationLoopRunning = true;
         console.log("animation started");
@@ -145,7 +150,7 @@ define(['underscore', 'three'], function(_, THREE){
     }
 
     function render(){
-        if (animationLoopRunning) return;
+        if ((appState && appState.get("turnOffRendering")) || animationLoopRunning) return;
         _render();
     }
 
-- 
GitLab