Skip to content

How to add a frame counter to xml3d?

Judith Hartmann edited this page Mar 6, 2015 · 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='relative';
targetElement.appendChild(stats.domElement);

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