1 . 在init()函数中添加

1
2
3
4
5
6
7
8
9
10
11
12
var stat = null;

function init() {

stat = new Stats();
stat.domElement.style.position = 'absolute';
stat.domElement.style.right = '0px';
stat.domElement.style.top = '0px';
document.body.appendChild(stat.domElement);


}

2 . 设置开始帧和结束帧

1
2
3
4
5
6
7
8
9
function animate() {

stat.begin();

//动画函数
//renderer.render(scene, camera);

stat.end();
}

也可以直接添加

stat.update();