From b5d2822d003d77bd32c8a36c19b497d1e423e733 Mon Sep 17 00:00:00 2001 From: Thomas FORGIONE Date: Mon, 13 Apr 2015 09:35:49 +0200 Subject: [PATCH] Corrected errors and added stats in rendering of prototype --- errors/.htaccess | 1 - js/three/stats.min.js | 6 ++++++ prototype/js/main.js | 13 ++++++++++++- templates/jsIncludes.html | 1 + 4 files changed, 19 insertions(+), 2 deletions(-) delete mode 100644 errors/.htaccess create mode 100644 js/three/stats.min.js diff --git a/errors/.htaccess b/errors/.htaccess deleted file mode 100644 index 3a42882..0000000 --- a/errors/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/js/three/stats.min.js b/js/three/stats.min.js new file mode 100644 index 0000000..52539f4 --- /dev/null +++ b/js/three/stats.min.js @@ -0,0 +1,6 @@ +// stats.js - http://github.com/mrdoob/stats.js +var Stats=function(){var l=Date.now(),m=l,g=0,n=Infinity,o=0,h=0,p=Infinity,q=0,r=0,s=0,f=document.createElement("div");f.id="stats";f.addEventListener("mousedown",function(b){b.preventDefault();t(++s%2)},!1);f.style.cssText="width:80px;opacity:0.9;cursor:pointer";var a=document.createElement("div");a.id="fps";a.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#002";f.appendChild(a);var i=document.createElement("div");i.id="fpsText";i.style.cssText="color:#0ff;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px"; +i.innerHTML="FPS";a.appendChild(i);var c=document.createElement("div");c.id="fpsGraph";c.style.cssText="position:relative;width:74px;height:30px;background-color:#0ff";for(a.appendChild(c);74>c.children.length;){var j=document.createElement("span");j.style.cssText="width:1px;height:30px;float:left;background-color:#113";c.appendChild(j)}var d=document.createElement("div");d.id="ms";d.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#020;display:none";f.appendChild(d);var k=document.createElement("div"); +k.id="msText";k.style.cssText="color:#0f0;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px";k.innerHTML="MS";d.appendChild(k);var e=document.createElement("div");e.id="msGraph";e.style.cssText="position:relative;width:74px;height:30px;background-color:#0f0";for(d.appendChild(e);74>e.children.length;)j=document.createElement("span"),j.style.cssText="width:1px;height:30px;float:left;background-color:#131",e.appendChild(j);var t=function(b){s=b;switch(s){case 0:a.style.display= +"block";d.style.display="none";break;case 1:a.style.display="none",d.style.display="block"}};return{REVISION:12,domElement:f,setMode:t,begin:function(){l=Date.now()},end:function(){var b=Date.now();g=b-l;n=Math.min(n,g);o=Math.max(o,g);k.textContent=g+" MS ("+n+"-"+o+")";var a=Math.min(30,30-30*(g/200));e.appendChild(e.firstChild).style.height=a+"px";r++;b>m+1E3&&(h=Math.round(1E3*r/(b-m)),p=Math.min(p,h),q=Math.max(q,h),i.textContent=h+" FPS ("+p+"-"+q+")",a=Math.min(30,30-30*(h/100)),c.appendChild(c.firstChild).style.height= +a+"px",m=b,r=0);return b},update:function(){l=this.end()}}};"object"===typeof module&&(module.exports=Stats); diff --git a/prototype/js/main.js b/prototype/js/main.js index ce37c4e..4739b14 100644 --- a/prototype/js/main.js +++ b/prototype/js/main.js @@ -6,6 +6,7 @@ var objects = []; var cameras = new CameraContainer(); var spheres = new Array(mesh_number); var visible = 0; +var stats; var loader; @@ -23,12 +24,20 @@ function init() { renderer.setSize(container_size.width, container_size.height); renderer.shadowMapEnabled = true; // renderer.setClearColor(0x000000); - document.getElementById('container').appendChild(renderer.domElement); // on initialise la scène scene = new THREE.Scene(); raycaster = new THREE.Raycaster(); + // Create stats counter + stats = new Stats(); + stats.setMode(0); + + stats.domElement.style.position = 'absolute'; + stats.domElement.style.cssFloat = "top-left"; + container.appendChild( stats.domElement ); + container.appendChild(renderer.domElement); + // init light var directional_light = new THREE.DirectionalLight(0x999999); directional_light.position.set(1, 0.5, 1).normalize(); @@ -157,10 +166,12 @@ function animate() { // on appelle la fonction animate() récursivement à chaque frame requestAnimationFrame(animate); + stats.begin(); cameras.update(); cameras.look(); renderer.render(scene, cameras.mainCamera()); + stats.end(); } function onWindowResize() { diff --git a/templates/jsIncludes.html b/templates/jsIncludes.html index 89f2fbc..aabfb1c 100644 --- a/templates/jsIncludes.html +++ b/templates/jsIncludes.html @@ -12,4 +12,5 @@ + #