Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update stats.js #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions build/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
* @author mrdoob / http://mrdoob.com/
*/

var Stats = function () {
let Stats = function () {

var mode = 0;
let mode = 0;

var container = document.createElement( 'div' );
let container = document.createElement( 'div' );
container.style.cssText = 'position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000';
container.addEventListener( 'click', function ( event ) {

Expand All @@ -32,7 +32,7 @@ var Stats = function () {

function showPanel( id ) {

for ( var i = 0; i < container.children.length; i ++ ) {
for ( let i = 0; i < container.children.length; i ++ ) {

container.children[ i ].style.display = i === id ? 'block' : 'none';

Expand All @@ -44,14 +44,14 @@ var Stats = function () {

//

var beginTime = ( performance || Date ).now(), prevTime = beginTime, frames = 0;
let beginTime = ( performance || Date ).now(), prevTime = beginTime, frames = 0;

var fpsPanel = addPanel( new Stats.Panel( 'FPS', '#0ff', '#002' ) );
var msPanel = addPanel( new Stats.Panel( 'MS', '#0f0', '#020' ) );
let fpsPanel = addPanel( new Stats.Panel( 'FPS', '#0ff', '#002' ) );
let msPanel = addPanel( new Stats.Panel( 'MS', '#0f0', '#020' ) );

if ( self.performance && self.performance.memory ) {

var memPanel = addPanel( new Stats.Panel( 'MB', '#f08', '#201' ) );
let memPanel = addPanel( new Stats.Panel( 'MB', '#f08', '#201' ) );

}

Expand All @@ -76,7 +76,7 @@ var Stats = function () {

frames ++;

var time = ( performance || Date ).now();
let time = ( performance || Date ).now();

msPanel.update( time - beginTime, 200 );

Expand All @@ -89,7 +89,7 @@ var Stats = function () {

if ( memPanel ) {

var memory = performance.memory;
let memory = performance.memory;
memPanel.update( memory.usedJSHeapSize / 1048576, memory.jsHeapSizeLimit / 1048576 );

}
Expand Down Expand Up @@ -117,20 +117,20 @@ var Stats = function () {

Stats.Panel = function ( name, fg, bg ) {

var min = Infinity, max = 0, round = Math.round;
var PR = round( window.devicePixelRatio || 1 );
let min = Infinity, max = 0, round = Math.round;
let PR = round( window.devicePixelRatio || 1 );

var WIDTH = 80 * PR, HEIGHT = 48 * PR,
let WIDTH = 80 * PR, HEIGHT = 48 * PR,
TEXT_X = 3 * PR, TEXT_Y = 2 * PR,
GRAPH_X = 3 * PR, GRAPH_Y = 15 * PR,
GRAPH_WIDTH = 74 * PR, GRAPH_HEIGHT = 30 * PR;

var canvas = document.createElement( 'canvas' );
let canvas = document.createElement( 'canvas' );
canvas.width = WIDTH;
canvas.height = HEIGHT;
canvas.style.cssText = 'width:80px;height:48px';

var context = canvas.getContext( '2d' );
let context = canvas.getContext( '2d' );
context.font = 'bold ' + ( 9 * PR ) + 'px Helvetica,Arial,sans-serif';
context.textBaseline = 'top';

Expand Down