提交 b7f7cb2a 编写于 作者: M Mr.doob

Updated stats.js

上级 b8822018
// stats.js - http://github.com/mrdoob/stats.js
var Stats=function(){function a(b,a,c){b=document.createElement(b);b.id=a;b.style.cssText=c;return b}var m=performance&&performance.now?performance.now.bind(performance):Date.now,k=m(),n=k,c=0,p=Infinity,q=0,d=0,r=Infinity,t=0,u=0,v=0,l=a("div","stats","width:80px;opacity:0.9;cursor:pointer");l.addEventListener("mousedown",function(b){b.preventDefault();z(++v%2)},!1);var e=a("div","fps","padding:0 0 3px 3px;text-align:left;background:#002");l.appendChild(e);var w=a("div","fpsText","color:#0ff;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px");
w.innerHTML="FPS";e.appendChild(w);var f=a("div","fpsGraph","position:relative;width:74px;height:30px;background:#0ff");for(e.appendChild(f);74>f.children.length;){var x=a("span","","width:1px;height:30px;float:left;background:#113");f.appendChild(x)}var g=a("div","ms","padding:0 0 3px 3px;text-align:left;background:#020;display:none");l.appendChild(g);var y=a("div","msText","color:#0f0;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px");y.innerHTML="MS";g.appendChild(y);
var h=a("div","msGraph","position:relative;width:74px;height:30px;background:#0f0");for(g.appendChild(h);74>h.children.length;)x=a("span","","width:1px;height:30px;float:left;background:#131"),h.appendChild(x);var z=function(b){v=b;switch(v){case 0:e.style.display="block";g.style.display="none";break;case 1:e.style.display="none",g.style.display="block"}};return{REVISION:13,domElement:l,setMode:z,begin:function(){k=m()},end:function(){var b=m();c=b-k;p=Math.min(p,c);q=Math.max(q,c);y.textContent=
(c|0)+" MS ("+(p|0)+"-"+(q|0)+")";var a=Math.min(30,30-c/200*30);h.appendChild(h.firstChild).style.height=a+"px";u++;b>n+1E3&&(d=Math.round(1E3*u/(b-n)),r=Math.min(r,d),t=Math.max(t,d),w.textContent=d+" FPS ("+r+"-"+t+")",a=Math.min(30,30-d/100*30),f.appendChild(f.firstChild).style.height=a+"px",n=b,u=0);return b},update:function(){k=this.end()}}};"object"===typeof module&&(module.exports=Stats);
var Stats=function(){function f(a,A,b){a=document.createElement(a);a.id=A;a.style.cssText=b;return a}function k(a,b,d){var e=f("div",a,"padding:0 0 3px 3px;text-align:left;background:"+d),c=f("div",a+"Text","font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px;color:"+b);c.innerHTML=a.toUpperCase();e.appendChild(c);a=f("div",a+"Graph","position:relative;width:74px;height:30px;background:"+b);e.appendChild(a);for(b=0;74>b;b++)c=f("span","","width:1px;height:30px;float:left;opacity:0.9;background:"+
d),a.appendChild(c);return e}function l(a){for(var b=d.children,c=0;c<b.length;c++)b[c].style.display=c===a?"block":"none";m=a}function n(a,b){a.appendChild(a.firstChild).style.height=Math.min(30,30-30*b)+"px"}var p=performance&&performance.now?performance.now.bind(performance):Date.now,g=p(),q=g,r=0,m=0,d=f("div","stats","width:80px;opacity:0.9;cursor:pointer");d.addEventListener("mousedown",function(a){a.preventDefault();l(++m%d.children.length)},!1);var e=0,t=Infinity,u=0,b=k("fps","#0ff","#002"),
B=b.children[0],C=b.children[1];d.appendChild(b);var c=0,v=Infinity,w=0,b=k("ms","#0f0","#020"),D=b.children[0],E=b.children[1];d.appendChild(b);if(performance&&performance.memory&&performance.memory.totalJSHeapSize){var x=performance.memory,h=0,y=Infinity,z=0,b=k("mem","#f08","#201"),F=b.children[0],G=b.children[1];d.appendChild(b)}l(m);return{REVISION:14,domElement:d,setMode:l,begin:function(){g=p()},end:function(){var a=p();c=a-g;v=Math.min(v,c);w=Math.max(w,c);D.textContent=(c|0)+" MS ("+(v|0)+
"-"+(w|0)+")";n(E,c/200);r++;a>q+1E3&&(e=Math.round(1E3*r/(a-q)),t=Math.min(t,e),u=Math.max(u,e),B.textContent=e+" FPS ("+t+"-"+u+")",n(C,e/100),q=a,r=0,void 0!==x&&(h=Math.round(9.54E-7*performance.memory.usedJSHeapSize),y=Math.min(y,h),z=Math.max(z,h),F.textContent=h+" MB ("+y+"-"+z+")",n(G,x.usedJSHeapSize/x.totalJSHeapSize)));return a},update:function(){g=this.end()}}};"object"===typeof module&&(module.exports=Stats);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册