Skip to content

Commit

Permalink
Prevent Stats from instantiating unless explicitly requested
Browse files Browse the repository at this point in the history
  • Loading branch information
colejd committed Feb 6, 2021
1 parent a291db2 commit ece5c89
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/reaction-diffusion.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,15 @@ export class ReactionDiffusion {
}, 100);
}

// Add Stats module
this.stats = new Stats();
this.container.appendChild(this.stats.dom);

let showDebug = this.container.getAttribute("show-debug");
if (showDebug != "true") this.stats.dom.style.display = "none";
if (this.container.getAttribute("show-debug") == "true") {
// Add Stats module
this.stats = new Stats();
this.container.appendChild(this.stats.dom);
}

// Set up clock for timing
this.clock = new THREE.Clock();




// Call last
this.RenderLoop();
}
Expand All @@ -65,15 +61,19 @@ export class ReactionDiffusion {

this.rdView.Render(this.clock);

this.stats.update();
if (this.stats) this.stats.update();

// TODO: Add info block https://threejs.org/docs/#api/en/renderers/WebGLRenderer.info

requestAnimationFrame( this.RenderLoop.bind(this) );
}

ToggleDebug() {
this.stats.dom.style.display = this.stats.dom.style.display == "none" ? "block" : "none";
if (!this.stats) {
this.stats = new Stats();
this.container.appendChild(this.stats.dom);
}
this.stats.dom.style.display = this.stats.dom.style.display == "none" ? "initial" : "none";
}

// Gives a dictionary holding the optional attributes a user might add
Expand Down

0 comments on commit ece5c89

Please sign in to comment.