私はhtmlキャンバスにフレーム/秒を表示しようとしています。私は後でそれを微調整することができるので、キャンバス上に置かれた場所は気にしません。ここで私がこれまで持っているもの:WebGL上でFPSを記録および表示する方法は?
var updateAnimation = function() {
requestAnimFrame(updateAnimation);
var anim = global.animation;
var e = global.events;
//Set current time
anim.animationCurrentTime = Date.now();
//Set start time
if (anim.animationStartTime === undefined) {
anim.animationStartTime = anim.animationCurrentTime;
}
//Clear the animationStage
webgl.clear(webgl.COLOR_BUFFER_BIT | webgl.DEPTH_BUFFER_BIT);
//Draw scene
drawScene();
//Set previous time as current time to use in next frame
anim.animationLastTime = anim.animationCurrentTime;
}
global.document.animationStage = document.getElementById("animation-scene");
webgl = setupScene(global.document.animationStage);
setupShaders();
setupAllBuffers();
setupEvents();
setupLight();
setupTextures();
initScene();
}
<header>
<h1 style="text-align: center">Applied Computer Graphics and Vision</h1>
<p>Instructions<span>
<br />
<br />
Rotation - \t Click and drag in the direction of rotation <br />
Increase/Decrease Orbit Radius - Up and Down Keys <br />
Increase/Decrease Orbit Speed - Left and Right Keys <br />
Translation Of X - Shift plus mouse drag <br />
Translation Of Y - Alt plus mouse drag <br />
Translation Of Z - Mouse scroll
</span></p>
</header>
<canvas style="float:left" ; id="animation-scene"></canvas>
<canvas id="myCanvas" width="1400" height="800"></canvas>
<script>
\t /* Sets */
var area = document.getElementById('animation-scene');
area.setAttribute('height', window.innerHeight);
area.setAttribute('width', window.innerWidth);
</script>
</body>
</html>
任意のヘルプまたはアドバイスは素晴らしいことです。私はレンダリングされたフレームの数を数えなければならないという基本的な考え方を知っています.1秒が経過するとfps変数に格納されますが、更新アニメーション機能でこれを実装する方法は不明です。
また、更新アニメーション機能内のシーンの現在/開始時刻を設定するメソッドもあります。
オーバーラップそれらを作るためにCSSを使用 – gaitat