개발 · 컴퓨터공학

three.js 프레임 확인하기

2022. 8. 30. 15:53
728x90
반응형
npm i stats.js

프레임을 확인할 수 있는 stats.js라는 라이브러리가 있다.

 

import Stats from 'stats.js';

...

// Stats
const stats = new Stats();
document.body.append(stats.domElement);

function draw() {
    stats.update();
    mesh.rotation.y = time;

    renderer.render(scene, camera);
    renderer.setAnimationLoop(draw);
}

stats 라이브러리를 import하고, Stats domElement를 추가한 후 매 draw마다 stats을 update하여 FPS를 표시할 수 있다.

728x90
반응형