Created
September 30, 2023 20:23
-
-
Save RobiMez/4a8b1e1110f906db93d7134917095b27 to your computer and use it in GitHub Desktop.
Get a fps counter running with svelte and three
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { GPUStatsPanel } from 'three/addons/utils/GPUStatsPanel.js'; | |
import Stats from 'three/addons/libs/stats.module.js'; | |
import { useThrelte } from '@threlte/core'; | |
const { scene, renderer } = useThrelte(); | |
const stats = new Stats(); | |
document.body.appendChild(stats.dom); | |
const gpuPanel = new GPUStatsPanel(renderer.getContext()); | |
stats.addPanel(gpuPanel); | |
stats.showPanel(0); | |
const animate = () => { | |
stats.update(); | |
requestAnimationFrame(animate); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment