Skip to content

Commit

Permalink
[Clean] lesson 46: clean the stats.js and remove the gui
Browse files Browse the repository at this point in the history
  • Loading branch information
trixky committed Aug 16, 2024
1 parent 3d0a085 commit 406dbf0
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/routes/lessons/46/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
const HEIGHT = 600;
const RATIO = WIDTH / HEIGHT;
let gui: GUI | null = null;
let stats: Stats | null = null;
function start() {
const pixelRatio = Math.min(window.devicePixelRatio, 2);
// fps stats
var stats = new Stats();
stats = new Stats();
stats.showPanel(0); // 0: fps, 1: ms, 2: mb, 3+: custom
document.body.appendChild(stats.dom);
Expand All @@ -35,9 +35,6 @@
base + "/optimization/displacementMap.png"
);
// Debug
gui = new GUI();
// Scene
const scene = new THREE.Scene();
Expand Down Expand Up @@ -211,7 +208,7 @@
// Animation
const tick = () => {
stats.begin();
stats!.begin();
const elapsedTime = clock.getElapsedTime();
torusKnot.rotation.y = elapsedTime * 0.1;
Expand All @@ -224,7 +221,7 @@
controls.update();
renderer.render(scene, camera);
stats.end();
stats!.end();
window.requestAnimationFrame(tick);
};
Expand All @@ -235,6 +232,10 @@
onMount(() => {
if (browser) {
start();
return () => {
stats?.dom.remove();
};
}
});
</script>
Expand Down

0 comments on commit 406dbf0

Please sign in to comment.