Skip to content

Commit dcb3061

Browse files
authored
Add web tools
1 parent 0e53686 commit dcb3061

2 files changed

Lines changed: 98 additions & 0 deletions

File tree

web-tools/fps.html

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
layout: default
3+
title: Refresh Rate Test
4+
---
5+
6+
<style>
7+
body {
8+
margin: 0;
9+
background: #000;
10+
overflow: hidden;
11+
}
12+
13+
#gl {
14+
position: fixed;
15+
top: 0;
16+
left: 0;
17+
z-index: 0;
18+
}
19+
20+
#fps {
21+
position: fixed;
22+
top: 0;
23+
right: 0;
24+
padding: 2.5rem;
25+
z-index: 9999;
26+
transform: scale(1);
27+
transform-origin: top right;
28+
}
29+
30+
main {
31+
padding: 0;
32+
}
33+
</style>
34+
35+
<main>
36+
<div id="fps"></div>
37+
<canvas id="gl"></canvas>
38+
39+
<script src="https://cdn.jsdelivr.net/npm/three@0.152.2/build/three.min.js"></script>
40+
<script src="https://cdn.jsdelivr.net/npm/stats.js@0.17.0/build/stats.min.js"></script>
41+
42+
<script>
43+
const canvas = document.getElementById("gl");
44+
canvas.width = window.innerWidth;
45+
canvas.height = window.innerHeight;
46+
47+
const renderer = new THREE.WebGLRenderer({ canvas });
48+
renderer.setSize(window.innerWidth, window.innerHeight);
49+
renderer.setPixelRatio(window.devicePixelRatio);
50+
51+
const scene = new THREE.Scene();
52+
const camera = new THREE.PerspectiveCamera(
53+
75,
54+
window.innerWidth / window.innerHeight,
55+
0.1,
56+
1000
57+
);
58+
camera.position.z = 3;
59+
60+
const geometry = new THREE.BoxGeometry();
61+
const material = new THREE.MeshNormalMaterial();
62+
const cube = new THREE.Mesh(geometry, material);
63+
scene.add(cube);
64+
65+
const stats = new Stats();
66+
stats.showPanel(0);
67+
document.getElementById("fps").appendChild(stats.dom);
68+
69+
function animate() {
70+
stats.begin();
71+
cube.rotation.x += 0.01;
72+
cube.rotation.y += 0.01;
73+
renderer.render(scene, camera);
74+
stats.end();
75+
requestAnimationFrame(animate);
76+
}
77+
78+
animate();
79+
80+
window.addEventListener("resize", () => {
81+
camera.aspect = window.innerWidth / window.innerHeight;
82+
camera.updateProjectionMatrix();
83+
renderer.setSize(window.innerWidth, window.innerHeight);
84+
});
85+
</script>
86+
</main>

web-tools/index.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
layout: default
3+
title: Web Tools
4+
---
5+
6+
7+
<div class="dashboard">
8+
<a class="card" href="/web-tools/fps.html">
9+
<h2>🖥️ Frame Rate Tester</h2>
10+
<p>Render a simple cube to observe the current refresh rate of a device.</p>
11+
</a>
12+
</div>

0 commit comments

Comments
 (0)