three.js學習:性能監視器stats.js的用法
阿新 • • 發佈:2019-02-09
can onf gin func style pre tin stats document
用法一:
var stats = new Stats(); stats.setMode(0); stats.domElement.style.position = ‘absolute‘; stats.domElement.style.left = ‘0px‘; stats.domElement.style.top = ‘0px‘; document.body.appendChild(stats.domElement); setInterval(function () { stats.begin(); stats.end(); }, 1000 / 60)
用法二(紅字部分):
var renderer;var stats = new Stats(); function initThree() { stats.setMode(0); stats.domElement.style.position = ‘absolute‘; stats.domElement.style.left = ‘0px‘; stats.domElement.style.top = ‘0px‘; document.body.appendChild(stats.domElement);
renderer = new THREE.WebGLRenderer({ canvas: canvas, antialias:true }); renderer.setSize(window.innerWidth, window.innerHeight); renderer.setClearColor(0xffffff, 1.0); }
......此處代碼省略......
function animation3D() {
cylinder.position.x -= 0.5;
renderer.render(scene, camera);
requestAnimationFrame(animation3D);
stats.update();
}
requestAnimationFrame(animation3D);
three.js學習:性能監視器stats.js的用法