Skip to content

How to add a frame counter to xml3d?

xml3d edited this page Jan 11, 2013 · 2 revisions

A nice way is to use the stats counter from: https://github.com/mrdoob/stats.js/

In the WebGL version, one can use the framedrawn event to update the counter, e.g:

var stats = new Stats();

stats.domElement.style.position='absolute';
stats.domElement.style.left='0px';
stats.domElement.style.top='0px';

var targetElement = ...
targetElement.style.position='realtive';
targetElement.appendChild(stats.domElement);

var myxml3d = document.getElementById("myxml3d");
myxml3d.addEventListener("framedrawn", function(e) {
    stats.update();
}, false); 
Clone this wiki locally